[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool MultiExtrudeTool.java,1.5,1.6
Status: Pre-Alpha
Brought to you by:
henryml
|
From: rimestad <rim...@us...> - 2006-03-07 16:45:25
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7026/src/net/sourceforge/bprocessor/gl/tool Modified Files: MultiExtrudeTool.java Log Message: Added extrude to other surface (there is a small distance bug), and hole analysis also made. There is a small bug with the algorithm so that some speed vectors are getting too big, a problem when marking top and side walls simultanusly Index: MultiExtrudeTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/MultiExtrudeTool.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** MultiExtrudeTool.java 23 Feb 2006 14:05:22 -0000 1.5 --- MultiExtrudeTool.java 7 Mar 2006 16:45:20 -0000 1.6 *************** *** 25,28 **** --- 25,29 ---- import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Plane; + import net.sourceforge.bprocessor.model.Project; import net.sourceforge.bprocessor.model.Selection; import net.sourceforge.bprocessor.model.Surface; *************** *** 51,54 **** --- 52,61 ---- private double t; + /** The set of extruded elements and the top surfaces of the extrusion*/ + private Set elements, tops; + + /** The extrusion direction */ + private double direction = 0.0; + /** * Constructor *************** *** 68,75 **** top = null; t = 0; ! v2dir = new HashMap(); ! super.pressed(e); if (target instanceof Surface) { - // lav extrudsionen af selectionen extrudeSurface = (Surface)target; View view = glv.getView(); --- 75,88 ---- top = null; t = 0; ! v2dir = null; ! elements = new HashSet(); ! if (directMode) { ! super.pressed(e); ! } ! if (e.isShiftDown() && !directMode) { ! super.pressed(e); ! return; ! } if (target instanceof Surface) { extrudeSurface = (Surface)target; View view = glv.getView(); *************** *** 92,101 **** */ protected void dragged(MouseEvent e) { ! if (v2dir != null) { ! if (top == null) { ! //make the extrusion ! Set elements = makeExtrusion(Selection.primary()); ! } ! // Find the move direction Vertex normal; if (top == null) { --- 105,110 ---- */ protected void dragged(MouseEvent e) { ! if (extrudeSurface != null) { ! // it is possible to make an extrusion find the direction Vertex normal; if (top == null) { *************** *** 109,119 **** Vertex delta = to.minus(from); double normDotDelta = normal.dot(delta); ! moveTo(v2dir.values(), normDotDelta); ! } else { ! // TODO Tell somehow that the extrusion were illigal } } /** * Move a collection of vertex, direction pairs * @param which The colelction of pairs --- 118,188 ---- Vertex delta = to.minus(from); double normDotDelta = normal.dot(delta); ! if (direction == 0) { ! //we have never set the direction; ! direction = normDotDelta; ! } ! if (top == null) { ! // there are no extrusion make one if we move the mouse ! if ((e.getX() - pressX) * (e.getX() - pressX) + ! (e.getY() - pressY) * (e.getY() - pressY) > 16) { ! elements = makeExtrusion(Selection.primary()); ! } ! } ! if (v2dir != null) { ! // The extrusion were succesfull move it ! // Find the move direction ! findTarget(e); ! if (target != null && target instanceof Surface) { ! //If there are a target that is a surface drag to that surface ! Vertex origin = extrudeSurface.getFirstVertex(); ! Surface current = (Surface) target; ! if (current != extrudeSurface && current != top && !elements.contains(current)) { ! Vertex n = current.normal(); ! Vertex cross = normal.cross(n); ! if (cross.isZero()) { ! Vertex o = current.getFirstVertex(); ! Vertex vector = o.minus(origin); ! double d = vector.dot(normal); ! if (Math.abs(d) > 0.0000001) { ! moveTo(v2dir.values(), d); ! return; ! } ! } ! } ! } ! // otherwise do a normal extrude ! if (direction * normDotDelta > 0) { ! // the extrusion is still in the same direction ! moveTo(v2dir.values(), normDotDelta); ! } else { ! // we have to remove the extrusion and make a new one ! remove(elements); ! elements = makeExtrusion(Selection.primary()); ! direction = normDotDelta; ! if (v2dir != null) { ! moveTo(v2dir.values(), normDotDelta); ! } ! } ! } } } /** + * Remove all the created extrusion elements + * @param elem The elements to remove + */ + private void remove(Set elem) { + if (elem != null) { + Iterator iter = elem.iterator(); + while (iter.hasNext()) { + Object o = iter.next(); + if (o instanceof Surface) { + Project.getInstance().delete((Surface)o); + } + } + } + } + + /** * Move a collection of vertex, direction pairs * @param which The colelction of pairs *************** *** 126,130 **** Direction d = (Direction)iter.next(); Vertex movement = d.getDirection(); - log.info(d.getVertex() + " blev flyttet " + movement); Vertex v = movement.copy(); v.scale(delta); --- 195,198 ---- *************** *** 132,135 **** --- 200,204 ---- } t = to; + glv.setLength(Math.abs(t)); } *************** *** 140,144 **** protected void released(MouseEvent e) { super.released(e); ! } --- 209,223 ---- protected void released(MouseEvent e) { super.released(e); ! if (top != null && Math.abs(t) < 0.1) { ! remove(elements); ! return; ! } else if (v2dir != null) { ! Iterator iter = elements.iterator(); ! while (iter.hasNext()) { ! Surface current = (Surface) iter.next(); ! holeAnalysis(current); ! } ! Selection.primary().addAll(tops); ! } } *************** *** 154,158 **** v2dir = new HashMap(); // vertex to direction map Map v2e = new HashMap(); // vertex to edge map ! // Check for selection of only surfaces --- 233,237 ---- v2dir = new HashMap(); // vertex to direction map Map v2e = new HashMap(); // vertex to edge map ! tops = new HashSet(); // Check for selection of only surfaces *************** *** 166,174 **** while (iter.hasNext()) { Surface cur = (Surface)iter.next(); ! Surface s = cur.extrude(1, elements, e2e, v2e, e2s, v2dir); if (cur == extrudeSurface) { // Set the top to the extruded surface of target top = s; } elements.add(s); } --- 245,254 ---- while (iter.hasNext()) { Surface cur = (Surface)iter.next(); ! Surface s = cur.extrude(direction, elements, e2e, v2e, e2s, v2dir); if (cur == extrudeSurface) { // Set the top to the extruded surface of target top = s; } + tops.add(s); elements.add(s); } |