#include <iostream>
#include <chrono>
#include <type_traits>
#include <typeinfo>
#include <CGAL/HDVF/Zp.h>
#include <CGAL/HDVF/Z2.h>
#include <CGAL/HDVF/Simplex.h>
#include <CGAL/HDVF/Simplicial_chain_complex.h>
#include <CGAL/HDVF/Cubical_chain_complex.h>
#include <CGAL/HDVF/Geometric_chain_complex_tools.h>
#include <CGAL/HDVF/Hdvf.h>
#include <CGAL/OSM/OSM.h>
#include <CGAL/OSM/Sparse_chain.h>
#include <CGAL/HDVF/Mesh_object_io.h>
#include <CGAL/HDVF/Cub_object_io.h>
#include <CGAL/HDVF/Hdvf_tools.h>
#include "arguments.h"
template <typename MeshType, typename ComplexType>
void mesh_complex_output(const MeshType& mesh, const ComplexType& complex, const Options& options)
{
if (options.with_output)
{
std::cout << "----> mesh informations" << std::endl ;
mesh.print_infos() ;
std::cout << "----> complex informations" << std::endl ;
complex.print_complex();
}
}
template <typename CoefficientType, typename ComplexType>
{
std::vector<CGAL::HDVF::PairCell> pairs ;
if (!options.random)
pairs = hdvf.compute_perfect_hdvf(options.verbose);
else
pairs = hdvf.compute_rand_perfect_hdvf(options.verbose);
if (options.with_output)
{
std::cout << "----> pairs found by computePerfectHDVF" << std::endl ;
std::cout << pairs ;
std::cout << "----> reduction" << std::endl ;
hdvf.print_reduction() ;
}
if (options.with_export)
{
std::string file(options.outfile_root+"_reduction.txt") ;
std::ofstream out ( file, std::ios::out | std::ios::trunc);
if ( not out . good () ) {
std::cerr << "hdvf: with_export. Fatal Error:\n " << file << " not found.\n";
throw std::runtime_error("File Parsing Error: File not found");
}
out << "----> pairs found by computePerfectHDVF" << std::endl ;
out << pairs ;
out << "----> reduction" << std::endl ;
hdvf.print_reduction(out) ;
out.close() ;
}
return hdvf ;
}
template <typename CoefficientType>
void main_code (const Options &options)
{
if (options.in_format == InputFormat::SIMP)
{
ComplexType complex(mesh);
mesh_complex_output<CGAL::HDVF::Mesh_object_io, ComplexType>(mesh, complex, options) ;
HDVFType hdvf(HDVF_comput<CoefficientType,ComplexType>(complex, options)) ;
}
else if (options.in_format == InputFormat::OFF)
{
mesh_complex_output<CGAL::HDVF::Mesh_object_io, ComplexType>(mesh, complex, options) ;
HDVFType hdvf(HDVF_comput<CoefficientType,ComplexType>(complex, options)) ;
if (options.loop)
{
auto output_vtk_simp = [options](HDVFType &hdvf, ComplexType& complex)
{
} ;
CGAL::HDVF::interaction_loop<CoefficientType, ComplexType>(hdvf, complex, output_vtk_simp) ;
}
else if (options.with_vtk_export)
{
std::cout << "----> exporting to vtk" << std::endl ;
}
}
else if ((options.in_format == InputFormat::PGM) || (options.in_format == InputFormat::CUB))
{
typename ComplexType::typeComplexCube primal_dual(ComplexType::PRIMAL) ;
if (options.primal)
{
if (options.in_format == InputFormat::PGM)
else
}
else
{
if (options.in_format == InputFormat::PGM)
else
primal_dual = ComplexType::DUAL ;
}
ComplexType complex(mesh, primal_dual);
mesh_complex_output<CGAL::HDVF::Cub_object_io, ComplexType>(mesh, complex, options) ;
HDVFType hdvf(HDVF_comput<CoefficientType,ComplexType>(complex, options)) ;
if (options.loop)
{
auto output_vtk_cub = [options](HDVFType &hdvf, ComplexType& complex)
{
} ;
CGAL::HDVF::interaction_loop<CoefficientType, ComplexType>(hdvf, complex, output_vtk_cub) ;
}
else if (options.with_vtk_export)
{
std::cout << "----> exporting to vtk" << std::endl ;
}
}
}
int main(int argc, char **argv)
{
if (argc <= 2)
usage() ;
else
{
for (int i=0;i<argc; ++i)
std::cout << "arg " << i << " : " << argv[i] << std::endl ;
Options options(read_arguments_hdvf(argc, argv)) ;
std::cout << "options:" << std::endl << options ;
std::cout << "TEST" << std::endl ;
std::cout << "before: " << gamma.is_null() << std::endl ;
gamma.set_coef(2, 1) ;
std::cout << "after: " << gamma.is_null() << std::endl ;
gamma.set_coef(2, 0) ;
std::cout << "after2: " << gamma.is_null() << std::endl ;
std::cout << "END TEST" << std::endl ;
#ifndef SCALAR
if (options.scalar == 0)
{
using CoefficientType = int ;
main_code<CoefficientType>(options) ;
}
else if (options.scalar == 2)
{
main_code<CoefficientType>(options) ;
}
else
{
std::cerr << "Z" << options.scalar << " not instantiated, use the #define at line 27" << std::endl ;
}
#else
typedef Zp<SCALAR> CoefficientType;
#endif
}
return 0 ;
}
The class Abstract_simplicial_chain_complex represents (topological) chain complexes associated to ab...
Definition: Abstract_simplicial_chain_complex.h:53
The class Cub_object_io is an intermediate IO class, used to load binary volumes and produce cubical ...
Definition: Cub_object_io.h:44
bool read_cub(const std::string &filename, bool khalimsky=false)
Definition: Cub_object_io.h:173
bool read_pgm(const std::string &filename, bool khal=false)
Definition: Cub_object_io.h:97
The class Cubical_chain_complex represents (topological) chain complexes associated to cubical comple...
Definition: Cubical_chain_complex.h:93
The class Hdvf implements homology and cohomology computation via homological discrete vector fields ...
Definition: Hdvf.h:86
The class Mesh_object_io is an intermediate IO class, used to load triangular/tetraedral meshes and p...
Definition: Mesh_object_io.h:201
std::vector< std::vector< double > > get_nodes()
Definition: Mesh_object_io.h:321
bool read_off(const std::string &filename)
Definition: Mesh_object_io.h:369
bool read_simp(const std::string &filename)
Definition: Mesh_object_io.h:492
The class Simplicial_chain_complex refines the Abstract_simplicial_chain_complex class by assigning c...
Definition: Simplicial_chain_complex.h:42
The class Z2 implements the concept Ring with the field .
Definition: Z2.h:33
The class Sparse_chain implements the concept SparseChain, that is, sparse vectors (encoding homologi...
Definition: Sparse_chain.h:52
void hdvf_geometric_chain_complex_output_vtk(Hdvf_core< CoefType, ComplexType, _ChainType, _SparseMatrixType > &hdvf, ComplexType &complex, string filename="test", bool co_faces=false)
Exports all the Hdvf information of a geometric chain complex to vtk files.
Definition: Geometric_chain_complex_tools.h:73