[Bprocessor-commit] /model/src/net/sourceforge/bprocessor/model Edge.java, 1.95, 1.96
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2007-09-27 10:50:11
|
Update of /cvsroot/bprocessor//model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv15081/src/net/sourceforge/bprocessor/model Modified Files: Edge.java Log Message: Made som visual feedback and a changed structur for extrusion Index: Edge.java =================================================================== RCS file: /cvsroot/bprocessor//model/src/net/sourceforge/bprocessor/model/Edge.java,v retrieving revision 1.95 retrieving revision 1.96 diff -C2 -d -r1.95 -r1.96 *** Edge.java 13 Aug 2007 11:36:21 -0000 1.95 --- Edge.java 27 Sep 2007 10:50:13 -0000 1.96 *************** *** 706,710 **** * @return an offset-direction map for each vertex */ ! public static Map<Vertex, Vertex> offsetDirections(List<Edge> which, Surface inner, double offset) { Map<Edge, Double> offsets = new HashMap<Edge, Double>(); --- 706,710 ---- * @return an offset-direction map for each vertex */ ! public static Map<Vertex, Vertex> offsetDirections(List<Edge> which, CoordinateSystem inner, double offset) { Map<Edge, Double> offsets = new HashMap<Edge, Double>(); *************** *** 725,730 **** * @return an offset-direction map for each vertex */ ! public static Map<Vertex, Vertex> offsetDirections(List<Edge> which, Surface inner, ! Map<Edge, Double> offsetMap) { Map<Vertex, Vertex> v2Dir = new HashMap<Vertex, Vertex>(); Edge e1 = null; --- 725,730 ---- * @return an offset-direction map for each vertex */ ! public static Map<Vertex, Vertex> offsetDirections(List<Edge> which, ! CoordinateSystem inner, Map<Edge, Double> offsetMap) { Map<Vertex, Vertex> v2Dir = new HashMap<Vertex, Vertex>(); Edge e1 = null; *************** *** 733,737 **** Vertex work; boolean done = false; ! Iterator edges2 = inner.getEdges().iterator(); if (edges2.hasNext()) { first = (Edge)edges2.next(); --- 733,737 ---- Vertex work; boolean done = false; ! Iterator edges2 = which.iterator(); if (edges2.hasNext()) { first = (Edge)edges2.next(); *************** *** 743,747 **** done = true; } ! Vertex normal = inner.normal(); while (!done) { work = commonVertex(e1, e2); --- 743,747 ---- done = true; } ! Vertex normal = inner.getN(); while (!done) { work = commonVertex(e1, e2); *************** *** 823,827 **** e2e.put(e, new Edge((Vertex)v2v.get(from), (Vertex)v2v.get(to))); } ! Map directions = offsetDirections(which, inner, offsetMap); Edge e1 = null; Edge e2 = null; --- 823,827 ---- e2e.put(e, new Edge((Vertex)v2v.get(from), (Vertex)v2v.get(to))); } ! Map directions = offsetDirections(which, inner.coordinateSystem(), offsetMap); Edge e1 = null; Edge e2 = null; *************** *** 884,907 **** * @return The generated list of Edges */ ! public static List<Edge> offset(List<Edge> which, Surface inner, double offset) { ! return offset(which, inner, offset, null); } /** * 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 <Edge> offset(List<Edge> which, Surface inner, ! double offset, Map<Vertex, Direction> directions) { ! Map<Edge, Double> offsetMap = new HashMap<Edge, Double>(); ! for (Edge e : which) { ! offsetMap.put(e, Double.valueOf(offset)); ! } ! return offset(which, inner, offsetMap, directions); } --- 884,903 ---- * @return The generated list of Edges */ ! public static List<Edge> offset(Collection<Edge> which, Surface inner, double offset) { ! return offset(which, inner.coordinateSystem(), offset, null); } /** * 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 * @return The generated list of Edges */ ! public static List<Edge> offset(Collection<Edge> which, CoordinateSystem inner, double offset) { ! return offset(which, inner, offset, null); } *************** *** 911,920 **** * @param which The list of edges in inner that are going to be offset * @param inner The surface ! * @param offsetMap mapping each edge to the amount it should be offset * @param directions The movement directions send a empty list to retrieve direction map * @return The generated list of Edges */ ! public static List<Edge> offset(List<Edge> which, Surface inner, ! Map<Edge, Double> offsetMap, Map<Vertex, Direction> directions) { HashSet<Edge> edges = new HashSet<Edge>(which); ArrayList<Edge> res = new ArrayList<Edge>(); --- 907,916 ---- * @param which The list of edges in inner that are going to be offset * @param inner The surface ! * @param offset The offset size * @param directions The movement directions send a empty list to retrieve direction map * @return The generated list of Edges */ ! public static List<Edge> offset(Collection<Edge> which, CoordinateSystem inner, ! double offset, Map<Vertex, Direction> directions) { HashSet<Edge> edges = new HashSet<Edge>(which); ArrayList<Edge> res = new ArrayList<Edge>(); *************** *** 928,932 **** Edge firstEdge = null; // Find all the affected vertices and make the new edges ! Iterator iter = inner.getEdges().iterator(); while (iter.hasNext()) { Edge e = (Edge)iter.next(); --- 924,929 ---- Edge firstEdge = null; // Find all the affected vertices and make the new edges ! Vertex common = null; ! Iterator iter = which.iterator(); while (iter.hasNext()) { Edge e = (Edge)iter.next(); *************** *** 950,956 **** } if (prevEdge != null) { ! Vertex common = commonVertex(prevEdge, e); ! from2edge.put(common, prevEdge); ! to2edge.put(common, e); } else { firstEdge = e; --- 947,960 ---- } if (prevEdge != null) { ! common = commonVertex(prevEdge, e); ! if (common != null) { ! from2edge.put(common, e); ! to2edge.put(common, prevEdge); ! if (prevEdge == firstEdge) { ! from2edge.put(firstEdge.otherVertex(common), firstEdge); ! } ! } else { ! log.error("The collection of given edges have to be connected"); ! } } else { firstEdge = e; *************** *** 958,973 **** 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); if (edges.contains(e1)) { if (edges.contains(e2)) { --- 962,978 ---- prevEdge = e; } ! if (common != null) { ! to2edge.put(prevEdge.otherVertex(common), prevEdge); ! } // calculate the directions ! Vertex normal = inner.getN(); ! iter = directions.values().iterator(); while (iter.hasNext()) { Direction dir = (Direction)iter.next(); Vertex work = (Vertex)v2v.get(dir.getVertex()); ! Edge e1 = (Edge)from2edge.get(work); ! Edge e2 = (Edge)to2edge.get(work); if (edges.contains(e1)) { if (edges.contains(e2)) { *************** *** 987,995 **** dir1 = dir1.cross(normal); dir1.normalize(); ! Vertex other = e2.otherVertex(work); ! Vertex dir2 = other.minus(work); ! dir2.normalize(); ! dir2.scale(1 / dir2.dot(dir1)); ! dir.setDirection(dir2); } } else if (edges.contains(e2)) { --- 992,1012 ---- dir1 = dir1.cross(normal); dir1.normalize(); ! if (e2 == null) { ! for (Edge connected : work.getEdges()) { ! Vertex newdirection = dir1; ! if (connected != e1 && inner.isInXYPlane(connected)) { ! e2 = connected; ! } ! } ! } ! if (e2 != null) { ! Vertex other = e2.otherVertex(work); ! Vertex dir2 = other.minus(work); ! dir2.normalize(); ! dir2.scale(1 / dir2.dot(dir1)); ! dir.setDirection(dir2); ! } else { ! dir.setDirection(dir1); ! } } } else if (edges.contains(e2)) { *************** *** 998,1006 **** dir2 = dir2.cross(normal); dir2.normalize(); ! Vertex other = e1.otherVertex(work); ! Vertex dir1 = other.minus(work); ! dir1.normalize(); ! dir1.scale(1 / dir1.dot(dir2)); ! dir.setDirection(dir1); } } --- 1015,1037 ---- dir2 = dir2.cross(normal); dir2.normalize(); ! if (e1 == null) { ! for (Edge connected : work.getEdges()) { ! if (connected != e2 && inner.isInXYPlane(connected)) { ! e1 = connected; ! } ! } ! } ! if (e1 != null) { ! Vertex other = e1.otherVertex(work); ! Vertex dir1 = other.minus(work); ! dir1.normalize(); ! dir1.scale(1 / dir1.dot(dir2)); ! dir.setDirection(dir1); ! } else { ! dir.setDirection(dir2); ! } ! } else { ! dir.setDirection(new Vertex(0, 0, 0)); ! log.error("The consistence for " + work + " weird got no conected edges"); } } *************** *** 1012,1016 **** dir.scale(-1); dir = dir.copy(); ! dir.scale(((Double)offsetMap.values().iterator().next()).doubleValue()); cur.getVertex().move(dir.getX(), dir.getY(), dir.getZ()); } --- 1043,1047 ---- dir.scale(-1); dir = dir.copy(); ! dir.scale(offset); cur.getVertex().move(dir.getX(), dir.getY(), dir.getZ()); } |