[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool PencilTool.java, 1.71, 1.72
Status: Pre-Alpha
Brought to you by:
henryml
|
From: Michael L. <he...@us...> - 2006-12-11 10:44:59
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv24179/src/net/sourceforge/bprocessor/gl/tool Modified Files: PencilTool.java Log Message: Progress 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.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** PencilTool.java 9 Dec 2006 16:33:09 -0000 1.71 --- PencilTool.java 11 Dec 2006 10:44:51 -0000 1.72 *************** *** 26,29 **** --- 26,30 ---- import net.sourceforge.bprocessor.gl.GLView; + import net.sourceforge.bprocessor.gl.view.View; import net.sourceforge.bprocessor.model.CoordinateSystem; import net.sourceforge.bprocessor.model.Entity; *************** *** 40,43 **** --- 41,45 ---- */ public class PencilTool extends AbstractPencil { + private Collection edges; /** * Constructor for Pencil *************** *** 47,50 **** --- 49,53 ---- public PencilTool(GLView glv, Cursor cursor) { super(glv, cursor); + edges = new LinkedList(); dragging = false; } *************** *** 183,191 **** } /** * @param space Space ! * @return Collection of CoordinateSystem */ public Collection planeAnalysis(Space space) { Collection systems = new LinkedList(); Collection edges = space.getEdges(); --- 186,205 ---- } + /** + * * @param space Space ! * @return collection of CoordinateSystem */ public Collection planeAnalysis(Space space) { + return planeAnalysis(space, space.getEdges()); + } + + /** + * @param space Space + * @param start Collection + * @return Collection of CoordinateSystem + */ + public Collection planeAnalysis(Space space, Collection start) { Collection systems = new LinkedList(); Collection edges = space.getEdges(); *************** *** 246,253 **** } } ! ! Iterator iter = edges.iterator(); ! while (iter.hasNext()) { ! Edge current = (Edge) iter.next(); if (!mark.contains(current)) { mark.add(current); --- 260,266 ---- } } ! LinkedList queue = new LinkedList(start); ! while (!queue.isEmpty()) { ! Edge current = (Edge) queue.removeFirst(); if (!mark.contains(current)) { mark.add(current); *************** *** 298,301 **** --- 311,316 ---- } else { Edge edge = new Edge(start.vertex(), current.vertex()); + edges.add(edge); + glv.getView().changeColor(edge, View.CLIP_PLANE_COLOR); Project.getInstance().getActiveSpace().insert(edge); Project.getInstance().changed(Project.getInstance().getActiveSpace()); *************** *** 345,348 **** --- 360,367 ---- */ public void surfaceAnalysis(Space space, CoordinateSystem system) { + if (system.determinant() < 0) { + System.out.println("LEFT HAND OF DARKNESS"); + } + Plane plane = system.plane(); Map vmap = new LinkedHashMap(); *************** *** 418,421 **** --- 437,442 ---- } } + Set added = new HashSet(); + Set removed = new HashSet(); { Iterator iter = emap.values().iterator(); *************** *** 423,431 **** while (iter.hasNext()) { EdgeNode current = (EdgeNode) iter.next(); ! surfaceAnalysis(current, system); } } } /** * Return a list of Edge corresponding to a list of EdgeNodes such --- 444,490 ---- while (iter.hasNext()) { EdgeNode current = (EdgeNode) iter.next(); ! surfaceAnalysis(current, system, added, removed); ! } ! } ! { ! Iterator iter = removed.iterator(); ! while (iter.hasNext()) { ! Surface current = (Surface) iter.next(); ! space.remove(current); ! } ! } ! { ! Iterator iter = added.iterator(); ! while (iter.hasNext()) { ! Surface current = (Surface) iter.next(); ! space.add(current); } } } + private List rightContour(LinkedList queue) { + Set mark = new HashSet(); + while (!queue.isEmpty()) { + EdgeNode start = (EdgeNode) queue.removeFirst(); + if (!mark.contains(start)) { + mark.add(start); + if (start.left != start.right) { + List edges = new LinkedList(); + VertexNode to = start.to; + EdgeNode current = start; + EdgeNode next = null; + while (next != start) { + edges.add(current.edge); + next = current.succ(to); + if (next.left == next.right) { + next = next.succ(next.other(to)); + } + } + } + } + } + return null; + } + /** * Return a list of Edge corresponding to a list of EdgeNodes such *************** *** 448,457 **** } ! /** ! * ! * @param start EdgeNode ! * @param system CoordinateSystem ! */ ! public void surfaceAnalysis(EdgeNode start, CoordinateSystem system) { if (start.left == null) { System.out.println("left analyze " + start); --- 507,532 ---- } ! private void assign(Surface surface, Collection surfaces) { ! if (!surfaces.isEmpty()) { ! Surface other = (Surface) surfaces.iterator().next(); ! Vertex n1 = surface.normal(); ! Vertex n2 = other.normal(); ! if (n1.dot(n2) > 0) { ! surface.setBackDomain(other.getBackDomain()); ! surface.setBackMaterial(other.getBackMaterial()); ! surface.setFrontDomain(other.getFrontDomain()); ! surface.setFrontMaterial(other.getFrontMaterial()); ! } else { ! surface.setBackDomain(other.getFrontDomain()); ! surface.setBackMaterial(other.getFrontMaterial()); ! surface.setFrontDomain(other.getBackDomain()); ! surface.setFrontMaterial(other.getBackMaterial()); ! } ! } ! } ! ! private void surfaceAnalysis (EdgeNode start, CoordinateSystem system, ! Set added, Set removed) { ! glv.getView().clearColor(start.edge); if (start.left == null) { System.out.println("left analyze " + start); *************** *** 476,480 **** System.out.println("consumes " + s.surfaces); Surface surface = new Surface(edges); ! Project.getInstance().getActiveSpace().add(surface); } if (turn == Surface.RIGHT) { --- 551,557 ---- System.out.println("consumes " + s.surfaces); Surface surface = new Surface(edges); ! assign(surface, s.surfaces); ! added.add(surface); ! removed.addAll(s.surfaces); } if (turn == Surface.RIGHT) { *************** *** 508,512 **** System.out.println("consumes " + s.surfaces); Surface surface = new Surface(edges); ! Project.getInstance().getActiveSpace().add(surface); } } --- 585,591 ---- System.out.println("consumes " + s.surfaces); Surface surface = new Surface(edges); ! assign(surface, s.surfaces); ! added.add(surface); ! removed.addAll(s.surfaces); } } |