Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv25933/src/net/sourceforge/bprocessor/gui
Modified Files:
PopupMenu.java
Log Message:
Union progress
Index: PopupMenu.java
===================================================================
RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/PopupMenu.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** PopupMenu.java 22 Jan 2007 15:40:22 -0000 1.20
--- PopupMenu.java 23 Jan 2007 10:51:55 -0000 1.21
***************
*** 9,15 ****
--- 9,17 ----
import java.awt.event.ActionEvent;
import java.util.Collection;
+ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
+ import java.util.Map;
import java.util.Set;
***************
*** 394,399 ****
}
Collection<Space> spaces = new HashSet<Space>();
for (Surface surface: surfaces) {
! Space empty = surface.getOwner().getEmpty();
if (surface.getFrontDomain() != empty) {
spaces.add(surface.getFrontDomain());
--- 396,403 ----
}
Collection<Space> spaces = new HashSet<Space>();
+ Space owner = null;
for (Surface surface: surfaces) {
! owner = surface.getOwner();
! Space empty = owner.getEmpty();
if (surface.getFrontDomain() != empty) {
spaces.add(surface.getFrontDomain());
***************
*** 420,425 ****
}
}
Selection.primary().clear();
! Selection.primary().addAll(border);
}
};
--- 424,492 ----
}
}
+ Space union = owner.createConstructionSpace("Union");
+ union.setUnion(true);
+
+ Map<Geometric, Geometric> map = new HashMap<Geometric, Geometric>();
+
+ for(Space space:interior) {
+ Space copy = space.simpleCopy();
+ map.put(space, copy);
+ union.add(copy);
+ }
+
+ Collection<Surface> all = new LinkedList<Surface>();
+ Collection<Surface> deletion = new LinkedList<Surface>();
+
+ for(Surface surface:inside) {
+ Surface copy = surface.copy(map);
+ Space front = surface.getFrontDomain();
+ if (front != owner.getEmpty()) {
+ Space newFront = (Space) map.get(front);
+ if (newFront != null) {
+ copy.setFrontDomain(newFront);
+ }
+ }
+ Space back = surface.getBackDomain();
+ if (back != owner.getEmpty()) {
+ Space newBack = (Space) map.get(back);
+ if (newBack != null) {
+ copy.setBackDomain(newBack);
+ }
+ }
+ all.add(copy);
+ deletion.add(surface);
+ }
+ for(Surface surface:border) {
+ Surface copy = surface.copy(map);
+ Space front = surface.getFrontDomain();
+ if (front != owner.getEmpty()) {
+ Space newFront = (Space) map.get(front);
+ if (newFront != null) {
+ copy.setFrontDomain(newFront);
+ }
+ }
+ Space back = surface.getBackDomain();
+ if (back != owner.getEmpty()) {
+ Space newBack = (Space) map.get(back);
+ if (newBack != null) {
+ copy.setBackDomain(newBack);
+ }
+ }
+ all.add(copy);
+ if (front == owner.getEmpty() || back == owner.getEmpty()) {
+ deletion.add(surface);
+ }
+ }
+ union.addAll(all);
+ for(Geometric geometric:deletion) {
+ geometric.delete();
+ }
+ for(Space space:interior) {
+ space.delete();
+ }
+ owner.add(union);
+ Project.getInstance().changed(owner);
Selection.primary().clear();
! Selection.primary().add(union);
}
};
|