Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv8976/src/net/sourceforge/bprocessor/model
Modified Files:
Space.java
Log Message:
new implementation of make union
Index: Space.java
===================================================================
RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Space.java,v
retrieving revision 1.204
retrieving revision 1.205
diff -C2 -d -r1.204 -r1.205
*** Space.java 8 Nov 2007 12:31:35 -0000 1.204
--- Space.java 9 Nov 2007 13:58:42 -0000 1.205
***************
*** 2835,2910 ****
/**
- * Make a union out of a collection of spaces
- * -All boundary surfaces are found and kept as envelope<br>
- * -All geometry are copied into the union
- * @param interior The spaces to make a union of
- */
- public static void makeUnion(Collection<Space> interior) {
- Collection<Surface> boundary = new LinkedList<Surface>();
- Collection<Surface> innerSurfs = new HashSet<Surface>();
- Space owner = null;
- for (Space s : interior) {
- owner = s.getOwner();
- for (Surface surface : s.getEnvelope()) {
- if (interior.contains(surface.getFrontDomain()) &&
- interior.contains(surface.getBackDomain())) {
- innerSurfs.add(surface);
- } else {
- boundary.add(surface);
- }
- }
- }
-
- Space union = owner.createUnion("unnamed");
- owner.add(union);
-
- for (Surface surface : boundary) {
- Surface copy = surface.copy(union);
- Space front = surface.getFrontDomain();
- if (!interior.contains(front)) {
- copy.setFrontDomain(union.getEmpty());
- } else {
- surface.setFrontDomain(union);
- copy.setFrontDomain(front);
- }
- Space back = surface.getBackDomain();
- if (!interior.contains(back)) {
- copy.setBackDomain(union.getEmpty());
- } else {
- surface.setBackDomain(union);
- copy.setBackDomain(back);
- }
- }
- Set<Edge> danglingEdges = new HashSet<Edge>();
- for (Surface surface : innerSurfs) {
- owner.remove(surface);
- danglingEdges.addAll(surface.getEdges());
- union.add(surface);
- }
-
- Set<Vertex> danglingVertex = new HashSet<Vertex>();
- for (Edge e : danglingEdges) {
- if (e.getSurfaces().isEmpty()) {
- danglingVertex.add(e.getFrom());
- danglingVertex.add(e.getTo());
- owner.remove(e);
- union.add(e);
- }
- }
-
- for (Vertex v : danglingVertex) {
- if (v.getEdges().isEmpty()) {
- owner.remove(v);
- union.add(v);
- }
- }
-
- for (Space space : interior) {
- owner.elements.remove(space.getId());
- union.add(space);
- }
- }
-
- /**
* Getter for anchor
* @return The anchor
--- 2835,2838 ----
|