Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 "vtkMRMLExport.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_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
112 void ReadXMLAttributes( const char** atts) override;
113
115 void WriteXML(ostream& of, int indent) override;
116
120
123 vtkPoints* GetCurvePointsWorld() override;
124 vtkPolyData* GetCurveWorld() override;
125 vtkAlgorithmOutput* GetCurveWorldConnection() override;
127
133 double GetCurveLengthWorld(vtkIdType startCurvePointIndex=0, vtkIdType numberOfCurvePoints=-1);
134
137 static double GetCurveLength(vtkPoints* curvePoints, bool closedCurve, vtkIdType startCurvePointIndex=0, vtkIdType numberOfCurvePoints=-1);
138
144 double GetCurveLengthBetweenStartEndPointsWorld(vtkIdType startCurvePointIndex, vtkIdType endCurvePointIndex);
145
147 bool SetControlPointLabels(vtkStringArray* labels, vtkPoints* points);
148
156 static bool ConstrainPointsToSurface(vtkPoints* originalPoints, vtkPoints* normalVectors, vtkPolyData* surfacePolydata,
157 vtkPoints* surfacePoints, double maximumSearchRadius=.25);
158
160 void ResampleCurveWorld(double controlPointDistance);
161
163 // If pedigreeIdsArray is specified then the method returns the fractional point index of the original point for each new point.
164 // Fractional point index is a value between the point indices of the two original points it was between, the fractional part
165 // specifies the distance from those two points. It can be used for interpolating point data.
166 static bool ResamplePoints(vtkPoints* originalPoints, vtkPoints* interpolatedPoints,
167 double samplingDistance, bool closedCurve, vtkDoubleArray* pedigreeIdsArray=nullptr);
168
170 static bool ResampleStaticControlPointMeasurements(vtkCollection* measurements, vtkDoubleArray* curvePointsPedigreeIdsArray,
171 int curvePointsPerControlPoint, bool closedCurve);
172
176 double samplingDistance, vtkIdType startCurvePointIndex, vtkIdType endCurvePointIndex);
177
179 vtkIdType GetClosestCurvePointIndexToPositionWorld(const double posWorld[3]);
180
186 vtkIdType GetClosestPointPositionAlongCurveWorld(const double posWorld[3], double closestPosWorld[3]);
187
195 static vtkIdType GetClosestPointPositionAlongCurve(vtkPoints* points, const double pos[3], double closestPos[3], vtkPointLocator* pointLocator=nullptr);
196
201 vtkIdType GetFarthestCurvePointIndexToPositionWorld(const double posWorld[3]);
202
207 static vtkIdType GetFarthestCurvePointIndexToPosition(vtkPoints* points, const double posWorld[3]);
208
211 vtkIdType GetCurvePointIndexFromControlPointIndex(int controlPointIndex);
212
214 static bool GetPositionAndClosestPointIndexAlongCurve(double foundCurvePosition[3], vtkIdType& foundClosestPointIndex,
215 vtkIdType startCurvePointId, double distanceFromStartPoint, vtkPoints* curvePoints, bool closedCurve);
216
221 vtkIdType GetCurvePointIndexAlongCurveWorld(vtkIdType startCurvePointId, double distanceFromStartPoint);
222
227 static vtkIdType GetCurvePointIndexAlongCurve(vtkPoints* points, vtkIdType startCurvePointId, double distanceFromStartPoint, bool curveClosed);
228
234 bool GetPositionAlongCurveWorld(double foundCurvePosition[3], vtkIdType startCurvePointId, double distanceFromStartPoint);
235
238 bool GetCurveDirectionAtPointIndexWorld(vtkIdType curvePointIndex, double directionVectorWorld[3]);
239
247 bool GetCurvePointToWorldTransformAtPointIndex(vtkIdType curvePointIndex, vtkMatrix4x4* curvePointToWorld);
248
249 bool GetPointsOnPlaneWorld(vtkPlane* plane, vtkPoints* intersectionPoints);
250
253 void SetCurveType(int type);
254 const char* GetCurveTypeAsString(int id);
255 int GetCurveTypeFromString(const char* name);
261
268
270 const char* GetSurfaceConstraintNodeReferenceRole() { return "shortestDistanceSurface"; }
271 const char* GetSurfaceConstraintNodeReferenceMRMLAttributeName() { return "shortestDistanceSurfaceRef"; };
272
281
287
296
300 void SetSurfaceCostFunctionType(int surfaceCostFunctionType);
301 static const char* GetSurfaceCostFunctionTypeAsString(int surfaceCostFunctionType);
302 static int GetSurfaceCostFunctionTypeFromString(const char* name);
303
307 void SetSurfaceDistanceWeightingFunction(const char* function);
308
310
315
317 virtual void UpdateAssignedAttribute() override;
318
319protected:
320 vtkSmartPointer<vtkCleanPolyData> CleanFilter;
321 vtkSmartPointer<vtkTriangleFilter> TriangleFilter;
322 vtkSmartPointer<vtkTransformPolyDataFilter> SurfaceToLocalTransformer;
323 vtkSmartPointer<vtkArrayCalculator> SurfaceScalarCalculator;
324 vtkSmartPointer<vtkPassThrough> SurfaceScalarPassThroughFilter;
325 vtkSmartPointer<vtkCurveMeasurementsCalculator> CurveMeasurementsCalculator;
326 vtkSmartPointer<vtkPassThrough> WorldOutput;
328
332 vtkSmartPointer<vtkAssignAttribute> ScalarDisplayAssignAttribute;
333
338
339protected:
340 void ProcessMRMLEvents(vtkObject* caller, unsigned long event, void* callData) override;
344
348
353
355
357 static void OnCurvatureMeasurementEnabledModified(vtkObject* caller, unsigned long eid, void* clientData, void* callData);
359 static void OnTorsionMeasurementEnabledModified(vtkObject* caller, unsigned long eid, void* clientData, void* callData);
360
361private:
362 vtkSmartPointer<vtkProjectMarkupsCurvePointsFilter> ProjectPointsFilter;
363};
364
365#endif
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 * GetCurveTypeAsString(int id)
vtkIdType GetCurvePointIndexFromControlPointIndex(int controlPointIndex)
const char * GetAddIcon() override
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.