mirror of https://github.com/CGAL/cgal
always use read_polygon_mesh and write_MEDIT
This commit is contained in:
parent
2359de500e
commit
bb61127254
|
|
@ -1,12 +1,13 @@
|
||||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||||
|
|
||||||
#include "CGAL/Polygon_mesh_processing/polygon_soup_self_intersections.h"
|
#include <CGAL/IO/polygon_mesh_io.h>
|
||||||
|
#include <CGAL/IO/write_MEDIT.h>
|
||||||
#include <CGAL/Polygon_mesh_processing/autorefinement.h>
|
#include <CGAL/Polygon_mesh_processing/autorefinement.h>
|
||||||
|
#include <CGAL/Polygon_mesh_processing/polygon_soup_self_intersections.h>
|
||||||
#include <CGAL/Polygon_mesh_processing/self_intersections.h>
|
#include <CGAL/Polygon_mesh_processing/self_intersections.h>
|
||||||
#include <CGAL/Surface_mesh/Surface_mesh.h>
|
#include <CGAL/Surface_mesh/Surface_mesh.h>
|
||||||
#include <CGAL/make_conforming_constrained_Delaunay_triangulation_3.h>
|
|
||||||
|
|
||||||
#include <CGAL/draw_constrained_triangulation_3.h>
|
#include <CGAL/draw_constrained_triangulation_3.h>
|
||||||
|
#include <CGAL/make_conforming_constrained_Delaunay_triangulation_3.h>
|
||||||
|
|
||||||
using K = CGAL::Exact_predicates_inexact_constructions_kernel;
|
using K = CGAL::Exact_predicates_inexact_constructions_kernel;
|
||||||
using Point = K::Point_3;
|
using Point = K::Point_3;
|
||||||
|
|
@ -20,8 +21,7 @@ int main(int argc, char* argv[])
|
||||||
: CGAL::data_file_path("meshes/spheres_intersecting.off");
|
: CGAL::data_file_path("meshes/spheres_intersecting.off");
|
||||||
|
|
||||||
CGAL::Surface_mesh<K::Point_3> mesh;
|
CGAL::Surface_mesh<K::Point_3> mesh;
|
||||||
std::ifstream in(filename);
|
if(!CGAL::IO::read_polygon_mesh(filename, mesh)) {
|
||||||
if(!in || !(in >> mesh)) {
|
|
||||||
std::cerr << "Error: cannot read file " << filename << std::endl;
|
std::cerr << "Error: cannot read file " << filename << std::endl;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
@ -29,6 +29,8 @@ int main(int argc, char* argv[])
|
||||||
std::cout << "Number of facets in " << filename << ": "
|
std::cout << "Number of facets in " << filename << ": "
|
||||||
<< mesh.number_of_faces() << "\n";
|
<< mesh.number_of_faces() << "\n";
|
||||||
|
|
||||||
|
CGAL::Conforming_constrained_Delaunay_triangulation_3<K> ccdt;
|
||||||
|
|
||||||
if(PMP::does_self_intersect(mesh))
|
if(PMP::does_self_intersect(mesh))
|
||||||
{
|
{
|
||||||
std::cout << "Mesh self-intersects, performing autorefine...\n";
|
std::cout << "Mesh self-intersects, performing autorefine...\n";
|
||||||
|
|
@ -46,22 +48,21 @@ int main(int argc, char* argv[])
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ccdt = CGAL::make_conforming_constrained_Delaunay_triangulation_3(points, polygons);
|
ccdt = CGAL::make_conforming_constrained_Delaunay_triangulation_3(points, polygons);
|
||||||
|
|
||||||
std::cout << "Number of constrained facets in the CDT: "
|
|
||||||
<< ccdt.number_of_constrained_facets() << '\n';
|
|
||||||
|
|
||||||
CGAL::draw(ccdt);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto ccdt = CGAL::make_conforming_constrained_Delaunay_triangulation_3(mesh);
|
ccdt = CGAL::make_conforming_constrained_Delaunay_triangulation_3(mesh);
|
||||||
|
}
|
||||||
std::cout << "Number of constrained facets in the CDT: "
|
std::cout << "Number of constrained facets in the CDT: "
|
||||||
<< ccdt.number_of_constrained_facets() << '\n';
|
<< ccdt.number_of_constrained_facets() << '\n';
|
||||||
|
|
||||||
|
std::ofstream ofs(argc > 2 ? argv[2] : "out.mesh");
|
||||||
|
ofs.precision(17);
|
||||||
|
CGAL::IO::write_MEDIT(ofs, ccdt);
|
||||||
|
|
||||||
CGAL::draw(ccdt);
|
CGAL::draw(ccdt);
|
||||||
}
|
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||||
|
|
||||||
|
#include <CGAL/IO/polygon_mesh_io.h>
|
||||||
|
#include <CGAL/IO/write_MEDIT.h>
|
||||||
#include <CGAL/Surface_mesh/Surface_mesh.h>
|
#include <CGAL/Surface_mesh/Surface_mesh.h>
|
||||||
#include <CGAL/make_conforming_constrained_Delaunay_triangulation_3.h>
|
#include <CGAL/make_conforming_constrained_Delaunay_triangulation_3.h>
|
||||||
|
|
||||||
|
|
@ -17,8 +19,7 @@ int main(int argc, char* argv[])
|
||||||
: CGAL::data_file_path("meshes/mpi_and_sphere.off");
|
: CGAL::data_file_path("meshes/mpi_and_sphere.off");
|
||||||
|
|
||||||
CGAL::Surface_mesh<K::Point_3> mesh;
|
CGAL::Surface_mesh<K::Point_3> mesh;
|
||||||
std::ifstream in(filename);
|
if(!CGAL::IO::read_polygon_mesh(filename, mesh)) {
|
||||||
if(!in || !(in >> mesh)) {
|
|
||||||
std::cerr << "Error: cannot read file " << filename << std::endl;
|
std::cerr << "Error: cannot read file " << filename << std::endl;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
@ -39,6 +40,10 @@ int main(int argc, char* argv[])
|
||||||
std::cout << "Number of constrained facets in the CDT: "
|
std::cout << "Number of constrained facets in the CDT: "
|
||||||
<< ccdt.number_of_constrained_facets() << '\n';
|
<< ccdt.number_of_constrained_facets() << '\n';
|
||||||
|
|
||||||
|
std::ofstream ofs(argc > 2 ? argv[2] : "out.mesh");
|
||||||
|
ofs.precision(17);
|
||||||
|
CGAL::IO::write_MEDIT(ofs, ccdt);
|
||||||
|
|
||||||
CGAL::draw(ccdt);
|
CGAL::draw(ccdt);
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
#include <CGAL/draw_constrained_triangulation_3.h>
|
|
||||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||||
#include <CGAL/make_conforming_constrained_Delaunay_triangulation_3.h>
|
#include <CGAL/IO/polygon_mesh_io.h>
|
||||||
|
#include <CGAL/IO/write_MEDIT.h>
|
||||||
#include <CGAL/Polygon_mesh_processing/connected_components.h>
|
#include <CGAL/Polygon_mesh_processing/connected_components.h>
|
||||||
#include <CGAL/Polygon_mesh_processing/polygon_mesh_to_polygon_soup.h>
|
#include <CGAL/Polygon_mesh_processing/polygon_mesh_to_polygon_soup.h>
|
||||||
#include <CGAL/Surface_mesh/Surface_mesh.h>
|
#include <CGAL/Surface_mesh/Surface_mesh.h>
|
||||||
|
#include <CGAL/draw_constrained_triangulation_3.h>
|
||||||
|
#include <CGAL/make_conforming_constrained_Delaunay_triangulation_3.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
@ -17,13 +19,10 @@ namespace PMP = CGAL::Polygon_mesh_processing;
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
CGAL::Surface_mesh<K::Point_3> mesh;
|
|
||||||
std::vector<K::Point_3> points;
|
|
||||||
std::vector<std::vector<std::size_t>> polygons;
|
|
||||||
|
|
||||||
auto filename = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/cubes_one_patch_id_per_cc.off");
|
auto filename = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/cubes_one_patch_id_per_cc.off");
|
||||||
std::ifstream in(filename);
|
|
||||||
if(!in || !(in >> mesh)) {
|
CGAL::Surface_mesh<K::Point_3> mesh;
|
||||||
|
if(!CGAL::IO::read_polygon_mesh(filename, mesh)) {
|
||||||
std::cerr << "Error: cannot read file " << filename << std::endl;
|
std::cerr << "Error: cannot read file " << filename << std::endl;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
@ -41,6 +40,9 @@ int main(int argc, char* argv[])
|
||||||
return fpmap[f1] < fpmap[f2];
|
return fpmap[f1] < fpmap[f2];
|
||||||
})] + 1
|
})] + 1
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
|
std::vector<K::Point_3> points;
|
||||||
|
std::vector<std::vector<std::size_t>> polygons;
|
||||||
PMP::polygon_mesh_to_polygon_soup(mesh, points, polygons);
|
PMP::polygon_mesh_to_polygon_soup(mesh, points, polygons);
|
||||||
|
|
||||||
auto polygon_to_patch_id = [&](std::size_t i) {
|
auto polygon_to_patch_id = [&](std::size_t i) {
|
||||||
|
|
@ -56,6 +58,9 @@ int main(int argc, char* argv[])
|
||||||
<< "Number of constrained facets in the CDT: "
|
<< "Number of constrained facets in the CDT: "
|
||||||
<< ccdt.number_of_constrained_facets() << '\n';
|
<< ccdt.number_of_constrained_facets() << '\n';
|
||||||
|
|
||||||
|
std::ofstream ofs(argc > 2 ? argv[2] : "out.mesh");
|
||||||
|
ofs.precision(17);
|
||||||
|
CGAL::IO::write_MEDIT(ofs, ccdt);
|
||||||
|
|
||||||
CGAL::draw(ccdt);
|
CGAL::draw(ccdt);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||||
|
|
||||||
|
#include <CGAL/IO/write_MEDIT.h>
|
||||||
#include <CGAL/Surface_mesh/Surface_mesh.h>
|
#include <CGAL/Surface_mesh/Surface_mesh.h>
|
||||||
#include <CGAL/Polygon_mesh_processing/self_intersections.h>
|
#include <CGAL/Polygon_mesh_processing/self_intersections.h>
|
||||||
#include <CGAL/Polygon_mesh_processing/autorefinement.h>
|
#include <CGAL/Polygon_mesh_processing/autorefinement.h>
|
||||||
|
|
@ -22,8 +23,7 @@ int main(int argc, char* argv[])
|
||||||
: CGAL::data_file_path("meshes/mpi_and_sphere.off");
|
: CGAL::data_file_path("meshes/mpi_and_sphere.off");
|
||||||
|
|
||||||
CGAL::Surface_mesh<K::Point_3> mesh;
|
CGAL::Surface_mesh<K::Point_3> mesh;
|
||||||
std::ifstream in(filename);
|
if(!CGAL::IO::read_polygon_mesh(filename, mesh)) {
|
||||||
if(!in || !(in >> mesh)) {
|
|
||||||
std::cerr << "Error: cannot read file " << filename << std::endl;
|
std::cerr << "Error: cannot read file " << filename << std::endl;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
@ -52,6 +52,7 @@ int main(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGAL::Conforming_constrained_Delaunay_triangulation_3<K> ccdt;
|
||||||
if(triangle_mesh && PMP::does_self_intersect(mesh))
|
if(triangle_mesh && PMP::does_self_intersect(mesh))
|
||||||
{
|
{
|
||||||
std::cout << "Mesh is a self-intersecting triangle mesh, perform autorefinement...\n";
|
std::cout << "Mesh is a self-intersecting triangle mesh, perform autorefinement...\n";
|
||||||
|
|
@ -64,25 +65,25 @@ int main(int argc, char* argv[])
|
||||||
std::cout << "Number of facets after preprocessing: "
|
std::cout << "Number of facets after preprocessing: "
|
||||||
<< polygons.size() << "\n";
|
<< polygons.size() << "\n";
|
||||||
|
|
||||||
auto ccdt = CGAL::make_conforming_constrained_Delaunay_triangulation_3(points, polygons);
|
ccdt = CGAL::make_conforming_constrained_Delaunay_triangulation_3(points, polygons);
|
||||||
|
|
||||||
std::cout << "Number of constrained facets in the CDT: "
|
|
||||||
<< ccdt.number_of_constrained_facets() << '\n';
|
|
||||||
|
|
||||||
CGAL::draw(ccdt);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "Number of facets after preprocessing: "
|
std::cout << "Number of facets after preprocessing: "
|
||||||
<< mesh.number_of_faces() << "\n";
|
<< mesh.number_of_faces() << "\n";
|
||||||
|
|
||||||
auto ccdt = CGAL::make_conforming_constrained_Delaunay_triangulation_3(mesh);
|
ccdt = CGAL::make_conforming_constrained_Delaunay_triangulation_3(mesh);
|
||||||
|
}
|
||||||
|
|
||||||
std::cout << "Number of constrained facets in the CDT: "
|
std::cout << "Number of constrained facets in the CDT: "
|
||||||
<< ccdt.number_of_constrained_facets() << '\n';
|
<< ccdt.number_of_constrained_facets() << '\n';
|
||||||
|
|
||||||
|
std::ofstream ofs(argc > 2 ? argv[2] : "out.mesh");
|
||||||
|
ofs.precision(17);
|
||||||
|
CGAL::IO::write_MEDIT(ofs, ccdt);
|
||||||
|
|
||||||
CGAL::draw(ccdt);
|
CGAL::draw(ccdt);
|
||||||
}
|
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,9 @@ using K = CGAL::Exact_predicates_inexact_constructions_kernel;
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
CGAL::Surface_mesh<K::Point_3> mesh;
|
|
||||||
|
|
||||||
auto filename = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/mpi.off");
|
auto filename = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/mpi.off");
|
||||||
|
|
||||||
|
CGAL::Surface_mesh<K::Point_3> mesh;
|
||||||
if(!CGAL::IO::read_polygon_mesh(filename, mesh)) {
|
if(!CGAL::IO::read_polygon_mesh(filename, mesh)) {
|
||||||
std::cerr << "Error: cannot read file " << filename << std::endl;
|
std::cerr << "Error: cannot read file " << filename << std::endl;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
@ -27,7 +27,8 @@ int main(int argc, char* argv[])
|
||||||
<< "Number of constrained facets in the CDT: "
|
<< "Number of constrained facets in the CDT: "
|
||||||
<< ccdt.number_of_constrained_facets() << '\n';
|
<< ccdt.number_of_constrained_facets() << '\n';
|
||||||
|
|
||||||
std::ofstream ofs("out.mesh");
|
std::ofstream ofs(argc > 2 ? argv[2] : "out.mesh");
|
||||||
|
ofs.precision(17);
|
||||||
CGAL::IO::write_MEDIT(ofs, ccdt);
|
CGAL::IO::write_MEDIT(ofs, ccdt);
|
||||||
|
|
||||||
CGAL::draw(ccdt);
|
CGAL::draw(ccdt);
|
||||||
|
|
|
||||||
|
|
@ -44,9 +44,9 @@ int main(int argc, char* argv[])
|
||||||
<< "Number of constrained facets in the CDT: "
|
<< "Number of constrained facets in the CDT: "
|
||||||
<< ccdt.number_of_constrained_facets() << '\n';
|
<< ccdt.number_of_constrained_facets() << '\n';
|
||||||
|
|
||||||
std::ofstream out("ccdt.mesh");
|
std::ofstream ofs(argc > 2 ? argv[2] : "out.mesh");
|
||||||
CGAL::IO::write_MEDIT(out, ccdt);
|
ofs.precision(17);
|
||||||
out.close();
|
CGAL::IO::write_MEDIT(ofs, ccdt);
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||||
#include <CGAL/IO/polygon_soup_io.h>
|
#include <CGAL/IO/polygon_soup_io.h>
|
||||||
|
#include <CGAL/IO/write_MEDIT.h>
|
||||||
#include <CGAL/draw_constrained_triangulation_3.h>
|
#include <CGAL/draw_constrained_triangulation_3.h>
|
||||||
#include <CGAL/make_conforming_constrained_Delaunay_triangulation_3.h>
|
#include <CGAL/make_conforming_constrained_Delaunay_triangulation_3.h>
|
||||||
|
|
||||||
|
|
@ -9,10 +10,10 @@ using K = CGAL::Exact_predicates_inexact_constructions_kernel;
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
auto filename = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/cubes.off");
|
||||||
|
|
||||||
std::vector<K::Point_3> points;
|
std::vector<K::Point_3> points;
|
||||||
std::vector<std::vector<std::size_t>> polygons;
|
std::vector<std::vector<std::size_t>> polygons;
|
||||||
|
|
||||||
auto filename = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/cubes.off");
|
|
||||||
if(!CGAL::IO::read_polygon_soup(filename, points, polygons)) {
|
if(!CGAL::IO::read_polygon_soup(filename, points, polygons)) {
|
||||||
std::cerr << "Error: cannot read file " << filename << std::endl;
|
std::cerr << "Error: cannot read file " << filename << std::endl;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
@ -28,6 +29,10 @@ int main(int argc, char* argv[])
|
||||||
<< "Number of constrained facets in the CDT: "
|
<< "Number of constrained facets in the CDT: "
|
||||||
<< ccdt.number_of_constrained_facets() << '\n';
|
<< ccdt.number_of_constrained_facets() << '\n';
|
||||||
|
|
||||||
|
std::ofstream ofs(argc > 2 ? argv[2] : "out.mesh");
|
||||||
|
ofs.precision(17);
|
||||||
|
CGAL::IO::write_MEDIT(ofs, ccdt);
|
||||||
|
|
||||||
CGAL::draw(ccdt);
|
CGAL::draw(ccdt);
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue