[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool PencilTool.java, 1.68, 1.69
Status: Pre-Alpha
Brought to you by:
henryml
|
From: Michael L. <he...@us...> - 2006-12-05 15:21:17
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv19008/src/net/sourceforge/bprocessor/gl/tool Modified Files: PencilTool.java Log Message: Improved plane analysis Index: PencilTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/PencilTool.java,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** PencilTool.java 5 Dec 2006 11:14:00 -0000 1.68 --- PencilTool.java 5 Dec 2006 15:21:13 -0000 1.69 *************** *** 132,141 **** /** * ! * @param planes Collection of coordinatesystem * @param edge Edge ! * @return True if edge is contained in a coordinatesystem */ ! private boolean contains(Collection planes, Edge edge) { ! Iterator iter = planes.iterator(); while (iter.hasNext()) { CoordinateSystem system = (CoordinateSystem) iter.next(); --- 132,141 ---- /** * ! * @param systems Collection of CoordinateSystem * @param edge Edge ! * @return True if edge is contained in a CoordinateSystem */ ! private boolean contains(Collection systems, Edge edge) { ! Iterator iter = systems.iterator(); while (iter.hasNext()) { CoordinateSystem system = (CoordinateSystem) iter.next(); *************** *** 148,151 **** --- 148,174 ---- /** + * + * @param systems Collection of CoordinateSystem + * @param system CoordinateSystem + * @return true if system is contained in collection + */ + private boolean contains(Collection systems, CoordinateSystem system) { + Iterator iter = systems.iterator(); + Plane plane = system.plane(); + while (iter.hasNext()) { + CoordinateSystem current = (CoordinateSystem) iter.next(); + if (plane.contains(current.getOrigin())) { + Vertex n1 = system.getN(); + Vertex n2 = current.getN(); + Vertex cross = n1.cross(n2); + if (cross.isZero()) { + return true; + } + } + } + return false; + } + + /** * Remove all coordinatesystems from space * @param space Space *************** *** 162,169 **** /** * @param space Space ! * @return Collection of planes */ public Collection planeAnalysis(Space space) { ! Collection planes = new LinkedList(); Collection edges = space.getEdges(); { --- 185,192 ---- /** * @param space Space ! * @return Collection of CoordinateSystem */ public Collection planeAnalysis(Space space) { ! Collection systems = new LinkedList(); Collection edges = space.getEdges(); { *************** *** 229,252 **** if (!mark.contains(current)) { mark.add(current); ! if (!contains(planes, current)) { ! List incident = (List) neighbours.get(current); ! List pls = new LinkedList(); ! Iterator it = incident.iterator(); ! while (it.hasNext()) { ! Edge edge = (Edge) it.next(); ! if (!contains(pls, edge)) { ! CoordinateSystem system = CoordinateSystem.create(current, edge); ! mark.add(edge); ! if (system != null) { pls.add(system); } } } - planes.addAll(pls); } } } } ! return planes; } --- 252,274 ---- if (!mark.contains(current)) { mark.add(current); ! List incident = (List) neighbours.get(current); ! List pls = new LinkedList(); ! Iterator it = incident.iterator(); ! while (it.hasNext()) { ! Edge edge = (Edge) it.next(); ! if (!contains(pls, edge)) { ! CoordinateSystem system = CoordinateSystem.create(current, edge); ! if (system != null) { ! if (!contains(systems, system)) { pls.add(system); } } } } + systems.addAll(pls); } } } ! return systems; } *************** *** 255,259 **** */ protected void pressed(MouseEvent e) { ! if (e.isPopupTrigger()) { glv.popup(menu(), e.getX(), e.getY()); } else { --- 277,281 ---- */ protected void pressed(MouseEvent e) { ! if (e.isPopupTrigger() || e.getButton() == MouseEvent.BUTTON3) { glv.popup(menu(), e.getX(), e.getY()); } else { *************** *** 308,313 **** */ public void surfaceAnalysis(Space space) { ! Collection planes = space.getCoordinateSystems(); ! Iterator iter = planes.iterator(); while (iter.hasNext()) { CoordinateSystem current = (CoordinateSystem) iter.next(); --- 330,335 ---- */ public void surfaceAnalysis(Space space) { ! Collection systems = space.getCoordinateSystems(); ! Iterator iter = systems.iterator(); while (iter.hasNext()) { CoordinateSystem current = (CoordinateSystem) iter.next(); |