// Print on master all the per-processor surface stats. void writeProcStats ( const triSurface& s, const List<List<treeBoundBox> >& meshBb ) { // Determine surface bounding boxes, faces, points List<treeBoundBox> surfBb(Pstream::nProcs()); { surfBb[Pstream::myProcNo()] = treeBoundBox(s.points()); Pstream::gatherList(surfBb); Pstream::scatterList(surfBb); } labelList nPoints(Pstream::nProcs()); nPoints[Pstream::myProcNo()] = s.points().size(); Pstream::gatherList(nPoints); Pstream::scatterList(nPoints); labelList nFaces(Pstream::nProcs()); nFaces[Pstream::myProcNo()] = s.size(); Pstream::gatherList(nFaces); Pstream::scatterList(nFaces); forAll(surfBb, procI) { const List<treeBoundBox>& bbs = meshBb[procI]; Info<< "processor" << procI << nl << "\tMesh bounds : " << bbs[0] << nl; for (label i = 1; i < bbs.size(); i++) { Info<< "\t " << bbs[i]<< nl; } Info<< "\tSurface bounding box : " << surfBb[procI] << nl << "\tTriangles : " << nFaces[procI] << nl << "\tVertices : " << nPoints[procI] << endl; } Info<< endl; }
scalarField calcCurvature(const triSurface& surf) { scalarField k(surf.points().size(), 0); Polyhedron P; buildCGALPolyhedron convert(surf); P.delegate(convert); // Info<< "Created CGAL Polyhedron with " << label(P.size_of_vertices()) // << " vertices and " << label(P.size_of_facets()) // << " facets. " << endl; // The rest of this function adapted from // CGAL-3.7/examples/Jet_fitting_3/Mesh_estimation.cpp //Vertex property map, with std::map typedef std::map<Vertex*, int> Vertex2int_map_type; typedef boost::associative_property_map< Vertex2int_map_type > Vertex_PM_type; typedef T_PolyhedralSurf_rings<Polyhedron, Vertex_PM_type > Poly_rings; typedef CGAL::Monge_via_jet_fitting<Kernel> Monge_via_jet_fitting; typedef Monge_via_jet_fitting::Monge_form Monge_form; std::vector<Point_3> in_points; //container for data points // default parameter values and global variables unsigned int d_fitting = 2; unsigned int d_monge = 2; unsigned int min_nb_points = (d_fitting + 1)*(d_fitting + 2)/2; //initialize the tag of all vertices to -1 Vertex_iterator vitb = P.vertices_begin(); Vertex_iterator vite = P.vertices_end(); Vertex2int_map_type vertex2props; Vertex_PM_type vpm(vertex2props); CGAL_For_all(vitb, vite) { put(vpm, &(*vitb), -1); }
// Does face use valid vertices? bool validTri ( const bool verbose, const triSurface& surf, const label faceI ) { // Simple check on indices ok. const labelledTri& f = surf[faceI]; forAll(f, fp) { if (f[fp] < 0 || f[fp] >= surf.points().size()) { WarningIn("validTri(const triSurface&, const label)") << "triangle " << faceI << " vertices " << f << " uses point indices outside point range 0.." << surf.points().size()-1 << endl; return false; } } if ((f[0] == f[1]) || (f[0] == f[2]) || (f[1] == f[2])) { WarningIn("validTri(const triSurface&, const label)") << "triangle " << faceI << " uses non-unique vertices " << f << " coords:" << f.points(surf.points()) << endl; return false; } // duplicate triangle check const labelList& fFaces = surf.faceFaces()[faceI]; // Check if faceNeighbours use same points as this face. // Note: discards normal information - sides of baffle are merged. forAll(fFaces, i) { label nbrFaceI = fFaces[i]; if (nbrFaceI <= faceI) { // lower numbered faces already checked continue; } const labelledTri& nbrF = surf[nbrFaceI]; if ( ((f[0] == nbrF[0]) || (f[0] == nbrF[1]) || (f[0] == nbrF[2])) && ((f[1] == nbrF[0]) || (f[1] == nbrF[1]) || (f[1] == nbrF[2])) && ((f[2] == nbrF[0]) || (f[2] == nbrF[1]) || (f[2] == nbrF[2])) ) { WarningIn("validTri(const triSurface&, const label)") << "triangle " << faceI << " vertices " << f << " has the same vertices as triangle " << nbrFaceI << " vertices " << nbrF << " coords:" << f.points(surf.points()) << endl; return false; } }