20 #ifndef MIRTK_BoundarySegment_H 21 #define MIRTK_BoundarySegment_H 23 #include "mirtk/Object.h" 24 #include "mirtk/Array.h" 25 #include "mirtk/Vector.h" 26 #include "mirtk/Point.h" 27 #include "mirtk/UnorderedMap.h" 29 #include "vtkSmartPointer.h" 30 #include "vtkPolyData.h" 54 typedef UnorderedMap<int, int> PointIdToIndexMap;
60 mirtkReadOnlyAttributeMacro(vtkSmartPointer<vtkPolyData>, Surface);
63 mirtkReadOnlyAttributeMacro(Array<int>, PointIds);
66 mirtkAttributeMacro(PointIdToIndexMap, Index);
69 mirtkAttributeMacro(Array<int>, Selection);
111 void InitializeLengths();
139 void GetPoint(
int i,
double p[3])
const;
145 void SetPoint(
int i,
const double p[3]);
152 class Point Point(int i) const;
158 void Point(
int i,
const class Point &p);
165 int Find(
int ptId)
const;
253 class Point SelectedPoint(int i) const;
278 if (_EdgeLengths)
return _EdgeLengths.
Sum();
289 return static_cast<int>(_PointIds.size());
296 if (i < 0) i = (i + 1) % n + n - 1;
297 else if (i >= n) i = i % n;
312 _Surface->GetPoint(static_cast<vtkIdType>(
PointId(i)), p);
319 _Surface->GetPoints()->SetPoint(static_cast<vtkIdType>(
PointId(i)), const_cast<double *>(p));
339 return Find(ptId) != -1;
349 if (_Length > 0.)
return _Length;
356 if (_EdgeLengths)
return _EdgeLengths;
377 return static_cast<int>(_Selection.size());
383 return _Selection[i];
389 return _PointIds[_Selection[i]];
401 return Point(_Selection[i]);
407 for (
auto it = _Selection.begin(); it != _Selection.end(); ++it) {
408 if (*it == i)
return true;
416 #endif // MIRTK_BoundarySegment_H double Length() const
Get total length of boundary segment.
class Point Point(int i) const
class Point SelectedPoint(int i) const
void ReserveSelection(int n)
double Sum() const
Returns sum of a vector components.
void ClearSelection()
Deselect all points.
Vector ComputeEdgeLengths() const
Compute edge lengths.
void GetSelectedPoint(int i, double p[3]) const
int IndexModuloNumberOfPoints(int i) const
Get boundary segment point index in range [0, N)
bool Contains(int ptId) const
BoundarySegment()
Default constructor.
void SetPoint(int i, const double p[3])
virtual ~BoundarySegment()
Destructor.
int NumberOfSelectedPoints() const
Number of selected curve points.
void GetPoint(int i, double p[3]) const
BoundarySegment & operator=(const BoundarySegment &)
Assignment operator.
int SelectedPointId(int i) const
int FindClosestPoint(const class Point &x, double *dist2=nullptr) const
void RemoveSelection(int i)
double EdgeLength(int i, int di=+1) const
int SelectedPointIndex(int i) const
void InitializeIndex()
Pre-compute map of surface point ID to boundary segment point index.
double ComputeLength() const
Compute length of boundary segment.
double Distance() const
Distance from origin.
bool IsSelected(int i) const
void DeselectPoint(int i)
Vector EdgeLengths() const
Get lengths of boundary segment edges.
int NumberOfPoints() const
Number of boundary segment points.