Unify input and make that output can be written simultaneously (for example during the testsuite)

This commit is contained in:
Andreas Fabri 2024-01-15 13:46:15 +00:00
parent 9a39ac9b61
commit 816a25895b
10 changed files with 26 additions and 25 deletions

View File

@ -58,7 +58,7 @@ int main(int, char**)
CGAL::Isosurfacing::dual_contouring(domain, 0.8, points, polygons);
// write output indexed surface mesh to file, in OFF format
CGAL::IO::write_OFF("output.off", points, polygons);
CGAL::IO::write_OFF("dual_contouring_Cartesian_grid.off", points, polygons);
return EXIT_SUCCESS;
}

View File

@ -53,7 +53,7 @@ int main(int, char**)
CGAL::Isosurfacing::dual_contouring(domain, 0.0, points, polygons);
// save output to the OFF format
CGAL::IO::write_OFF("output.off", points, polygons);
CGAL::IO::write_OFF("dual_contouring_implicit_iwp.off", points, polygons);
return EXIT_SUCCESS;
}

View File

@ -30,9 +30,10 @@ using Tree = CGAL::AABB_tree<Traits>;
using Point_range = std::vector<Point>;
using Polygon_range = std::vector<std::vector<std::size_t> >;
int main(int, char**)
int main(int argc, char* argv[])
{
const std::string input_name = CGAL::data_file_path("meshes/cross.off");
const std::string input_name = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/cross.off");
const Vector grid_spacing(0.1, 0.1, 0.1);
const FT offset_value = 0.2;
@ -79,7 +80,7 @@ int main(int, char**)
CGAL::Isosurfacing::dual_contouring(domain, offset_value, points, polygons);
// save output indexed mesh to a file, in the OFF format
CGAL::IO::write_OFF("result.off", points, polygons);
CGAL::IO::write_OFF("dual_contouring_mesh_offset.off", points, polygons);
return EXIT_SUCCESS;
}

View File

@ -96,7 +96,7 @@ int main(int, char**)
CGAL::Isosurfacing::dual_contouring(domain, 0.8, points, polygons);
CGAL::IO::write_OFF("output.off", points, polygons);
CGAL::IO::write_OFF("dual_contouring_octree.off", points, polygons);
return EXIT_SUCCESS;
}

View File

@ -16,7 +16,7 @@ using Polygon_range = std::vector<std::vector<std::size_t> >;
int main(int, char**)
{
// 3D bounding box [-1, 1]^3 and Cartesian grid
// 3D bounding box [-1, 1]^3 and Cartesian grid
const CGAL::Bbox_3 bbox{-1., -1., -1., 1., 1., 1.};
Grid grid { 50, 50, 50, bbox };
@ -46,7 +46,7 @@ int main(int, char**)
CGAL::Isosurfacing::marching_cubes(domain, 0.8, points, triangles);
// save output indexed surface mesh to file, in the OFF format
CGAL::IO::write_OFF("output.off", points, triangles);
CGAL::IO::write_OFF("marching_cubes_Cartesian_grid_sphere.off", points, triangles);
return EXIT_SUCCESS;
}

View File

@ -44,7 +44,7 @@ int main(int, char**)
std::cout << "done (" << timer.time() << "s, " << triangles.size() << " triangles)" << std::endl;
// save ouput indexed mesh to a file, in the OFF format
CGAL::IO::write_OFF("output.off", points, triangles);
CGAL::IO::write_OFF("marching_cubes_implicit_sphere.off", points, triangles);
return EXIT_SUCCESS;
}

View File

@ -15,9 +15,9 @@ using Grid = CGAL::Isosurfacing::Cartesian_grid_3<Kernel>;
using Point_range = std::vector<Point>;
using Polygon_range = std::vector<std::vector<std::size_t> >;
int main(int, char**)
int main(int argc, char* argv[])
{
const std::string fname = "../examples/Isosurfacing_3/FullHead.inr";//CGAL::data_file_path("images/skull_2.9.inr");
const std::string fname = (argc > 1) ? argv[1] : CGAL::data_file_path("images/skull_2.9.inr");
// load volumetric image from a file
CGAL::Image_3 image;
@ -46,7 +46,7 @@ int main(int, char**)
CGAL::Isosurfacing::marching_cubes(domain, 1120 /*isovalue*/, points, polygons);
// save output indexed mesh to a file, in the OFF format
CGAL::IO::write_OFF("result.off", points, polygons);
CGAL::IO::write_OFF("marching_cubes_inrimage.off", points, polygons);
return EXIT_SUCCESS;
}

View File

@ -41,9 +41,9 @@ inline Kernel::FT distance_to_mesh(const Tree& tree,
}
// Usage : marching_cubes_multiple_mesh_offsets input.off
int main(int argc, char **argv)
int main(int argc, char *argv[])
{
const std::string input_name(argv[1]);
const std::string input_name = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/cross.off");
std::cout << "Input file: " << input_name << std::endl;
@ -93,26 +93,26 @@ int main(int argc, char **argv)
// create domain from the grid
auto domain = CGAL::Isosurfacing::create_explicit_Cartesian_grid_domain(grid);
// run Marching cubes with a range of offsets,
// run Marching cubes with a range of offsets,
// and save all output meshes to files "output-index.off"
int index = 0;
for(FT offset = 0.0; offset < 0.3; offset += 0.01, index++)
{
// containers for the triangle soup output
Point_range points;
Polygon_range triangles;
// containers for the triangle soup output
Point_range points;
Polygon_range triangles;
// execute marching cubes with an isovalue equating offset
// execute marching cubes with an isovalue equating offset
std::cout << "Marching cubes with offset " << offset << "...";
CGAL::Isosurfacing::marching_cubes(domain, offset, points, triangles);
std::cout << "done" << std::endl;
// save the output
// save the output
std::string filename("output-");
filename.append(std::to_string(index));
filename.append(std::string(".off"));
std::cout << "Save to file " << filename << "...";
CGAL::IO::write_polygon_soup(filename, points, triangles);
CGAL::IO::write_polygon_soup(filename, points, triangles);
std::cout << "done" << std::endl;
}

View File

@ -43,7 +43,7 @@ int main(int, char**)
CGAL::Isosurfacing::marching_cubes<CGAL::Sequential_tag>(domain, isovalue, points, triangles);
timer.stop();
std::cout << "done (" << timer.time() << "s, " << triangles.size() << " triangles)" << std::endl;
CGAL::IO::write_OFF("output-seq.off", points, triangles);
CGAL::IO::write_OFF("output-sequential.off", points, triangles);
// clear points and triangles
points.clear();

View File

@ -40,9 +40,9 @@ inline Kernel::FT distance_to_mesh(const Tree& tree,
return sqrt((p - x).squared_length());
}
int main(int, char**)
int main(int argc, char* argv[])
{
const std::string input_name = CGAL::data_file_path("meshes/cross.off");
const std::string input_name = (argc > 1) ? argv[1] :CGAL::data_file_path("meshes/cross.off");
const int n_voxels = 20;
const FT offset_value = 0.2;
@ -99,7 +99,7 @@ int main(int, char**)
CGAL::Isosurfacing::marching_cubes(domain, offset_value, points, polygons);
// save the output
CGAL::IO::write_polygon_soup("output.off", points, polygons);
CGAL::IO::write_polygon_soup("marching_cubes_signed_mesh_offset.off", points, polygons);
return EXIT_SUCCESS;
}