Skip to content

Instantly share code, notes, and snippets.

@pentacular
Created December 22, 2023 14:16
Show Gist options
  • Save pentacular/2bc66d9c01439e70a32cc083a4ec61d5 to your computer and use it in GitHub Desktop.
Save pentacular/2bc66d9c01439e70a32cc083a4ec61d5 to your computer and use it in GitHub Desktop.
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Polygon_mesh_processing/refine.h>
#include <CGAL/Polygonal_surface_reconstruction.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/property_map.h>
int main() {
typedef CGAL::Exact_predicates_exact_constructions_kernel Epeck_kernel;
typedef Epeck_kernel::Point_3 Epeck_point;
typedef CGAL::Surface_mesh<Epeck_point> Epeck_surface_mesh;
std::string off = R"off(OFF
12 20 0
5.5 5 4
-5.5 5 4
-5.5 4 4
5.5 4 4
5.5 4 5
5.5 5 5
-5.5 5 5
-5.5 4 5
-3.66667 4 5
-5.5 4.83333 5
3.66667 5 5
5.5 4.16667 5
3 0 3 1
3 3 2 1
3 10 4 11
3 8 6 9
3 11 0 5
3 0 4 3
3 10 1 6
3 1 5 0
3 9 2 7
3 2 6 1
3 8 3 4
3 3 7 2
3 0 11 4
3 4 10 6
3 5 10 11
3 1 10 5
3 2 9 6
3 6 8 4
3 7 8 9
3 3 8 7
)off";
Epeck_surface_mesh mesh;
std::istringstream(off) >> mesh;
std::vector<Epeck_surface_mesh::Face_index> new_facets;
std::vector<Epeck_surface_mesh::Vertex_index> new_vertices;
CGAL::get_default_random() = CGAL::Random(0);
std::srand(0);
CGAL::Polygon_mesh_processing::refine(
mesh, mesh.faces(), std::back_inserter(new_facets),
std::back_inserter(new_vertices),
CGAL::parameters::vertex_point_map(
mesh.points()));
std::cout << "New face count: " << new_facets.size() << std::endl;
std::cout << "New vertex count: " << new_vertices.size() << std::endl;
std::cout << "Mesh=" << mesh;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment