diff --git a/.gitattributes b/.gitattributes index efbfac79743..217d433b25c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -104,7 +104,6 @@ Alpha_shapes_3/doc_tex/Alpha_shapes_3/alpha_shapes_3_large.png -text Alpha_shapes_3/doc_tex/Alpha_shapes_3/alpha_shapes_3_small.png -text Alpha_shapes_3/doc_tex/Alpha_shapes_3/alphashape.gif -text svneol=unset#image/gif Alpha_shapes_3/doc_tex/Alpha_shapes_3/alphashape.pdf -text svneol=unset#application/pdf -Alpha_shapes_3/examples/Alpha_shapes_3/ex_periodic_alpha_shapes_3 -text Apollonius_graph_2/doc_tex/Apollonius_graph_2/apollonius-both_vertices.gif -text svneol=unset#image/gif Apollonius_graph_2/doc_tex/Apollonius_graph_2/apollonius-both_vertices_bw.png -text svneol=unset#image/png Apollonius_graph_2/doc_tex/Apollonius_graph_2/apollonius-entire_edge.gif -text svneol=unset#image/gif diff --git a/Alpha_shapes_3/examples/Alpha_shapes_3/ex_periodic_alpha_shapes_3 b/Alpha_shapes_3/examples/Alpha_shapes_3/ex_periodic_alpha_shapes_3 deleted file mode 100755 index 0e0049fc573..00000000000 Binary files a/Alpha_shapes_3/examples/Alpha_shapes_3/ex_periodic_alpha_shapes_3 and /dev/null differ diff --git a/Alpha_shapes_3/examples/Alpha_shapes_3/ex_periodic_alpha_shapes_3.cpp b/Alpha_shapes_3/examples/Alpha_shapes_3/ex_periodic_alpha_shapes_3.cpp new file mode 100644 index 00000000000..99f1dbe5b6e --- /dev/null +++ b/Alpha_shapes_3/examples/Alpha_shapes_3/ex_periodic_alpha_shapes_3.cpp @@ -0,0 +1,64 @@ +#include +#include +#include +#include + +#include +#include + +// Traits +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef CGAL::Periodic_3_triangulation_traits_3 PK; + +// Vertex type +typedef CGAL::Periodic_3_triangulation_ds_vertex_base_3<> DsVb; +typedef CGAL::Triangulation_vertex_base_3 Vb; +typedef CGAL::Alpha_shape_vertex_base_3 AsVb; +// Cell type +typedef CGAL::Periodic_3_triangulation_ds_cell_base_3<> DsCb; +typedef CGAL::Triangulation_cell_base_3 Cb; +typedef CGAL::Alpha_shape_cell_base_3 AsCb; + +typedef CGAL::Triangulation_data_structure_3 Tds; +typedef CGAL::Periodic_3_Delaunay_triangulation_3 P3DT3; +typedef CGAL::Alpha_shape_3 Alpha_shape_3; + +typedef PK::Point_3 Point; + +int main() +{ + typedef CGAL::Creator_uniform_3 Creator; + CGAL::Random random(7); + CGAL::Random_points_in_cube_3 in_cube(1, random); + std::vector pts; + + // Generating 1000 random points + for (int i=0 ; i < 1000 ; i++) { + Point p = *in_cube++; + pts.push_back(p); + } + + // Define the periodic cube + P3DT3 pdt(PK::Iso_cuboid_3(-1,-1,-1,1,1,1)); + // Heuristic for inserting large point sets (if pts is reasonably large) + pdt.insert(pts.begin(), pts.end(), true); + // As pdt won't be modified anymore switch to 1-sheeted cover if possible + if (pdt.is_triangulation_in_1_sheet()) pdt.convert_to_1_sheeted_covering(); + std::cout << "Periodic Delaunay computed." << std::endl; + + // compute alpha shape + Alpha_shape_3 as(pdt); + std::cout << "Alpha shape computed in REGULARIZED mode by default." + << std::endl; + + // find optimal alpha values + Alpha_shape_3::NT alpha_solid = as.find_alpha_solid(); + Alpha_shape_3::Alpha_iterator opt = as.find_optimal_alpha(1); + std::cout << "Smallest alpha value to get a solid through data points is " + << alpha_solid << std::endl; + std::cout << "Optimal alpha value to get one connected component is " + << *opt << std::endl; + as.set_alpha(*opt); + assert(as.number_of_solid_components() == 1); + return 0; +}