Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10708/src/net/sourceforge/bprocessor/gl/view
Modified Files:
AbstractView.java
Log Message:
Improved hitdetection of edges
Index: AbstractView.java
===================================================================
RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/AbstractView.java,v
retrieving revision 1.54
retrieving revision 1.55
diff -C2 -d -r1.54 -r1.55
*** AbstractView.java 6 Nov 2005 16:33:44 -0000 1.54
--- AbstractView.java 13 Nov 2005 13:16:15 -0000 1.55
***************
*** 882,885 ****
--- 882,886 ----
gl.glEnable(GL.GL_DEPTH_TEST);
} else if (o instanceof Edge) {
+ gl.glDisable(GL.GL_DEPTH_TEST);
Edge e = (Edge) o;
Vertex to = e.getTo();
***************
*** 889,892 ****
--- 890,894 ----
gl.glVertex3d(from.getX(), from.getY(), from.getZ());
gl.glEnd();
+ gl.glEnable(GL.GL_DEPTH_TEST);
} else if (o instanceof Surface) {
gl.glEnable(GL.GL_POLYGON_STIPPLE);
***************
*** 1247,1250 ****
--- 1249,1253 ----
Set vertices = new HashSet();
+ Set edges = new HashSet();
for (int i = 0; i < hits; i++) {
***************
*** 1262,1265 ****
--- 1265,1270 ----
if (current instanceof Vertex) {
vertices.add(current);
+ } else if (current instanceof Edge) {
+ edges.add(current);
}
if (near < nearest) {
***************
*** 1278,1297 ****
Surface surface = (Surface) closest;
CoordinateSystem system = surface.coordinateSystem();
! Iterator iter = vertices.iterator();
! while (iter.hasNext()) {
! // TODO Find the clost point measured as XY distance in
! // the closest surface
! Vertex v = (Vertex) iter.next();
! // Test if v is in the same plane as the closest surface
! Vertex vv = system.translate(v);
! if (Math.abs(vv.getZ()) < 0.0000000001) {
! return v;
! } else {
! System.out.println("vv = " + vv);
}
}
}
if (closest instanceof Edge) {
--- 1283,1328 ----
Surface surface = (Surface) closest;
CoordinateSystem system = surface.coordinateSystem();
!
! // Look for a Vertex
! {
! Iterator iter = vertices.iterator();
! while (iter.hasNext()) {
! // TODO Find the clost point measured as XY distance in
! // the closest surface
! Vertex v = (Vertex) iter.next();
! // Test if v is in the same plane as the closest surface
! Vertex vLocal = system.translate(v);
! if (Math.abs(vLocal.getZ()) < 0.0000000001) {
! return v;
! }
}
}
+ // Look for an Edge
+ {
+ Iterator iter = edges.iterator();
+ while (iter.hasNext()) {
+ // TODO Find the two closest edges measured as XY distance in
+ // the closest surface
+ Edge e = (Edge) iter.next();
+ Vertex from = e.getFrom();
+ Vertex to = e.getTo();
+ if (vertices.contains(from)) {
+ return from;
+ }
+ if (vertices.contains(to)) {
+ return to;
+ }
+ // Test if from and to are in the same plane as the closest surface
+ Vertex fromLocal = system.translate(from);
+ Vertex toLocal = system.translate(to);
+ if ((Math.abs(fromLocal.getZ()) < 0.0000000001)
+ && (Math.abs(toLocal.getZ()) < 0.0000000001)) {
+ return e;
+ }
+ }
+ }
}
if (closest instanceof Edge) {
|