diff --git a/CMakeLists.txt b/CMakeLists.txt index 38e8085e9d83be086dc3b623d64e63fd8bdf1337..3c89c282e76636b56439ebb0ed9da8d319a1bd98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -377,7 +377,6 @@ add_subdirectory(Source/CollisionDetection) add_subdirectory(Source/CollisionHandling) add_subdirectory(Source/Scene) add_subdirectory(Source/SimulationManager) -add_subdirectory(Source/apiUtilities) add_subdirectory(Source/Filtering) add_subdirectory(Source/FilteringCore) diff --git a/Examples/BoneShaving/CMakeLists.txt b/Examples/BoneShaving/CMakeLists.txt index be6b047dfb1ac1f3d083b81b965095c9138309f6..f5951b4c7d0a6f4ac71c05f4500202a9c295a264 100644 --- a/Examples/BoneShaving/CMakeLists.txt +++ b/Examples/BoneShaving/CMakeLists.txt @@ -36,11 +36,10 @@ if(iMSTK_USE_OpenHaptics) if(UNIX) target_link_libraries(${PROJECT_NAME} SimulationManager - apiUtilities) + ) else() target_link_libraries(${PROJECT_NAME} SimulationManager - apiUtilities SFML) endif() diff --git a/Examples/CameraController/CMakeLists.txt b/Examples/CameraController/CMakeLists.txt index 797e223819a63eb3c25cc1e87e6d73669c94ddf5..e3ae4737fdd8a87228abcfee79493899f43255d8 100644 --- a/Examples/CameraController/CMakeLists.txt +++ b/Examples/CameraController/CMakeLists.txt @@ -32,7 +32,7 @@ if(iMSTK_USE_OpenHaptics) #----------------------------------------------------------------------------- # Link libraries to executable #----------------------------------------------------------------------------- - target_link_libraries(${PROJECT_NAME} SimulationManager apiUtilities) + target_link_libraries(${PROJECT_NAME} SimulationManager) #----------------------------------------------------------------------------- # Associate external data diff --git a/Examples/CollisionDetection/ManualCDWithOctree/CMakeLists.txt b/Examples/CollisionDetection/ManualCDWithOctree/CMakeLists.txt index 743d27f306899765bf4ae373a5a262e7edb7223d..6e0a1accc3fba72480f10dd137a52bc0d78fd94d 100644 --- a/Examples/CollisionDetection/ManualCDWithOctree/CMakeLists.txt +++ b/Examples/CollisionDetection/ManualCDWithOctree/CMakeLists.txt @@ -35,4 +35,4 @@ SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES FOLDER Examples) #----------------------------------------------------------------------------- # Link libraries to executable #----------------------------------------------------------------------------- -target_link_libraries(${PROJECT_NAME} SimulationManager apiUtilities) +target_link_libraries(${PROJECT_NAME} SimulationManager) diff --git a/Examples/CreateEnclosingMesh/CMakeLists.txt b/Examples/CreateEnclosingMesh/CMakeLists.txt index 9c658349190c5181992b7fa427f6f5a02b2b9995..a3174ed8621dc50b0b6950b66eb53ddb964bad1d 100644 --- a/Examples/CreateEnclosingMesh/CMakeLists.txt +++ b/Examples/CreateEnclosingMesh/CMakeLists.txt @@ -31,5 +31,5 @@ SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES FOLDER Examples) #----------------------------------------------------------------------------- # Link libraries to executable #----------------------------------------------------------------------------- -target_link_libraries(${PROJECT_NAME} apiUtilities) +target_link_libraries(${PROJECT_NAME} Common SimulationManager SceneEntities) diff --git a/Examples/DebugRendering/CMakeLists.txt b/Examples/DebugRendering/CMakeLists.txt index fd3197b4324d534d35b687584f839f83cc99082e..eb4ecf407207a52ddc5dec57590b0062d9eba0ec 100644 --- a/Examples/DebugRendering/CMakeLists.txt +++ b/Examples/DebugRendering/CMakeLists.txt @@ -31,4 +31,4 @@ SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES FOLDER Examples) #----------------------------------------------------------------------------- # Link libraries to executable #----------------------------------------------------------------------------- -target_link_libraries(${PROJECT_NAME} SimulationManager apiUtilities) +target_link_libraries(${PROJECT_NAME} SimulationManager) diff --git a/Examples/DeformableBody/CMakeLists.txt b/Examples/DeformableBody/CMakeLists.txt index 50396605859e9d05a4a594f824c0093bce057bea..104d32fcb54a1d3d184ebaa053904dbfffb9e8f7 100644 --- a/Examples/DeformableBody/CMakeLists.txt +++ b/Examples/DeformableBody/CMakeLists.txt @@ -31,4 +31,4 @@ SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES FOLDER Examples) #----------------------------------------------------------------------------- # Link libraries to executable #----------------------------------------------------------------------------- -target_link_libraries(${PROJECT_NAME} SimulationManager apiUtilities) +target_link_libraries(${PROJECT_NAME} SimulationManager) diff --git a/Examples/GeometryProcessing/CMakeLists.txt b/Examples/GeometryProcessing/CMakeLists.txt index 0abe14903b4ffbda995eaa3d783c1fe8e8f9b060..3baf12ddbefe20d04f5f0b25d372b217a70ab35b 100644 --- a/Examples/GeometryProcessing/CMakeLists.txt +++ b/Examples/GeometryProcessing/CMakeLists.txt @@ -31,4 +31,4 @@ SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES FOLDER Examples) #----------------------------------------------------------------------------- # Link libraries to executable #----------------------------------------------------------------------------- -target_link_libraries(${PROJECT_NAME} SimulationManager apiUtilities Filtering) +target_link_libraries(${PROJECT_NAME} SimulationManager Filtering) diff --git a/Examples/GeometryTransforms/CMakeLists.txt b/Examples/GeometryTransforms/CMakeLists.txt index 412eb8054a4baf51461059ba010f56e384c840ab..fdd23f2a232c1c652b128173f7be4f5163f67648 100644 --- a/Examples/GeometryTransforms/CMakeLists.txt +++ b/Examples/GeometryTransforms/CMakeLists.txt @@ -31,4 +31,4 @@ SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES FOLDER Examples) #----------------------------------------------------------------------------- # Link libraries to executable #----------------------------------------------------------------------------- -target_link_libraries(${PROJECT_NAME} SimulationManager apiUtilities) +target_link_libraries(${PROJECT_NAME} SimulationManager) diff --git a/Examples/GeometryTransforms/GeometryTransformsExample.cpp b/Examples/GeometryTransforms/GeometryTransformsExample.cpp index 287d5f2e74c974c33fda3a290ab23458a5e6451c..e5ad0e3b10b3e04d7c52325118dec0e3d10c919c 100644 --- a/Examples/GeometryTransforms/GeometryTransformsExample.cpp +++ b/Examples/GeometryTransforms/GeometryTransformsExample.cpp @@ -19,7 +19,6 @@ =========================================================================*/ -#include "imstkAPIUtilities.h" #include "imstkCamera.h" #include "imstkCylinder.h" #include "imstkKeyboardSceneControl.h" @@ -29,6 +28,8 @@ #include "imstkNew.h" #include "imstkOrientedBox.h" #include "imstkPlane.h" +#include "imstkSurfaceMesh.h" +#include "imstkMeshIO.h" #include "imstkRenderMaterial.h" #include "imstkScene.h" #include "imstkSceneManager.h" @@ -50,9 +51,11 @@ main() imstkNew<Scene> scene("GeometryTransforms"); - auto sceneObj = apiutils::createAndAddVisualSceneObject(scene, iMSTK_DATA_ROOT "/asianDragon/asianDragon.obj", "Dragon"); - - CHECK(sceneObj != nullptr) << "ERROR: Unable to create scene object"; + // Create object and add to scene + auto SurfaceMesh = std::dynamic_pointer_cast<imstk::SurfaceMesh>(MeshIO::read(iMSTK_DATA_ROOT "/asianDragon/asianDragon.obj")); + auto sceneObj = std::make_shared<SceneObject>("Dragon"); + sceneObj->setVisualGeometry(SurfaceMesh); + scene->addSceneObject(sceneObj); auto surfaceMesh = sceneObj->getVisualGeometry(); surfaceMesh->scale(5.0, Geometry::TransformType::ConcatenateToTransform); diff --git a/Examples/ObjectController/CMakeLists.txt b/Examples/ObjectController/CMakeLists.txt index bbc831bfa99783eb1a1b9f7ab0a8e5d2c04cc904..f4d400d5f9692db43fdb45bc9152ffb0cae2b16a 100644 --- a/Examples/ObjectController/CMakeLists.txt +++ b/Examples/ObjectController/CMakeLists.txt @@ -32,6 +32,6 @@ if(iMSTK_USE_OpenHaptics) #----------------------------------------------------------------------------- # Link libraries to executable #----------------------------------------------------------------------------- - target_link_libraries(${PROJECT_NAME} SimulationManager apiUtilities) + target_link_libraries(${PROJECT_NAME} SimulationManager) endif() diff --git a/Examples/ObjectControllerDummyClient/CMakeLists.txt b/Examples/ObjectControllerDummyClient/CMakeLists.txt index 248fcb43e92de330435e351caefe1535b34be35f..1448cc63809246d6a6f9b60c23c92214e5436600 100644 --- a/Examples/ObjectControllerDummyClient/CMakeLists.txt +++ b/Examples/ObjectControllerDummyClient/CMakeLists.txt @@ -31,5 +31,5 @@ SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES FOLDER Examples) #----------------------------------------------------------------------------- # Link libraries to executable #----------------------------------------------------------------------------- -target_link_libraries(${PROJECT_NAME} SimulationManager apiUtilities) +target_link_libraries(${PROJECT_NAME} SimulationManager) diff --git a/Examples/Octree/CMakeLists.txt b/Examples/Octree/CMakeLists.txt index bfca94999d5deef6665950fcfb4a78d6b1db28ed..98f95d91c51ed5fdcfd3c6886a934b6bb65e6017 100644 --- a/Examples/Octree/CMakeLists.txt +++ b/Examples/Octree/CMakeLists.txt @@ -31,4 +31,4 @@ SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES FOLDER Examples) #----------------------------------------------------------------------------- # Link libraries to executable #----------------------------------------------------------------------------- -target_link_libraries(${PROJECT_NAME} SimulationManager apiUtilities) +target_link_libraries(${PROJECT_NAME} SimulationManager) diff --git a/Examples/PBD/PBDCloth/CMakeLists.txt b/Examples/PBD/PBDCloth/CMakeLists.txt index 8e1aec6197321a303041ca440844ba24046b06c0..db0500ae60a96a5b9a40d1eea59f4d03a3ad1026 100644 --- a/Examples/PBD/PBDCloth/CMakeLists.txt +++ b/Examples/PBD/PBDCloth/CMakeLists.txt @@ -31,4 +31,4 @@ SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES FOLDER Examples/PBD) #----------------------------------------------------------------------------- # Link libraries to executable #----------------------------------------------------------------------------- -target_link_libraries(${PROJECT_NAME} SimulationManager apiUtilities) +target_link_libraries(${PROJECT_NAME} SimulationManager) diff --git a/Examples/PBD/PBDCollisionMultipleObjects/CMakeLists.txt b/Examples/PBD/PBDCollisionMultipleObjects/CMakeLists.txt index 6d57c6b7095ef29940aae9a751ae7fb092eaf1da..8466f312f928e63364ec53aef7a802d7aaad5951 100644 --- a/Examples/PBD/PBDCollisionMultipleObjects/CMakeLists.txt +++ b/Examples/PBD/PBDCollisionMultipleObjects/CMakeLists.txt @@ -31,4 +31,4 @@ SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES FOLDER Examples/PBD) #----------------------------------------------------------------------------- # Link libraries to executable #----------------------------------------------------------------------------- -target_link_libraries(${PROJECT_NAME} SimulationManager apiUtilities ) +target_link_libraries(${PROJECT_NAME} SimulationManager) diff --git a/Examples/PBD/PBDCollisionOneObject/CMakeLists.txt b/Examples/PBD/PBDCollisionOneObject/CMakeLists.txt index 2e02b86646e8c08ce7d1b5628166fd61ae2c85a1..d6454dd97fa2a5a9be48e359e23f830453e562a9 100644 --- a/Examples/PBD/PBDCollisionOneObject/CMakeLists.txt +++ b/Examples/PBD/PBDCollisionOneObject/CMakeLists.txt @@ -31,4 +31,4 @@ SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES FOLDER Examples/PBD) #----------------------------------------------------------------------------- # Link libraries to executable #----------------------------------------------------------------------------- -target_link_libraries(${PROJECT_NAME} SimulationManager apiUtilities) +target_link_libraries(${PROJECT_NAME} SimulationManager) diff --git a/Examples/PBD/PBDCollisionStairs/CMakeLists.txt b/Examples/PBD/PBDCollisionStairs/CMakeLists.txt index c0c0bf8fc598af7500482dcb3023681a556d4e33..e0c408bb07cf6a667f60f2442168e52b41577fc8 100644 --- a/Examples/PBD/PBDCollisionStairs/CMakeLists.txt +++ b/Examples/PBD/PBDCollisionStairs/CMakeLists.txt @@ -31,4 +31,4 @@ SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES FOLDER Examples/PBD) #----------------------------------------------------------------------------- # Link libraries to executable #----------------------------------------------------------------------------- -target_link_libraries(${PROJECT_NAME} SimulationManager apiUtilities) \ No newline at end of file +target_link_libraries(${PROJECT_NAME} SimulationManager) \ No newline at end of file diff --git a/Examples/PBD/PBDDeformableObject/CMakeLists.txt b/Examples/PBD/PBDDeformableObject/CMakeLists.txt index b677e9e8f04d309e2c1644f115c88f2c84f84902..022b4d101b55cfd1e88e3825223e4eedf6ee03d3 100644 --- a/Examples/PBD/PBDDeformableObject/CMakeLists.txt +++ b/Examples/PBD/PBDDeformableObject/CMakeLists.txt @@ -31,4 +31,4 @@ SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES FOLDER Examples/PBD) #----------------------------------------------------------------------------- # Link libraries to executable #----------------------------------------------------------------------------- -target_link_libraries(${PROJECT_NAME} SimulationManager apiUtilities) +target_link_libraries(${PROJECT_NAME} SimulationManager) diff --git a/Examples/PBDCutting/CMakeLists.txt b/Examples/PBDCutting/CMakeLists.txt index a2aff794533c4c81eed61e23e58e45c4b97ec27f..573401da589c9f93e3bd4f2b8481694c474c0d00 100644 --- a/Examples/PBDCutting/CMakeLists.txt +++ b/Examples/PBDCutting/CMakeLists.txt @@ -32,6 +32,6 @@ if(iMSTK_USE_OpenHaptics) #----------------------------------------------------------------------------- # Link libraries to executable #----------------------------------------------------------------------------- - target_link_libraries(${PROJECT_NAME} SimulationManager apiUtilities Filtering) + target_link_libraries(${PROJECT_NAME} SimulationManager Filtering) endif() diff --git a/Examples/PBDPicking/CMakeLists.txt b/Examples/PBDPicking/CMakeLists.txt index 17355b81fce860db0699f5899fb289f6b03935e5..26b5faa8ee59c773595d5a302c195dd1e4905de8 100644 --- a/Examples/PBDPicking/CMakeLists.txt +++ b/Examples/PBDPicking/CMakeLists.txt @@ -32,6 +32,6 @@ if(iMSTK_USE_OpenHaptics) #----------------------------------------------------------------------------- # Link libraries to executable #----------------------------------------------------------------------------- - target_link_libraries(${PROJECT_NAME} SimulationManager apiUtilities) + target_link_libraries(${PROJECT_NAME} SimulationManager) endif() diff --git a/Examples/RCM/CMakeLists.txt b/Examples/RCM/CMakeLists.txt index 10814d1f326c1b66b7f90cadc02a73cca99537a4..2163379bb93477cf33011e9ec54f05484a1710b0 100644 --- a/Examples/RCM/CMakeLists.txt +++ b/Examples/RCM/CMakeLists.txt @@ -31,4 +31,4 @@ SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES FOLDER Examples) #----------------------------------------------------------------------------- # Link libraries to executable #----------------------------------------------------------------------------- -target_link_libraries(${PROJECT_NAME} apiUtilities) +target_link_libraries(${PROJECT_NAME} Common SceneEntities) diff --git a/Examples/Rendering/CMakeLists.txt b/Examples/Rendering/CMakeLists.txt index badbc676327941df19c9222ecea11c4f8dc7277d..b0b6a0069756c95bf5a2bf5b02f8d6c94f841768 100644 --- a/Examples/Rendering/CMakeLists.txt +++ b/Examples/Rendering/CMakeLists.txt @@ -31,4 +31,4 @@ SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES FOLDER Examples) #----------------------------------------------------------------------------- # Link libraries to executable #----------------------------------------------------------------------------- -target_link_libraries(${PROJECT_NAME} SimulationManager apiUtilities) +target_link_libraries(${PROJECT_NAME} SimulationManager) diff --git a/Examples/Rendering/RenderingExample.cpp b/Examples/Rendering/RenderingExample.cpp index 90633cd4efe11c285c215f14e457b65cf5b4bc6a..8fbdade5452199549dd76068f9930965d4f0a713 100644 --- a/Examples/Rendering/RenderingExample.cpp +++ b/Examples/Rendering/RenderingExample.cpp @@ -19,12 +19,12 @@ =========================================================================*/ -#include "imstkAPIUtilities.h" #include "imstkCamera.h" #include "imstkIBLProbe.h" #include "imstkKeyboardSceneControl.h" #include "imstkDirectionalLight.h" #include "imstkMeshIO.h" +#include "imstkPlane.h" #include "imstkMouseSceneControl.h" #include "imstkNew.h" #include "imstkRenderMaterial.h" @@ -87,12 +87,6 @@ main() dirLight->setIntensity(10.0); dirLight->setColor(Color(1.0, 0.95, 0.8)); scene->addLight("directionalLight", dirLight); - - // Plane - auto planeObj = apiutils::createVisualAnalyticalSceneObject("Plane", scene, "VisualPlane", Vec3d(10.0, 10.0, 10.0)); - imstkNew<RenderMaterial> planeMaterial; - planeMaterial->setColor(Color::LightGray); - planeObj->getVisualModel(0)->setRenderMaterial(planeMaterial); } // Run the simulation @@ -131,8 +125,8 @@ main() auto rendConfig = std::make_shared<RendererConfig>(); rendConfig->m_ssaoConfig.m_enableSSAO = true; rendConfig->m_ssaoConfig.m_SSAOBlur = true; - rendConfig->m_ssaoConfig.m_SSAORadius = 1.0 * sceneSize; - rendConfig->m_ssaoConfig.m_SSAOBias = 0.001 * sceneSize; + rendConfig->m_ssaoConfig.m_SSAORadius = 10.0 * sceneSize; + rendConfig->m_ssaoConfig.m_SSAOBias = 0.01 * sceneSize; rendConfig->m_ssaoConfig.m_KernelSize = 128; viewer->getActiveRenderer()->setConfig(rendConfig); diff --git a/Examples/SPHFluid/SPHFluid-BallDrop/CMakeLists.txt b/Examples/SPHFluid/SPHFluid-BallDrop/CMakeLists.txt index ff4b4fe830cbddc65765a215a6ccabf42312e8f8..e7e4328037f68a1d0836bdc757dc03a18fec22ba 100644 --- a/Examples/SPHFluid/SPHFluid-BallDrop/CMakeLists.txt +++ b/Examples/SPHFluid/SPHFluid-BallDrop/CMakeLists.txt @@ -31,4 +31,4 @@ SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES FOLDER Examples/SPH) #----------------------------------------------------------------------------- # Link libraries to executable #----------------------------------------------------------------------------- -target_link_libraries(${PROJECT_NAME} SimulationManager apiUtilities) +target_link_libraries(${PROJECT_NAME} SimulationManager) diff --git a/Examples/SPHFluid/SPHFluid-BunnyShape/CMakeLists.txt b/Examples/SPHFluid/SPHFluid-BunnyShape/CMakeLists.txt index c735cd3a26f78296a8b8f0fd595c8c385781a742..01c20d23dba7a76043a0d67cc0bc98f16b45b4f8 100644 --- a/Examples/SPHFluid/SPHFluid-BunnyShape/CMakeLists.txt +++ b/Examples/SPHFluid/SPHFluid-BunnyShape/CMakeLists.txt @@ -31,4 +31,4 @@ SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES FOLDER Examples/SPH) #----------------------------------------------------------------------------- # Link libraries to executable #----------------------------------------------------------------------------- -target_link_libraries(${PROJECT_NAME} SimulationManager apiUtilities) +target_link_libraries(${PROJECT_NAME} SimulationManager) diff --git a/Examples/SPHFluid/SPHFluid-HighViscousity/CMakeLists.txt b/Examples/SPHFluid/SPHFluid-HighViscousity/CMakeLists.txt index 6166e288f1615790264ac600c181a8c9b1bfc9b0..966b9f21baefddb72d96287538c875df04e94319 100644 --- a/Examples/SPHFluid/SPHFluid-HighViscousity/CMakeLists.txt +++ b/Examples/SPHFluid/SPHFluid-HighViscousity/CMakeLists.txt @@ -31,4 +31,4 @@ SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES FOLDER Examples/SPH) #----------------------------------------------------------------------------- # Link libraries to executable #----------------------------------------------------------------------------- -target_link_libraries(${PROJECT_NAME} SimulationManager apiUtilities) +target_link_libraries(${PROJECT_NAME} SimulationManager) diff --git a/Examples/SceneManagement/CMakeLists.txt b/Examples/SceneManagement/CMakeLists.txt index 12c0da7d6b9afed91b77dd25f246b704a6806273..6c41f4ed74201a3d86e0bfe8a0566c0970645c3a 100644 --- a/Examples/SceneManagement/CMakeLists.txt +++ b/Examples/SceneManagement/CMakeLists.txt @@ -31,4 +31,4 @@ SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES FOLDER Examples) #----------------------------------------------------------------------------- # Link libraries to executable #----------------------------------------------------------------------------- -target_link_libraries(${PROJECT_NAME} SimulationManager apiUtilities) +target_link_libraries(${PROJECT_NAME} SimulationManager) diff --git a/Examples/Screenshot/CMakeLists.txt b/Examples/Screenshot/CMakeLists.txt index 6493e5d75078b178bd9f20fc3b5162135b6d6be5..6e901d9a1c4ef03ff79d49e4a5f6f66c9ef92d1c 100644 --- a/Examples/Screenshot/CMakeLists.txt +++ b/Examples/Screenshot/CMakeLists.txt @@ -31,4 +31,4 @@ SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES FOLDER Examples) #----------------------------------------------------------------------------- # Link libraries to executable #----------------------------------------------------------------------------- -target_link_libraries(${PROJECT_NAME} SimulationManager apiUtilities) +target_link_libraries(${PROJECT_NAME} SimulationManager) diff --git a/Examples/TaskGraph/Configuration/CMakeLists.txt b/Examples/TaskGraph/Configuration/CMakeLists.txt index 09512ba38eb3a3f85dd128ed4793b9d215eafa96..e52ad78a1e9f242fd7089b43e54df4f841c47aa6 100644 --- a/Examples/TaskGraph/Configuration/CMakeLists.txt +++ b/Examples/TaskGraph/Configuration/CMakeLists.txt @@ -31,4 +31,4 @@ SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES FOLDER Examples/TaskGraph) #----------------------------------------------------------------------------- # Link libraries to executable #----------------------------------------------------------------------------- -target_link_libraries(${PROJECT_NAME} SimulationManager apiUtilities) +target_link_libraries(${PROJECT_NAME} SimulationManager) diff --git a/Examples/TaskGraph/TaskGraph/CMakeLists.txt b/Examples/TaskGraph/TaskGraph/CMakeLists.txt index e51e2e76989b6317c48160e5dfc264cd977697b0..31d8fe23e2bc708ec44ba911a13342a476b2a642 100644 --- a/Examples/TaskGraph/TaskGraph/CMakeLists.txt +++ b/Examples/TaskGraph/TaskGraph/CMakeLists.txt @@ -31,4 +31,4 @@ SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES FOLDER Examples/TaskGraph) #----------------------------------------------------------------------------- # Link libraries to executable #----------------------------------------------------------------------------- -target_link_libraries(${PROJECT_NAME} SimulationManager apiUtilities) +target_link_libraries(${PROJECT_NAME} SimulationManager) diff --git a/Examples/TaskGraph/Timing/CMakeLists.txt b/Examples/TaskGraph/Timing/CMakeLists.txt index ea4991855fcfe14cb594f62e1370b62de19b2eff..77eb164965fab9005ca69fc4460aaa603f118f94 100644 --- a/Examples/TaskGraph/Timing/CMakeLists.txt +++ b/Examples/TaskGraph/Timing/CMakeLists.txt @@ -31,4 +31,4 @@ SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES FOLDER Examples/TaskGraph) #----------------------------------------------------------------------------- # Link libraries to executable #----------------------------------------------------------------------------- -target_link_libraries(${PROJECT_NAME} SimulationManager apiUtilities) +target_link_libraries(${PROJECT_NAME} SimulationManager) diff --git a/Examples/VolumeRendering/CMakeLists.txt b/Examples/VolumeRendering/CMakeLists.txt index 07db4511b4132b8b7a25a828182883bd8f2b7ecc..ba361d23204cb78a18f840a9b3ee560356a97aa2 100644 --- a/Examples/VolumeRendering/CMakeLists.txt +++ b/Examples/VolumeRendering/CMakeLists.txt @@ -31,4 +31,4 @@ SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES FOLDER Examples) #----------------------------------------------------------------------------- # Link libraries to executable #----------------------------------------------------------------------------- -target_link_libraries(${PROJECT_NAME} SimulationManager apiUtilities Filtering) +target_link_libraries(${PROJECT_NAME} SimulationManager Filtering) diff --git a/Source/Common/CMakeLists.txt b/Source/Common/CMakeLists.txt index b0481037b7c98eb248e67265bf5f0b17a679f499..c79c608b43470756b3635d4df1d0f732a208abe0 100644 --- a/Source/Common/CMakeLists.txt +++ b/Source/Common/CMakeLists.txt @@ -7,7 +7,6 @@ imstk_add_library( Common Eigen3::Eigen g3log tbb - # tsimd ) #----------------------------------------------------------------------------- diff --git a/Source/Common/TaskGraph/imstkTaskGraph.h b/Source/Common/TaskGraph/imstkTaskGraph.h index b38b474df84053e74b8a2056a7e2675471700ea2..1cdacadee1dc28897d33aa07c693cd1386009915 100644 --- a/Source/Common/TaskGraph/imstkTaskGraph.h +++ b/Source/Common/TaskGraph/imstkTaskGraph.h @@ -142,7 +142,7 @@ public: void addEdge(std::shared_ptr<TaskNode> srcNode, std::shared_ptr<TaskNode> destNode); /// - /// \brief Attachs another TaskGraph as a subgraph (copies nodes and edges, then connects source->subgraph::source, subgraph::sink->sink), + /// \brief Attaches another TaskGraph as a subgraph (copies nodes and edges, then connects source->subgraph::source, subgraph::sink->sink), /// source and sink must exist in this graph. Also serves as a graph sum between this and subgraph /// void nestGraph(std::shared_ptr<TaskGraph> subgraph, std::shared_ptr<TaskNode> source, std::shared_ptr<TaskNode> sink); @@ -190,7 +190,7 @@ public: static std::shared_ptr<TaskGraph> resolveCriticalNodes(std::shared_ptr<TaskGraph> graph); /// - /// \brief Remove redudant edges. Removal is such that all vertices are still reachable and graph goes from source->sink + /// \brief Remove redundant edges. Removal is such that all vertices are still reachable and graph goes from source->sink /// returns nullptr if failed. Only fails if graph is cyclic. /// static std::shared_ptr<TaskGraph> transitiveReduce(std::shared_ptr<TaskGraph> graph); diff --git a/Source/Common/imstkEventObject.h b/Source/Common/imstkEventObject.h index 79b5eede77a2e20935758842dd10c065f891ee51..aa2dd08cbe0357c2f06e36f60f473180601f8f80 100644 --- a/Source/Common/imstkEventObject.h +++ b/Source/Common/imstkEventObject.h @@ -102,10 +102,10 @@ static void disconnect(EventObject*, EventObject*, std::string (*)()); /// \class EventObject /// /// \brief EventObject is the base class for all objects in iMSTK that -/// can recieve and emit events. It supports direct and queued observer functions. -/// Direct observers recieve events immediately on the same thread +/// can receive and emit events. It supports direct and queued observer functions. +/// Direct observers receive events immediately on the same thread /// This can either be posted on an object or be a function pointer -/// Queued observers recieve events within their queue which they can process whenever +/// Queued observers receive events within their queue which they can process whenever /// they like. /// These can be connected with the connect/queuedConnect/disconnect functions /// \todo ThreadObject affinity diff --git a/Source/Common/imstkModule.cpp b/Source/Common/imstkModule.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6ce00bc20289e447dae2335cce8ec86f886e0027 --- /dev/null +++ b/Source/Common/imstkModule.cpp @@ -0,0 +1,59 @@ +/*========================================================================= + + Library: iMSTK + + Copyright (c) Kitware, Inc. & Center for Modeling, Simulation, + & Imaging in Medicine, Rensselaer Polytechnic Institute. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0.txt + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +=========================================================================*/ + +#include "imstkModule.h" + +namespace imstk +{ +void +Module::update() +{ + if (m_init && !m_paused) + { + if (sleepDelay != 0.0) + { + std::this_thread::sleep_for(std::chrono::duration<double, std::milli>(sleepDelay)); + } + + if (muteUpdateEvents) + { + this->updateModule(); + } + else + { + this->postEvent(Event(Module::preUpdate())); + this->updateModule(); + this->postEvent(Event(Module::postUpdate())); + } + } +} + +void +Module::uninit() +{ + // Can only uninit if, init'd + if (m_init) + { + uninitModule(); + m_init = false; + } +} +}// imstk diff --git a/Source/Common/imstkModule.h b/Source/Common/imstkModule.h index 7d2f88e7cf8f39f9d7add0c69664980c26c724f0..724083eaa06cddee5ad807a5b3ddf60bfb6180fa 100644 --- a/Source/Common/imstkModule.h +++ b/Source/Common/imstkModule.h @@ -74,7 +74,7 @@ public: public: /// - /// \brief Get/Set the timestep + /// \brief Get/Set the time step /// double getDt() const { return m_dt; } void setDt(const double dt) { m_dt = dt; } @@ -90,6 +90,9 @@ public: bool getPaused() const { return m_paused; } void setPaused(const bool paused) { m_paused = paused; } + /// + /// \brief Set/Get the execution type (see imstk::ExecutionType) + /// ExecutionType getExecutionType() const { return m_executionType; } void setExecutionType(const ExecutionType type) { m_executionType = type; } @@ -101,37 +104,9 @@ public: public: void init() { m_init = initModule(); } - void update() - { - if (m_init && !m_paused) - { - if (sleepDelay != 0.0) - { - std::this_thread::sleep_for(std::chrono::duration<double, std::milli>(sleepDelay)); - } - - if (muteUpdateEvents) - { - this->updateModule(); - } - else - { - this->postEvent(Event(Module::preUpdate())); - this->updateModule(); - this->postEvent(Event(Module::postUpdate())); - } - } - } - - void uninit() - { - // Can only uninit if, init'd - if (m_init) - { - uninitModule(); - m_init = false; - } - } + void update(); + + void uninit(); public: virtual bool initModule() = 0; diff --git a/Source/Rendering/Testing/CMakeLists.txt b/Source/Rendering/Testing/CMakeLists.txt index 2b7b0a196ce4e774965d94bc3be5fa5992c12bd3..c6b875d6afb312e99c17d3964daeb20c65a06f47 100644 --- a/Source/Rendering/Testing/CMakeLists.txt +++ b/Source/Rendering/Testing/CMakeLists.txt @@ -1,3 +1,3 @@ include(imstkAddTest) imstk_add_visual_test( Rendering ) - target_link_libraries( RenderingVisualTests apiUtilities ) \ No newline at end of file + target_link_libraries( RenderingVisualTests Common SimulationManager) \ No newline at end of file diff --git a/Source/Rendering/VTKRenderer/imstkVTKRenderer.cpp b/Source/Rendering/VTKRenderer/imstkVTKRenderer.cpp index 718501404790638fd2b796f7b816196a0acb8718..19a809dd792811a57bf38fa82ddeef9a2b0f91d1 100644 --- a/Source/Rendering/VTKRenderer/imstkVTKRenderer.cpp +++ b/Source/Rendering/VTKRenderer/imstkVTKRenderer.cpp @@ -418,7 +418,6 @@ VTKRenderer::updateCamera() m_camera->SetViewUp(up[0], up[1], up[2]); m_camera->SetViewAngle(cam->getFieldOfView()); m_camera->SetClippingRange(cam->getNearZ(), cam->getFarZ()); - m_camera->SetClippingRange(cam->getNearZ(), cam->getFarZ()); } void diff --git a/Source/Scene/imstkInteractionPair.h b/Source/Scene/imstkInteractionPair.h index 585bba397924de58261c2c42101784a6416ee2bf..7714d919217b4bff94b8218b5778136eb57f9ce6 100644 --- a/Source/Scene/imstkInteractionPair.h +++ b/Source/Scene/imstkInteractionPair.h @@ -50,10 +50,10 @@ public: const Outputs& getTaskNodeOutputs() const { return m_taskNodeOutputs; } public: - /// - /// \brief Modifies the computational graph - /// - void compute(); +/// +/// \brief Modifies the computational graph +/// +//void compute(); protected: Inputs m_taskNodeInputs; ///> The interacting nodes diff --git a/Source/Scene/imstkObjectInteractionPair.h b/Source/Scene/imstkObjectInteractionPair.h index 35f92499ecd7ccef9b60aad126cae80eaa563c0e..14bed089b129dd1cf92e6668352c52469559ad16 100644 --- a/Source/Scene/imstkObjectInteractionPair.h +++ b/Source/Scene/imstkObjectInteractionPair.h @@ -31,7 +31,7 @@ class SceneObject; /// \class ObjectInteractionPair /// /// \brief This class defines an interaction between two SceneObjects -/// An interaction is a function occuring between two SceneObjects at some point +/// An interaction is a function occurring between two SceneObjects at some point /// class ObjectInteractionPair : public InteractionPair { @@ -46,7 +46,7 @@ protected: virtual ~ObjectInteractionPair() override = default; public: - /// \brief TODO + /// \brief Return the pair of scene objects involved in the interaction const SceneObjectPair& getObjectsPair() const { return m_objects; } public: diff --git a/Source/Scene/imstkPbdObjectCuttingPair.h b/Source/Scene/imstkPbdObjectCuttingPair.h index f045183f2ce511a857116b345e06f688155d3669..3f9a2d9f63103a70b22763ffe4113fc15c4f6122 100644 --- a/Source/Scene/imstkPbdObjectCuttingPair.h +++ b/Source/Scene/imstkPbdObjectCuttingPair.h @@ -71,7 +71,7 @@ protected: std::shared_ptr<VecDataArray<int, 3>> elements); /// - /// \brief Modify exsiting elements of pbdObj + /// \brief Modify existing elements of pbdObj /// void modifyTriangles(std::shared_ptr<SurfaceMesh> pbdMesh, std::shared_ptr<std::vector<size_t>> elementIndices, diff --git a/Source/SceneEntities/Camera/imstkCamera.cpp b/Source/SceneEntities/Camera/imstkCamera.cpp new file mode 100644 index 0000000000000000000000000000000000000000..945d1ded6a2830b5bb64a2981cbc679527e9ca88 --- /dev/null +++ b/Source/SceneEntities/Camera/imstkCamera.cpp @@ -0,0 +1,33 @@ +/*========================================================================= + + Library: iMSTK + + Copyright (c) Kitware, Inc. & Center for Modeling, Simulation, + & Imaging in Medicine, Rensselaer Polytechnic Institute. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0.txt + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +=========================================================================*/ + +#include "imstkCamera.h" + +namespace imstk +{ +void +Camera::print() +{ + std::cout << "CamPos: " << m_position[0] << ", " << m_position[1] << ", " << m_position[2] << std::endl; + std::cout << "FocalPoint: " << m_focalPoint[0] << ", " << m_focalPoint[1] << ", " << m_focalPoint[2] << std::endl; + std::cout << "Up: " << m_viewUp[0] << ", " << m_viewUp[1] << ", " << m_viewUp[2] << std::endl; +} +} \ No newline at end of file diff --git a/Source/SceneEntities/Camera/imstkCamera.h b/Source/SceneEntities/Camera/imstkCamera.h index a4e84dd8747bcc052f74e86a681204cea8a90d37..b5f2d368ae83d71179f30f403155904f26b3e219 100644 --- a/Source/SceneEntities/Camera/imstkCamera.h +++ b/Source/SceneEntities/Camera/imstkCamera.h @@ -81,44 +81,34 @@ public: /// \brief Get camera view matrix /// \returns Camera view matrix reference /// - Mat4d& getView() { return m_view; } + inline Mat4d& getView() { return m_view; } /// /// \brief Get the inverse view matrix /// - const Mat4d& getInvView() { return m_invView; } + inline const Mat4d& getInvView() { return m_invView; } /// /// \brief Set the camera view matrix /// - void setView(const Mat4d& view) + inline void setView(const Mat4d& view) { m_viewModified = false; m_view = view; m_invView = m_view.inverse(); } - /// - /// \brief Get camera projection matrix - /// - //const Mat4d& getProj() { return m_proj; } - - /// - /// \brief Set camera projection matrix - /// - //void setProj(const Mat4d& proj) { m_proj = proj; } - /// /// \brief Gets the field of view /// \returns vertical field of view in degrees /// - const double getFieldOfView() const { return m_fieldOfView; } + inline const double getFieldOfView() const { return m_fieldOfView; } /// /// \brief Sets the field of view /// \param vertical field of view in degrees /// - void setFieldOfView(const double fov) + inline void setFieldOfView(const double fov) { m_fieldOfView = fov; //m_projModified = true; @@ -129,20 +119,19 @@ public: /// note: You lose depth accuracy as the range between near and far increases /// could cause z fighting /// - void setNearZ(const double nearZ) { m_nearZ = nearZ; } - - const double getNearZ() const { return m_nearZ; } + inline void setNearZ(const double nearZ) { m_nearZ = nearZ; } + inline const double getNearZ() const { return m_nearZ; } /// /// \brief Set clipping near /// note: You lose depth accuracy as the range between near and far increases /// could cause z fighting /// - void setFarZ(const double farZ) { m_farZ = farZ; } + inline void setFarZ(const double farZ) { m_farZ = farZ; } - const double getFarZ() const { return m_farZ; } + inline const double getFarZ() const { return m_farZ; } - virtual void update() + inline virtual void update() { if (m_viewModified) { @@ -156,25 +145,24 @@ public: }*/ } -public: /// /// \brief Gets the camera position /// \returns camera position /// - const Vec3d& getPosition() const { return m_position; } + inline const Vec3d& getPosition() const { return m_position; } /// /// \brief Sets the camera position /// - void setPosition(const Vec3d& pos) + inline void setPosition(const Vec3d& pos) { m_position = pos; m_viewModified = true; } - void setPosition(const double x, - const double y, - const double z) + inline void setPosition(const double x, + const double y, + const double z) { setPosition(Vec3d(x, y, z)); } @@ -184,20 +172,20 @@ public: /// The focal point is the point that the camera points to /// \returns Focal point position /// - const Vec3d& getFocalPoint() const { return m_focalPoint; } + inline const Vec3d& getFocalPoint() const { return m_focalPoint; } /// /// \brief Sets the focal point /// - void setFocalPoint(const Vec3d& focalPt) + inline void setFocalPoint(const Vec3d& focalPt) { m_focalPoint = focalPt; m_viewModified = true; } - void setFocalPoint(const double x, - const double y, - const double z) + inline void setFocalPoint(const double x, + const double y, + const double z) { setFocalPoint(Vec3d(x, y, z)); } @@ -206,20 +194,20 @@ public: /// \brief Get the up vector /// \returns up vector of camera /// - const Vec3d& getViewUp() const { return m_viewUp; } + inline const Vec3d& getViewUp() const { return m_viewUp; } /// /// \brief Set the up vector /// - void setViewUp(const Vec3d& up) + inline void setViewUp(const Vec3d& up) { m_viewUp = up.normalized(); m_viewModified = true; } - void setViewUp(const double x, - const double y, - const double z) + inline void setViewUp(const double x, + const double y, + const double z) { setViewUp(Vec3d(x, y, z)); } @@ -227,12 +215,7 @@ public: /// /// \brief Utility function to quickly print cam stats /// - void print() - { - std::cout << "CamPos: " << m_position[0] << ", " << m_position[1] << ", " << m_position[2] << std::endl; - std::cout << "FocalPoint: " << m_focalPoint[0] << ", " << m_focalPoint[1] << ", " << m_focalPoint[2] << std::endl; - std::cout << "Up: " << m_viewUp[0] << ", " << m_viewUp[1] << ", " << m_viewUp[2] << std::endl; - } + void print(); protected: // Base camera values @@ -242,7 +225,6 @@ protected: bool m_viewModified = true; //bool m_projModified = true; -protected: // Base projection parameters double m_fieldOfView = 40.0; ///> field of view in degrees double m_nearZ = 0.01; ///> near plane of the camera diff --git a/Source/SceneEntities/Lights/imstkLight.h b/Source/SceneEntities/Lights/imstkLight.h index 8b2106aaf4f307e1f6ea4ec5292b7d2b9715f424..e3e5c96998a883992bb48dfcb0402335fbc94ec8 100644 --- a/Source/SceneEntities/Lights/imstkLight.h +++ b/Source/SceneEntities/Lights/imstkLight.h @@ -77,11 +77,6 @@ public: /// void switchOn() { m_switchState = true; } - /// - /// \brief Get the status (On/off) of the light - /// - bool isOff() const { return m_switchState; } - /// /// \brief Switch the light Off /// @@ -105,7 +100,7 @@ public: /// /// \brief Set the light intensity. This value is unbounded. /// - void setIntensity(double intensity) { m_intensity = (float)intensity; } + void setIntensity(const double intensity) { m_intensity = (float)intensity; } protected: Light(const LightType& type) : SceneEntity(), m_type(type) { } diff --git a/Source/SceneEntities/Objects/imstkAnimationModel.h b/Source/SceneEntities/Objects/imstkAnimationModel.h index 924fe863291df26ac3f4863d4641c2c1140634e9..66c2f16d1919bb84ec6883e2b5c39fa18f15883a 100644 --- a/Source/SceneEntities/Objects/imstkAnimationModel.h +++ b/Source/SceneEntities/Objects/imstkAnimationModel.h @@ -37,7 +37,6 @@ public: /// \brief Constructor /// explicit AnimationModel(std::shared_ptr<Geometry> geometry); - AnimationModel() = delete; /// diff --git a/Source/SceneEntities/Objects/imstkVisualModel.cpp b/Source/SceneEntities/Objects/imstkVisualModel.cpp index 1b3f017a333c77d85f83065fc6951493d91c713f..74f58c226ab18a3d94f13862797d080b5103be77 100644 --- a/Source/SceneEntities/Objects/imstkVisualModel.cpp +++ b/Source/SceneEntities/Objects/imstkVisualModel.cpp @@ -50,6 +50,20 @@ VisualModel::VisualModel() : m_renderMaterial(std::make_shared<RenderMaterial>() { } +void +VisualModel::setRenderMaterial(std::shared_ptr<RenderMaterial> renderMaterial) +{ + m_renderMaterial = renderMaterial; + this->postModified(); +} + +void +VisualModel::setIsVisible(const bool visible) +{ + m_isVisible = visible; + this->postModified(); +} + bool VisualModel::getRenderDelegateCreated(Renderer* ren) { diff --git a/Source/SceneEntities/Objects/imstkVisualModel.h b/Source/SceneEntities/Objects/imstkVisualModel.h index 8fab729f22db2e7ac1e67050ea1a9e7f9e797534..21494f9be3af683e42f000500ca2a08c46acd5ec 100644 --- a/Source/SceneEntities/Objects/imstkVisualModel.h +++ b/Source/SceneEntities/Objects/imstkVisualModel.h @@ -81,11 +81,7 @@ public: /// /// \brief Set/Get render material /// - void setRenderMaterial(std::shared_ptr<RenderMaterial> renderMaterial) - { - m_renderMaterial = renderMaterial; - this->postModified(); - } + void setRenderMaterial(std::shared_ptr<RenderMaterial> renderMaterial); std::shared_ptr<RenderMaterial> getRenderMaterial() const { return m_renderMaterial; } @@ -95,11 +91,7 @@ public: void show() { setIsVisible(true); } void hide() { setIsVisible(false); } bool isVisible() const { return m_isVisible; } - void setIsVisible(const bool visible) - { - m_isVisible = visible; - this->postModified(); - } + void setIsVisible(const bool visible); /// /// \brief Get/Set whether the delegate has been created diff --git a/Source/apiUtilities/CMakeLists.txt b/Source/apiUtilities/CMakeLists.txt deleted file mode 100644 index 6990101b5d55aeaa2526052872502da6856627bb..0000000000000000000000000000000000000000 --- a/Source/apiUtilities/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -#----------------------------------------------------------------------------- -# Create target -#----------------------------------------------------------------------------- -include(imstkAddLibrary) -imstk_add_library(apiUtilities - DEPENDS - Common - SimulationManager - Scene - ) - -#----------------------------------------------------------------------------- -# Testing -#----------------------------------------------------------------------------- -#if( ${PROJECT_NAME}_BUILD_TESTING ) -# add_subdirectory( Testing ) -#endif() \ No newline at end of file diff --git a/Source/apiUtilities/imstkAPIUtilities.cpp b/Source/apiUtilities/imstkAPIUtilities.cpp deleted file mode 100644 index df74d14c90630918d064e8484a2d681d9efb485e..0000000000000000000000000000000000000000 --- a/Source/apiUtilities/imstkAPIUtilities.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/*========================================================================= - - Library: iMSTK - - Copyright (c) Kitware, Inc. & Center for Modeling, Simulation, - & Imaging in Medicine, Rensselaer Polytechnic Institute. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0.txt - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -=========================================================================*/ -#include "imstkAPIUtilities.h" -#include "imstkGraph.h" -#include "imstkLinearProjectionConstraint.h" -#include "imstkLogger.h" -#include "imstkVecDataArray.h" - -// Objects -#include "imstkCollidingObject.h" -#include "imstkFEMDeformableBodyModel.h" -#include "imstkScene.h" -#include "imstkSceneManager.h" - -// Geometry -#include "imstkCapsule.h" -#include "imstkOrientedBox.h" -#include "imstkImageData.h" -#include "imstkMeshIO.h" -#include "imstkPlane.h" -#include "imstkSphere.h" -#include "imstkSurfaceMesh.h" -#include "imstkTetrahedralMesh.h" - -namespace imstk -{ -namespace apiutils -{ -std::unordered_map<std::string, std::function<std::shared_ptr<Geometry>()>> geomMakeFunctions = -{ - { "Sphere", []() { return std::make_shared<Sphere>(); } }, - { "Plane", []() { return std::make_shared<Sphere>(); } }, - { "OrientedBox", []() { return std::make_shared<OrientedBox>(); } }, - { "Capsule", []() { return std::make_shared<Sphere>(); } }, - { "Cylinder", []() { return std::make_shared<Sphere>(); } } -}; - -/// -/// \brief Create a analytical visual scene object that and add it to the scene -/// -std::shared_ptr<SceneObject> -createVisualAnalyticalSceneObject(std::string type, - std::shared_ptr<Scene> scene, - const std::string& objName, - const Vec3d scale /* = 1.*/, - const Vec3d t /*= Vec3d(0., 0., 0.)*/) -{ - CHECK(scene != nullptr) << "Error: Scene object is not valid!"; - CHECK(!objName.empty()) << "Error: Name is empty!"; - - if (geomMakeFunctions.count(type) == 0) - { - LOG(WARNING) << "Scene object geometry type " << type << " is not analytical!"; - return nullptr; - } - std::shared_ptr<Geometry> geom = geomMakeFunctions[type](); - - geom->scale(scale, Geometry::TransformType::ApplyToData); - geom->translate(t, Geometry::TransformType::ApplyToData); - - auto sceneObj = std::make_shared<SceneObject>(objName); - sceneObj->setVisualGeometry(geom); - scene->addSceneObject(sceneObj); - - return sceneObj; -} - -/// -/// \brief Create a analytical colliding scene object that and add it to the scene -/// -std::shared_ptr<CollidingObject> -createCollidingAnalyticalSceneObject(std::string type, - std::shared_ptr<Scene> scene, - const std::string& objName, - const Vec3d scale /*= 1.*/, - const Vec3d t /*= Vec3d(0., 0., 0.)*/) -{ - CHECK(scene != nullptr) << "Scene is not valid!"; - CHECK(!objName.empty()) << "Name is empty!"; - - if (geomMakeFunctions.count(type) == 0) - { - LOG(WARNING) << "Scene object geometry type " << type << " is not analytical!"; - return nullptr; - } - std::shared_ptr<Geometry> geom = geomMakeFunctions[type](); - - geom->scale(scale, Geometry::TransformType::ApplyToData); - geom->translate(t, Geometry::TransformType::ApplyToData); - - auto sceneObj = std::make_shared<CollidingObject>(objName); - sceneObj->setVisualGeometry(geom); - sceneObj->setCollidingGeometry(geom); - scene->addSceneObject(sceneObj); - - return sceneObj; -} - -/// -/// \brief Read a mesh, create a visual scene object and add to the scene -/// -std::shared_ptr<SceneObject> -createAndAddVisualSceneObject(std::shared_ptr<Scene> scene, - const std::string& fileName, - const std::string& objectName) -{ - CHECK(scene != nullptr) << "Error: Scene object supplied is not valid!"; - CHECK(!fileName.empty()) << "Error: Name is empty!"; - - auto mesh = MeshIO::read(fileName); - auto SurfaceMesh = std::dynamic_pointer_cast<imstk::SurfaceMesh>(mesh); - - // Create object and add to scene - auto meshSceneObject = std::make_shared<SceneObject>("meshObject"); - meshSceneObject->setVisualGeometry(SurfaceMesh); - meshSceneObject->setName(objectName); - scene->addSceneObject(meshSceneObject); - - return meshSceneObject; -} - -/// -/// \brief Create a non-linear system using FEM dynamic model -/// -std::shared_ptr<NonLinearSystem<SparseMatrixd>> -createNonLinearSystem(std::shared_ptr<FEMDeformableBodyModel> dynaModel) -{ - CHECK(dynaModel != nullptr) << "Dynamic model object supplied is not valid!"; - - auto nlSystem = std::make_shared<NonLinearSystem<SparseMatrixd>>( - dynaModel->getFunction(), - dynaModel->getFunctionGradient()); - - std::vector<LinearProjectionConstraint> linProj; - for (auto i : dynaModel->getFixNodeIds()) - { - linProj.push_back(LinearProjectionConstraint(i, true)); - } - nlSystem->setUnknownVector(dynaModel->getUnknownVec()); - nlSystem->setUpdateFunction(dynaModel->getUpdateFunction()); - nlSystem->setUpdatePreviousStatesFunction(dynaModel->getUpdatePrevStateFunction()); - - return nlSystem; -} - -std::shared_ptr<Graph> -getMeshGraph(std::shared_ptr<PointSet> m) -{ - LOG(WARNING) << "Note: The graph of a point set has no edges"; - - return std::make_shared<Graph>(m->getNumVertices()); -} - -std::shared_ptr<Graph> -getMeshGraph(std::shared_ptr<SurfaceMesh> m) -{ - auto gMesh = std::make_shared<Graph>(m->getNumVertices()); - for (auto tri : *m->getTriangleIndices()) - { - gMesh->addEdge(tri[0], tri[1]); - gMesh->addEdge(tri[0], tri[2]); - gMesh->addEdge(tri[1], tri[2]); - } - - return gMesh; -} - -std::shared_ptr<Graph> -getMeshGraph(std::shared_ptr<TetrahedralMesh> m) -{ - auto gMesh = std::make_shared<Graph>(m->getNumVertices()); - for (auto tet : *m->getTetrahedraIndices()) - { - gMesh->addEdge(tet[0], tet[1]); - gMesh->addEdge(tet[0], tet[2]); - gMesh->addEdge(tet[0], tet[3]); - gMesh->addEdge(tet[1], tet[2]); - gMesh->addEdge(tet[1], tet[3]); - gMesh->addEdge(tet[2], tet[3]); - } - return gMesh; -} -} //apiutils -} // imstk diff --git a/Source/apiUtilities/imstkAPIUtilities.h b/Source/apiUtilities/imstkAPIUtilities.h deleted file mode 100644 index c0b9ed9b2cec01197f277406b57df33100eeb785..0000000000000000000000000000000000000000 --- a/Source/apiUtilities/imstkAPIUtilities.h +++ /dev/null @@ -1,80 +0,0 @@ -/*========================================================================= - - Library: iMSTK - - Copyright (c) Kitware, Inc. & Center for Modeling, Simulation, - & Imaging in Medicine, Rensselaer Polytechnic Institute. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0.txt - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -=========================================================================*/ - -#pragma once - -#include "imstkGeometry.h" -#include "imstkMath.h" - -namespace imstk -{ -class CollidingObject; -class FEMDeformableBodyModel; -class Graph; -template<typename Matrix> -class NonLinearSystem; -class PointSet; -class Scene; -class SceneManager; -class SceneObject; -class SurfaceMesh; -class TetrahedralMesh; - -namespace apiutils -{ -/// -/// \brief Create a analytical visual scene object that and add it to the scene -/// -std::shared_ptr<SceneObject> createVisualAnalyticalSceneObject(std::string type, - std::shared_ptr<Scene> scene, - const std::string& objName, - const Vec3d scale = Vec3d(1.0, 1.0, 1.0), - const Vec3d t = Vec3d(0., 0., 0.)); - -/// -/// \brief Create a analytical colliding scene object that and add it to the scene -/// -std::shared_ptr<CollidingObject> createCollidingAnalyticalSceneObject(std::string type, - std::shared_ptr<Scene> scene, - const std::string& objName, - const Vec3d scale = Vec3d(1.0, 1.0, 1.0), - const Vec3d t = Vec3d(0., 0., 0.)); - -/// -/// \brief Read a mesh, create a visual scene object and add to the scene -/// -std::shared_ptr<SceneObject> createAndAddVisualSceneObject(std::shared_ptr<Scene> scene, - const std::string& fileName, - const std::string& objectName); - -/// -/// \brief Create a non-linear system using FEM dynamic model -/// -std::shared_ptr<NonLinearSystem<SparseMatrixd>> createNonLinearSystem(std::shared_ptr<FEMDeformableBodyModel> dynaModel); - -/// -/// \brief Create a \ref Graph ref -/// -std::shared_ptr<Graph> getMeshGraph(std::shared_ptr<PointSet> m); -std::shared_ptr<Graph> getMeshGraph(std::shared_ptr<SurfaceMesh> m); -std::shared_ptr<Graph> getMeshGraph(std::shared_ptr<TetrahedralMesh> m); -} //apiutils -} // imstk