All Classes Functions Variables Typedefs Friends Groups Pages
Gudhi::Points_off_reader< Point_d > Class Template Reference

OFF file reader implementation in order to read points from an OFF file. More...

#include <gudhi/Points_off_io.h>

Public Member Functions

 Points_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_d > & get_point_cloud () const
 Point cloud getter. More...
 

Detailed Description

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 CGAL points in dimension d. Then, it is asked to display the points.

#include <gudhi/Points_off_io.h>
// For CGAL points type in dimension d
// cf. http://doc.cgal.org/latest/Kernel_d/classCGAL_1_1Point__d.html
#include <CGAL/Epick_d.h>
#include <iostream>
#include <string>
#include <vector>
using Kernel = CGAL::Epick_d< CGAL::Dynamic_dimension_tag >;
using Point_d = typename Kernel::Point_d;
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_off_reader<Point_d> 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_d> point_cloud = off_reader.get_point_cloud();
int n {0};
for (auto point : point_cloud) {
std::cout << "Point[" << n << "] = ";
for (int i {0}; i < point.dimension(); i++)
std::cout << point[i] << " ";
std::cout << "\n";
++n;
}
return 0;
}

When launching:

$> ./cgaloffreader ../../data/points/alphacomplexdoc.off

the program output is:

Point[0] = 1 1
Point[1] = 7 0
Point[2] = 4 6
Point[3] = 9 6
Point[4] = 0 14
Point[5] = 2 19
Point[6] = 9 17
Examples:
common/CGAL_points_off_reader.cpp.

Constructor & Destructor Documentation

template<typename Point_d>
Gudhi::Points_off_reader< Point_d >::Points_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_d>
const std::vector<Point_d>& Gudhi::Points_off_reader< Point_d >::get_point_cloud ( ) const
inline

Point cloud getter.

Returns
point_cloud.
template<typename Point_d>
bool Gudhi::Points_off_reader< Point_d >::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 1.3.0  - C++ library for Topological Data Analysis (TDA) and Higher Dimensional Geometry Understanding. Generated on Fri Apr 15 2016 17:36:21 for GUDHI by doxygen 1.8.6