summaryrefslogtreecommitdiff
path: root/src/Alpha_complex/include
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-06-18 21:50:42 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-06-18 21:50:42 +0000
commit5a2b1b9c0c79ef2b0595cf1f9428596261824b45 (patch)
treec5f1d83b47a828eeb87238603a104ff7f1f34341 /src/Alpha_complex/include
parent3ad2102607abfcd9beb6d1c9da05c14452747652 (diff)
Add periodic 3d Alpha shapes
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alpha_complex_3d_module_vincent@3622 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: a97b603cf83c5f9a80404dd5786896e51015ee08
Diffstat (limited to 'src/Alpha_complex/include')
-rw-r--r--src/Alpha_complex/include/gudhi/Alpha_complex_3d.h56
-rw-r--r--src/Alpha_complex/include/gudhi/Alpha_complex_3d_options.h32
2 files changed, 80 insertions, 8 deletions
diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h b/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h
index b04aa6d7..21707e5e 100644
--- a/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h
+++ b/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h
@@ -43,10 +43,9 @@ private:
// filtration with alpha values needed type definition
using Alpha_value_type = typename Alpha_shape_3::FT;
using Object = CGAL::Object;
- using Dispatch =
- CGAL::Dispatch_output_iterator<CGAL::cpp11::tuple<Object, Alpha_value_type>,
- CGAL::cpp11::tuple<std::back_insert_iterator<std::vector<Object> >,
- std::back_insert_iterator<std::vector<Alpha_value_type> > > >;
+ using Dispatch = CGAL::Dispatch_output_iterator<CGAL::cpp11::tuple<Object, Alpha_value_type>,
+ CGAL::cpp11::tuple<std::back_insert_iterator<std::vector<Object> >,
+ std::back_insert_iterator<std::vector<Alpha_value_type> > > >;
using Cell_handle = typename Alpha_shape_3::Cell_handle;
using Facet = typename Alpha_shape_3::Facet;
using Edge_3 = typename Alpha_shape_3::Edge;
@@ -118,6 +117,55 @@ public:
#endif // DEBUG_TRACES
}
+ /** \brief Alpha_complex constructor from a list of points.
+*
+* Duplicate points are inserted once in the Alpha_complex. This is the reason why the vertices may be not contiguous.
+*
+* @param[in] points Range of points to triangulate. Points must be in Kernel::Point_d
+*
+* The type InputPointRange must be a range for which std::begin and
+* std::end return input iterators on a Kernel::Point_d.
+*/
+ template<typename InputPointRange>
+ Alpha_complex_3d(const InputPointRange& points,
+ Alpha_value_type x_min, Alpha_value_type y_min, Alpha_value_type z_min,
+ Alpha_value_type x_max, Alpha_value_type y_max, Alpha_value_type z_max) {
+ static_assert(!AlphaComplex3dOptions::weighted,
+ "This constructor is not available for weighted versions of Alpha_complex_3d");
+ static_assert(AlphaComplex3dOptions::periodic,
+ "This constructor is not available for non-periodic versions of Alpha_complex_3d");
+ // Checking if the cuboid is the same in x,y and z direction. If not, CGAL will not process it.
+ GUDHI_CHECK((x_max - x_min != y_max - y_min) || (x_max - x_min != z_max - z_min) || (z_max - z_min != y_max - y_min),
+ std::invalid_argument("The size of the cuboid in every directions is not the same."));
+
+ using Periodic_delaunay_triangulation_3 = typename AlphaComplex3dOptions::Periodic_delaunay_triangulation_3;
+ using Iso_cuboid_3 = typename AlphaComplex3dOptions::Iso_cuboid_3;
+ // Define the periodic cube
+ Periodic_delaunay_triangulation_3 pdt(Iso_cuboid_3(x_min, y_min, z_min, x_max, y_max, z_max));
+ // Heuristic for inserting large point sets (if pts is reasonably large)
+ pdt.insert(std::begin(points), std::end(points), true);
+ // As pdt won't be modified anymore switch to 1-sheeted cover if possible
+ GUDHI_CHECK(pdt.is_triangulation_in_1_sheet(),
+ std::invalid_argument("Uable to construct a triangulation within a single periodic domain."));
+
+ // alpha shape construction from points. CGAL has a strange behavior in REGULARIZED mode. This is the default mode
+ // Maybe need to set it to GENERAL mode
+ Alpha_shape_3 as(pdt, 0, Alpha_shape_3::GENERAL);
+
+ // filtration with alpha values from alpha shape
+ std::vector<Object> the_objects;
+ std::vector<Alpha_value_type> the_alpha_values;
+
+ Dispatch disp = CGAL::dispatch_output<Object, Alpha_value_type>(std::back_inserter(the_objects),
+ std::back_inserter(the_alpha_values));
+
+ as.filtration_with_alpha_values(disp);
+#ifdef DEBUG_TRACES
+ std::cout << "filtration_with_alpha_values returns : " << the_objects.size() << " objects" << std::endl;
+#endif // DEBUG_TRACES
+
+ }
+
private:
std::vector<Object> the_objects;
std::vector<Alpha_value_type> the_alpha_values;
diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex_3d_options.h b/src/Alpha_complex/include/gudhi/Alpha_complex_3d_options.h
index 3b753ee2..e05e5a7f 100644
--- a/src/Alpha_complex/include/gudhi/Alpha_complex_3d_options.h
+++ b/src/Alpha_complex/include/gudhi/Alpha_complex_3d_options.h
@@ -26,6 +26,8 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_3.h>
+#include <CGAL/Periodic_3_Delaunay_triangulation_traits_3.h>
+#include <CGAL/Periodic_3_Delaunay_triangulation_3.h>
#include <CGAL/Regular_triangulation_3.h>
#include <CGAL/Alpha_shape_3.h>
#include <CGAL/Alpha_shape_cell_base_3.h>
@@ -49,7 +51,6 @@ public:
using Alpha_shape_3 = CGAL::Alpha_shape_3<Triangulation_3>;
using Point_3 = Kernel::Point_3;
- static const bool exact = false;
static const bool weighted = false;
static const bool periodic = false;
@@ -69,7 +70,6 @@ public:
using Alpha_shape_3 = CGAL::Alpha_shape_3<Triangulation_3, Exact_tag>;
using Point_3 = Kernel::Point_3;
- static const bool exact = true;
static const bool weighted = false;
static const bool periodic = false;
};
@@ -90,13 +90,37 @@ public:
using Point_3 = Triangulation_3::Bare_point;
using Weighted_point_3 = Triangulation_3::Weighted_point;
- static const bool exact = false;
static const bool weighted = true;
static const bool periodic = false;
};
+class Periodic_alpha_shapes_3d {
+private:
+ using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
+ using Periodic_kernel = CGAL::Periodic_3_Delaunay_triangulation_traits_3<Kernel>;
+// Vertex type
+ using DsVb = CGAL::Periodic_3_triangulation_ds_vertex_base_3<>;
+ using Vb = CGAL::Triangulation_vertex_base_3<Periodic_kernel, DsVb>;
+ using AsVb = CGAL::Alpha_shape_vertex_base_3<Periodic_kernel, Vb>;
+// Cell type
+ using DsCb = CGAL::Periodic_3_triangulation_ds_cell_base_3<>;
+ using Cb = CGAL::Triangulation_cell_base_3<Periodic_kernel, DsCb>;
+ using AsCb = CGAL::Alpha_shape_cell_base_3<Periodic_kernel, Cb>;
+ using Tds = CGAL::Triangulation_data_structure_3<AsVb, AsCb>;
+
+public:
+ using Periodic_delaunay_triangulation_3 = CGAL::Periodic_3_Delaunay_triangulation_3<Periodic_kernel, Tds>;
+ using Alpha_shape_3 = CGAL::Alpha_shape_3<Periodic_delaunay_triangulation_3>;
+ using Point_3 = Periodic_kernel::Point_3;
+ using Alpha_value_type = Alpha_shape_3::FT;
+ using Iso_cuboid_3 = Periodic_kernel::Iso_cuboid_3;
+
+ static const bool weighted = false;
+ static const bool periodic = true;
+};
+
} // namespace alpha_complex
} // namespace Gudhi
-#endif // ALPHA_COMPLEX_3D_H_
+#endif // ALPHA_COMPLEX_3D_OPTIONS_H_