22 #ifndef SKELETON_BLOCKER_SKELETON_BLOCKER_OFF_IO_H_
23 #define SKELETON_BLOCKER_SKELETON_BLOCKER_OFF_IO_H_
25 #include <gudhi/Off_reader.h>
38 template<
typename Complex>
42 typedef typename Complex::Point Point;
44 const bool load_only_points_;
49 load_only_points_(load_only_points) { }
51 void init(
int dim,
int num_vertices,
int num_faces,
int num_edges) {
56 void point(
const std::vector<double>& point) {
57 complex_.
add_vertex(Point(point.begin(), point.end()));
60 void maximal_face(
const std::vector<int>& face) {
61 if (!load_only_points_) {
62 for (
size_t i = 0; i < face.size(); ++i)
63 for (
size_t j = i + 1; j < face.size(); ++j) {
75 template<
typename Complex>
79 typedef typename Complex::Simplex_handle Simplex_handle;
80 typedef typename Complex::Point Point;
82 const bool load_only_points_;
83 std::vector<Point> points_;
84 std::vector<Simplex_handle> maximal_faces_;
89 load_only_points_(load_only_points) { }
91 void init(
int dim,
int num_vertices,
int num_faces,
int num_edges) {
92 maximal_faces_.reserve(num_faces);
93 points_.reserve(num_vertices);
96 void point(
const std::vector<double>& point) {
97 points_.emplace_back(point.begin(), point.end());
100 void maximal_face(
const std::vector<int>& face) {
101 if (!load_only_points_) {
105 maximal_faces_.emplace_back(s);
110 complex_ = make_complex_from_top_faces<Complex>(maximal_faces_.begin(), maximal_faces_.end(),
111 points_.begin(), points_.end() );
118 template<
typename Complex>
127 bool read_only_points =
false,
bool is_flag =
false) : valid_(false) {
128 std::ifstream stream(name_file);
129 if (stream.is_open()) {
130 if (is_flag || read_only_points) {
133 valid_ = off_reader.
read(off_visitor);
137 valid_ = off_reader.
read(off_visitor);
153 template<
typename Complex>
154 class Skeleton_blocker_off_writer {
161 Skeleton_blocker_off_writer(
const std::string & name_file,
const Complex& save_complex) {
164 std::ofstream stream(name_file);
165 if (stream.is_open()) {
168 stream << save_complex.num_vertices() <<
" " << num_triangles <<
" 0 \n";
172 std::map<Vertex_handle, size_t> vertex_num;
173 size_t current_vertex = 0;
176 vertex_num[v] = current_vertex++;
177 const auto& pt(save_complex.
point(v));
186 stream << vertex_num[x] <<
" ";
191 std::cerr <<
"could not open file " << name_file << std::endl;
200 #endif // SKELETON_BLOCKER_SKELETON_BLOCKER_OFF_IO_H_
Skeleton_blocker_off_reader(const std::string &name_file, Complex &read_complex, bool read_only_points=false, bool is_flag=false)
Definition: Skeleton_blocker_off_io.h:126
Class that allows to load a Skeleton_blocker_complex from an off file.
Definition: Skeleton_blocker_off_io.h:119
bool read(OffVisitor &off_visitor)
Definition: Off_reader.h:70
Vertex_handle add_vertex()
Add a vertex to the complex with a default constructed associated point.
Definition: Skeleton_blocker_geometric_complex.h:96
Off reader visitor that can be passed to Off_reader to read a Skeleton_blocker_complex.
Definition: Skeleton_blocker_off_io.h:39
const Point & point(Vertex_handle v) const
Returns the Point associated to the vertex v.
Definition: Skeleton_blocker_geometric_complex.h:112
Definition: Off_reader.h:49
bool is_valid() const
Definition: Skeleton_blocker_off_io.h:145
Edge_handle add_edge(Vertex_handle a, Vertex_handle b)
Adds an edge between vertices a and b and all its cofaces.
Definition: Skeleton_blocker_complex.h:546
Complex_vertex_range vertex_range() const
Returns a Complex_vertex_range over all vertices of the complex.
Definition: Skeleton_blocker_complex.h:1245
Off reader visitor that can be passed to Off_reader to read a Skeleton_blocker_complex.
Definition: Skeleton_blocker_off_io.h:76
Complex_triangle_around_vertex_range triangle_range(Vertex_handle v) const
Range over triangles around a vertex of the simplicial complex. Methods .begin() and ...
Definition: Skeleton_blocker_complex.h:1321
Definition: SkeletonBlockerDS.h:60