Thread: [Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Edge.java, 1.92, 1.93 Vertex.java, 1
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2007-07-18 14:03:43
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv27905/src/net/sourceforge/bprocessor/model Modified Files: Edge.java Vertex.java Surface.java Space.java Log Message: Refactored delete Index: Surface.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Surface.java,v retrieving revision 1.169 retrieving revision 1.170 diff -C2 -d -r1.169 -r1.170 *** Surface.java 18 Jul 2007 12:24:04 -0000 1.169 --- Surface.java 18 Jul 2007 14:03:38 -0000 1.170 *************** *** 321,325 **** public void delete() { if (getOwner() != null) { ! getOwner().delete(this); } } --- 321,330 ---- public void delete() { if (getOwner() != null) { ! for (Edge edge : getEdges()) { ! if (edge.getSurfaces().size() < 1) { ! edge.delete(); ! } ! } ! getOwner().remove(this); } } Index: Space.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Space.java,v retrieving revision 1.159 retrieving revision 1.160 diff -C2 -d -r1.159 -r1.160 *** Space.java 18 Jul 2007 13:35:38 -0000 1.159 --- Space.java 18 Jul 2007 14:03:38 -0000 1.160 *************** *** 612,631 **** /** - * Delete a vertex - * @param vertex The vertex - */ - public void delete(Vertex vertex) { - if (vertex.getId() != null) { - Set edges = vertex.getEdges(); - remove(vertex); - Iterator iter = edges.iterator(); - while (iter.hasNext()) { - Edge current = (Edge) iter.next(); - delete(current); - } - } - } - - /** * Return the vertices * @return The vertices --- 612,615 ---- *************** *** 736,811 **** /** - * Delete a edge - * @param edge The edge - */ - public void delete(Edge edge) { - if (edge.getId() != null) { - Set<Surface> surfaces = edge.getSurfaces(); - Vertex to = edge.getTo(); - Vertex from = edge.getFrom(); - remove(edge); - - - // Merge two adjacant surface. - // FIXME Replace with surface-analysis - { - if (surfaces.size() == 2) { - Iterator<Surface> it = surfaces.iterator(); - Surface s1 = it.next(); - Surface s2 = it.next(); - if (s1.plane().contains(s2)) { - List<Edge> edges1 = edgeFirst(s1, edge); - List<Edge> edges2 = edgeFirst(s2, edge); - edges1.remove(edge); - edges2.remove(edge); - if (Edge.first(edges1) == Edge.first(edges2)) { - Collections.reverse(edges2); - } - edges1.addAll(edges2); - Surface surface = new Surface(edges1); - add(surface); - if (s1.getExterior() != null) { - s1.getExterior().addHole(surface); - } else if (s2.getExterior() != null) { - s2.getExterior().addHole(surface); - } - Set<Surface> holes = new HashSet<Surface>(); - holes.addAll(s1.getHoles()); - holes.addAll(s2.getHoles()); - for (Surface hole : holes) { - surface.addHole(hole); - } - Surface.mergeSpaceAssign(s1, s2, surface); - } - } - } - - for (Surface surface : surfaces) { - // Here the surface need to be unlinked - remove(surface); - } - - if (to.getOwner() != null) { - if (to.getEdges().size() == 0) { - remove(to); - } - } - if (from.getOwner() != null) { - if (from.getEdges().size() == 0) { - remove(from); - } - } - } - } - - /** * Takes a surface and arranges its edgelist so that * the a specified edge in the list is the first edge in the list ! * @param surface the surface * @param first the edge that should be first in the edgelist * @return a list of the surfaces edges arranged correctly, returns * unaltered edgelist if the edge is not in the surface. */ ! private static List<Edge> edgeFirst(Surface s, Edge first) { List<Edge> edges = new LinkedList<Edge>(s.getEdges()); int index = edges.indexOf(first); --- 720,731 ---- /** * Takes a surface and arranges its edgelist so that * the a specified edge in the list is the first edge in the list ! * @param s the surface * @param first the edge that should be first in the edgelist * @return a list of the surfaces edges arranged correctly, returns * unaltered edgelist if the edge is not in the surface. */ ! public static List<Edge> edgeFirst(Surface s, Edge first) { List<Edge> edges = new LinkedList<Edge>(s.getEdges()); int index = edges.indexOf(first); *************** *** 935,983 **** /** - * Delete a surface - * @param surface The surface - */ - public void delete(Surface surface) { - remove(surface); - for (Edge edge : surface.getEdges()) { - if (edge.getSurfaces().size() < 1) { - delete(edge); - } - } - } - - /** - * Delete the space and delete envelope surfaces not part of - * another space. - * @param space Space - */ - public void delete(Space space) { - List<Surface> deletion = new LinkedList<Surface>(); - { - Iterator iter = space.getEnvelope().iterator(); - while (iter.hasNext()) { - Surface current = (Surface) iter.next(); - Space other; - if (current.getFrontDomain() == space) { - other = current.getBackDomain(); - } else { - other = current.getFrontDomain(); - } - if (other == space || other == empty) { - deletion.add(current); - } - } - } - { - Iterator<Surface> iter = deletion.iterator(); - while (iter.hasNext()) { - Surface current = iter.next(); - delete(current); - } - } - remove(space); - } - - /** * Return the surfaces * @return The surfaces --- 855,858 ---- *************** *** 1690,1695 **** // FIXME should we clear this Space? clear(); ! Space owner = this.getOwner(); ! owner.delete(this); } --- 1565,1584 ---- // FIXME should we clear this Space? clear(); ! List<Surface> deletion = new LinkedList<Surface>(); ! for (Surface current : getEnvelope()) { ! Space other; ! if (current.getFrontDomain() == this) { ! other = current.getBackDomain(); ! } else { ! other = current.getFrontDomain(); ! } ! if (other == this || other == getOwner().empty) { ! deletion.add(current); ! } ! } ! for (Surface current : deletion) { ! current.delete(); ! } ! getOwner().remove(this); } Index: Vertex.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Vertex.java,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** Vertex.java 18 Jul 2007 12:24:04 -0000 1.62 --- Vertex.java 18 Jul 2007 14:03:37 -0000 1.63 *************** *** 501,505 **** public void delete() { if (getOwner() != null) { ! getOwner().delete(this); } } --- 501,509 ---- public void delete() { if (getOwner() != null) { ! Set<Edge> edges = getEdges(); ! getOwner().remove(this); ! for (Edge current : edges) { ! current.delete(); ! } } } Index: Edge.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Edge.java,v retrieving revision 1.92 retrieving revision 1.93 diff -C2 -d -r1.92 -r1.93 *** Edge.java 18 Jul 2007 12:24:04 -0000 1.92 --- Edge.java 18 Jul 2007 14:03:37 -0000 1.93 *************** *** 202,206 **** public void delete() { if (getOwner() != null) { ! getOwner().delete(this); } } --- 202,259 ---- public void delete() { if (getOwner() != null) { ! Set<Surface> surfaces = getSurfaces(); ! Vertex to = getTo(); ! Vertex from = getFrom(); ! ! // Merge two adjacant surface. ! // FIXME Replace with surface-analysis ! { ! if (surfaces.size() == 2) { ! Iterator<Surface> it = surfaces.iterator(); ! Surface s1 = it.next(); ! Surface s2 = it.next(); ! if (s1.plane().contains(s2)) { ! List<Edge> edges1 = Space.edgeFirst(s1, this); ! List<Edge> edges2 = Space.edgeFirst(s2, this); ! edges1.remove(this); ! edges2.remove(this); ! if (Edge.first(edges1) == Edge.first(edges2)) { ! Collections.reverse(edges2); ! } ! edges1.addAll(edges2); ! Surface surface = new Surface(edges1); ! getOwner().add(surface); ! if (s1.getExterior() != null) { ! s1.getExterior().addHole(surface); ! } else if (s2.getExterior() != null) { ! s2.getExterior().addHole(surface); ! } ! Set<Surface> holes = new HashSet<Surface>(); ! holes.addAll(s1.getHoles()); ! holes.addAll(s2.getHoles()); ! for (Surface hole : holes) { ! surface.addHole(hole); ! } ! Surface.mergeSpaceAssign(s1, s2, surface); ! } ! } ! } ! ! for (Surface surface : surfaces) { ! // Here the surface need to be unlinked ! getOwner().remove(surface); ! } ! ! if (to.getOwner() != null) { ! if (to.getEdges().size() == 0) { ! getOwner().remove(to); ! } ! } ! if (from.getOwner() != null) { ! if (from.getEdges().size() == 0) { ! getOwner().remove(from); ! } ! } ! getOwner().remove(this); } } |