gudhi-devel icon indicating copy to clipboard operation
gudhi-devel copied to clipboard

[Coxeter triangulation] The use of the Cell complex should not be advertised

Open VincentRouvreau opened this issue 2 years ago • 0 comments

In the basic example for Coxeter, we advertise the use of the Cell complex, but we wanted to hide it from the user.

We could rewrite the example as:

#include <iostream>

#include <gudhi/Coxeter_triangulation.h>
#include <gudhi/Implicit_manifold_intersection_oracle.h>  // for Gudhi::coxeter_triangulation::make_oracle
#include <gudhi/Manifold_tracing.h>
#include <gudhi/Functions/Function_Sm_in_Rd.h>

using namespace Gudhi::coxeter_triangulation;

int main(int argc, char** argv) {
  // Oracle is a circle of radius 1
  double radius = 1.;
  auto oracle = make_oracle(Function_Sm_in_Rd(radius, 1)); 

  // Define a Coxeter triangulation.
  Coxeter_triangulation<> cox_tr(oracle.amb_d());
  // Theory forbids that a vertex of the triangulation lies exactly on the circle.
  // Add some offset to avoid algorithm degeneracies.
  cox_tr.change_offset(-Eigen::VectorXd::Random(oracle.amb_d()));
  // For a better manifold approximation, one can change the circle radius value or change the linear transformation
  // matrix.
  // The number of points and edges will increase with a better resolution.
  //cox_tr.change_matrix(0.5 * cox_tr.matrix());

  // Manifold tracing algorithm
  using Out_simplex_map = typename Manifold_tracing<Coxeter_triangulation<> >::Out_simplex_map;

  std::vector<Eigen::VectorXd> seed_points(1, oracle.seed());
  Out_simplex_map interior_simplex_map;
  manifold_tracing_algorithm(seed_points, cox_tr, oracle, interior_simplex_map);

  using Simplex_handle = typename Out_simplex_map::key_type;
  auto cod_d_ = interior_simplex_map.begin()->first.dimension();
  for (auto& os_pair : interior_simplex_map) {
    const Simplex_handle& simplex = os_pair.first;
    const Eigen::VectorXd& point = os_pair.second;
    std::cout << "point= (" << point[0] << ", "<< point[1] << ") - simplex= " << simplex << std::endl;
    for (Simplex_handle coface : simplex.coface_range(cod_d_ + 1))
      std::cout << "  coface= " << coface << std::endl;
  }

  return 0;
}

That ouputs:

point= (-0.680375, 0.523483) - simplex= (0, 0) [{0}, {1, 2}]
  coface= (0, 0) [{0}, {1}, {2}]
  coface= (0, -1) [{1}, {0}, {2}]
point= (-0.847996, 0.30801) - simplex= (0, -1) [{1}, {0, 2}]
  coface= (0, -1) [{1}, {0}, {2}]
  coface= (-1, -1) [{0}, {1}, {2}]
point= (0.147642, 0.887879) - simplex= (1, 0) [{1}, {0, 2}]
  coface= (1, 0) [{1}, {0}, {2}]
  coface= (0, 0) [{0}, {1}, {2}]
point= (-0.680375, -0.461325) - simplex= (-1, 0) [{0}, {1, 2}]
  coface= (-1, 0) [{0}, {1}, {2}]
  coface= (-1, -1) [{1}, {0}, {2}]
point= (-0.364269, -0.760962) - simplex= (-1, 0) [{0, 1}, {2}]
  coface= (-1, 0) [{0}, {1}, {2}]
  coface= (-1, 0) [{1}, {0}, {2}]
point= (-0.881369, 0.0951903) - simplex= (-1, -1) [{0, 1}, {2}]
  coface= (-1, -1) [{0}, {1}, {2}]
  coface= (-1, -1) [{1}, {0}, {2}]
point= (0.319625, 0.889605) - simplex= (1, 1) [{0}, {1, 2}]
  coface= (1, 1) [{0}, {1}, {2}]
  coface= (1, 0) [{1}, {0}, {2}]
point= (0.415344, 0.843848) - simplex= (1, 1) [{0, 1}, {2}]
  coface= (1, 1) [{0}, {1}, {2}]
  coface= (1, 1) [{1}, {0}, {2}]
point= (0.579487, 0.638553) - simplex= (1, 1) [{1}, {0, 2}]
  coface= (1, 1) [{1}, {0}, {2}]
  coface= (0, 1) [{0}, {1}, {2}]
point= (0.319625, -0.7709) - simplex= (-1, 1) [{0}, {1, 2}]
  coface= (-1, 1) [{0}, {1}, {2}]
  coface= (-1, 0) [{1}, {0}, {2}]
point= (0.812453, -0.0815816) - simplex= (0, 1) [{0, 1}, {2}]
  coface= (0, 1) [{0}, {1}, {2}]
  coface= (0, 1) [{1}, {0}, {2}]
point= (0.638494, -0.550215) - simplex= (0, 1) [{1}, {0, 2}]
  coface= (0, 1) [{1}, {0}, {2}]
  coface= (-1, 1) [{0}, {1}, {2}]

VincentRouvreau avatar Nov 30 '22 07:11 VincentRouvreau