Thread: [Bprocessor-commit] model/src/net/sourceforge/bprocessor/model ClippingPlane.java, 1.3, 1.4
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2006-07-20 12:58:11
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv22166/src/net/sourceforge/bprocessor/model Modified Files: ClippingPlane.java Log Message: changes caused by changes in plane Index: ClippingPlane.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/ClippingPlane.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ClippingPlane.java 4 Jul 2006 09:36:54 -0000 1.3 --- ClippingPlane.java 20 Jul 2006 12:58:08 -0000 1.4 *************** *** 26,33 **** /** The placement of the clippingplane */ ! private Plane plane; ! ! /** The coordinate sytem of the clipping plane */ ! private CoordinateSystem system; /** The corners */ --- 26,30 ---- /** The placement of the clippingplane */ ! private CoordinateSystem cs; /** The corners */ *************** *** 37,40 **** --- 34,40 ---- private ArrayList silluet; + /** The plane of the clipingplane */ + private Plane plane; + /** * The constructor *************** *** 42,46 **** */ public ClippingPlane(CoordinateSystem system) { ! this.system = system; update(); } --- 42,47 ---- */ public ClippingPlane(CoordinateSystem system) { ! this.cs = system; ! plane = cs.plane(); update(); } *************** *** 51,71 **** */ public Plane getPlane() { ! return plane; ! } ! ! /** ! * Getter for the origin ! * @return The origin ! */ ! public Vertex origin() { ! Vertex origin = origin = system.getOrigin(); ! // FIXME Interning the origin to give it an ID.. ! // It needs an ID to be in a hashtable, but this ! // means that the origin point will be drawn an ! // clickable etc. ! if (origin.getId() == null) { ! //Project.getInstance().intern(origin); } ! return origin; } --- 52,59 ---- */ public Plane getPlane() { ! if (plane == null) { ! plane = cs.plane(); } ! return plane; } *************** *** 75,87 **** */ public Vertex center() { ! return origin(); } /** * Update this clipping from the defining coordinatesystem attribute - * */ public void update() { ! plane = system.plane(); findCorners(); } --- 63,74 ---- */ public Vertex center() { ! return cs.getOrigin(); } /** * Update this clipping from the defining coordinatesystem attribute */ public void update() { ! plane = null; findCorners(); } *************** *** 103,119 **** return number; } /** * Find intersections with all edges and return the vertices * @return The set of all intersection vertices */ public Collection findIntersections() { Collection edges = Project.getInstance().getEdges(); ! silluet = new ArrayList(); Collection res = new ArrayList(); Iterator it = edges.iterator(); while (it.hasNext()) { Edge e = (Edge)it.next(); ! Vertex v = plane.intersection(e); if (v != null) { res.add(v); --- 90,168 ---- return number; } + + /** + * Getter for corners + * @return The corners + */ + public Collection getCorners() { + if (corners == null) { + update(); + } + return corners; + } + + /** + * collects the vertices for this clipplane + * @return the set of vertices + */ + public Set collect() { + Set result = new HashSet(); + result.add(center()); + return result; + } + + /** + * FIXME: empty implementation to make compile + * (pfff make sure stuff compiles before you check in please) + */ + public void delete() { + Iterator it = Project.getInstance().getCameras().iterator(); + while (it.hasNext()) { + Camera cam = (Camera)it.next(); + Iterator clipIt = cam.getClipplanes().iterator(); + while (clipIt.hasNext()) { + ClippingPlane clip = (ClippingPlane)clipIt.next(); + if (clip == this) { + cam.removeClipplane(this); + Project.getInstance().changed(cam); + break; + } + } + } + return; + } + + /** + * Makes a string representation of the clippingplane + * @return The string representing til object + */ + public String toString() { + double[] p = getPlane().getDoublev(); + return "[" + p[0] + ", " + p[1] + ", " + p[2] + ", " + p[3] + "]"; + } + + /** + * Gettter for the intersected geometry + * @return The intersection edges + */ + public Collection getLines() { + return silluet; + } + + /** * Find intersections with all edges and return the vertices + * (Have sideeffects) * @return The set of all intersection vertices */ public Collection findIntersections() { Collection edges = Project.getInstance().getEdges(); ! ArrayList silluet = new ArrayList(); Collection res = new ArrayList(); Iterator it = edges.iterator(); while (it.hasNext()) { Edge e = (Edge)it.next(); ! Vertex v = getPlane().intersection(e); if (v != null) { res.add(v); *************** *** 129,133 **** while (iter.hasNext()) { Edge e = (Edge)iter.next(); ! Vertex v = plane.intersection(e); if (v != null) { if (first == null) { --- 178,182 ---- while (iter.hasNext()) { Edge e = (Edge)iter.next(); ! Vertex v = getPlane().intersection(e); if (v != null) { if (first == null) { *************** *** 143,155 **** } } return res; } ! /** ! * Find the 4 corners among intersections */ - public void findCorners() { ! Collection c = findIntersections(); if (c.isEmpty()) { if (!corners.isEmpty()) { --- 192,208 ---- } } + if (silluet.size() > 0) { + this.silluet = silluet; + } return res; } ! /** ! * Find the 4 corners among intersections ! * (Have side effects) */ public void findCorners() { ! Collection c = this.findIntersections(); ! CoordinateSystem system = getPlane().coordinateSystem(); if (c.isEmpty()) { if (!corners.isEmpty()) { *************** *** 205,263 **** } } - - /** - * Getter for corners - * @return The corners - */ - public Collection getCorners() { - return corners; - } - - /** - * collects the vertices for this clipplane - * @return the set of vertices - */ - public Set collect() { - Set result = new HashSet(); - result.add(origin()); - return result; - } - - /** - * FIXME: empty implementation to make compile - * (pfff make sure stuff compiles before you check in please) - */ - public void delete() { - Iterator it = Project.getInstance().getCameras().iterator(); - while (it.hasNext()) { - Camera cam = (Camera)it.next(); - Iterator clipIt = cam.getClipplanes().iterator(); - while (clipIt.hasNext()) { - ClippingPlane clip = (ClippingPlane)clipIt.next(); - if (clip == this) { - cam.removeClipplane(this); - Project.getInstance().changed(cam); - break; - } - } - } - return; - } - - /** - * Makes a string representation of the clippingplane - * @return The string representing til object - */ - public String toString() { - double[] p = plane.getDoublev(); - return "[" + p[0] + ", " + p[1] + ", " + p[2] + ", " + p[3] + "]"; - } - - /** - * Gettter for the intersected geometry - * @return The intersection edges - */ - public Collection getLines() { - return silluet; - } } --- 258,260 ---- |