Slicer  5.0
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkProjectMarkupsCurvePointsFilter.h
Go to the documentation of this file.
1 /*==============================================================================
2 
3  Program: 3D Slicer
4 
5  Copyright (c) Kitware Inc.
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 __vtkProjectMarkupsCurvePointsFilter_h
19 #define __vtkProjectMarkupsCurvePointsFilter_h
20 
21 #include "vtkSlicerMarkupsModuleMRMLExport.h"
22 
23 #include <vtkInformation.h>
24 #include <vtkPolyDataAlgorithm.h>
25 #include <vtkWeakPointer.h>
26 
27 class vtkDoubleArray;
28 class vtkOBBTree;
29 class vtkPointLocator;
30 class vtkPoints;
31 class vtkPolyData;
32 
34 class vtkMRMLModelNode;
35 
46 class VTK_SLICER_MARKUPS_MODULE_MRML_EXPORT vtkProjectMarkupsCurvePointsFilter : public vtkPolyDataAlgorithm
47 {
48 public:
49  vtkTypeMacro(vtkProjectMarkupsCurvePointsFilter, vtkPolyDataAlgorithm);
51 
64  void SetInputCurveNode(vtkMRMLMarkupsCurveNode* inputCurveNode);
65 
74  using vtkPolyDataAlgorithm::SetInputData;
75  using vtkPolyDataAlgorithm::SetInputConnection;
77 
89  static bool ConstrainPointsToSurface(vtkPoints* originalPoints, vtkDoubleArray* normalVectors, vtkPolyData* surfacePolydata,
90  vtkPoints* surfacePoints, double maximumSearchRadiusTolerance);
91 
99  void SetMaximumSearchRadiusTolerance(double maximumSearchRadiusTolerance);
100  double GetMaximumSearchRadiusTolerance() const;
102 
103 protected:
104  int FillInputPortInformation(int port, vtkInformation* info) override;
105  int RequestData(vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector) override;
106 
108 private:
109  vtkWeakPointer<vtkMRMLMarkupsCurveNode> InputCurveNode;
110  double MaximumSearchRadiusTolerance;
111 
112  bool ProjectPointsToSurface(vtkMRMLModelNode* modelNode, double maximumSearchRadiusTolerance, vtkPoints* interpolatedPoints, vtkPoints* outputPoints);
113  static bool ConstrainPointsToSurfaceImpl(vtkOBBTree* surfaceObbTree, vtkPointLocator* pointLocator,
114  vtkPoints* originalPoints, vtkDoubleArray* normalVectors, vtkPolyData* surfacePolydata,
115  vtkPoints* surfacePoints, double maximumSearchRadius=.25);
116 
117  class PointProjectionHelper
118  {
119  public:
120  PointProjectionHelper();
121  void SetModel(vtkMRMLModelNode* model);
124  vtkSmartPointer<vtkDoubleArray> GetPointNormals(vtkPoints* points, vtkPoints* controlPoints);
125  vtkPointLocator* GetPointLocator();
126  vtkOBBTree* GetObbTree();
127  vtkPolyData* GetSurfacePolyData();
128 
129  private:
130  vtkMRMLModelNode* Model;
131  vtkMTimeType LastModelModifiedTime;
132  vtkMTimeType LastTransformModifiedTime;
133  vtkSmartPointer<vtkDataArray> ModelNormalVectorArray;
134  vtkSmartPointer<vtkPointLocator> ModelPointLocator;
135  vtkSmartPointer<vtkOBBTree> ModelObbTree;
136  vtkSmartPointer<vtkPolyData> SurfacePolyData;
137 
138  bool UpdateAll();
139  static vtkIdType GetClosestControlPointIndex(const double point[3], vtkPoints* controlPoints);
140  };
141 
142  PointProjectionHelper PointProjection;
143 };
144 
145 #endif
MRML node to represent a curve markup Curve Markups nodes contain N control points. Visualization parameters are set in the vtkMRMLMarkupsDisplayNode class.
Projects curve points from a vtkMRMLMarkupsCurveNode to the surface of a model.
MRML node to represent a 3D surface model.