template<typename Point_d>
class Gudhi::Points_off_reader< Point_d >
OFF file reader implementation in order to read points from an OFF file.
This class is using the Points_off_visitor_reader to visit the OFF file according to Off_reader.
Point_d must have a constructor with the following form:
template<class InputIterator > Point_d::Point_d(int d, InputIterator first, InputIterator last)
where d is the point dimension.
Example
This example loads points from an OFF file and builds a vector of points (vector of double). Then, it is asked to display the points.
#include <gudhi/Points_off_io.h>
#include <iostream>
#include <string>
#include <vector>
using Point_d = std::vector<double>;
void usage(char * const progName) {
std::cerr << "Usage: " << progName << " inputFile.off" << std::endl;
exit(-1);
}
int main(int argc, char **argv) {
if (argc != 2) {
std::cerr << "Error: Number of arguments (" << argc << ") is not correct" << std::endl;
usage(argv[0]);
}
std::string off_input_file(argv[1]);
if (!off_reader.is_valid()) {
std::cerr << "Unable to read file " << off_input_file << std::endl;
usage(argv[0]);
}
std::vector<Point_d> point_cloud = off_reader.get_point_cloud();
std::ofstream output_file(off_input_file + ".txt");
int n {0};
for (auto point : point_cloud) {
output_file << "Point[" << n << "] = ";
for (std::size_t i {0}; i < point.size(); i++)
output_file << point[i] << " ";
output_file << "\n";
++n;
}
output_file.close();
return 0;
}
OFF file reader implementation in order to read points from an OFF file.
Definition: Points_off_io.h:122
When launching:
$> ./vector_double_off_reader ../../data/points/alphacomplexdoc.off
the program outputs a file ../../data/points/alphacomplexdoc.off.txt:
Point[0] = 1 1 0
Point[1] = 7 0 0
Point[2] = 4 6 0
Point[3] = 9 6 0
Point[4] = 0 14 0
Point[5] = 2 19 0
Point[6] = 9 17 0
- Examples
- alpha_complex_persistence.cpp, alpha_rips_persistence_bottleneck_distance.cpp, cech_complex_cgal_mini_sphere_3d.cpp, cech_persistence.cpp, edge_collapse_conserve_persistence.cpp, example_CGAL_points_off_reader.cpp, example_rips_complex_from_off_file.cpp, example_strong_witness_complex_off.cpp, example_vector_double_points_off_reader.cpp, example_witness_complex_off.cpp, point_cloud_edge_collapse_rips_persistence.cpp, rips_multifield_persistence.cpp, rips_persistence.cpp, rips_persistence_step_by_step.cpp, rips_persistence_via_boundary_matrix.cpp, sparse_rips_persistence.cpp, strong_witness_persistence.cpp, and weak_witness_persistence.cpp.