[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Space.java, 1.254, 1.255 Persistence
Status: Pre-Alpha
Brought to you by:
henryml
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory vz-cvs-2.sog:/tmp/cvs-serv5237/src/net/sourceforge/bprocessor/model Modified Files: Space.java Persistence.java Surface.java Plane.java Item.java Geometry.java Log Message: Removed the "empty" space Index: Surface.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Surface.java,v retrieving revision 1.228 retrieving revision 1.229 diff -C2 -d -r1.228 -r1.229 *** Surface.java 22 Apr 2010 08:13:47 -0000 1.228 --- Surface.java 6 Mar 2011 23:13:27 -0000 1.229 *************** *** 1345,1349 **** return backMaterial; } else { ! return backDomain.material(); } } --- 1345,1353 ---- return backMaterial; } else { ! if (backDomain != null) { ! return backDomain.material(); ! } else { ! return Defaults.getVoidMaterial(); ! } } } *************** *** 1373,1377 **** return frontMaterial; } else { ! return frontDomain.material(); } } --- 1377,1385 ---- return frontMaterial; } else { ! if (frontDomain != null) { ! return frontDomain.material(); ! } else { ! return Defaults.getVoidMaterial(); ! } } } *************** *** 1382,1388 **** */ public Space getBackDomain() { - if (backDomain == null && getOwner() != null) { - setBackDomain(getOwner().getEmpty()); - } return backDomain; } --- 1390,1393 ---- *************** *** 1424,1430 **** */ public Space getFrontDomain() { - if (frontDomain == null && getOwner() != null) { - setFrontDomain(getOwner().getEmpty()); - } return frontDomain; } --- 1429,1432 ---- *************** *** 2041,2047 **** if (sur1.getFrontDomain() == sur2.getFrontDomain()) { front = sur1.getFrontDomain(); ! } else if (sur1.getFrontDomain() == sur1.getOwner().empty) { front = sur2.getFrontDomain(); ! } else if (sur2.getFrontDomain() == sur2.getOwner().empty) { front = sur1.getFrontDomain(); } --- 2043,2049 ---- if (sur1.getFrontDomain() == sur2.getFrontDomain()) { front = sur1.getFrontDomain(); ! } else if (sur1.getFrontDomain() == null) { front = sur2.getFrontDomain(); ! } else if (sur2.getFrontDomain() == null) { front = sur1.getFrontDomain(); } *************** *** 2049,2055 **** if (sur1.getBackDomain() == sur2.getBackDomain()) { back = sur1.getBackDomain(); ! } else if (sur1.getBackDomain() == sur1.getOwner().empty) { back = sur2.getBackDomain(); ! } else if (sur2.getBackDomain() == sur2.getOwner().empty) { back = sur1.getBackDomain(); } --- 2051,2057 ---- if (sur1.getBackDomain() == sur2.getBackDomain()) { back = sur1.getBackDomain(); ! } else if (sur1.getBackDomain() == null) { back = sur2.getBackDomain(); ! } else if (sur2.getBackDomain() == null) { back = sur1.getBackDomain(); } *************** *** 2057,2063 **** if (sur1.getFrontDomain() == sur2.getBackDomain()) { front = sur1.getFrontDomain(); ! } else if (sur1.getFrontDomain() == sur1.getOwner().empty) { front = sur2.getBackDomain(); ! } else if (sur2.getBackDomain() == sur2.getOwner().empty) { front = sur1.getFrontDomain(); } --- 2059,2065 ---- if (sur1.getFrontDomain() == sur2.getBackDomain()) { front = sur1.getFrontDomain(); ! } else if (sur1.getFrontDomain() == null) { front = sur2.getBackDomain(); ! } else if (sur2.getBackDomain() == null) { front = sur1.getFrontDomain(); } *************** *** 2065,2071 **** if (sur1.getBackDomain() == sur2.getFrontDomain()) { back = sur1.getBackDomain(); ! } else if (sur1.getBackDomain() == sur1.getOwner().empty) { back = sur2.getFrontDomain(); ! } else if (sur2.getFrontDomain() == sur2.getOwner().empty) { back = sur1.getBackDomain(); } --- 2067,2073 ---- if (sur1.getBackDomain() == sur2.getFrontDomain()) { back = sur1.getBackDomain(); ! } else if (sur1.getBackDomain() == null) { back = sur2.getFrontDomain(); ! } else if (sur2.getFrontDomain() == null) { back = sur1.getBackDomain(); } Index: Plane.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Plane.java,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** Plane.java 25 Jun 2009 22:17:30 -0000 1.43 --- Plane.java 6 Mar 2011 23:13:27 -0000 1.44 *************** *** 251,261 **** private void copyElements() { for (Item current : input.elements()) { ! if (!current.isVoid()) { ! Item element = current.shallowCopy(); ! map.put(current, element); ! silhouette.add(element); ! } else { ! map.put(current, silhouette.getEmpty()); ! } } } --- 251,257 ---- private void copyElements() { for (Item current : input.elements()) { ! Item element = current.shallowCopy(); ! map.put(current, element); ! silhouette.add(element); } } Index: Item.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Item.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Item.java 26 Nov 2010 14:20:31 -0000 1.10 --- Item.java 6 Mar 2011 23:13:27 -0000 1.11 *************** *** 85,92 **** /** The classification type*/ private ClassificationType productType; ! ! /** The empty space in this space (also called void) */ ! protected Space empty; ! /** The material */ protected Material material; --- 85,89 ---- /** The classification type*/ private ClassificationType productType; ! /** The material */ protected Material material; *************** *** 201,209 **** */ public boolean isVoid() { ! if (getOwner() != null) { ! return getOwner().empty == this; ! } else { ! return false; ! } } --- 198,202 ---- */ public boolean isVoid() { ! return false; } *************** *** 267,271 **** */ public void setEmpty(Space element) { - empty = element; } --- 260,263 ---- *************** *** 275,279 **** */ public Space getEmpty() { ! return empty; } --- 267,271 ---- */ public Space getEmpty() { ! return null; } *************** *** 684,696 **** */ public String getKindName() { ! if (this != getOwner().empty) { ! String lvl = getLevelName(); ! if (getClassification() != null) { ! return lvl + " - " + getClassification().toString(); ! } else { ! return lvl; ! } } else { ! return null; } } --- 676,684 ---- */ public String getKindName() { ! String lvl = getLevelName(); ! if (getClassification() != null) { ! return lvl + " - " + getClassification().toString(); } else { ! return lvl; } } Index: Space.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Space.java,v retrieving revision 1.254 retrieving revision 1.255 diff -C2 -d -r1.254 -r1.255 *** Space.java 21 May 2010 07:28:57 -0000 1.254 --- Space.java 6 Mar 2011 23:13:27 -0000 1.255 *************** *** 111,116 **** container = true; initializeContainers(); - empty = new Space("Void", FUNCTIONAL, false); - ((Space) this).add(empty); } --- 111,114 ---- *************** *** 125,130 **** if (container) { initializeContainers(); - empty = new Space("Void", FUNCTIONAL, false); - ((Space) this).add(empty); } } --- 123,126 ---- *************** *** 191,198 **** Space front = current.getFrontDomain(); if (back == element) { ! current.setBackDomain(empty); } if (front == element) { ! current.setFrontDomain(empty); } } --- 187,194 ---- Space front = current.getFrontDomain(); if (back == element) { ! current.setBackDomain(null); } if (front == element) { ! current.setFrontDomain(null); } } *************** *** 757,766 **** surfaces.put(id, surface); surface.setOwner((Space) this); - if (surface.getFrontDomain() == null) { - surface.setFrontDomain(empty); - } - if (surface.getBackDomain() == null) { - surface.setBackDomain(empty); - } } else { throw new Error("adding surface to non-container " + this); --- 753,756 ---- *************** *** 937,942 **** constructors.clear(); nextConstructorId = 1; - empty.clear(); - ((Space) this).add(empty); } } --- 927,930 ---- *************** *** 1019,1023 **** other = current.getFrontDomain(); } ! if (other == this || other == getOwner().empty) { deletion.add(current); } --- 1007,1011 ---- other = current.getFrontDomain(); } ! if (other == this || other == null) { deletion.add(current); } *************** *** 1630,1634 **** container.setEdges((HashMap) Entity.asMap(mesh.edges())); container.setVertices((HashMap) Entity.asMap(mesh.vertices())); - container.setEmpty((Space) map.get(empty)); } --- 1618,1621 ---- Index: Geometry.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Geometry.java,v retrieving revision 1.74 retrieving revision 1.75 diff -C2 -d -r1.74 -r1.75 *** Geometry.java 5 Feb 2010 13:32:50 -0000 1.74 --- Geometry.java 6 Mar 2011 23:13:27 -0000 1.75 *************** *** 52,110 **** /** - * Find all edges in given space and all its subspaces that are active parts, - * that is all edges in spaces that have no subspaces. - * @param s The space to start from - * @return The collection of edges - */ - public static Collection<Edge> getActiveEdges(Space s) { - if (s.getElements().size() == 1) { - Collection<Edge> e = new ArrayList<Edge>(); - e.addAll(s.getEdges()); - for (Surface envelope : s.getEnvelope()) { - e.addAll(envelope.getEdges()); - } - return e; - } else { - ArrayList<Edge> edges = new ArrayList<Edge>(); - for (Item cur : s.getElements()) { - if (cur != s.getEmpty()) { - Collection<Edge> c = getActiveEdges((Space) cur); - edges.addAll(c); - } - } - edges.addAll(s.getEdges()); - return edges; - } - } - - /** - * Find all surfaces in given space and all its subspaces that are active parts, - * that is all surfaces in spaces that have no subspaces. - * @param s The space to start from - * @return The collection of surfaces - */ - public static Collection getActiveSurfaces(Space s) { - if (s.getElements().size() == 1) { - //If void is the only space add all surfaces in the space and the envelope - Collection c = new ArrayList(); - c.addAll(s.getSurfaces()); - c.addAll(s.getEnvelope()); - return c; - } else { - //If there are elements call recursive on elements and add envelope - ArrayList surfaces = new ArrayList(); - Iterator iter = s.getElements().iterator(); - while (iter.hasNext()) { - Space cur = (Space)iter.next(); - if (cur != s.getEmpty()) { - surfaces.addAll(getActiveSurfaces(cur)); - } - } - surfaces.addAll(s.getSurfaces()); - return surfaces; - } - } - - /** * Rotate * @param angle The angle --- 52,55 ---- *************** *** 498,510 **** for (Surface s : surfaces) { Space front = s.getFrontDomain(); ! if (front != null && ! front == s.getBackDomain()) { ! Space owner = front.getOwner(); ! if (owner != null && ! front != owner.empty) { ! redundant.add(s); ! front.removeSurface(s); ! s.delete(); ! } } } --- 443,450 ---- for (Surface s : surfaces) { Space front = s.getFrontDomain(); ! if (front != null && front == s.getBackDomain()) { ! redundant.add(s); ! front.removeSurface(s); ! s.delete(); } } Index: Persistence.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Persistence.java,v retrieving revision 1.91 retrieving revision 1.92 diff -C2 -d -r1.91 -r1.92 *** Persistence.java 26 Nov 2010 14:20:31 -0000 1.91 --- Persistence.java 6 Mar 2011 23:13:27 -0000 1.92 *************** *** 328,332 **** long empty = xml.getVoidref(); boolean container = (empty != 0); ! // Alternative: //space = new Space() --- 328,332 ---- long empty = xml.getVoidref(); boolean container = (empty != 0); ! container = true; // Alternative: //space = new Space() |