bprocessor-commit Mailing List for B-processor (Page 84)
Status: Pre-Alpha
Brought to you by:
henryml
You can subscribe to this list here.
| 2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(12) |
Jul
(117) |
Aug
(151) |
Sep
(157) |
Oct
(81) |
Nov
(117) |
Dec
(119) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2006 |
Jan
(183) |
Feb
(130) |
Mar
(117) |
Apr
(61) |
May
(82) |
Jun
(45) |
Jul
(149) |
Aug
(173) |
Sep
(199) |
Oct
(165) |
Nov
(107) |
Dec
(137) |
| 2007 |
Jan
(124) |
Feb
(58) |
Mar
(123) |
Apr
(80) |
May
(130) |
Jun
(64) |
Jul
(31) |
Aug
(42) |
Sep
(114) |
Oct
(167) |
Nov
(239) |
Dec
(200) |
| 2008 |
Jan
(43) |
Feb
(43) |
Mar
(4) |
Apr
(9) |
May
(5) |
Jun
(1) |
Jul
(3) |
Aug
(3) |
Sep
(13) |
Oct
(9) |
Nov
(12) |
Dec
|
| 2009 |
Jan
|
Feb
(20) |
Mar
(7) |
Apr
(12) |
May
(34) |
Jun
(72) |
Jul
|
Aug
(3) |
Sep
(31) |
Oct
(2) |
Nov
(8) |
Dec
(4) |
| 2010 |
Jan
(5) |
Feb
(32) |
Mar
(8) |
Apr
(7) |
May
(36) |
Jun
|
Jul
(11) |
Aug
(15) |
Sep
(7) |
Oct
(2) |
Nov
(13) |
Dec
(80) |
| 2011 |
Jan
|
Feb
|
Mar
(8) |
Apr
(12) |
May
(32) |
Jun
(9) |
Jul
(5) |
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
(8) |
| 2012 |
Jan
|
Feb
|
Mar
(3) |
Apr
(5) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(22) |
Jun
(5) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Nikolaj B. <nbr...@us...> - 2006-12-18 12:08:29
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv32143/src/net/sourceforge/bprocessor/model Modified Files: Project.java Log Message: fixed type error in file import name Index: Project.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Project.java,v retrieving revision 1.100 retrieving revision 1.101 diff -C2 -d -r1.100 -r1.101 *** Project.java 17 Dec 2006 20:23:36 -0000 1.100 --- Project.java 18 Dec 2006 12:08:27 -0000 1.101 *************** *** 797,801 **** if (construction) { bf = new BufferedReader ! (new InputStreamReader(new FileInputStream("construction2.txt"), "ISO-8859-1")); clas = new Classification(0); parent = new Classification(0); --- 797,801 ---- if (construction) { bf = new BufferedReader ! (new InputStreamReader(new FileInputStream("constructions.txt"), "ISO-8859-1")); clas = new Classification(0); parent = new Classification(0); *************** *** 941,944 **** --- 941,950 ---- } + public Classification getProduktType(Classification clas, String id) { + Classification temp = getType(clas.getProdukt()); + + return temp; + } + /** * This method loads the product types from a file |
|
From: rimestad <rim...@us...> - 2006-12-18 09:11:55
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv25789/src/net/sourceforge/bprocessor/model Modified Files: ClippingPlane.java Camera.java Persistence.java Log Message: Added the views and clipplanes to the xml file, does not make any changes to the shema so old files should still be working There is one thing the externalization makes the clipplanes unique for each view should it be so or shouldn't it???? Index: Persistence.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Persistence.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** Persistence.java 5 Dec 2006 20:40:52 -0000 1.28 --- Persistence.java 18 Dec 2006 09:11:47 -0000 1.29 *************** *** 10,13 **** --- 10,15 ---- import net.sourceforge.bprocessor.model.xml.AxisRotateType; import net.sourceforge.bprocessor.model.xml.Bmodel; + import net.sourceforge.bprocessor.model.xml.CameraType; + import net.sourceforge.bprocessor.model.xml.ClipplaneType; import net.sourceforge.bprocessor.model.xml.ConstructorType; import net.sourceforge.bprocessor.model.xml.CoordinateSystemType; *************** *** 30,37 **** --- 32,42 ---- import net.sourceforge.bprocessor.model.xml.TransformType; import net.sourceforge.bprocessor.model.xml.TranslateType; + import net.sourceforge.bprocessor.model.xml.TripletType; import net.sourceforge.bprocessor.model.xml.VertexType; import net.sourceforge.bprocessor.model.xml.VertexesType; import net.sourceforge.bprocessor.model.xml.impl.AxisRotateTypeImpl; import net.sourceforge.bprocessor.model.xml.impl.BmodelImpl; + import net.sourceforge.bprocessor.model.xml.impl.CameraTypeImpl; + import net.sourceforge.bprocessor.model.xml.impl.ClipplaneTypeImpl; import net.sourceforge.bprocessor.model.xml.impl.CoordinateSystemTypeImpl; import net.sourceforge.bprocessor.model.xml.impl.DoubleTypeImpl; *************** *** 51,54 **** --- 56,60 ---- import net.sourceforge.bprocessor.model.xml.impl.SurfaceImpl; import net.sourceforge.bprocessor.model.xml.impl.TranslateTypeImpl; + import net.sourceforge.bprocessor.model.xml.impl.TripletTypeImpl; import net.sourceforge.bprocessor.model.xml.impl.VertexImpl; import net.sourceforge.bprocessor.model.xml.impl.VertexesTypeImpl; *************** *** 119,122 **** --- 125,159 ---- p.setName(document.getName()); p.changed(p); + { + Iterator iter = document.getCamera().iterator(); + while (iter.hasNext()) { + CameraType ct = (CameraType) iter.next(); + Camera cam = new Camera(); + cam.setName(ct.getName()); + TripletType campos = ct.getCamera(); + cam.setCamera(new double[]{campos.getX(), campos.getY(), campos.getZ()}); + TripletType cenpos = ct.getCenter(); + cam.setCenter(new double[]{cenpos.getX(), cenpos.getY(), cenpos.getZ()}); + TripletType up = ct.getRoll(); + cam.setRoll(new double[]{up.getX(), up.getY(), up.getZ()}); + Collection clips = ct.getClipplanes(); + Iterator clipit = clips.iterator(); + while (clipit.hasNext()) { + ClipplaneType cpt = (ClipplaneType)clipit.next(); + CoordinateSystemType cst = cpt.getCoordinateSystem(); + CoordinateSystem cs = internalizeCoordinateSystem(cst, new HashMap(), new LinkedList()); + ClippingPlane cp = new ClippingPlane(cs); + cp.setId(new Long(cpt.getId())); + cp.setActive(cpt.isActive()); + cp.setNumber(cpt.getNumber()); + cp.setSlice(cpt.isSlice()); + cam.addClipplane(cp); + } + cam.setFocalwidth(ct.getFocalwidth()); + cam.setId(new Long(ct.getProgid())); + cam.setType(ct.getType()); + p.add(cam); + } + } } *************** *** 665,668 **** --- 702,754 ---- document.setActive(id(mapper, Project.getInstance().getActiveSpace())); document.setName(Project.getInstance().getName()); + + { + Collection cams = document.getCamera(); + Iterator iter = Project.getInstance().getCameras().iterator(); + while (iter.hasNext()) { + Camera c = (Camera) iter.next(); + CameraType cam = new CameraTypeImpl(); + cam.setName(c.getName()); + TripletType campos = new TripletTypeImpl(); + campos.setX(c.getCamera()[0]); + campos.setY(c.getCamera()[1]); + campos.setZ(c.getCamera()[2]); + cam.setCamera(campos); + TripletType cenpos = new TripletTypeImpl(); + cenpos.setX(c.getCenter()[0]); + cenpos.setY(c.getCenter()[1]); + cenpos.setZ(c.getCenter()[2]); + cam.setCenter(cenpos); + TripletType up = new TripletTypeImpl(); + up.setX(c.getRoll()[0]); + up.setY(c.getRoll()[1]); + up.setZ(c.getRoll()[2]); + cam.setRoll(up); + Collection clips = c.getClipplanes(); + Iterator clipit = clips.iterator(); + while (clipit.hasNext()) { + ClippingPlane cp = (ClippingPlane)clipit.next(); + ClipplaneType cpt = new ClipplaneTypeImpl(); + CoordinateSystemType cst = + externalizeCoordinateSystem(cp.getCoordinateSystem(), new HashMap()); + cpt.setCoordinateSystem(cst); + cpt.setId(counter++); + if (cp.getId() != null) { + cpt.setProgid(cp.getId().longValue()); + } + cpt.setNumber(cp.getNumber()); + cpt.setSlice(cp.isSlice()); + cpt.setActive(cp.isActive()); + cam.getClipplanes().add(cpt); + } + cam.setFocalwidth(c.getFocalwidth()); + if (c.getId() != null) { + cam.setProgid(c.getId().longValue()); + } + cam.setId(counter++); + cam.setType(c.getType()); + cams.add(cam); + } + } return document; } *************** *** 866,910 **** Map map) { if (constructor instanceof Point) { ! PointType xml = new PointTypeImpl(); ! xml.setId(counter++); ! xml.setProgid(constructor.getId().longValue()); ! xml.setActive(constructor.isActive()); ! xml.setEditable(constructor.isEditable()); ! VertexType orig = externalizeVertex(constructor.getOrigin(), new HashMap()); ! xml.setVertex(orig); ! map.put(constructor, xml); ! return xml; } else if (constructor instanceof Line) { ! LineType xml = new LineTypeImpl(); ! VertexesType vt = new VertexesTypeImpl(); ! vt.getVertex().add(externalizeVertex(((Line)constructor).getDirection(), ! new HashMap())); ! ((LineType)xml).setDirection(vt); ! xml.setId(counter++); ! xml.setProgid(constructor.getId().longValue()); ! xml.setActive(constructor.isActive()); ! xml.setEditable(constructor.isEditable()); ! VertexType orig = externalizeVertex(constructor.getOrigin(), new HashMap()); ! xml.setVertex(orig); ! map.put(constructor, xml); ! return xml; } else if (constructor instanceof CoordinateSystem) { ! CoordinateSystem cs = (CoordinateSystem)constructor; ! CoordinateSystemType xml = new CoordinateSystemTypeImpl(); ! xml.setOnlyplane(((CoordinateSystem)constructor).onlyPlane()); ! VertexesType vt = new VertexesTypeImpl(); ! List ijn = vt.getVertex(); ! ijn.add(0, externalizeVertex(cs.getI(), new HashMap())); ! ijn.add(1, externalizeVertex(cs.getJ(), new HashMap())); ! ijn.add(2, externalizeVertex(cs.getN(), new HashMap())); ! xml.setIjn(vt); ! xml.setId(counter++); ! xml.setProgid(constructor.getId().longValue()); ! xml.setActive(constructor.isActive()); ! xml.setEditable(constructor.isEditable()); ! VertexType orig = externalizeVertex(constructor.getOrigin(), new HashMap()); ! xml.setVertex(orig); ! map.put(constructor, xml); ! return xml; } else { log.error(constructor + " were of unknown type"); --- 952,960 ---- Map map) { if (constructor instanceof Point) { ! return externalizePoint((Point)constructor, map); } else if (constructor instanceof Line) { ! return externalizeLine((Line)constructor, map); } else if (constructor instanceof CoordinateSystem) { ! return externalizeCoordinateSystem((CoordinateSystem)constructor, map); } else { log.error(constructor + " were of unknown type"); *************** *** 913,916 **** --- 963,1031 ---- } + + /** + * @param cs the coordinatesystem object to externalize + * @param map the map to put the object to xml reference into + * @return the xml object + */ + private static CoordinateSystemType externalizeCoordinateSystem(CoordinateSystem cs, Map map) { + CoordinateSystemType xml = new CoordinateSystemTypeImpl(); + xml.setOnlyplane(cs.onlyPlane()); + VertexesType vt = new VertexesTypeImpl(); + List ijn = vt.getVertex(); + ijn.add(0, externalizeVertex(cs.getI(), new HashMap())); + ijn.add(1, externalizeVertex(cs.getJ(), new HashMap())); + ijn.add(2, externalizeVertex(cs.getN(), new HashMap())); + xml.setIjn(vt); + xml.setId(counter++); + if (cs.getId() != null) { + xml.setProgid(cs.getId().longValue()); + } + xml.setActive(cs.isActive()); + xml.setEditable(cs.isEditable()); + VertexType orig = externalizeVertex(cs.getOrigin(), new HashMap()); + xml.setVertex(orig); + map.put(cs, xml); + return xml; + } + + /** + * @param line the line object to externalize + * @param map the map to put the object to xml reference into + * @return the xml object + */ + private static LineType externalizeLine(Line line, Map map) { + LineType xml = new LineTypeImpl(); + VertexesType vt = new VertexesTypeImpl(); + vt.getVertex().add(externalizeVertex(line.getDirection(), + new HashMap())); + ((LineType)xml).setDirection(vt); + xml.setId(counter++); + xml.setProgid(line.getId().longValue()); + xml.setActive(line.isActive()); + xml.setEditable(line.isEditable()); + VertexType orig = externalizeVertex(line.getOrigin(), new HashMap()); + xml.setVertex(orig); + map.put(line, xml); + return xml; + } + + /** + * @param point the point object to externalize + * @param map the map to put the object to xml reference into + * @return the xml object + */ + private static PointType externalizePoint(Point point, Map map) { + PointType xml = new PointTypeImpl(); + xml.setId(counter++); + xml.setProgid(point.getId().longValue()); + xml.setActive(point.isActive()); + xml.setEditable(point.isEditable()); + VertexType orig = externalizeVertex(point.getOrigin(), new HashMap()); + xml.setVertex(orig); + map.put(point, xml); + return xml; + } + /** * Create an xml SurfaceImpl and place it in the map Index: Camera.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Camera.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** Camera.java 17 Nov 2006 15:47:28 -0000 1.29 --- Camera.java 18 Dec 2006 09:11:47 -0000 1.30 *************** *** 64,67 **** --- 64,68 ---- */ Camera() { + this.clipplanes = new ArrayList(); } Index: ClippingPlane.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/ClippingPlane.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** ClippingPlane.java 13 Nov 2006 14:56:14 -0000 1.14 --- ClippingPlane.java 18 Dec 2006 09:11:46 -0000 1.15 *************** *** 396,398 **** --- 396,412 ---- update(); } + + /** + * @return Returns the cs. + */ + public CoordinateSystem getCoordinateSystem() { + return cs; + } + + /** + * @param cs The cs to set. + */ + public void setCoordinateSystem(CoordinateSystem cs) { + this.cs = cs; + } } |
|
From: rimestad <rim...@us...> - 2006-12-18 09:11:55
|
Update of /cvsroot/bprocessor/model/src/etc In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv25789/src/etc Modified Files: bprocessor.xsd Log Message: Added the views and clipplanes to the xml file, does not make any changes to the shema so old files should still be working There is one thing the externalization makes the clipplanes unique for each view should it be so or shouldn't it???? Index: bprocessor.xsd =================================================================== RCS file: /cvsroot/bprocessor/model/src/etc/bprocessor.xsd,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** bprocessor.xsd 5 Dec 2006 20:40:52 -0000 1.24 --- bprocessor.xsd 18 Dec 2006 09:11:47 -0000 1.25 *************** *** 45,51 **** <xsd:complexType name="TripletType"> ! <xsd:attribute name="x" type="xsd:int" use="required"/> ! <xsd:attribute name="y" type="xsd:int" use="required"/> ! <xsd:attribute name="z" type="xsd:int" use="required"/> </xsd:complexType> --- 45,51 ---- <xsd:complexType name="TripletType"> ! <xsd:attribute name="x" type="xsd:double" use="required"/> ! <xsd:attribute name="y" type="xsd:double" use="required"/> ! <xsd:attribute name="z" type="xsd:double" use="required"/> </xsd:complexType> *************** *** 59,63 **** <xsd:attribute name="friend" type="xsd:long"/> <xsd:attribute name="number" type="xsd:int" use="required"/> ! <xsd:attribute name="clipdepth" type="xsd:double" use="required"/> </xsd:extension> </xsd:complexContent> --- 59,63 ---- <xsd:attribute name="friend" type="xsd:long"/> <xsd:attribute name="number" type="xsd:int" use="required"/> ! <xsd:attribute name="Slice" type="xsd:boolean" use="required"/> </xsd:extension> </xsd:complexContent> *************** *** 75,78 **** --- 75,79 ---- <xsd:element name="clipplanes" type="ClipplaneType" maxOccurs="unbounded" minOccurs="0"/> </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required"/> </xsd:extension> </xsd:complexContent> |
|
From: Nikolaj B. <nbr...@us...> - 2006-12-17 20:26:59
|
Update of /cvsroot/bprocessor/bprocessor In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv22341 Added Files: typer.txt Log Message: The produkt types --- NEW FILE: typer.txt --- (This appears to be a binary file; contents omitted.) |
|
From: Nikolaj B. <nbr...@us...> - 2006-12-17 20:24:52
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv21567/src/net/sourceforge/bprocessor/gl/tool Modified Files: CreateSpaceActionListener.java Log Message: Changed default names of new spaces Index: CreateSpaceActionListener.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/CreateSpaceActionListener.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** CreateSpaceActionListener.java 19 Nov 2006 21:49:02 -0000 1.13 --- CreateSpaceActionListener.java 17 Dec 2006 20:24:50 -0000 1.14 *************** *** 75,81 **** Space space; if (functional) { ! space = owner.createFunctionalSpace("Unspecified"); } else { ! space = owner.createConstructionSpace("Unspecified"); } owner.add(space); --- 75,81 ---- Space space; if (functional) { ! space = owner.createFunctionalSpace("Functional"); } else { ! space = owner.createConstructionSpace("Construction"); } owner.add(space); |
|
From: Nikolaj B. <nbr...@us...> - 2006-12-17 20:24:14
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv21509/src/net/sourceforge/bprocessor/gui/attrview Modified Files: ClassificationTextAttribute.java GenericPanel.java Log Message: Implemented produkttypes for the classifications Index: GenericPanel.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview/GenericPanel.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** GenericPanel.java 16 Nov 2006 23:20:04 -0000 1.28 --- GenericPanel.java 17 Dec 2006 20:24:12 -0000 1.29 *************** *** 209,213 **** where.add(new AttributeRow(catext)); if (a.getClassification() != null && ! !a.getClassification().getId().equalsIgnoreCase("-1")) { // Handles the id part of classification ClassificationIdAttribute caid = new ClassificationIdAttribute(a); --- 209,214 ---- where.add(new AttributeRow(catext)); if (a.getClassification() != null && ! !a.getClassification().getId().equalsIgnoreCase("-1") && ! a.getLevel() != 4) { // Handles the id part of classification ClassificationIdAttribute caid = new ClassificationIdAttribute(a); Index: ClassificationTextAttribute.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview/ClassificationTextAttribute.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ClassificationTextAttribute.java 16 Nov 2006 23:20:04 -0000 1.3 --- ClassificationTextAttribute.java 17 Dec 2006 20:24:12 -0000 1.4 *************** *** 57,60 **** --- 57,63 ---- private JLabel icon; + /** The label */ + private JLabel label; + /** The popup menu */ private JPopupMenu classification; *************** *** 71,75 **** public ClassificationTextAttribute(Attribute attribute) { super(BoxLayout.X_AXIS); ! this.attribute = attribute; this.listeners = new LinkedList(); --- 74,78 ---- public ClassificationTextAttribute(Attribute attribute) { super(BoxLayout.X_AXIS); ! label = new JLabel(attribute.getName() + ": "); this.attribute = attribute; this.listeners = new LinkedList(); *************** *** 77,87 **** component = Box.createHorizontalBox(); if (attribute.getClassification() != null) { ! component.add((JLabel) createValueLabel(attribute.getClassification())); } else { ! component.add(new JLabel("Classification")); } createMenu(attribute.getValue()); Box header = Box.createHorizontalBox(); header.add(Box.createHorizontalStrut(7)); header.add(component); header.add(Box.createHorizontalGlue()); --- 80,96 ---- component = Box.createHorizontalBox(); if (attribute.getClassification() != null) { ! JLabel cur = (JLabel) createValueLabel(attribute.getClassification()); ! cur.setFont(AttributeView.FONT_PLAIN); ! component.add(cur); } else { ! JLabel cur = new JLabel("unassigned"); ! cur.setFont(AttributeView.FONT_PLAIN); ! component.add(cur); } createMenu(attribute.getValue()); Box header = Box.createHorizontalBox(); header.add(Box.createHorizontalStrut(7)); + + header.add(label); header.add(component); header.add(Box.createHorizontalGlue()); *************** *** 102,105 **** --- 111,115 ---- */ public void addMouseListener(MouseListener mouseListener) { + label.addMouseListener(mouseListener); component.addMouseListener(mouseListener); icon.addMouseListener(this); *************** *** 299,303 **** if (((Classification) attribute.getValue()).getType() == 0) { cur.addAll(Project.getInstance().getClassification("-99", 0).getChildren()); ! } else { cur.addAll(Project.getInstance().getClassification("-99", 1).getChildren()); } --- 309,314 ---- if (((Classification) attribute.getValue()).getType() == 0) { cur.addAll(Project.getInstance().getClassification("-99", 0).getChildren()); ! } ! if (((Classification) attribute.getValue()).getType() == 0) { cur.addAll(Project.getInstance().getClassification("-99", 1).getChildren()); } |
|
From: Nikolaj B. <nbr...@us...> - 2006-12-17 20:23:47
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv21118/src/net/sourceforge/bprocessor/model Modified Files: Classification.java Space.java Project.java Log Message: Implemented produkttypes for the classifications, and the loading of the file containing them. Index: Space.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Space.java,v retrieving revision 1.106 retrieving revision 1.107 diff -C2 -d -r1.106 -r1.107 *** Space.java 5 Dec 2006 15:21:19 -0000 1.106 --- Space.java 17 Dec 2006 20:23:36 -0000 1.107 *************** *** 125,128 **** --- 125,131 ---- private Classification classification; + /** The classification */ + private Classification productType; + /** If the constructionspace is transparent */ private boolean transparent; *************** *** 132,160 **** - /** The construcstionspace classification options */ - private String[] constructionOptions = - {"None", "Terrandæk", "Tagkonstruktion", "Ydervæg", "Ældre termovindue", - "2-lags lavenergivindue", "3-lags lavenergivindue", "Dør", "Loft"}; - - /** The functionalspace classification options */ - private String[] functionalOptions = - {"None", "Exteriør", "Stue", "Badeværelse", "Opvarmet rum", "Uopvarmet rum"}; - - /** The construcstionspace on part element, classification options */ - private String[] elementConstructionOptions = - {"None", "Karm", "Sprosse", "Post", "Vindue 2lag termo", "Vindue 3lag termo"}; - - /** The functionalspace on part element, classification options */ - private String[] elementFunctionalOptions = - {"None"}; - - /** The construcstionspace on part level, classification options */ - private String[] partConstructionOptions = - {"None"}; - - /** The functionalspace on part level, classification options */ - private String[] partFunctionalOptions = - {"None"}; - /** The modellor */ private Modellor modellor; --- 135,138 ---- *************** *** 1145,1148 **** --- 1123,1141 ---- } + /** + * Return the product type + * @return The product type + */ + public Classification getTypeClassification() { + return productType; + } + /** + * Set the product type + * @param productType The product type + */ + public void setTypeClassification(Classification productType) { + this.productType = productType; + } + *************** *** 1492,1495 **** --- 1485,1490 ---- setClassification(((Classification)a.getClassification())); } + } else if (a.getName().equals("Type")) { + setTypeClassification((((Classification)a.getClassification()))); } else if (a.getName().equals("Transparent")) { setTransparent((((Boolean)a.getValue()).booleanValue())); *************** *** 1555,1558 **** --- 1550,1557 ---- } } + if (getClassification() != null && !getClassification().getProdukt().equalsIgnoreCase("")) { + res.add(new Attribute("Type", Project.getInstance(). + getType(getClassification().getName()), getTypeClassification(), 4)); + } res.add(new Attribute("ID", getId().toString(), false)); res.add(new Attribute("Owner", getOwner(), false)); *************** *** 1643,1647 **** return getClassification().toString() + " - " + res + id; } else { ! return name + " - " + res + id; } } --- 1642,1650 ---- return getClassification().toString() + " - " + res + id; } else { ! if (name.equalsIgnoreCase("Void")) { ! return name; ! } else { ! return name + " - " + res + id; ! } } } Index: Classification.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Classification.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Classification.java 16 Nov 2006 23:20:39 -0000 1.4 --- Classification.java 17 Dec 2006 20:23:36 -0000 1.5 *************** *** 30,33 **** --- 30,37 ---- private Classification parent; + /** The type of this classification */ + private String produkt; + + /** Construction Type */ public static final int CONSTRUCTION = 0; *************** *** 36,39 **** --- 40,46 ---- public static final int FUNCTIONAL = 1; + /** functional Type */ + public static final int TYPES = 2; + /** type */ private int type; *************** *** 51,54 **** --- 58,62 ---- setType(type); setParent(parent); + setProdukt(""); } *************** *** 62,65 **** --- 70,74 ---- setType(type); setId(new String("-1")); + setProdukt(""); } *************** *** 72,75 **** --- 81,85 ---- setId(new String("0")); setType(type); + setProdukt(""); } *************** *** 179,182 **** --- 189,209 ---- } + + /** + * Get the different types for this classification + * @return produkt the produkt types + */ + public String getProdukt() { + return produkt; + } + + /** + * Set the produkt type for this classification + * @param produkt the produkt types + */ + public void setProdukt(String produkt) { + this.produkt = produkt; + } + Index: Project.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Project.java,v retrieving revision 1.99 retrieving revision 1.100 diff -C2 -d -r1.99 -r1.100 *** Project.java 3 Dec 2006 17:50:36 -0000 1.99 --- Project.java 17 Dec 2006 20:23:36 -0000 1.100 *************** *** 53,56 **** --- 53,59 ---- private Classification functionalClas = new Classification(1); + /** The classification */ + private Classification typesClas = new Classification(2); + /** The cameras */ private HashMap cameras = new HashMap(); *************** *** 140,143 **** --- 143,147 ---- loadClassification(true); loadClassification(false); + loadTypes(); } catch (Exception e) { System.out.println("loading classification"); *************** *** 785,788 **** --- 789,793 ---- String curname = ""; String curid; + boolean clasmade = false; Classification parent; Classification last; *************** *** 792,796 **** if (construction) { bf = new BufferedReader ! (new InputStreamReader(new FileInputStream("constructions.txt"), "ISO-8859-1")); clas = new Classification(0); parent = new Classification(0); --- 797,801 ---- if (construction) { bf = new BufferedReader ! (new InputStreamReader(new FileInputStream("construction2.txt"), "ISO-8859-1")); clas = new Classification(0); parent = new Classification(0); *************** *** 808,850 **** while (st.hasMoreTokens()) { token = st.nextToken(); ! if (depth == 0 && !token.equalsIgnoreCase(";")) { ! curid = new String(token); ! st.nextToken(); ! curname = st.nextToken(); ! Classification curclas; ! if (construction) { ! curclas = new Classification(curid, curname, clas, 0); ! } else { ! curclas = new Classification(curid, curname, clas, 1); ! } ! parent = curclas; ! clas.addChild(curclas); ! lastdepth = 0; ! last = curclas; ! } else if (token.equalsIgnoreCase(";")) { ! depth++; ! } else if (depth != 0 && !token.equalsIgnoreCase(";")) { ! curid = new String(token); ! st.nextToken(); ! curname = st.nextToken(); ! if (depth > lastdepth) { ! parent = last; ! } ! if (depth < lastdepth) { ! parent = parent.getParent(); ! } ! Classification curclas; ! if (construction) { ! curclas = new Classification(curid, curname, parent, 0); ! } else { ! curclas = new Classification(curid, curname, parent, 1); } ! parent.addChild(curclas); ! last = curclas; ! lastdepth = depth; ! } } depth = 0; current = bf.readLine(); } if (construction) { --- 813,867 ---- while (st.hasMoreTokens()) { token = st.nextToken(); ! if (!clasmade) { ! if (depth == 0 && !token.equalsIgnoreCase(";")) { ! curid = new String(token); ! st.nextToken(); ! curname = st.nextToken(); ! Classification curclas; ! if (construction) { ! curclas = new Classification(curid, curname, clas, 0); ! clasmade = true; ! } else { ! curclas = new Classification(curid, curname, clas, 1); ! clasmade = true; ! } ! parent = curclas; ! clas.addChild(curclas); ! lastdepth = 0; ! last = curclas; ! } else if (token.equalsIgnoreCase(";")) { ! depth++; ! } else if (depth != 0 && !token.equalsIgnoreCase(";")) { ! curid = new String(token); ! st.nextToken(); ! curname = st.nextToken(); ! if (depth > lastdepth) { ! parent = last; ! } ! if (depth < lastdepth) { ! parent = parent.getParent(); ! } ! Classification curclas; ! if (construction) { ! curclas = new Classification(curid, curname, parent, 0); ! clasmade = true; ! } else { ! curclas = new Classification(curid, curname, parent, 1); ! clasmade = true; ! } ! parent.addChild(curclas); ! last = curclas; ! lastdepth = depth; ! } ! } else { ! if (!token.equalsIgnoreCase(";")) { ! last.setProdukt(token); ! //System.out.println(token); } ! } } depth = 0; current = bf.readLine(); + clasmade = false; } if (construction) { *************** *** 923,927 **** --- 940,1035 ---- return cl; } + + /** + * This method loads the product types from a file + * @exception Exception Thrown if an exception occurs + */ + public void loadTypes() throws Exception { + BufferedReader bf; + bf = new BufferedReader( + new InputStreamReader(new FileInputStream("typer.txt"), "ISO-8859-1")); + Classification clas; + String current = ""; + String token = ""; + String curname = ""; + String curid; + boolean clasmade = false; + Classification parent; + Classification last; + clas = new Classification(2); + parent = new Classification(2); + last = new Classification(2); + int depth = 0; + int lastdepth = 0; + current = bf.readLine(); + while (!current.equalsIgnoreCase("--stop--")) { + StringTokenizer st = new StringTokenizer(current, ";", true); + while (st.hasMoreTokens()) { + token = st.nextToken(); + if (!clasmade) { + if (depth == 0 && !token.equalsIgnoreCase(";")) { + curname = new String(token); + Classification curclas; + curclas = new Classification("0", curname, clas, 2); + clasmade = true; + parent = curclas; + clas.addChild(curclas); + lastdepth = 0; + last = curclas; + } else if (token.equalsIgnoreCase(";")) { + depth++; + } else if (depth != 0 && !token.equalsIgnoreCase(";")) { + curid = new String(token); + st.nextToken(); + curname = st.nextToken(); + if (depth > lastdepth) { + parent = last; + } + if (depth < lastdepth) { + parent = parent.getParent(); + } + Classification curclas; + curclas = new Classification(curid, curname, parent, 0); + clasmade = true; + parent.addChild(curclas); + last = curclas; + lastdepth = depth; + } + } + } + depth = 0; + current = bf.readLine(); + clasmade = false; + } + typesClas = clas; + } + /** + * GetType returns the type of this classification + * @param name the name of the classification + * @return temp the type + */ + public Classification getType(String name) { + Classification temp = null; + Iterator it = typesClas.getChildren().iterator(); + while (it.hasNext()) { + temp = (Classification) it.next(); + if (temp.getName().equalsIgnoreCase(name)) { + return temp; + } + } + return null; + } + + + /** + * Get the types classification + * @return typesClas the types classification + */ + public Classification getTypesClas() { + return typesClas; + } + + /** * getter for the copy buffer |
|
From: rimestad <rim...@us...> - 2006-12-13 17:45:23
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv17910/src/net/sourceforge/bprocessor/model Modified Files: Plane.java Log Message: Made a additional constructor for plane takin the normal and a point in the plane Index: Plane.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Plane.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** Plane.java 7 Nov 2006 10:51:24 -0000 1.26 --- Plane.java 13 Dec 2006 17:45:17 -0000 1.27 *************** *** 61,64 **** --- 61,78 ---- /** + * Constructor + * @param a the a + * @param b the b + * @param c the c + * @param point a point in the plane + */ + public Plane(double a, double b, double c, Vertex point) { + this.a = a; + this.b = b; + this.c = c; + this.d = -(a * point.getX() + b * point.getY() + c * point.getZ()); + } + + /** * Return a doublearray {a,b,c,d} * @return The array |
|
From: rimestad <rim...@us...> - 2006-12-13 17:44:20
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv17485/src/net/sourceforge/bprocessor/model Modified Files: Line.java Log Message: made method to get a vertex some extend from the origin along the direction Index: Line.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Line.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** Line.java 3 Dec 2006 17:51:23 -0000 1.28 --- Line.java 13 Dec 2006 17:44:16 -0000 1.29 *************** *** 178,181 **** --- 178,192 ---- /** + * A point t times the direction from the origin of the line + * @param t the t value + * @return the point + */ + public Vertex getPointAt(double t) { + Vertex tmp = dir.copy(); + tmp.scale(t); + return getOrigin().add(tmp); + } + + /** * @see net.sourceforge.bprocessor.model.Parametric#getGeneralName() */ |
|
From: rimestad <rim...@us...> - 2006-12-13 17:43:35
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv17078/src/net/sourceforge/bprocessor/model Modified Files: Geometry.java Log Message: Removed Math.toDegree duplicating method Index: Geometry.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Geometry.java,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** Geometry.java 12 Dec 2006 09:50:39 -0000 1.39 --- Geometry.java 13 Dec 2006 17:43:29 -0000 1.40 *************** *** 330,342 **** /** - * Convert radian to degree - * @param radianAngle the radian angle - * @return the angle - */ - public static double radianToDegree(double radianAngle) { - return radianAngle * Math.PI / 180; - } - - /** * Calculate the rotation of a direction vector about the z-axis * @param dir The direction vector --- 330,333 ---- |
|
From: rimestad <rim...@us...> - 2006-12-13 17:42:53
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16686/src/net/sourceforge/bprocessor/gl/tool Modified Files: RotationTool.java Log Message: made some major changes to the rotation tool Index: RotationTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/RotationTool.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** RotationTool.java 5 Dec 2006 09:07:25 -0000 1.21 --- RotationTool.java 13 Dec 2006 17:42:45 -0000 1.22 *************** *** 7,17 **** --- 7,26 ---- package net.sourceforge.bprocessor.gl.tool; + import net.java.games.jogl.GL; + import net.java.games.jogl.GLDrawable; + import net.java.games.jogl.GLU; import net.sourceforge.bprocessor.gl.GLView; + import net.sourceforge.bprocessor.gl.model.GlObject; import net.sourceforge.bprocessor.gl.model.Intersection; + import net.sourceforge.bprocessor.gui.GUI; + import net.sourceforge.bprocessor.model.Camera; import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Geometry; import net.sourceforge.bprocessor.model.Line; + import net.sourceforge.bprocessor.model.Plane; + import net.sourceforge.bprocessor.model.Project; import net.sourceforge.bprocessor.model.Selection; + import net.sourceforge.bprocessor.model.Surface; import net.sourceforge.bprocessor.model.Vertex; *************** *** 36,45 **** /** The vertexes to rotate */ private Set vertices = new HashSet(); ! /***/ ! private Intersection p1; ! /***/ ! private Intersection p2; ! /***/ ! private Line l; /** * The Constructor --- 45,65 ---- /** The vertexes to rotate */ private Set vertices = new HashSet(); ! /** The first pressed point */ ! private Vertex p1; ! /** The secondly pressed point*/ ! private Vertex p2; ! /** The starting rotation point*/ ! private Vertex from; ! /** the previous vertex when moving the mouse */ ! private Vertex previous; ! /** The plane whose normal is rotated aboud */ ! private Plane onto; ! /** The gl object drawing the rotation circle */ ! private GlProtractor pro; ! /** The total rotation angle */ ! private double totalAngle; ! /** The set of object not to hit */ ! private Set nothits = new HashSet(); ! /** * The Constructor *************** *** 58,61 **** --- 78,124 ---- process(e); } + + /** + * @param e MouseEvent + */ + protected void moved(MouseEvent e) { + current = findIntersection(e); + if (current != null) { + updateFeedback(); + if (previous != null) { + //find the angle to rotate + Vertex to = onto.projection(current.vertex()); + double angle = (previous.minus(p1).angle(to.minus(p1))); + if ((previous.minus(p1).cross(to.minus(p1))).angle(p2.minus(p1)) > 0) { + angle *= -1; + } + if (angle != Double.NaN) { + totalAngle = (totalAngle + angle) % (2 * Math.PI); + rotate(angle); + } + previous = onto.projection(current.vertex()); + } + } + } + + /** + * Invoked when a mouse button has been released on a component. + * @param e The MouseEvent + */ + protected void released(MouseEvent e) { + + } + + /** + * Update the length field + */ + protected void updateLength() { + double angle = 0; + if (p1 != null && p2 != null && from != null && current != null) { + angle = Math.toDegrees(totalAngle); + setLength(angle / 1000); + pro.setAngle((int)angle); + } + } /** *************** *** 71,110 **** */ private void process(MouseEvent e) { ! if (p1 == null) { ! p1 = current; ! start = p1; ! active = true; ! } else if (p2 == null) { ! p2 = current; ! start = p2; ! active = true; } else { ! if (start == p2) { ! //finish tool ! current = findIntersection(e); ! start = current; active = true; ! } else { current = findIntersection(e); ! Vertex v1 = new Edge(p1.vertex(), start.vertex()).getDirection(); ! Vertex v2 = new Edge(p1.vertex(), current.vertex()).getDirection(); ! double angle = v1.angle(v2); ! vertices = Selection.primary().collect(); ! Iterator iter = vertices.iterator(); ! while (iter.hasNext()) { ! Vertex v = (Vertex) iter.next(); ! Geometry.rotate(angle, l.getDirection().getX(), ! l.getDirection().getY(), l.getDirection().getZ(), v, l.getOrigin()); ! } ! clear(); active = false; } } ! updateFeedback(); } /** ! * bla ! * */ private void updateFeedback() { --- 134,220 ---- */ private void process(MouseEvent e) { ! if (Selection.primary().isEmpty()) { ! GUI.getInstance().alert("There is no selection to rotate"); } else { ! vertices = Selection.primary().collect(); ! if (p1 == null) { ! if (current.type() == Intersection.EDGE) { ! p1 = current.vertex(); ! p2 = p1.add(((Edge)current.object()).getDirection()); ! initDisk(); ! } else if (current.type() == Intersection.SURFACE) { ! p1 = current.vertex(); ! p2 = p1.add(((Surface)(current.object())).normal()); ! initDisk(); ! } else { ! p1 = current.vertex(); ! start = current; ! active = true; ! totalAngle = 0; ! } ! } else if (p2 == null) { ! p2 = current.vertex(); ! start = null; ! initDisk(); active = true; ! } else if (from == null) { current = findIntersection(e); ! from = onto.projection(current.vertex()); ! previous = from; ! pro.setStart(from); ! active = false; ! nothits = getAffected(vertices); ! } else { ! finish(); active = false; } + updateFeedback(); } ! } ! ! /** ! * Initialize the gldisk ! */ ! private void initDisk() { ! Vertex v = p2.minus(p1); ! v.normalize(); ! onto = new Plane(v.getX(), v.getY(), v.getZ(), p1); ! pro = new GlProtractor(onto, p1); ! glv.getView().addGlObjects3D(pro); ! } ! ! /** ! * Finish off the tool ! */ ! private void finish() { ! Project.getInstance().checkpoint(); ! Project.getInstance().changed(vertices); ! active = false; ! clear(); } /** ! * Escape ! */ ! public void escape() { ! rotate(-totalAngle); ! cleanUp(); ! } ! ! /** ! * Apply current tool with specified length value ! * @param length The lengthfield value ! */ ! public void apply(double length) { ! int sign = 1; ! if (totalAngle < 0) { ! sign = -1; ! } ! rotate(sign * (Math.toRadians(length * 1000) - Math.abs(totalAngle))); ! finish(); ! } ! ! /** ! * Update the feedback */ private void updateFeedback() { *************** *** 112,131 **** List edges = new LinkedList(); if (p1 != null) { ! points.add(p1.vertex()); if (p2 != null) { ! if (l == null) { ! l = new Line(p1.vertex(), p2.vertex().minus(p1.vertex())); ! l.setActive(true); ! } edges.add(l); ! Edge e = new Edge(p1.vertex(), start.vertex()); ! e.setStrippled(true); ! edges.add(e); ! e = new Edge(p1.vertex(), current.vertex()); ! e.setStrippled(true); ! edges.add(e); } } ! excluded(edges); points(points); feedback(edges); --- 222,238 ---- List edges = new LinkedList(); if (p1 != null) { ! points.add(p1); if (p2 != null) { ! Line l = new Line(p1, p2.minus(p1)); ! l.setActive(true); edges.add(l); ! edges.add(onto); } } ! List temp = new LinkedList(); ! temp.addAll(nothits); ! temp.addAll(edges); ! temp.addAll(points); ! excluded(temp); points(points); feedback(edges); *************** *** 133,145 **** updateConstructors(); } ! ! /** ! * Invoked when a mouse button has been released on a component. ! * @param e The MouseEvent ! */ ! protected void released(MouseEvent e) { ! ! } ! /** * Remove tool specific things at tool change --- 240,244 ---- updateConstructors(); } ! /** * Remove tool specific things at tool change *************** *** 156,159 **** --- 255,259 ---- private void clear() { vertices.clear(); + totalAngle = 0; p1 = null; p2 = null; *************** *** 161,198 **** current = null; incident = null; ! l = null; } ! /** ! * @param e MouseEvent */ ! protected void moved(MouseEvent e) { ! current = findIntersection(e); ! if (current != null) { ! updateFeedback(); } } /** ! * Update the length field */ ! protected void updateLength() { ! Vertex v1 = null; ! Vertex v2 = null; ! if (p1 != null && p2 != null) { ! if (current != null) { ! if (start != null) { ! v1 = new Edge(p1.vertex(), start.vertex()).getDirection(); ! v2 = new Edge(p1.vertex(), current.vertex()).getDirection(); ! } else if (incident != null) { ! v1 = new Edge(p1.vertex(), incident.vertex()).getDirection(); ! v2 = new Edge(p1.vertex(), current.vertex()).getDirection(); ! } } } ! if (v1 != null && v2 != null) { ! setLength(v1.angle(v2)); ! } else { ! glv.setLengthValue(""); } } --- 261,426 ---- current = null; incident = null; ! from = null; ! onto = null; ! glv.getView().removeGlObjects3D(pro); ! pro = null; ! previous = null; ! nothits.clear(); } ! /** ! * Do the rotation of the vertices ! * @param angle the angle to rotate in degrees */ ! private void rotate(double angle) { ! if (angle != Double.NaN) { ! Iterator iter = vertices.iterator(); ! while (iter.hasNext()) { ! Vertex v = (Vertex)iter.next(); ! Geometry.rotate(angle, onto.getDoublev()[Plane.X], ! onto.getDoublev()[Plane.Y], onto.getDoublev()[Plane.Z], v, p1); ! } ! } else { ! log.error("Angle were " + angle); } } /** ! * A GlObject that draw a protactor on the gl */ ! class GlProtractor implements GlObject { ! /** The location for the protractor */ ! private Plane plane; ! /** The input rotation angle */ ! private int angle; ! /** The center of the protractor */ ! private Vertex origin; ! /** The vertex the rotation starts from */ ! private Vertex start; ! /** The preset angles to intersect with */ ! private LinkedList edges; ! /** The magnification factor */ ! private double factor; ! ! /** ! * The construtor for the protractor ! * @param p The location for the protractor ! * @param origin The center for the protractor ! */ ! public GlProtractor(Plane p, Vertex origin) { ! angle = 0; ! plane = p; ! this.origin = origin; ! edges = new LinkedList(); ! } ! ! /** ! * Setter of the angle of rotation ! * @param angle The rotation angle to visualize ! */ ! public void setAngle(int angle) { ! this.angle = angle; ! } ! ! /** ! * Setter for the start vertex ! * @param start the first vertex in the rotation ! */ ! public void setStart(Vertex start) { ! this.start = start; ! double i = 0; ! double increment = Math.PI / 12; ! while (i < Math.PI) { ! Vertex to = start.copy(); ! Vertex n = plane.normal(); ! Geometry.rotate(i, n.getX(), n.getY(), n.getZ(), to, origin); ! Edge e = new Edge(origin, to); ! edges.add(new Line(origin, e.getDirection())); ! i += increment; } } ! ! /** ! * @inheritDoc ! */ ! public void draw(GLDrawable gld) { ! Camera cam = Project.getInstance().getCurrentCamera(); ! Vertex camorig = new Vertex(cam.getCamera()); ! double dist = camorig.distance(plane.origin()); ! factor = dist / 20; ! GL gl = gld.getGL(); ! GLU glu = gld.getGLU(); ! // translate ! Vertex z = plane.normal(); ! z.normalize(); ! Vertex y = new Vertex(0, 1, 0); ! if (y.minus(z).length() < 0.00000001) { ! y = new Vertex(1, 0, 0); ! } ! ! /*gl.glColor3d(0, 0, 0); ! gl.glLineWidth(2); ! Iterator iter = edges.iterator(); ! while (iter.hasNext()) { ! Line l = (Line) iter.next(); ! Vertex from = l.getPointAt(-5); ! Vertex to = l.getPointAt(5); ! gl.glBegin(GL.GL_LINE_STRIP); ! gl.glVertex3d(from.getX(), from.getY(), from.getZ()); ! gl.glVertex3d(to.getX(), to.getY(), to.getZ()); ! gl.glEnd(); ! } ! */ ! // place the axis right ! if (start != null) { ! y = start.minus(origin); ! y.normalize(); ! } ! Vertex x = y.cross(z); ! y = z.cross(x); ! double[] m = new double[]{x.getX(), x.getY(), x.getZ(), 0, ! y.getX(), y.getY(), y.getZ(), 0, ! z.getX(), z.getY(), z.getZ(), 0, ! origin.getX(), origin.getY(), origin.getZ(), 1}; ! gl.glPushMatrix(); ! gl.glMultMatrixd(m); ! //draw ! ! ! ! gl.glColor4fv(new float[] {0.5f, 0.5f, 0.5f, 0.6f}); ! int sign = 1; ! if (angle < 0) { ! sign = -1; ! } ! glu.gluPartialDisk( ! glu.gluNewQuadric(), 0, 2 * factor, 360, 1, 0, sign * (360 - Math.abs(angle))); ! gl.glColor4fv(new float[] {0.0f, 0.0f, 1.0f, 1.0f}); ! glu.gluPartialDisk(glu.gluNewQuadric(), 0, 2.2 * factor, 360, 1, 0, -angle); ! //restore matrix ! gl.glPopMatrix(); ! } ! ! /** ! * @inheritDoc ! */ ! public Vertex intersection(Edge e) { ! Vertex i = plane.intersection(e); ! Iterator iter = edges.iterator(); ! double p1 = -2.5 * factor; ! double p2 = 2.5 * factor; ! while (iter.hasNext()) { ! Line l = (Line) iter.next(); ! Edge tmp = new Edge(l.getPointAt(p1), l.getPointAt(p2)); ! Edge con = e.intersection(tmp); ! if (con.getLength() < 0.05) { ! if (tmp.coincides(con.getFrom())) { ! i = con.getFrom(); ! } else if (tmp.coincides(con.getTo())) { ! i = con.getTo(); ! } ! } ! } ! return i; } } |
|
From: rimestad <rim...@us...> - 2006-12-13 17:42:21
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16636/src/net/sourceforge/bprocessor/gl/model Added Files: GlObject.java Log Message: Added GLObject to the gl/model and made view contain a list of them to draw and intersect --- NEW FILE: GlObject.java --- //--------------------------------------------------------------------------------- // $Id: GlObject.java,v 1.1 2006/12/13 17:42:13 rimestad Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.gl.model; import net.java.games.jogl.GLDrawable; import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Vertex; /** * A object for making more interesting graphics for tools and the like * Can make any gl operations, and are called during every drawing in the view */ public interface GlObject { /** * Draw the globject via the GL draw methods * @param gld the GLDrawable */ public void draw(GLDrawable gld); /** * Calculate the intersection between the GLObject and the given edge * @param e The edge to calc intersection with * @return The intersection vertex */ public Vertex intersection(Edge e); } |
|
From: rimestad <rim...@us...> - 2006-12-13 17:42:19
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16636/src/net/sourceforge/bprocessor/gl/view Modified Files: View.java Log Message: Added GLObject to the gl/model and made view contain a list of them to draw and intersect Index: View.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.165 retrieving revision 1.166 diff -C2 -d -r1.165 -r1.166 *** View.java 28 Nov 2006 16:43:26 -0000 1.165 --- View.java 13 Dec 2006 17:42:10 -0000 1.166 *************** *** 9,12 **** --- 9,13 ---- import net.sourceforge.bprocessor.gl.GLView; import net.sourceforge.bprocessor.gl.tool.SpaceTool; + import net.sourceforge.bprocessor.gl.model.GlObject; import net.sourceforge.bprocessor.gl.model.Intersection; import net.sourceforge.bprocessor.gui.Toolbar; *************** *** 349,352 **** --- 350,356 ---- private Set highligts; + /** GL objects that are in the model */ + private Set glObjects3D; + /** Max number of clipplanes */ private int maxClippingPlanes; *************** *** 466,469 **** --- 470,474 ---- onTopEntities = new HashSet(); colorMap = new HashMap(); + glObjects3D = new HashSet(); Toolbar tb = Toolbar.getInstance(); *************** *** 968,971 **** --- 973,984 ---- drawConstructorPlanes(); + { + Iterator it = glObjects3D.iterator(); + while (it.hasNext()) { + GlObject glo = (GlObject) it.next(); + glo.draw(gld); + } + } + gl.glDisable(GL.GL_DEPTH_TEST); { *************** *** 2049,2052 **** --- 2062,2076 ---- } } + if (selectMode == ALL) { + { + Iterator it = glObjects3D.iterator(); + while (it.hasNext()) { + GlObject glo = (GlObject) it.next(); + pushName(gl, glo); + glo.draw(gld); + popName(gl); + } + } + } if (selectMode == CONSTRUCTORS || selectMode == ALL) { { *************** *** 2626,2629 **** --- 2650,2660 ---- Vertex intersection = p.intersection(ray); if (intersection != null) { + return new Intersection(intersection, Intersection.PLANE_INTERSECTION, p); + } + } else if (object instanceof GlObject) { + // find out what is intersected + GlObject glo = (GlObject) object; + Vertex intersection = glo.intersection(ray); + if (intersection != null) { return new Intersection(intersection, Intersection.PLANE_INTERSECTION, xy); } *************** *** 3264,3266 **** --- 3295,3322 ---- tempConstructors.remove(c); } + + /** + * remove a object from the glObjects3D set + * @param glo the GLObject to remove + * @return if it were a succes + */ + public boolean removeGlObjects3D(GlObject glo) { + return glObjects3D.remove(glo); + } + + /** + * Add a whole list of GLObject + * @param glObjects The glObjects to add. + */ + public void addGlObjects3D(Set glObjects) { + this.glObjects3D.addAll(glObjects); + } + + /** + * Add a single GLObject + * @param glo The glObject to add. + */ + public void addGlObjects3D(GlObject glo) { + this.glObjects3D.add(glo); + } } |
|
From: Michael L. <he...@us...> - 2006-12-12 13:59:23
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv20408/src/net/sourceforge/bprocessor/model Modified Files: Surface.java Log Message: Simplified hole-analysis to get rid of bug Index: Surface.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Surface.java,v retrieving revision 1.126 retrieving revision 1.127 diff -C2 -d -r1.126 -r1.127 *** Surface.java 11 Dec 2006 10:04:43 -0000 1.126 --- Surface.java 12 Dec 2006 13:59:14 -0000 1.127 *************** *** 1186,1208 **** while (iter.hasNext()) { Vertex current = (Vertex) iter.next(); ! if (!onBoundary(current)) { ! if (!surrounds(current)) { ! return false; ! } ! } ! } ! iter = hole.getEdges().iterator(); ! while (iter.hasNext()) { ! Edge current = (Edge) iter.next(); ! Iterator inner = getEdges().iterator(); ! while (inner.hasNext()) { ! Edge e = (Edge) inner.next(); ! Edge inter = e.intersection(current); ! if (inter != null && inter.getLength() < 0.00001) { ! boolean res = (current.coincides(inter.getFrom()) && e.coincides(inter.getFrom())); ! if (res) { ! return false; ! } ! } } } --- 1186,1191 ---- while (iter.hasNext()) { Vertex current = (Vertex) iter.next(); ! if (!surrounds(current)) { ! return false; } } |
|
From: Michael L. <he...@us...> - 2006-12-12 10:09:33
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv23853/src/net/sourceforge/bprocessor/model Modified Files: SurfaceAnalysis.java Log Message: Improvement of pencil Index: SurfaceAnalysis.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/SurfaceAnalysis.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SurfaceAnalysis.java 12 Dec 2006 09:33:54 -0000 1.1 --- SurfaceAnalysis.java 12 Dec 2006 10:09:32 -0000 1.2 *************** *** 311,314 **** --- 311,325 ---- if (emap.containsKey(current)) { EdgeNode node = (EdgeNode) emap.get(current); + node.left = null; + node.right = null; + } + } + } + { + Iterator iter = start.iterator(); + while (iter.hasNext()) { + Edge current = (Edge) iter.next(); + if (emap.containsKey(current)) { + EdgeNode node = (EdgeNode) emap.get(current); surfaceAnalysis(node, system, added, removed); } |
|
From: Michael L. <he...@us...> - 2006-12-12 09:50:42
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16435/src/net/sourceforge/bprocessor/model Modified Files: Geometry.java Log Message: Removed old pencil code Index: Geometry.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Geometry.java,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** Geometry.java 12 Dec 2006 09:43:26 -0000 1.38 --- Geometry.java 12 Dec 2006 09:50:39 -0000 1.39 *************** *** 9,13 **** import java.util.ArrayList; - import java.util.Arrays; import java.util.Collection; import java.util.HashSet; --- 9,12 ---- *************** *** 236,680 **** /** - * Find surfaces formed by a sequence of newly inserted edges - * @param edges The list of edges - * @return a list of the surfaces created - */ - public static List surfaceAnalysis(List edges) { - List result = new LinkedList(); - Edge first = (Edge) edges.get(0); - Vertex from = first.getFrom(); - Edge last = (Edge) edges.get(edges.size() - 1); - Vertex to = last.getTo(); - Surface exterior = null; - //Finding out if the edges are all contained in one surface with - //endpoints of the chain of edges as vertices of the surface. - //If such a surface exists it is set to extorior - { - Set fromSurfaces = from.getSurfaces(); - Set toSurfaces = to.getSurfaces(); - Set shared = new HashSet(); - Iterator it = fromSurfaces.iterator(); - while (it.hasNext()) { - Surface current = (Surface) it.next(); - if (toSurfaces.contains(current)) { - shared.add(current); - } - } - if (shared.size() == 1) { - exterior = (Surface) shared.iterator().next(); - } else { - Iterator iter = shared.iterator(); - while (edges.size() > 1 && iter.hasNext() && (exterior == null)) { - Surface currentSurface = (Surface) iter.next(); - Vertex currentVertex = first.otherVertex(from); - int currentIndex = 1; - Edge currentEdge = (Edge) edges.get(currentIndex); - boolean outside = false; - while ((currentVertex != to) && !outside) { - outside = !currentSurface.surrounds(currentVertex); - currentVertex = currentEdge.otherVertex(currentVertex); - currentIndex++; - if (currentIndex < edges.size()) { - currentEdge = (Edge) edges.get(currentIndex); - } else { - currentEdge = null; - } - } - if (!outside) { - exterior = currentSurface; - } - } - } - } - //Find the surfaces - Set siblings = to.getEdges(); - siblings.remove(first); - siblings.remove(last); - while (!siblings.isEmpty()) { - Edge current = (Edge) siblings.iterator().next(); - CoordinateSystem system = CoordinateSystem.create(last, current); - siblings.remove(current); - if (system != null) { - VertexNode node = new VertexNode(to, system); - EdgeNode lastEdgeNode = node.insert(last); - if (lastEdgeNode != null) { - node.insert(current); - siblings = node.insert(siblings); - node.sort(); - result.addAll(findSurfaces(node, lastEdgeNode, edges, exterior)); - } - } - } - return result; - } - - /** - * Find surfaces that the new edges forms in the plane the coordinate system - * of the VertexNode - * @param vertex The Vertex - * @param last The first EdgeNode - * @param edges The edges - * @param exterior The exterior - * @return a list of the surfaces found - */ - private static List findSurfaces(VertexNode vertex, EdgeNode last, - List edges, Surface exterior) { - int count = 0; - List surfaces = new LinkedList(); - Space space = ((Edge) edges.iterator().next()).getOwner(); - { - Surface clockwise = clockwiseSurface(vertex, last, edges); - if (clockwise != null) { - if (clockwise.angle(vertex.system()) < 0) { - space.add(clockwise); - holeAnalysis(clockwise); - surfaces.add(clockwise); - count++; - } - } - } - { - Surface counterclockwise = counterclockwiseSurface(vertex, last, edges); - if (counterclockwise != null) { - if (counterclockwise.angle(vertex.system()) > 0) { - space.add(counterclockwise); - holeAnalysis(counterclockwise); - surfaces.add(counterclockwise); - count++; - } - } - } - if (exterior != null) { - if (count == 2) { - Iterator iter = surfaces.iterator(); - Vertex normal = exterior.normal(); - while (iter.hasNext()) { - Surface current = (Surface) iter.next(); - Vertex n = current.normal(); - Vertex o = n.add(normal); - if (o.isZero()) { - current.flip(); - } - current.setBackDomain(exterior.getBackDomain()); - current.setFrontDomain(exterior.getFrontDomain()); - } - space.remove(exterior); - } - } - return surfaces; - } - - /** - * Find the clockwise surface that edges forms in the coordinate system of - * the VertexNode - * @param vertex The Vertex - * @param last The first EdgeNode - * @param edges The edges - * @return The Surface - */ - private static Surface clockwiseSurface(VertexNode vertex, EdgeNode last, List edges) { - if (last == null) { - throw new Error("last null"); - } - ArrayList result = new ArrayList(); - result.addAll(edges); - - Vertex from = ((Edge) edges.get(0)).getFrom(); - - EdgeNode currentEdge = last; - VertexNode current = vertex; - - while (current.vertex() != from) { - currentEdge = current.clockwise(currentEdge.edge()); - if (result.contains(currentEdge.edge())) { - return null; - } - result.add(currentEdge.edge()); - current = currentEdge.other(current); - } - return new Surface(result); - } - - /** - * Find the counterclockwise surface that edges forms in the coordinate system of - * the VertexNode - * @param vertex The Vertex - * @param last The first EdgeNode - * @param edges The edges - * @return The Surface - */ - private static Surface counterclockwiseSurface(VertexNode vertex, EdgeNode last, List edges) { - ArrayList result = new ArrayList(); - result.addAll(edges); - - Vertex from = ((Edge) edges.get(0)).getFrom(); - - EdgeNode currentEdge = last; - VertexNode current = vertex; - - while (current.vertex() != from) { - currentEdge = current.counterclockwise(currentEdge.edge()); - if (result.contains(currentEdge.edge())) { - return null; - } - result.add(currentEdge.edge()); - current = currentEdge.other(current); - } - return new Surface(result); - } - - - /** - * The VertexNode class is used for internal surface calculations - */ - private static class VertexNode { - /** The vertex */ - private Vertex vertex; - /** The edgenodes */ - private List edgenodes; - /** The coordinate system */ - private CoordinateSystem system; - - /** - * Constructor for VertexNode - * @param vertex The vertex - * @param system The coordinate systen - */ - public VertexNode(Vertex vertex, CoordinateSystem system) { - this.vertex = vertex; - this.system = system; - edgenodes = new LinkedList(); - } - /** - * Insert a list of edges into this VertexNode by - * finding all edges in that lies in the coordinate - * system, and sorting the edges clockwise - * @param edges List of edges - * @return The edges that are not inserted - */ - public Set insert(Set edges) { - Set result = new HashSet(); - Iterator iter = edges.iterator(); - while (iter.hasNext()) { - Edge current = (Edge) iter.next(); - if (insert(current) == null) { - result.add(current); - } - } - return result; - } - /** - * Test if this edges is in the coordinate system and - * insert if yes. - * @param edge The edge - * @return The EdgeNode if inserted - */ - public EdgeNode insert(Edge edge) { - Vertex v = edge.otherVertex(vertex).minus(vertex); - double dz = v.dot(system.getN()); - if (Math.abs(dz) < 0.00000001) { - double dx = v.dot(system.getI()); - double dy = v.dot(system.getJ()); - EdgeNode node = new EdgeNode(edge, dx, dy); - insert(node); - return node; - } else { - return null; - } - } - - /** - * Insert an EdgeNode - * @param node The EdgeNode - */ - public void insert(EdgeNode node) { - edgenodes.add(node); - } - - /** - * Get the vertex - * @return The vertex - */ - public Vertex vertex() { - return vertex; - } - - /** - * Get the system - * @return The system - */ - public CoordinateSystem system() { - return system; - } - - /** - * Sort the EdgeNodes clockwise around the vertex - */ - public void sort() { - LinkedList right = new LinkedList(); - LinkedList left = new LinkedList(); - Iterator iter = edgenodes.iterator(); - while (iter.hasNext()) { - EdgeNode current = (EdgeNode) iter.next(); - if (current.dx == 0) { - if (current.dy < 0) { - right.addLast(current); - } - if (current.dy > 0) { - left.addLast(current); - } - } - if (current.dx > 0) { - right.addLast(current); - } - if (current.dx < 0) { - left.addLast(current); - } - } - Object[] rights = right.toArray(); - Arrays.sort(rights); - Object[] lefts = left.toArray(); - Arrays.sort(lefts); - LinkedList result = new LinkedList(); - for (int i = 0; i < rights.length; i++) { - result.addLast(((EdgeNode) rights[i])); - } - for (int i = 0; i < lefts.length; i++) { - result.addLast(((EdgeNode) lefts[i])); - } - edgenodes = result; - } - - /** - * Return the edgenode counterclockwise around the vertex from the edge - * @param edge The edgenode - * @return The counterclockwise edgenode - */ - public EdgeNode counterclockwise(Edge edge) { - Object[] sorted = edgenodes.toArray(); - int index = 0; - for (int i = 0; i < sorted.length; i++) { - if (((EdgeNode) sorted[i]).edge() == edge) { - index = i; - } - } - index++; - if (index == sorted.length) { - return (EdgeNode) sorted[0]; - } else { - return (EdgeNode) sorted[index]; - } - } - - /** - * Return the edgenode clockwise around the vertex from the edge - * @param edge The edgen - * @return The clockwise edgenode - */ - public EdgeNode clockwise(Edge edge) { - EdgeNode result = null; - Object[] sorted = edgenodes.toArray(); - int index = 0; - for (int i = 0; i < sorted.length; i++) { - if (((EdgeNode) sorted[i]).edge() == edge) { - index = i; - } - } - if (index == 0) { - result = (EdgeNode) sorted[sorted.length - 1]; - } else { - result = (EdgeNode) sorted[index - 1]; - } - if (result == null) { - throw new Error("null"); - } - return result; - } - - /** - * Return a String describing this VertexNode - * @return String describing this VertexNode - */ - public String toString() { - StringBuffer buffer = new StringBuffer(); - buffer.append("{" + vertex + "\n"); - Iterator iter = edgenodes.iterator(); - while (iter.hasNext()) { - EdgeNode current = (EdgeNode) iter.next(); - buffer.append(" " + current.edge() + "\n"); - } - buffer.append("}\n"); - return buffer.toString(); - } - } - - /** - * The EdgeNode class is used for surface calculations - */ - private static class EdgeNode implements Comparable { - /** The edge */ - private Edge edge; - /** The dx */ - private double dx; - /** The dy */ - private double dy; - - /** - * Constructor for EdgeNode - * @param edge The edge - * @param dx The dx - * @param dy The dy - */ - public EdgeNode(Edge edge, double dx, double dy) { - this.edge = edge; - this.dx = dx; - this.dy = dy; - } - - /** - * Return the Edge - * @return The Edge - */ - public Edge edge() { - return edge; - } - - /** - * Return the other end - * @param node The node - * @return The other end - */ - public VertexNode other(VertexNode node) { - Vertex other = edge.otherVertex(node.vertex()); - CoordinateSystem system = node.system(); - VertexNode result = new VertexNode(other, system); - Set edges = other.getEdges(); - result.insert(edges); - result.sort(); - return result; - } - - /** - * Compare one edgenode to a nother - * @param other The other - * @return The result of comparison - */ - public int compareTo(Object other) { - EdgeNode entry = (EdgeNode) other; - if (this.dx == 0) { - return -1; - } - if (entry.dx == 0) { - return 1; - } - if ((this.dy / this.dx) < (entry.dy / entry.dx)) { - return -1; - } else { - return 1; - } - } - } - - /** * Test if exterior contains interior * @param exterior The exterior surface --- 235,238 ---- |
|
From: Michael L. <he...@us...> - 2006-12-12 09:43:27
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv13559/src/net/sourceforge/bprocessor/model Modified Files: Geometry.java Log Message: Uses new pencil algo in all tools inserting edges (other than ExtrudeTool) Index: Geometry.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Geometry.java,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** Geometry.java 5 Dec 2006 09:06:17 -0000 1.37 --- Geometry.java 12 Dec 2006 09:43:26 -0000 1.38 *************** *** 838,855 **** } } ! if (!actual.isEmpty()) { ! Vertex v = Edge.commonVertex((Edge) actual.get(0), (Edge) actual.get(actual.size() - 1)); ! if (v != null && actual.size() > 2) { ! Surface surface = new Surface(actual); ! Surface existing = space.findSurface(surface); ! if (existing == null) { ! result.add(surface); ! space.add(surface); ! holeAnalysis(surface); ! } ! } else { ! result.addAll(surfaceAnalysis(actual)); ! } ! } Project.getInstance().changed(Project.getInstance()); Project.getInstance().checkpoint(); --- 838,843 ---- } } ! SurfaceAnalysis analysis = new SurfaceAnalysis(); ! analysis.surfaceAnalysis(space, actual); Project.getInstance().changed(Project.getInstance()); Project.getInstance().checkpoint(); |
|
From: Michael L. <he...@us...> - 2006-12-12 09:33:58
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv9712/src/net/sourceforge/bprocessor/model Added Files: SurfaceAnalysis.java Log Message: Moved new pencil algorithme to a SurfaceAnalysis class --- NEW FILE: SurfaceAnalysis.java --- //--------------------------------------------------------------------------------- // $Id: SurfaceAnalysis.java,v 1.1 2006/12/12 09:33:54 henryml Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.model; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; /** * Surface Analysis * */ public class SurfaceAnalysis { /** * * @param systems Collection of CoordinateSystem * @param edge Edge * @return True if edge is contained in a CoordinateSystem */ private boolean contains(Collection systems, Edge edge) { Iterator iter = systems.iterator(); while (iter.hasNext()) { CoordinateSystem system = (CoordinateSystem) iter.next(); if (system.plane().contains(edge)) { return true; } } return false; } /** * * @param systems Collection of CoordinateSystem * @param system CoordinateSystem * @return true if system is contained in collection */ private boolean contains(Collection systems, CoordinateSystem system) { Iterator iter = systems.iterator(); Plane plane = system.plane(); while (iter.hasNext()) { CoordinateSystem current = (CoordinateSystem) iter.next(); if (plane.contains(current.getOrigin())) { Vertex n1 = system.getN(); Vertex n2 = current.getN(); Vertex cross = n1.cross(n2); if (cross.isZero()) { return true; } } } return false; } /** * Remove all coordinatesystems from space * @param space Space */ public void clearPlanes(Space space) { Collection planes = space.getCoordinateSystems(); Iterator iter = planes.iterator(); while (iter.hasNext()) { CoordinateSystem current = (CoordinateSystem) iter.next(); space.remove(current); } } /** * * @param space Space * @return collection of CoordinateSystem */ public Collection planeAnalysis(Space space) { return planeAnalysis(space, space.getEdges()); } /** * @param space Space * @param start Collection * @return Collection of CoordinateSystem */ public Collection planeAnalysis(Space space, Collection start) { Collection systems = new LinkedList(); Collection edges = space.getEdges(); { Set mark = new HashSet(); Map neighbours = new HashMap(); { Collection vertices = space.getVertices(); Map edgemap = new HashMap(); { Iterator iter = vertices.iterator(); while (iter.hasNext()) { Vertex current = (Vertex) iter.next(); edgemap.put(current, new LinkedList()); } } { Iterator iter = edges.iterator(); while (iter.hasNext()) { Edge current = (Edge) iter.next(); Vertex from = current.getFrom(); List fl = (List) edgemap.get(from); fl.add(current); Vertex to = current.getTo(); List tl = (List) edgemap.get(to); tl.add(current); } } { Iterator iter = edges.iterator(); while (iter.hasNext()) { Edge current = (Edge) iter.next(); List incident = new LinkedList(); { Vertex from = current.getFrom(); List fl = (List) edgemap.get(from); Iterator flit = fl.iterator(); while (flit.hasNext()) { Edge edge = (Edge) flit.next(); if (edge != current) { incident.add(edge); } } } { Vertex to = current.getTo(); List tl = (List) edgemap.get(to); Iterator tlit = tl.iterator(); while (tlit.hasNext()) { Edge edge = (Edge) tlit.next(); if (edge != current) { incident.add(edge); } } } neighbours.put(current, incident); } } } LinkedList queue = new LinkedList(start); while (!queue.isEmpty()) { Edge current = (Edge) queue.removeFirst(); if (!mark.contains(current)) { mark.add(current); List incident = (List) neighbours.get(current); List pls = new LinkedList(); Iterator it = incident.iterator(); while (it.hasNext()) { Edge edge = (Edge) it.next(); CoordinateSystem system = CoordinateSystem.create(current, edge); if (system != null) { if (!contains(pls, edge)) { if (!contains(systems, system)) { pls.add(system); } } } else { queue.addLast(edge); } } systems.addAll(pls); } } } return systems; } /** * Clear surfaces in specified space * @param space Space */ public void clearSurfaces(Space space) { Collection surfaces = new LinkedList(space.getSurfaces()); Iterator iter = surfaces.iterator(); while (iter.hasNext()) { Surface current = (Surface) iter.next(); space.remove(current); } } /** * Find surfaces in the space starting with the * edges in collection of edges * @param space Space * @param start collection of edges * @return collection of surfaces */ public Collection surfaceAnalysis(Space space, Collection start) { Collection systems = planeAnalysis(space, start); Iterator iter = systems.iterator(); Collection added = new LinkedList(); while (iter.hasNext()) { CoordinateSystem current = (CoordinateSystem) iter.next(); added.addAll(surfaceAnalysis(space, current, start)); } return added; } /** * Find surfaces in specified space * @param space Space */ public void surfaceAnalysis(Space space) { Collection systems = space.getCoordinateSystems(); Iterator iter = systems.iterator(); while (iter.hasNext()) { CoordinateSystem current = (CoordinateSystem) iter.next(); surfaceAnalysis(space, current, space.getEdges()); } } /** * Find surfaces in specified space that lies in the specified * coordinatesystem * @param space Space * @param system CoordinateSystem * @param start collection of edges * @return collection of Surfaces */ public Collection surfaceAnalysis(Space space, CoordinateSystem system, Collection start) { Plane plane = system.plane(); Map vmap = new LinkedHashMap(); Map emap = new LinkedHashMap(); { List vertices = new LinkedList(space.getVertices()); Entity.sort(vertices); Iterator iter = vertices.iterator(); while (iter.hasNext()) { Vertex current = (Vertex) iter.next(); if (plane.contains(current)) { vmap.put(current, new VertexNode(current)); } } } { List edges = new LinkedList(space.getEdges()); Entity.sort(edges); Iterator iter = edges.iterator(); while (iter.hasNext()) { Edge current = (Edge) iter.next(); VertexNode from = (VertexNode) vmap.get(current.getFrom()); VertexNode to = (VertexNode) vmap.get(current.getTo()); if (from != null && to != null) { EdgeNode node = new EdgeNode(current, from, to); emap.put(current, node); from.add(node); to.add(node); } } } { Iterator iter = vmap.values().iterator(); while (iter.hasNext()) { VertexNode current = (VertexNode) iter.next(); current.sort(system); } } { Set keys = emap.keySet(); Collection surfaces = space.getSurfaces(); Iterator iter = surfaces.iterator(); while (iter.hasNext()) { Surface current = (Surface) iter.next(); if (keys.containsAll(current.getEdges())) { SurfaceNode surfacenode = new SurfaceNode(current); int direction = Surface.direction(current.getEdges(), system); if (direction == Surface.RIGHT) { Iterator eit = current.getEdges().iterator(); VertexNode from = (VertexNode) vmap.get(current.getFirstVertex()); while (eit.hasNext()) { Edge edge = (Edge) eit.next(); EdgeNode node = (EdgeNode) emap.get(edge); VertexNode to = node.other(from); node.setRight(to, surfacenode); from = to; } } if (direction == Surface.LEFT) { Iterator eit = current.getEdges().iterator(); VertexNode from = (VertexNode) vmap.get(current.getFirstVertex()); while (eit.hasNext()) { Edge edge = (Edge) eit.next(); EdgeNode node = (EdgeNode) emap.get(edge); VertexNode to = node.other(from); node.setLeft(to, surfacenode); from = to; } } } } } Set added = new HashSet(); Set removed = new HashSet(); { Iterator iter = start.iterator(); while (iter.hasNext()) { Edge current = (Edge) iter.next(); if (emap.containsKey(current)) { EdgeNode node = (EdgeNode) emap.get(current); surfaceAnalysis(node, system, added, removed); } } } { Iterator iter = removed.iterator(); while (iter.hasNext()) { Surface current = (Surface) iter.next(); space.remove(current); } } { Iterator iter = added.iterator(); while (iter.hasNext()) { Surface current = (Surface) iter.next(); space.add(current); } } { Iterator iter = added.iterator(); while (iter.hasNext()) { Surface current = (Surface) iter.next(); Geometry.holeAnalysis(current); } } return added; } private List rightContour(EdgeNode start) { List edges = new LinkedList(); VertexNode to = start.to; EdgeNode current = start; EdgeNode next = null; while (next != start) { edges.add(current.edge); next = current.succ(to); if (next.left == next.right) { next = next.succ(to); } to = next.other(to); current = next; } return edges; } private List leftContour(EdgeNode start) { List edges = new LinkedList(); VertexNode to = start.to; EdgeNode current = start; EdgeNode next = null; while (next != start) { edges.add(current.edge); next = current.pred(to); if (next.left == next.right) { next = next.pred(to); } to = next.other(to); current = next; } return edges; } private void assign(Surface surface, Collection surfaces) { if (!surfaces.isEmpty()) { Surface other = (Surface) surfaces.iterator().next(); Vertex n1 = surface.normal(); Vertex n2 = other.normal(); if (n1.dot(n2) > 0) { surface.setBackDomain(other.getBackDomain()); surface.setBackMaterial(other.getBackMaterial()); surface.setFrontDomain(other.getFrontDomain()); surface.setFrontMaterial(other.getFrontMaterial()); } else { surface.setBackDomain(other.getFrontDomain()); surface.setBackMaterial(other.getFrontMaterial()); surface.setFrontDomain(other.getBackDomain()); surface.setFrontMaterial(other.getBackMaterial()); } } } private void surfaceAnalysis (EdgeNode start, CoordinateSystem system, Set added, Set removed) { if (start.left == null) { SurfaceNode s = new SurfaceNode(); VertexNode to = start.to; EdgeNode current = start; while (current.getLeft(to) != s) { s.consume(current.getLeft(to)); current.setLeft(to, s); current = current.pred(to); to = current.other(to); } if (start.left != start.right) { List edges = leftContour(start); if (edges.size() > 2) { int turn = Surface.direction(edges, system); if (turn == Surface.LEFT) { Surface surface = new Surface(edges); assign(surface, s.surfaces); added.add(surface); removed.addAll(s.surfaces); } } } } if (start.right == null) { SurfaceNode s = new SurfaceNode(); VertexNode to = start.to; EdgeNode current = start; while (current.getRight(to) != s) { s.consume(current.getRight(to)); current.setRight(to, s); current = current.succ(to); to = current.other(to); } if (start.right != start.left) { List edges = rightContour(start); if (edges.size() > 2) { int turn = Surface.direction(edges, system); if (turn == Surface.RIGHT) { Surface surface = new Surface(edges); assign(surface, s.surfaces); added.add(surface); removed.addAll(s.surfaces); } } } } } /** * VertexNode */ public class VertexNode { /** vertex */ private Vertex vertex; /** edges */ private List edges; /** * Constructor * @param vertex Vertex */ public VertexNode(Vertex vertex) { this.vertex = vertex; edges = new LinkedList(); } /** * * @param edge Edge */ public void add(EdgeNode edge) { edges.add(edge); } /** * * @param system CoordinateSystem */ public void sort(CoordinateSystem system) { /** * Entry */ class Entry implements Comparable { protected double dx; protected double dy; protected EdgeNode node; /** * * @param node EdgeNode * @param dx double * @param dy double */ public Entry(EdgeNode node, double dx, double dy) { this.node = node; this.dx = dx; this.dy = dy; } /** * @param other Object * @return int */ public int compareTo(Object other) { Entry entry = (Entry) other; if (this.dx == 0) { return -1; } if (entry.dx == 0) { return 1; } if ((this.dy / this.dx) < (entry.dy / entry.dx)) { return -1; } else { return 1; } } } { List left = new LinkedList(); List right = new LinkedList(); Iterator iter = edges.iterator(); while (iter.hasNext()) { EdgeNode current = (EdgeNode) iter.next(); VertexNode other = current.other(this); Vertex delta = other.vertex.minus(vertex); double dx = system.getI().dot(delta); double dy = system.getJ().dot(delta); Entry entry = new Entry(current, dx, dy); if (dx == 0) { if (dy < 0) { right.add(entry); } if (dy > 0) { left.add(entry); } } else { if (dx > 0) { right.add(entry); } if (dx < 0) { left.add(entry); } } } Object[] rights = right.toArray(); Arrays.sort(rights); Object[] lefts = left.toArray(); Arrays.sort(lefts); List result = new LinkedList(); for (int i = 0; i < rights.length; i++) { result.add(((Entry) rights[i]).node); } for (int i = 0; i < lefts.length; i++) { result.add(((Entry) lefts[i]).node); } edges = result; } { EdgeNode previous = (EdgeNode) edges.get(edges.size() - 1); Iterator iter = edges.iterator(); while (iter.hasNext()) { EdgeNode current = (EdgeNode) iter.next(); if (previous.to == this) { previous.toSucc = current; } if (previous.from == this) { previous.fromSucc = current; } if (current.to == this) { current.toPred = previous; } if (current.from == this) { current.fromPred = previous; } previous = current; } } } /** * @return String */ public String toString() { return "{" + vertex.getName() + " " + edges + "}"; } } /** * EdgeNode */ public class EdgeNode { /** edge */ private Edge edge; /** from */ private VertexNode from; /** to */ private VertexNode to; /** successor arround to */ private EdgeNode toSucc; /** predecessor around to */ private EdgeNode toPred; /** sucessor around from */ private EdgeNode fromSucc; /** predecessor around from */ private EdgeNode fromPred; /** left surface */ private SurfaceNode left; /** right surface */ private SurfaceNode right; /** * * @param edge Edge * @param from VertexNode * @param to VertexNode */ public EdgeNode(Edge edge, VertexNode from, VertexNode to) { this.edge = edge; this.from = from; this.to = to; } /** * * @param end VertexNode * @return VertexNode */ public VertexNode other(VertexNode end) { if (end == from) { return to; } if (end == to) { return from; } return null; } /** * * @param end VertexNode * @return EdgeNode */ public EdgeNode succ(VertexNode end) { if (end == to) { return toSucc; } if (end == from) { return fromSucc; } return null; } /** * * @param end VertexNode * @return EdgeNode */ public EdgeNode pred(VertexNode end) { if (end == to) { return toPred; } if (end == from) { return fromPred; } return null; } /** * * @param end VertexNode * @return SurfaceNode */ public SurfaceNode getLeft(VertexNode end) { if (end == to) { return left; } if (end == from) { return right; } return null; } /** * @param end VertexNode * @param left SurfaceNode */ public void setLeft(VertexNode end, SurfaceNode left) { if (end == to) { this.left = left; } if (end == from) { this.right = left; } } /** * * @param end VertexNode * @return SurfaceNode */ public SurfaceNode getRight(VertexNode end) { if (end == to) { return right; } if (end == from) { return left; } return null; } /** * * @param end VertexNode * @param right SurfaceNode */ public void setRight(VertexNode end, SurfaceNode right) { if (end == to) { this.right = right; } if (end == from) { this.left = right; } } /** * @return String */ public String toString() { return "{" + edge.getName() + " fp:" + ((fromPred == null) ? "nil" : fromPred.edge.getName()) + " fs:" + ((fromSucc == null) ? "nil" : fromSucc.edge.getName()) + " tp:" + ((toPred == null) ? "nil" : toPred.edge.getName()) + " ts:" + ((toSucc == null) ? "nil" : toSucc.edge.getName()) + "}"; } } /** * SurfaceNode */ public class SurfaceNode { /** * The set of surfaces is the surfaces is in the model prior to * surface analysis. Newly created surfaces inherit properties from * the existing surfaces that are later deleted. * * Unless the geometry was malformed, there is only one surface related * to this SurfaceNode. More than one surface means that an edge is part * of more than two surfaces in a plane. This can happen easily with * the current geometric tools. */ private Set surfaces; /** * Constructs this SurfaceNode with an empty set of surfaces */ public SurfaceNode() { super(); surfaces = new HashSet(); } /** * Constructs this SurfaceNode with the given surface in the set * of surfaces * @param surface a surface related to this SurfaceNode */ public SurfaceNode(Surface surface) { super(); surfaces = new HashSet(); surfaces.add(surface); } /** * Adds the surfaces from another SurfaceNode to the set of * surfaces of this SurfaceNode. The other SurfaceNode may * be null. * @param other possibly null SurfaceNode from wich to add surfaces */ public void consume(SurfaceNode other) { if (other != null) { surfaces.addAll(other.surfaces); } } } } |
|
From: Michael L. <he...@us...> - 2006-12-12 09:33:52
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv9703/src/net/sourceforge/bprocessor/gl/tool Modified Files: PencilTool.java Log Message: Moved new pencil algorithme to a SurfaceAnalysis class Index: PencilTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/PencilTool.java,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -d -r1.76 -r1.77 *** PencilTool.java 12 Dec 2006 09:05:15 -0000 1.76 --- PencilTool.java 12 Dec 2006 09:33:49 -0000 1.77 *************** *** 11,24 **** import java.awt.event.ActionEvent; import java.awt.event.MouseEvent; - import java.util.Arrays; import java.util.Collection; - import java.util.HashMap; - import java.util.HashSet; import java.util.Iterator; - import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; - import java.util.Map; - import java.util.Set; import javax.swing.AbstractAction; --- 11,18 ---- *************** *** 26,39 **** import net.sourceforge.bprocessor.gl.GLView; - import net.sourceforge.bprocessor.gl.view.View; import net.sourceforge.bprocessor.model.CoordinateSystem; - import net.sourceforge.bprocessor.model.Entity; - import net.sourceforge.bprocessor.model.Geometry; - import net.sourceforge.bprocessor.model.Plane; import net.sourceforge.bprocessor.model.Project; import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Space; ! import net.sourceforge.bprocessor.model.Surface; ! import net.sourceforge.bprocessor.model.Vertex; /** --- 20,28 ---- import net.sourceforge.bprocessor.gl.GLView; import net.sourceforge.bprocessor.model.CoordinateSystem; import net.sourceforge.bprocessor.model.Project; import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Space; ! import net.sourceforge.bprocessor.model.SurfaceAnalysis; /** *************** *** 42,45 **** --- 31,36 ---- */ public class PencilTool extends AbstractPencil { + + private SurfaceAnalysis analysis; /** * Constructor for Pencil *************** *** 50,53 **** --- 41,45 ---- super(glv, cursor); dragging = false; + analysis = new SurfaceAnalysis(); } *************** *** 89,94 **** public void actionPerformed(ActionEvent arg0) { Space space = Project.getInstance().getActiveSpace(); ! clearPlanes(space); ! Collection planes = planeAnalysis(space); Iterator iter = planes.iterator(); while (iter.hasNext()) { --- 81,86 ---- public void actionPerformed(ActionEvent arg0) { Space space = Project.getInstance().getActiveSpace(); ! analysis.clearPlanes(space); ! Collection planes = analysis.planeAnalysis(space); Iterator iter = planes.iterator(); while (iter.hasNext()) { *************** *** 104,108 **** public void actionPerformed(ActionEvent arg0) { Space space = Project.getInstance().getActiveSpace(); ! clearPlanes(space); Project.getInstance().changed(space); Project.getInstance().checkpoint(); --- 96,100 ---- public void actionPerformed(ActionEvent arg0) { Space space = Project.getInstance().getActiveSpace(); ! analysis.clearPlanes(space); Project.getInstance().changed(space); Project.getInstance().checkpoint(); *************** *** 113,118 **** public void actionPerformed(ActionEvent arg0) { Space space = Project.getInstance().getActiveSpace(); ! //clearSurfaces(space); ! surfaceAnalysis(space); Project.getInstance().changed(space); Project.getInstance().checkpoint(); --- 105,109 ---- public void actionPerformed(ActionEvent arg0) { Space space = Project.getInstance().getActiveSpace(); ! analysis.surfaceAnalysis(space); Project.getInstance().changed(space); Project.getInstance().checkpoint(); *************** *** 123,127 **** public void actionPerformed(ActionEvent arg0) { Space space = Project.getInstance().getActiveSpace(); ! clearSurfaces(space); Project.getInstance().changed(space); Project.getInstance().checkpoint(); --- 114,118 ---- public void actionPerformed(ActionEvent arg0) { Space space = Project.getInstance().getActiveSpace(); ! analysis.clearSurfaces(space); Project.getInstance().changed(space); Project.getInstance().checkpoint(); *************** *** 133,291 **** /** - * - * @param systems Collection of CoordinateSystem - * @param edge Edge - * @return True if edge is contained in a CoordinateSystem - */ - private boolean contains(Collection systems, Edge edge) { - Iterator iter = systems.iterator(); - while (iter.hasNext()) { - CoordinateSystem system = (CoordinateSystem) iter.next(); - if (system.plane().contains(edge)) { - return true; - } - } - return false; - } - - /** - * - * @param systems Collection of CoordinateSystem - * @param system CoordinateSystem - * @return true if system is contained in collection - */ - private boolean contains(Collection systems, CoordinateSystem system) { - Iterator iter = systems.iterator(); - Plane plane = system.plane(); - while (iter.hasNext()) { - CoordinateSystem current = (CoordinateSystem) iter.next(); - if (plane.contains(current.getOrigin())) { - Vertex n1 = system.getN(); - Vertex n2 = current.getN(); - Vertex cross = n1.cross(n2); - if (cross.isZero()) { - return true; - } - } - } - return false; - } - - /** - * Remove all coordinatesystems from space - * @param space Space - */ - public void clearPlanes(Space space) { - Collection planes = space.getCoordinateSystems(); - Iterator iter = planes.iterator(); - while (iter.hasNext()) { - CoordinateSystem current = (CoordinateSystem) iter.next(); - space.remove(current); - } - } - - - /** - * - * @param space Space - * @return collection of CoordinateSystem - */ - public Collection planeAnalysis(Space space) { - return planeAnalysis(space, space.getEdges()); - } - - /** - * @param space Space - * @param start Collection - * @return Collection of CoordinateSystem - */ - public Collection planeAnalysis(Space space, Collection start) { - Collection systems = new LinkedList(); - Collection edges = space.getEdges(); - { - Set mark = new HashSet(); - Map neighbours = new HashMap(); - { - Collection vertices = space.getVertices(); - Map edgemap = new HashMap(); - { - Iterator iter = vertices.iterator(); - while (iter.hasNext()) { - Vertex current = (Vertex) iter.next(); - edgemap.put(current, new LinkedList()); - } - } - { - Iterator iter = edges.iterator(); - while (iter.hasNext()) { - Edge current = (Edge) iter.next(); - Vertex from = current.getFrom(); - List fl = (List) edgemap.get(from); - fl.add(current); - Vertex to = current.getTo(); - List tl = (List) edgemap.get(to); - tl.add(current); - } - } - { - Iterator iter = edges.iterator(); - while (iter.hasNext()) { - Edge current = (Edge) iter.next(); - List incident = new LinkedList(); - { - Vertex from = current.getFrom(); - List fl = (List) edgemap.get(from); - Iterator flit = fl.iterator(); - while (flit.hasNext()) { - Edge edge = (Edge) flit.next(); - if (edge != current) { - incident.add(edge); - } - } - } - { - Vertex to = current.getTo(); - List tl = (List) edgemap.get(to); - Iterator tlit = tl.iterator(); - while (tlit.hasNext()) { - Edge edge = (Edge) tlit.next(); - if (edge != current) { - incident.add(edge); - } - } - } - neighbours.put(current, incident); - } - } - } - LinkedList queue = new LinkedList(start); - while (!queue.isEmpty()) { - Edge current = (Edge) queue.removeFirst(); - if (!mark.contains(current)) { - mark.add(current); - List incident = (List) neighbours.get(current); - List pls = new LinkedList(); - Iterator it = incident.iterator(); - while (it.hasNext()) { - Edge edge = (Edge) it.next(); - CoordinateSystem system = CoordinateSystem.create(current, edge); - if (system != null) { - if (!contains(pls, edge)) { - if (!contains(systems, system)) { - pls.add(system); - } - } - } else { - queue.addLast(edge); - } - } - systems.addAll(pls); - } - } - } - return systems; - } - - /** * @param e MouseEvent */ --- 124,127 ---- *************** *** 312,322 **** } else { Edge edge = new Edge(start.vertex(), current.vertex()); - glv.getView().changeColor(edge, View.CLIP_PLANE_COLOR); edge = Project.getInstance().getActiveSpace().insert(edge); Collection edges = new LinkedList(); edges.add(edge); ! Collection surfaces ! = surfaceAnalysis(Project.getInstance().getActiveSpace(), edges); ! Project.getInstance().changed(Project.getInstance().getActiveSpace()); Project.getInstance().checkpoint(); --- 148,157 ---- } else { Edge edge = new Edge(start.vertex(), current.vertex()); edge = Project.getInstance().getActiveSpace().insert(edge); Collection edges = new LinkedList(); edges.add(edge); ! Space space = Project.getInstance().getActiveSpace(); ! Collection surfaces = analysis.surfaceAnalysis(space, edges); ! Project.getInstance().changed(space); Project.getInstance().checkpoint(); *************** *** 333,939 **** glv.repaint(); } - - /** - * Clear surfaces in specified space - * @param space Space - */ - public void clearSurfaces(Space space) { - Collection surfaces = new LinkedList(space.getSurfaces()); - Iterator iter = surfaces.iterator(); - while (iter.hasNext()) { - Surface current = (Surface) iter.next(); - space.remove(current); - } - } - - /** - * Find surfaces in the space starting with the - * edges in collection of edges - * @param space Space - * @param start collection of edges - * @return collection of surfaces - */ - public Collection surfaceAnalysis(Space space, Collection start) { - Collection systems = planeAnalysis(space, start); - Iterator iter = systems.iterator(); - Collection added = new LinkedList(); - while (iter.hasNext()) { - CoordinateSystem current = (CoordinateSystem) iter.next(); - added.addAll(surfaceAnalysis(space, current, start)); - } - return added; - } - - /** - * Find surfaces in specified space - * @param space Space - */ - public void surfaceAnalysis(Space space) { - Collection systems = space.getCoordinateSystems(); - Iterator iter = systems.iterator(); - while (iter.hasNext()) { - CoordinateSystem current = (CoordinateSystem) iter.next(); - surfaceAnalysis(space, current, space.getEdges()); - } - } - - /** - * Find surfaces in specified space that lies in the specified - * coordinatesystem - * @param space Space - * @param system CoordinateSystem - * @param start collection of edges - * @return collection of Surfaces - */ - public Collection surfaceAnalysis(Space space, CoordinateSystem system, Collection start) { - Plane plane = system.plane(); - Map vmap = new LinkedHashMap(); - Map emap = new LinkedHashMap(); - { - List vertices = new LinkedList(space.getVertices()); - Entity.sort(vertices); - Iterator iter = vertices.iterator(); - while (iter.hasNext()) { - Vertex current = (Vertex) iter.next(); - glv.getView().clearColor(current); - if (plane.contains(current)) { - vmap.put(current, new VertexNode(current)); - } - } - } - { - List edges = new LinkedList(space.getEdges()); - Entity.sort(edges); - Iterator iter = edges.iterator(); - while (iter.hasNext()) { - Edge current = (Edge) iter.next(); - glv.getView().clearColor(current); - VertexNode from = (VertexNode) vmap.get(current.getFrom()); - VertexNode to = (VertexNode) vmap.get(current.getTo()); - if (from != null && to != null) { - EdgeNode node = new EdgeNode(current, from, to); - emap.put(current, node); - from.add(node); - to.add(node); - } - } - } - { - Iterator iter = vmap.values().iterator(); - while (iter.hasNext()) { - VertexNode current = (VertexNode) iter.next(); - current.sort(system); - } - } - { - Set keys = emap.keySet(); - Collection surfaces = space.getSurfaces(); - Iterator iter = surfaces.iterator(); - while (iter.hasNext()) { - Surface current = (Surface) iter.next(); - if (keys.containsAll(current.getEdges())) { - SurfaceNode surfacenode = new SurfaceNode(current); - int direction = Surface.direction(current.getEdges(), system); - if (direction == Surface.RIGHT) { - Iterator eit = current.getEdges().iterator(); - VertexNode from = (VertexNode) vmap.get(current.getFirstVertex()); - while (eit.hasNext()) { - Edge edge = (Edge) eit.next(); - EdgeNode node = (EdgeNode) emap.get(edge); - VertexNode to = node.other(from); - node.setRight(to, surfacenode); - from = to; - } - } - if (direction == Surface.LEFT) { - Iterator eit = current.getEdges().iterator(); - VertexNode from = (VertexNode) vmap.get(current.getFirstVertex()); - while (eit.hasNext()) { - Edge edge = (Edge) eit.next(); - EdgeNode node = (EdgeNode) emap.get(edge); - VertexNode to = node.other(from); - node.setLeft(to, surfacenode); - from = to; - } - } - } - } - } - Set added = new HashSet(); - Set removed = new HashSet(); - { - Iterator iter = start.iterator(); - while (iter.hasNext()) { - Edge current = (Edge) iter.next(); - if (emap.containsKey(current)) { - EdgeNode node = (EdgeNode) emap.get(current); - surfaceAnalysis(node, system, added, removed); - } - } - } - { - Iterator iter = removed.iterator(); - while (iter.hasNext()) { - Surface current = (Surface) iter.next(); - space.remove(current); - } - } - { - Iterator iter = added.iterator(); - while (iter.hasNext()) { - Surface current = (Surface) iter.next(); - space.add(current); - } - } - { - Iterator iter = added.iterator(); - while (iter.hasNext()) { - Surface current = (Surface) iter.next(); - Geometry.holeAnalysis(current); - } - } - return added; - } - - private List rightContour(EdgeNode start) { - List edges = new LinkedList(); - VertexNode to = start.to; - EdgeNode current = start; - EdgeNode next = null; - while (next != start) { - edges.add(current.edge); - next = current.succ(to); - if (next.left == next.right) { - next = next.succ(to); - } - to = next.other(to); - current = next; - } - return edges; - } - - private List leftContour(EdgeNode start) { - List edges = new LinkedList(); - VertexNode to = start.to; - EdgeNode current = start; - EdgeNode next = null; - while (next != start) { - edges.add(current.edge); - next = current.pred(to); - if (next.left == next.right) { - next = next.pred(to); - } - to = next.other(to); - current = next; - } - return edges; - } - - private void assign(Surface surface, Collection surfaces) { - if (!surfaces.isEmpty()) { - Surface other = (Surface) surfaces.iterator().next(); - Vertex n1 = surface.normal(); - Vertex n2 = other.normal(); - if (n1.dot(n2) > 0) { - surface.setBackDomain(other.getBackDomain()); - surface.setBackMaterial(other.getBackMaterial()); - surface.setFrontDomain(other.getFrontDomain()); - surface.setFrontMaterial(other.getFrontMaterial()); - } else { - surface.setBackDomain(other.getFrontDomain()); - surface.setBackMaterial(other.getFrontMaterial()); - surface.setFrontDomain(other.getBackDomain()); - surface.setFrontMaterial(other.getBackMaterial()); - } - } - } - - private void surfaceAnalysis (EdgeNode start, CoordinateSystem system, - Set added, Set removed) { - glv.getView().clearColor(start.edge); - if (start.left == null) { - SurfaceNode s = new SurfaceNode(); - VertexNode to = start.to; - EdgeNode current = start; - while (current.getLeft(to) != s) { - s.consume(current.getLeft(to)); - current.setLeft(to, s); - current = current.pred(to); - to = current.other(to); - } - if (start.left != start.right) { - List edges = leftContour(start); - if (edges.size() > 2) { - int turn = Surface.direction(edges, system); - if (turn == Surface.LEFT) { - Surface surface = new Surface(edges); - assign(surface, s.surfaces); - added.add(surface); - removed.addAll(s.surfaces); - } - } - } - } - if (start.right == null) { - SurfaceNode s = new SurfaceNode(); - VertexNode to = start.to; - EdgeNode current = start; - while (current.getRight(to) != s) { - s.consume(current.getRight(to)); - current.setRight(to, s); - current = current.succ(to); - to = current.other(to); - } - if (start.right != start.left) { - List edges = rightContour(start); - if (edges.size() > 2) { - int turn = Surface.direction(edges, system); - if (turn == Surface.RIGHT) { - Surface surface = new Surface(edges); - assign(surface, s.surfaces); - added.add(surface); - removed.addAll(s.surfaces); - } - } - } - } - } - - /** - * VertexNode - */ - public class VertexNode { - /** vertex */ - private Vertex vertex; - /** edges */ - private List edges; - - /** - * Constructor - * @param vertex Vertex - */ - public VertexNode(Vertex vertex) { - this.vertex = vertex; - edges = new LinkedList(); - } - - /** - * - * @param edge Edge - */ - public void add(EdgeNode edge) { - edges.add(edge); - } - - /** - * - * @param system CoordinateSystem - */ - public void sort(CoordinateSystem system) { - /** - * Entry - */ - class Entry implements Comparable { - protected double dx; - protected double dy; - protected EdgeNode node; - - /** - * - * @param node EdgeNode - * @param dx double - * @param dy double - */ - public Entry(EdgeNode node, double dx, double dy) { - this.node = node; - this.dx = dx; - this.dy = dy; - } - /** - * @param other Object - * @return int - */ - public int compareTo(Object other) { - Entry entry = (Entry) other; - if (this.dx == 0) { - return -1; - } - if (entry.dx == 0) { - return 1; - } - if ((this.dy / this.dx) < (entry.dy / entry.dx)) { - return -1; - } else { - return 1; - } - } - } - { - List left = new LinkedList(); - List right = new LinkedList(); - - Iterator iter = edges.iterator(); - while (iter.hasNext()) { - EdgeNode current = (EdgeNode) iter.next(); - VertexNode other = current.other(this); - Vertex delta = other.vertex.minus(vertex); - double dx = system.getI().dot(delta); - double dy = system.getJ().dot(delta); - Entry entry = new Entry(current, dx, dy); - if (dx == 0) { - if (dy < 0) { - right.add(entry); - } - if (dy > 0) { - left.add(entry); - } - } else { - if (dx > 0) { - right.add(entry); - } - if (dx < 0) { - left.add(entry); - } - } - } - - Object[] rights = right.toArray(); - Arrays.sort(rights); - Object[] lefts = left.toArray(); - Arrays.sort(lefts); - List result = new LinkedList(); - for (int i = 0; i < rights.length; i++) { - result.add(((Entry) rights[i]).node); - } - for (int i = 0; i < lefts.length; i++) { - result.add(((Entry) lefts[i]).node); - } - edges = result; - } - { - EdgeNode previous = (EdgeNode) edges.get(edges.size() - 1); - Iterator iter = edges.iterator(); - while (iter.hasNext()) { - EdgeNode current = (EdgeNode) iter.next(); - if (previous.to == this) { - previous.toSucc = current; - } - if (previous.from == this) { - previous.fromSucc = current; - } - if (current.to == this) { - current.toPred = previous; - } - if (current.from == this) { - current.fromPred = previous; - } - previous = current; - } - } - } - - /** - * @return String - */ - public String toString() { - return "{" + vertex.getName() + " " + edges + "}"; - } - } - - /** - * EdgeNode - */ - public class EdgeNode { - /** edge */ - private Edge edge; - /** from */ - private VertexNode from; - /** to */ - private VertexNode to; - /** successor arround to */ - private EdgeNode toSucc; - /** predecessor around to */ - private EdgeNode toPred; - /** sucessor around from */ - private EdgeNode fromSucc; - /** predecessor around from */ - private EdgeNode fromPred; - /** left surface */ - private SurfaceNode left; - /** right surface */ - private SurfaceNode right; - - /** - * - * @param edge Edge - * @param from VertexNode - * @param to VertexNode - */ - public EdgeNode(Edge edge, VertexNode from, VertexNode to) { - this.edge = edge; - this.from = from; - this.to = to; - } - - /** - * - * @param end VertexNode - * @return VertexNode - */ - public VertexNode other(VertexNode end) { - if (end == from) { - return to; - } - if (end == to) { - return from; - } - return null; - } - - /** - * - * @param end VertexNode - * @return EdgeNode - */ - public EdgeNode succ(VertexNode end) { - if (end == to) { - return toSucc; - } - if (end == from) { - return fromSucc; - } - return null; - } - - /** - * - * @param end VertexNode - * @return EdgeNode - */ - public EdgeNode pred(VertexNode end) { - if (end == to) { - return toPred; - } - if (end == from) { - return fromPred; - } - return null; - } - - /** - * - * @param end VertexNode - * @return SurfaceNode - */ - public SurfaceNode getLeft(VertexNode end) { - if (end == to) { - return left; - } - if (end == from) { - return right; - } - return null; - } - - /** - * @param end VertexNode - * @param left SurfaceNode - */ - public void setLeft(VertexNode end, SurfaceNode left) { - if (end == to) { - this.left = left; - } - if (end == from) { - this.right = left; - } - } - - /** - * - * @param end VertexNode - * @return SurfaceNode - */ - public SurfaceNode getRight(VertexNode end) { - if (end == to) { - return right; - } - if (end == from) { - return left; - } - return null; - } - - /** - * - * @param end VertexNode - * @param right SurfaceNode - */ - public void setRight(VertexNode end, SurfaceNode right) { - if (end == to) { - this.right = right; - } - if (end == from) { - this.left = right; - } - } - - /** - * @return String - */ - public String toString() { - return "{" + edge.getName() - + " fp:" + ((fromPred == null) ? "nil" : fromPred.edge.getName()) - + " fs:" + ((fromSucc == null) ? "nil" : fromSucc.edge.getName()) - + " tp:" + ((toPred == null) ? "nil" : toPred.edge.getName()) - + " ts:" + ((toSucc == null) ? "nil" : toSucc.edge.getName()) - + "}"; - } - } - - /** - * SurfaceNode - */ - public class SurfaceNode { - /** - * The set of surfaces is the surfaces is in the model prior to - * surface analysis. Newly created surfaces inherit properties from - * the existing surfaces that are later deleted. - * - * Unless the geometry was malformed, there is only one surface related - * to this SurfaceNode. More than one surface means that an edge is part - * of more than two surfaces in a plane. This can happen easily with - * the current geometric tools. - */ - private Set surfaces; - - /** - * Constructs this SurfaceNode with an empty set of surfaces - */ - public SurfaceNode() { - super(); - surfaces = new HashSet(); - } - /** - * Constructs this SurfaceNode with the given surface in the set - * of surfaces - * @param surface a surface related to this SurfaceNode - */ - public SurfaceNode(Surface surface) { - super(); - surfaces = new HashSet(); - surfaces.add(surface); - } - - /** - * Adds the surfaces from another SurfaceNode to the set of - * surfaces of this SurfaceNode. The other SurfaceNode may - * be null. - * @param other possibly null SurfaceNode from wich to add surfaces - */ - public void consume(SurfaceNode other) { - if (other != null) { - surfaces.addAll(other.surfaces); - } - } - } } --- 168,170 ---- |
|
From: Michael L. <he...@us...> - 2006-12-12 09:05:17
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv30953/src/net/sourceforge/bprocessor/gl/tool Modified Files: PencilTool.java Log Message: Removed test prints from penciltool - added a few more test models Index: PencilTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/PencilTool.java,v retrieving revision 1.75 retrieving revision 1.76 diff -C2 -d -r1.75 -r1.76 *** PencilTool.java 11 Dec 2006 16:51:56 -0000 1.75 --- PencilTool.java 12 Dec 2006 09:05:15 -0000 1.76 *************** *** 464,468 **** { Iterator iter = start.iterator(); - System.out.println("-- analysis --"); while (iter.hasNext()) { Edge current = (Edge) iter.next(); --- 464,467 ---- *************** *** 554,563 **** glv.getView().clearColor(start.edge); if (start.left == null) { - System.out.println("left analyze " + start); SurfaceNode s = new SurfaceNode(); VertexNode to = start.to; EdgeNode current = start; while (current.getLeft(to) != s) { - System.out.println(current); s.consume(current.getLeft(to)); current.setLeft(to, s); --- 553,560 ---- *************** *** 568,576 **** List edges = leftContour(start); if (edges.size() > 2) { - System.out.println("left surface:" + edges); int turn = Surface.direction(edges, system); if (turn == Surface.LEFT) { - System.out.println("turns left"); - System.out.println("consumes " + s.surfaces); Surface surface = new Surface(edges); assign(surface, s.surfaces); --- 565,570 ---- *************** *** 578,594 **** removed.addAll(s.surfaces); } - if (turn == Surface.RIGHT) { - System.out.println("turns right"); - } } } } if (start.right == null) { - System.out.println("right analyze " + start); SurfaceNode s = new SurfaceNode(); VertexNode to = start.to; EdgeNode current = start; while (current.getRight(to) != s) { - System.out.println(current); s.consume(current.getRight(to)); current.setRight(to, s); --- 572,583 ---- *************** *** 599,610 **** List edges = rightContour(start); if (edges.size() > 2) { - System.out.println("right surface:" + edges); int turn = Surface.direction(edges, system); - if (turn == Surface.LEFT) { - System.out.println("turns left"); - } if (turn == Surface.RIGHT) { - System.out.println("turns right"); - System.out.println("consumes " + s.surfaces); Surface surface = new Surface(edges); assign(surface, s.surfaces); --- 588,593 ---- |
|
From: Michael L. <he...@us...> - 2006-12-12 09:05:13
|
Update of /cvsroot/bprocessor/test/input In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv30945/input Added Files: model4.xml model3.xml Log Message: Removed test prints from penciltool - added a few more test models --- NEW FILE: model3.xml --- <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <bmodel> <active>1</active> <cs>23</cs> <name>new project</name> <space voidref="2" level="2" name="Project" type="1" transparent="false" progid="0" id="1"> <description/> <Classification>unassigned</Classification> <constructor xsi:type="CoordinateSystemType" onlyplane="false" active="true" editable="true" progid="1" id="23" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <vertex x="0.0" y="0.0" z="0.0" id="24"/> <ijn> <vertex x="1.0" y="0.0" z="0.0" id="20"/> <vertex x="0.0" y="1.0" z="0.0" id="21"/> <vertex x="0.0" y="0.0" z="1.0" id="22"/> </ijn> </constructor> <space level="3" name="Void" type="1" transparent="false" progid="1" id="2"> <description/> <Classification>unassigned</Classification> </space> <edge constructor="false" progid="1" id="3"> <from>12</from> <to>13</to> </edge> <edge constructor="false" progid="2" id="4"> <from>13</from> <to>14</to> </edge> <edge constructor="false" progid="3" id="5"> <from>14</from> <to>15</to> </edge> <edge constructor="false" progid="4" id="6"> <from>15</from> <to>12</to> </edge> <edge constructor="false" progid="5" id="7"> <from>16</from> <to>17</to> </edge> <edge constructor="false" progid="6" id="8"> <from>17</from> <to>18</to> </edge> <edge constructor="false" progid="7" id="9"> <from>18</from> <to>19</to> </edge> <edge constructor="false" progid="8" id="10"> <from>19</from> <to>16</to> </edge> <edge constructor="false" progid="9" id="11"> <from>12</from> <to>16</to> </edge> <vertex x="1.0" y="1.0" z="0.0" progid="1" id="12"/> <vertex x="1.0" y="7.1634584297" z="0.0" progid="2" id="13"/> <vertex x="7.1928775012" y="7.1634584297" z="0.0" progid="3" id="14"/> <vertex x="7.1928775012" y="1.0" z="0.0" progid="4" id="15"/> <vertex x="1.6351242583" y="1.6351242583" z="0.0" progid="5" id="16"/> <vertex x="1.6351242583" y="6.5283341714" z="0.0" progid="6" id="17"/> <vertex x="6.5577532428" y="6.5283341714" z="0.0" progid="7" id="18"/> <vertex x="6.5577532428" y="1.6351242583" z="0.0" progid="8" id="19"/> </space> </bmodel> --- NEW FILE: model4.xml --- <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <bmodel> <active>1</active> <cs>17</cs> <name>new project</name> <space level="2" voidref="2" name="Project" transparent="false" type="1" progid="0" id="1"> <description/> <Classification>unassigned</Classification> <constructor xsi:type="CoordinateSystemType" onlyplane="false" active="true" editable="true" progid="1" id="17" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <vertex y="0.0" x="0.0" z="0.0" id="18"/> <ijn> <vertex y="0.0" x="1.0" z="0.0" id="14"/> <vertex y="1.0" x="0.0" z="0.0" id="15"/> <vertex y="0.0" x="0.0" z="1.0" id="16"/> </ijn> </constructor> <space level="3" name="Void" transparent="false" type="1" progid="1" id="2"> <description/> <Classification>unassigned</Classification> </space> <edge constructor="false" progid="1" id="3"> <from>8</from> <to>9</to> </edge> <edge constructor="false" progid="2" id="4"> <from>9</from> <to>10</to> </edge> <edge constructor="false" progid="3" id="5"> <from>10</from> <to>11</to> </edge> <edge constructor="false" progid="4" id="6"> <from>11</from> <to>12</to> </edge> <edge constructor="false" progid="5" id="7"> <from>12</from> <to>13</to> </edge> <vertex y="11.9462363143" x="3.6382682103" z="0.0" progid="1" id="8"/> <vertex y="17.2463055596" x="3.6382682103" z="0.0" progid="2" id="9"/> <vertex y="17.2463055596" x="8.9377460268" z="0.0" progid="3" id="10"/> <vertex y="7.338455852" x="8.9377460268" z="0.0" progid="4" id="11"/> <vertex y="7.338455852" x="3.6382682103" z="0.0" progid="5" id="12"/> <vertex y="9.8225086678" x="3.6382682103" z="0.0" progid="6" id="13"/> </space> </bmodel> |
|
From: Michael L. <he...@us...> - 2006-12-11 16:52:02
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv7456/src/net/sourceforge/bprocessor/gl/tool Modified Files: PencilTool.java Log Message: New pencil tool algorithm done Index: PencilTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/PencilTool.java,v retrieving revision 1.74 retrieving revision 1.75 diff -C2 -d -r1.74 -r1.75 *** PencilTool.java 11 Dec 2006 14:56:54 -0000 1.74 --- PencilTool.java 11 Dec 2006 16:51:56 -0000 1.75 *************** *** 29,32 **** --- 29,33 ---- import net.sourceforge.bprocessor.model.CoordinateSystem; import net.sourceforge.bprocessor.model.Entity; + import net.sourceforge.bprocessor.model.Geometry; import net.sourceforge.bprocessor.model.Plane; import net.sourceforge.bprocessor.model.Project; *************** *** 268,278 **** while (it.hasNext()) { Edge edge = (Edge) it.next(); ! if (!contains(pls, edge)) { ! CoordinateSystem system = CoordinateSystem.create(current, edge); ! if (system != null) { if (!contains(systems, system)) { pls.add(system); } } } } --- 269,281 ---- while (it.hasNext()) { Edge edge = (Edge) it.next(); ! CoordinateSystem system = CoordinateSystem.create(current, edge); ! if (system != null) { ! if (!contains(pls, edge)) { if (!contains(systems, system)) { pls.add(system); } } + } else { + queue.addLast(edge); } } *************** *** 313,323 **** Collection edges = new LinkedList(); edges.add(edge); ! this.surfaceAnalysis(Project.getInstance().getActiveSpace(), edges); Project.getInstance().changed(Project.getInstance().getActiveSpace()); Project.getInstance().checkpoint(); hooverEdge = edge; start = current; incident = null; ! cleanUp(); } } --- 316,330 ---- Collection edges = new LinkedList(); edges.add(edge); ! Collection surfaces ! = surfaceAnalysis(Project.getInstance().getActiveSpace(), edges); Project.getInstance().changed(Project.getInstance().getActiveSpace()); Project.getInstance().checkpoint(); + hooverEdge = edge; start = current; incident = null; ! if (!surfaces.isEmpty()) { ! cleanUp(); ! } } } *************** *** 345,356 **** * @param space Space * @param start collection of edges */ ! public void surfaceAnalysis(Space space, Collection start) { Collection systems = planeAnalysis(space, start); Iterator iter = systems.iterator(); while (iter.hasNext()) { CoordinateSystem current = (CoordinateSystem) iter.next(); ! surfaceAnalysis(space, current, start); } } --- 352,366 ---- * @param space Space * @param start collection of edges + * @return collection of surfaces */ ! public Collection surfaceAnalysis(Space space, Collection start) { Collection systems = planeAnalysis(space, start); Iterator iter = systems.iterator(); + Collection added = new LinkedList(); while (iter.hasNext()) { CoordinateSystem current = (CoordinateSystem) iter.next(); ! added.addAll(surfaceAnalysis(space, current, start)); } + return added; } *************** *** 374,379 **** * @param system CoordinateSystem * @param start collection of edges */ ! public void surfaceAnalysis(Space space, CoordinateSystem system, Collection start) { Plane plane = system.plane(); Map vmap = new LinkedHashMap(); --- 384,390 ---- * @param system CoordinateSystem * @param start collection of edges + * @return collection of Surfaces */ ! public Collection surfaceAnalysis(Space space, CoordinateSystem system, Collection start) { Plane plane = system.plane(); Map vmap = new LinkedHashMap(); *************** *** 476,479 **** --- 487,498 ---- } } + { + Iterator iter = added.iterator(); + while (iter.hasNext()) { + Surface current = (Surface) iter.next(); + Geometry.holeAnalysis(current); + } + } + return added; } |
|
From: Michael L. <he...@us...> - 2006-12-11 14:56:58
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv26273/src/net/sourceforge/bprocessor/gl/tool Modified Files: PencilTool.java Log Message: Almost done with pencil algo Index: PencilTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/PencilTool.java,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** PencilTool.java 11 Dec 2006 11:59:15 -0000 1.73 --- PencilTool.java 11 Dec 2006 14:56:54 -0000 1.74 *************** *** 41,45 **** */ public class PencilTool extends AbstractPencil { - private Collection edges; /** * Constructor for Pencil --- 41,44 ---- *************** *** 49,53 **** public PencilTool(GLView glv, Cursor cursor) { super(glv, cursor); - edges = new LinkedList(); dragging = false; } --- 48,51 ---- *************** *** 311,317 **** } else { Edge edge = new Edge(start.vertex(), current.vertex()); - edges.add(edge); glv.getView().changeColor(edge, View.CLIP_PLANE_COLOR); ! Project.getInstance().getActiveSpace().insert(edge); Project.getInstance().changed(Project.getInstance().getActiveSpace()); Project.getInstance().checkpoint(); --- 309,317 ---- } else { Edge edge = new Edge(start.vertex(), current.vertex()); glv.getView().changeColor(edge, View.CLIP_PLANE_COLOR); ! edge = Project.getInstance().getActiveSpace().insert(edge); ! Collection edges = new LinkedList(); ! edges.add(edge); ! this.surfaceAnalysis(Project.getInstance().getActiveSpace(), edges); Project.getInstance().changed(Project.getInstance().getActiveSpace()); Project.getInstance().checkpoint(); *************** *** 341,344 **** --- 341,359 ---- /** + * Find surfaces in the space starting with the + * edges in collection of edges + * @param space Space + * @param start collection of edges + */ + public void surfaceAnalysis(Space space, Collection start) { + Collection systems = planeAnalysis(space, start); + Iterator iter = systems.iterator(); + while (iter.hasNext()) { + CoordinateSystem current = (CoordinateSystem) iter.next(); + surfaceAnalysis(space, current, start); + } + } + + /** * Find surfaces in specified space * @param space Space *************** *** 349,353 **** while (iter.hasNext()) { CoordinateSystem current = (CoordinateSystem) iter.next(); ! surfaceAnalysis(space, current); } } --- 364,368 ---- while (iter.hasNext()) { CoordinateSystem current = (CoordinateSystem) iter.next(); ! surfaceAnalysis(space, current, space.getEdges()); } } *************** *** 358,367 **** * @param space Space * @param system CoordinateSystem */ ! public void surfaceAnalysis(Space space, CoordinateSystem system) { ! if (system.determinant() < 0) { ! System.out.println("LEFT HAND OF DARKNESS"); ! } ! Plane plane = system.plane(); Map vmap = new LinkedHashMap(); --- 373,379 ---- * @param space Space * @param system CoordinateSystem + * @param start collection of edges */ ! public void surfaceAnalysis(Space space, CoordinateSystem system, Collection start) { Plane plane = system.plane(); Map vmap = new LinkedHashMap(); *************** *** 440,448 **** Set removed = new HashSet(); { ! Iterator iter = emap.values().iterator(); System.out.println("-- analysis --"); while (iter.hasNext()) { ! EdgeNode current = (EdgeNode) iter.next(); ! surfaceAnalysis(current, system, added, removed); } } --- 452,463 ---- Set removed = new HashSet(); { ! Iterator iter = start.iterator(); System.out.println("-- analysis --"); while (iter.hasNext()) { ! Edge current = (Edge) iter.next(); ! if (emap.containsKey(current)) { ! EdgeNode node = (EdgeNode) emap.get(current); ! surfaceAnalysis(node, system, added, removed); ! } } } |
|
From: Michael L. <he...@us...> - 2006-12-11 11:59:16
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv22239/src/net/sourceforge/bprocessor/gl/tool Modified Files: PencilTool.java Log Message: Fixed bug in pencil algo when a hole is connected to exterior by *one* edge Index: PencilTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/PencilTool.java,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** PencilTool.java 11 Dec 2006 10:44:51 -0000 1.72 --- PencilTool.java 11 Dec 2006 11:59:15 -0000 1.73 *************** *** 463,506 **** } ! private List rightContour(LinkedList queue) { ! Set mark = new HashSet(); ! while (!queue.isEmpty()) { ! EdgeNode start = (EdgeNode) queue.removeFirst(); ! if (!mark.contains(start)) { ! mark.add(start); ! if (start.left != start.right) { ! List edges = new LinkedList(); ! VertexNode to = start.to; ! EdgeNode current = start; ! EdgeNode next = null; ! while (next != start) { ! edges.add(current.edge); ! next = current.succ(to); ! if (next.left == next.right) { ! next = next.succ(next.other(to)); ! } ! } ! } } } ! return null; } ! /** ! * Return a list of Edge corresponding to a list of EdgeNodes such ! * that all nodes with the same surfacenode on both sides are ignored. ! * @param nodes list of EdgeNode ! * @return list of Edge ! */ ! public List contour(List nodes) { List edges = new LinkedList(); ! { ! Iterator iter = nodes.iterator(); ! while (iter.hasNext()) { ! EdgeNode current = (EdgeNode) iter.next(); ! if (current.left != current.right) { ! edges.add(current.edge); ! } } } return edges; --- 463,496 ---- } ! private List rightContour(EdgeNode start) { ! List edges = new LinkedList(); ! VertexNode to = start.to; ! EdgeNode current = start; ! EdgeNode next = null; ! while (next != start) { ! edges.add(current.edge); ! next = current.succ(to); ! if (next.left == next.right) { ! next = next.succ(to); } + to = next.other(to); + current = next; } ! return edges; } ! private List leftContour(EdgeNode start) { List edges = new LinkedList(); ! VertexNode to = start.to; ! EdgeNode current = start; ! EdgeNode next = null; ! while (next != start) { ! edges.add(current.edge); ! next = current.pred(to); ! if (next.left == next.right) { ! next = next.pred(to); } + to = next.other(to); + current = next; } return edges; *************** *** 532,541 **** System.out.println("left analyze " + start); SurfaceNode s = new SurfaceNode(); - List nodes = new LinkedList(); VertexNode to = start.to; EdgeNode current = start; while (current.getLeft(to) != s) { System.out.println(current); - nodes.add(current); s.consume(current.getLeft(to)); current.setLeft(to, s); --- 522,529 ---- *************** *** 543,560 **** to = current.other(to); } ! List edges = contour(nodes); ! if (edges.size() > 2) { ! System.out.println("left surface:" + edges); ! int turn = Surface.direction(edges, system); ! if (turn == Surface.LEFT) { ! System.out.println("turns left"); ! System.out.println("consumes " + s.surfaces); ! Surface surface = new Surface(edges); ! assign(surface, s.surfaces); ! added.add(surface); ! removed.addAll(s.surfaces); ! } ! if (turn == Surface.RIGHT) { ! System.out.println("turns right"); } } --- 531,550 ---- to = current.other(to); } ! if (start.left != start.right) { ! List edges = leftContour(start); ! if (edges.size() > 2) { ! System.out.println("left surface:" + edges); ! int turn = Surface.direction(edges, system); ! if (turn == Surface.LEFT) { ! System.out.println("turns left"); ! System.out.println("consumes " + s.surfaces); ! Surface surface = new Surface(edges); ! assign(surface, s.surfaces); ! added.add(surface); ! removed.addAll(s.surfaces); ! } ! if (turn == Surface.RIGHT) { ! System.out.println("turns right"); ! } } } *************** *** 563,572 **** System.out.println("right analyze " + start); SurfaceNode s = new SurfaceNode(); - List nodes = new LinkedList(); VertexNode to = start.to; EdgeNode current = start; while (current.getRight(to) != s) { System.out.println(current); - nodes.add(current); s.consume(current.getRight(to)); current.setRight(to, s); --- 553,560 ---- *************** *** 574,591 **** to = current.other(to); } ! List edges = contour(nodes); ! if (edges.size() > 2) { ! System.out.println("right surface:" + edges); ! int turn = Surface.direction(edges, system); ! if (turn == Surface.LEFT) { ! System.out.println("turns left"); ! } ! if (turn == Surface.RIGHT) { ! System.out.println("turns right"); ! System.out.println("consumes " + s.surfaces); ! Surface surface = new Surface(edges); ! assign(surface, s.surfaces); ! added.add(surface); ! removed.addAll(s.surfaces); } } --- 562,581 ---- to = current.other(to); } ! if (start.right != start.left) { ! List edges = rightContour(start); ! if (edges.size() > 2) { ! System.out.println("right surface:" + edges); ! int turn = Surface.direction(edges, system); ! if (turn == Surface.LEFT) { ! System.out.println("turns left"); ! } ! if (turn == Surface.RIGHT) { ! System.out.println("turns right"); ! System.out.println("consumes " + s.surfaces); ! Surface surface = new Surface(edges); ! assign(surface, s.surfaces); ! added.add(surface); ! removed.addAll(s.surfaces); ! } } } |
|
From: Michael L. <he...@us...> - 2006-12-11 10:44:59
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv24179/src/net/sourceforge/bprocessor/gl/tool Modified Files: PencilTool.java Log Message: Progress on incremental version of pencil algo Index: PencilTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/PencilTool.java,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** PencilTool.java 9 Dec 2006 16:33:09 -0000 1.71 --- PencilTool.java 11 Dec 2006 10:44:51 -0000 1.72 *************** *** 26,29 **** --- 26,30 ---- import net.sourceforge.bprocessor.gl.GLView; + import net.sourceforge.bprocessor.gl.view.View; import net.sourceforge.bprocessor.model.CoordinateSystem; import net.sourceforge.bprocessor.model.Entity; *************** *** 40,43 **** --- 41,45 ---- */ public class PencilTool extends AbstractPencil { + private Collection edges; /** * Constructor for Pencil *************** *** 47,50 **** --- 49,53 ---- public PencilTool(GLView glv, Cursor cursor) { super(glv, cursor); + edges = new LinkedList(); dragging = false; } *************** *** 183,191 **** } /** * @param space Space ! * @return Collection of CoordinateSystem */ public Collection planeAnalysis(Space space) { Collection systems = new LinkedList(); Collection edges = space.getEdges(); --- 186,205 ---- } + /** + * * @param space Space ! * @return collection of CoordinateSystem */ public Collection planeAnalysis(Space space) { + return planeAnalysis(space, space.getEdges()); + } + + /** + * @param space Space + * @param start Collection + * @return Collection of CoordinateSystem + */ + public Collection planeAnalysis(Space space, Collection start) { Collection systems = new LinkedList(); Collection edges = space.getEdges(); *************** *** 246,253 **** } } ! ! Iterator iter = edges.iterator(); ! while (iter.hasNext()) { ! Edge current = (Edge) iter.next(); if (!mark.contains(current)) { mark.add(current); --- 260,266 ---- } } ! LinkedList queue = new LinkedList(start); ! while (!queue.isEmpty()) { ! Edge current = (Edge) queue.removeFirst(); if (!mark.contains(current)) { mark.add(current); *************** *** 298,301 **** --- 311,316 ---- } else { Edge edge = new Edge(start.vertex(), current.vertex()); + edges.add(edge); + glv.getView().changeColor(edge, View.CLIP_PLANE_COLOR); Project.getInstance().getActiveSpace().insert(edge); Project.getInstance().changed(Project.getInstance().getActiveSpace()); *************** *** 345,348 **** --- 360,367 ---- */ public void surfaceAnalysis(Space space, CoordinateSystem system) { + if (system.determinant() < 0) { + System.out.println("LEFT HAND OF DARKNESS"); + } + Plane plane = system.plane(); Map vmap = new LinkedHashMap(); *************** *** 418,421 **** --- 437,442 ---- } } + Set added = new HashSet(); + Set removed = new HashSet(); { Iterator iter = emap.values().iterator(); *************** *** 423,431 **** while (iter.hasNext()) { EdgeNode current = (EdgeNode) iter.next(); ! surfaceAnalysis(current, system); } } } /** * Return a list of Edge corresponding to a list of EdgeNodes such --- 444,490 ---- while (iter.hasNext()) { EdgeNode current = (EdgeNode) iter.next(); ! surfaceAnalysis(current, system, added, removed); ! } ! } ! { ! Iterator iter = removed.iterator(); ! while (iter.hasNext()) { ! Surface current = (Surface) iter.next(); ! space.remove(current); ! } ! } ! { ! Iterator iter = added.iterator(); ! while (iter.hasNext()) { ! Surface current = (Surface) iter.next(); ! space.add(current); } } } + private List rightContour(LinkedList queue) { + Set mark = new HashSet(); + while (!queue.isEmpty()) { + EdgeNode start = (EdgeNode) queue.removeFirst(); + if (!mark.contains(start)) { + mark.add(start); + if (start.left != start.right) { + List edges = new LinkedList(); + VertexNode to = start.to; + EdgeNode current = start; + EdgeNode next = null; + while (next != start) { + edges.add(current.edge); + next = current.succ(to); + if (next.left == next.right) { + next = next.succ(next.other(to)); + } + } + } + } + } + return null; + } + /** * Return a list of Edge corresponding to a list of EdgeNodes such *************** *** 448,457 **** } ! /** ! * ! * @param start EdgeNode ! * @param system CoordinateSystem ! */ ! public void surfaceAnalysis(EdgeNode start, CoordinateSystem system) { if (start.left == null) { System.out.println("left analyze " + start); --- 507,532 ---- } ! private void assign(Surface surface, Collection surfaces) { ! if (!surfaces.isEmpty()) { ! Surface other = (Surface) surfaces.iterator().next(); ! Vertex n1 = surface.normal(); ! Vertex n2 = other.normal(); ! if (n1.dot(n2) > 0) { ! surface.setBackDomain(other.getBackDomain()); ! surface.setBackMaterial(other.getBackMaterial()); ! surface.setFrontDomain(other.getFrontDomain()); ! surface.setFrontMaterial(other.getFrontMaterial()); ! } else { ! surface.setBackDomain(other.getFrontDomain()); ! surface.setBackMaterial(other.getFrontMaterial()); ! surface.setFrontDomain(other.getBackDomain()); ! surface.setFrontMaterial(other.getBackMaterial()); ! } ! } ! } ! ! private void surfaceAnalysis (EdgeNode start, CoordinateSystem system, ! Set added, Set removed) { ! glv.getView().clearColor(start.edge); if (start.left == null) { System.out.println("left analyze " + start); *************** *** 476,480 **** System.out.println("consumes " + s.surfaces); Surface surface = new Surface(edges); ! Project.getInstance().getActiveSpace().add(surface); } if (turn == Surface.RIGHT) { --- 551,557 ---- System.out.println("consumes " + s.surfaces); Surface surface = new Surface(edges); ! assign(surface, s.surfaces); ! added.add(surface); ! removed.addAll(s.surfaces); } if (turn == Surface.RIGHT) { *************** *** 508,512 **** System.out.println("consumes " + s.surfaces); Surface surface = new Surface(edges); ! Project.getInstance().getActiveSpace().add(surface); } } --- 585,591 ---- System.out.println("consumes " + s.surfaces); Surface surface = new Surface(edges); ! assign(surface, s.surfaces); ! added.add(surface); ! removed.addAll(s.surfaces); } } |