Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv20365/src/net/sourceforge/bprocessor/model
Modified Files:
Edge.java
Log Message:
Added extrusion of a contour to the edge class, havn't implemented the tool interaction yet
Index: Edge.java
===================================================================
RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Edge.java,v
retrieving revision 1.73
retrieving revision 1.74
diff -C2 -d -r1.73 -r1.74
*** Edge.java 16 Feb 2007 09:47:43 -0000 1.73
--- Edge.java 8 Mar 2007 12:07:28 -0000 1.74
***************
*** 949,952 ****
--- 949,995 ----
/**
+ * Extrude a set of lines in a given direction, create the surfaces in between
+ * @param edges The edges to extrude
+ * @param direction the direction of the extrusion
+ * @return the generated surfaces during extrusion
+ */
+ public static Collection<Geometric> extrude(Set<Edge> edges, Vertex direction) {
+ Collection<Geometric> extrusion = new ArrayList<Geometric>();
+ if (edges == null || edges.isEmpty() || direction == null) {
+ return extrusion;
+ }
+ Map<Vertex, Vertex> vertexmap = new HashMap<Vertex, Vertex>();
+ Map<Vertex, Edge> sideMap = new HashMap<Vertex, Edge>();
+ Map<Edge, Edge> topMap = new HashMap<Edge, Edge>();
+ Set<Vertex> vertexes = Geometry.collect(edges);
+
+ // generate new vertexes and edges to them
+ for (Vertex v : vertexes) {
+ Vertex newv = v.add(direction);
+ vertexmap.put(v, newv);
+ Edge newe = new Edge(v, newv);
+ sideMap.put(v, newe);
+ }
+
+ // generate the displaces edges
+ for (Edge e : edges) {
+ Edge ecopy = new Edge(vertexmap.get(e.getFrom()), vertexmap.get(e.getTo()));
+ topMap.put(e, ecopy);
+ }
+
+ // generate surfaces
+ for (Edge e : edges) {
+ ArrayList<Edge> surfaceedges = new ArrayList<Edge>(4);
+ surfaceedges.add(sideMap.get(e.getFrom()));
+ surfaceedges.add(topMap.get(e));
+ surfaceedges.add(sideMap.get(e.getTo()));
+ surfaceedges.add(e);
+ extrusion.add(new Surface(surfaceedges));
+ }
+
+ return extrusion;
+ }
+
+ /**
* Find the common vertex of the two given edges, if there is one
* otherwise return null
|