21 #ifndef MIRTK_PointSet_H 22 #define MIRTK_PointSet_H 24 #include "mirtk/Object.h" 26 #include "mirtk/Memory.h" 27 #include "mirtk/Cfstream.h" 28 #include "mirtk/Point.h" 29 #include "mirtk/Array.h" 30 #include "mirtk/OrderedSet.h" 32 #include "mirtk/NumericsExport.h" 36 class vtkAbstractArray;
63 MIRTK_Numerics_EXPORT
static int POINTSET_SIZE;
117 void Clear(
bool deallocate =
true);
132 void GetPoint(
int,
double [3])
const;
138 void SetPoint(
int,
const double [3]);
216 void Read(
const char *);
219 void Write(
const char *)
const;
229 void AddVTK(
const char *);
234 void WriteVTK(
const char *, vtkAbstractArray * = NULL)
const;
260 ostream &operator <<(ostream &,
const PointSet &);
263 istream &operator >>(istream &,
PointSet &);
280 _m(0), _n(0), _data(NULL)
289 _m(0), _n(0), _data(NULL)
292 Size(static_cast<int>(subset.size()));
293 for (Array<int>::const_iterator it = subset.begin(); it != subset.end(); ++it, ++i) {
294 _data[i] = pset(*it);
302 _m(0), _n(0), _data(NULL)
305 Size(static_cast<int>(subset.size()));
306 for (OrderedSet<int>::const_iterator it = subset.begin(); it != subset.end(); ++it, ++i) {
307 _data[i] = pset(*it);
351 p[0] = pt.
_x, p[1] = pt.
_y, p[2] = pt.
_z;
364 pt.
_x = p[0], pt.
_y = p[1], pt.
_z = p[2];
399 for (
int i = j; i < k; j++) {
409 while (n > m) m += POINTSET_SIZE;
412 for (
int i = _n; i <
_m; ++i) _data[i] = p;
420 Point *new_data = Allocate<Point>(m);
421 for (
int i = 0; i <
_n; ++i) new_data[i] = _data[i];
437 Point *new_data = Allocate<Point>(n);
438 for (
int i = 0; i <
_n; ++i) new_data[i] = _data[i];
455 Point *new_data = Allocate<Point>(
_n);
456 for (
int i = 0; i <
_n; ++i) new_data[i] = _data[i];
484 #endif // MIRTK_PointSet_H bool operator==(const PointSet &) const
Test for equality.
Point & operator()(int)
Operator for Point put access.
void ReadVTK(const char *)
int Size() const
Access function for size.
void WriteVTK(const char *, vtkAbstractArray *=NULL) const
void Write(const char *) const
Write pointset to file.
double _x
x coordinate of Point
void Del()
Delete all points without freeing already allocated memory.
int _n
Actual size of PointSet.
int _m
Allocated size of PointSet.
void Allocate(Type *&matrix, int n)
Allocate 1D array.
bool operator!=(const PointSet &) const
Test for inequality.
virtual ~PointSet()
Destructor.
void ShrinkToFit()
Requests the container to reduce its capacity to fit its size.
int Capacity() const
Return size of allocated storage capacity.
virtual void BoundingBox(Point &, Point &) const
Bounding box.
void Add(const Point &)
Adding of a point to point set.
virtual double PointDistance(Point &)
Point set distance to given point.
virtual Point ClosestPoint(Point &)
Closest point to given point.
virtual Point CenterOfGravity() const
Centre of gravity.
void Resize(int, const Point &=Point())
Resizes container so it contains n elements.
Point & GetPoint(int)
Get n-th point.
Point StandardDeviationEllipsoid() const
Computes the standard deviation ellipsoid about the centroid of a point set.
void Deallocate(Type *&p)
Deallocate 1D array.
void AddVTK(const char *)
int IsInside(double, double) const
Tests if a point is inside the polygon defined by the point set.
PointSet(int=0)
Default constructor.
void Read(const char *)
Read pointset from file.
void SetPoint(int, const Point &)
Set n-th point.
void Clear(bool deallocate=true)
double _z
z coordinate of Point
Point * _data
Pointer to Points.
double _y
y coordinate of Point
Point Centroid() const
Get (unweighted) centroid of point set.
void Reserve(int)
Request a change in capacity.