iMSTK
Interactive Medical Simulation Toolkit
ConvertVTKToVega.cpp
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 #include "imstkMeshIO.h"
8 #include "imstkTetrahedralMesh.h"
9 #include "imstkVegaMeshIO.h"
10 #include "imstkVTKMeshIO.h"
11 
12 using namespace imstk;
13 
14 const std::string defaultFileName = iMSTK_DATA_ROOT "textured_organs/heart_volume.vtk";
15 
16 int
17 main(int argc, char** argv)
18 {
19  std::string vtkFileName = defaultFileName;
20  std::string vegaFileName = "convertedMesh.veg";
21 
22  if (argc > 1)
23  {
24  vtkFileName = std::string(argv[1]);
25  }
26 
27  auto tetMesh = MeshIO::read<TetrahedralMesh>(vtkFileName);
28  tetMesh->rotate(Vec3d(1.0, 0.0, 0.0), -1.3, Geometry::TransformType::ApplyToData);
29  bool converted = VegaMeshIO::write(tetMesh, vegaFileName, MeshFileType::VEG);
30  VTKMeshIO::write(tetMesh, "convertedMesh.vtk", MeshFileType::VTK);
31 
32  if (converted)
33  {
34  return 0;
35  }
36  return 1;
37 }
Compound Geometry.
static bool write(const std::shared_ptr< PointSet > imstkMesh, const std::string &filePath, const MeshFileType meshType)
Writes the given mesh to the specified file path.
static bool write(const std::shared_ptr< imstk::PointSet > imstkMesh, const std::string &filePath, const MeshFileType meshType)
Write a volumetric mesh in vega file format.