[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool ExtrusionTool.java,1.29,1.30
Status: Pre-Alpha
Brought to you by:
henryml
From: Nordholt <nor...@us...> - 2005-11-23 13:18:33
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1594/src/net/sourceforge/bprocessor/gl/tool Modified Files: ExtrusionTool.java Log Message: extrusion through surfaces makes holes in the surfaces. still doesnt work completely in some situations Index: ExtrusionTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ExtrusionTool.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** ExtrusionTool.java 18 Nov 2005 12:32:05 -0000 1.29 --- ExtrusionTool.java 23 Nov 2005 13:18:23 -0000 1.30 *************** *** 41,45 **** /** The logger */ private static Logger log = Logger.getLogger(ExtrusionTool.class); ! /** The new surface to drag */ private static Surface dragSurface = null; --- 41,45 ---- /** The logger */ private static Logger log = Logger.getLogger(ExtrusionTool.class); ! /** The new surface to drag */ private static Surface dragSurface = null; *************** *** 53,57 **** /** The previous y-coordinate */ private double prevY; ! /** The extrusion edge */ private Edge extrusion; --- 53,57 ---- /** The previous y-coordinate */ private double prevY; ! /** The extrusion edge */ private Edge extrusion; *************** *** 68,72 **** /** The length typed in for length of the extrusion*/ private String number; ! /** * The Constructor --- 68,72 ---- /** The length typed in for length of the extrusion*/ private String number; ! /** * The Constructor *************** *** 84,88 **** //have to use getModifiersEx() getButton() gives wrong results if ((e.getModifiersEx() & ! MouseEvent.BUTTON3_DOWN_MASK) == MouseEvent.BUTTON3_DOWN_MASK) { return; --- 84,88 ---- //have to use getModifiersEx() getButton() gives wrong results if ((e.getModifiersEx() & ! MouseEvent.BUTTON3_DOWN_MASK) == MouseEvent.BUTTON3_DOWN_MASK) { return; *************** *** 120,127 **** Vertex v = (Vertex)l.get(count); updateVertex(v, new double[] {v.getX() + normal.getX(), ! v.getY() + normal.getY(), ! v.getZ() + normal.getZ()}); } ! //also moving any inner surfaces Set innerSurfaces = dragSurface.getInnerSurfaces(); if (innerSurfaces != null) { --- 120,127 ---- Vertex v = (Vertex)l.get(count); updateVertex(v, new double[] {v.getX() + normal.getX(), ! v.getY() + normal.getY(), ! v.getZ() + normal.getZ()}); } ! //also moving any inner surfaces Set innerSurfaces = dragSurface.getInnerSurfaces(); if (innerSurfaces != null) { *************** *** 133,141 **** Vertex v = (Vertex)verticies.get(count); updateVertex(v, new double[] {v.getX() + normal.getX(), ! v.getY() + normal.getY(), ! v.getZ() + normal.getZ()}); } } } if (extrusion != null) { glv.setLength(extrusion.getLength()); --- 133,166 ---- Vertex v = (Vertex)verticies.get(count); updateVertex(v, new double[] {v.getX() + normal.getX(), ! v.getY() + normal.getY(), ! v.getZ() + normal.getZ()}); } } } + Surface inSurface = inOtherSurface(dragSurface); + if (inSurface != null) { + List list = dragSurface.getVertices(); + Iterator listIt = list.iterator(); + Vertex to = null; + Vertex from = null; + Vertex first = null; + List edges = new LinkedList(); + if (listIt.hasNext()) { + from = (Vertex)listIt.next(); + first = from; + } + while (listIt.hasNext()) { + to = (Vertex)listIt.next(); + edges.add(createEdge(from, to)); + from = to; + } + if (from != null) { + edges.add(createEdge(from, first)); + } + Surface hole = createSurface(edges); + inSurface.addHole(hole); + dragSurface = createExtension(dragSurface); + spaceAssignment(); + } if (extrusion != null) { glv.setLength(extrusion.getLength()); *************** *** 143,146 **** --- 168,203 ---- } } + + /** + * Tells if a surface is inside any other surface. + * @param drag the surface + * @return a surface the dragsurface is now inside, + * null if none such exists. + */ + private Surface inOtherSurface(Surface drag) { + boolean inSide = false; + Set surfaces = Project.getInstance().getSurfaces(); + Iterator it = surfaces.iterator(); + + Surface surface = null; + while (it.hasNext() && !inSide) { + surface = (Surface)it.next(); + if (!surface.equals(drag) && !surface.equals(extrudeSurface)) { + Iterator vertIt = drag.getVertices().iterator(); + if (vertIt.hasNext()) { + inSide = true; + } + while (vertIt.hasNext() && inSide) { + Vertex vert = (Vertex)vertIt.next(); + inSide = surface.surrounds(vert, 1); + } + } + } + if (inSide) { + return surface; + } else { + return null; + } + } /** * Invoked when a mouse button has been pressed on a component. *************** *** 158,162 **** glv.setLength(0); super.pressed(e); ! if (target instanceof Surface) { Surface selectedSurface = (Surface)target; --- 215,219 ---- glv.setLength(0); super.pressed(e); ! if (target instanceof Surface) { Surface selectedSurface = (Surface)target; *************** *** 227,231 **** while (sideEdgeIt.hasNext() && hole) { Edge edge = (Edge)sideEdgeIt.next(); ! Vertex vertex = surface.intersection(edge); if (vertex == null) { hole = false; --- 284,288 ---- while (sideEdgeIt.hasNext() && hole) { Edge edge = (Edge)sideEdgeIt.next(); ! Vertex vertex = surface.intersection(edge); if (vertex == null) { hole = false; *************** *** 251,265 **** } /* ! Debug code ! Iterator it = edgeToSplit.keySet().iterator(); ! while (it.hasNext()) { ! Edge edge = (Edge)it.next(); ! log.info("To: " + edge.getTo()); ! Iterator it2 = ((LinkedList)edgeToSplit.get(edge)).iterator(); ! while (it2.hasNext()) { ! log.info((Vertex)it2.next()); ! } ! } ! */ breakExtension(surfaceToInnerPoints, edgeToSplit, splitToEdge); } --- 308,322 ---- } /* ! Debug code ! Iterator it = edgeToSplit.keySet().iterator(); ! while (it.hasNext()) { ! Edge edge = (Edge)it.next(); ! log.info("To: " + edge.getTo()); ! Iterator it2 = ((LinkedList)edgeToSplit.get(edge)).iterator(); ! while (it2.hasNext()) { ! log.info((Vertex)it2.next()); ! } ! } ! */ breakExtension(surfaceToInnerPoints, edgeToSplit, splitToEdge); } *************** *** 314,318 **** return distance1 < distance2; } ! /** --- 371,375 ---- return distance1 < distance2; } ! /** *************** *** 498,506 **** if (previousEdge == null) { Vertex newTo = createVertex(new double[] {current.getFrom().getX(), ! current.getFrom().getY(), ! current.getFrom().getZ()}); Vertex newFrom = createVertex(new double[] {current.getTo().getX(), ! current.getTo().getY(), ! current.getTo().getZ()}); Edge newE = createEdge(newFrom, newTo); Edge ntofrom = createEdge(newTo, current.getFrom()); --- 555,563 ---- if (previousEdge == null) { Vertex newTo = createVertex(new double[] {current.getFrom().getX(), ! current.getFrom().getY(), ! current.getFrom().getZ()}); Vertex newFrom = createVertex(new double[] {current.getTo().getX(), ! current.getTo().getY(), ! current.getTo().getZ()}); Edge newE = createEdge(newFrom, newTo); Edge ntofrom = createEdge(newTo, current.getFrom()); *************** *** 520,524 **** if (times == edges.size() - 1 && ((first.getTo() == current.getTo()) || ! (first.getTo() == current.getFrom()))) { Edge newE = createEdge(first.getFrom(), previousEdge.getTo()); newEdges.add(current); --- 577,581 ---- if (times == edges.size() - 1 && ((first.getTo() == current.getTo()) || ! (first.getTo() == current.getFrom()))) { Edge newE = createEdge(first.getFrom(), previousEdge.getTo()); newEdges.add(current); *************** *** 530,535 **** Vertex c = current.otherVertex(previousEdge.otherVertex(previousVertex)); Vertex newFrom = createVertex(new double[] {c.getX(), ! c.getY(), ! c.getZ()}); Edge newE = createEdge(newFrom, previousVertex); Edge tonfrom = createEdge(c, newFrom); --- 587,592 ---- Vertex c = current.otherVertex(previousEdge.otherVertex(previousVertex)); Vertex newFrom = createVertex(new double[] {c.getX(), ! c.getY(), ! c.getZ()}); Edge newE = createEdge(newFrom, previousVertex); Edge tonfrom = createEdge(c, newFrom); *************** *** 576,590 **** private Surface createExtension(Surface selectedSurface) { extrudeSurface = selectedSurface; ! LinkedList extensions = extendSurface(selectedSurface); Surface top = (Surface)extensions.getFirst(); extensions.addLast(extrudeSurface); /* ! Note the first surface of the extensions lists is the top of the ! hole extension and the last surface is the bottom. This is used ! when assigning spaces to the surfaces. ! */ extrudedSurfaces = extensions; ! Set innerSurfaces = selectedSurface.getInnerSurfaces(); innerExSurfs = new HashSet(); --- 633,647 ---- private Surface createExtension(Surface selectedSurface) { extrudeSurface = selectedSurface; ! LinkedList extensions = extendSurface(selectedSurface); Surface top = (Surface)extensions.getFirst(); extensions.addLast(extrudeSurface); /* ! Note the first surface of the extensions lists is the top of the ! hole extension and the last surface is the bottom. This is used ! when assigning spaces to the surfaces. ! */ extrudedSurfaces = extensions; ! Set innerSurfaces = selectedSurface.getInnerSurfaces(); innerExSurfs = new HashSet(); *************** *** 597,604 **** extensions.addLast(innerSurf); /* ! Note the first surface of the extensions lists is the top of the ! hole-extension and the last surface is the bottom. This is used ! when assigning spaces to the surfaces. ! */ innerExSurfs.add(extensions); top.addHole(newInnerSurf); --- 654,661 ---- extensions.addLast(innerSurf); /* ! Note the first surface of the extensions lists is the top of the ! hole-extension and the last surface is the bottom. This is used ! when assigning spaces to the surfaces. ! */ innerExSurfs.add(extensions); top.addHole(newInnerSurf); *************** *** 615,620 **** public void keyPressed(KeyEvent e) { /*a length can only be typed in if some surface is selected ! for extrusion, and if the "number"-variable has been initialised ! */ super.keyPressed(e); if (dragSurface != null && number != null) { --- 672,677 ---- public void keyPressed(KeyEvent e) { /*a length can only be typed in if some surface is selected ! for extrusion, and if the "number"-variable has been initialised ! */ super.keyPressed(e); if (dragSurface != null && number != null) { |