[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool OffsetTool.java, 1.18, 1.19
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2007-10-05 09:08:22
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv23250/src/net/sourceforge/bprocessor/gl/tool Modified Files: OffsetTool.java Log Message: Made offsetTool offset the right way... Relies on the fact that a surface can tell if the press point is inside it or not, which can fail Index: OffsetTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/OffsetTool.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** OffsetTool.java 27 Sep 2007 10:50:16 -0000 1.18 --- OffsetTool.java 5 Oct 2007 09:08:14 -0000 1.19 *************** *** 14,17 **** --- 14,18 ---- import java.util.ArrayList; import java.util.Collection; + import java.util.Collections; import java.util.HashSet; import java.util.List; *************** *** 110,121 **** outNormal = dir.cross(offsetCoord.getN()); outNormal.normalize(); ! if (offsetSurface != null && current != null) { ! if (offsetSurface.surrounds(current.vertex())) { ! if (outNormal.dot(current.vertex().minus(edgePoint)) > 0) { ! outNormal.scale(-1); } } else { ! if (outNormal.dot(current.vertex().minus(edgePoint)) < 0) { ! outNormal.scale(-1); } } --- 111,142 ---- outNormal = dir.cross(offsetCoord.getN()); outNormal.normalize(); ! if (current != null) { ! if (offsetSurface != null) { ! if (offsetSurface.surrounds(current.vertex())) { ! if (outNormal.dot(current.vertex().minus(edgePoint)) > 0) { ! outNormal.scale(-1); ! } ! } else { ! if (outNormal.dot(current.vertex().minus(edgePoint)) < 0) { ! outNormal.scale(-1); ! } } } else { ! List<Edge> edges = new ArrayList<Edge>(); ! edges.addAll(finalEdgeList); ! Vertex first = Edge.commonVertex(finalEdgeList.get(0), finalEdgeList.get(1)); ! Vertex last = Edge.commonVertex(finalEdgeList.getLast(), ! finalEdgeList.get(finalEdgeList.size() - 2)); ! //edges.add(new Edge(first, last)); ! Surface s = new Surface(edges); ! if (s.surrounds(current.vertex())) { ! if (outNormal.dot(current.vertex().minus(edgePoint)) > 0) { ! outNormal.scale(-1); ! } ! log.debug("Surrounds"); ! } else { ! if (outNormal.dot(current.vertex().minus(edgePoint)) < 0) { ! outNormal.scale(-1); ! } } } *************** *** 147,150 **** --- 168,174 ---- feedback.addAll(contour); feedback.add(guide); + if (log.isDebugEnabled()) { + feedback.add(new Edge(start.vertex(), start.vertex().add(outNormal))); + } feedback(feedback); } else { *************** *** 417,420 **** --- 441,447 ---- offsetCoord = new CoordinateSystem(i, j, n, first.getFrom()); } + if (Surface.direction(finalEdgeList, offsetCoord) == Surface.RIGHT) { + Collections.reverse(finalEdgeList); + } } } |