Slicer 5.6
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
vtkMRMLMarkupsCurveNode.h
Go to the documentation of this file.
1/*==============================================================================
2
3 Program: 3D Slicer
4
5 Portions (c) Copyright Brigham and Women's Hospital (BWH) All Rights Reserved.
6
7 See COPYRIGHT.txt
8 or http://www.slicer.org/copyright/copyright.txt for details.
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15
16==============================================================================*/
17
18#ifndef __vtkMRMLMarkupsCurveNode_h
19#define __vtkMRMLMarkupsCurveNode_h
20
21// MRML includes
23#include "vtkMRMLModelNode.h"
24
25// Markups includes
26#include "vtkSlicerMarkupsModuleMRMLExport.h"
28#include "vtkMRMLMarkupsNode.h"
29
30// VTK includes
31#include <vtkStringArray.h>
32
33// std includes
34#include <vector>
35
36class vtkArrayCalculator;
37class vtkAssignAttribute;
38class vtkCallbackCommand;
39class vtkCleanPolyData;
41class vtkPassThrough;
42class vtkPlane;
44class vtkTransformPolyDataFilter;
45class vtkTriangleFilter;
46
88class VTK_SLICER_MARKUPS_MODULE_MRML_EXPORT vtkMRMLMarkupsCurveNode : public vtkMRMLMarkupsNode
89{
90public:
94 void PrintSelf(ostream& os, vtkIndent indent) override;
95
96 const char* GetIcon() override {return ":/Icons/MarkupsOpenCurve.png";}
97 const char* GetAddIcon() override {return ":/Icons/MarkupsCurveMouseModePlace.png";}
98 const char* GetPlaceAddIcon() override {return ":/Icons/MarkupsCurveMouseModePlaceAdd.png";}
99
100 //--------------------------------------------------------------------------
101 // MRMLNode methods
102 //--------------------------------------------------------------------------
103
106 const char* GetNodeTagName() override {return "MarkupsCurve";}
107
109 const char* GetMarkupType() override {return "Curve";};
110
111 // Get markup type GUI display name
112 const char* GetTypeDisplayName() override {return "Curve";};
113
115 const char* GetDefaultNodeNamePrefix() override {return "OC";};
116
118 void ReadXMLAttributes( const char** atts) override;
119
121 void WriteXML(ostream& of, int indent) override;
122
126
129 vtkPoints* GetCurvePointsWorld() override;
130 vtkPolyData* GetCurveWorld() override;
131 vtkAlgorithmOutput* GetCurveWorldConnection() override;
133
139 double GetCurveLengthWorld(vtkIdType startCurvePointIndex=0, vtkIdType numberOfCurvePoints=-1);
140
143 static double GetCurveLength(vtkPoints* curvePoints, bool closedCurve, vtkIdType startCurvePointIndex=0, vtkIdType numberOfCurvePoints=-1);
144
150 double GetCurveLengthBetweenStartEndPointsWorld(vtkIdType startCurvePointIndex, vtkIdType endCurvePointIndex);
151
153 bool SetControlPointLabels(vtkStringArray* labels, vtkPoints* points);
154
162 static bool ConstrainPointsToSurface(vtkPoints* originalPoints, vtkPoints* normalVectors, vtkPolyData* surfacePolydata,
163 vtkPoints* surfacePoints, double maximumSearchRadius=.25);
164
166 void ResampleCurveWorld(double controlPointDistance);
167
169 // If pedigreeIdsArray is specified then the method returns the fractional point index of the original point for each new point.
170 // Fractional point index is a value between the point indices of the two original points it was between, the fractional part
171 // specifies the distance from those two points. It can be used for interpolating point data.
172 static bool ResamplePoints(vtkPoints* originalPoints, vtkPoints* interpolatedPoints,
173 double samplingDistance, bool closedCurve, vtkDoubleArray* pedigreeIdsArray=nullptr);
174
176 static bool ResampleStaticControlPointMeasurements(vtkCollection* measurements, vtkDoubleArray* curvePointsPedigreeIdsArray,
177 int curvePointsPerControlPoint, bool closedCurve);
178
182 double samplingDistance, vtkIdType startCurvePointIndex, vtkIdType endCurvePointIndex);
183
185 vtkIdType GetClosestCurvePointIndexToPositionWorld(const double posWorld[3]);
186
192 vtkIdType GetClosestPointPositionAlongCurveWorld(const double posWorld[3], double closestPosWorld[3]);
193
201 static vtkIdType GetClosestPointPositionAlongCurve(vtkPoints* points, const double pos[3], double closestPos[3], vtkPointLocator* pointLocator=nullptr);
202
207 vtkIdType GetFarthestCurvePointIndexToPositionWorld(const double posWorld[3]);
208
213 static vtkIdType GetFarthestCurvePointIndexToPosition(vtkPoints* points, const double posWorld[3]);
214
217 vtkIdType GetCurvePointIndexFromControlPointIndex(int controlPointIndex);
218
220 static bool GetPositionAndClosestPointIndexAlongCurve(double foundCurvePosition[3], vtkIdType& foundClosestPointIndex,
221 vtkIdType startCurvePointId, double distanceFromStartPoint, vtkPoints* curvePoints, bool closedCurve);
222
227 vtkIdType GetCurvePointIndexAlongCurveWorld(vtkIdType startCurvePointId, double distanceFromStartPoint);
228
233 static vtkIdType GetCurvePointIndexAlongCurve(vtkPoints* points, vtkIdType startCurvePointId, double distanceFromStartPoint, bool curveClosed);
234
240 bool GetPositionAlongCurveWorld(double foundCurvePosition[3], vtkIdType startCurvePointId, double distanceFromStartPoint);
241
244 bool GetCurveDirectionAtPointIndexWorld(vtkIdType curvePointIndex, double directionVectorWorld[3]);
245
253 bool GetCurvePointToWorldTransformAtPointIndex(vtkIdType curvePointIndex, vtkMatrix4x4* curvePointToWorld);
254
255 bool GetPointsOnPlaneWorld(vtkPlane* plane, vtkPoints* intersectionPoints);
256
259 void SetCurveType(int type);
260 const char* GetCurveTypeAsString(int id);
261 int GetCurveTypeFromString(const char* name);
267
270 const char* GetShortestDistanceSurfaceNodeReferenceRole() { return this->GetSurfaceConstraintNodeReferenceRole(); }
273 const char* GetShortestDistanceSurfaceNodeReferenceMRMLAttributeName() { return this->GetSurfaceConstraintNodeReferenceMRMLAttributeName(); }
274
276 const char* GetSurfaceConstraintNodeReferenceRole() { return "shortestDistanceSurface"; }
277 const char* GetSurfaceConstraintNodeReferenceMRMLAttributeName() { return "shortestDistanceSurfaceRef"; };
278
283 void SetAndObserveShortestDistanceSurfaceNode(vtkMRMLModelNode* modelNode) { this->SetAndObserveSurfaceConstraintNode(modelNode); }
286 vtkMRMLModelNode* GetShortestDistanceSurfaceNode() { return this->GetSurfaceConstraintNode(); }
287
293
302
306 void SetSurfaceCostFunctionType(int surfaceCostFunctionType);
307 static const char* GetSurfaceCostFunctionTypeAsString(int surfaceCostFunctionType);
308 static int GetSurfaceCostFunctionTypeFromString(const char* name);
309
313 void SetSurfaceDistanceWeightingFunction(const char* function);
314
316
321
323 virtual void UpdateAssignedAttribute() override;
324
325protected:
326 vtkSmartPointer<vtkCleanPolyData> CleanFilter;
327 vtkSmartPointer<vtkTriangleFilter> TriangleFilter;
328 vtkSmartPointer<vtkTransformPolyDataFilter> SurfaceToLocalTransformer;
329 vtkSmartPointer<vtkArrayCalculator> SurfaceScalarCalculator;
330 vtkSmartPointer<vtkPassThrough> SurfaceScalarPassThroughFilter;
331 vtkSmartPointer<vtkCurveMeasurementsCalculator> CurveMeasurementsCalculator;
332 vtkSmartPointer<vtkPassThrough> WorldOutput;
334
338 vtkSmartPointer<vtkAssignAttribute> ScalarDisplayAssignAttribute;
339
344
345protected:
346 void ProcessMRMLEvents(vtkObject* caller, unsigned long event, void* callData) override;
350
354
359
361
363 static void OnCurvatureMeasurementEnabledModified(vtkObject* caller, unsigned long eid, void* clientData, void* callData);
365 static void OnTorsionMeasurementEnabledModified(vtkObject* caller, unsigned long eid, void* clientData, void* callData);
366
367private:
368 vtkSmartPointer<vtkProjectMarkupsCurvePointsFilter> ProjectPointsFilter;
369};
370
371#endif
MRML node to represent a curve markup Curve Markups nodes contain N control points....
int GetNumberOfPointsPerInterpolatingSegment()
static void OnCurvatureMeasurementEnabledModified(vtkObject *caller, unsigned long eid, void *clientData, void *callData)
Callback function observing curvature measurement modified events to propagate enabled state.
vtkSmartPointer< vtkTransformPolyDataFilter > SurfaceToLocalTransformer
double GetSurfaceConstraintMaximumSearchRadiusTolerance() const
void SetCurveTypeToShortestDistanceOnSurface(vtkMRMLModelNode *modelNode=nullptr)
static void OnTorsionMeasurementEnabledModified(vtkObject *caller, unsigned long eid, void *clientData, void *callData)
Callback function observing torsion measurement modified events to propagate enabled state.
int GetCurveTypeFromString(const char *name)
void OnNodeReferenceRemoved(vtkMRMLNodeReference *reference) override
Called after a node reference ID is removed (list size decreased).
const char * GetTypeDisplayName() override
const char * GetCurveTypeAsString(int id)
vtkIdType GetCurvePointIndexFromControlPointIndex(int controlPointIndex)
const char * GetAddIcon() override
const char * GetDefaultNodeNamePrefix() override
Get markup short name.
vtkIdType GetFarthestCurvePointIndexToPositionWorld(const double posWorld[3])
const char * GetShortestDistanceSurfaceNodeReferenceRole()
void ReadXMLAttributes(const char **atts) override
Read node attributes from XML file.
virtual void OnSurfaceModelTransformChanged()
vtkCallbackCommand * TorsionMeasurementModifiedCallbackCommand
Command handling torsion measurement modified events to propagate enabled state.
const char * GetSurfaceConstraintNodeReferenceMRMLAttributeName()
bool SetControlPointLabels(vtkStringArray *labels, vtkPoints *points)
Provides access to protected vtkMRMLMarkupsNode::SetControlPointLabelsWorld.
vtkMRMLModelNode * GetShortestDistanceSurfaceNode()
const char * GetMarkupType() override
Get markup type internal name.
vtkMRMLNode * CreateNodeInstance() override
MRMLNode methods.
vtkIdType GetClosestCurvePointIndexToPositionWorld(const double posWorld[3])
Get the index of the closest curve point to the world coordinates.
void SetSurfaceDistanceWeightingFunction(const char *function)
virtual void UpdateSurfaceScalarVariables()
vtkPolyData * GetCurveWorld() override
void ProcessMRMLEvents(vtkObject *caller, unsigned long event, void *callData) override
alternative method to propagate events generated in Display nodes
bool GetCurveDirectionAtPointIndexWorld(vtkIdType curvePointIndex, double directionVectorWorld[3])
static bool ConstrainPointsToSurface(vtkPoints *originalPoints, vtkPoints *normalVectors, vtkPolyData *surfacePolydata, vtkPoints *surfacePoints, double maximumSearchRadius=.25)
const char * GetShortestDistanceSurfaceNodeReferenceMRMLAttributeName()
void SetSurfaceCostFunctionType(int surfaceCostFunctionType)
vtkSmartPointer< vtkPassThrough > WorldOutput
void WriteXML(ostream &of, int indent) override
Write this node's information to a MRML file in XML format.
vtkPoints * GetCurvePointsWorld() override
int GetCurveType()
Type of curve to generate.
void UpdateMeasurementsInternal() override
const char * GetNodeTagName() override
Get node XML tag name (like Volume, Model)
vtkIdType GetCurvePointIndexAlongCurveWorld(vtkIdType startCurvePointId, double distanceFromStartPoint)
vtkCallbackCommand * CurvatureMeasurementModifiedCallbackCommand
Command handling curvature measurement modified events to propagate enabled state.
static vtkIdType GetClosestPointPositionAlongCurve(vtkPoints *points, const double pos[3], double closestPos[3], vtkPointLocator *pointLocator=nullptr)
const char * GetSurfaceDistanceWeightingFunction()
vtkAlgorithmOutput * GetCurveWorldConnection() override
static vtkIdType GetFarthestCurvePointIndexToPosition(vtkPoints *points, const double posWorld[3])
void PrintSelf(ostream &os, vtkIndent indent) override
Print out the node information to the output stream.
void operator=(const vtkMRMLMarkupsCurveNode &)
static vtkMRMLMarkupsCurveNode * New()
void SetAndObserveShortestDistanceSurfaceNode(vtkMRMLModelNode *modelNode)
void OnNodeReferenceAdded(vtkMRMLNodeReference *reference) override
Called when a node reference ID is added (list size increased).
vtkMRMLMarkupsCurveNode(const vtkMRMLMarkupsCurveNode &)
void ResampleCurveWorld(double controlPointDistance)
Resample control points to have equal distances in the world coordinate system.
vtkSmartPointer< vtkCurveMeasurementsCalculator > CurveMeasurementsCalculator
vtkSmartPointer< vtkCleanPolyData > CleanFilter
const char * GetSurfaceConstraintNodeReferenceRole()
Node reference role for the surface that is used to project the curve onto.
void SetAndObserveSurfaceConstraintNode(vtkMRMLModelNode *modelNode)
vtkSmartPointer< vtkArrayCalculator > SurfaceScalarCalculator
const char * GetPlaceAddIcon() override
void SetCurveType(int type)
virtual void OnSurfaceModelNodeChanged()
bool GetCurvePointToWorldTransformAtPointIndex(vtkIdType curvePointIndex, vtkMatrix4x4 *curvePointToWorld)
vtkMRMLCopyContentMacro(vtkMRMLMarkupsCurveNode)
void SetNumberOfPointsPerInterpolatingSegment(int pointsPerSegment)
bool GetPositionAlongCurveWorld(double foundCurvePosition[3], vtkIdType startCurvePointId, double distanceFromStartPoint)
void OnNodeReferenceModified(vtkMRMLNodeReference *reference) override
Called when a node reference ID is modified.
static double GetCurveLength(vtkPoints *curvePoints, bool closedCurve, vtkIdType startCurvePointIndex=0, vtkIdType numberOfCurvePoints=-1)
void SetSurfaceConstraintMaximumSearchRadiusTolerance(double tolerance)
virtual void UpdateAssignedAttribute() override
Update scalar range and update markups pipeline when the active scalar array is changed.
~vtkMRMLMarkupsCurveNode() override
vtkSmartPointer< vtkPassThrough > SurfaceScalarPassThroughFilter
static bool GetPositionAndClosestPointIndexAlongCurve(double foundCurvePosition[3], vtkIdType &foundClosestPointIndex, vtkIdType startCurvePointId, double distanceFromStartPoint, vtkPoints *curvePoints, bool closedCurve)
Get point position along curve. Position is found along the curve and not snapped to closest curve po...
const char * GetIcon() override
bool GetSampledCurvePointsBetweenStartEndPointsWorld(vtkPoints *sampledPoints, double samplingDistance, vtkIdType startCurvePointIndex, vtkIdType endCurvePointIndex)
double GetCurveLengthBetweenStartEndPointsWorld(vtkIdType startCurvePointIndex, vtkIdType endCurvePointIndex)
vtkSmartPointer< vtkTriangleFilter > TriangleFilter
bool GetPointsOnPlaneWorld(vtkPlane *plane, vtkPoints *intersectionPoints)
static vtkIdType GetCurvePointIndexAlongCurve(vtkPoints *points, vtkIdType startCurvePointId, double distanceFromStartPoint, bool curveClosed)
static const char * GetSurfaceCostFunctionTypeAsString(int surfaceCostFunctionType)
vtkIdType GetClosestPointPositionAlongCurveWorld(const double posWorld[3], double closestPosWorld[3])
vtkSmartPointer< vtkAssignAttribute > ScalarDisplayAssignAttribute
static bool ResampleStaticControlPointMeasurements(vtkCollection *measurements, vtkDoubleArray *curvePointsPedigreeIdsArray, int curvePointsPerControlPoint, bool closedCurve)
Resample static control point measurements using linear interpolation, based on fractional pedigreeId...
static bool ResamplePoints(vtkPoints *originalPoints, vtkPoints *interpolatedPoints, double samplingDistance, bool closedCurve, vtkDoubleArray *pedigreeIdsArray=nullptr)
Resample control points to have equal distances in the node's coordinate system.
static int GetSurfaceCostFunctionTypeFromString(const char *name)
double GetCurveLengthWorld(vtkIdType startCurvePointIndex=0, vtkIdType numberOfCurvePoints=-1)
vtkMRMLModelNode * GetSurfaceConstraintNode()
MRML node to represent a 3D surface model.
Class to hold information about a node reference.
Abstract Superclass for all specific types of MRML nodes.
Projects curve points from a vtkMRMLMarkupsCurveNode to the surface of a model.