iMSTK
Interactive Medical Simulation Toolkit
imstkPointToTetMap.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 "imstkGeometryMap.h"
10 #include "imstkMacros.h"
11 #include "imstkMath.h"
12 
13 namespace imstk
14 {
15 template<typename T, int N> class VecDataArray;
16 
24 class PointToTetMap : public GeometryMap
25 {
26 public:
27  PointToTetMap();
29  std::shared_ptr<Geometry> parent,
30  std::shared_ptr<Geometry> child);
31  ~PointToTetMap() override = default;
32 
33  IMSTK_TYPE_NAME(PointToTetMap)
34 
35 
36  void compute() override;
39 
40 protected:
44  void requestUpdate() override;
45 
49  int findEnclosingTetrahedron(const Vec3d& pos) const;
50 
54  void updateBoundingBox();
55 
60  int findClosestTetrahedron(const Vec3d& pos) const;
61 
62 protected:
63  std::vector<Vec4d> m_verticesWeights;
64 
65  std::vector<int> m_verticesEnclosingTetraId;
66 
67  std::vector<Vec3d> m_bBoxMin;
68  std::vector<Vec3d> m_bBoxMax;
69  bool m_boundingBoxAvailable;
70 
71 private:
72  std::shared_ptr<VecDataArray<double, 3>> m_childVerts;
73 };
74 } // namespace imstk
void compute() override
Compute the tetra-triangle mesh map.
void requestUpdate() override
Apply (if active) the tetra-triangle mesh map.
void updateBoundingBox()
Update bounding box of each tetrahedra of the mesh.
Compound Geometry.
int findClosestTetrahedron(const Vec3d &pos) const
Find the closest tetrahedron based on the distance to their centroids for a given point in 3D space...
std::vector< Vec4d > m_verticesWeights
weights
Base class for any geometric map.
std::vector< int > m_verticesEnclosingTetraId
Enclosing tetrahedra to interpolate the weights upon.
Computes and applies the PointSet-Tetrahedra map. Vertices of the child geometry are deformed accordi...
int findEnclosingTetrahedron(const Vec3d &pos) const
Find the tetrahedron that encloses a given point in 3D space.