[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Space.java, 1.146, 1.147
Status: Pre-Alpha
Brought to you by:
henryml
|
From: Michael L. <he...@us...> - 2007-05-29 12:39:35
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv12171/src/net/sourceforge/bprocessor/model Modified Files: Space.java Log Message: Refacted add/remove protected in Space Index: Space.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Space.java,v retrieving revision 1.146 retrieving revision 1.147 diff -C2 -d -r1.146 -r1.147 *** Space.java 24 May 2007 11:00:11 -0000 1.146 --- Space.java 29 May 2007 12:39:17 -0000 1.147 *************** *** 2413,2448 **** /** ! * Remove collection of surfaces from this space ! * @param extrusion Collection of surfaces */ ! public void removeProtected(Collection<Surface> extrusion) { ! Iterator surfaces = extrusion.iterator(); ! while (surfaces.hasNext()) { ! Surface surface = (Surface) surfaces.next(); ! if (surface.getOwner() == this) { ! if (surface.protect()) { ! this.remove(surface); ! } } ! Iterator edges = surface.getEdges().iterator(); ! while (edges.hasNext()) { ! Edge edge = (Edge) edges.next(); ! if (edge.getOwner() == this) { ! if (edge.protect()) { ! this.remove(edge); ! } ! } ! Vertex from = edge.getFrom(); ! if (from.getOwner() == this) { ! if (from.protect()) { ! this.remove(from); ! } ! } ! Vertex to = edge.getTo(); ! if (to.getOwner() == this) { ! if (to.protect()) { ! this.remove(to); ! } ! } } } --- 2413,2450 ---- /** ! * Removes a collection of geometric objects ! * @param geometrics Collection of geometric objects */ ! public void removeProtected(Collection geometrics) { ! for (Object object : geometrics) { ! removeProtected((Geometric) object); ! } ! } ! ! /** ! * Removes a protected geometric ! * @param geometric Geometric ! */ ! public void removeProtected(Geometric geometric) { ! if (geometric instanceof Surface) { ! removeProtected((Surface) geometric); ! } else if (geometric instanceof Edge) { ! removeProtected((Edge) geometric); ! } else if (geometric instanceof Vertex) { ! removeProtected((Vertex) geometric); ! } ! } ! ! /** ! * Removes a protected surface ! * @param surface Surface ! */ ! public void removeProtected(Surface surface) { ! if (surface.getOwner() == this) { ! if (surface.protect()) { ! remove(surface); } ! for (Edge edge : surface.getEdges()) { ! removeProtected(edge); } } *************** *** 2450,2481 **** /** ! * Add extrusion to this space and protect all elements ! * @param extrusion Collection of surfaces */ ! public void addProtected(Collection<Surface> 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) { ! from.protect(true); ! this.add(from); ! } ! Vertex to = edge.getTo(); ! if (to.getOwner() == null) { ! to.protect(true); ! this.add(to); ! } ! if (edge.getOwner() == null) { ! edge.protect(true); ! this.add(edge); ! } } ! if (surface.getOwner() == null) { ! surface.protect(true); ! this.add(surface); } } --- 2452,2476 ---- /** ! * Removes a protected edge ! * @param edge Edge */ ! public void removeProtected(Edge edge) { ! if (edge.getOwner() == this) { ! if (edge.protect()) { ! remove(edge); } ! removeProtected(edge.from); ! removeProtected(edge.to); ! } ! } ! ! /** ! * Removes a protected vertex ! * @param vertex Vertex ! */ ! public void removeProtected(Vertex vertex) { ! if (vertex.getOwner() == this) { ! if (vertex.protect()) { ! remove(vertex); } } *************** *** 2483,2486 **** --- 2478,2543 ---- /** + * Add collection of geometrics to this space and protect all elements + * @param geometrics Collection of geometrics + */ + public void addProtected(Collection geometrics) { + for (Object object : geometrics) { + addProtected((Geometric) object); + } + } + + /** + * Adds a protected geometric + * @param geometric Geometric + */ + public void addProtected(Geometric geometric) { + if (geometric instanceof Surface) { + addProtected((Surface) geometric); + } else if (geometric instanceof Edge) { + addProtected((Edge) geometric); + } else if (geometric instanceof Vertex) { + addProtected((Vertex) geometric); + } + } + + /** + * Adds a protected surface + * @param surface Surface + */ + public void addProtected(Surface surface) { + for (Edge edge : surface.getEdges()) { + addProtected(edge); + } + if (surface.getOwner() == null) { + surface.protect(true); + add(surface); + } + } + + /** + * Adds a protected edge + * @param edge Edge + */ + public void addProtected(Edge edge) { + addProtected(edge.from); + addProtected(edge.to); + if (edge.getOwner() == null) { + edge.protect(true); + add(edge); + } + } + + /** + * Adds a protected vertex + * @param vertex Vertex + */ + public void addProtected(Vertex vertex) { + if (vertex.getOwner() == null) { + vertex.protect(true); + add(vertex); + } + } + + /** * Add surfaces and all of its geometry to this space * @param surfaces Collection of surfaces |