[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool PencilTool.java, 1.72, 1.73
Status: Pre-Alpha
Brought to you by:
henryml
|
From: Michael L. <he...@us...> - 2006-12-11 11:59:16
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv22239/src/net/sourceforge/bprocessor/gl/tool Modified Files: PencilTool.java Log Message: Fixed bug in pencil algo when a hole is connected to exterior by *one* edge Index: PencilTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/PencilTool.java,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** PencilTool.java 11 Dec 2006 10:44:51 -0000 1.72 --- PencilTool.java 11 Dec 2006 11:59:15 -0000 1.73 *************** *** 463,506 **** } ! 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 ! * that all nodes with the same surfacenode on both sides are ignored. ! * @param nodes list of EdgeNode ! * @return list of Edge ! */ ! public List contour(List nodes) { List edges = new LinkedList(); ! { ! Iterator iter = nodes.iterator(); ! while (iter.hasNext()) { ! EdgeNode current = (EdgeNode) iter.next(); ! if (current.left != current.right) { ! edges.add(current.edge); ! } } } return edges; --- 463,496 ---- } ! private List rightContour(EdgeNode start) { ! 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(to); } + to = next.other(to); + current = next; } ! return edges; } ! private List leftContour(EdgeNode start) { List edges = new LinkedList(); ! VertexNode to = start.to; ! EdgeNode current = start; ! EdgeNode next = null; ! while (next != start) { ! edges.add(current.edge); ! next = current.pred(to); ! if (next.left == next.right) { ! next = next.pred(to); } + to = next.other(to); + current = next; } return edges; *************** *** 532,541 **** System.out.println("left analyze " + start); SurfaceNode s = new SurfaceNode(); - List nodes = new LinkedList(); VertexNode to = start.to; EdgeNode current = start; while (current.getLeft(to) != s) { System.out.println(current); - nodes.add(current); s.consume(current.getLeft(to)); current.setLeft(to, s); --- 522,529 ---- *************** *** 543,560 **** to = current.other(to); } ! List edges = contour(nodes); ! if (edges.size() > 2) { ! System.out.println("left surface:" + edges); ! int turn = Surface.direction(edges, system); ! if (turn == Surface.LEFT) { ! System.out.println("turns left"); ! 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) { ! System.out.println("turns right"); } } --- 531,550 ---- to = current.other(to); } ! if (start.left != start.right) { ! List edges = leftContour(start); ! if (edges.size() > 2) { ! System.out.println("left surface:" + edges); ! int turn = Surface.direction(edges, system); ! if (turn == Surface.LEFT) { ! System.out.println("turns left"); ! 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) { ! System.out.println("turns right"); ! } } } *************** *** 563,572 **** System.out.println("right analyze " + start); SurfaceNode s = new SurfaceNode(); - List nodes = new LinkedList(); VertexNode to = start.to; EdgeNode current = start; while (current.getRight(to) != s) { System.out.println(current); - nodes.add(current); s.consume(current.getRight(to)); current.setRight(to, s); --- 553,560 ---- *************** *** 574,591 **** to = current.other(to); } ! List edges = contour(nodes); ! if (edges.size() > 2) { ! System.out.println("right surface:" + edges); ! int turn = Surface.direction(edges, system); ! if (turn == Surface.LEFT) { ! System.out.println("turns left"); ! } ! if (turn == Surface.RIGHT) { ! System.out.println("turns right"); ! System.out.println("consumes " + s.surfaces); ! Surface surface = new Surface(edges); ! assign(surface, s.surfaces); ! added.add(surface); ! removed.addAll(s.surfaces); } } --- 562,581 ---- to = current.other(to); } ! if (start.right != start.left) { ! List edges = rightContour(start); ! if (edges.size() > 2) { ! System.out.println("right surface:" + edges); ! int turn = Surface.direction(edges, system); ! if (turn == Surface.LEFT) { ! System.out.println("turns left"); ! } ! if (turn == Surface.RIGHT) { ! System.out.println("turns right"); ! System.out.println("consumes " + s.surfaces); ! Surface surface = new Surface(edges); ! assign(surface, s.surfaces); ! added.add(surface); ! removed.addAll(s.surfaces); ! } } } |