EZC3D
Points.cpp
Go to the documentation of this file.
1 #define EZC3D_API_EXPORTS
2 
10 #include "Points.h"
11 
12 // Point3d data
14 {
15 
16 }
17 
19 {
20  _points.resize(nbPoints);
21 }
22 
24 {
25  for (size_t i = 0; i < nbPoints(); ++i)
26  point(i).print();
27 }
28 
29 void ezc3d::DataNS::Points3dNS::Points::write(std::fstream &f) const
30 {
31  for (size_t i = 0; i < nbPoints(); ++i)
32  point(i).write(f);
33 }
34 
36 {
37  return _points.size();
38 }
39 
41 {
42  try {
43  return _points.at(idx);
44  } catch(std::out_of_range) {
45  throw std::out_of_range("Points::point method is trying to access the point "
46  + std::to_string(idx) +
47  " while the maximum number of points is "
48  + std::to_string(nbPoints()) + ".");
49  }
50 }
51 
53 {
54  try {
55  return _points.at(idx);
56  } catch(std::out_of_range) {
57  throw std::out_of_range("Points::point method is trying to access the point "
58  + std::to_string(idx) +
59  " while the maximum number of points is "
60  + std::to_string(nbPoints()) + ".");
61  }
62 }
63 
65 {
66  if (idx == SIZE_MAX)
67  _points.push_back(point);
68  else{
69  if (idx >= nbPoints())
70  _points.resize(idx+1);
71  _points[idx] = point;
72  }
73 }
74 
75 const std::vector<ezc3d::DataNS::Points3dNS::Point> &ezc3d::DataNS::Points3dNS::Points::points() const
76 {
77  return _points;
78 }
79 
81 {
82  for (Point point : points())
83  if (!point.isempty())
84  return false;
85  return true;
86 }
const std::vector< ezc3d::DataNS::Points3dNS::Point > & points() const
Get all the points from the 3D points data.
Definition: Points.cpp:75
ezc3d::DataNS::Points3dNS::Point & point_nonConst(size_t idx)
Get a particular point of index idx from the 3D points data in order to be modified by the caller...
Definition: Points.cpp:52
Declaration of Points class.
void write(std::fstream &f) const
Write points to an opened file.
Definition: Points.cpp:29
void print() const
Print the points.
Definition: Points.cpp:23
size_t nbPoints() const
Get the number of points.
Definition: Points.cpp:35
Points()
Create an empty holder for 3D points.
Definition: Points.cpp:13
bool isempty() const
Return if the points are empty.
Definition: Points.cpp:80
const ezc3d::DataNS::Points3dNS::Point & point(size_t idx) const
Get a particular point of index idx from the 3D points data.
Definition: Points.cpp:40