Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10019/src/net/sourceforge/bprocessor/model
Modified Files:
Space.java Container.java
Log Message:
implementing the closed operation on space
Index: Space.java
===================================================================
RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Space.java,v
retrieving revision 1.238
retrieving revision 1.239
diff -C2 -d -r1.238 -r1.239
*** Space.java 3 Nov 2008 14:26:18 -0000 1.238
--- Space.java 4 May 2009 09:43:24 -0000 1.239
***************
*** 17,20 ****
--- 17,21 ----
import java.util.List;
import java.util.Map;
+ import java.util.Queue;
import java.util.Set;
***************
*** 459,462 ****
--- 460,504 ----
/**
+ *
+ * @return true if closed
+ */
+ public boolean closed() {
+ List<Surface> envelope = new LinkedList(getEnvelope());
+ if (!envelope.isEmpty()) {
+ Surface leader = envelope.iterator().next();
+ Command.Inverse inv = new Command.Inverse(envelope);
+ Set<Surface> mark = new HashSet();
+ Queue<Surface> queue = new LinkedList();
+ queue.add(leader);
+ mark.add(leader);
+ while (!queue.isEmpty()) {
+ Surface current = queue.remove();
+ for (Edge edge : current.getEdges()) {
+ List<Surface> lst = inv.surfaces(edge);
+ for (Surface adjacent : lst) {
+ if (!mark.contains(adjacent)) {
+ mark.add(adjacent);
+ queue.add(adjacent);
+ }
+ }
+ }
+ }
+
+ List<Surface> unreachable = new LinkedList();
+ for (Surface current : envelope) {
+ if (!mark.contains(current)) {
+ unreachable.add(current);
+ }
+ }
+
+ System.out.println("unreach: " + unreachable.size());
+
+ return (unreachable.size() < 0);
+ } else {
+ return false;
+ }
+ }
+
+ /**
* Notify that this Space has changed
* FIXME: Make the change-update mechanism general
***************
*** 574,577 ****
--- 616,620 ----
res.add(new Attribute("Material", new Reference(material(), materials)));
res.add(new Attribute("Euler", Double.valueOf(eulerCharacteristic())));
+ res.add(new Attribute("Closed", Boolean.valueOf(closed())));
res.add(new Attribute("Description", getDescription()));
if (getModellor() != null) {
Index: Container.java
===================================================================
RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Container.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** Container.java 21 Apr 2009 10:21:21 -0000 1.20
--- Container.java 4 May 2009 09:43:24 -0000 1.21
***************
*** 1518,1521 ****
--- 1518,1523 ----
}
+
+
/**
*
|