[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Surface.java, 1.173, 1.174 Vertex.ja
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2007-09-07 13:21:21
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv14232/src/net/sourceforge/bprocessor/model Modified Files: Surface.java Vertex.java Log Message: Added a controlledExtrudeTool and made som refactoring on the way through the code. Index: Surface.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Surface.java,v retrieving revision 1.173 retrieving revision 1.174 diff -C2 -d -r1.173 -r1.174 *** Surface.java 3 Sep 2007 16:06:28 -0000 1.173 --- Surface.java 7 Sep 2007 13:21:14 -0000 1.174 *************** *** 21,25 **** import org.apache.log4j.Logger; - /** * Surface is defined by its list of boundary edges, and are related --- 21,24 ---- *************** *** 883,886 **** --- 882,896 ---- /** + * A method for controlled extrusion (like a push/pull tool) + * @param delta The distance to extrude + * @param sides Pass a list for the created surfaces + * @param v2dir Pass a vertex to direction map for the extrusion + * @return The resulting top surface + */ + public Surface extrusionControlled(double delta, Set sides, Map v2dir) { + return extrudeControlled(delta, sides, new HashMap(), new HashMap(), new HashMap(), v2dir); + } + + /** * Make the new vertices, edges and surfaces for extrusion * @param delta the length of extrusion in meters *************** *** 894,897 **** --- 904,908 ---- public Surface extrudeControlled(double delta, Set sides, Map e2e, Map v2e, Map e2s, Map v2dir) { Vertex normal = normal(); + normal.scale(delta); boolean makeNewTop = true; List vertices = getVertices(); *************** *** 916,920 **** for (int i = 0; i < n; i++) { ! if (isFree(v[i])) { if (v2dir.containsKey(v[i])) { Direction d = (Direction)v2dir.get(v[i]); --- 927,931 ---- for (int i = 0; i < n; i++) { ! if (isVertexBounded(v[i])) { if (v2dir.containsKey(v[i])) { Direction d = (Direction)v2dir.get(v[i]); *************** *** 941,944 **** --- 952,960 ---- for (int i = 0; i < n; i++) { + //move points delta + vmap[i].setX(vmap[i].getX() + normal.getX()); + vmap[i].setY(vmap[i].getY() + normal.getY()); + vmap[i].setZ(vmap[i].getZ() + normal.getZ()); + //make edges if (e2e.containsKey(e[i])) { topmap[i] = (Edge)e2e.get(e[i]); *************** *** 1097,1123 **** /** ! * Check if the given vertex is free, that is ! * 1) it is only part of the parent surface (this) ! * 2) if it is part of more surfaces two of these have to be coplanar (this have to be one) * @param vertex The vertex to check * @return True if the vertex is bounded and false otherwise */ ! private boolean isFree(Vertex vertex) { ! Set sur = vertex.getSurfaces(); ! if (sur.size() > 1) { ! // we have to do further checks ! Iterator iter = sur.iterator(); ! while (iter.hasNext()) { ! Surface cur = (Surface)iter.next(); ! log.info(vertex + " Saw " + cur); ! if (cur != this && this.plane().contains(cur)) { return true; } } - // if the while loop does not return then return false return false; ! } else { ! return true; } } --- 1113,1146 ---- /** ! * Check if the given vertex is free (do not have a edge to follow in move og pull), that is ! * 1) it is only part of the parent surface (this) or ! * 2) it is only connected to one edge not in this surface, which is not in ! * the plane of the surface * @param vertex The vertex to check * @return True if the vertex is bounded and false otherwise */ ! public boolean isVertexBounded(Vertex vertex) { ! Set<Edge> connected = vertex.getEdges(); ! switch (connected.size()) { ! case 3: ! //If the third connected edge is not in the plane of the surface ! //it is not free otherwise it is ! Plane plane = this.plane(); ! for (Edge e : connected) { ! if (!this.contains(e) && plane.contains(e)) { return true; } } return false; ! case 2: ! // look at the surfaces ! for (Surface s : vertex.getSurfaces()) { ! if (this != s) { ! return false; ! } ! } ! break; } + return true; } Index: Vertex.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Vertex.java,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** Vertex.java 18 Jul 2007 14:03:37 -0000 1.63 --- Vertex.java 7 Sep 2007 13:21:14 -0000 1.64 *************** *** 205,210 **** * @return The connected surfaces */ ! public Set getSurfaces() { ! Set result = new HashSet(); Set edges = getEdges(); Iterator iter = edges.iterator(); --- 205,210 ---- * @return The connected surfaces */ ! public Set<Surface> getSurfaces() { ! Set<Surface> result = new HashSet<Surface>(); Set edges = getEdges(); Iterator iter = edges.iterator(); |