iMSTK
Interactive Medical Simulation Toolkit
imstkSurfaceMeshDistanceTransform.h
1 /*
2 ** This file is part of the Interactive Medical Simulation Toolkit (iMSTK)
3 ** iMSTK is distributed under the Apache License, Version 2.0.
4 ** See accompanying NOTICE for details.
5 */
6 
7 #pragma once
8 
9 #include "imstkGeometryAlgorithm.h"
10 #include "imstkMath.h"
11 
12 #include <vtkSmartPointer.h>
13 
14 class vtkImplicitPolyDataDistance;
15 
16 namespace imstk
17 {
18 class ImageData;
19 class SurfaceMesh;
20 
31 {
32 public:
34  ~SurfaceMeshDistanceTransform() override = default;
35 
36 public:
40  void setInputMesh(std::shared_ptr<SurfaceMesh> surfMesh);
41 
42  std::shared_ptr<ImageData> getOutputImage();
43 
44  void setupDistFunc();
45 
49  Vec3d getNearestPoint(const Vec3d& pos);
50 
54  imstkSetMacro(Dimensions, const Vec3i&);
55  void setDimensions(int dimX, int dimY, int dimZ) { setDimensions(Vec3i(dimX, dimY, dimZ)); }
56  imstkGetMacro(Dimensions, const Vec3i&);
58 
65  void setBounds(const Vec3d& min, const Vec3d& max);
66  void setBounds(const Vec6d&);
67  imstkGetMacro(Bounds, const Vec6d&);
69 
73  imstkSetMacro(NarrowBanded, bool);
74  imstkGetMacro(NarrowBanded, bool);
76 
80  imstkSetMacro(DilateSize, int);
81  imstkGetMacro(DilateSize, int);
83 
85  imstkSetMacro(Tolerance, double);
86  imstkGetMacro(Tolerance, double);
88 
89 protected:
90  void requestUpdate() override;
91 
92 private:
93  Vec3i m_Dimensions = Vec3i::Zero();
94  Vec6d m_Bounds = Vec6d::Zero();
95  double m_Tolerance = 1.0e-10;
96 
97  bool m_NarrowBanded = false;
98  int m_DilateSize = 4;
99 
100  vtkSmartPointer<vtkImplicitPolyDataDistance> m_distFunc;
101 };
102 } // namespace imstk
imstkSetMacro(Dimensions, const Vec3i &)
Dimensions of distance transform to fill.
Compound Geometry.
void setBounds(const Vec3d &min, const Vec3d &max)
Optionally one may specify bounds, if not specified bounds of the input SurfaceMesh is used...
Abstract base class for geometry algorithms. GeometryAlgorithms take N input geometries and produce N...
void requestUpdate() override
Users can implement this for the logic to be run.
This filter computes exact signed distance fields using octrees and pseudonormal computations. One might need to adjust the tolerance depending on dataset scale. The bounds for the image can be set in the filter, when none are set the bounding box of the mesh is used, the margin. When providing your own bounds a box larger than the original object might be necessary depending on shape.
Vec3d getNearestPoint(const Vec3d &pos)
Get the nearest point.
void setInputMesh(std::shared_ptr< SurfaceMesh > surfMesh)
Required input, port 0.