[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model ClippingPlane.java, 1.30, 1.31
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2008-09-09 13:42:45
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv11783/src/net/sourceforge/bprocessor/model Modified Files: ClippingPlane.java Log Message: ClippingPlane improvements Index: ClippingPlane.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/ClippingPlane.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** ClippingPlane.java 9 Sep 2008 12:15:07 -0000 1.30 --- ClippingPlane.java 9 Sep 2008 13:42:54 -0000 1.31 *************** *** 12,15 **** --- 12,16 ---- import java.util.ArrayList; import java.util.List; + import java.util.Map; import java.util.Set; import java.util.HashSet; *************** *** 37,41 **** /** The edge map */ ! private HashMap toModel; /** The plane of the ClippingPlane */ --- 38,42 ---- /** The edge map */ ! private Map<Edge, Edge> e2e; /** The plane of the ClippingPlane */ *************** *** 58,62 **** this.silhouette = new ArrayList<Edge>(); this.corners = new ArrayList<Vertex>(); ! this.toModel = new HashMap(); Project.getInstance().addObserver(this); } --- 59,63 ---- this.silhouette = new ArrayList<Edge>(); this.corners = new ArrayList<Vertex>(); ! this.e2e = new HashMap(); Project.getInstance().addObserver(this); } *************** *** 164,167 **** --- 165,179 ---- return plane.contains(surface); } + + /** + * Returns true if edge is contained in this ClippingPlane + * @param edge Edge to test + * @return true of the edge is contained + */ + public boolean contains(Edge edge) { + Plane plane = getPlane(); + return plane.contains(edge); + } + /** *************** *** 190,229 **** */ public Collection<Vertex> findIntersections() { ! toModel.clear(); Container space = Project.getInstance().getActiveSpace(); ! Collection edges = Geometry.getActiveEdges(space); silhouette.clear(); ! Collection<Vertex> res = new ArrayList<Vertex>(); ! Plane plan = system.plane(); ! Iterator it = edges.iterator(); ! while (it.hasNext()) { ! Edge e = (Edge)it.next(); ! Vertex v = plan.intersection(e); ! if (v != null) { ! res.add(v); ! } ! Vertex transTo = system.translate(e.getTo()); ! Vertex transFrom = system.translate(e.getFrom()); ! if (Math.abs(transTo.getZ()) < 0.00001 && ! Math.abs(transFrom.getZ()) < 0.00001) { ! res.add(e.getTo().copy()); ! res.add(e.getFrom().copy()); ! Edge eCopy = e.copy(); ! // edges should be solid ! eCopy.setStrippled(false); ! toModel.put(eCopy, e); ! silhouette.add(eCopy); } } ! Collection surfaces = Geometry.getActiveSurfaces(space); ! it = surfaces.iterator(); ! while (it.hasNext()) { ! Surface s = (Surface)it.next(); ! Collection lines = s.getEdges(); ! Iterator iter = lines.iterator(); Vertex first = null; ! while (iter.hasNext()) { ! Edge e = (Edge)iter.next(); ! Vertex v = plan.intersection(e); if (v != null) { if (first == null) { --- 202,232 ---- */ public Collection<Vertex> findIntersections() { ! e2e.clear(); Container space = Project.getInstance().getActiveSpace(); ! Collection<Edge> edges = Geometry.getActiveEdges(space); silhouette.clear(); ! Collection<Vertex> vertices = new ArrayList<Vertex>(); ! Plane plane = system.plane(); ! for (Edge current : edges) { ! if (plane.contains(current)) { ! Edge edge = current.copy(); ! edge.setStrippled(false); ! vertices.add(edge.getFrom()); ! vertices.add(edge.getTo()); ! silhouette.add(edge); ! e2e.put(edge, current); ! } else { ! Vertex intersection = plane.intersection(current); ! if (intersection != null) { ! vertices.add(intersection); ! } } } ! Collection<Surface> surfaces = Geometry.getActiveSurfaces(space); ! for (Surface current : surfaces) { ! Collection<Edge> contour = current.getEdges(); Vertex first = null; ! for (Edge edge : contour) { ! Vertex v = plane.intersection(edge); if (v != null) { if (first == null) { *************** *** 234,238 **** first = null; silhouette.add(newE); ! toModel.put(newE, newE); break; } --- 237,241 ---- first = null; silhouette.add(newE); ! e2e.put(newE, newE); break; } *************** *** 240,244 **** } } ! return res; } --- 243,247 ---- } } ! return vertices; } *************** *** 393,398 **** */ public Geometric toModel(Edge e) { ! if (toModel != null) { ! Object o = toModel.get(e); if (o != null) { return (Geometric)o; --- 396,401 ---- */ public Geometric toModel(Edge e) { ! if (e2e != null) { ! Object o = e2e.get(e); if (o != null) { return (Geometric)o; |