Gudhi::Points_3D_off_reader< Point_3 > Class Template Reference

Public Member Functions

 Points_3D_off_reader (const std::string &name_file)
 Reads the OFF file and constructs a vector of points from the points that are in the OFF file. More...
 
bool is_valid () const
 Returns if the OFF file read operation was successful or not. More...
 
const std::vector< Point_3 > & get_point_cloud () const
 Point cloud getter. More...
 

Detailed Description

template<typename Point_3>
class Gudhi::Points_3D_off_reader< Point_3 >

@brief OFF file reader implementation in order to read dimension 3 points from an OFF file.

This class is using the Points_3D_off_visitor_reader to visit the OFF file according to Off_reader.

Point_3 must have a constructor with the following form:

template<class InputIterator > Point_3::Point_3(double x, double y, double z)

Example

This example loads points from an OFF file and builds a vector of CGAL points in dimension 3. Then, it is asked to display the points.

#include <gudhi/Points_3D_off_io.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <iostream>
#include <string>
#include <vector>
using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
using Point_3 = Kernel::Point_3;
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 offInputFile(argv[1]);
// Read the OFF file (input file name given as parameter) and triangulate points
Gudhi::Points_3D_off_reader<Point_3> off_reader(offInputFile);
// Check the read operation was correct
if (!off_reader.is_valid()) {
std::cerr << "Unable to read file " << offInputFile << std::endl;
usage(argv[0]);
}
// Retrieve the triangulation
std::vector<Point_3> point_cloud = off_reader.get_point_cloud();
int n {};
for (auto point : point_cloud) {
++n;
std::cout << "Point[" << n << "] = (" << point[0] << ", " << point[1] << ", " << point[2] << ")\n";
}
return 0;
}

When launching:

$> ./cgal3Doffreader ../../data/points/tore3D_300.off

the program output is:

Point[1] = (0.959535, -0.418347, 0.302237)
Point[2] = (2.16795, 1.85348, -0.52312)
Point[3] = (-2.38753, -1.50911, -0.565889)
Point[4] = (-2.70428, -1.25688, 0.188394)
Point[5] = (-1.22932, -1.64337, -0.998632)
...
Point[300] = (-0.56244, 2.6018, -0.749591)
Examples:
common/example_CGAL_3D_points_off_reader.cpp, Persistent_cohomology/alpha_complex_3d_persistence.cpp, Persistent_cohomology/exact_alpha_complex_3d_persistence.cpp, Persistent_cohomology/periodic_alpha_complex_3d_persistence.cpp, Persistent_cohomology/weighted_alpha_complex_3d_persistence.cpp, and Simplex_tree/example_alpha_shapes_3_simplex_tree_from_off_file.cpp.

Constructor & Destructor Documentation

template<typename Point_3>
Gudhi::Points_3D_off_reader< Point_3 >::Points_3D_off_reader ( const std::string &  name_file)
inline

Reads the OFF file and constructs a vector of points from the points that are in the OFF file.

Parameters
[in]name_fileOFF file to read.
Postcondition
Check with is_valid() function to see if read operation was successful.

Member Function Documentation

template<typename Point_3>
const std::vector<Point_3>& Gudhi::Points_3D_off_reader< Point_3 >::get_point_cloud ( ) const
inline

Point cloud getter.

Returns
point_cloud.
template<typename Point_3>
bool Gudhi::Points_3D_off_reader< Point_3 >::is_valid ( ) const
inline

Returns if the OFF file read operation was successful or not.

Returns
OFF file read status.

The documentation for this class was generated from the following file:
GUDHI  Version 2.0.0  - C++ library for Topological Data Analysis (TDA) and Higher Dimensional Geometry Understanding. Generated on Wed Apr 19 2017 22:26:16 for GUDHI by doxygen 1.8.11