Issues

Issue #12 open

WETriangleMesh

opiateangel
created an issue

use of removeFace(Face f) to remove adjacent faces in a SuperEllipsoid WETriangeleMesh results in edges between faces not removed, and "can't remove edge" for imported stls.

{{{ public void removeFace(Face f) { faces.remove(f); for (WingedEdge e : ((WEFace) f).edges) { e.faces.remove(f); if (e.faces.size() == 0) { removeEdge(e); } } } }}}

removing {{{ if (e.faces.size() == 0) { removeEdge(e); } }}} bypasses the problem for processing, by copying the class WETriangleMesh into script, but when exporting as obj, the resultant mesh displays incorrect indexing. tried to edit the removeEdge, {{{ protected void removeEdge(WingedEdge e) { e.remove(); WEVertex v = (WEVertex) e.a; if (v.edges.size() == 0) { vertices.remove(v); } v = (WEVertex) e.b; if (v.edges.size() == 0) { vertices.remove(v); } for (WEFace f : e.faces) { removeFace(f); } WingedEdge removed = edges.remove(edgeCheck.set(e.a, e.b)); if (removed != e) { throw new IllegalStateException("can't remove edge"); } } }}} into {{{ protected void removeEdge(WingedEdge e) { e.remove(); WEVertex v = (WEVertex) e.a; if (v.edges.size() == 0) { vertices.remove(v); } v = (WEVertex) e.b; if (v.edges.size() == 0) { vertices.remove(v); } for (WEFace f : e.faces) { removeFace(f); } edges.remove(edgeCheck.set(e.a, e.b)); } }}} but this unravels the mesh.

looked at the face and edge and vertex count for the mesh, and the numbers are off, there are duplicate edges, vertices, and faces. {{{ SurfaceMeshBuilder(new SuperEllipsoid(1, 1)).createMesh(i); }}} for i = 3 vertex:5 edge:7 face:5 when it should be 4,6,4 for i = 4 vertex:12 edge:16 face:17 when it should be 6,12,8 for i=5 bottom face doesn't exist, vertex:12 edge:26 face:17 when it should be 11,25,15 for i = 6 vertex:16 edge:38 face:28 when it should be 14,36,24

in which case, this is probably an issue with SuperEllipsoid and not the WETriangleMesh, but i haven't had the chance to look at the code beyond this yet.

Comments (4)

  1. opiateangel reporter

    for the intersect ray this checks orientation.

    		Vec3D intersectRay(Ray3D r) {
    			Vec3D ps = new Vec3D(999999f, 999999f, 999999f);
    			for (Face f : mesh.faces) {
    				Triangle3D t = f.toTriangle();
    				Vec3D fp = f.getCentroid();
    				Vec3D fn = f.normal;
    				Vec3D vt = fn.cross(r.getDirection());
    				Vec3D vp = r.sub(fp);
    				Vec3D p = orthonormal(vp, vt);
    				p.add(fp);
    				if (t.containsPoint(p) && p.sub(r).magnitude() < ps.sub(r).magnitude() 
    						&& vp.angleBetween(r.getDirection(), true) > PI / 2)
    					ps = p;
    			}
    			return ps;
    		}
    
    		Vec3D orthonormal(Vec3D u, Vec3D v) {
    			float a = u.cross(v).magnitude() / v.magnitude();
    			Vec3D w = v.cross(u.cross(v)).normalizeTo(a);
    			return w;
    		}
    
  2. Log in to comment