summaryrefslogtreecommitdiff
path: root/src/Coxeter_triangulation
diff options
context:
space:
mode:
authorROUVREAU Vincent <vincent.rouvreau@inria.fr>2020-09-22 16:43:54 +0200
committerROUVREAU Vincent <vincent.rouvreau@inria.fr>2020-09-22 16:43:54 +0200
commite0041b766b647f3906b52f861e97edba1f089312 (patch)
tree693206fa60c757346750461922e107e5f16f5c0a /src/Coxeter_triangulation
parentcba4b7047cc8665a3f20e2334358a4ca28bf021a (diff)
include what you use
Diffstat (limited to 'src/Coxeter_triangulation')
-rw-r--r--src/Coxeter_triangulation/concept/IntersectionOracle.h10
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Cell_complex.h85
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Cell_complex/Hasse_diagram_cell.h17
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Coxeter_triangulation.h25
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Freudenthal_triangulation.h52
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Functions/Cartesian_product.h6
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Functions/Constant_function.h6
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Functions/Embed_in_Rd.h6
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Functions/Function_Sm_in_Rd.h5
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Functions/Function_affine_plane_in_Rd.h5
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Functions/Function_chair_in_R3.h4
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Functions/Function_iron_in_R3.h6
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Functions/Function_lemniscate_revolution_in_R3.h10
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Functions/Function_moment_curve_in_Rd.h5
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Functions/Function_torus_in_R3.h6
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Functions/Function_whitney_umbrella_in_R3.h5
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Functions/Linear_transformation.h5
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Functions/Negation.h7
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Functions/PL_approximation.h5
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Functions/Translate.h5
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Functions/random_orthogonal_matrix.h17
-rw-r--r--src/Coxeter_triangulation/include/gudhi/IO/Mesh_medit.h5
-rw-r--r--src/Coxeter_triangulation/include/gudhi/IO/build_mesh_from_cell_complex.h83
-rw-r--r--src/Coxeter_triangulation/include/gudhi/IO/output_meshes_to_medit.h9
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Implicit_manifold_intersection_oracle.h42
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Manifold_tracing.h160
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Permutahedral_representation.h41
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Combination_iterator.h2
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Integer_combination_iterator.h13
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Ordered_set_partition_iterator.h25
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Permutahedral_representation_iterators.h81
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Permutation_iterator.h22
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Set_partition_iterator.h29
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Size_range.h16
-rw-r--r--src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/face_from_indices.h8
35 files changed, 441 insertions, 387 deletions
diff --git a/src/Coxeter_triangulation/concept/IntersectionOracle.h b/src/Coxeter_triangulation/concept/IntersectionOracle.h
index 8c0dbf19..1427460b 100644
--- a/src/Coxeter_triangulation/concept/IntersectionOracle.h
+++ b/src/Coxeter_triangulation/concept/IntersectionOracle.h
@@ -48,9 +48,9 @@ struct IntersectionOracle {
* (the domain dimension of the function).
*/
template <class Simplex_handle,
- class Triangulation>
+ class Triangulation>
Query_result<Simplex_handle> intersects(const Simplex_handle& simplex,
- const Triangulation& triangulation) const;
+ const Triangulation& triangulation) const;
/** \brief Intersection query with the boundary of the manifold.
*
@@ -73,9 +73,9 @@ struct IntersectionOracle {
* (the domain dimension of the function).
*/
template <class Simplex_handle,
- class Triangulation>
+ class Triangulation>
Query_result<Simplex_handle> intersects_boundary(const Simplex_handle& simplex,
- const Triangulation& triangulation) const;
+ const Triangulation& triangulation) const;
/** \brief Returns true if the input point lies inside the piecewise-linear
* domain induced by the given ambient triangulation that defines the relative
@@ -89,7 +89,7 @@ struct IntersectionOracle {
*/
template <class Triangulation>
bool lies_in_domain(const Eigen::VectorXd& p,
- const Triangulation& triangulation) const {
+ const Triangulation& triangulation) const {
Eigen::VectorXd pl_p = make_pl_approximation(domain_fun_, triangulation)(p);
return pl_p(0) < 0;
}
diff --git a/src/Coxeter_triangulation/include/gudhi/Cell_complex.h b/src/Coxeter_triangulation/include/gudhi/Cell_complex.h
index 03d5b288..3bc60a50 100644
--- a/src/Coxeter_triangulation/include/gudhi/Cell_complex.h
+++ b/src/Coxeter_triangulation/include/gudhi/Cell_complex.h
@@ -13,10 +13,11 @@
#include <Eigen/Dense>
-#include <algorithm>
-#include <gudhi/Permutahedral_representation/Simplex_comparator.h>
-#include <fstream> // for Hasse_diagram_persistence.h
+#include <vector>
+#include <map>
+#include <utility> // for std::make_pair
+#include <gudhi/Permutahedral_representation/Simplex_comparator.h>
#include <gudhi/Cell_complex/Hasse_diagram_cell.h> // for Hasse_cell
namespace Gudhi {
@@ -43,40 +44,36 @@ public:
/** \brief Type of a simplex in the ambient triangulation.
* Is a model of the concept SimplexInCoxeterTriangulation.
*/
- typedef typename Out_simplex_map_::key_type Simplex_handle;
+ using Simplex_handle = typename Out_simplex_map_::key_type;
/** \brief Type of a cell in the cell complex.
* Always is Gudhi::Hasse_cell from the Hasse diagram module.
* The additional information is the boolean that is true if and only if the cell lies
* on the boundary.
*/
- typedef Gudhi::Hasse_diagram::Hasse_diagram_cell<int, double, bool> Hasse_cell;
+ using Hasse_cell = Gudhi::Hasse_diagram::Hasse_diagram_cell<int, double, bool>;
/** \brief Type of a map from permutahedral representations of simplices in the
* ambient triangulation to the corresponding cells in the cell complex of some
* specific dimension.
*/
- typedef std::map<Simplex_handle,
- Hasse_cell*,
- Simplex_comparator<Simplex_handle> > Simplex_cell_map;
+ using Simplex_cell_map = std::map<Simplex_handle, Hasse_cell*, Simplex_comparator<Simplex_handle> >;
/** \brief Type of a vector of maps from permutahedral representations of simplices in the
* ambient triangulation to the corresponding cells in the cell complex of various dimensions.
*/
- typedef std::vector<Simplex_cell_map> Simplex_cell_maps;
+ using Simplex_cell_maps = std::vector<Simplex_cell_map>;
/** \brief Type of a map from cells in the cell complex to the permutahedral representations
* of the corresponding simplices in the ambient triangulation.
*/
- typedef std::map<Hasse_cell*, Simplex_handle> Cell_simplex_map;
+ using Cell_simplex_map = std::map<Hasse_cell*, Simplex_handle>;
/** \brief Type of a map from vertex cells in the cell complex to the permutahedral representations
* of their Cartesian coordinates.
*/
- typedef std::map<Hasse_cell*, Eigen::VectorXd> Cell_point_map;
+ using Cell_point_map = std::map<Hasse_cell*, Eigen::VectorXd>;
private:
- Hasse_cell* insert_cell(const Simplex_handle& simplex,
- std::size_t cell_d,
- bool is_boundary) {
+ Hasse_cell* insert_cell(const Simplex_handle& simplex, std::size_t cell_d, bool is_boundary) {
Simplex_cell_maps& simplex_cell_maps
= (is_boundary? boundary_simplex_cell_maps_ : interior_simplex_cell_maps_);
#ifdef GUDHI_COX_OUTPUT_TO_HTML
@@ -110,27 +107,27 @@ private:
const Simplex_handle& simplex = sc_pair.first;
Hasse_cell* cell = sc_pair.second;
for (Simplex_handle coface: simplex.coface_range(cod_d_ + cell_d)) {
- Hasse_cell* new_cell = insert_cell(coface, cell_d, false);
- new_cell->get_boundary().emplace_back(std::make_pair(cell, 1));
+ Hasse_cell* new_cell = insert_cell(coface, cell_d, false);
+ new_cell->get_boundary().emplace_back(std::make_pair(cell, 1));
}
}
if (is_manifold_with_boundary) {
for (auto& sc_pair: boundary_simplex_cell_maps_[cell_d - 1]) {
- const Simplex_handle& simplex = sc_pair.first;
- Hasse_cell* cell = sc_pair.second;
- if (cell_d != intr_d_)
- for (Simplex_handle coface: simplex.coface_range(cod_d_ + cell_d + 1)) {
- Hasse_cell* new_cell = insert_cell(coface, cell_d, true);
- new_cell->get_boundary().emplace_back(std::make_pair(cell, 1));
- }
- auto map_it = interior_simplex_cell_maps_[cell_d].find(simplex);
- if (map_it == interior_simplex_cell_maps_[cell_d].end())
- std::cerr << "Cell_complex::expand_level error: A boundary cell does not have an interior counterpart.\n";
- else {
- Hasse_cell* i_cell = map_it->second;
- i_cell->get_boundary().emplace_back(std::make_pair(cell, 1));
- }
+ const Simplex_handle& simplex = sc_pair.first;
+ Hasse_cell* cell = sc_pair.second;
+ if (cell_d != intr_d_)
+ for (Simplex_handle coface: simplex.coface_range(cod_d_ + cell_d + 1)) {
+ Hasse_cell* new_cell = insert_cell(coface, cell_d, true);
+ new_cell->get_boundary().emplace_back(std::make_pair(cell, 1));
+ }
+ auto map_it = interior_simplex_cell_maps_[cell_d].find(simplex);
+ if (map_it == interior_simplex_cell_maps_[cell_d].end())
+ std::cerr << "Cell_complex::expand_level error: A boundary cell does not have an interior counterpart.\n";
+ else {
+ Hasse_cell* i_cell = map_it->second;
+ i_cell->get_boundary().emplace_back(std::make_pair(cell, 1));
+ }
}
}
}
@@ -148,15 +145,15 @@ private:
cell_point_map_.emplace(std::make_pair(new_cell, point));
}
for (std::size_t cell_d = 1;
- cell_d < interior_simplex_cell_maps_.size() &&
- !interior_simplex_cell_maps_[cell_d - 1].empty();
- ++cell_d) {
+ cell_d < interior_simplex_cell_maps_.size() &&
+ !interior_simplex_cell_maps_[cell_d - 1].empty();
+ ++cell_d) {
expand_level(cell_d);
}
}
void construct_complex_(const Out_simplex_map_& interior_simplex_map,
- const Out_simplex_map_& boundary_simplex_map) {
+ const Out_simplex_map_& boundary_simplex_map) {
#ifdef GUDHI_COX_OUTPUT_TO_HTML
cc_interior_summary_lists.resize(interior_simplex_cell_maps_.size());
cc_interior_prejoin_lists.resize(interior_simplex_cell_maps_.size());
@@ -185,17 +182,17 @@ private:
#endif
for (std::size_t cell_d = 1;
- cell_d < interior_simplex_cell_maps_.size() &&
- !interior_simplex_cell_maps_[cell_d - 1].empty();
- ++cell_d) {
+ cell_d < interior_simplex_cell_maps_.size() &&
+ !interior_simplex_cell_maps_[cell_d - 1].empty();
+ ++cell_d) {
expand_level(cell_d);
#ifdef GUDHI_COX_OUTPUT_TO_HTML
for (const auto& sc_pair: interior_simplex_cell_maps_[cell_d])
- cc_interior_summary_lists[cell_d].push_back(CC_summary_info(sc_pair));
+ cc_interior_summary_lists[cell_d].push_back(CC_summary_info(sc_pair));
if (cell_d < boundary_simplex_cell_maps_.size())
- for (const auto& sc_pair: boundary_simplex_cell_maps_[cell_d])
- cc_boundary_summary_lists[cell_d].push_back(CC_summary_info(sc_pair));
+ for (const auto& sc_pair: boundary_simplex_cell_maps_[cell_d])
+ cc_boundary_summary_lists[cell_d].push_back(CC_summary_info(sc_pair));
#endif
}
}
@@ -230,7 +227,7 @@ public:
* \param[in] limit_dimension The dimension of the constructed skeleton.
*/
void construct_complex(const Out_simplex_map_& out_simplex_map,
- std::size_t limit_dimension) {
+ std::size_t limit_dimension) {
interior_simplex_cell_maps_.resize(limit_dimension + 1);
if (!out_simplex_map.empty())
cod_d_ = out_simplex_map.begin()->first.dimension();
@@ -250,7 +247,7 @@ public:
* to the intersection points.
*/
void construct_complex(const Out_simplex_map_& interior_simplex_map,
- const Out_simplex_map_& boundary_simplex_map) {
+ const Out_simplex_map_& boundary_simplex_map) {
interior_simplex_cell_maps_.resize(intr_d_ + 1);
boundary_simplex_cell_maps_.resize(intr_d_);
if (!interior_simplex_map.empty())
@@ -273,8 +270,8 @@ public:
* \param[in] limit_dimension The dimension of the constructed skeleton.
*/
void construct_complex(const Out_simplex_map_& interior_simplex_map,
- const Out_simplex_map_& boundary_simplex_map,
- std::size_t limit_dimension) {
+ const Out_simplex_map_& boundary_simplex_map,
+ std::size_t limit_dimension) {
interior_simplex_cell_maps_.resize(limit_dimension + 1);
boundary_simplex_cell_maps_.resize(limit_dimension);
if (!interior_simplex_map.empty())
diff --git a/src/Coxeter_triangulation/include/gudhi/Cell_complex/Hasse_diagram_cell.h b/src/Coxeter_triangulation/include/gudhi/Cell_complex/Hasse_diagram_cell.h
index e751f002..a59026fa 100644
--- a/src/Coxeter_triangulation/include/gudhi/Cell_complex/Hasse_diagram_cell.h
+++ b/src/Coxeter_triangulation/include/gudhi/Cell_complex/Hasse_diagram_cell.h
@@ -8,21 +8,14 @@
* - YYYY/MM Author: Description of the modification
*/
-#include <iostream>
-#include <vector>
-#include <algorithm>
-#include <string>
-#include <sstream>
-#include <type_traits>
-#include <cstdlib>
-#include <cstdio>
-
-
-
-
#ifndef HASSE_DIAGRAM_CELL_H
#define HASSE_DIAGRAM_CELL_H
+#include <vector>
+#include <utility> // for std::pair
+#include <ostream>
+#include <string>
+#include <type_traits> // for std::is_same
namespace Gudhi {
namespace Hasse_diagram {
diff --git a/src/Coxeter_triangulation/include/gudhi/Coxeter_triangulation.h b/src/Coxeter_triangulation/include/gudhi/Coxeter_triangulation.h
index 1110c850..19ceb007 100644
--- a/src/Coxeter_triangulation/include/gudhi/Coxeter_triangulation.h
+++ b/src/Coxeter_triangulation/include/gudhi/Coxeter_triangulation.h
@@ -11,9 +11,8 @@
#ifndef COXETER_TRIANGULATION_H_
#define COXETER_TRIANGULATION_H_
-#include <stack>
-#include <map>
-#include <numeric> //iota
+#include <vector>
+#include <cmath> // for std::sqrt
#include <boost/range/iterator_range.hpp>
#include <boost/graph/graph_traits.hpp>
@@ -42,10 +41,9 @@ namespace coxeter_triangulation {
* Needs to be a model of SimplexInCoxeterTriangulation.
*/
template <class Permutahedral_representation_
- = Permutahedral_representation<std::vector<int>, std::vector<std::vector<std::size_t> > > >
+ = Permutahedral_representation<std::vector<int>, std::vector<std::vector<std::size_t> > > >
class Coxeter_triangulation : public Freudenthal_triangulation<Permutahedral_representation_> {
-
- typedef Eigen::MatrixXd Matrix;
+ using Matrix = Eigen::MatrixXd;
Matrix root_matrix(unsigned d) {
Matrix cartan(d,d);
@@ -58,8 +56,8 @@ class Coxeter_triangulation : public Freudenthal_triangulation<Permutahedral_rep
}
for (unsigned i = 0; i < d; i++)
for (unsigned j = 0; j < d; j++)
- if (j+1 < i || j > i+1)
- cartan(i,j) = 0;
+ if (j+1 < i || j > i+1)
+ cartan(i,j) = 0;
Eigen::SelfAdjointEigenSolver<Matrix> saes(cartan);
Eigen::VectorXd sqrt_diag(d);
for (unsigned i = 0; i < d; ++i)
@@ -68,16 +66,15 @@ class Coxeter_triangulation : public Freudenthal_triangulation<Permutahedral_rep
Matrix lower(d,d);
for (unsigned i = 0; i < d; i++)
for (unsigned j = 0; j < d; j++)
- if (i < j)
- lower(i,j) = 0;
- else
- lower(i,j) = 1;
+ if (i < j)
+ lower(i,j) = 0;
+ else
+ lower(i,j) = 1;
Matrix result = (lower * saes.eigenvectors()*sqrt_diag.asDiagonal()).inverse();
return result;
}
-
-public:
+ public:
/** \brief Constructor of Coxeter triangulation of a given dimension.
* @param[in] dimension The dimension of the triangulation.
*/
diff --git a/src/Coxeter_triangulation/include/gudhi/Freudenthal_triangulation.h b/src/Coxeter_triangulation/include/gudhi/Freudenthal_triangulation.h
index 99fe81d2..6b33a00c 100644
--- a/src/Coxeter_triangulation/include/gudhi/Freudenthal_triangulation.h
+++ b/src/Coxeter_triangulation/include/gudhi/Freudenthal_triangulation.h
@@ -11,9 +11,11 @@
#ifndef FREUDENTHAL_TRIANGULATION_H_
#define FREUDENTHAL_TRIANGULATION_H_
-#include <stack>
-#include <map>
-#include <numeric> //iota
+#include <vector>
+#include <algorithm> // for std::sort
+#include <cmath> // for std::floor
+#include <numeric> // for std::iota
+#include <cstdlib> // for std::size_t
#include <Eigen/Eigenvalues>
#include <Eigen/Sparse>
@@ -40,21 +42,19 @@ namespace coxeter_triangulation {
* Needs to be a model of SimplexInCoxeterTriangulation.
*/
template <class Permutahedral_representation_
- = Permutahedral_representation<std::vector<int>, std::vector<std::vector<std::size_t> > > >
+ = Permutahedral_representation<std::vector<int>, std::vector<std::vector<std::size_t> > > >
class Freudenthal_triangulation {
-
- typedef Eigen::MatrixXd Matrix;
- typedef Eigen::VectorXd Vector;
- typedef Eigen::SparseMatrix<double> SparseMatrix;
- typedef Eigen::Triplet<double> Triplet;
+ using Matrix = Eigen::MatrixXd;
+ using Vector = Eigen::VectorXd;
+ using SparseMatrix = Eigen::SparseMatrix<double>;
+ using Triplet = Eigen::Triplet<double>;
-public:
-
+ public:
/** \brief Type of the simplices in the triangulation. */
- typedef Permutahedral_representation_ Simplex_handle;
+ using Simplex_handle = Permutahedral_representation_;
/** \brief Type of the vertices in the triangulation. */
- typedef typename Permutahedral_representation_::Vertex Vertex_handle;
+ using Vertex_handle = typename Permutahedral_representation_::Vertex;
/** \brief Constructor of the Freudenthal-Kuhn triangulation of a given dimension.
@@ -155,37 +155,37 @@ public:
std::vector<double> z;
if (is_freudenthal) {
for (std::size_t i = 0; i < d; i++) {
- double x_i = scale * point[i];
- int y_i = std::floor(x_i);
- output.vertex().push_back(y_i);
- z.push_back(x_i - y_i);
+ double x_i = scale * point[i];
+ int y_i = std::floor(x_i);
+ output.vertex().push_back(y_i);
+ z.push_back(x_i - y_i);
}
}
else {
Eigen::VectorXd p_vect(d);
for (std::size_t i = 0; i < d; i++)
- p_vect(i) = point[i];
+ p_vect(i) = point[i];
Eigen::VectorXd x_vect = colpivhouseholderqr_.solve(p_vect - offset_);
for (std::size_t i = 0; i < d; i++) {
- double x_i = scale * x_vect(i);
- int y_i = std::floor(x_i);
- output.vertex().push_back(y_i);
- z.push_back(x_i - y_i);
+ double x_i = scale * x_vect(i);
+ int y_i = std::floor(x_i);
+ output.vertex().push_back(y_i);
+ z.push_back(x_i - y_i);
}
}
z.push_back(0);
Part indices(d+1);
std::iota(indices.begin(), indices.end(), 0);
std::sort(indices.begin(),
- indices.end(),
- [&z](std::size_t i1, std::size_t i2) {return z[i1] > z[i2];});
+ indices.end(),
+ [&z](std::size_t i1, std::size_t i2) {return z[i1] > z[i2];});
output.partition().push_back(Part(1, indices[0]));
for (std::size_t i = 1; i <= d; ++i)
if (z[indices[i-1]] > z[indices[i]] + error)
- output.partition().push_back(Part(1, indices[i]));
+ output.partition().push_back(Part(1, indices[i]));
else
- output.partition().back().push_back(indices[i]);
+ output.partition().back().push_back(indices[i]);
return output;
}
diff --git a/src/Coxeter_triangulation/include/gudhi/Functions/Cartesian_product.h b/src/Coxeter_triangulation/include/gudhi/Functions/Cartesian_product.h
index cda966f8..0a6f264d 100644
--- a/src/Coxeter_triangulation/include/gudhi/Functions/Cartesian_product.h
+++ b/src/Coxeter_triangulation/include/gudhi/Functions/Cartesian_product.h
@@ -13,9 +13,11 @@
#include <cstdlib>
#include <tuple>
-#include <utility>
+#include <type_traits> // for std::enable_if
+#include <cstdlib> // for std::size_t
#include <gudhi/Functions/Function.h>
+
#include <Eigen/Dense>
namespace Gudhi {
@@ -139,7 +141,7 @@ struct Cartesian_product : public Function {
cod_d_ = get_cod_d(function_tuple_);
}
-private:
+ private:
std::tuple<Functions...> function_tuple_;
std::size_t amb_d_, cod_d_;
};
diff --git a/src/Coxeter_triangulation/include/gudhi/Functions/Constant_function.h b/src/Coxeter_triangulation/include/gudhi/Functions/Constant_function.h
index e5b78b04..c03a2a24 100644
--- a/src/Coxeter_triangulation/include/gudhi/Functions/Constant_function.h
+++ b/src/Coxeter_triangulation/include/gudhi/Functions/Constant_function.h
@@ -11,7 +11,10 @@
#ifndef FUNCTIONS_CONSTANT_FUNCTION_H_
#define FUNCTIONS_CONSTANT_FUNCTION_H_
+#include <cstdlib> // for std::size_t
+
#include <gudhi/Functions/Function.h>
+
#include <Eigen/Dense>
namespace Gudhi {
@@ -57,7 +60,8 @@ struct Constant_function : public Function {
*/
Constant_function(std::size_t d, std::size_t k, const Eigen::VectorXd& value)
: d_(d), k_(k), value_(value) {}
-
+
+ private:
std::size_t d_, k_;
Eigen::VectorXd value_;
};
diff --git a/src/Coxeter_triangulation/include/gudhi/Functions/Embed_in_Rd.h b/src/Coxeter_triangulation/include/gudhi/Functions/Embed_in_Rd.h
index 230c89d8..5ebeac75 100644
--- a/src/Coxeter_triangulation/include/gudhi/Functions/Embed_in_Rd.h
+++ b/src/Coxeter_triangulation/include/gudhi/Functions/Embed_in_Rd.h
@@ -11,10 +11,10 @@
#ifndef FUNCTIONS_EMBED_IN_RD_H_
#define FUNCTIONS_EMBED_IN_RD_H_
-#include <cstdlib>
-#include <random>
+#include <cstdlib> // for std::size_t
#include <gudhi/Functions/Function.h>
+
#include <Eigen/Dense>
@@ -76,6 +76,8 @@ struct Embed_in_Rd : public Function {
Embed_in_Rd(const Function_& function, std::size_t d) :
fun_(function), d_(d) {
}
+
+ private:
Function_ fun_;
std::size_t d_;
};
diff --git a/src/Coxeter_triangulation/include/gudhi/Functions/Function_Sm_in_Rd.h b/src/Coxeter_triangulation/include/gudhi/Functions/Function_Sm_in_Rd.h
index f3ae577a..7ebb7fc8 100644
--- a/src/Coxeter_triangulation/include/gudhi/Functions/Function_Sm_in_Rd.h
+++ b/src/Coxeter_triangulation/include/gudhi/Functions/Function_Sm_in_Rd.h
@@ -11,7 +11,10 @@
#ifndef FUNCTIONS_FUNCTION_SM_IN_RD_H_
#define FUNCTIONS_FUNCTION_SM_IN_RD_H_
+#include <cstdlib> // for std::size_t
+
#include <gudhi/Functions/Function.h>
+
#include <Eigen/Dense>
namespace Gudhi {
@@ -115,7 +118,7 @@ struct Function_Sm_in_Rd: public Function {
: Function_Sm_in_Rd(rhs.r_, rhs.m_, rhs.d_, rhs.center_) {}
-protected:
+ private:
std::size_t m_, k_, d_;
double r_;
Eigen::VectorXd center_;
diff --git a/src/Coxeter_triangulation/include/gudhi/Functions/Function_affine_plane_in_Rd.h b/src/Coxeter_triangulation/include/gudhi/Functions/Function_affine_plane_in_Rd.h
index 75fb9322..1e950d4e 100644
--- a/src/Coxeter_triangulation/include/gudhi/Functions/Function_affine_plane_in_Rd.h
+++ b/src/Coxeter_triangulation/include/gudhi/Functions/Function_affine_plane_in_Rd.h
@@ -11,7 +11,10 @@
#ifndef FUNCTIONS_FUNCTION_AFFINE_PLANE_IN_RD_H_
#define FUNCTIONS_FUNCTION_AFFINE_PLANE_IN_RD_H_
+#include <cstdlib> // for std::size_t
+
#include <gudhi/Functions/Function.h>
+
#include <Eigen/Dense>
namespace Gudhi {
@@ -85,7 +88,7 @@ struct Function_affine_plane_in_Rd : public Function {
normal_matrix_.colwise().normalize();
}
-protected:
+private:
Eigen::MatrixXd normal_matrix_;
std::size_t d_, k_, m_;
Eigen::VectorXd off_;
diff --git a/src/Coxeter_triangulation/include/gudhi/Functions/Function_chair_in_R3.h b/src/Coxeter_triangulation/include/gudhi/Functions/Function_chair_in_R3.h
index 1649ef9c..fe16d37b 100644
--- a/src/Coxeter_triangulation/include/gudhi/Functions/Function_chair_in_R3.h
+++ b/src/Coxeter_triangulation/include/gudhi/Functions/Function_chair_in_R3.h
@@ -11,9 +11,11 @@
#ifndef FUNCTIONS_FUNCTION_CHAIR_IN_R3_H_
#define FUNCTIONS_FUNCTION_CHAIR_IN_R3_H_
-#include <cstdlib>
+#include <cstdlib> // for std::size_t
+#include <cmath> // for std::pow
#include <gudhi/Functions/Function.h>
+
#include <Eigen/Dense>
namespace Gudhi {
diff --git a/src/Coxeter_triangulation/include/gudhi/Functions/Function_iron_in_R3.h b/src/Coxeter_triangulation/include/gudhi/Functions/Function_iron_in_R3.h
index 8a438bf4..fa5e4e66 100644
--- a/src/Coxeter_triangulation/include/gudhi/Functions/Function_iron_in_R3.h
+++ b/src/Coxeter_triangulation/include/gudhi/Functions/Function_iron_in_R3.h
@@ -11,7 +11,11 @@
#ifndef FUNCTIONS_FUNCTION_IRON_IN_R3_H_
#define FUNCTIONS_FUNCTION_IRON_IN_R3_H_
+#include <cstdlib> // for std::size_t
+#include <cmath> // for std::pow
+
#include <gudhi/Functions/Function.h>
+
#include <Eigen/Dense>
namespace Gudhi {
@@ -59,7 +63,7 @@ struct Function_iron_in_R3 : public Function {
Function_iron_in_R3(Eigen::Vector3d off = Eigen::Vector3d::Zero()) :
off_(off) {}
-protected:
+ private:
Eigen::Vector3d off_;
};
diff --git a/src/Coxeter_triangulation/include/gudhi/Functions/Function_lemniscate_revolution_in_R3.h b/src/Coxeter_triangulation/include/gudhi/Functions/Function_lemniscate_revolution_in_R3.h
index 4f08614f..b715932b 100644
--- a/src/Coxeter_triangulation/include/gudhi/Functions/Function_lemniscate_revolution_in_R3.h
+++ b/src/Coxeter_triangulation/include/gudhi/Functions/Function_lemniscate_revolution_in_R3.h
@@ -11,7 +11,11 @@
#ifndef FUNCTIONS_FUNCTION_LEMNISCATE_REVOLUTION_IN_R3_H_
#define FUNCTIONS_FUNCTION_LEMNISCATE_REVOLUTION_IN_R3_H_
+#include <cstdlib> // for std::size_t
+#include <cmath> // for std::sqrt
+
#include <gudhi/Functions/Function.h>
+
#include <Eigen/Dense>
namespace Gudhi {
@@ -51,7 +55,7 @@ struct Function_lemniscate_revolution_in_R3 : public Function {
* See the method seed2() for the other point.
*/
virtual Eigen::VectorXd seed() const override {
- Eigen::Vector3d result(sqrt(2*a_)+off_[0], off_[1], off_[2]);
+ Eigen::Vector3d result(std::sqrt(2*a_)+off_[0], off_[1], off_[2]);
return result;
}
@@ -60,7 +64,7 @@ struct Function_lemniscate_revolution_in_R3 : public Function {
* See the method seed() for the other point.
*/
Eigen::VectorXd seed2() const {
- Eigen::Vector3d result(-sqrt(2*a_)+off_[0], off_[1], off_[2]);
+ Eigen::Vector3d result(-std::sqrt(2*a_)+off_[0], off_[1], off_[2]);
return result;
}
@@ -75,7 +79,7 @@ struct Function_lemniscate_revolution_in_R3 : public Function {
Eigen::Vector3d off = Eigen::Vector3d::Zero())
: a_(a), off_(off) {}
-protected:
+ private:
double a_;
Eigen::Vector3d off_;
};
diff --git a/src/Coxeter_triangulation/include/gudhi/Functions/Function_moment_curve_in_Rd.h b/src/Coxeter_triangulation/include/gudhi/Functions/Function_moment_curve_in_Rd.h
index f7588225..eecbc914 100644
--- a/src/Coxeter_triangulation/include/gudhi/Functions/Function_moment_curve_in_Rd.h
+++ b/src/Coxeter_triangulation/include/gudhi/Functions/Function_moment_curve_in_Rd.h
@@ -11,7 +11,10 @@
#ifndef FUNCTIONS_FUNCTION_MOMENT_CURVE_IN_RD_H_
#define FUNCTIONS_FUNCTION_MOMENT_CURVE_IN_RD_H_
+#include <cstdlib> // for std::size_t
+
#include <gudhi/Functions/Function.h>
+
#include <Eigen/Dense>
namespace Gudhi {
@@ -73,7 +76,7 @@ struct Function_moment_curve_in_Rd : public Function {
Eigen::VectorXd& offset)
: m_(1), k_(d-1), d_(d), r_(r), off_(offset) {}
-protected:
+ private:
std::size_t m_, k_, d_;
double r_;
Eigen::VectorXd off_;
diff --git a/src/Coxeter_triangulation/include/gudhi/Functions/Function_torus_in_R3.h b/src/Coxeter_triangulation/include/gudhi/Functions/Function_torus_in_R3.h
index af0675b0..c756c1a6 100644
--- a/src/Coxeter_triangulation/include/gudhi/Functions/Function_torus_in_R3.h
+++ b/src/Coxeter_triangulation/include/gudhi/Functions/Function_torus_in_R3.h
@@ -11,7 +11,11 @@
#ifndef FUNCTIONS_FUNCTION_TORUS_IN_R3_H_
#define FUNCTIONS_FUNCTION_TORUS_IN_R3_H_
+#include <cstdlib> // for std::size_t
+#include <cmath> // for std::sqrt
+
#include <gudhi/Functions/Function.h>
+
#include <Eigen/Dense>
namespace Gudhi {
@@ -62,7 +66,7 @@ struct Function_torus_in_R3 : public Function {
Eigen::Vector3d off = Eigen::Vector3d::Zero()) :
R_(R), r_(r), off_(off) {}
-protected:
+ private:
double R_, r_;
Eigen::Vector3d off_;
};
diff --git a/src/Coxeter_triangulation/include/gudhi/Functions/Function_whitney_umbrella_in_R3.h b/src/Coxeter_triangulation/include/gudhi/Functions/Function_whitney_umbrella_in_R3.h
index 3c729878..09306561 100644
--- a/src/Coxeter_triangulation/include/gudhi/Functions/Function_whitney_umbrella_in_R3.h
+++ b/src/Coxeter_triangulation/include/gudhi/Functions/Function_whitney_umbrella_in_R3.h
@@ -11,7 +11,10 @@
#ifndef FUNCTIONS_FUNCTION_WHITNEY_UMBRELLA_IN_R3_H_
#define FUNCTIONS_FUNCTION_WHITNEY_UMBRELLA_IN_R3_H_
+#include <cstdlib> // for std::size_t
+
#include <gudhi/Functions/Function.h>
+
#include <Eigen/Dense>
namespace Gudhi {
@@ -69,6 +72,8 @@ struct Function_whitney_umbrella_in_R3 : public Function {
*/
Function_whitney_umbrella_in_R3(Eigen::Vector3d off = Eigen::Vector3d::Zero())
: off_(off) {}
+
+ private:
Eigen::Vector3d off_;
};
diff --git a/src/Coxeter_triangulation/include/gudhi/Functions/Linear_transformation.h b/src/Coxeter_triangulation/include/gudhi/Functions/Linear_transformation.h
index 7d36cf84..a5d17fe0 100644
--- a/src/Coxeter_triangulation/include/gudhi/Functions/Linear_transformation.h
+++ b/src/Coxeter_triangulation/include/gudhi/Functions/Linear_transformation.h
@@ -11,9 +11,10 @@
#ifndef FUNCTIONS_LINEAR_TRANSFORMATION_H_
#define FUNCTIONS_LINEAR_TRANSFORMATION_H_
-#include <cstdlib>
+#include <cstdlib> // for std::size_t
#include <gudhi/Functions/Function.h>
+
#include <Eigen/Dense>
namespace Gudhi {
@@ -65,7 +66,7 @@ struct Linear_transformation : public Function {
fun_(function), matrix_(matrix) {
}
-private:
+ private:
Function_ fun_;
Eigen::MatrixXd matrix_;
};
diff --git a/src/Coxeter_triangulation/include/gudhi/Functions/Negation.h b/src/Coxeter_triangulation/include/gudhi/Functions/Negation.h
index e3ddecdb..3439dbad 100644
--- a/src/Coxeter_triangulation/include/gudhi/Functions/Negation.h
+++ b/src/Coxeter_triangulation/include/gudhi/Functions/Negation.h
@@ -11,9 +11,10 @@
#ifndef FUNCTIONS_NEGATION_H_
#define FUNCTIONS_NEGATION_H_
-#include <cstdlib>
+#include <cstdlib> // for std::size_t
#include <gudhi/Functions/Function.h>
+
#include <Eigen/Dense>
namespace Gudhi {
@@ -62,6 +63,8 @@ struct Negation : public Function {
Negation(const Function_& function) :
fun_(function) {
}
+
+ private:
Function_ fun_;
};
@@ -78,7 +81,7 @@ struct Negation : public Function {
* \ingroup coxeter_triangulation
*/
template <class Function_>
-Negation<Function_> negation(const Function_& function) {
+Negation<Function_> negation(const Function_& function) {
return Negation<Function_>(function);
}
diff --git a/src/Coxeter_triangulation/include/gudhi/Functions/PL_approximation.h b/src/Coxeter_triangulation/include/gudhi/Functions/PL_approximation.h
index abfad697..ab2b9294 100644
--- a/src/Coxeter_triangulation/include/gudhi/Functions/PL_approximation.h
+++ b/src/Coxeter_triangulation/include/gudhi/Functions/PL_approximation.h
@@ -11,9 +11,10 @@
#ifndef FUNCTIONS_PL_APPROXIMATION_H_
#define FUNCTIONS_PL_APPROXIMATION_H_
-#include <cstdlib>
+#include <cstdlib> // for std::size_t
#include <gudhi/Functions/Function.h>
+
#include <Eigen/Dense>
namespace Gudhi {
@@ -90,7 +91,7 @@ struct PL_approximation : public Function {
PL_approximation(const Function_& function, const Triangulation_& triangulation)
: fun_(function), tr_(triangulation) {}
-private:
+ private:
Function_ fun_;
Triangulation_ tr_;
};
diff --git a/src/Coxeter_triangulation/include/gudhi/Functions/Translate.h b/src/Coxeter_triangulation/include/gudhi/Functions/Translate.h
index 90f09a0b..b3f53fe0 100644
--- a/src/Coxeter_triangulation/include/gudhi/Functions/Translate.h
+++ b/src/Coxeter_triangulation/include/gudhi/Functions/Translate.h
@@ -11,9 +11,10 @@
#ifndef FUNCTIONS_TRANSLATE_H_
#define FUNCTIONS_TRANSLATE_H_
-#include <cstdlib>
+#include <cstdlib> // for std::size_t
#include <gudhi/Functions/Function.h>
+
#include <Eigen/Dense>
namespace Gudhi {
@@ -65,6 +66,8 @@ struct Translate : public Function {
Translate(const Function_& function, const Eigen::VectorXd& off) :
fun_(function), off_(off) {
}
+
+ private:
Function_ fun_;
Eigen::VectorXd off_;
};
diff --git a/src/Coxeter_triangulation/include/gudhi/Functions/random_orthogonal_matrix.h b/src/Coxeter_triangulation/include/gudhi/Functions/random_orthogonal_matrix.h
index e1bbaea3..34fc1a67 100644
--- a/src/Coxeter_triangulation/include/gudhi/Functions/random_orthogonal_matrix.h
+++ b/src/Coxeter_triangulation/include/gudhi/Functions/random_orthogonal_matrix.h
@@ -11,8 +11,11 @@
#ifndef FUNCTIONS_RANDOM_ORTHOGONAL_MATRIX_H_
#define FUNCTIONS_RANDOM_ORTHOGONAL_MATRIX_H_
-#include <cstdlib>
-#include <random>
+#include <cstdlib> // for std::size_t
+#include <cmath> // for std::cos, std::sin
+#include <random> // for std::uniform_real_distribution, std::random_device
+
+#include <gudhi/math.h>
#include <Eigen/Dense>
#include <Eigen/Sparse>
@@ -41,10 +44,14 @@ Eigen::MatrixXd random_orthogonal_matrix(std::size_t d) {
if (d == 1)
return Eigen::VectorXd::Constant(1, 1.0);
if (d == 2) {
- double X = 2 * 3.14159265358;
- double alpha = static_cast <float> (rand()) / (static_cast <float> (RAND_MAX/X));
+ // 0. < alpha < 2 Pi
+ std::uniform_real_distribution<double> unif(0., 2 * Gudhi::PI);
+ std::random_device rand_dev;
+ std::mt19937 rand_engine(rand_dev());
+ double alpha = unif(rand_engine);
+
Eigen::Matrix2d rot;
- rot << cos(alpha), -sin(alpha), sin(alpha), cos(alpha);
+ rot << std::cos(alpha), -std::sin(alpha), std::sin(alpha), cos(alpha);
return rot;
}
Eigen::MatrixXd low_dim_rot = random_orthogonal_matrix(d-1);
diff --git a/src/Coxeter_triangulation/include/gudhi/IO/Mesh_medit.h b/src/Coxeter_triangulation/include/gudhi/IO/Mesh_medit.h
index 2cceeac1..28276bf7 100644
--- a/src/Coxeter_triangulation/include/gudhi/IO/Mesh_medit.h
+++ b/src/Coxeter_triangulation/include/gudhi/IO/Mesh_medit.h
@@ -15,6 +15,11 @@ namespace Gudhi {
namespace coxeter_triangulation {
+#include <Eigen/Dense>
+
+#include <vector>
+#include <utility> // for std::pair
+
/* \class Mesh_medit
* \brief Structure to store a mesh that can be output in Medit .mesh file format
* using the output_meshes_to_medit method.
diff --git a/src/Coxeter_triangulation/include/gudhi/IO/build_mesh_from_cell_complex.h b/src/Coxeter_triangulation/include/gudhi/IO/build_mesh_from_cell_complex.h
index a96d12ba..abe6cdbf 100644
--- a/src/Coxeter_triangulation/include/gudhi/IO/build_mesh_from_cell_complex.h
+++ b/src/Coxeter_triangulation/include/gudhi/IO/build_mesh_from_cell_complex.h
@@ -13,34 +13,42 @@
#include <gudhi/IO/Mesh_medit.h>
+#include <Eigen/Dense>
+
+#include <cstdlib> // for std::size_t
+#include <map>
+#include <set>
+#include <string>
+#include <utility> // for std::make_pair
+#include <algorithm> // for std::min
+
namespace Gudhi {
namespace coxeter_triangulation {
struct Configuration {
+ Configuration(bool t_edges, bool t_triangles, bool t_tetrahedra,
+ std::size_t r_edges, std::size_t r_triangles, std::size_t r_tetrahedra)
+ : toggle_edges(t_edges), toggle_triangles(t_triangles), toggle_tetrahedra(t_tetrahedra),
+ ref_edges(r_edges), ref_triangles(r_triangles), ref_tetrahedra(r_tetrahedra) {}
+
+ Configuration() {}
+
bool toggle_edges = true,
toggle_triangles = true,
toggle_tetrahedra = true;
std::size_t ref_edges = 1,
ref_triangles = 1,
ref_tetrahedra = 1;
-
- Configuration(bool t_edges, bool t_triangles, bool t_tetrahedra,
- std::size_t r_edges, std::size_t r_triangles, std::size_t r_tetrahedra)
- : toggle_edges(t_edges), toggle_triangles(t_triangles), toggle_tetrahedra(t_tetrahedra),
- ref_edges(r_edges), ref_triangles(r_triangles), ref_tetrahedra(r_tetrahedra) {}
-
- Configuration() {}
};
-template <class Hasse_cell,
- class Simplex_cell_map>
+template <class Hasse_cell, class Simplex_cell_map>
void populate_mesh(Mesh_medit& output,
- Simplex_cell_map& sc_map,
- Configuration configuration,
- std::size_t amb_d,
- std::map<Hasse_cell*, std::size_t> vi_map) {
+ Simplex_cell_map& sc_map,
+ Configuration configuration,
+ std::size_t amb_d,
+ std::map<Hasse_cell*, std::size_t> vi_map) {
using Mesh_element_vertices = Mesh_medit::Mesh_elements::value_type::first_type;
std::map<Hasse_cell*, std::size_t> ci_map;
std::size_t index = vi_map.size() + 1; // current size of output.vertex_points
@@ -50,16 +58,16 @@ void populate_mesh(Mesh_medit& output,
std::set<std::size_t> vertex_indices;
Hasse_cell* cell = sc_pair.second;
for (const auto& ei_pair: cell->get_boundary())
- for (const auto& vi_pair: ei_pair.first->get_boundary())
- vertex_indices.emplace(vi_map[vi_pair.first]);
+ for (const auto& vi_pair: ei_pair.first->get_boundary())
+ vertex_indices.emplace(vi_map[vi_pair.first]);
for (const std::size_t& v: vertex_indices)
- barycenter += output.vertex_points[v-1];
+ barycenter += output.vertex_points[v-1];
ci_map.emplace(std::make_pair(cell, index++));
output.vertex_points.emplace_back((1./vertex_indices.size()) * barycenter);
#ifdef GUDHI_COX_OUTPUT_TO_HTML
std::string vlist = " (" + std::to_string(index-1) + ")";
for (const std::size_t& v: vertex_indices)
- vlist += " " + std::to_string(v);
+ vlist += " " + std::to_string(v);
cell_vlist_map.emplace(std::make_pair(to_string(cell), vlist));
#endif
}
@@ -69,12 +77,12 @@ void populate_mesh(Mesh_medit& output,
Hasse_cell* edge_cell = sc_map.second;
Mesh_element_vertices edge;
for (const auto& vi_pair: edge_cell->get_boundary())
- edge.push_back(vi_map[vi_pair.first]);
+ edge.push_back(vi_map[vi_pair.first]);
output.edges.emplace_back(std::make_pair(edge, configuration.ref_edges));
#ifdef GUDHI_COX_OUTPUT_TO_HTML
std::string vlist;
for (const std::size_t& v: edge)
- vlist += " " + std::to_string(v);
+ vlist += " " + std::to_string(v);
cell_vlist_map.emplace(std::make_pair(to_string(edge_cell), vlist));
#endif
}
@@ -82,10 +90,10 @@ void populate_mesh(Mesh_medit& output,
if (configuration.toggle_triangles && sc_map.size() >= 3)
for (const auto& sc_pair: sc_map[2]) {
for (const auto& ei_pair: sc_pair.second->get_boundary()) {
- Mesh_element_vertices triangle(1, ci_map[sc_pair.second]);
- for (const auto& vi_pair: ei_pair.first->get_boundary())
- triangle.push_back(vi_map[vi_pair.first]);
- output.triangles.emplace_back(std::make_pair(triangle, configuration.ref_triangles));
+ Mesh_element_vertices triangle(1, ci_map[sc_pair.second]);
+ for (const auto& vi_pair: ei_pair.first->get_boundary())
+ triangle.push_back(vi_map[vi_pair.first]);
+ output.triangles.emplace_back(std::make_pair(triangle, configuration.ref_triangles));
}
}
@@ -95,34 +103,34 @@ void populate_mesh(Mesh_medit& output,
std::set<std::size_t> vertex_indices;
Hasse_cell* cell = sc_pair.second;
for (const auto& ci_pair: cell->get_boundary())
- for (const auto& ei_pair: ci_pair.first->get_boundary())
- for (const auto& vi_pair: ei_pair.first->get_boundary())
- vertex_indices.emplace(vi_map[vi_pair.first]);
- for (const std::size_t& v: vertex_indices)
- barycenter += output.vertex_points[v-1];
+ for (const auto& ei_pair: ci_pair.first->get_boundary())
+ for (const auto& vi_pair: ei_pair.first->get_boundary())
+ vertex_indices.emplace(vi_map[vi_pair.first]);
+ for (const std::size_t& v: vertex_indices)
+ barycenter += output.vertex_points[v-1];
output.vertex_points.emplace_back((1./vertex_indices.size()) * barycenter);
#ifdef GUDHI_COX_OUTPUT_TO_HTML
std::string vlist = " (" + std::to_string(index) + ")";
for (const std::size_t& v: vertex_indices)
- vlist += " " + std::to_string(v);
+ vlist += " " + std::to_string(v);
cell_vlist_map.emplace(std::make_pair(to_string(cell), vlist));
#endif
for (const auto& ci_pair: cell->get_boundary())
- for (const auto& ei_pair: ci_pair.first->get_boundary()) {
- Mesh_element_vertices tetrahedron = {index, ci_map[sc_pair.second]};
- for (const auto& vi_pair: ei_pair.first->get_boundary())
- tetrahedron.push_back(vi_map[vi_pair.first]);
- output.tetrahedra.emplace_back(std::make_pair(tetrahedron, configuration.ref_tetrahedra));
- }
+ for (const auto& ei_pair: ci_pair.first->get_boundary()) {
+ Mesh_element_vertices tetrahedron = {index, ci_map[sc_pair.second]};
+ for (const auto& vi_pair: ei_pair.first->get_boundary())
+ tetrahedron.push_back(vi_map[vi_pair.first]);
+ output.tetrahedra.emplace_back(std::make_pair(tetrahedron, configuration.ref_tetrahedra));
+ }
index++;
}
}
template <class Cell_complex>
Mesh_medit build_mesh_from_cell_complex(const Cell_complex& cell_complex,
- Configuration i_configuration = Configuration(),
- Configuration b_configuration = Configuration()) {
+ Configuration i_configuration = Configuration(),
+ Configuration b_configuration = Configuration()) {
using Hasse_cell = typename Cell_complex::Hasse_cell;
Mesh_medit output;
std::map<Hasse_cell*, std::size_t> vi_map; // one for vertices, other for 2d-cells
@@ -142,7 +150,6 @@ Mesh_medit build_mesh_from_cell_complex(const Cell_complex& cell_complex,
output.vertex_points.push_back(cp_pair.second);
output.vertex_points.back().conservativeResize(amb_d);
}
-
populate_mesh(output, cell_complex.interior_simplex_cell_maps(), i_configuration, amb_d, vi_map);
#ifdef GUDHI_COX_OUTPUT_TO_HTML
diff --git a/src/Coxeter_triangulation/include/gudhi/IO/output_meshes_to_medit.h b/src/Coxeter_triangulation/include/gudhi/IO/output_meshes_to_medit.h
index b40593ba..850736e9 100644
--- a/src/Coxeter_triangulation/include/gudhi/IO/output_meshes_to_medit.h
+++ b/src/Coxeter_triangulation/include/gudhi/IO/output_meshes_to_medit.h
@@ -12,8 +12,15 @@
#define IO_OUTPUT_MESHES_TO_MEDIT_H_
#include <gudhi/IO/Mesh_medit.h>
+
#include <Eigen/Dense>
-#include <fstream>
+
+#include <cstdlib> // for std::size_t
+#include <fstream> // for std::ofstream
+#include <vector>
+#include <type_traits> // for std::enable_if
+#include <tuple> // for std::get
+#include <utility> // for std::make_pair
namespace Gudhi {
diff --git a/src/Coxeter_triangulation/include/gudhi/Implicit_manifold_intersection_oracle.h b/src/Coxeter_triangulation/include/gudhi/Implicit_manifold_intersection_oracle.h
index d3f371a6..51d84274 100644
--- a/src/Coxeter_triangulation/include/gudhi/Implicit_manifold_intersection_oracle.h
+++ b/src/Coxeter_triangulation/include/gudhi/Implicit_manifold_intersection_oracle.h
@@ -37,15 +37,15 @@ namespace coxeter_triangulation {
* \ingroup coxeter_triangulation
*/
template<class Function_,
- class Domain_function_ = Constant_function>
+ class Domain_function_ = Constant_function>
class Implicit_manifold_intersection_oracle {
/* Computes the affine coordinates of the intersection point of the implicit manifold
* and the affine hull of the simplex. */
template <class Simplex_handle,
- class Triangulation>
+ class Triangulation>
Eigen::VectorXd compute_lambda(const Simplex_handle& simplex,
- const Triangulation& triangulation) const {
+ const Triangulation& triangulation) const {
std::size_t cod_d = this->cod_d();
Eigen::MatrixXd matrix(cod_d + 1, cod_d + 1);
for (std::size_t i = 0; i < cod_d + 1; ++i)
@@ -54,7 +54,7 @@ class Implicit_manifold_intersection_oracle {
for (auto v: simplex.vertex_range()) {
Eigen::VectorXd v_coords = fun_(triangulation.cartesian_coordinates(v));
for (std::size_t i = 1; i < cod_d + 1; ++i)
- matrix(i, j) = v_coords(i-1);
+ matrix(i, j) = v_coords(i-1);
j++;
}
Eigen::VectorXd z(cod_d + 1);
@@ -68,9 +68,9 @@ class Implicit_manifold_intersection_oracle {
/* Computes the affine coordinates of the intersection point of the boundary
* of the implicit manifold and the affine hull of the simplex. */
template <class Simplex_handle,
- class Triangulation>
+ class Triangulation>
Eigen::VectorXd compute_boundary_lambda(const Simplex_handle& simplex,
- const Triangulation& triangulation) const {
+ const Triangulation& triangulation) const {
std::size_t cod_d = this->cod_d();
Eigen::MatrixXd matrix(cod_d + 2, cod_d + 2);
for (std::size_t i = 0; i < cod_d + 2; ++i)
@@ -79,7 +79,7 @@ class Implicit_manifold_intersection_oracle {
for (auto v: simplex.vertex_range()) {
Eigen::VectorXd v_coords = fun_(triangulation.cartesian_coordinates(v));
for (std::size_t i = 1; i < cod_d + 1; ++i)
- matrix(i, j) = v_coords(i-1);
+ matrix(i, j) = v_coords(i-1);
Eigen::VectorXd bv_coords = domain_fun_(triangulation.cartesian_coordinates(v));
matrix(cod_d + 1, j) = bv_coords(0);
j++;
@@ -94,17 +94,17 @@ class Implicit_manifold_intersection_oracle {
/* Computes the intersection result for a given simplex in a triangulation. */
template <class Simplex_handle,
- class Triangulation>
+ class Triangulation>
Query_result<Simplex_handle> intersection_result(const Eigen::VectorXd& lambda,
- const Simplex_handle& simplex,
- const Triangulation& triangulation) const {
+ const Simplex_handle& simplex,
+ const Triangulation& triangulation) const {
using QR = Query_result<Simplex_handle>;
std::size_t amb_d = triangulation.dimension();
std::size_t cod_d = simplex.dimension();
for (std::size_t i = 0; i < (std::size_t)lambda.size(); ++i)
if (lambda(i) < 0 || lambda(i) > 1)
- return QR({Eigen::VectorXd(), false});
+ return QR({Eigen::VectorXd(), false});
Eigen::MatrixXd vertex_matrix(cod_d + 1, amb_d);
auto v_range = simplex.vertex_range();
@@ -112,7 +112,7 @@ class Implicit_manifold_intersection_oracle {
for (std::size_t i = 0; i < cod_d + 1 && v_it != v_range.end(); ++v_it, ++i) {
Eigen::VectorXd v_coords = triangulation.cartesian_coordinates(*v_it);
for (std::size_t j = 0; j < amb_d; ++j)
- vertex_matrix(i, j) = v_coords(j);
+ vertex_matrix(i, j) = v_coords(j);
}
Eigen::VectorXd intersection = lambda.transpose()*vertex_matrix;
return QR({intersection, true});
@@ -151,9 +151,9 @@ public:
* (the domain dimension of the function).
*/
template <class Simplex_handle,
- class Triangulation>
+ class Triangulation>
Query_result<Simplex_handle> intersects(const Simplex_handle& simplex,
- const Triangulation& triangulation) const {
+ const Triangulation& triangulation) const {
Eigen::VectorXd lambda = compute_lambda(simplex, triangulation);
return intersection_result(lambda, simplex, triangulation);
}
@@ -179,9 +179,9 @@ public:
* (the domain dimension of the function).
*/
template <class Simplex_handle,
- class Triangulation>
+ class Triangulation>
Query_result<Simplex_handle> intersects_boundary(const Simplex_handle& simplex,
- const Triangulation& triangulation) const {
+ const Triangulation& triangulation) const {
Eigen::VectorXd lambda = compute_boundary_lambda(simplex, triangulation);
return intersection_result(lambda, simplex, triangulation);
}
@@ -199,7 +199,7 @@ public:
*/
template <class Triangulation>
bool lies_in_domain(const Eigen::VectorXd& p,
- const Triangulation& triangulation) const {
+ const Triangulation& triangulation) const {
Eigen::VectorXd pl_p = make_pl_approximation(domain_fun_, triangulation)(p);
return pl_p(0) < 0;
}
@@ -218,7 +218,7 @@ public:
* manifold with boundary.
*/
Implicit_manifold_intersection_oracle(const Function_& function,
- const Domain_function_& domain_function)
+ const Domain_function_& domain_function)
: fun_(function), domain_fun_(domain_function) {}
/** \brief Constructs an intersection oracle for an implicit manifold
@@ -249,12 +249,12 @@ private:
* \ingroup coxeter_triangulation
*/
template<class Function_,
- class Domain_function_>
+ class Domain_function_>
Implicit_manifold_intersection_oracle<Function_, Domain_function_>
make_oracle(const Function_& function,
- const Domain_function_& domain_function){
+ const Domain_function_& domain_function){
return Implicit_manifold_intersection_oracle<Function_, Domain_function_>(function,
- domain_function);
+ domain_function);
}
diff --git a/src/Coxeter_triangulation/include/gudhi/Manifold_tracing.h b/src/Coxeter_triangulation/include/gudhi/Manifold_tracing.h
index bbd86eb9..25b664eb 100644
--- a/src/Coxeter_triangulation/include/gudhi/Manifold_tracing.h
+++ b/src/Coxeter_triangulation/include/gudhi/Manifold_tracing.h
@@ -76,26 +76,26 @@ public:
* are the intersection points.
*/
template <class Point_range,
- class Intersection_oracle>
+ class Intersection_oracle>
void manifold_tracing_algorithm(const Point_range& seed_points,
- const Triangulation_& triangulation,
- const Intersection_oracle& oracle,
- Out_simplex_map& out_simplex_map) {
+ const Triangulation_& triangulation,
+ const Intersection_oracle& oracle,
+ Out_simplex_map& out_simplex_map) {
std::size_t cod_d = oracle.cod_d();
std::queue<Simplex_handle> queue;
for (const auto& p: seed_points) {
Simplex_handle full_simplex = triangulation.locate_point(p);
for (Simplex_handle face: full_simplex.face_range(cod_d)) {
- Query_result<Simplex_handle> qr = oracle.intersects(face, triangulation);
- if (qr.success &&
- out_simplex_map.emplace(std::make_pair(face, qr.intersection)).second) {
+ Query_result<Simplex_handle> qr = oracle.intersects(face, triangulation);
+ if (qr.success &&
+ out_simplex_map.emplace(std::make_pair(face, qr.intersection)).second) {
#ifdef GUDHI_COX_OUTPUT_TO_HTML
- mt_seed_inserted_list.push_back(MT_inserted_info(qr, face, false));
+ mt_seed_inserted_list.push_back(MT_inserted_info(qr, face, false));
#endif
- queue.emplace(face);
- break;
- }
+ queue.emplace(face);
+ break;
+ }
}
}
@@ -104,12 +104,12 @@ public:
Simplex_handle s = queue.front();
queue.pop();
for (auto cof: s.coface_range(cod_d+1)) {
- for (auto face: cof.face_range(cod_d)) {
- Query_result<Simplex_handle> qr = oracle.intersects(face, triangulation);
- if (qr.success &&
- out_simplex_map.emplace(std::make_pair(face, qr.intersection)).second)
- queue.emplace(face);
- }
+ for (auto face: cof.face_range(cod_d)) {
+ Query_result<Simplex_handle> qr = oracle.intersects(face, triangulation);
+ if (qr.success &&
+ out_simplex_map.emplace(std::make_pair(face, qr.intersection)).second)
+ queue.emplace(face);
+ }
}
}
}
@@ -139,39 +139,39 @@ public:
* and the mapped values are the intersection points.
*/
template <class Point_range,
- class Intersection_oracle>
+ class Intersection_oracle>
void manifold_tracing_algorithm(const Point_range& seed_points,
- const Triangulation_& triangulation,
- const Intersection_oracle& oracle,
- Out_simplex_map& interior_simplex_map,
- Out_simplex_map& boundary_simplex_map) {
+ const Triangulation_& triangulation,
+ const Intersection_oracle& oracle,
+ Out_simplex_map& interior_simplex_map,
+ Out_simplex_map& boundary_simplex_map) {
std::size_t cod_d = oracle.cod_d();
std::queue<Simplex_handle> queue;
for (const auto& p: seed_points) {
Simplex_handle full_simplex = triangulation.locate_point(p);
for (Simplex_handle face: full_simplex.face_range(cod_d)) {
- auto qr = oracle.intersects(face, triangulation);
+ auto qr = oracle.intersects(face, triangulation);
#ifdef GUDHI_COX_OUTPUT_TO_HTML
- mt_seed_inserted_list.push_back(MT_inserted_info(qr, face, false));
-#endif
- if (qr.success) {
- if (oracle.lies_in_domain(qr.intersection, triangulation)) {
- if (interior_simplex_map.emplace(std::make_pair(face, qr.intersection)).second)
- queue.emplace(face);
- }
- else {
- for (Simplex_handle cof: face.coface_range(cod_d+1)) {
- auto qrb = oracle.intersects_boundary(cof, triangulation);
+ mt_seed_inserted_list.push_back(MT_inserted_info(qr, face, false));
+#endif
+ if (qr.success) {
+ if (oracle.lies_in_domain(qr.intersection, triangulation)) {
+ if (interior_simplex_map.emplace(std::make_pair(face, qr.intersection)).second)
+ queue.emplace(face);
+ }
+ else {
+ for (Simplex_handle cof: face.coface_range(cod_d+1)) {
+ auto qrb = oracle.intersects_boundary(cof, triangulation);
#ifdef GUDHI_COX_OUTPUT_TO_HTML
- mt_seed_inserted_list.push_back(MT_inserted_info(qrb, cof, true));
-#endif
- if (qrb.success)
- boundary_simplex_map.emplace(cof, qrb.intersection);
- }
- }
- // break;
- }
+ mt_seed_inserted_list.push_back(MT_inserted_info(qrb, cof, true));
+#endif
+ if (qrb.success)
+ boundary_simplex_map.emplace(cof, qrb.intersection);
+ }
+ }
+ // break;
+ }
}
}
@@ -179,27 +179,27 @@ public:
Simplex_handle s = queue.front();
queue.pop();
for (auto cof: s.coface_range(cod_d+1)) {
- for (auto face: cof.face_range(cod_d)) {
- auto qr = oracle.intersects(face, triangulation);
+ for (auto face: cof.face_range(cod_d)) {
+ auto qr = oracle.intersects(face, triangulation);
#ifdef GUDHI_COX_OUTPUT_TO_HTML
- mt_inserted_list.push_back(MT_inserted_info(qr, face, false));
-#endif
- if (qr.success) {
- if (oracle.lies_in_domain(qr.intersection, triangulation)) {
- if (interior_simplex_map.emplace(face, qr.intersection).second)
- queue.emplace(face);
- }
- else {
- auto qrb = oracle.intersects_boundary(cof, triangulation);
+ mt_inserted_list.push_back(MT_inserted_info(qr, face, false));
+#endif
+ if (qr.success) {
+ if (oracle.lies_in_domain(qr.intersection, triangulation)) {
+ if (interior_simplex_map.emplace(face, qr.intersection).second)
+ queue.emplace(face);
+ }
+ else {
+ auto qrb = oracle.intersects_boundary(cof, triangulation);
#ifdef GUDHI_COX_OUTPUT_TO_HTML
- mt_inserted_list.push_back(MT_inserted_info(qrb, cof, true));
-#endif
- // assert (qrb.success); // always a success
- if (qrb.success)
- boundary_simplex_map.emplace(cof, qrb.intersection);
- }
- }
- }
+ mt_inserted_list.push_back(MT_inserted_info(qrb, cof, true));
+#endif
+ // assert (qrb.success); // always a success
+ if (qrb.success)
+ boundary_simplex_map.emplace(cof, qrb.intersection);
+ }
+ }
+ }
}
}
}
@@ -237,18 +237,18 @@ public:
* \ingroup coxeter_triangulation
*/
template <class Point_range,
- class Triangulation,
- class Intersection_oracle,
- class Out_simplex_map>
+ class Triangulation,
+ class Intersection_oracle,
+ class Out_simplex_map>
void manifold_tracing_algorithm(const Point_range& seed_points,
- const Triangulation& triangulation,
- const Intersection_oracle& oracle,
- Out_simplex_map& out_simplex_map) {
+ const Triangulation& triangulation,
+ const Intersection_oracle& oracle,
+ Out_simplex_map& out_simplex_map) {
Manifold_tracing<Triangulation> mt;
mt.manifold_tracing_algorithm(seed_points,
- triangulation,
- oracle,
- out_simplex_map);
+ triangulation,
+ oracle,
+ out_simplex_map);
}
/**
@@ -281,20 +281,20 @@ void manifold_tracing_algorithm(const Point_range& seed_points,
* \ingroup coxeter_triangulation
*/
template <class Point_range,
- class Triangulation,
- class Intersection_oracle,
- class Out_simplex_map>
+ class Triangulation,
+ class Intersection_oracle,
+ class Out_simplex_map>
void manifold_tracing_algorithm(const Point_range& seed_points,
- const Triangulation& triangulation,
- const Intersection_oracle& oracle,
- Out_simplex_map& interior_simplex_map,
- Out_simplex_map& boundary_simplex_map) {
+ const Triangulation& triangulation,
+ const Intersection_oracle& oracle,
+ Out_simplex_map& interior_simplex_map,
+ Out_simplex_map& boundary_simplex_map) {
Manifold_tracing<Triangulation> mt;
mt.manifold_tracing_algorithm(seed_points,
- triangulation,
- oracle,
- interior_simplex_map,
- boundary_simplex_map);
+ triangulation,
+ oracle,
+ interior_simplex_map,
+ boundary_simplex_map);
}
diff --git a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation.h b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation.h
index 303011a2..b1f57b08 100644
--- a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation.h
+++ b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation.h
@@ -13,8 +13,7 @@
#include <gudhi/Permutahedral_representation/Permutahedral_representation_iterators.h>
-#include <unordered_set>
-#include <iostream>
+#include <utility> // for std::make_pair
namespace Gudhi {
@@ -36,7 +35,7 @@ namespace coxeter_triangulation {
* random-access ranges.
*/
template <class Vertex_,
- class Ordered_set_partition_>
+ class Ordered_set_partition_>
class Permutahedral_representation {
typedef Permutahedral_representation<Vertex_, Ordered_set_partition_> Self;
@@ -100,7 +99,7 @@ public:
return false;
for (std::size_t k = 0; k < partition_.size(); ++k)
if (partition_[k] != other.partition_[k])
- return false;
+ return false;
return true;
}
@@ -118,7 +117,7 @@ public:
*/
Vertex_range vertex_range() const {
return Vertex_range(Vertex_iterator(*this),
- Vertex_iterator());
+ Vertex_iterator());
}
typedef Gudhi::coxeter_triangulation::Face_iterator<Self> Face_iterator;
@@ -128,7 +127,7 @@ public:
*/
Face_range face_range(std::size_t value_dim) const {
return Face_range(Face_iterator(*this, value_dim),
- Face_iterator());
+ Face_iterator());
}
/** \brief Returns a range of permutahedral representations of facets of the simplex.
@@ -136,7 +135,7 @@ public:
*/
Face_range facet_range() const {
return Face_range(Face_iterator(*this, dimension()-1),
- Face_iterator());
+ Face_iterator());
}
typedef Gudhi::coxeter_triangulation::Coface_iterator<Self> Coface_iterator;
@@ -146,7 +145,7 @@ public:
*/
Coface_range coface_range(std::size_t value_dim) const {
return Coface_range(Coface_iterator(*this, value_dim),
- Coface_iterator());
+ Coface_iterator());
}
/** \brief Returns a range of permutahedral representations of cofacets of the simplex.
@@ -154,7 +153,7 @@ public:
*/
Coface_range cofacet_range() const {
return Coface_range(Coface_iterator(*this, dimension()+1),
- Coface_iterator());
+ Coface_iterator());
}
/** \brief Returns true, if the simplex is a face of other simplex.
@@ -174,19 +173,19 @@ public:
auto other_partition_it = other.partition_.begin();
while (self_partition_it != partition_.end()) {
while (other_partition_it != other.partition_.end() && v_self != v_other) {
- const Part& other_part = *other_partition_it++;
- if (other_partition_it == other.partition_.end())
- return false;
- for (const auto& k: other_part)
- v_other[k]++;
+ const Part& other_part = *other_partition_it++;
+ if (other_partition_it == other.partition_.end())
+ return false;
+ for (const auto& k: other_part)
+ v_other[k]++;
}
if (other_partition_it == other.partition_.end())
- return false;
+ return false;
const Part& self_part = *self_partition_it++;
if (self_partition_it == partition_.end())
- return true;
+ return true;
for (const auto& k: self_part)
- v_self[k]++;
+ v_self[k]++;
}
return true;
}
@@ -204,9 +203,9 @@ private:
* @param[in] simplex A simplex represented by its permutahedral representation.
*/
template <class Vertex,
- class OrderedSetPartition>
+ class OrderedSetPartition>
std::ostream& operator<<(std::ostream& os,
- const Permutahedral_representation<Vertex, OrderedSetPartition>& simplex) {
+ const Permutahedral_representation<Vertex, OrderedSetPartition>& simplex) {
// vertex part
os << "(";
if (simplex.vertex().empty()) {
@@ -225,12 +224,12 @@ std::ostream& operator<<(std::ostream& os,
[&os](const Part& p) {
os << "{";
if (p.empty()) {
- os << "}";
+ os << "}";
}
auto p_it = p.begin();
os << *p_it++;
for (; p_it != p.end(); ++p_it)
- os << ", " << *p_it;
+ os << ", " << *p_it;
os << "}";
};
os << " [";
diff --git a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Combination_iterator.h b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Combination_iterator.h
index 36bf4b55..ce6a34ec 100644
--- a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Combination_iterator.h
+++ b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Combination_iterator.h
@@ -83,7 +83,7 @@ public:
}
}
-protected:
+ private:
value_t value_; // the dereference value
bool is_end_; // is true when the current permutation is the final one
diff --git a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Integer_combination_iterator.h b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Integer_combination_iterator.h
index 8bf75711..c4e86a36 100644
--- a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Integer_combination_iterator.h
+++ b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Integer_combination_iterator.h
@@ -25,11 +25,11 @@ typedef unsigned uint;
* Based on the algorithm by Mifsud.
*/
class Integer_combination_iterator : public boost::iterator_facade< Integer_combination_iterator,
- std::vector<uint> const,
- boost::forward_traversal_tag> {
- typedef std::vector<uint> value_t;
+ std::vector<uint> const,
+ boost::forward_traversal_tag> {
+ using value_t = std::vector<uint>;
-protected:
+ private:
friend class boost::iterator_core_access;
bool equal(Integer_combination_iterator const& other) const {
@@ -71,7 +71,6 @@ protected:
}
public:
-
template <class Bound_range>
Integer_combination_iterator(const uint& n, const uint& k, const Bound_range& bounds)
:
@@ -109,8 +108,8 @@ public:
// Used for the creating an end iterator
Integer_combination_iterator() : is_end_(true), n_(0), k_(0) {}
-
-protected:
+
+ private:
value_t value_; // the dereference value
bool is_end_; // is true when the current integer combination is the final one
diff --git a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Ordered_set_partition_iterator.h b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Ordered_set_partition_iterator.h
index 73b98337..d6f9f121 100644
--- a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Ordered_set_partition_iterator.h
+++ b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Ordered_set_partition_iterator.h
@@ -13,8 +13,10 @@
#include <vector>
#include <limits>
+
#include <gudhi/Permutahedral_representation/Permutation_iterator.h>
#include <gudhi/Permutahedral_representation/Set_partition_iterator.h>
+
#include <boost/range/iterator_range.hpp>
namespace Gudhi {
@@ -48,11 +50,11 @@ struct Ordered_set_partition {
*
*/
class Ordered_set_partition_iterator : public boost::iterator_facade< Ordered_set_partition_iterator,
- Ordered_set_partition const,
- boost::forward_traversal_tag> {
- typedef Ordered_set_partition value_t;
+ Ordered_set_partition const,
+ boost::forward_traversal_tag> {
+ using value_t = Ordered_set_partition;
-protected:
+ private:
friend class boost::iterator_core_access;
bool equal(Ordered_set_partition_iterator const& other) const {
@@ -66,22 +68,19 @@ protected:
void increment() {
if (++value_.p_it_ == p_end_) {
if (++value_.s_it_ == s_end_) {
- is_end_ = true;
- return;
+ is_end_ = true;
+ return;
}
else
- value_.p_it_.reinitialize();
+ value_.p_it_.reinitialize();
}
}
-public:
-
+ public:
Ordered_set_partition_iterator(const uint& n, const uint& k)
:
value_({Set_partition_iterator(n,k), Permutation_iterator(k)}),
- is_end_(n == 0)
- {
- }
+ is_end_(n == 0) {}
// Used for the creating an end iterator
Ordered_set_partition_iterator() : is_end_(true) {}
@@ -92,7 +91,7 @@ public:
value_.s_it_.reinitialize();
}
-protected:
+ private:
Set_partition_iterator s_end_; // Set partition iterator and the corresponding end iterator
Permutation_iterator p_end_; // Permutation iterator and the corresponding end iterator
value_t value_; // the dereference value
diff --git a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Permutahedral_representation_iterators.h b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Permutahedral_representation_iterators.h
index e892b73b..d42e892a 100644
--- a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Permutahedral_representation_iterators.h
+++ b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Permutahedral_representation_iterators.h
@@ -20,7 +20,7 @@
#include <vector>
#include <iostream>
-#include <algorithm>
+#include <algorithm> // for std::find
namespace Gudhi {
@@ -37,15 +37,15 @@ namespace coxeter_triangulation {
* Forward iterator, 'value_type' is Permutahedral_representation::Vertex.*/
template <class Permutahedral_representation>
class Vertex_iterator : public boost::iterator_facade< Vertex_iterator<Permutahedral_representation>,
- typename Permutahedral_representation::Vertex const,
- boost::forward_traversal_tag> {
-protected:
+ typename Permutahedral_representation::Vertex const,
+ boost::forward_traversal_tag> {
+ private:
friend class boost::iterator_core_access;
using Vertex = typename Permutahedral_representation::Vertex;
using Ordered_partition = typename Permutahedral_representation::OrderedSetPartition;
- typedef Vertex value_t;
+ using value_t = Vertex;
bool equal(Vertex_iterator const& other) const {
@@ -60,12 +60,12 @@ protected:
std::size_t d = value_.size();
for (auto i: *o_it_)
if (i != d)
- value_[i]++;
+ value_[i]++;
else
- for (std::size_t j = 0; j < d; j++)
- value_[j]--;
+ for (std::size_t j = 0; j < d; j++)
+ value_[j]--;
}
-
+
void increment() {
if (is_end_)
return;
@@ -84,9 +84,8 @@ public:
{}
Vertex_iterator() : is_end_(true) {}
-
-
-protected:
+
+ private:
typename Ordered_partition::const_iterator o_it_, o_end_;
value_t value_;
bool is_end_;
@@ -100,11 +99,11 @@ protected:
* Forward iterator, value_type is Permutahedral_representation. */
template <class Permutahedral_representation>
class Face_iterator : public boost::iterator_facade< Face_iterator<Permutahedral_representation>,
- Permutahedral_representation const,
- boost::forward_traversal_tag> {
- typedef Permutahedral_representation value_t;
+ Permutahedral_representation const,
+ boost::forward_traversal_tag> {
+ using value_t = Permutahedral_representation;
-protected:
+ private:
friend class boost::iterator_core_access;
using Vertex = typename Permutahedral_representation::Vertex;
@@ -130,9 +129,8 @@ protected:
// Combination *c_it_ is supposed to be sorted in increasing order
value_ = face_from_indices<Permutahedral_representation>(simplex_, *c_it_);
}
-
+
public:
-
Face_iterator(const Permutahedral_representation& simplex, const uint& k)
: simplex_(simplex),
k_(k),
@@ -147,7 +145,7 @@ public:
// Used for the creating an end iterator
Face_iterator() : is_end_(true) {}
-protected:
+ private:
Permutahedral_representation simplex_; // Input simplex
uint k_;
uint l_; // Dimension of the input simplex
@@ -165,11 +163,11 @@ protected:
* Forward iterator, value_type is Permutahedral_representation. */
template <class Permutahedral_representation>
class Coface_iterator : public boost::iterator_facade< Coface_iterator<Permutahedral_representation>,
- Permutahedral_representation const,
- boost::forward_traversal_tag> {
- typedef Permutahedral_representation value_t;
-
-protected:
+ Permutahedral_representation const,
+ boost::forward_traversal_tag> {
+ using value_t = Permutahedral_representation;
+
+ private:
friend class boost::iterator_core_access;
using Vertex = typename Permutahedral_representation::Vertex;
@@ -187,20 +185,20 @@ protected:
uint i = 0;
for (; i < k_+1; i++) {
if (++(o_its_[i]) != o_end_)
- break;
+ break;
}
if (i == k_+1) {
if (++i_it_ == i_end_) {
- is_end_ = true;
- return;
+ is_end_ = true;
+ return;
}
o_its_.clear();
for (uint j = 0; j < k_ + 1; j++)
- o_its_.emplace_back(Ordered_set_partition_iterator(simplex_.partition()[j].size(), (*i_it_)[j]+1));
+ o_its_.emplace_back(Ordered_set_partition_iterator(simplex_.partition()[j].size(), (*i_it_)[j]+1));
}
else
for (uint j = 0; j < i; j++)
- o_its_[j].reinitialize();
+ o_its_[j].reinitialize();
update_value();
}
@@ -212,30 +210,29 @@ protected:
for (; u_ <= (*i_it_)[k_]; u_++) {
auto range = (*o_its_[k_])[u_];
if (std::find(range.begin(), range.end(), t_) != range.end())
- break;
+ break;
}
uint i = 0;
for (uint j = u_+1; j <= (*i_it_)[k_]; j++, i++)
for (uint b: (*o_its_[k_])[j]) {
- uint c = simplex_.partition()[k_][b];
+ uint c = simplex_.partition()[k_][b];
value_.partition()[i].push_back(c);
- value_.vertex()[c]--;
+ value_.vertex()[c]--;
}
for (uint h = 0; h < k_; h++)
for (uint j = 0; j <= (*i_it_)[h]; j++, i++) {
- for (uint b: (*o_its_[h])[j])
- value_.partition()[i].push_back(simplex_.partition()[h][b]);
+ for (uint b: (*o_its_[h])[j])
+ value_.partition()[i].push_back(simplex_.partition()[h][b]);
}
for (uint j = 0; j <= u_; j++, i++)
for (uint b: (*o_its_[k_])[j])
- value_.partition()[i].push_back(simplex_.partition()[k_][b]);
+ value_.partition()[i].push_back(simplex_.partition()[k_][b]);
// sort the values in each part (probably not needed)
for (auto& part: value_.partition())
std::sort(part.begin(), part.end());
}
-
-public:
-
+
+ public:
Coface_iterator(const Permutahedral_representation& simplex, const uint& l)
: simplex_(simplex),
d_(simplex.vertex().size()),
@@ -248,8 +245,8 @@ public:
uint j = 0;
for (; j < simplex_.partition()[k_].size(); j++)
if (simplex_.partition()[k_][j] == d_) {
- t_ = j;
- break;
+ t_ = j;
+ break;
}
if (j == simplex_.partition()[k_].size()) {
std::cerr << "Coface iterator: the argument simplex is not a permutahedral representation\n";
@@ -263,8 +260,8 @@ public:
// Used for the creating an end iterator
Coface_iterator() : is_end_(true) {}
-
-protected:
+
+ private:
Permutahedral_representation simplex_; // Input simplex
uint d_; // Ambient dimension
uint l_; // Dimension of the coface
diff --git a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Permutation_iterator.h b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Permutation_iterator.h
index ed1fb337..e0142bf4 100644
--- a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Permutation_iterator.h
+++ b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Permutation_iterator.h
@@ -11,7 +11,9 @@
#ifndef PERMUTAHEDRAL_REPRESENTATION_PERMUTATION_ITERATOR_H_
#define PERMUTAHEDRAL_REPRESENTATION_PERMUTATION_ITERATOR_H_
+#include <cstdlib> // for std::size_t
#include <vector>
+
#include <boost/range/iterator_range.hpp>
namespace Gudhi {
@@ -24,11 +26,11 @@ typedef unsigned uint;
* Based on the optimization of the Heap's algorithm by Sedgewick.
*/
class Permutation_iterator : public boost::iterator_facade< Permutation_iterator,
- std::vector<uint> const,
- boost::forward_traversal_tag> {
- typedef std::vector<uint> value_t;
+ std::vector<uint> const,
+ boost::forward_traversal_tag> {
+ using value_t = std::vector<uint>;
-protected:
+ private:
friend class boost::iterator_core_access;
bool equal(Permutation_iterator const& other) const {
@@ -70,12 +72,12 @@ protected:
ct_ = 5;
uint j = 2;
while (d_[j] == j+1) {
- d_[j] = 0;
- ++j;
+ d_[j] = 0;
+ ++j;
}
if (j == n_ - 1) {
- is_end_ = true;
- return;
+ is_end_ = true;
+ return;
}
uint k = j+1;
uint x = (k%2 ? d_[j] : 0);
@@ -117,8 +119,8 @@ public:
if (n_ > 0)
is_end_ = false;
}
-
-protected:
+
+ private:
value_t value_; // the dereference value
bool is_end_; // is true when the current permutation is the final one
bool optim_3_; // true if n>=3. for n >= 3, the algorithm is optimized
diff --git a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Set_partition_iterator.h b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Set_partition_iterator.h
index 26bbc1ef..bd1770bc 100644
--- a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Set_partition_iterator.h
+++ b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Set_partition_iterator.h
@@ -25,11 +25,11 @@ typedef unsigned uint;
*
*/
class Set_partition_iterator : public boost::iterator_facade< Set_partition_iterator,
- std::vector<std::vector<uint> > const,
- boost::forward_traversal_tag> {
- typedef std::vector<std::vector<uint> > value_t;
-
-protected:
+ std::vector<std::vector<uint> > const,
+ boost::forward_traversal_tag> {
+ using value_t = std::vector<std::vector<uint>>;
+
+ private:
friend class boost::iterator_core_access;
bool equal(Set_partition_iterator const& other) const {
@@ -54,7 +54,7 @@ protected:
}
uint i = n_ - 1;
while (rgs_[i] + 1 > max_[i] ||
- rgs_[i] + 1 >= k_)
+ rgs_[i] + 1 >= k_)
i--;
if (i == 0) {
is_end_ = true;
@@ -71,16 +71,15 @@ protected:
uint p = k_;
if (mm < p)
do {
- max_[i] = p;
- --i;
- --p;
- rgs_[i] = p;
+ max_[i] = p;
+ --i;
+ --p;
+ rgs_[i] = p;
} while (max_[i] < p);
update_value();
}
-public:
-
+ public:
Set_partition_iterator(const uint& n, const uint& k)
:
value_(k),
@@ -116,12 +115,12 @@ public:
max_[i] = rgs_[i-1] + 1;
update_value();
}
-
-protected:
+
+ private:
value_t value_; // the dereference value
std::vector<uint> rgs_; // restricted growth string
std::vector<uint> max_; // max_[i] = max(rgs_[0],...,rgs[i-1]) + 1
- bool is_end_; // is true when the current permutation is the final one
+ bool is_end_; // is true when the current permutation is the final one
uint n_;
uint k_;
diff --git a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Size_range.h b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Size_range.h
index 262915fb..f41335e9 100644
--- a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Size_range.h
+++ b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/Size_range.h
@@ -11,8 +11,9 @@
#ifndef PERMUTAHEDRAL_REPRESENTATION_SIZE_RANGE_H_
#define PERMUTAHEDRAL_REPRESENTATION_SIZE_RANGE_H_
+#include <cstdlib> // for std::size_t
+
#include <boost/range/iterator_range.hpp>
-#include <cstdlib> // std::size_t
namespace Gudhi {
@@ -22,11 +23,11 @@ namespace coxeter_triangulation {
*/
template <class T_it>
class Size_iterator : public boost::iterator_facade< Size_iterator<T_it>,
- std::size_t const,
- boost::forward_traversal_tag> {
+ std::size_t const,
+ boost::forward_traversal_tag> {
friend class boost::iterator_core_access;
-protected:
+ private:
bool equal(Size_iterator const& other) const {
return (is_end_ && other.is_end_);
}
@@ -43,15 +44,14 @@ protected:
value_ = t_it_->size()-1;
}
-public:
-
+ public:
Size_iterator(const T_it& t_begin, const T_it& t_end)
: t_it_(t_begin), t_end_(t_end), is_end_(t_begin == t_end) {
if (!is_end_)
value_ = t_it_->size()-1;
}
-protected:
+ private:
T_it t_it_, t_end_;
bool is_end_;
std::size_t value_;
@@ -61,7 +61,7 @@ template <class T>
class Size_range {
const T& t_;
-public:
+ public:
typedef Size_iterator<typename T::const_iterator> iterator;
Size_range(const T& t) : t_(t) {}
diff --git a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/face_from_indices.h b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/face_from_indices.h
index c658a06d..21ee3c8b 100644
--- a/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/face_from_indices.h
+++ b/src/Coxeter_triangulation/include/gudhi/Permutahedral_representation/face_from_indices.h
@@ -15,6 +15,9 @@ namespace Gudhi {
namespace coxeter_triangulation {
+#include <cstdlib> // for std::size_t
+#include <algorithm>
+
/** \brief Computes the permutahedral representation of a face of a given simplex
* and a range of the vertex indices that compose the face.
*
@@ -25,10 +28,9 @@ namespace coxeter_triangulation {
* @param[in] simplex Input simplex.
* @param[in] indices Input range of indices.
*/
-template <class Permutahedral_representation,
- class Index_range>
+template <class Permutahedral_representation, class Index_range>
Permutahedral_representation face_from_indices(const Permutahedral_representation& simplex,
- const Index_range& indices) {
+ const Index_range& indices) {
using range_index = typename Index_range::value_type;
using Ordered_set_partition = typename Permutahedral_representation::OrderedSetPartition;
using Part = typename Ordered_set_partition::value_type;