[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool PencilTool.java, 1.70, 1.71
Status: Pre-Alpha
Brought to you by:
henryml
|
From: Michael L. <he...@us...> - 2006-12-09 16:33:13
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv3218/src/net/sourceforge/bprocessor/gl/tool Modified Files: PencilTool.java Log Message: Started work on incremental version of pencil algo Index: PencilTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/PencilTool.java,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** PencilTool.java 7 Dec 2006 23:06:02 -0000 1.70 --- PencilTool.java 9 Dec 2006 16:33:09 -0000 1.71 *************** *** 111,115 **** public void actionPerformed(ActionEvent arg0) { Space space = Project.getInstance().getActiveSpace(); ! clearSurfaces(space); surfaceAnalysis(space); Project.getInstance().changed(space); --- 111,115 ---- public void actionPerformed(ActionEvent arg0) { Space space = Project.getInstance().getActiveSpace(); ! //clearSurfaces(space); surfaceAnalysis(space); Project.getInstance().changed(space); *************** *** 385,388 **** --- 385,422 ---- } { + Set keys = emap.keySet(); + Collection surfaces = space.getSurfaces(); + Iterator iter = surfaces.iterator(); + while (iter.hasNext()) { + Surface current = (Surface) iter.next(); + if (keys.containsAll(current.getEdges())) { + SurfaceNode surfacenode = new SurfaceNode(current); + int direction = Surface.direction(current.getEdges(), system); + if (direction == Surface.RIGHT) { + Iterator eit = current.getEdges().iterator(); + VertexNode from = (VertexNode) vmap.get(current.getFirstVertex()); + while (eit.hasNext()) { + Edge edge = (Edge) eit.next(); + EdgeNode node = (EdgeNode) emap.get(edge); + VertexNode to = node.other(from); + node.setRight(to, surfacenode); + from = to; + } + } + if (direction == Surface.LEFT) { + Iterator eit = current.getEdges().iterator(); + VertexNode from = (VertexNode) vmap.get(current.getFirstVertex()); + while (eit.hasNext()) { + Edge edge = (Edge) eit.next(); + EdgeNode node = (EdgeNode) emap.get(edge); + VertexNode to = node.other(from); + node.setLeft(to, surfacenode); + from = to; + } + } + } + } + } + { Iterator iter = emap.values().iterator(); System.out.println("-- analysis --"); *************** *** 429,432 **** --- 463,467 ---- System.out.println(current); nodes.add(current); + s.consume(current.getLeft(to)); current.setLeft(to, s); current = current.pred(to); *************** *** 439,442 **** --- 474,478 ---- if (turn == Surface.LEFT) { System.out.println("turns left"); + System.out.println("consumes " + s.surfaces); Surface surface = new Surface(edges); Project.getInstance().getActiveSpace().add(surface); *************** *** 456,459 **** --- 492,496 ---- System.out.println(current); nodes.add(current); + s.consume(current.getRight(to)); current.setRight(to, s); current = current.succ(to); *************** *** 469,472 **** --- 506,510 ---- if (turn == Surface.RIGHT) { System.out.println("turns right"); + System.out.println("consumes " + s.surfaces); Surface surface = new Surface(edges); Project.getInstance().getActiveSpace().add(surface); *************** *** 771,774 **** --- 809,853 ---- */ public class SurfaceNode { + /** + * The set of surfaces is the surfaces is in the model prior to + * surface analysis. Newly created surfaces inherit properties from + * the existing surfaces that are later deleted. + * + * Unless the geometry was malformed, there is only one surface related + * to this SurfaceNode. More than one surface means that an edge is part + * of more than two surfaces in a plane. This can happen easily with + * the current geometric tools. + */ + private Set surfaces; + + /** + * Constructs this SurfaceNode with an empty set of surfaces + */ + public SurfaceNode() { + super(); + surfaces = new HashSet(); + } + /** + * Constructs this SurfaceNode with the given surface in the set + * of surfaces + * @param surface a surface related to this SurfaceNode + */ + public SurfaceNode(Surface surface) { + super(); + surfaces = new HashSet(); + surfaces.add(surface); + } + + /** + * Adds the surfaces from another SurfaceNode to the set of + * surfaces of this SurfaceNode. The other SurfaceNode may + * be null. + * @param other possibly null SurfaceNode from wich to add surfaces + */ + public void consume(SurfaceNode other) { + if (other != null) { + surfaces.addAll(other.surfaces); + } + } } } |