-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Square root filtration values for alpha and delaunay-cech complex #1138
Open
VincentRouvreau
wants to merge
7
commits into
GUDHI:master
Choose a base branch
from
VincentRouvreau:alpha_complex_square_root_filtrations_option
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
986ad6f
c++ part of square root filtration values for alpha and delaunay-cech…
VincentRouvreau 6be76bc
square_root_filtrations was missing in documentation for Alpha complex
VincentRouvreau 7b14133
Add new feature in changes
VincentRouvreau 2cdc152
Python version of square root filtrations for alpha complex and delau…
VincentRouvreau 9d1f74a
Merge branch 'master' into alpha_complex_square_root_filtrations_option
VincentRouvreau c578b93
python hints not well managed on cython class
VincentRouvreau 46f5616
Add some python test for square_root_filtrations versions
VincentRouvreau File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
* | ||
* Modification(s): | ||
* - 2019/08 Vincent Rouvreau: Fix issue #10 for CGAL and Eigen3 | ||
* - 2024/10 Vincent Rouvreau: Add square root filtration values interface | ||
* - YYYY/MM Author: Description of the modification | ||
*/ | ||
|
||
|
@@ -65,14 +66,14 @@ template<typename D> struct Is_Epeck_D<CGAL::Epeck_d<D>> { static const bool val | |
/** | ||
* \class Alpha_complex Alpha_complex.h gudhi/Alpha_complex.h | ||
* \brief Alpha complex data structure. | ||
* | ||
* | ||
* \ingroup alpha_complex | ||
* | ||
* | ||
* \details | ||
* The data structure is constructing a CGAL Delaunay triangulation (for more information on CGAL Delaunay | ||
* The data structure is constructing a CGAL Delaunay triangulation (for more information on CGAL Delaunay | ||
* triangulation, please refer to the corresponding chapter in page http://doc.cgal.org/latest/Triangulation/) from a | ||
* range of points or from an OFF file (cf. Points_off_reader). | ||
* | ||
* | ||
* Please refer to \ref alpha_complex for examples. | ||
* | ||
* The complex is a template class requiring an <a target="_blank" | ||
|
@@ -84,7 +85,7 @@ template<typename D> struct Is_Epeck_D<CGAL::Epeck_d<D>> { static const bool val | |
* href="https://doc.cgal.org/latest/Kernel_d/structCGAL_1_1Epeck__d.html">CGAL::Epeck_d</a> | ||
* < <a target="_blank" href="http://doc.cgal.org/latest/Kernel_23/classCGAL_1_1Dynamic__dimension__tag.html"> | ||
* CGAL::Dynamic_dimension_tag </a> > | ||
* | ||
* | ||
* \remark | ||
* - When Alpha_complex is constructed with an infinite value of alpha, the complex is a Delaunay complex. | ||
* - Using the default `CGAL::Epeck_d` makes the construction safe. If you pass exact=true to create_complex, the | ||
|
@@ -161,10 +162,10 @@ class Alpha_complex { | |
|
||
public: | ||
/** \brief Alpha_complex constructor from an OFF file name. | ||
* | ||
* Uses the Points_off_reader to construct the Delaunay triangulation required to initialize | ||
* | ||
* Uses the Points_off_reader to construct the Delaunay triangulation required to initialize | ||
* the Alpha_complex. | ||
* | ||
* | ||
* Duplicate points are inserted once in the Alpha_complex. This is the reason why the vertices may be not contiguous. | ||
* | ||
* @param[in] off_file_name OFF file [path and] name. | ||
|
@@ -183,9 +184,9 @@ class Alpha_complex { | |
* | ||
* The vertices may be not contiguous as some points may be discarded in the triangulation (duplicate points, | ||
* weighted hidden point, ...). | ||
* | ||
* | ||
* @param[in] points Range of points to triangulate. Points must be in Kernel::Point_d or Kernel::Weighted_point_d. | ||
* | ||
* | ||
* The type InputPointRange must be a range for which std::begin and std::end return input iterators on a | ||
* Kernel::Point_d or Kernel::Weighted_point_d. | ||
*/ | ||
|
@@ -198,11 +199,11 @@ class Alpha_complex { | |
* | ||
* The vertices may be not contiguous as some points may be discarded in the triangulation (duplicate points, | ||
* weighted hidden point, ...). | ||
* | ||
* | ||
* @param[in] points Range of points to triangulate. Points must be in Kernel::Point_d. | ||
* | ||
* | ||
* @param[in] weights Range of points weights. Weights must be in Kernel::FT. | ||
* | ||
* | ||
* The type InputPointRange must be a range for which std::begin and std::end return input iterators on a | ||
* Kernel::Point_d. | ||
*/ | ||
|
@@ -354,8 +355,10 @@ class Alpha_complex { | |
* It also computes the filtration values accordingly to the \ref createcomplexalgorithm if default_filtration_value | ||
* is not set. | ||
* | ||
* \tparam square_root_filtrations If false (default value), it assigns to each simplex a filtration value equal to | ||
* the squared cicumradius of the simplices, or to the radius when square_root_filtrations is true. | ||
* \tparam SimplicialComplexForAlpha must meet `SimplicialComplexForAlpha` concept. | ||
* | ||
* | ||
* @param[in] complex SimplicialComplexForAlpha to be created. | ||
* @param[in] max_alpha_square maximum for alpha square value. Default value is +\f$\infty\f$, and there is very | ||
* little point using anything else since it does not save time. Useless if `default_filtration_value` is set to | ||
|
@@ -367,13 +370,14 @@ class Alpha_complex { | |
* Default value is `false` (which means compute the filtration values). | ||
* | ||
* @return true if creation succeeds, false otherwise. | ||
* | ||
* | ||
* @pre Delaunay triangulation must be already constructed with dimension strictly greater than 0. | ||
* @pre The simplicial complex must be empty (no vertices) | ||
* | ||
* | ||
* Initialization can be launched once. | ||
*/ | ||
template <typename SimplicialComplexForAlpha, | ||
template <bool square_root_filtrations = false, | ||
typename SimplicialComplexForAlpha, | ||
typename Filtration_value = typename SimplicialComplexForAlpha::Filtration_value> | ||
bool create_complex(SimplicialComplexForAlpha& complex, | ||
Filtration_value max_alpha_square = std::numeric_limits<Filtration_value>::infinity(), | ||
|
@@ -389,6 +393,9 @@ class Alpha_complex { | |
using Simplex_handle = typename SimplicialComplexForAlpha::Simplex_handle; | ||
using Vector_vertex = std::vector<Vertex_handle>; | ||
|
||
// For users to be able to define their own sqrt function on their desired Filtration_value type | ||
using std::sqrt; | ||
Comment on lines
+396
to
+397
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could also put it next to the single place where it is used, but it is ok here. |
||
|
||
if (triangulation_ == nullptr) { | ||
std::cerr << "Alpha_complex cannot create_complex from a NULL triangulation\n"; | ||
return false; // ----- >> | ||
|
@@ -438,7 +445,6 @@ class Alpha_complex { | |
} | ||
} | ||
// -------------------------------------------------------------------------------------------- | ||
|
||
if (!default_filtration_value) { | ||
CGAL::NT_converter<FT, Filtration_value> cgal_converter; | ||
// -------------------------------------------------------------------------------------------- | ||
|
@@ -458,6 +464,9 @@ class Alpha_complex { | |
if(exact) CGAL::exact(sqrad); | ||
#endif | ||
alpha_complex_filtration = cgal_converter(sqrad); | ||
if constexpr (square_root_filtrations) { | ||
alpha_complex_filtration = sqrt(alpha_complex_filtration); | ||
} | ||
} | ||
complex.assign_filtration(f_simplex, alpha_complex_filtration); | ||
#ifdef DEBUG_TRACES | ||
|
@@ -473,14 +482,18 @@ class Alpha_complex { | |
cache_.clear(); | ||
} | ||
// -------------------------------------------------------------------------------------------- | ||
|
||
// -------------------------------------------------------------------------------------------- | ||
if (!exact) | ||
// As Alpha value is an approximation, we have to make filtration non decreasing while increasing the dimension | ||
// Only in not exact version, cf. https://github.com/GUDHI/gudhi-devel/issues/57 | ||
complex.make_filtration_non_decreasing(); | ||
// Remove all simplices that have a filtration value greater than max_alpha_square | ||
complex.prune_above_filtration(max_alpha_square); | ||
if constexpr (square_root_filtrations) { | ||
complex.prune_above_filtration(sqrt(max_alpha_square)); | ||
} else { | ||
complex.prune_above_filtration(max_alpha_square); | ||
} | ||
// -------------------------------------------------------------------------------------------- | ||
} | ||
return true; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(ignore the exact names I use here)
I wonder what is more natural between do_sqrt=true/false and output_squared_values=true/false. As the person writing the code, it is natural to ask if you should call sqrt. As the user... I am not sure, it might be the other one.