[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool AbstractTool.java, 1.112, 1.113 Extru
Status: Pre-Alpha
Brought to you by:
henryml
|
From: rimestad <rim...@us...> - 2007-02-13 15:40:33
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv654/src/net/sourceforge/bprocessor/gl/tool Modified Files: AbstractTool.java ExtrusionTool.java Log Message: added new extrude Index: ExtrusionTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ExtrusionTool.java,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** ExtrusionTool.java 7 Dec 2006 00:24:53 -0000 1.44 --- ExtrusionTool.java 13 Feb 2007 15:05:47 -0000 1.45 *************** *** 15,18 **** --- 15,20 ---- import java.util.Set; + import org.apache.log4j.Logger; + import net.sourceforge.bprocessor.gl.GLView; import net.sourceforge.bprocessor.gl.view.Transformation; *************** *** 29,32 **** --- 31,36 ---- */ public class ExtrusionTool extends AbstractPencil { + /** The logger */ + private static Logger log = Logger.getLogger(ExtrusionTool.class); /** Surface to extrude */ *************** *** 56,59 **** --- 60,65 ---- /** Extrusion */ private Collection extrusion; + + private Plane ontoPlane; /** *************** *** 114,117 **** --- 120,160 ---- /** + * Extrude + * @param p the plane to extrude onto + * @param all Extrude all + * @param finish Finish extrusion + */ + public void extrudeOnto(Plane p, boolean all, boolean finish) { + Space space = Project.getInstance().getActiveSpace(); + if (extrusion != null) { + space.removeProtected(extrusion); + space.computeNextId(); + extrusion = null; + } + extrusion = new LinkedList(); + Collection sides = new LinkedList(); + Set tops = new HashSet(); + if (p == null) { + log.info("Found null plane"); + return; + } + if (all) { + extrudesurface.extrusionAllOnto(p, sides, tops); + extrusion.addAll(sides); + extrusion.addAll(tops); + } else { + Surface top = extrudesurface.extrusionOnto(p, sides); + extrusion.add(top); + extrusion.addAll(sides); + } + if (finish) { + insert(space, extrusion); + + } else { + space.addProtected(extrusion); + } + } + + /** * Moved * @param e MouseEvent *************** *** 136,161 **** elements.add(extrudesurface); } ! findTarget(e, elements); ! if (target instanceof Surface) { ! Surface surface = (Surface) target; ! Vertex n = surface.normal(); ! Vertex cross = normal.cross(n); ! if (cross.isZero()) { ! Vertex v = surface.getFirstVertex(); ! if (!extrudesurface.plane().contains(v)) { ! to = v; } } ! } else if (target instanceof Edge) { ! Edge edge = (Edge) target; ! to = edge.center(); ! Vertex v = edge.center(); ! if (!extrudesurface.plane().contains(v)) { ! to = v; } } - Vertex delta = to.minus(from); - distance = normal.dot(delta); - extrude(distance, all, false); } updateLength(); --- 179,229 ---- elements.add(extrudesurface); } ! findTarget(e); ! if (metaPressed) { ! // extrude onto the plane generated by surfaces ! if (target instanceof Surface && extrusion != null && !extrusion.contains(target)) { ! Surface sur = (Surface) target; ! if (normal.dot(sur.normal()) == 0) { ! // the normals are orthogonal ! Vertex delta = to.minus(from); ! distance = normal.dot(delta); ! extrude(distance, all, false); ! } else { ! ontoPlane = sur.plane(); ! extrudeOnto(ontoPlane, all, false); } + } else { + Vertex delta = to.minus(from); + distance = normal.dot(delta); + extrude(distance, all, false); } ! } else { ! // extrude the normal way ! if (target instanceof Surface) { ! Surface surface = (Surface) target; ! if (!elements.contains(surface)) { ! Vertex n = surface.normal(); ! Vertex cross = normal.cross(n); ! if (cross.isZero()) { ! Vertex v = surface.getFirstVertex(); ! if (!extrudesurface.plane().contains(v)) { ! to = v; ! } ! } ! } ! } else if (target instanceof Edge) { ! Edge edge = (Edge) target; ! if (!elements.contains(edge)) { ! to = edge.center(); ! Vertex v = edge.center(); ! if (!extrudesurface.plane().contains(v)) { ! to = v; ! } ! } } + Vertex delta = to.minus(from); + distance = normal.dot(delta); + extrude(distance, all, false); } } updateLength(); *************** *** 188,192 **** } else { if (extrusion != null) { ! extrude(distance, all, true); extrusion = null; Project.getInstance().checkpoint(); --- 256,264 ---- } else { if (extrusion != null) { ! if (metaPressed) { ! extrudeOnto(ontoPlane, all, true); ! } else { ! extrude(distance, all, true); ! } extrusion = null; Project.getInstance().checkpoint(); Index: AbstractTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractTool.java,v retrieving revision 1.112 retrieving revision 1.113 diff -C2 -d -r1.112 -r1.113 *** AbstractTool.java 8 Feb 2007 12:23:13 -0000 1.112 --- AbstractTool.java 13 Feb 2007 15:05:47 -0000 1.113 *************** *** 236,240 **** up.scale(2 / up.length()); if (e.getKeyCode() == KeyEvent.VK_META || e.getKeyCode() == KeyEvent.VK_ALT) { - log.info("META:" + e); metaPressed = true; glv.setCursor(metaCursor); --- 236,239 ---- |