//---------------------------------------------------------------------------- void VETable::RemoveTriangles (V3Array& rkVA, T3Array& rkTA) { // ear-clip the wireframe to get the triangles Triangle3 kTri; while ( Remove(kTri) ) { int iV0 = (int)rkVA.size(), iV1 = iV0+1, iV2 = iV1+1; rkTA.push_back(Triangle3(iV0,iV1,iV2)); const Vertex& rkV0 = m_akVertex[kTri.i0]; const Vertex& rkV1 = m_akVertex[kTri.i1]; const Vertex& rkV2 = m_akVertex[kTri.i2]; rkVA.push_back(Vertex3(rkV0.m_fX,rkV0.m_fY,rkV0.m_fZ)); rkVA.push_back(Vertex3(rkV1.m_fX,rkV1.m_fY,rkV1.m_fZ)); rkVA.push_back(Vertex3(rkV2.m_fX,rkV2.m_fY,rkV2.m_fZ)); } }
void triangle_tree( const Eigen::MatrixXd & V, const Eigen::MatrixXi & F, TriTree & tree, TriangleList & tlist) { assert(F.cols() == 3); tlist.clear(); // Loop over facets for(int f = 0;f<F.rows();f++) { Point3 a(V(F(f,0),0), V(F(f,0),1), V(F(f,0),2)); Point3 b(V(F(f,1),0), V(F(f,1),1), V(F(f,1),2)); Point3 c(V(F(f,2),0), V(F(f,2),1), V(F(f,2),2)); tlist.push_back(Triangle3( a,b,c)); } // constructs AABB tree tree.clear(); tree.insert(tlist.begin(),tlist.end()); }