iMSTK
Interactive Medical Simulation Toolkit
imstkLocalMarchingCubes.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 <list>
13 #include <unordered_set>
14 
15 namespace imstk
16 {
17 class ImageData;
18 class SurfaceMesh;
19 
34 {
35 public:
37  ~LocalMarchingCubes() override = default;
38 
39  std::shared_ptr<SurfaceMesh> getOutputMesh(const int i) const;
40 
41  void setInputImage(std::shared_ptr<ImageData> inputImage);
42 
46  void setIsoValue(double isovalue) { m_isoValue = isovalue; }
47 
51  void setAllModified(bool val) { m_allModified = val; }
52 
57  void setModified(const Vec3i& coord);
58 
62  void clearModified() { m_modifiedVoxels.clear(); }
63 
70  void setNumberOfChunks(const Vec3i& numChunks);
71 
72  const Vec3i& getNumberOfChunks() const { return m_numChunks; }
73 
74  std::unordered_map<int, Vec3i> getModifiedChunks() { return m_modifiedChunks; }
75 
76 protected:
77  void requestUpdate() override;
78 
79 private:
80  // Id + coordinate of the modified voxels
81  std::unordered_map<int, Vec3i> m_modifiedVoxels; // Id + coordinate
82 
83  bool m_allModified = true;
84 
85  double m_isoValue = 0.0;
86 
87  Vec3i m_numChunks = Vec3i(0, 0, 0); // Number of chunks along x, y, z
88  size_t m_chunkCount = 0;
89 
90  std::unordered_map<int, Vec3i> m_modifiedChunks;
91 };
92 } // namespace imstk
void setModified(const Vec3i &coord)
Set a voxel that was modified in the image (the neighboring dual voxels will be updated on the next r...
void setAllModified(bool val)
Set all voxels as modified (used initially)
void setIsoValue(double isovalue)
Value where the boundary lies.
Compound Geometry.
void setNumberOfChunks(const Vec3i &numChunks)
Set the number of chunks. one minus the dimensions of image must be divisible by numChunks ((dimensio...
void clearModified()
Clear all pending modifications.
This filter extracts a contour SurfaceMesh from an image given an isovalue. Users should prefer imstk...
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.