10 #include "imstkTypes.h"    11 #include "imstkVecDataArray.h"    18 #include <unordered_map>    19 #include <unordered_set>    20 #include <vtkSmartPointer.h>    30 class vtkUnstructuredGrid;
    32 class vtkDataSetAttributes;
    36 class AbstractCellMesh;
    37 class AbstractDataArray;
    38 class AnalyticalGeometry;
    44 class TetrahedralMesh;
    54 namespace GeometryUtils
    56 static std::unordered_map<int, ScalarTypeId> vtkToImstkScalarType =
    58     { VTK_VOID, IMSTK_VOID },
    59     { VTK_CHAR, IMSTK_CHAR },
    60     { VTK_UNSIGNED_CHAR, IMSTK_UNSIGNED_CHAR },
    61     { VTK_SHORT, IMSTK_SHORT },
    62     { VTK_UNSIGNED_SHORT, IMSTK_UNSIGNED_SHORT },
    63     { VTK_INT, IMSTK_INT },
    64     { VTK_UNSIGNED_INT, IMSTK_UNSIGNED_INT },
    65     { VTK_LONG, IMSTK_LONG },
    66     { VTK_UNSIGNED_LONG, IMSTK_UNSIGNED_LONG },
    67     { VTK_FLOAT, IMSTK_FLOAT },
    68     { VTK_DOUBLE, IMSTK_DOUBLE },
    69     { VTK_LONG_LONG, IMSTK_LONG_LONG },
    70     { VTK_UNSIGNED_LONG_LONG, IMSTK_UNSIGNED_LONG_LONG },
    71     { VTK_ID_TYPE, IMSTK_UNSIGNED_LONG_LONG }
    73 static std::unordered_map<ScalarTypeId, int> imstkToVtkScalarType =
    75     { IMSTK_VOID, VTK_VOID },
    76     { IMSTK_CHAR, VTK_CHAR },
    77     { IMSTK_UNSIGNED_CHAR, VTK_UNSIGNED_CHAR },
    78     { IMSTK_SHORT, VTK_SHORT },
    79     { IMSTK_UNSIGNED_SHORT, VTK_UNSIGNED_SHORT },
    80     { IMSTK_INT, VTK_INT },
    81     { IMSTK_UNSIGNED_INT, VTK_UNSIGNED_INT },
    82     { IMSTK_LONG, VTK_LONG },
    83     { IMSTK_UNSIGNED_LONG, VTK_UNSIGNED_LONG },
    84     { IMSTK_FLOAT, VTK_FLOAT },
    85     { IMSTK_DOUBLE, VTK_DOUBLE },
    86     { IMSTK_LONG_LONG, VTK_LONG_LONG },
    87     { IMSTK_UNSIGNED_LONG_LONG, VTK_UNSIGNED_LONG_LONG }
    94 vtkSmartPointer<vtkDataArray> 
coupleVtkDataArray(std::shared_ptr<AbstractDataArray> imstkArray);
    95 vtkSmartPointer<vtkImageData> coupleVtkImageData(std::shared_ptr<ImageData> imstkImageData);
   101 vtkSmartPointer<vtkDataArray> 
copyToVtkDataArray(std::shared_ptr<AbstractDataArray> imstkArray);
   102 std::shared_ptr<AbstractDataArray> copyToDataArray(vtkSmartPointer<vtkDataArray> vtkArray);
   104 std::shared_ptr<ImageData> copyToImageData(vtkSmartPointer<vtkImageData> imageDataVtk);
   105 vtkSmartPointer<vtkImageData> copyToVtkImageData(std::shared_ptr<ImageData> imageData);
   111 std::shared_ptr<PointSet> 
copyToPointSet(vtkSmartPointer<vtkPointSet> vtkMesh);
   116 std::shared_ptr<SurfaceMesh> 
copyToSurfaceMesh(vtkSmartPointer<vtkPolyData> vtkMesh);
   121 std::shared_ptr<LineMesh> 
copyToLineMesh(vtkSmartPointer<vtkPolyData> vtkMesh);
   127 std::shared_ptr<AbstractCellMesh> 
copyToCellMesh(vtkSmartPointer<vtkUnstructuredGrid> vtkMesh);
   132 vtkSmartPointer<vtkPointSet> 
copyToVtkPointSet(std::shared_ptr<PointSet> imstkMesh);
   137 vtkSmartPointer<vtkPolyData> 
copyToVtkPolyData(std::shared_ptr<LineMesh> imstkMesh);
   142 vtkSmartPointer<vtkPolyData> 
copyToVtkPolyData(std::shared_ptr<SurfaceMesh> imstkMesh);
   157 std::shared_ptr<VecDataArray<double, 3>> 
copyToVecDataArray(vtkSmartPointer<vtkPoints> points);
   179 void copyToDataMap(vtkDataSetAttributes* pointData, std::unordered_map<std::string, std::shared_ptr<AbstractDataArray>>& dataMap);
   185 void copyToVtkDataAttributes(vtkDataSetAttributes* pointData, 
const std::unordered_map<std::string, std::shared_ptr<AbstractDataArray>>& dataMap);
   191                                                    const unsigned int phiDivisions, 
const unsigned int thetaDivisions);
   196 std::shared_ptr<SurfaceMesh> 
toSurfaceMesh(std::shared_ptr<AnalyticalGeometry> geom);
   205 std::shared_ptr<TetrahedralMesh> 
toTetGrid(
   206     const Vec3d& center, 
const Vec3d& size, 
const Vec3i& divisions,
   207     const Quatd orientation = Quatd::Identity());
   217     const Vec3d& center, 
const Vec2d& size, 
const Vec2i& dim,
   218     const Quatd orientation = Quatd::Identity(),
   219     const double uvScale    = 1.0);
   228 std::shared_ptr<LineMesh> 
toLineGrid(
const Vec3d& start, 
const Vec3d& dir,
   229                                      const double length, 
const int dim);
   248 double getVolume(std::shared_ptr<SurfaceMesh> surfMesh);
   260 std::shared_ptr<TetrahedralMesh> 
createUniformMesh(
const Vec3d& aabbMin, 
const Vec3d& aabbMax, 
const int nx, 
const int ny, 
const int nz);
   265 std::shared_ptr<TetrahedralMesh> 
createTetrahedralMeshCover(std::shared_ptr<SurfaceMesh> surfMesh, 
const int nx, 
const int ny, 
int nz);
   283 template<
typename NeighborContainer>
   295 template<
typename ElemConn>
 vtkSmartPointer< vtkUnstructuredGrid > copyToVtkUnstructuredGrid(std::shared_ptr< TetrahedralMesh > imstkMesh)
Converts imstk tetrahedral mesh into a vtk unstructured grid. 
 
std::shared_ptr< SurfaceMesh > toTriangleGrid(const Vec3d ¢er, const Vec2d &size, const Vec2i &dim, const Quatd orientation=Quatd::Identity(), const double uvScale=1.0)
Produces a triangle grid on a plane given the imstkPlane. 
 
vtkSmartPointer< vtkDataArray > coupleVtkDataArray(std::shared_ptr< AbstractDataArray > imstkArray)
Coupling functions, these create vtk data objects that point to our data objects thus no copying is d...
 
bool isClosed(std::shared_ptr< SurfaceMesh > surfMesh)
Returns if the surface is closed or not. 
 
std::shared_ptr< LineMesh > copyToLineMesh(vtkSmartPointer< vtkPolyData > vtkMesh)
Converts vtk polydata into a imstk surface mesh. 
 
vtkSmartPointer< vtkPolyData > copyToVtkPolyData(std::shared_ptr< LineMesh > imstkMesh)
Converts imstk line mesh into a vtk polydata. 
 
int getOpenEdgeCount(std::shared_ptr< SurfaceMesh > surfMesh)
Returns the number of open edges, use to tell if manifold (==0) 
 
vtkSmartPointer< vtkPoints > copyToVtkPoints(std::shared_ptr< VecDataArray< double, 3 >> vertices)
Copies vertices from imstk structure to VTK one. 
 
std::shared_ptr< TetrahedralMesh > toTetGrid(const Vec3d ¢er, const Vec3d &size, const Vec3i &divisions, const Quatd orientation=Quatd::Identity())
Produces a tetrahedral grid given the OrientedBox with the given divisions. 
 
std::shared_ptr< AbstractCellMesh > copyToCellMesh(vtkSmartPointer< vtkUnstructuredGrid > vtkMesh)
Get imstk cell mesh given vtkUnstructuredGrid as input iMSTK only supports homogenous cells...
 
std::shared_ptr< LineMesh > toLineGrid(const Vec3d &start, const Vec3d &dir, const double length, const int dim)
Creates a set of connected lines. 
 
vtkSmartPointer< vtkPointSet > copyToVtkPointSet(std::shared_ptr< PointSet > imstkMesh)
Converts imstk point set into a vtk polydata. 
 
void copyToDataMap(vtkDataSetAttributes *pointData, std::unordered_map< std::string, std::shared_ptr< AbstractDataArray >> &dataMap)
Copy vtkPointData to a data map. 
 
std::shared_ptr< TetrahedralMesh > createUniformMesh(const Vec3d &aabbMin, const Vec3d &aabbMax, const int nx, const int ny, const int nz)
Create a tetrahedral mesh based on a uniform Cartesian mesh. 
 
std::shared_ptr< SurfaceMesh > toUVSphereSurfaceMesh(std::shared_ptr< Sphere > sphere, const unsigned int phiDivisions, const unsigned int thetaDivisions)
UV sphere from imstkSphere. 
 
std::shared_ptr< SurfaceMesh > copyToSurfaceMesh(vtkSmartPointer< vtkPolyData > vtkMesh)
Converts vtk polydata into a imstk surface mesh. 
 
std::shared_ptr< TetrahedralMesh > createTetrahedralMeshCover(std::shared_ptr< SurfaceMesh > surfMesh, const int nx, const int ny, int nz)
Create a tetrahedral mesh cover. 
 
double getVolume(std::shared_ptr< SurfaceMesh > surfMesh)
Returns volume estimate of closed SurfaceMesh. 
 
vtkSmartPointer< vtkCellArray > copyToVtkCellArray(std::shared_ptr< VecDataArray< int, dim >> cells)
Copies cells of the given dimension from imstk structure to VTK one. 
 
void copyToVtkDataAttributes(vtkDataSetAttributes *pointData, const std::unordered_map< std::string, std::shared_ptr< AbstractDataArray >> &dataMap)
Copy from a data map to vtkDataAttributes (used for vtkCellData and vtkPointData) warning: Components...
 
std::shared_ptr< PointSet > copyToPointSet(vtkSmartPointer< vtkPointSet > vtkMesh)
Converts vtk polydata into a imstk point set. 
 
vtkSmartPointer< vtkDataArray > copyToVtkDataArray(std::shared_ptr< AbstractDataArray > imstkArray)
Copy functions, these copy to/from vtk data objects. 
 
std::shared_ptr< SurfaceMesh > toSurfaceMesh(std::shared_ptr< AnalyticalGeometry > geom)
Produces SurfaceMesh from an analytical geometry. 
 
MeshNodeRenumberingStrategy
Enumeration for reordering method. 
 
std::shared_ptr< VecDataArray< double, 3 > > copyToVecDataArray(vtkSmartPointer< vtkPoints > points)
Copy from vtk points to a imstk vertices array. 
 
std::vector< size_t > reorderConnectivity(const std::vector< NeighborContainer > &neighbors, const MeshNodeRenumberingStrategy &method=MeshNodeRenumberingStrategy::ReverseCuthillMckee)
Reorder indices in a connectivity to reduce bandwidth.