Thread: [Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Edge.java, 1.61, 1.62
Status: Pre-Alpha
Brought to you by:
henryml
From: Nordholt <nor...@us...> - 2006-10-16 15:15:11
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv1368/src/net/sourceforge/bprocessor/model Modified Files: Edge.java Log Message: Fixed error ocurring in offset when a surface was flipped. Should now work in some more cases. Index: Edge.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Edge.java,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** Edge.java 16 Oct 2006 06:49:25 -0000 1.61 --- Edge.java 16 Oct 2006 15:14:51 -0000 1.62 *************** *** 584,588 **** */ 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(); --- 584,587 ---- *************** *** 594,598 **** HashMap v2v = new HashMap(); Edge prevEdge = null; ! // Find all the affected vertexes and make the edges Iterator iter = inner.getEdges().iterator(); while (iter.hasNext()) { --- 593,598 ---- HashMap v2v = new HashMap(); Edge prevEdge = null; ! Edge firstEdge = null; ! // Find all the affected vertices and make the edges Iterator iter = inner.getEdges().iterator(); while (iter.hasNext()) { *************** *** 615,665 **** v2v.put(from, e.getFrom()); res.add(new Edge(from, to)); ! /*if (from2edge.containsKey(e.getFrom()) || prevEdge == null) { ! from2edge.put(e.getTo(), e); ! to2edge.put(e.getFrom(), e); ! } else { ! from2edge.put(e.getFrom(), e); ! to2edge.put(e.getTo(), e); ! }*/ ! Vertex common = Edge.commonVertex(e, prevEdge); ! if (common == null) { ! from2edge.put(e.getFrom(), e); ! to2edge.put(e.getTo(), e); ! } else { ! if (from2edge.containsKey(common)) { ! to2edge.put(common, e); ! from2edge.put(e.otherVertex(common), e); ! } else if (to2edge.containsKey(common)) { ! from2edge.put(common, e); ! to2edge.put(e.otherVertex(common), e); ! } else { ! log.error("common should be either from or to???"); ! } ! } } else { ! Vertex common = Edge.commonVertex(e, prevEdge); ! if (common == null) { ! from2edge.put(e.getFrom(), e); ! to2edge.put(e.getTo(), e); ! } else { ! if (from2edge.containsKey(common)) { ! to2edge.put(common, e); ! from2edge.put(e.otherVertex(common), e); ! } else if (to2edge.containsKey(common)) { ! from2edge.put(common, e); ! to2edge.put(e.otherVertex(common), e); ! } else { ! log.error("common should be either from or to???"); ! } ! } } prevEdge = e; } // calculate the directions iter = directions.values().iterator(); while (iter.hasNext()) { Direction dir = (Direction)iter.next(); ! Vertex work = (Vertex)v2v.get(dir.getVertex()); ! Vertex normal = inner.normal(); Edge e1 = (Edge)to2edge.get(work); Edge e2 = (Edge)from2edge.get(work); --- 615,638 ---- v2v.put(from, e.getFrom()); res.add(new Edge(from, to)); ! } ! if (prevEdge != null) { ! Vertex common = commonVertex(prevEdge, e); ! from2edge.put(common, prevEdge); ! to2edge.put(common, e); } else { ! firstEdge = e; } prevEdge = e; } + Vertex common = commonVertex(firstEdge, prevEdge); + from2edge.put(common, prevEdge); + to2edge.put(common, firstEdge); + // calculate the directions + Vertex normal = inner.normal(); iter = directions.values().iterator(); while (iter.hasNext()) { Direction dir = (Direction)iter.next(); ! Vertex work = (Vertex)v2v.get(dir.getVertex()); Edge e1 = (Edge)to2edge.get(work); Edge e2 = (Edge)from2edge.get(work); *************** *** 674,682 **** 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 { --- 647,651 ---- dir2.normalize(); Vertex mainDir = dir1.add(dir2); ! mainDir.scale(1 / mainDir.dot(dir1)); dir.setDirection(mainDir); } else { *************** *** 688,696 **** 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); } --- 657,661 ---- Vertex dir2 = other.minus(work); dir2.normalize(); ! dir2.scale(1 / dir2.dot(dir1)); dir.setDirection(dir2); } *************** *** 703,711 **** 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); } --- 668,672 ---- Vertex dir1 = other.minus(work); dir1.normalize(); ! dir1.scale(1 / dir1.dot(dir2)); dir.setDirection(dir1); } *************** *** 715,729 **** while (diriter.hasNext()) { Direction cur = (Direction)diriter.next(); ! Vertex dir = cur.getDirection().copy(); dir.scale(offset); cur.getVertex().move(dir.getX(), dir.getY(), dir.getZ()); ! } ! return res; } /** ! * Find the common edge of the two given edges, if ther is one ! * otherwise it just return null * @param e1 The first edge * @param e2 The second edge --- 676,691 ---- while (diriter.hasNext()) { Direction cur = (Direction)diriter.next(); ! Vertex dir = cur.getDirection(); ! dir.scale(-1); ! dir = dir.copy(); dir.scale(offset); cur.getVertex().move(dir.getX(), dir.getY(), dir.getZ()); ! } return res; } /** ! * Find the common vertex of the two given edges, if there is one ! * otherwise return null * @param e1 The first edge * @param e2 The second edge |