[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Edge.java, 1.63, 1.64 Vertex.java, 1
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2006-11-02 14:45:49
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv26634/src/net/sourceforge/bprocessor/model Modified Files: Edge.java Vertex.java Surface.java Space.java Log Message: New copy operations on surface/edge/vertex Index: Surface.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Surface.java,v retrieving revision 1.119 retrieving revision 1.120 diff -C2 -d -r1.119 -r1.120 *** Surface.java 30 Oct 2006 10:43:32 -0000 1.119 --- Surface.java 2 Nov 2006 14:45:38 -0000 1.120 *************** *** 437,470 **** */ public Surface copy(Space mesh) { - Surface surface = new Surface(); - HashMap map = new HashMap(); ! List edges = new ArrayList(); ! Iterator iter = getEdges().iterator(); ! while (iter.hasNext()) { ! Edge current = (Edge) iter.next(); ! Edge newEdge = new Edge(); ! Vertex from = current.getFrom(); ! Vertex newFrom = (Vertex) map.get(from); ! if (newFrom == null) { ! newFrom = from.copy(); ! map.put(from, newFrom); ! mesh.add(newFrom); ! } ! newEdge.setFrom(newFrom); ! Vertex to = current.getTo(); ! Vertex newTo = (Vertex) map.get(to); ! if (newTo == null) { ! newTo = to.copy(); ! map.put(to, newTo); ! mesh.add(newTo); } ! newEdge.setTo(newTo); ! mesh.add(newEdge); ! edges.add(newEdge); } ! surface.setEdges(edges); ! mesh.add(surface); ! return surface; } --- 437,469 ---- */ public Surface copy(Space mesh) { HashMap map = new HashMap(); ! Surface surface = copy(map); ! Collection surfaces = new LinkedList(); ! surfaces.add(surface); ! mesh.addAll(surfaces); ! return surface; ! } ! ! /** ! * Return a copy of this surface and insert the copy ! * in the map. ! * If the map already contains a copy, just return ! * the existing copy ! * @param map Maps objects to their copy ! * @return A copy ! */ ! public Surface copy(Map map) { ! Surface copy = (Surface) map.get(this); ! if (copy == null) { ! copy = new Surface(); ! List edges = new ArrayList(); ! Iterator iter = getEdges().iterator(); ! while (iter.hasNext()) { ! Edge current = (Edge) iter.next(); ! edges.add(current.copy(map)); } ! copy.setEdges(edges); } ! return copy; } Index: Space.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Space.java,v retrieving revision 1.91 retrieving revision 1.92 diff -C2 -d -r1.91 -r1.92 *** Space.java 30 Oct 2006 06:49:24 -0000 1.91 --- Space.java 2 Nov 2006 14:45:38 -0000 1.92 *************** *** 2221,2225 **** /** ! * Add extrusion to this space * @param extrusion Collection of surfaces */ --- 2221,2225 ---- /** ! * Add extrusion to this space and protect all elements * @param extrusion Collection of surfaces */ *************** *** 2252,2255 **** --- 2252,2284 ---- } } + + /** + * Add extrusion to this space + * @param extrusion Collection of surfaces + */ + public void addAll(Collection extrusion) { + Iterator surfaces = extrusion.iterator(); + while (surfaces.hasNext()) { + Surface surface = (Surface) surfaces.next(); + Iterator edges = surface.getEdges().iterator(); + while (edges.hasNext()) { + Edge edge = (Edge) edges.next(); + Vertex from = edge.getFrom(); + if (from.getOwner() == null) { + this.add(from); + } + Vertex to = edge.getTo(); + if (to.getOwner() == null) { + this.add(to); + } + if (edge.getOwner() == null) { + this.add(edge); + } + } + if (surface.getOwner() == null) { + this.add(surface); + } + } + } /** Index: Vertex.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Vertex.java,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** Vertex.java 30 Oct 2006 15:01:31 -0000 1.49 --- Vertex.java 2 Nov 2006 14:45:38 -0000 1.50 *************** *** 12,15 **** --- 12,16 ---- import java.util.Iterator; import java.util.List; + import java.util.Map; import java.util.Set; *************** *** 215,222 **** */ public Vertex copy() { ! Vertex vertex = new Vertex(); ! vertex.setX(getX()); ! vertex.setY(getY()); ! vertex.setZ(getZ()); return vertex; } --- 216,220 ---- */ public Vertex copy() { ! Vertex vertex = new Vertex(x, y, z); return vertex; } *************** *** 232,235 **** --- 230,250 ---- return v; } + + /** + * Return a copy of the vertex and insert the copy + * in the map. + * If the map already contains a copy, just return + * the existing copy + * @param map Maps objects to their copy + * @return A copy + */ + public Vertex copy(Map map) { + Vertex copy = (Vertex) map.get(this); + if (copy == null) { + copy = new Vertex(x, y, z); + map.put(this, copy); + } + return copy; + } /** Index: Edge.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Edge.java,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** Edge.java 19 Oct 2006 09:56:21 -0000 1.63 --- Edge.java 2 Nov 2006 14:45:38 -0000 1.64 *************** *** 267,270 **** --- 267,288 ---- return edge; } + + /** + * Return a copy of this edge and insert the copy + * in the map. + * If the map already contains a copy, just return + * the existing copy + * @param map Maps objects to their copy + * @return A copy + */ + public Edge copy(Map map) { + Edge copy = (Edge) map.get(this); + if (copy == null) { + copy = new Edge(from.copy(map), to.copy(map)); + map.put(this, copy); + } + return copy; + } + /** * Move the Edge a distance (dx, dy, dz) |