void Foam::DelaunayMeshTools::writeInternalDelaunayVertices ( const fileName& instance, const Triangulation& t ) { pointField internalDelaunayVertices(t.number_of_vertices()); label vertI = 0; for ( typename Triangulation::Finite_vertices_iterator vit = t.finite_vertices_begin(); vit != t.finite_vertices_end(); ++vit ) { if (vit->internalPoint()) { internalDelaunayVertices[vertI++] = topoint(vit->point()); } } internalDelaunayVertices.setSize(vertI); pointIOField internalDVs ( IOobject ( "internalDelaunayVertices", instance, t.time(), IOobject::NO_READ, IOobject::AUTO_WRITE ), internalDelaunayVertices ); Info<< nl << "Writing " << internalDVs.name() << " to " << internalDVs.instance() << endl; internalDVs.write(); }
int main() { Triangulation triangulation; boost::filesystem::path input_pathname = "C:/Carleton/CGAL-4.4/demo/Polyhedron/data/elephant.off"; // create_cubes(triangulation, 2, 2, 1 ); read_off( triangulation, input_pathname.string() ); // read_off(triangulation, "C:/Carleton/Meshes/holmes_off/geometry/octahedron.off"); // read_off(triangulation, "C:/Carleton/CGAL-4.4/demo/Polyhedron/data/cube.off"); // read_off(triangulation, "C:/Carleton/CGAL-4.4/demo/Polyhedron/data/ellipsoid.off"); #if 0 for (auto cell = triangulation.finite_cells_begin(); cell != triangulation.finite_cells_end(); ++cell) { for (int i = 0; i < 4; ++i) { Point p = cell->vertex(i)->point(); assert(-10.0 < p.x() && p.x() < +10.0); assert(-10.0 < p.y() && p.y() < +10.0); assert(-10.0 < p.z() && p.z() < +10.0); } } #endif set_cell_and_vertex_ids(triangulation); set_random_weights(triangulation); propagate_weights(triangulation); std::cout << "Number of finite vertices : " << triangulation.number_of_vertices() << std::endl; std::cout << "Number of finite edges : " << triangulation.number_of_finite_edges() << std::endl; std::cout << "Number of finite facets : " << triangulation.number_of_finite_facets() << std::endl; std::cout << "Number of finite cells : " << triangulation.number_of_finite_cells() << std::endl; std::string filename = input_pathname.filename().stem().string() + "_tet.vtk"; write_vtk( triangulation, filename ); if (triangulation.number_of_finite_cells() < 100) { dump_triangulation(triangulation); } Graph graph; create_steiner_points(graph,triangulation); // the distances are temporary, so we choose an external property for that std::vector<double> distances(num_vertices(graph)); std::vector<GraphNode_descriptor> predecessors(num_vertices(graph)); boost::dijkstra_shortest_paths( graph, *vertices(graph).first, boost::weight_map(get(&GraphEdge::weight, graph)). distance_map(boost::make_iterator_property_map(distances.begin(), get(boost::vertex_index, graph))). predecessor_map(boost::make_iterator_property_map(predecessors.begin(), get(boost::vertex_index, graph))) ); filename = input_pathname.filename().stem().string() + "_wsp.vtk"; write_shortest_path_vtk( graph, predecessors, distances, filename ); // write_graph_dot("graph.dot", graph); std::cout << "This is the end..." << std::endl; return EXIT_SUCCESS; }
bool Foam::conformalVoronoiMesh::distributeBackground(const Triangulation& mesh) { if (!Pstream::parRun()) { return false; } Info<< nl << "Redistributing points" << endl; timeCheck("Before distribute"); label iteration = 0; scalar previousLoadUnbalance = 0; while (true) { scalar maxLoadUnbalance = mesh.calculateLoadUnbalance(); if ( maxLoadUnbalance <= foamyHexMeshControls().maxLoadUnbalance() || maxLoadUnbalance <= previousLoadUnbalance ) { // If this is the first iteration, return false, if it was a // subsequent one, return true; return iteration != 0; } previousLoadUnbalance = maxLoadUnbalance; Info<< " Total number of vertices before redistribution " << returnReduce(label(mesh.number_of_vertices()), sumOp<label>()) << endl; const fvMesh& bMesh = decomposition_().mesh(); volScalarField cellWeights ( IOobject ( "cellWeights", bMesh.time().timeName(), bMesh, IOobject::NO_READ, IOobject::NO_WRITE ), bMesh, dimensionedScalar("weight", dimless, 1e-2), zeroGradientFvPatchScalarField::typeName ); meshSearch cellSearch(bMesh, polyMesh::FACE_PLANES); labelList cellVertices(bMesh.nCells(), label(0)); for ( typename Triangulation::Finite_vertices_iterator vit = mesh.finite_vertices_begin(); vit != mesh.finite_vertices_end(); ++vit ) { // Only store real vertices that are not feature vertices if (vit->real() && !vit->featurePoint()) { pointFromPoint v = topoint(vit->point()); label cellI = cellSearch.findCell(v); if (cellI == -1) { // Pout<< "findCell conformalVoronoiMesh::distribute " // << "findCell " // << vit->type() << " " // << vit->index() << " " // << v << " " // << cellI // << " find nearest cellI "; cellI = cellSearch.findNearestCell(v); } cellVertices[cellI]++; } } forAll(cellVertices, cI) { // Give a small but finite weight for empty cells. Some // decomposition methods have difficulty with integer overflows in // the sum of the normalised weight field. cellWeights.internalField()[cI] = max ( cellVertices[cI], 1e-2 ); } autoPtr<mapDistributePolyMesh> mapDist = decomposition_().distribute ( cellWeights ); cellShapeControl_.shapeControlMesh().distribute(decomposition_); distribute(); timeCheck("After distribute"); iteration++; }