Loading...
Searching...
No Matches
Gudhi::Points_3D_off_reader< Point_3 > Class Template Reference

#include <include/gudhi/Points_3D_off_io.h>

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 off_input_file(argv[1]);
// Read the OFF file (input file name given as parameter) and triangulate points
Gudhi::Points_3D_off_reader<Point_3> off_reader(off_input_file);
// Check the read operation was correct
if (!off_reader.is_valid()) {
std::cerr << "Unable to read file " << off_input_file << 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::clog << "Point[" << n << "] = (" << point[0] << ", " << point[1] << ", " << point[2] << ")\n";
}
return 0;
}
Definition: Points_3D_off_io.h:140

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
alpha_complex_3d_persistence.cpp, example_CGAL_3D_points_off_reader.cpp, and example_alpha_shapes_3_simplex_tree_from_off_file.cpp.

Constructor & Destructor Documentation

◆ Points_3D_off_reader()

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

◆ get_point_cloud()

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.

◆ is_valid()

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: