Thread: [Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool AbstractTool.java, 1.89, 1.90 Abstrac
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2006-08-03 15:41:29
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv11739/src/net/sourceforge/bprocessor/gl/tool Modified Files: AbstractTool.java AbstractPencil.java Log Message: removed unused methods from AbstractTool that were the same as those in AbstractPencil. And chenged all use of edges as constructors to constructor instead. Index: AbstractPencil.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractPencil.java,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** AbstractPencil.java 31 Jul 2006 13:03:43 -0000 1.51 --- AbstractPencil.java 3 Aug 2006 14:29:33 -0000 1.52 *************** *** 30,33 **** --- 30,34 ---- import net.sourceforge.bprocessor.model.Geometric; import net.sourceforge.bprocessor.model.Geometry; + import net.sourceforge.bprocessor.model.Line; import net.sourceforge.bprocessor.model.Plane; import net.sourceforge.bprocessor.model.Project; *************** *** 174,178 **** (Intersection) glv.getView().getObjectAtPoint(e.getX(), e.getY(), unwanted, true, work); - if (constrain) { if (lockingEdge != null) { --- 175,178 ---- *************** *** 191,195 **** return intersection; } ! /** * Insert a vertex into model --- 191,206 ---- return intersection; } ! ! /** ! * Insert a Constructor into model ! * @param c the constructor ! * @return The model Constructor ! */ ! public Constructor insertConstructor(Constructor c) { ! Space space = mesh(); ! ! return space.insert(c); ! } ! /** * Insert a vertex into model *************** *** 225,229 **** while (iter.hasNext()) { Edge e = (Edge) iter.next(); ! if (!e.getConstructor()) { e.split(actual); } --- 236,240 ---- while (iter.hasNext()) { Edge e = (Edge) iter.next(); ! if (!e.getStrippled()) { e.split(actual); } *************** *** 314,319 **** Iterator iter = elements.iterator(); while (iter.hasNext()) { ! Edge current = (Edge) iter.next(); ! glv.getView().addTempEdge(current); } } --- 325,334 ---- Iterator iter = elements.iterator(); while (iter.hasNext()) { ! Object o = iter.next(); ! if (o instanceof Edge) { ! glv.getView().addTempEdge((Edge) o); ! } else if (o instanceof Constructor) { ! glv.getView().addTempConstructor((Constructor) o); ! } } } *************** *** 325,330 **** Iterator iter = elements.iterator(); while (iter.hasNext()) { ! Edge current = (Edge) iter.next(); ! glv.getView().removeTempEdge(current); } } --- 340,349 ---- Iterator iter = elements.iterator(); while (iter.hasNext()) { ! Object o = iter.next(); ! if (o instanceof Edge) { ! glv.getView().removeTempEdge((Edge) o); ! } else if (o instanceof Constructor) { ! glv.getView().removeTempConstructor((Constructor) o); ! } } } *************** *** 347,352 **** Iterator iter = constructors.iterator(); while (iter.hasNext()) { ! Edge current = (Edge) iter.next(); ! glv.getView().addTempEdge(current); } } --- 366,375 ---- Iterator iter = constructors.iterator(); while (iter.hasNext()) { ! Object o = iter.next(); ! if (o instanceof Edge) { ! glv.getView().addTempEdge((Edge) o); ! } else if (o instanceof Constructor) { ! glv.getView().addTempConstructor((Constructor) o); ! } } } *************** *** 358,363 **** Iterator iter = constructors.iterator(); while (iter.hasNext()) { ! Edge current = (Edge) iter.next(); ! glv.getView().removeTempEdge(current); } } --- 381,390 ---- Iterator iter = constructors.iterator(); while (iter.hasNext()) { ! Object o = iter.next(); ! if (o instanceof Edge) { ! glv.getView().removeTempEdge((Edge) o); ! } else if (o instanceof Constructor) { ! glv.getView().removeTempConstructor((Constructor) o); ! } } } *************** *** 409,418 **** /** ! * Test if an edge is parrallel with an axiz (x, y or z) ! * @param edge The edge to test ! * @return True if edge is parrallel to an axis */ ! protected boolean isAxisAligned(Edge edge) { ! Vertex vector = edge.getDirection(); { Vertex cross = vector.cross(new Vertex(1, 0 , 0)); --- 436,445 ---- /** ! * Test if an line is parrallel with an axiz (x, y or z) ! * @param line The line to test ! * @return True if line is parrallel to an axis */ ! protected boolean isAxisAligned(Line line) { ! Vertex vector = line.getDirection(); { Vertex cross = vector.cross(new Vertex(1, 0 , 0)); *************** *** 454,461 **** List constructors = new LinkedList(); if (start != null) { ! constructors.addAll(xyz(start.vertex())); } if (incident != null) { ! constructors.addAll(xyz(incident.vertex())); } --- 481,488 ---- List constructors = new LinkedList(); if (start != null) { ! constructors.add(new CoordinateSystem(start.vertex())); } if (incident != null) { ! constructors.add(new CoordinateSystem(incident.vertex())); } *************** *** 463,483 **** Edge edge = hooverEdge; Vertex v = edge.getDirection(); ! v.scale(50 / v.length()); ! Edge parrallel = null; if (start != null) { ! parrallel = new Edge(start.vertex().minus(v), start.vertex().add(v)); } else { if (incident != null) { ! parrallel = new Edge(incident.vertex().minus(v), incident.vertex().add(v)); } } ! if (parrallel != null) { ! if (!isAxisAligned(parrallel)) { ! parrallel.setConstructor(true); ! glv.getView().changeColor(parrallel, new float[] {255f / 255f, 153f / 255f, 0}); ! constructors.add(parrallel); ! } ! ! Plane plane; --- 490,504 ---- Edge edge = hooverEdge; Vertex v = edge.getDirection(); ! v.normalize(); ! Line parrallel = null; if (start != null) { ! parrallel = new Line(start.vertex(), v, true, false); } else { if (incident != null) { ! parrallel = new Line(incident.vertex(), v, true, false); } } ! if (parrallel != null && !isAxisAligned(parrallel)) { ! constructors.add(parrallel); Plane plane; *************** *** 506,528 **** direction.setY(x); direction = system.unTranslate(direction); ! direction.scale(50 / direction.length()); ! Edge orthogonal = null; if (Math.abs(direction.getZ()) < 0.0000001) { if (start != null) { ! orthogonal = new Edge(start.vertex().minus(direction), start.vertex().add(direction)); } else { if (incident != null) { ! orthogonal = new Edge(incident.vertex().minus(direction), ! incident.vertex().add(direction)); } } } ! if (orthogonal != null) { ! if (!isAxisAligned(orthogonal)) { ! orthogonal.setConstructor(true); ! glv.getView().changeColor(orthogonal, new float[] {255f / 255f, 153f / 255f, 0}); ! constructors.add(orthogonal); ! } } } --- 527,544 ---- direction.setY(x); direction = system.unTranslate(direction); ! direction.normalize(); ! Line orthogonal = null; if (Math.abs(direction.getZ()) < 0.0000001) { if (start != null) { ! orthogonal = new Line(start.vertex(), direction, true, false); } else { if (incident != null) { ! orthogonal = new Line(incident.vertex(), direction, true, false); } } } ! if (orthogonal != null) { ! constructors.add(orthogonal); } } *************** *** 666,670 **** case Intersection.EDGE: Edge edge = (Edge) intersection.object(); ! if (edge.getConstructor()) { target = current; targetColor = View.CONSTRUCTOR_COLOR; --- 682,686 ---- case Intersection.EDGE: Edge edge = (Edge) intersection.object(); ! if (edge.getStrippled()) { target = current; targetColor = View.CONSTRUCTOR_COLOR; *************** *** 731,762 **** } } - - /** - * Make xyz in point origin - * @param origin Origin - * @return List of constructors - */ - protected List xyz(Vertex origin) { - List constructors = new LinkedList(); - Vertex i = new Vertex(1, 0, 0); - Vertex j = new Vertex(0, 1, 0); - Vertex n = new Vertex(0, 0, 1); - i.scale(50); - j.scale(50); - n.scale(50); - Edge e1 = new Edge(origin.minus(i), origin.add(i)); - Edge e2 = new Edge(origin.minus(j), origin.add(j)); - Edge e3 = new Edge(origin.minus(n), origin.add(n)); - e1.setConstructor(true); - e2.setConstructor(true); - e3.setConstructor(true); - glv.getView().changeColor(e1, new float[] {0, 1, 0}); - glv.getView().changeColor(e2, new float[] {1, 0, 0}); - glv.getView().changeColor(e3, new float[] {0, 0, 1}); - constructors.add(e1); - constructors.add(e2); - constructors.add(e3); - return constructors; - } /** --- 747,750 ---- Index: AbstractTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractTool.java,v retrieving revision 1.89 retrieving revision 1.90 diff -C2 -d -r1.89 -r1.90 *** AbstractTool.java 26 Jul 2006 14:41:12 -0000 1.89 --- AbstractTool.java 3 Aug 2006 14:29:33 -0000 1.90 *************** *** 440,561 **** /** - * Makes constructors parralel to the x y and z-axis, originating - * from a vertex. - * @param v the vertex - * @return a set of XYZ constructors. - */ - protected Set makeXYZConstructors(Vertex v) { - if (v != null) { - Edge x = new Edge(xAxis.getFrom().add(v), - xAxis.getTo().add(v)); - x.setConstructor(true); - Edge y = new Edge(yAxis.getFrom().add(v), - yAxis.getTo().add(v)); - y.setConstructor(true); - Edge z = new Edge(zAxis.getFrom().add(v), - zAxis.getTo().add(v)); - z.setConstructor(true); - Set constructors = new HashSet(); - constructors.add(x); - constructors.add(y); - constructors.add(z); - if (showConstructors) { - displayConstructors(constructors); - } - return constructors; - } - return null; - } - - /** - * Makes constructors parralel to the x y and z-axis, originating - * from a vertex. - * @param v the vertex - * @return a set of XYZ constructors. - */ - protected Set makeXYZConerConstructors(Vertex v) { - if (v != null) { - Vertex xDir = new Vertex(1, 0, 0); - Vertex yDir = new Vertex(0, 1, 0); - Vertex zDir = new Vertex(0, 0, 1); - Camera camera = Project.getInstance().getCurrentCamera(); - double[] center = camera.getCenter(); - double[] eye = camera.getCamera(); - Vertex cameraDir = new Vertex(center[0] - eye[0], - center[1] - eye[1], - center[2] - eye[2]); - - Edge x = new Edge(xAxis.getFrom().add(v), - xAxis.getTo().add(v)); - if (cameraDir.dot(xDir) > 0) { - x.getFrom().move(-50, 0, 0); - x.getTo().move(-50, 0, 0); - } else { - x.getFrom().move(50, 0, 0); - x.getTo().move(50, 0, 0); - } - x.setConstructor(true); - Edge y = new Edge(yAxis.getFrom().add(v), - yAxis.getTo().add(v)); - if (cameraDir.dot(yDir) > 0) { - y.getFrom().move(0, -50, 0); - y.getTo().move(0, -50, 0); - } else { - y.getFrom().move(0, 50, 0); - y.getTo().move(0, 50, 0); - } - y.setConstructor(true); - Edge z = new Edge(zAxis.getFrom().add(v), - zAxis.getTo().add(v)); - if (cameraDir.dot(zDir) > 0) { - z.getFrom().move(0, 0, -50); - z.getTo().move(0, 0, -50); - } else { - z.getFrom().move(0, 0, 50); - z.getTo().move(0, 0, 50); - } - z.setConstructor(true); - Set constructors = new HashSet(); - constructors.add(x); - constructors.add(y); - constructors.add(z); - if (showConstructors) { - displayConstructors(constructors); - } - return constructors; - } - return null; - } - - /** - * Makes constructors parrallel to the edges connected to a vertex. - * @param v the vertex - * @return a set of constructors. - */ - protected Set makeEdgeConstructors(Vertex v) { - Set constructors = new HashSet(); - Set edges = v.getEdges(); - Iterator it = edges.iterator(); - while (it.hasNext()) { - Edge e = (Edge)it.next(); - Vertex direction = e.getFrom().minus(e.getTo()); - direction.scale(50 / direction.length()); - Vertex to = direction.copy(); - direction.scale(-1); - Vertex from = direction.copy(); - to = to.add(v); - from = from.add(v); - Edge constructor = new Edge(from, to); - - constructor.setConstructor(true); - constructors.add(constructor); - } - if (showConstructors) { - displayConstructors(constructors); - } - return constructors; - } - - /** * Makes a set of constructors be displayed. * @param constructors a set of constructors. --- 440,443 ---- |