From 4f9a8cbe4c0a4911d1c01673fc77424a8b3549ba Mon Sep 17 00:00:00 2001
From: Sreekanth Arikatla <sreekanth.arikatla@kitware.com>
Date: Mon, 4 Apr 2016 17:45:07 -0400
Subject: [PATCH] ENH: Adds tests for geometric mapping

Adds visual tests for Isometric mapping
---
 Base/Geometry/imstkIsometricMap.h |  2 ++
 Examples/Sandbox/main.cpp         | 56 +++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+)

diff --git a/Base/Geometry/imstkIsometricMap.h b/Base/Geometry/imstkIsometricMap.h
index 12e78aa6f..d5b81f5df 100644
--- a/Base/Geometry/imstkIsometricMap.h
+++ b/Base/Geometry/imstkIsometricMap.h
@@ -36,6 +36,8 @@ public:
 
     void applyMap();
 
+    void computeMap(){};
+
     // Accessors
     void setTransform(const RigidTransform3d& affineTransform);
     const RigidTransform3d& getTransform() const;
diff --git a/Examples/Sandbox/main.cpp b/Examples/Sandbox/main.cpp
index c8bdc051c..ca28e217f 100644
--- a/Examples/Sandbox/main.cpp
+++ b/Examples/Sandbox/main.cpp
@@ -11,10 +11,16 @@
 #include "imstkMath.h"
 #include "imstkSimulationManager.h"
 
+// Maps
+#include "imstkIsometricMap.h"
+
 #include "g3log/g3log.hpp"
 
+void testGeometryMaps();
+
 int main()
 {
+
     std::cout << "****************" << std::endl
               << "Starting Sandbox" << std::endl
               << "****************" << std::endl;
@@ -52,6 +58,7 @@ int main()
 
     sdk->startSimulation("SceneTest");
 
+
     /*
         //--------------------------------------------
         // Geometry
@@ -140,3 +147,52 @@ int main()
 
     return 0;
 }
+
+void testGeometryMaps()
+{
+    std::cout << "****************" << std::endl
+        << "Test: Geometric maps" << std::endl
+        << "****************" << std::endl;
+
+    auto sdk = std::make_shared<imstk::SimulationManager>();
+
+    // Scene object 1
+    auto cubeGeom = std::make_shared<imstk::Cube>();
+    cubeGeom->scale(0.5);
+    auto cubeObj = std::make_shared<imstk::VisualObject>("VisualCube");
+    cubeObj->setVisualGeometry(cubeGeom);
+
+    // Scene object 2
+    auto sphereGeom = std::make_shared<imstk::Sphere>();
+    sphereGeom->scale(0.3);
+    auto sphereObj = std::make_shared<imstk::VisualObject>("VisualSphere");
+    sphereObj->setVisualGeometry(sphereGeom);
+
+    // Isometric Map
+    auto rigidMap = std::make_shared<imstk::IsometricMap>();
+
+    rigidMap->setMaster(sphereObj->getVisualGeometry());
+    rigidMap->setSlave(cubeObj->getVisualGeometry());
+
+    auto trans = imstk::RigidTransform3d::Identity();
+    trans.translate(imstk::Vec3d(1.5, 1.5, 1.5));
+
+    auto rz = imstk::RigidTransform3d(Eigen::AngleAxisd(imstk::PI_4, imstk::Vec3d(0, 1.0, 0)));
+    trans.rotate(rz.rotation());
+
+    rigidMap->setTransform(trans);
+
+    // Apply map
+    rigidMap->applyMap();
+
+    // Move master and Apply map again
+    sphereObj->getVisualGeometry()->setPosition(-1.0, 0, 0);
+    rigidMap->applyMap();
+
+    auto geometryMapTest = sdk->createNewScene("geometryMapTest");
+    geometryMapTest->setLoopDelay(1000);
+    geometryMapTest->addSceneObject(cubeObj);
+    geometryMapTest->addSceneObject(sphereObj);
+
+    sdk->startSimulation("geometryMapTest");
+}
\ No newline at end of file
-- 
GitLab