[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Edge.java, 1.59, 1.60
Status: Pre-Alpha
Brought to you by:
henryml
From: Nordholt <nor...@us...> - 2006-10-09 13:12:46
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv806/src/net/sourceforge/bprocessor/model Modified Files: Edge.java Log Message: fixed offset method to work with clockwise surfaces aswell. Index: Edge.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Edge.java,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** Edge.java 5 Oct 2006 11:27:04 -0000 1.59 --- Edge.java 9 Oct 2006 13:12:37 -0000 1.60 *************** *** 561,574 **** /** * Create a offset from a list of lines and a surface ! * PRECONDITION: all the edges have to be in the given surface and the edges ! * in the surface have to be counter clockwise drawn. If the edges are drawn clockwise ! * the offset will be negative outside and positive inside * @param which The list of edges in inner that are going to be offset * @param inner The surface ! * @param offset The offset negative inside and positive outside * @param directions The movement directions send a empty list to retrieve direction map * @return The generated list of Edges */ public static List offset(List which, Surface inner, double offset, Map directions) { HashSet edges = new HashSet(which); ArrayList res = new ArrayList(); --- 561,573 ---- /** * Create a offset from a list of lines and a surface ! * PRECONDITION: all the edges have to be in the given surface. * @param which The list of edges in inner that are going to be offset * @param inner The surface ! * @param offset The offset: negative inside and positive outside * @param directions The movement directions send a empty list to retrieve direction map * @return The generated list of Edges */ public static List offset(List which, Surface inner, double offset, Map directions) { + boolean clockwise = Geometry.angle(inner.getVertices()) > 0; HashSet edges = new HashSet(which); ArrayList res = new ArrayList(); *************** *** 579,586 **** HashMap from2edge = new HashMap(); HashMap v2v = new HashMap(); - Iterator iter = inner.getEdges().iterator(); - Edge prevEdge = null; // Find all the affected vertexes and make the edges while (iter.hasNext()) { Edge e = (Edge)iter.next(); --- 578,584 ---- HashMap from2edge = new HashMap(); HashMap v2v = new HashMap(); Edge prevEdge = null; // Find all the affected vertexes and make the edges + Iterator iter = inner.getEdges().iterator(); while (iter.hasNext()) { Edge e = (Edge)iter.next(); *************** *** 661,665 **** dir2.normalize(); Vertex mainDir = dir1.add(dir2); ! mainDir.scale(1 / mainDir.dot(dir1)); dir.setDirection(mainDir); } else { --- 659,667 ---- dir2.normalize(); Vertex mainDir = dir1.add(dir2); ! if (clockwise) { ! mainDir.scale(-1 / mainDir.dot(dir1)); ! } else { ! mainDir.scale(1 / mainDir.dot(dir1)); ! } dir.setDirection(mainDir); } else { *************** *** 671,675 **** Vertex dir2 = other.minus(work); dir2.normalize(); ! dir2.scale(1 / dir2.dot(dir1)); dir.setDirection(dir2); } --- 673,681 ---- Vertex dir2 = other.minus(work); dir2.normalize(); ! if (clockwise) { ! dir2.scale(-1 / dir2.dot(dir1)); ! } else { ! dir2.scale(1 / dir2.dot(dir1)); ! } dir.setDirection(dir2); } *************** *** 682,686 **** Vertex dir1 = other.minus(work); dir1.normalize(); ! dir1.scale(1 / dir1.dot(dir2)); dir.setDirection(dir1); } --- 688,696 ---- Vertex dir1 = other.minus(work); dir1.normalize(); ! if (clockwise) { ! dir1.scale(-1 / dir1.dot(dir2)); ! } else { ! dir1.scale(1 / dir1.dot(dir2)); ! } dir.setDirection(dir1); } |