Slicer  4.11
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
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
22 #include "vtkMRMLDisplayableNode.h"
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 
36 class vtkArrayCalculator;
37 class vtkAssignAttribute;
38 class vtkCallbackCommand;
39 class vtkCleanPolyData;
41 class vtkPassThroughFilter;
42 class vtkPlane;
43 class vtkTransformPolyDataFilter;
44 class vtkTriangleFilter;
45 
88 class VTK_SLICER_MARKUPS_MODULE_MRML_EXPORT vtkMRMLMarkupsCurveNode : public vtkMRMLMarkupsNode
89 {
90 public:
91  static vtkMRMLMarkupsCurveNode *New();
94  void PrintSelf(ostream& os, vtkIndent indent) override;
95 
96  const char* GetIcon() override {return ":/Icons/MarkupsCurveMouseModePlace.png";}
97 
98  //--------------------------------------------------------------------------
99  // MRMLNode methods
100  //--------------------------------------------------------------------------
101 
102  vtkMRMLNode* CreateNodeInstance() override;
104  const char* GetNodeTagName() override {return "MarkupsCurve";}
105 
107  void ReadXMLAttributes( const char** atts) override;
108 
110  void WriteXML(ostream& of, int indent) override;
111 
115 
117  vtkPoints* GetCurvePointsWorld();
118 
124  double GetCurveLengthWorld(vtkIdType startCurvePointIndex=0, vtkIdType numberOfCurvePoints=-1);
125 
128  static double GetCurveLength(vtkPoints* curvePoints, bool closedCurve, vtkIdType startCurvePointIndex=0, vtkIdType numberOfCurvePoints=-1);
129 
135  double GetCurveLengthBetweenStartEndPointsWorld(vtkIdType startCurvePointIndex, vtkIdType endCurvePointIndex);
136 
138  bool SetControlPointLabels(vtkStringArray* labels, vtkPoints* points);
139 
145  bool ResampleCurveSurface(double controlPointDistance, vtkMRMLModelNode* node, double maximumSearchRadius=.25);
146 
152  static bool ConstrainPointsToSurface(vtkPoints* originalPoints, vtkPoints* normalVectors, vtkPolyData* surfacePolydata,
153  vtkPoints* surfacePoints, double maximumSearchRadius=.25);
154 
155  void ResampleCurveWorld(double controlPointDistance);
156 
157  static bool ResamplePoints(vtkPoints* originalPoints, vtkPoints* interpolatedPoints, double samplingDistance, bool closedCurve);
158 
161  bool GetSampledCurvePointsBetweenStartEndPointsWorld(vtkPoints* sampledPoints,
162  double samplingDistance, vtkIdType startCurvePointIndex, vtkIdType endCurvePointIndex);
163 
165  vtkIdType GetClosestCurvePointIndexToPositionWorld(const double posWorld[3]);
166 
172  vtkIdType GetClosestPointPositionAlongCurveWorld(const double posWorld[3], double closestPosWorld[3]);
173 
178  vtkIdType GetFarthestCurvePointIndexToPositionWorld(const double posWorld[3]);
179 
182  vtkIdType GetCurvePointIndexFromControlPointIndex(int controlPointIndex);
183 
185  static bool GetPositionAndClosestPointIndexAlongCurve(double foundCurvePosition[3], vtkIdType& foundClosestPointIndex,
186  vtkIdType startCurvePointId, double distanceFromStartPoint, vtkPoints* curvePoints, bool closedCurve);
187 
192  vtkIdType GetCurvePointIndexAlongCurveWorld(vtkIdType startCurvePointId, double distanceFromStartPoint);
193 
199  bool GetPositionAlongCurveWorld(double foundCurvePosition[3], vtkIdType startCurvePointId, double distanceFromStartPoint);
200 
203  bool GetCurveDirectionAtPointIndexWorld(vtkIdType curvePointIndex, double directionVectorWorld[3]);
204 
212  bool GetCurvePointToWorldTransformAtPointIndex(vtkIdType curvePointIndex, vtkMatrix4x4* curvePointToWorld);
213 
214  bool GetPointsOnPlaneWorld(vtkPlane* plane, vtkPoints* intersectionPoints);
215 
217  int GetCurveType();
218  void SetCurveType(int type);
219  const char* GetCurveTypeAsString(int id);
220  int GetCurveTypeFromString(const char* name);
221  void SetCurveTypeToLinear();
222  void SetCurveTypeToCardinalSpline();
223  void SetCurveTypeToKochanekSpline();
224  void SetCurveTypeToPolynomial();
225  void SetCurveTypeToShortestDistanceOnSurface(vtkMRMLModelNode* modelNode=nullptr);
226 
228  const char* GetShortestDistanceSurfaceNodeReferenceRole() { return "shortestDistanceSurface"; };
229  const char* GetShortestDistanceSurfaceNodeReferenceMRMLAttributeName() { return "shortestDistanceSurfaceRef"; };
230 
233  void SetAndObserveShortestDistanceSurfaceNode(vtkMRMLModelNode* modelNode);
234  vtkMRMLModelNode* GetShortestDistanceSurfaceNode();
235 
238  int GetSurfaceCostFunctionType();
239  void SetSurfaceCostFunctionType(int surfaceCostFunctionType);
240  static const char* GetSurfaceCostFunctionTypeAsString(int surfaceCostFunctionType);
241  static int GetSurfaceCostFunctionTypeFromString(const char* name);
242 
245  const char* GetSurfaceDistanceWeightingFunction();
246  void SetSurfaceDistanceWeightingFunction(const char* function);
247 
249  int GetNumberOfPointsPerInterpolatingSegment();
252  void SetNumberOfPointsPerInterpolatingSegment(int pointsPerSegment);
254 
256  virtual void UpdateAssignedAttribute() override;
257 
258 protected:
259  vtkSmartPointer<vtkCleanPolyData> CleanFilter;
260  vtkSmartPointer<vtkTriangleFilter> TriangleFilter;
261  vtkSmartPointer<vtkTransformPolyDataFilter> SurfaceToLocalTransformer;
262  vtkSmartPointer<vtkArrayCalculator> SurfaceScalarCalculator;
263  vtkSmartPointer<vtkPassThroughFilter> SurfaceScalarPassThroughFilter;
264  vtkSmartPointer<vtkCurveMeasurementsCalculator> CurveMeasurementsCalculator;
266 
270  vtkSmartPointer<vtkAssignAttribute> ScalarDisplayAssignAttribute;
271 
274 
275 protected:
276  void ProcessMRMLEvents(vtkObject* caller, unsigned long event, void* callData) override;
277  void OnNodeReferenceAdded(vtkMRMLNodeReference* reference) override;
278  void OnNodeReferenceModified(vtkMRMLNodeReference* reference) override;
279  void OnNodeReferenceRemoved(vtkMRMLNodeReference* reference) override;
280 
281  virtual void UpdateSurfaceScalarVariables();
282  virtual void OnSurfaceModelNodeChanged();
283  virtual void OnSurfaceModelTransformChanged();
284 
286  ~vtkMRMLMarkupsCurveNode() override;
288  void operator=(const vtkMRMLMarkupsCurveNode&);
289 
290  void UpdateMeasurementsInternal() override;
291 
293  static void OnCurvatureMeasurementModified(vtkObject* caller, unsigned long eid, void* clientData, void* callData);
294 };
295 
296 #endif
static vtkMRMLMarkupsNode * New()
MRML node to represent a curve markup Curve Markups nodes contain N control points. Visualization parameters are set in the vtkMRMLMarkupsDisplayNode class.
void OnNodeReferenceRemoved(vtkMRMLNodeReference *reference) override
Called after a node reference ID is removed (list size decreased).
vtkSmartPointer< vtkPassThroughFilter > SurfaceScalarPassThroughFilter
MRML node to represent a 3D surface model.
void operator=(const vtkMRMLMarkupsNode &)
const char * GetShortestDistanceSurfaceNodeReferenceMRMLAttributeName()
vtkSmartPointer< vtkArrayCalculator > SurfaceScalarCalculator
Filter that generates curves between points of an input polydata.
vtkSmartPointer< vtkCleanPolyData > CleanFilter
void OnNodeReferenceAdded(vtkMRMLNodeReference *reference) override
Called when a node reference ID is added (list size increased).
const char * GetNodeTagName() override
Get node XML tag name (like Volume, Model)
vtkSmartPointer< vtkTriangleFilter > TriangleFilter
vtkSmartPointer< vtkAssignAttribute > ScalarDisplayAssignAttribute
const char * GetIcon() override
virtual void UpdateMeasurementsInternal()
vtkMRMLCopyContentMacro(vtkMRMLMarkupsNode)
vtkSmartPointer< vtkTransformPolyDataFilter > SurfaceToLocalTransformer
vtkPoints * GetCurvePointsWorld()
vtkMRMLNode * CreateNodeInstance() override
MRMLNode methods.
const char * ShortestDistanceSurfaceActiveScalar
vtkCallbackCommand * CurvatureMeasurementModifiedCallbackCommand
Command handling curvature measurement modified events to propagate enabled state.
void ReadXMLAttributes(const char **atts) override
Read node attributes from XML file.
const char * GetShortestDistanceSurfaceNodeReferenceRole()
Node reference role for the surface that is used in the shortest surface distance curve type...
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167
Class to hold information about a node reference.
Definition: vtkMRMLNode.h:775
void OnNodeReferenceModified(vtkMRMLNodeReference *reference) override
Called when a node reference ID is modified.
virtual void UpdateAssignedAttribute()
vtkSmartPointer< vtkCurveMeasurementsCalculator > CurveMeasurementsCalculator
void WriteXML(ostream &of, int indent) override
Write this node&#39;s information to a MRML file in XML format.
void ProcessMRMLEvents(vtkObject *, unsigned long, void *) override
Alternative method to propagate events generated in Display nodes.
void PrintSelf(ostream &os, vtkIndent indent) override