From 29484105a506d5bf8bce44f48f9c41ad796bd4d3 Mon Sep 17 00:00:00 2001
From: Sreekanth <venkatnitk@gmail.com>
Date: Wed, 18 Mar 2020 23:15:41 -0400
Subject: [PATCH] REFAC: Make getters for geometry data const

---
 Source/Geometry/Analytic/imstkAnalyticalGeometry.cpp | 2 +-
 Source/Geometry/Analytic/imstkAnalyticalGeometry.h   | 6 +++---
 Source/Geometry/Analytic/imstkCapsule.cpp            | 2 +-
 Source/Geometry/Analytic/imstkCapsule.h              | 6 +++---
 Source/Geometry/Analytic/imstkCube.cpp               | 2 +-
 Source/Geometry/Analytic/imstkCube.h                 | 4 ++--
 Source/Geometry/Analytic/imstkCylinder.cpp           | 2 +-
 Source/Geometry/Analytic/imstkCylinder.h             | 6 +++---
 Source/Geometry/Analytic/imstkPlane.cpp              | 2 +-
 Source/Geometry/Analytic/imstkPlane.h                | 4 ++--
 Source/Geometry/Analytic/imstkSphere.cpp             | 2 +-
 Source/Geometry/Analytic/imstkSphere.h               | 4 ++--
 Source/Geometry/Decal/imstkDecalPool.h               | 2 +-
 Source/Geometry/Mesh/imstkImageData.cpp              | 2 +-
 Source/Geometry/Mesh/imstkImageData.h                | 2 +-
 Source/Geometry/Mesh/imstkPointSet.cpp               | 6 +++---
 Source/Geometry/Mesh/imstkPointSet.h                 | 8 ++++----
 Source/Geometry/Particles/imstkRenderParticles.h     | 2 +-
 Source/Geometry/imstkGeometry.h                      | 4 ++--
 19 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/Source/Geometry/Analytic/imstkAnalyticalGeometry.cpp b/Source/Geometry/Analytic/imstkAnalyticalGeometry.cpp
index 5fd1b4c7c..2c5ac36dd 100644
--- a/Source/Geometry/Analytic/imstkAnalyticalGeometry.cpp
+++ b/Source/Geometry/Analytic/imstkAnalyticalGeometry.cpp
@@ -102,7 +102,7 @@ AnalyticalGeometry::applyRotation(const Mat3d r)
 }
 
 void
-AnalyticalGeometry::updatePostTransformData()
+AnalyticalGeometry::updatePostTransformData() const
 {
     m_orientationAxisPostTransform = m_transform.rotation() * m_orientationAxis;
     m_orientationAxisPostTransform.normalize();
diff --git a/Source/Geometry/Analytic/imstkAnalyticalGeometry.h b/Source/Geometry/Analytic/imstkAnalyticalGeometry.h
index e643ca5f1..f9919f112 100644
--- a/Source/Geometry/Analytic/imstkAnalyticalGeometry.h
+++ b/Source/Geometry/Analytic/imstkAnalyticalGeometry.h
@@ -61,12 +61,12 @@ protected:
 
     void applyTranslation(const Vec3d t) override;
     void applyRotation(const Mat3d r) override;
-    virtual void updatePostTransformData() override;
+    virtual void updatePostTransformData() const override;
 
     Vec3d m_position = WORLD_ORIGIN;                  ///> position
-    Vec3d m_positionPostTransform = WORLD_ORIGIN;     ///> position once transform applied
+    mutable Vec3d m_positionPostTransform = WORLD_ORIGIN;     ///> position once transform applied
 
     Vec3d m_orientationAxis = UP_VECTOR;              ///> orientation
-    Vec3d m_orientationAxisPostTransform = UP_VECTOR; ///> orientation once transform applied
+    mutable Vec3d m_orientationAxisPostTransform = UP_VECTOR; ///> orientation once transform applied
 };
 } //imstk
diff --git a/Source/Geometry/Analytic/imstkCapsule.cpp b/Source/Geometry/Analytic/imstkCapsule.cpp
index a2634283d..bbdc898ce 100644
--- a/Source/Geometry/Analytic/imstkCapsule.cpp
+++ b/Source/Geometry/Analytic/imstkCapsule.cpp
@@ -89,7 +89,7 @@ Capsule::applyScaling(const double s)
 }
 
 void
-Capsule::updatePostTransformData()
+Capsule::updatePostTransformData() const
 {
     if (m_transformApplied)
     {
diff --git a/Source/Geometry/Analytic/imstkCapsule.h b/Source/Geometry/Analytic/imstkCapsule.h
index 5c11ffbd9..7cdb8260c 100644
--- a/Source/Geometry/Analytic/imstkCapsule.h
+++ b/Source/Geometry/Analytic/imstkCapsule.h
@@ -73,11 +73,11 @@ protected:
     friend class VTKCapsuleRenderDelegate;
 
     void applyScaling(const double s) override;
-    void updatePostTransformData() override;
+    void updatePostTransformData() const override;
 
     double m_radius = 1.0;              ///> Radius of the hemispheres at the end of the capsule
-    double m_radiusPostTransform = 1.0; ///> Radius after transform
+    mutable double m_radiusPostTransform = 1.0; ///> Radius after transform
     double m_length = 1.0;              ///> Length between the centers of two hemispheres
-    double m_lengthPostTransform = 1.0; ///> Length after transform
+    mutable double m_lengthPostTransform = 1.0; ///> Length after transform
 };
 } // imstk
diff --git a/Source/Geometry/Analytic/imstkCube.cpp b/Source/Geometry/Analytic/imstkCube.cpp
index 63c1cd78e..98c8d9c5d 100644
--- a/Source/Geometry/Analytic/imstkCube.cpp
+++ b/Source/Geometry/Analytic/imstkCube.cpp
@@ -71,7 +71,7 @@ Cube::applyScaling(const double s)
 }
 
 void
-Cube::updatePostTransformData()
+Cube::updatePostTransformData() const
 {
     if (m_transformApplied)
     {
diff --git a/Source/Geometry/Analytic/imstkCube.h b/Source/Geometry/Analytic/imstkCube.h
index e36a6ca2f..52c89940f 100644
--- a/Source/Geometry/Analytic/imstkCube.h
+++ b/Source/Geometry/Analytic/imstkCube.h
@@ -60,9 +60,9 @@ protected:
     friend class VTKCubeRenderDelegate;
 
     void applyScaling(const double s) override;
-    void updatePostTransformData() override;
+    void updatePostTransformData() const override;
 
     double m_width = 1.0;               ///> Width of the cube
-    double m_widthPostTransform = 1.0;  ///> Width of the cube once transform applied
+    mutable double m_widthPostTransform = 1.0;  ///> Width of the cube once transform applied
 };
 }
diff --git a/Source/Geometry/Analytic/imstkCylinder.cpp b/Source/Geometry/Analytic/imstkCylinder.cpp
index 38a1e253c..ee0fa6295 100644
--- a/Source/Geometry/Analytic/imstkCylinder.cpp
+++ b/Source/Geometry/Analytic/imstkCylinder.cpp
@@ -101,7 +101,7 @@ Cylinder::applyScaling(const double s)
 }
 
 void
-Cylinder::updatePostTransformData()
+Cylinder::updatePostTransformData() const
 {
     if (m_transformApplied)
     {
diff --git a/Source/Geometry/Analytic/imstkCylinder.h b/Source/Geometry/Analytic/imstkCylinder.h
index 5f7e02cc5..63462cfdf 100644
--- a/Source/Geometry/Analytic/imstkCylinder.h
+++ b/Source/Geometry/Analytic/imstkCylinder.h
@@ -73,11 +73,11 @@ protected:
     friend class VTKCylinderRenderDelegate;
 
     void applyScaling(const double s) override;
-    void updatePostTransformData() override;
+    void updatePostTransformData() const override;
 
     double m_radius = 1.;              ///> Radius of the cylinder
     double m_length = 1.;              ///> Length of the cylinder
-    double m_radiusPostTransform = 1.; ///> Radius of the cylinder oncee transform applied
-    double m_lengthPostTransform = 1.; ///> Length of the cylinder onc transform applied
+    mutable double m_radiusPostTransform = 1.; ///> Radius of the cylinder oncee transform applied
+    mutable double m_lengthPostTransform = 1.; ///> Length of the cylinder onc transform applied
 };
 } // imstk
diff --git a/Source/Geometry/Analytic/imstkPlane.cpp b/Source/Geometry/Analytic/imstkPlane.cpp
index 1d1822a75..d298d07ef 100644
--- a/Source/Geometry/Analytic/imstkPlane.cpp
+++ b/Source/Geometry/Analytic/imstkPlane.cpp
@@ -89,7 +89,7 @@ Plane::applyScaling(const double s)
 }
 
 void
-Plane::updatePostTransformData()
+Plane::updatePostTransformData() const
 {
     if (m_transformApplied)
     {
diff --git a/Source/Geometry/Analytic/imstkPlane.h b/Source/Geometry/Analytic/imstkPlane.h
index dd7c4a6f6..90a9a3e09 100644
--- a/Source/Geometry/Analytic/imstkPlane.h
+++ b/Source/Geometry/Analytic/imstkPlane.h
@@ -74,9 +74,9 @@ protected:
     friend class VTKPlaneRenderDelegate;
 
     void applyScaling(const double s) override;
-    void updatePostTransformData() override;
+    void updatePostTransformData() const override;
 
     double m_width = 1.0;               ///> Width of the plane
-    double m_widthPostTransform = 1.0;  ///> Width of the plane once transform applied
+    mutable double m_widthPostTransform = 1.0;  ///> Width of the plane once transform applied
 };
 } // imstk
diff --git a/Source/Geometry/Analytic/imstkSphere.cpp b/Source/Geometry/Analytic/imstkSphere.cpp
index 05d4d9dc7..65af6c65b 100644
--- a/Source/Geometry/Analytic/imstkSphere.cpp
+++ b/Source/Geometry/Analytic/imstkSphere.cpp
@@ -88,7 +88,7 @@ Sphere::applyScaling(const double s)
 }
 
 void
-Sphere::updatePostTransformData()
+Sphere::updatePostTransformData() const
 {
     if (m_transformApplied)
     {
diff --git a/Source/Geometry/Analytic/imstkSphere.h b/Source/Geometry/Analytic/imstkSphere.h
index 4ae41fd64..1cf181294 100644
--- a/Source/Geometry/Analytic/imstkSphere.h
+++ b/Source/Geometry/Analytic/imstkSphere.h
@@ -68,9 +68,9 @@ protected:
     friend class VTKSphereRenderDelegate;
 
     void applyScaling(const double s) override;
-    void updatePostTransformData() override;
+    void updatePostTransformData() const override;
 
     double m_radius = 1.0;              ///> Radius of the sphere
-    double m_radiusPostTransform = 1.0; ///> Radius of the sphere once transform applied
+    mutable double m_radiusPostTransform = 1.0; ///> Radius of the sphere once transform applied
 };
 } // imstk
diff --git a/Source/Geometry/Decal/imstkDecalPool.h b/Source/Geometry/Decal/imstkDecalPool.h
index 3f20ae0d0..1a2ceed70 100644
--- a/Source/Geometry/Decal/imstkDecalPool.h
+++ b/Source/Geometry/Decal/imstkDecalPool.h
@@ -61,7 +61,7 @@ protected:
     void applyTranslation(const Vec3d t) override {}
     void applyRotation(const Mat3d r) override {}
     void applyScaling(const double s) override {}
-    virtual void updatePostTransformData() override {}
+    virtual void updatePostTransformData() const override {}
 
     unsigned int m_maxNumDecals;
     unsigned int m_numDecals = 0;
diff --git a/Source/Geometry/Mesh/imstkImageData.cpp b/Source/Geometry/Mesh/imstkImageData.cpp
index 21845bbb1..34d17a2a1 100644
--- a/Source/Geometry/Mesh/imstkImageData.cpp
+++ b/Source/Geometry/Mesh/imstkImageData.cpp
@@ -123,7 +123,7 @@ ImageData::applyRotation(const Mat3d r)
 }
 
 void
-ImageData::updatePostTransformData()
+ImageData::updatePostTransformData() const
 {
     if (m_transformApplied || !this->m_data)
     {
diff --git a/Source/Geometry/Mesh/imstkImageData.h b/Source/Geometry/Mesh/imstkImageData.h
index 4d5fa73d9..a90b1073d 100644
--- a/Source/Geometry/Mesh/imstkImageData.h
+++ b/Source/Geometry/Mesh/imstkImageData.h
@@ -83,6 +83,6 @@ protected:
 
     void applyScaling(const double s) override;
 
-    void updatePostTransformData() override;
+    void updatePostTransformData() const override;
 };
 } // imstk
diff --git a/Source/Geometry/Mesh/imstkPointSet.cpp b/Source/Geometry/Mesh/imstkPointSet.cpp
index 2f868ccec..b33d9af57 100644
--- a/Source/Geometry/Mesh/imstkPointSet.cpp
+++ b/Source/Geometry/Mesh/imstkPointSet.cpp
@@ -113,7 +113,7 @@ PointSet::setVertexPositions(const StdVectorOfVec3d& vertices)
 }
 
 const StdVectorOfVec3d&
-PointSet::getVertexPositions(DataType type /* = DataType::PostTransform */)
+PointSet::getVertexPositions(DataType type /* = DataType::PostTransform */) const
 {
     if (type == DataType::PostTransform)
     {
@@ -136,7 +136,7 @@ PointSet::setVertexPosition(const size_t vertNum, const Vec3d& pos)
 }
 
 const Vec3d&
-PointSet::getVertexPosition(const size_t vertNum, DataType type)
+PointSet::getVertexPosition(const size_t vertNum, DataType type) const
 {
 #if defined(DEBUG) || defined(_DEBUG) || !defined(NDEBUG)
     LOG_IF(FATAL, (vertNum >= getVertexPositions().size())) << "Invalid index";
@@ -275,7 +275,7 @@ PointSet::applyScaling(const double s)
 }
 
 void
-PointSet::updatePostTransformData()
+PointSet::updatePostTransformData() const
 {
     if (m_transformApplied)
     {
diff --git a/Source/Geometry/Mesh/imstkPointSet.h b/Source/Geometry/Mesh/imstkPointSet.h
index 4b7b27b4a..f47b909e9 100644
--- a/Source/Geometry/Mesh/imstkPointSet.h
+++ b/Source/Geometry/Mesh/imstkPointSet.h
@@ -91,7 +91,7 @@ public:
     ///
     /// \brief Returns the vector of current positions of the mesh vertices
     ///
-    const StdVectorOfVec3d& getVertexPositions(DataType type = DataType::PostTransform);
+    const StdVectorOfVec3d& getVertexPositions(DataType type = DataType::PostTransform) const;
 
     ///
     /// \brief Set the current position of a vertex given its index to certain position (this is not a thread-safe method)
@@ -101,7 +101,7 @@ public:
     ///
     /// \brief Returns the position of a vertex given its index
     ///
-    const Vec3d& getVertexPosition(const size_t vertNum, DataType type = DataType::PostTransform);
+    const Vec3d& getVertexPosition(const size_t vertNum, DataType type = DataType::PostTransform) const;
 
     ///
     /// \brief Sets the displacements of mesh vertices from an array
@@ -177,11 +177,11 @@ protected:
     void applyTranslation(const Vec3d t) override;
     void applyRotation(const Mat3d r) override;
     void applyScaling(const double s) override;
-    void updatePostTransformData() override;
+    void updatePostTransformData() const override;
 
     StdVectorOfVec3d m_initialVertexPositions;                ///> Initial positions of vertices
     StdVectorOfVec3d m_vertexPositions;                       ///> Current positions of vertices
-    StdVectorOfVec3d m_vertexPositionsPostTransform;          ///> Positions of vertices after transform
+    mutable StdVectorOfVec3d m_vertexPositionsPostTransform;  ///> Positions of vertices after transform
 
     std::map<std::string, StdVectorOfVectorf> m_pointDataMap; ///> vector of data arrays per vertice
 
diff --git a/Source/Geometry/Particles/imstkRenderParticles.h b/Source/Geometry/Particles/imstkRenderParticles.h
index 56b8c751f..923c41fb5 100644
--- a/Source/Geometry/Particles/imstkRenderParticles.h
+++ b/Source/Geometry/Particles/imstkRenderParticles.h
@@ -127,6 +127,6 @@ protected:
     void applyTranslation(const Vec3d t) override {}
     void applyRotation(const Mat3d r) override {}
     void applyScaling(const double s) override {}
-    virtual void updatePostTransformData() override {}
+    virtual void updatePostTransformData() const override {}
 };
 }
diff --git a/Source/Geometry/imstkGeometry.h b/Source/Geometry/imstkGeometry.h
index 66608d150..8a12bb6aa 100644
--- a/Source/Geometry/imstkGeometry.h
+++ b/Source/Geometry/imstkGeometry.h
@@ -205,7 +205,7 @@ protected:
     virtual void applyTranslation(const Vec3d t) = 0;
     virtual void applyRotation(const Mat3d r)    = 0;
     virtual void applyScaling(const double s)    = 0;
-    virtual void updatePostTransformData()       = 0;
+    virtual void updatePostTransformData() const  const = 0;
 
     Type m_type;                 ///> Type of geometry
     std::string m_name;          ///> Unique name for each geometry
@@ -213,7 +213,7 @@ protected:
 
     bool m_dataModified      = false;
     bool m_transformModified = false;
-    bool m_transformApplied  = true;
+    mutable bool m_transformApplied  = true;
 
     RigidTransform3d m_transform = RigidTransform3d::Identity(); ///> Transformation matrix
     double m_scaling = 1.0;
-- 
GitLab