tetrahedra (point p1, point p2, point p3, point p4, bool v = false) : p {p1, p2, p3, p4} { label = p1.l; totalPoints = 0; wrongPoints = 0; // create triangles triangle t1(p1, p2, p3); triangle t2(p2, p1, p4); triangle t3(p3, p2, p4); triangle t4(p1, p3, p4); t1.getPlaneEquationCoefficients(a1, b1,c1,d1); t2.getPlaneEquationCoefficients(a2, b2,c2,d2); t3.getPlaneEquationCoefficients(a3, b3,c3,d3); t4.getPlaneEquationCoefficients(a4, b4,c4,d4); calculateSideLength(); if(v) { std::ofstream fpoints("points.dat"); fpoints << p1.x << " " << p1.y << " " << p1.z << std::endl; fpoints << p2.x << " " << p2.y << " " << p2.z << std::endl; fpoints << p3.x << " " << p3.y << " " << p3.z << std::endl; fpoints << p4.x << " " << p4.y << " " << p4.z << std::endl; fpoints.close(); } centerX = (p1.x + p2.x + p3.x + p4.x)/4.0; centerY = (p1.y + p2.y + p3.y + p4.y)/4.0; centerZ = (p1.z + p2.z + p3.z + p4.z)/4.0; if(v) { std::ofstream fnormals("normals.dat"); fnormals << centerX << " " << centerY << " " << centerZ << std::endl; fnormals << centerX - a1 << " " << centerY - b1 << " " << centerZ - c1 << " " << d1 << std::endl << std::endl<< std::endl; fnormals << centerX << " " << centerY << " " << centerZ << std::endl; fnormals << centerX - a2 << " " << centerY - b2 << " " << centerZ - c2 << " " << d2 << std::endl << std::endl<< std::endl; fnormals << centerX << " " << centerY << " " << centerZ << std::endl; fnormals << centerX - a3 << " " << centerY - b3 << " " << centerZ - c3 << " " << d3 << std::endl << std::endl<< std::endl; fnormals << centerX << " " << centerY << " " << centerZ << std::endl; fnormals << centerX - a4 << " " << centerY - b4 << " " << centerZ - c4 << " " << d4 << std::endl << std::endl<< std::endl; fnormals.close(); } point com(centerX, centerY, centerZ +1 , 1); if (!checkPointInside(com)) std::cerr << "ERROR: Center of Mass not inside Tetrahedra!" << std::endl; }
int main(int argc, char* argv[]) { const char* filename = (argc > 1) ? argv[1] : "data/eight.off"; Mesh mesh; OpenMesh::IO::read_mesh(mesh, filename); CGAL::OM_pmap<Mesh, face_descriptor, Vector> fnormals(mesh); CGAL::OM_pmap<Mesh, vertex_descriptor, Vector> vnormals(mesh); mesh.add_property(fnormals.handle()); mesh.add_property(vnormals.handle()); Vector v(0, 0, 0); BOOST_FOREACH(vertex_descriptor vd, vertices(mesh)){ put(vnormals, vd, v); }