[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model SpaceAnalysis.java, 1.12, 1.13
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2008-10-13 10:54:29
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv19501/src/net/sourceforge/bprocessor/model Modified Files: SpaceAnalysis.java Log Message: Index: SpaceAnalysis.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/SpaceAnalysis.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** SpaceAnalysis.java 31 Jan 2008 14:32:12 -0000 1.12 --- SpaceAnalysis.java 13 Oct 2008 10:54:13 -0000 1.13 *************** *** 86,94 **** while (!queue.isEmpty()) { Element element = queue.remove(); ! process(element); } } ! private void process(Element element) { Surface surface = element.surface(); int side = element.side; --- 86,95 ---- while (!queue.isEmpty()) { Element element = queue.remove(); ! propgate(element); } } ! ! private void propgate(Element element) { Surface surface = element.surface(); int side = element.side; *************** *** 100,118 **** if (selected != null) { if (!mark.contains(selected)) { if (travel(surface, current) == travel(selected, current)) { ! if (side == 1) { ! selected.setBackDomain(surface.getFrontDomain()); ! } else { ! selected.setFrontDomain(surface.getBackDomain()); ! } ! queue.offer(new Element(selected, -side)); } else { ! if (side == 1) { ! selected.setFrontDomain(surface.getFrontDomain()); ! } else { ! selected.setBackDomain(surface.getBackDomain()); ! } ! queue.offer(new Element(selected, side)); } } } --- 101,112 ---- if (selected != null) { if (!mark.contains(selected)) { + int other = 0; if (travel(surface, current) == travel(selected, current)) { ! other = -side; } else { ! other = side; } + setSide(selected, other, getSide(surface, side)); + queue.offer(new Element(selected, other)); } } *************** *** 121,124 **** --- 115,187 ---- } + /** + * Subsume a space assignment in specified direction + * 1 = front and -1 = back from a neighbour + * @param surface Surface whose space assigment is propagated + * @param side side of surface to start + */ + public void subsume(Surface surface, int side) { + Container space = surface.getOwner(); + edgemap = new HashMap(); + for (Edge current : space.getEdges()) { + edgemap.put(current, new LinkedList()); + } + for (Surface current : space.getSurfaces()) { + for (Edge edge : current.getEdges()) { + edgemap.get(edge).add(current); + } + } + + mark = new HashSet(); + Element element = new Element(surface, side); + subsume(element); + } + + + private void subsume(Element element) { + Surface surface = element.surface(); + int side = element.side; + if (!mark.contains(surface)) { + mark.add(surface); + Container assigned = getSide(surface, side); + if (assigned.isVoid()) { + for (Edge current : surface.getEdges()) { + List<Surface> surfaces = edgemap.get(current); + if (surfaces.size() > 1) { + Surface selected = select(current, surfaces, surface, side); + int other = 0; + if (travel(surface, current) == travel(selected, current)) { + other = -side; + } else { + other = side; + } + subsume(new Element(selected, other)); + Container container = getSide(selected, other); + if (!container.isVoid()) { + setSide(surface, side, container); + } + } + } + } + } + } + + private Container getSide(Surface surface, int side) { + if (side == 1) { + return surface.getFrontDomain(); + } else { + return surface.getBackDomain(); + } + } + + private void setSide(Surface surface, int side, Container space) { + if (side == 1) { + surface.setFrontDomain(space); + } else { + surface.setBackDomain(space); + } + } + + private Surface select(Edge edge, List<Surface> surfaces, Surface leader, int side) { Vertex n = edge.getDirection(); |