Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv17140/src/net/sourceforge/bprocessor/gui
Modified Files:
PopupMenu.java
Log Message:
Union started
Index: PopupMenu.java
===================================================================
RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/PopupMenu.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** PopupMenu.java 29 Dec 2006 13:32:57 -0000 1.19
--- PopupMenu.java 22 Jan 2007 15:40:22 -0000 1.20
***************
*** 31,34 ****
--- 31,35 ----
import net.sourceforge.bprocessor.model.Edge;
import net.sourceforge.bprocessor.model.Entity;
+ import net.sourceforge.bprocessor.model.Geometric;
import net.sourceforge.bprocessor.model.Geometry;
import net.sourceforge.bprocessor.model.Project;
***************
*** 383,386 ****
--- 384,428 ----
};
menu.add(allConnected);
+ AbstractAction makeUnion = new EntitiesMenuAction(entities, "Make Union") {
+ public void actionPerformed(ActionEvent e) {
+ Collection<Surface> surfaces = new HashSet<Surface>();
+ Collection<Geometric> geometrics = (Collection<Geometric>) entities;
+ for (Geometric geometric: geometrics) {
+ if (geometric instanceof Surface) {
+ surfaces.add((Surface) geometric);
+ }
+ }
+ Collection<Space> spaces = new HashSet<Space>();
+ for (Surface surface: surfaces) {
+ Space empty = surface.getOwner().getEmpty();
+ if (surface.getFrontDomain() != empty) {
+ spaces.add(surface.getFrontDomain());
+ }
+ if (surface.getBackDomain() != empty) {
+ spaces.add(surface.getBackDomain());
+ }
+ }
+ Collection<Space> interior = new HashSet<Space>();
+ for (Space space: spaces) {
+ interior.add(space);
+ }
+ for (Space space: interior) {
+ surfaces.addAll(space.getEnvelope());
+ }
+ Collection<Surface> inside = new LinkedList<Surface>();
+ Collection<Surface> border = new LinkedList<Surface>();
+ for (Surface surface: surfaces) {
+ if (interior.contains(surface.getFrontDomain()) &&
+ interior.contains(surface.getBackDomain())) {
+ inside.add(surface);
+ } else {
+ border.add(surface);
+ }
+ }
+ Selection.primary().clear();
+ Selection.primary().addAll(border);
+ }
+ };
+ menu.add(makeUnion);
return menu;
}
|