[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Edge.java, 1.57, 1.58 Surface.java,
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2006-09-18 14:51:22
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv17863/src/net/sourceforge/bprocessor/model Modified Files: Edge.java Surface.java Geometry.java Point.java Log Message: Made changes to extrude tool to use extend abstractpencil and therfore making escape work and modified offset to use Edge.offset and thereby giving way for offset of only a subset of edges... There are still some bugs to be fixed Index: Surface.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Surface.java,v retrieving revision 1.110 retrieving revision 1.111 diff -C2 -d -r1.110 -r1.111 *** Surface.java 17 Sep 2006 22:00:21 -0000 1.110 --- Surface.java 18 Sep 2006 14:10:07 -0000 1.111 *************** *** 1479,1481 **** --- 1479,1503 ---- } } + + /** + * Find the nearest intersection with a edge in the surface + * @param vertex the mouse position on the surface + * @return the nearest edge + */ + public Edge findClosestEdge(Vertex vertex) { + Iterator iter = getEdges().iterator(); + Vertex v = null; + Edge closest = null; + double distance = Double.MAX_VALUE; + while (iter.hasNext()) { + Edge cur = (Edge)iter.next(); + Vertex tmp = cur.intersection(vertex); + if (tmp.minus(vertex).length() < distance) { + distance = tmp.minus(vertex).length(); + v = tmp; + closest = cur; + } + } + return closest; + } } Index: Point.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Point.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Point.java 8 Sep 2006 13:25:59 -0000 1.9 --- Point.java 18 Sep 2006 14:10:07 -0000 1.10 *************** *** 84,86 **** --- 84,94 ---- return "P-" + getId(); } + + /** + * Generate a string of Point + * @return the textual repestation of Point + */ + public String toString() { + return "Point[" + getOrigin() + "]"; + } } Index: Geometry.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Geometry.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** Geometry.java 17 Sep 2006 17:29:25 -0000 1.26 --- Geometry.java 18 Sep 2006 14:10:07 -0000 1.27 *************** *** 842,849 **** boolean closed = false; if (!edges.isEmpty()) { ! Vertex from = ((Edge) edges.get(0)).getFrom(); ! Vertex to = ((Edge) edges.get(edges.size() - 1)).getTo(); ! ! if (from == to) { List actual = new LinkedList(); Iterator iter = edges.iterator(); --- 842,847 ---- boolean closed = false; if (!edges.isEmpty()) { ! Vertex v = Edge.commonVertex((Edge) edges.get(0), (Edge) edges.get(edges.size() - 1)); ! if (v != null && edges.size() > 2) { List actual = new LinkedList(); Iterator iter = edges.iterator(); Index: Edge.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Edge.java,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** Edge.java 7 Sep 2006 15:50:51 -0000 1.57 --- Edge.java 18 Sep 2006 14:10:07 -0000 1.58 *************** *** 15,18 **** --- 15,19 ---- import java.util.Iterator; import java.util.List; + import java.util.Map; import java.util.Set; *************** *** 541,545 **** return surfaces; } ! /** * Create a offset from a list of lines and a surface --- 542,546 ---- return surfaces; } ! /** * Create a offset from a list of lines and a surface *************** *** 553,559 **** */ public static List offset(List which, Surface inner, double offset) { HashSet edges = new HashSet(which); ArrayList res = new ArrayList(); ! HashMap directions = new HashMap(); HashMap to2edge = new HashMap(); HashMap from2edge = new HashMap(); --- 554,577 ---- */ public static List offset(List 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 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(); ! if (directions == null) { ! directions = new HashMap(); ! } HashMap to2edge = new HashMap(); HashMap from2edge = new HashMap(); *************** *** 581,585 **** v2v.put(to, e.getTo()); v2v.put(from, e.getFrom()); ! res.add(new Edge(to, from)); /*if (from2edge.containsKey(e.getFrom()) || prevEdge == null) { from2edge.put(e.getTo(), e); --- 599,603 ---- v2v.put(to, e.getTo()); v2v.put(from, e.getFrom()); ! res.add(new Edge(from, to)); /*if (from2edge.containsKey(e.getFrom()) || prevEdge == null) { from2edge.put(e.getTo(), e); *************** *** 670,674 **** while (diriter.hasNext()) { Direction cur = (Direction)diriter.next(); ! Vertex dir = cur.getDirection(); dir.scale(offset); cur.getVertex().move(dir.getX(), dir.getY(), dir.getZ()); --- 688,692 ---- 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()); *************** *** 685,689 **** * @return The common vertex or null if none */ ! private static Vertex commonVertex(Edge e1, Edge e2) { if (e1 == null || e2 == null) { return null; --- 703,707 ---- * @return The common vertex or null if none */ ! public static Vertex commonVertex(Edge e1, Edge e2) { if (e1 == null || e2 == null) { return null; |