diff --git a/CMakeLists.txt b/CMakeLists.txt index 02b8e3f91b4d4de48bef6e7532664920af44e538..711bea25ce584912ae01a95e246ca44986ef2146 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -366,6 +366,8 @@ set(${PROJECT_NAME}_INSTALL_FOLDER ${PROJECT_NAME}-${${PROJECT_NAME}_VERSION_MAJ #-------------------------------------------------------------------------- add_subdirectory(Source/Common) add_subdirectory(Source/Geometry) +add_subdirectory(Source/MeshIO) +add_subdirectory(Source/GeometryMappers) add_subdirectory(Source/DataStructures) add_subdirectory(Source/Constraint) add_subdirectory(Source/Devices) @@ -374,10 +376,11 @@ add_subdirectory(Source/Rendering/GUIOverlay) add_subdirectory(Source/Rendering) add_subdirectory(Source/Solvers) add_subdirectory(Source/DynamicalModels) -add_subdirectory(Source/Scene/SceneElements) +add_subdirectory(Source/SceneEntities) add_subdirectory(Source/Animation) add_subdirectory(Source/Controllers) -add_subdirectory(Source/Collision) +add_subdirectory(Source/CollisionDetection) +add_subdirectory(Source/CollisionHandling) add_subdirectory(Source/Scene) add_subdirectory(Source/SimulationManager) add_subdirectory(Source/apiUtilities) diff --git a/Examples/CollisionDetection/ManualCDWithOctree/ManualCDWithOctreeExample.cpp b/Examples/CollisionDetection/ManualCDWithOctree/ManualCDWithOctreeExample.cpp index b16814ba18a8bdc3c7b800e71cae0a08ea0a7e58..a36fe291a8cdfc2dfaa47d2ff63094dbaac2f2dd 100644 --- a/Examples/CollisionDetection/ManualCDWithOctree/ManualCDWithOctreeExample.cpp +++ b/Examples/CollisionDetection/ManualCDWithOctree/ManualCDWithOctreeExample.cpp @@ -112,8 +112,9 @@ addPointsDebugRendering(const std::shared_ptr<Scene>& scene) auto material = std::make_shared<RenderMaterial>(); material->setDebugColor(Color::Yellow); material->setSphereGlyphSize(.01); - debugPoints->setRenderMaterial(material); - scene->addDebugGeometry(debugPoints); + + auto dbgViz = std::make_shared<VisualModel>(debugPoints, material); + scene->addDebugVisualModel(dbgViz); return std::dynamic_pointer_cast<DebugRenderGeometry>(debugPoints); } @@ -129,8 +130,9 @@ addVTConnectingLinesDebugRendering(const std::shared_ptr<Scene>& scene) material->setBackFaceCulling(false); material->setDebugColor(Color::Green); material->setLineWidth(4.0); - debugLines->setRenderMaterial(material); - scene->addDebugGeometry(debugLines); + + auto dbgViz = std::make_shared<VisualModel>(debugLines, material); + scene->addDebugVisualModel(dbgViz); return std::dynamic_pointer_cast<DebugRenderGeometry>(debugLines); } @@ -146,8 +148,9 @@ addEEConnectingLinesDebugRendering(const std::shared_ptr<Scene>& scene) material->setBackFaceCulling(false); material->setDebugColor(Color::Red); material->setLineWidth(4.0); - debugLines->setRenderMaterial(material); - scene->addDebugGeometry(debugLines); + + auto dbgViz = std::make_shared<VisualModel>(debugLines, material); + scene->addDebugVisualModel(dbgViz); return std::dynamic_pointer_cast<DebugRenderGeometry>(debugLines); } @@ -163,8 +166,9 @@ addHighlightedLinesDebugRendering(const std::shared_ptr<Scene>& scene) material->setBackFaceCulling(false); material->setDebugColor(Color::Orange); material->setLineWidth(8.0); - debugLines->setRenderMaterial(material); - scene->addDebugGeometry(debugLines); + + auto dbgViz = std::make_shared<VisualModel>(debugLines, material); + scene->addDebugVisualModel(dbgViz); return std::dynamic_pointer_cast<DebugRenderGeometry>(debugLines); } diff --git a/Examples/DebugRendering/DebugRenderingExample.cpp b/Examples/DebugRendering/DebugRenderingExample.cpp index 34510c7e26a717f4762cae13eea03201490b7b33..fa36764c3ae1f19ccdac4a000a4ce4d588aae98c 100644 --- a/Examples/DebugRendering/DebugRenderingExample.cpp +++ b/Examples/DebugRendering/DebugRenderingExample.cpp @@ -37,19 +37,19 @@ using namespace imstk; -std::shared_ptr<DebugRenderGeometry> +std::shared_ptr<DebugRenderPoints> addPointsDebugRendering(const std::shared_ptr<Scene>& scene) { auto debugPoints = std::make_shared<DebugRenderPoints>("Debug Points"); auto material = std::make_shared<RenderMaterial>(); material->setDebugColor(Color::Blue); - debugPoints->setRenderMaterial(material); - scene->addDebugGeometry(debugPoints); + auto vizModel = std::make_shared<VisualModel>(debugPoints, material); + scene->addDebugVisualModel(vizModel); - return std::dynamic_pointer_cast<DebugRenderGeometry>(debugPoints); + return debugPoints; } -std::shared_ptr<DebugRenderGeometry> +std::shared_ptr<DebugRenderLines> addLinesDebugRendering(const std::shared_ptr<Scene>& scene) { auto debugLines = std::make_shared<DebugRenderLines>("Debug Lines"); @@ -57,13 +57,13 @@ addLinesDebugRendering(const std::shared_ptr<Scene>& scene) material->setBackFaceCulling(false); material->setDebugColor(Color::Green); material->setLineWidth(2.0); - debugLines->setRenderMaterial(material); - scene->addDebugGeometry(debugLines); + auto vizModel = std::make_shared<VisualModel>(debugLines, material); + scene->addDebugVisualModel(vizModel); - return std::dynamic_pointer_cast<DebugRenderGeometry>(debugLines); + return debugLines; } -std::shared_ptr<DebugRenderGeometry> +std::shared_ptr<DebugRenderTriangles> addTrianglesDebugRendering(const std::shared_ptr<Scene>& scene) { auto debugTriangles = std::make_shared<DebugRenderTriangles>("Debug Triangles"); @@ -71,10 +71,9 @@ addTrianglesDebugRendering(const std::shared_ptr<Scene>& scene) material->setBackFaceCulling(false); material->setDebugColor(Color::Red); material->setDisplayMode(RenderMaterial::DisplayMode::WireframeSurface); - debugTriangles->setRenderMaterial(material); - scene->addDebugGeometry(debugTriangles); + auto vizModel = std::make_shared<VisualModel>(debugTriangles, material); - return std::dynamic_pointer_cast<DebugRenderGeometry>(debugTriangles); + return debugTriangles; } Vec3d diff --git a/Examples/DeformableBody/DeformableBodyExample.cpp b/Examples/DeformableBody/DeformableBodyExample.cpp index 03f9c3966eee5cadcce3e38c37df71d693498b70..a49faf30dcbb8f0bb199bc3bf57ddbd0510369dd 100644 --- a/Examples/DeformableBody/DeformableBodyExample.cpp +++ b/Examples/DeformableBody/DeformableBodyExample.cpp @@ -49,7 +49,7 @@ int main() { // simManager and Scene - auto simConfig = std::make_shared<simManagerConfig>(); + auto simConfig = std::make_shared<SimManagerConfig>(); simConfig->simulationMode = SimulationMode::Rendering; auto simManager = std::make_shared<SimulationManager>(simConfig); auto scene = simManager->createNewScene("DeformableBodyFEM"); diff --git a/Examples/LineMesh/LineMeshExample.cpp b/Examples/LineMesh/LineMeshExample.cpp index fd64ccea6c23256771bedfe08ec8d368368cf704..0aeb68af371224bdc2104561b8658d622c7ea2c2 100644 --- a/Examples/LineMesh/LineMeshExample.cpp +++ b/Examples/LineMesh/LineMeshExample.cpp @@ -52,7 +52,6 @@ main() size_t numVoxels = resolution * resolution * resolution; points.resize(numVoxels * 8); - colors.resize(numVoxels * 8); lines.resize(numVoxels * 12); size_t index = 0; @@ -75,15 +74,6 @@ main() points[index + 6] = Vec3d(x + 1, y + 1, z); points[index + 7] = Vec3d(x + 1, y + 1, z + 1); - colors[index + 0] = color; - colors[index + 1] = color; - colors[index + 2] = color; - colors[index + 3] = color; - colors[index + 4] = color; - colors[index + 5] = color; - colors[index + 6] = color; - colors[index + 7] = color; - lines[lineIndex + 0][0] = index + 0; lines[lineIndex + 0][1] = index + 1; lines[lineIndex + 1][0] = index + 2; @@ -118,7 +108,6 @@ main() } lineMesh->initialize(points, lines); - lineMesh->setVertexColors(colors); auto lineModel = std::make_shared<VisualModel>(lineMesh); lineModel->setRenderMaterial(lineMeshMaterial); lineObject->addVisualModel(lineModel); diff --git a/Examples/MultipleScenes/multipleScenes.cpp b/Examples/MultipleScenes/multipleScenes.cpp index 0291b9fbf2eda88970a00fcc1c6edcbe99528618..ca7f47f6260aa6a56494be66b41aedbb6ace7fbd 100644 --- a/Examples/MultipleScenes/multipleScenes.cpp +++ b/Examples/MultipleScenes/multipleScenes.cpp @@ -194,7 +194,7 @@ createClothScene(std::shared_ptr<SimulationManager> simManager, const char* scen void testMultipleScenesInBackendMode() { - auto simConfig = std::make_shared<simManagerConfig>(); + auto simConfig = std::make_shared<SimManagerConfig>(); simConfig->simulationMode = SimulationMode::Backend; auto simManager = std::make_shared<SimulationManager>(simConfig); @@ -292,7 +292,7 @@ testMultipleScenesInRenderMode() void testMultipleScenesInBackgroundMode() { - auto simConfig = std::make_shared<simManagerConfig>(); + auto simConfig = std::make_shared<SimManagerConfig>(); simConfig->simulationMode = SimulationMode::RunInBackgroundSync; auto simManager = std::make_shared<SimulationManager>(simConfig); auto scene1 = createClothScene(simManager, "clothScene"); diff --git a/Examples/Octree/OctreeExample.cpp b/Examples/Octree/OctreeExample.cpp index 512240c6f90dc8864684fcbdc46856fadffeb1ca..0b7cb17e64df2cbcd9678a4d441d92fe53684bb7 100644 --- a/Examples/Octree/OctreeExample.cpp +++ b/Examples/Octree/OctreeExample.cpp @@ -165,7 +165,12 @@ main() // Create debug geometry for the octree (render up to 8 levels, and render all non-empty nodes) const auto debugOctree = octree.getDebugGeometry(8, true); - scene->addDebugGeometry(debugOctree); + + const auto matDbgViz = std::make_shared<RenderMaterial>(); + matDbgViz->setDebugColor(Color::Green); + matDbgViz->setLineWidth(1.0); + auto octreeVizDbgModel = std::make_shared<VisualModel>(debugOctree, matDbgViz); + scene->addDebugVisualModel(octreeVizDbgModel); // Data for animation const double translation = 15.0; diff --git a/Examples/PBD/PBDCollisionMultipleObjects/CMakeLists.txt b/Examples/PBD/PBDCollisionMultipleObjects/CMakeLists.txt index 6a167b0465190129a90bd23086089a3fa8bee1f4..948698f2abf8483aa3c5fb9ebab4855e91ad502b 100644 --- a/Examples/PBD/PBDCollisionMultipleObjects/CMakeLists.txt +++ b/Examples/PBD/PBDCollisionMultipleObjects/CMakeLists.txt @@ -36,4 +36,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 apiUtilities ) diff --git a/Source/Animation/CMakeLists.txt b/Source/Animation/CMakeLists.txt index 779a1168b68021ea82a76ad770986930003b64da..6bf130e7684c5569375938f6773619490fd6d47f 100644 --- a/Source/Animation/CMakeLists.txt +++ b/Source/Animation/CMakeLists.txt @@ -5,8 +5,9 @@ include(imstkAddLibrary) imstk_add_library( Animation DEPENDS Common - #Geometry - SceneElements + Geometry + Materials + SceneEntities ) #----------------------------------------------------------------------------- diff --git a/Source/Animation/Particles/imstkRenderParticleEmitter.cpp b/Source/Animation/Particles/imstkRenderParticleEmitter.cpp index 41df212733501e27e816b5668c99e4f2a6a218ed..0cf3c618e03203587e5126221bbb6b9eb36918cf 100644 --- a/Source/Animation/Particles/imstkRenderParticleEmitter.cpp +++ b/Source/Animation/Particles/imstkRenderParticleEmitter.cpp @@ -231,7 +231,8 @@ RenderParticleEmitter::update() particle->m_scale = (alpha * endKeyFrame->m_scale) + ((1.0f - alpha) * startKeyFrame->m_scale); - this->interpolateColor(particle->m_color, + auto particleColor = imstk::Color(particle->m_color[0], particle->m_color[1], particle->m_color[2], particle->m_color[3]); + this->interpolateColor(particleColor, endKeyFrame->m_color, startKeyFrame->m_color, alpha); diff --git a/Source/Animation/Particles/imstkRenderParticleEmitter.h b/Source/Animation/Particles/imstkRenderParticleEmitter.h index bd7280735807fbeb9783ce099b4ab27a95e6261b..996e5c470970d09cf2278350450fbd23bdfe321e 100644 --- a/Source/Animation/Particles/imstkRenderParticleEmitter.h +++ b/Source/Animation/Particles/imstkRenderParticleEmitter.h @@ -25,10 +25,11 @@ #include "imstkAnimationModel.h" #include "imstkRenderParticles.h" #include "imstkTimer.h" +#include "imstkColor.h" namespace imstk { -struct Color; +//struct Color; /// /// \struct RenderParticleKeyFrame diff --git a/Source/Collision/CMakeLists.txt b/Source/CollisionDetection/CMakeLists.txt similarity index 70% rename from Source/Collision/CMakeLists.txt rename to Source/CollisionDetection/CMakeLists.txt index c55306555ee88974c81ef453a3a0e942d9ba2f23..3917cada24284be6cede7b66b5debe2e0a8d0014 100644 --- a/Source/Collision/CMakeLists.txt +++ b/Source/CollisionDetection/CMakeLists.txt @@ -2,14 +2,13 @@ # Create target #----------------------------------------------------------------------------- include(imstkAddLibrary) -imstk_add_library( Collision +imstk_add_library( CollisionDetection DEPENDS + Common DataStructures Geometry - SceneElements - DynamicalModels - Controllers - SCCD + MeshIO #TODO: remove this dependency + SCCD ) #----------------------------------------------------------------------------- @@ -19,6 +18,6 @@ if( ${PROJECT_NAME}_BUILD_TESTING ) include(imstkAddTest) - imstk_add_test(Collision) - imstk_add_data(Collision ${FILE_LIST_COL_TEST}) + imstk_add_test(CollisionDetection) + imstk_add_data(CollisionDetection ${FILE_LIST_COL_TEST}) endif() diff --git a/Source/Collision/CollisionData/imstkCollisionData.h b/Source/CollisionDetection/CollisionData/imstkCollisionData.h similarity index 100% rename from Source/Collision/CollisionData/imstkCollisionData.h rename to Source/CollisionDetection/CollisionData/imstkCollisionData.h diff --git a/Source/Collision/CollisionDetection/imstkBidirectionalPlaneToSphereCD.cpp b/Source/CollisionDetection/CollisionDetection/imstkBidirectionalPlaneToSphereCD.cpp similarity index 100% rename from Source/Collision/CollisionDetection/imstkBidirectionalPlaneToSphereCD.cpp rename to Source/CollisionDetection/CollisionDetection/imstkBidirectionalPlaneToSphereCD.cpp diff --git a/Source/Collision/CollisionDetection/imstkBidirectionalPlaneToSphereCD.h b/Source/CollisionDetection/CollisionDetection/imstkBidirectionalPlaneToSphereCD.h similarity index 100% rename from Source/Collision/CollisionDetection/imstkBidirectionalPlaneToSphereCD.h rename to Source/CollisionDetection/CollisionDetection/imstkBidirectionalPlaneToSphereCD.h diff --git a/Source/CollisionDetection/CollisionDetection/imstkCollisionDetection.cpp b/Source/CollisionDetection/CollisionDetection/imstkCollisionDetection.cpp new file mode 100644 index 0000000000000000000000000000000000000000..231430dddb4aaf9ce99a7f82c03c134254bc4a39 --- /dev/null +++ b/Source/CollisionDetection/CollisionDetection/imstkCollisionDetection.cpp @@ -0,0 +1,85 @@ +/*========================================================================= + + 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 "imstkCollisionDetection.h" +#include "imstkCollisionData.h" +#include "imstkOctreeBasedCD.h" +#include "imstkSurfaceMesh.h" + +#include <g3log/g3log.hpp> + +namespace imstk +{ +CollisionDetection::CollisionDetection(const CollisionDetection::Type& type, std::shared_ptr<CollisionData> colData) : m_type(type), + m_colData((colData == nullptr) ? std::make_shared<CollisionData>() : colData) +{ +} + +// Static functions ==> +void +CollisionDetection::addCollisionPairToOctree(const std::shared_ptr<Geometry>& geomA, + const std::shared_ptr<Geometry>& geomB, + const Type collisionType, + const std::shared_ptr<CollisionData>& collisionData) +{ + auto addToOctree = + [&](const std::shared_ptr<Geometry>& geom) { + if (!s_OctreeCD->hasGeometry(geom->getGlobalIndex())) + { + if (geom->getType() == Geometry::Type::PointSet) + { + s_OctreeCD->addPointSet(std::dynamic_pointer_cast<PointSet>(geom)); + } + else if (geom->getType() == Geometry::Type::SurfaceMesh) + { + s_OctreeCD->addTriangleMesh(std::dynamic_pointer_cast<SurfaceMesh>(geom)); + } + else + { + s_OctreeCD->addAnalyticalGeometry(geom); + } + } + }; + + addToOctree(geomA); + addToOctree(geomB); + s_OctreeCD->addCollisionPair(geomA, geomB, collisionType, collisionData); +} + +void +CollisionDetection::updateInternalOctreeAndDetectCollision() +{ + if (s_OctreeCD->getNumCollisionPairs() > 0) + { + s_OctreeCD->update(); + s_OctreeCD->detectCollision(); + } +} + +void +CollisionDetection::clearInternalOctree() +{ + s_OctreeCD->clear(); +} + +// Static octree +std::shared_ptr<OctreeBasedCD> CollisionDetection::s_OctreeCD = std::make_shared<OctreeBasedCD>(Vec3d(0, 0, 0), 100.0, 0.1, 1); +} diff --git a/Source/Collision/CollisionDetection/imstkCollisionDetection.h b/Source/CollisionDetection/CollisionDetection/imstkCollisionDetection.h similarity index 86% rename from Source/Collision/CollisionDetection/imstkCollisionDetection.h rename to Source/CollisionDetection/CollisionDetection/imstkCollisionDetection.h index a914598a52e9b70293dd27cb8e3c256f746d1307..ed8c7bcde19590d53231893748fcfa321e057731 100644 --- a/Source/Collision/CollisionDetection/imstkCollisionDetection.h +++ b/Source/CollisionDetection/CollisionDetection/imstkCollisionDetection.h @@ -66,18 +66,6 @@ public: Custom }; - /// - /// \brief Static factory for collision detection sub classes - /// If the collision pair is PointSet to SurfaceMesh, or SurfaceMesh to SurfaceMesh, - /// it will be added to an internal static octree for detecting collision - /// \todo Other collision pair may be considered to use octree too - /// - static std::shared_ptr<CollisionDetection> makeCollisionDetectionObject( - const Type type, - std::shared_ptr<CollidingObject> objA, - std::shared_ptr<CollidingObject> objB, - std::shared_ptr<CollisionData> colData); - /// /// \brief Constructor /// @@ -114,10 +102,6 @@ public: /// static void clearInternalOctree(); -protected: - Type m_type = Type::Custom; ///< Collision detection algorithm type - std::shared_ptr<CollisionData> m_colData; ///< Collision data - /// /// \brief Add the geometry into the background octree for collision detection /// \todo Add line primitive geometry @@ -127,6 +111,10 @@ protected: const CollisionDetection::Type collisionType, const std::shared_ptr<CollisionData>& collisionData); +protected: + Type m_type = Type::Custom; ///< Collision detection algorithm type + std::shared_ptr<CollisionData> m_colData; ///< Collision data + /// Static octree for collision detection /// This octree is valid throughout the lifetime of the program /// and will serve as a background mean to detect collision between geometries diff --git a/Source/Collision/CollisionDetection/imstkCollisionUtils.cpp b/Source/CollisionDetection/CollisionDetection/imstkCollisionUtils.cpp similarity index 100% rename from Source/Collision/CollisionDetection/imstkCollisionUtils.cpp rename to Source/CollisionDetection/CollisionDetection/imstkCollisionUtils.cpp diff --git a/Source/Collision/CollisionDetection/imstkCollisionUtils.h b/Source/CollisionDetection/CollisionDetection/imstkCollisionUtils.h similarity index 100% rename from Source/Collision/CollisionDetection/imstkCollisionUtils.h rename to Source/CollisionDetection/CollisionDetection/imstkCollisionUtils.h diff --git a/Source/Collision/CollisionDetection/imstkMeshToMeshBruteForceCD.cpp b/Source/CollisionDetection/CollisionDetection/imstkMeshToMeshBruteForceCD.cpp similarity index 99% rename from Source/Collision/CollisionDetection/imstkMeshToMeshBruteForceCD.cpp rename to Source/CollisionDetection/CollisionDetection/imstkMeshToMeshBruteForceCD.cpp index bf3a503e5af0b4b87f7a4f3de6f49b433c5bc7a4..a59e0ab21367088465ab2bdec6a256b05f68c373 100644 --- a/Source/Collision/CollisionDetection/imstkMeshToMeshBruteForceCD.cpp +++ b/Source/CollisionDetection/CollisionDetection/imstkMeshToMeshBruteForceCD.cpp @@ -21,13 +21,13 @@ #include "imstkMeshToMeshBruteForceCD.h" -#include "imstkCollidingObject.h" +//#include "imstkCollidingObject.h" #include "imstkCollisionData.h" #include "imstkSurfaceMesh.h" #include "imstkPointSet.h" #include "imstkLineMesh.h" #include "imstkGeometry.h" -#include "imstkColor.h" +//#include "imstkColor.h" #include "imstkCollisionUtils.h" #include <g3log/g3log.hpp> diff --git a/Source/Collision/CollisionDetection/imstkMeshToMeshBruteForceCD.h b/Source/CollisionDetection/CollisionDetection/imstkMeshToMeshBruteForceCD.h similarity index 100% rename from Source/Collision/CollisionDetection/imstkMeshToMeshBruteForceCD.h rename to Source/CollisionDetection/CollisionDetection/imstkMeshToMeshBruteForceCD.h diff --git a/Source/Collision/CollisionDetection/imstkNarrowPhaseCD.cpp b/Source/CollisionDetection/CollisionDetection/imstkNarrowPhaseCD.cpp similarity index 100% rename from Source/Collision/CollisionDetection/imstkNarrowPhaseCD.cpp rename to Source/CollisionDetection/CollisionDetection/imstkNarrowPhaseCD.cpp diff --git a/Source/Collision/CollisionDetection/imstkNarrowPhaseCD.h b/Source/CollisionDetection/CollisionDetection/imstkNarrowPhaseCD.h similarity index 100% rename from Source/Collision/CollisionDetection/imstkNarrowPhaseCD.h rename to Source/CollisionDetection/CollisionDetection/imstkNarrowPhaseCD.h diff --git a/Source/Collision/CollisionDetection/imstkOctreeBasedCD.cpp b/Source/CollisionDetection/CollisionDetection/imstkOctreeBasedCD.cpp similarity index 100% rename from Source/Collision/CollisionDetection/imstkOctreeBasedCD.cpp rename to Source/CollisionDetection/CollisionDetection/imstkOctreeBasedCD.cpp diff --git a/Source/Collision/CollisionDetection/imstkOctreeBasedCD.h b/Source/CollisionDetection/CollisionDetection/imstkOctreeBasedCD.h similarity index 100% rename from Source/Collision/CollisionDetection/imstkOctreeBasedCD.h rename to Source/CollisionDetection/CollisionDetection/imstkOctreeBasedCD.h diff --git a/Source/Collision/CollisionDetection/imstkPointSetToCapsuleCD.cpp b/Source/CollisionDetection/CollisionDetection/imstkPointSetToCapsuleCD.cpp similarity index 100% rename from Source/Collision/CollisionDetection/imstkPointSetToCapsuleCD.cpp rename to Source/CollisionDetection/CollisionDetection/imstkPointSetToCapsuleCD.cpp diff --git a/Source/Collision/CollisionDetection/imstkPointSetToCapsuleCD.h b/Source/CollisionDetection/CollisionDetection/imstkPointSetToCapsuleCD.h similarity index 100% rename from Source/Collision/CollisionDetection/imstkPointSetToCapsuleCD.h rename to Source/CollisionDetection/CollisionDetection/imstkPointSetToCapsuleCD.h diff --git a/Source/Collision/CollisionDetection/imstkPointSetToPlaneCD.cpp b/Source/CollisionDetection/CollisionDetection/imstkPointSetToPlaneCD.cpp similarity index 100% rename from Source/Collision/CollisionDetection/imstkPointSetToPlaneCD.cpp rename to Source/CollisionDetection/CollisionDetection/imstkPointSetToPlaneCD.cpp diff --git a/Source/Collision/CollisionDetection/imstkPointSetToPlaneCD.h b/Source/CollisionDetection/CollisionDetection/imstkPointSetToPlaneCD.h similarity index 100% rename from Source/Collision/CollisionDetection/imstkPointSetToPlaneCD.h rename to Source/CollisionDetection/CollisionDetection/imstkPointSetToPlaneCD.h diff --git a/Source/Collision/CollisionDetection/imstkPointSetToSphereCD.cpp b/Source/CollisionDetection/CollisionDetection/imstkPointSetToSphereCD.cpp similarity index 100% rename from Source/Collision/CollisionDetection/imstkPointSetToSphereCD.cpp rename to Source/CollisionDetection/CollisionDetection/imstkPointSetToSphereCD.cpp diff --git a/Source/Collision/CollisionDetection/imstkPointSetToSphereCD.h b/Source/CollisionDetection/CollisionDetection/imstkPointSetToSphereCD.h similarity index 100% rename from Source/Collision/CollisionDetection/imstkPointSetToSphereCD.h rename to Source/CollisionDetection/CollisionDetection/imstkPointSetToSphereCD.h diff --git a/Source/Collision/CollisionDetection/imstkPointSetToSpherePickingCD.cpp b/Source/CollisionDetection/CollisionDetection/imstkPointSetToSpherePickingCD.cpp similarity index 100% rename from Source/Collision/CollisionDetection/imstkPointSetToSpherePickingCD.cpp rename to Source/CollisionDetection/CollisionDetection/imstkPointSetToSpherePickingCD.cpp diff --git a/Source/Collision/CollisionDetection/imstkPointSetToSpherePickingCD.h b/Source/CollisionDetection/CollisionDetection/imstkPointSetToSpherePickingCD.h similarity index 100% rename from Source/Collision/CollisionDetection/imstkPointSetToSpherePickingCD.h rename to Source/CollisionDetection/CollisionDetection/imstkPointSetToSpherePickingCD.h diff --git a/Source/Collision/CollisionDetection/imstkPointSetToSurfaceMeshCD.cpp b/Source/CollisionDetection/CollisionDetection/imstkPointSetToSurfaceMeshCD.cpp similarity index 100% rename from Source/Collision/CollisionDetection/imstkPointSetToSurfaceMeshCD.cpp rename to Source/CollisionDetection/CollisionDetection/imstkPointSetToSurfaceMeshCD.cpp diff --git a/Source/Collision/CollisionDetection/imstkPointSetToSurfaceMeshCD.h b/Source/CollisionDetection/CollisionDetection/imstkPointSetToSurfaceMeshCD.h similarity index 100% rename from Source/Collision/CollisionDetection/imstkPointSetToSurfaceMeshCD.h rename to Source/CollisionDetection/CollisionDetection/imstkPointSetToSurfaceMeshCD.h diff --git a/Source/Collision/CollisionDetection/imstkSphereToCylinderCD.cpp b/Source/CollisionDetection/CollisionDetection/imstkSphereToCylinderCD.cpp similarity index 100% rename from Source/Collision/CollisionDetection/imstkSphereToCylinderCD.cpp rename to Source/CollisionDetection/CollisionDetection/imstkSphereToCylinderCD.cpp diff --git a/Source/Collision/CollisionDetection/imstkSphereToCylinderCD.h b/Source/CollisionDetection/CollisionDetection/imstkSphereToCylinderCD.h similarity index 100% rename from Source/Collision/CollisionDetection/imstkSphereToCylinderCD.h rename to Source/CollisionDetection/CollisionDetection/imstkSphereToCylinderCD.h diff --git a/Source/Collision/CollisionDetection/imstkSphereToSphereCD.cpp b/Source/CollisionDetection/CollisionDetection/imstkSphereToSphereCD.cpp similarity index 100% rename from Source/Collision/CollisionDetection/imstkSphereToSphereCD.cpp rename to Source/CollisionDetection/CollisionDetection/imstkSphereToSphereCD.cpp diff --git a/Source/Collision/CollisionDetection/imstkSphereToSphereCD.h b/Source/CollisionDetection/CollisionDetection/imstkSphereToSphereCD.h similarity index 100% rename from Source/Collision/CollisionDetection/imstkSphereToSphereCD.h rename to Source/CollisionDetection/CollisionDetection/imstkSphereToSphereCD.h diff --git a/Source/Collision/CollisionDetection/imstkSurfaceMeshToSurfaceMeshCCD.cpp b/Source/CollisionDetection/CollisionDetection/imstkSurfaceMeshToSurfaceMeshCCD.cpp similarity index 100% rename from Source/Collision/CollisionDetection/imstkSurfaceMeshToSurfaceMeshCCD.cpp rename to Source/CollisionDetection/CollisionDetection/imstkSurfaceMeshToSurfaceMeshCCD.cpp diff --git a/Source/Collision/CollisionDetection/imstkSurfaceMeshToSurfaceMeshCCD.h b/Source/CollisionDetection/CollisionDetection/imstkSurfaceMeshToSurfaceMeshCCD.h similarity index 100% rename from Source/Collision/CollisionDetection/imstkSurfaceMeshToSurfaceMeshCCD.h rename to Source/CollisionDetection/CollisionDetection/imstkSurfaceMeshToSurfaceMeshCCD.h diff --git a/Source/Collision/CollisionDetection/imstkSurfaceMeshToSurfaceMeshCD.cpp b/Source/CollisionDetection/CollisionDetection/imstkSurfaceMeshToSurfaceMeshCD.cpp similarity index 100% rename from Source/Collision/CollisionDetection/imstkSurfaceMeshToSurfaceMeshCD.cpp rename to Source/CollisionDetection/CollisionDetection/imstkSurfaceMeshToSurfaceMeshCD.cpp diff --git a/Source/Collision/CollisionDetection/imstkSurfaceMeshToSurfaceMeshCD.h b/Source/CollisionDetection/CollisionDetection/imstkSurfaceMeshToSurfaceMeshCD.h similarity index 100% rename from Source/Collision/CollisionDetection/imstkSurfaceMeshToSurfaceMeshCD.h rename to Source/CollisionDetection/CollisionDetection/imstkSurfaceMeshToSurfaceMeshCD.h diff --git a/Source/Collision/CollisionDetection/imstkTetraToTetraCD.cpp b/Source/CollisionDetection/CollisionDetection/imstkTetraToTetraCD.cpp similarity index 100% rename from Source/Collision/CollisionDetection/imstkTetraToTetraCD.cpp rename to Source/CollisionDetection/CollisionDetection/imstkTetraToTetraCD.cpp diff --git a/Source/Collision/CollisionDetection/imstkTetraToTetraCD.h b/Source/CollisionDetection/CollisionDetection/imstkTetraToTetraCD.h similarity index 100% rename from Source/Collision/CollisionDetection/imstkTetraToTetraCD.h rename to Source/CollisionDetection/CollisionDetection/imstkTetraToTetraCD.h diff --git a/Source/Collision/CollisionDetection/imstkUnidirectionalPlaneToSphereCD.cpp b/Source/CollisionDetection/CollisionDetection/imstkUnidirectionalPlaneToSphereCD.cpp similarity index 100% rename from Source/Collision/CollisionDetection/imstkUnidirectionalPlaneToSphereCD.cpp rename to Source/CollisionDetection/CollisionDetection/imstkUnidirectionalPlaneToSphereCD.cpp diff --git a/Source/Collision/CollisionDetection/imstkUnidirectionalPlaneToSphereCD.h b/Source/CollisionDetection/CollisionDetection/imstkUnidirectionalPlaneToSphereCD.h similarity index 100% rename from Source/Collision/CollisionDetection/imstkUnidirectionalPlaneToSphereCD.h rename to Source/CollisionDetection/CollisionDetection/imstkUnidirectionalPlaneToSphereCD.h diff --git a/Source/Collision/Testing/imstkOctreeBasedCDTest.cpp b/Source/CollisionDetection/Testing/imstkOctreeBasedCDTest.cpp similarity index 100% rename from Source/Collision/Testing/imstkOctreeBasedCDTest.cpp rename to Source/CollisionDetection/Testing/imstkOctreeBasedCDTest.cpp diff --git a/Source/Collision/Testing/imstkTetraToTetraCDTest.cpp b/Source/CollisionDetection/Testing/imstkTetraToTetraCDTest.cpp similarity index 95% rename from Source/Collision/Testing/imstkTetraToTetraCDTest.cpp rename to Source/CollisionDetection/Testing/imstkTetraToTetraCDTest.cpp index 1ee4ddb66a4f21ff96d5680bb3d31720fa55411b..a1ab43d0c7c356e63e0ffacf065b633003504291 100644 --- a/Source/Collision/Testing/imstkTetraToTetraCDTest.cpp +++ b/Source/CollisionDetection/Testing/imstkTetraToTetraCDTest.cpp @@ -25,7 +25,6 @@ #include <memory> #include "imstkCollisionData.h" -#include "imstkIsometricMap.h" #include "imstkMeshIO.h" #include "imstkTetraToTetraCD.h" #include "imstkTetrahedralMesh.h" @@ -41,9 +40,9 @@ protected: std::shared_ptr<TetrahedralMesh> loadMesh(const std::string& externalDataSuffix) { - std::string file = iMSTK_DATA_ROOT + externalDataSuffix; - std::shared_ptr<TetrahedralMesh> volMesh - = std::static_pointer_cast<TetrahedralMesh>(imstk::MeshIO::read(file)); + std::string file = iMSTK_DATA_ROOT + externalDataSuffix; + + auto volMesh = std::static_pointer_cast<TetrahedralMesh>(imstk::MeshIO::read(file)); CHECK(volMesh != nullptr) << "Failed to read a volumetric mesh file : " << file; diff --git a/Source/CollisionHandling/CMakeLists.txt b/Source/CollisionHandling/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..945f87540646cc3d6530e3dcd6200aec0cc29593 --- /dev/null +++ b/Source/CollisionHandling/CMakeLists.txt @@ -0,0 +1,21 @@ +#----------------------------------------------------------------------------- +# Create target +#----------------------------------------------------------------------------- +include(imstkAddLibrary) +imstk_add_library( CollisionHandling + DEPENDS + CollisionDetection + SceneEntities + Controllers + ) + +#----------------------------------------------------------------------------- +# Testing +#----------------------------------------------------------------------------- +#if( ${PROJECT_NAME}_BUILD_TESTING ) + +# include(imstkAddTest) + +# imstk_add_test(Collision) +# imstk_add_data(Collision ${FILE_LIST_COL_TEST}) +#endif() diff --git a/Source/Collision/CollisionHandling/imstkBoneDrillingCH.cpp b/Source/CollisionHandling/imstkBoneDrillingCH.cpp similarity index 100% rename from Source/Collision/CollisionHandling/imstkBoneDrillingCH.cpp rename to Source/CollisionHandling/imstkBoneDrillingCH.cpp diff --git a/Source/Collision/CollisionHandling/imstkBoneDrillingCH.h b/Source/CollisionHandling/imstkBoneDrillingCH.h similarity index 100% rename from Source/Collision/CollisionHandling/imstkBoneDrillingCH.h rename to Source/CollisionHandling/imstkBoneDrillingCH.h diff --git a/Source/Collision/CollisionHandling/imstkCollisionHandling.cpp b/Source/CollisionHandling/imstkCollisionHandling.cpp similarity index 100% rename from Source/Collision/CollisionHandling/imstkCollisionHandling.cpp rename to Source/CollisionHandling/imstkCollisionHandling.cpp diff --git a/Source/Collision/CollisionHandling/imstkCollisionHandling.h b/Source/CollisionHandling/imstkCollisionHandling.h similarity index 100% rename from Source/Collision/CollisionHandling/imstkCollisionHandling.h rename to Source/CollisionHandling/imstkCollisionHandling.h diff --git a/Source/Collision/CollisionHandling/imstkPBDCollisionHandling.cpp b/Source/CollisionHandling/imstkPBDCollisionHandling.cpp similarity index 100% rename from Source/Collision/CollisionHandling/imstkPBDCollisionHandling.cpp rename to Source/CollisionHandling/imstkPBDCollisionHandling.cpp diff --git a/Source/Collision/CollisionHandling/imstkPBDCollisionHandling.h b/Source/CollisionHandling/imstkPBDCollisionHandling.h similarity index 100% rename from Source/Collision/CollisionHandling/imstkPBDCollisionHandling.h rename to Source/CollisionHandling/imstkPBDCollisionHandling.h diff --git a/Source/Collision/CollisionHandling/imstkPenaltyCH.cpp b/Source/CollisionHandling/imstkPenaltyCH.cpp similarity index 100% rename from Source/Collision/CollisionHandling/imstkPenaltyCH.cpp rename to Source/CollisionHandling/imstkPenaltyCH.cpp diff --git a/Source/Collision/CollisionHandling/imstkPenaltyCH.h b/Source/CollisionHandling/imstkPenaltyCH.h similarity index 100% rename from Source/Collision/CollisionHandling/imstkPenaltyCH.h rename to Source/CollisionHandling/imstkPenaltyCH.h diff --git a/Source/Collision/CollisionHandling/imstkPickingCH.cpp b/Source/CollisionHandling/imstkPickingCH.cpp similarity index 100% rename from Source/Collision/CollisionHandling/imstkPickingCH.cpp rename to Source/CollisionHandling/imstkPickingCH.cpp diff --git a/Source/Collision/CollisionHandling/imstkPickingCH.h b/Source/CollisionHandling/imstkPickingCH.h similarity index 100% rename from Source/Collision/CollisionHandling/imstkPickingCH.h rename to Source/CollisionHandling/imstkPickingCH.h diff --git a/Source/Collision/CollisionHandling/imstkSPHCollisionHandling.cpp b/Source/CollisionHandling/imstkSPHCollisionHandling.cpp similarity index 100% rename from Source/Collision/CollisionHandling/imstkSPHCollisionHandling.cpp rename to Source/CollisionHandling/imstkSPHCollisionHandling.cpp diff --git a/Source/Collision/CollisionHandling/imstkSPHCollisionHandling.h b/Source/CollisionHandling/imstkSPHCollisionHandling.h similarity index 100% rename from Source/Collision/CollisionHandling/imstkSPHCollisionHandling.h rename to Source/CollisionHandling/imstkSPHCollisionHandling.h diff --git a/Source/Collision/CollisionHandling/imstkVirtualCouplingCH.cpp b/Source/CollisionHandling/imstkVirtualCouplingCH.cpp similarity index 100% rename from Source/Collision/CollisionHandling/imstkVirtualCouplingCH.cpp rename to Source/CollisionHandling/imstkVirtualCouplingCH.cpp diff --git a/Source/Collision/CollisionHandling/imstkVirtualCouplingCH.h b/Source/CollisionHandling/imstkVirtualCouplingCH.h similarity index 100% rename from Source/Collision/CollisionHandling/imstkVirtualCouplingCH.h rename to Source/CollisionHandling/imstkVirtualCouplingCH.h diff --git a/Source/Common/CMakeLists.txt b/Source/Common/CMakeLists.txt index 83ae7865ed1fc9bc8d0c00f9b365f4a08488a3e2..fd79865f63fd76aef8a5e48235b5d97dc4976335 100644 --- a/Source/Common/CMakeLists.txt +++ b/Source/Common/CMakeLists.txt @@ -16,3 +16,4 @@ if( ${PROJECT_NAME}_BUILD_TESTING ) include(imstkAddTest) imstk_add_test( Common ) endif() + diff --git a/Source/Rendering/Materials/imstkColor.cpp b/Source/Common/imstkColor.cpp similarity index 100% rename from Source/Rendering/Materials/imstkColor.cpp rename to Source/Common/imstkColor.cpp diff --git a/Source/Rendering/Materials/imstkColor.h b/Source/Common/imstkColor.h similarity index 100% rename from Source/Rendering/Materials/imstkColor.h rename to Source/Common/imstkColor.h diff --git a/Source/Controllers/CMakeLists.txt b/Source/Controllers/CMakeLists.txt index 9055b1c1b6f3b5b694b4bfb4dd0c35509e31af0c..f4071ef623e6c0b2f9d7ce8ce4d18f731201fd93 100644 --- a/Source/Controllers/CMakeLists.txt +++ b/Source/Controllers/CMakeLists.txt @@ -4,9 +4,8 @@ include(imstkAddLibrary) imstk_add_library( Controllers DEPENDS - Common - Scene - SceneElements + Devices + SceneEntities ) #----------------------------------------------------------------------------- diff --git a/Source/DataStructures/CMakeLists.txt b/Source/DataStructures/CMakeLists.txt index 1f181387d9bcfac053efd143b614ddde819e4000..98d8e6ae29048438eb82d0c684dbff7d541b2b66 100644 --- a/Source/DataStructures/CMakeLists.txt +++ b/Source/DataStructures/CMakeLists.txt @@ -5,8 +5,7 @@ include(imstkAddLibrary) imstk_add_library( DataStructures DEPENDS Common - #Materials - Geometry + Geometry #TODO remove this dependency ) #----------------------------------------------------------------------------- diff --git a/Source/DataStructures/imstkLooseOctree.cpp b/Source/DataStructures/imstkLooseOctree.cpp index 9f88d95419e1ce735331a27057325ee822e1fa7a..0ef44a90ba33b6dedd8e77d4cbb2f009d2539022 100644 --- a/Source/DataStructures/imstkLooseOctree.cpp +++ b/Source/DataStructures/imstkLooseOctree.cpp @@ -25,7 +25,7 @@ #include "imstkPointSet.h" #include "imstkSurfaceMesh.h" #include "imstkDebugRenderGeometry.h" -#include "imstkRenderMaterial.h" +//#include "imstkRenderMaterial.h" namespace imstk { @@ -1026,10 +1026,6 @@ LooseOctree::getDebugGeometry(const uint32_t maxLevel, bool bDrawNonEmptyParent // Create debug geometry and set default rendering mateirial m_DebugGeometry = std::make_shared<DebugRenderLines>("OctreeDebugRendering"); - const auto material = std::make_shared<RenderMaterial>(); - material->setDebugColor(Color::Green); - material->setLineWidth(1.0); - m_DebugGeometry->setRenderMaterial(material); // Update debug rendering data (if any) m_pRootNode->updateDebugGeometry(); diff --git a/Source/DynamicalModels/CMakeLists.txt b/Source/DynamicalModels/CMakeLists.txt index adb258a712ff1998c80ac6c6b1e4e57a88e290b4..b69970a4c2ad14e919c332a40d157f5059c74a5a 100644 --- a/Source/DynamicalModels/CMakeLists.txt +++ b/Source/DynamicalModels/CMakeLists.txt @@ -10,8 +10,7 @@ imstk_add_library( DynamicalModels ObjectModels ObjectModels/PbdConstraints InternalForceModel - DEPENDS - Common + DEPENDS DataStructures Constraints Geometry diff --git a/Source/DynamicalModels/ObjectModels/imstkPbdModel.cpp b/Source/DynamicalModels/ObjectModels/imstkPbdModel.cpp index 4d9715513c89c95acfac9f9728f70e7d97617689..188949934a7743c086eb10660386b07ba27b1fda 100644 --- a/Source/DynamicalModels/ObjectModels/imstkPbdModel.cpp +++ b/Source/DynamicalModels/ObjectModels/imstkPbdModel.cpp @@ -35,7 +35,7 @@ #include "imstkParallelUtils.h" #include "imstkGeometryUtilities.h" #include "imstkMeshIO.h" -#include "imstkColor.h" +//#include "imstkColor.h" #include <unordered_map> diff --git a/Source/Geometry/CMakeLists.txt b/Source/Geometry/CMakeLists.txt index 82540c2e850d874744b0ca01a31106a964841128..d3eb93e9a206193c0108dc7755c6dc3b7f400c3f 100644 --- a/Source/Geometry/CMakeLists.txt +++ b/Source/Geometry/CMakeLists.txt @@ -4,11 +4,7 @@ include(imstkAddLibrary) imstk_add_library( Geometry DEPENDS - Common - glm - Assimp - Materials - VegaFEM::volumetricMesh + Common ${VTK_LIBRARIES} ) diff --git a/Source/Geometry/Decal/imstkDecalPool.cpp b/Source/Geometry/Decal/imstkDecalPool.cpp index 17d6d7c23fd864398feac51c906c8cc2b494f944..7c496a5191b751e65620cb2d25bf53a510d43ab3 100644 --- a/Source/Geometry/Decal/imstkDecalPool.cpp +++ b/Source/Geometry/Decal/imstkDecalPool.cpp @@ -20,6 +20,7 @@ =========================================================================*/ #include "imstkDecalPool.h" +#include "imstkLogger.h" namespace imstk { diff --git a/Source/Geometry/Decal/imstkDecalPool.h b/Source/Geometry/Decal/imstkDecalPool.h index 787136b914d831e862d0e6bca6008a5786b2b99c..e19a847c8bbbcf775838aa07b57a59b5c79f1559 100644 --- a/Source/Geometry/Decal/imstkDecalPool.h +++ b/Source/Geometry/Decal/imstkDecalPool.h @@ -26,7 +26,7 @@ #include "imstkDecal.h" #include "imstkGeometry.h" -#include "imstkRenderMaterial.h" +//#include "imstkRenderMaterial.h" namespace imstk { diff --git a/Source/Geometry/Mesh/imstkLineMesh.cpp b/Source/Geometry/Mesh/imstkLineMesh.cpp index 0ab7c7b683094b55a86e778c30173c74318ba3f2..b90b21c780a94c9e81fdc6667deb45f2ca7b7a77 100644 --- a/Source/Geometry/Mesh/imstkLineMesh.cpp +++ b/Source/Geometry/Mesh/imstkLineMesh.cpp @@ -21,7 +21,6 @@ #include "imstkLineMesh.h" #include "imstkLogger.h" -#include "imstkColor.h" namespace imstk { @@ -40,7 +39,6 @@ void LineMesh::clear() { m_lines.clear(); - m_vertexColors.clear(); } void @@ -55,19 +53,6 @@ LineMesh::getVolume() const return 0.0; } -void -LineMesh::setVertexColors(const std::vector<Color>& colors) -{ - if (colors.size() <= m_maxNumVertices) - { - m_vertexColors = colors; - } - else - { - LOG(WARNING) << "Vertex colors not set, exceeded maximum number of vertices"; - } -} - void LineMesh::setLinesVertices(const std::vector<LineArray>& lines) { @@ -100,10 +85,4 @@ LineMesh::getLinesVertices() const { return m_lines; } - -std::vector<Color> -LineMesh::getVertexColors() const -{ - return m_vertexColors; -} } // imstk diff --git a/Source/Geometry/Mesh/imstkLineMesh.h b/Source/Geometry/Mesh/imstkLineMesh.h index 905fc6cc0d483bae462da2f0888b4b8f67a67c1b..00e472e62b0dd4171deae1e5475836e34a45fd58 100644 --- a/Source/Geometry/Mesh/imstkLineMesh.h +++ b/Source/Geometry/Mesh/imstkLineMesh.h @@ -66,11 +66,6 @@ public: /// double getVolume() const override; - /// - /// \brief - /// - void setVertexColors(const std::vector<Color>& colors); - /// /// \brief /// @@ -86,11 +81,6 @@ public: /// std::vector<LineArray> getLinesVertices() const; - /// - /// \brief - /// - std::vector<Color> getVertexColors() const; - private: friend class VTKLineMeshRenderDelegate; @@ -98,6 +88,5 @@ private: size_t m_maxNumLines = 0; std::vector<LineArray> m_lines; ///> line connectivity - std::vector<Color> m_vertexColors; }; } // imstk diff --git a/Source/Geometry/Mesh/imstkVolumetricMesh.cpp b/Source/Geometry/Mesh/imstkVolumetricMesh.cpp index ef3325f79084cf4076626fedea35dc7aa0f0d28e..c05f409b2a3975b615d12c9f014bfe6e2ffa4a02 100644 --- a/Source/Geometry/Mesh/imstkVolumetricMesh.cpp +++ b/Source/Geometry/Mesh/imstkVolumetricMesh.cpp @@ -23,12 +23,6 @@ #include "imstkSurfaceMesh.h" #include "imstkLogger.h" -#pragma warning( push ) -#pragma warning( disable : 4458 ) -// Vega -#include "volumetricMesh.h" -#pragma warning( pop ) - namespace imstk { std::shared_ptr<SurfaceMesh> diff --git a/Source/Geometry/Particles/imstkRenderParticles.h b/Source/Geometry/Particles/imstkRenderParticles.h index 3239da80f7d680fda415cc2e831c403f32451afe..9e65f0caae6ee000f600b7af1f2f2f07728fe641 100644 --- a/Source/Geometry/Particles/imstkRenderParticles.h +++ b/Source/Geometry/Particles/imstkRenderParticles.h @@ -28,7 +28,7 @@ #include "imstkGeometry.h" #include "imstkMath.h" -#include "imstkColor.h" +//#include "imstkColor.h" namespace imstk { @@ -42,7 +42,7 @@ struct RenderParticle Vec3f m_position = Vec3f(0, 0, 0); Vec3f m_velocity = Vec3f(0, 0, 0); Vec3f m_acceleration = Vec3f(0, 0, 0); - Color m_color = Color::White; + Vec4d m_color = Vec4d(1., 1., 1., 1.); float m_age = 0; bool m_created = false; float m_scale = 1.0f; diff --git a/Source/Geometry/imstkDebugRenderGeometry.cpp b/Source/Geometry/imstkDebugRenderGeometry.cpp index ecc302b0689b4317000ea4a16b341d41214f712e..52574285025b6c0b5541c661c33471f891b4d0ab 100644 --- a/Source/Geometry/imstkDebugRenderGeometry.cpp +++ b/Source/Geometry/imstkDebugRenderGeometry.cpp @@ -20,6 +20,7 @@ =========================================================================*/ #include "imstkDebugRenderGeometry.h" +#include "imstkLogger.h" namespace imstk { @@ -27,7 +28,7 @@ const Vec3d& DebugRenderGeometry::getVertex(const size_t idx) const { #if defined(DEBUG) || defined(_DEBUG) || !defined(NDEBUG) - LOG_IF(FATAL, (idx >= getNumVertices())) << "Invalid index"; + CHECK(idx < getNumVertices()) << "Invalid index"; #endif return m_VertexBuffer[idx]; } @@ -36,20 +37,8 @@ void DebugRenderGeometry::setVertex(const size_t idx, const Vec3d& vert) { #if defined(DEBUG) || defined(_DEBUG) || !defined(NDEBUG) - LOG_IF(FATAL, (idx >= getNumVertices())) << "Invalid index"; + CHECK(idx < getNumVertices()) << "Invalid index"; #endif m_VertexBuffer[idx] = vert; } - -void -DebugRenderGeometry::setRenderMaterial(const std::shared_ptr<RenderMaterial>& renderMat) -{ - m_renderMaterial = renderMat; -} - -const std::shared_ptr<imstk::RenderMaterial>& -DebugRenderGeometry::getRenderMaterial() const -{ - return m_renderMaterial; -} } // end namespace imstk diff --git a/Source/Geometry/imstkDebugRenderGeometry.h b/Source/Geometry/imstkDebugRenderGeometry.h index 6d170d1bfae253fbf612c1dcfc1e750c0333bf35..86fbef44a286f650b262ac789c3d83e1b69eb1bf 100644 --- a/Source/Geometry/imstkDebugRenderGeometry.h +++ b/Source/Geometry/imstkDebugRenderGeometry.h @@ -22,7 +22,6 @@ #pragma once #include "imstkMath.h" -#include "imstkRenderMaterial.h" namespace imstk { @@ -108,12 +107,6 @@ public: bool isModified() const { return m_isModified; } void setDataModified(const bool bState) { m_isModified = bState; } - /// - /// \brief Set/Get render material - /// - void setRenderMaterial(const std::shared_ptr<RenderMaterial>& renderMat); - const std::shared_ptr<RenderMaterial>& getRenderMaterial() const; - protected: friend class VTKRenderer; friend class VTKRenderDelegate; @@ -121,10 +114,10 @@ protected: /// /// \brief Constructor /// - explicit DebugRenderGeometry(const std::string& name, const Type type) : - m_name(name), m_type(type), m_renderMaterial(std::make_shared<RenderMaterial>()) - { - } + explicit DebugRenderGeometry(const std::string& name, + const Type type) : + m_name(name), + m_type(type) {} virtual ~DebugRenderGeometry() = default; @@ -132,9 +125,7 @@ protected: Type m_type; ///> Debug geometry type StdVectorOfVec3d m_VertexBuffer; ///> Vertex buffer - bool m_renderDelegateCreated = false; ///> This variable is used in Renderer bool m_isModified = false; - std::shared_ptr<RenderMaterial> m_renderMaterial = nullptr; }; /// diff --git a/Source/Geometry/imstkGeometryUtilities.cpp b/Source/Geometry/imstkGeometryUtilities.cpp index c1da31885f344c2065d35370922f4f5a239ac618..225d33704f80df844b53ad27e46559f139c8a1ee 100644 --- a/Source/Geometry/imstkGeometryUtilities.cpp +++ b/Source/Geometry/imstkGeometryUtilities.cpp @@ -25,7 +25,6 @@ #include "imstkPointSet.h" #include "imstkSurfaceMesh.h" #include "imstkTetrahedralMesh.h" -#include "imstkColor.h" #include <vtkAppendPolyData.h> #include <vtkCleanPolyData.h> diff --git a/Source/GeometryMappers/CMakeLists.txt b/Source/GeometryMappers/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..1c12a86d3c5f2098bf0d5fd2e86d263cf7f9c4ea --- /dev/null +++ b/Source/GeometryMappers/CMakeLists.txt @@ -0,0 +1,16 @@ +#----------------------------------------------------------------------------- +# Create target +#----------------------------------------------------------------------------- +include(imstkAddLibrary) +imstk_add_library( GeometryMappers + DEPENDS + Geometry + ) + +#----------------------------------------------------------------------------- +# Testing +#----------------------------------------------------------------------------- +#if( ${PROJECT_NAME}_BUILD_TESTING ) +# include(imstkAddTest) +# imstk_add_test( GeometryMappers ) +#endif() diff --git a/Source/Geometry/Map/imstkGeometryMap.cpp b/Source/GeometryMappers/imstkGeometryMap.cpp similarity index 100% rename from Source/Geometry/Map/imstkGeometryMap.cpp rename to Source/GeometryMappers/imstkGeometryMap.cpp diff --git a/Source/Geometry/Map/imstkGeometryMap.h b/Source/GeometryMappers/imstkGeometryMap.h similarity index 100% rename from Source/Geometry/Map/imstkGeometryMap.h rename to Source/GeometryMappers/imstkGeometryMap.h diff --git a/Source/Geometry/Map/imstkIdentityMap.cpp b/Source/GeometryMappers/imstkIdentityMap.cpp similarity index 100% rename from Source/Geometry/Map/imstkIdentityMap.cpp rename to Source/GeometryMappers/imstkIdentityMap.cpp diff --git a/Source/Geometry/Map/imstkIdentityMap.h b/Source/GeometryMappers/imstkIdentityMap.h similarity index 100% rename from Source/Geometry/Map/imstkIdentityMap.h rename to Source/GeometryMappers/imstkIdentityMap.h diff --git a/Source/Geometry/Map/imstkIsometricMap.cpp b/Source/GeometryMappers/imstkIsometricMap.cpp similarity index 100% rename from Source/Geometry/Map/imstkIsometricMap.cpp rename to Source/GeometryMappers/imstkIsometricMap.cpp diff --git a/Source/Geometry/Map/imstkIsometricMap.h b/Source/GeometryMappers/imstkIsometricMap.h similarity index 100% rename from Source/Geometry/Map/imstkIsometricMap.h rename to Source/GeometryMappers/imstkIsometricMap.h diff --git a/Source/Geometry/Map/imstkOneToOneMap.cpp b/Source/GeometryMappers/imstkOneToOneMap.cpp similarity index 100% rename from Source/Geometry/Map/imstkOneToOneMap.cpp rename to Source/GeometryMappers/imstkOneToOneMap.cpp diff --git a/Source/Geometry/Map/imstkOneToOneMap.h b/Source/GeometryMappers/imstkOneToOneMap.h similarity index 100% rename from Source/Geometry/Map/imstkOneToOneMap.h rename to Source/GeometryMappers/imstkOneToOneMap.h diff --git a/Source/Geometry/Map/imstkTetraTriangleMap.cpp b/Source/GeometryMappers/imstkTetraTriangleMap.cpp similarity index 100% rename from Source/Geometry/Map/imstkTetraTriangleMap.cpp rename to Source/GeometryMappers/imstkTetraTriangleMap.cpp diff --git a/Source/Geometry/Map/imstkTetraTriangleMap.h b/Source/GeometryMappers/imstkTetraTriangleMap.h similarity index 100% rename from Source/Geometry/Map/imstkTetraTriangleMap.h rename to Source/GeometryMappers/imstkTetraTriangleMap.h diff --git a/Source/MeshIO/CMakeLists.txt b/Source/MeshIO/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..d26bc6ff931da03f666ca371b26bb0379ee7d391 --- /dev/null +++ b/Source/MeshIO/CMakeLists.txt @@ -0,0 +1,21 @@ +#----------------------------------------------------------------------------- +# Create target +#----------------------------------------------------------------------------- +include(imstkAddLibrary) +imstk_add_library( MeshIO + DEPENDS + Common + Geometry + glm + Assimp + VegaFEM::volumetricMesh + ${VTK_LIBRARIES} + ) + +#----------------------------------------------------------------------------- +# Testing +#----------------------------------------------------------------------------- +#if( ${PROJECT_NAME}_BUILD_TESTING ) +# include(imstkAddTest) +# imstk_add_test( Geometry ) +#endif() diff --git a/Source/Geometry/Reader/imstkAssimpMeshIO.cpp b/Source/MeshIO/imstkAssimpMeshIO.cpp similarity index 100% rename from Source/Geometry/Reader/imstkAssimpMeshIO.cpp rename to Source/MeshIO/imstkAssimpMeshIO.cpp diff --git a/Source/Geometry/Reader/imstkAssimpMeshIO.h b/Source/MeshIO/imstkAssimpMeshIO.h similarity index 100% rename from Source/Geometry/Reader/imstkAssimpMeshIO.h rename to Source/MeshIO/imstkAssimpMeshIO.h diff --git a/Source/Geometry/Reader/imstkMSHMeshIO.cpp b/Source/MeshIO/imstkMSHMeshIO.cpp similarity index 100% rename from Source/Geometry/Reader/imstkMSHMeshIO.cpp rename to Source/MeshIO/imstkMSHMeshIO.cpp diff --git a/Source/Geometry/Reader/imstkMSHMeshIO.h b/Source/MeshIO/imstkMSHMeshIO.h similarity index 100% rename from Source/Geometry/Reader/imstkMSHMeshIO.h rename to Source/MeshIO/imstkMSHMeshIO.h diff --git a/Source/Geometry/Reader/imstkMeshIO.cpp b/Source/MeshIO/imstkMeshIO.cpp similarity index 99% rename from Source/Geometry/Reader/imstkMeshIO.cpp rename to Source/MeshIO/imstkMeshIO.cpp index aad6421d3bde995f97b2fa9e62fa0bf4713db17e..5245897c0764daf0571efd3b2e616ab5d8829c20 100644 --- a/Source/Geometry/Reader/imstkMeshIO.cpp +++ b/Source/MeshIO/imstkMeshIO.cpp @@ -26,7 +26,7 @@ #include "imstkAssimpMeshIO.h" #include "imstkVegaMeshIO.h" #include "imstkMSHMeshIO.h" -#include "imstkColor.h" +//#include "imstkColor.h" #include "imstkSurfaceMesh.h" #include "imstkLineMesh.h" diff --git a/Source/Geometry/Reader/imstkMeshIO.h b/Source/MeshIO/imstkMeshIO.h similarity index 100% rename from Source/Geometry/Reader/imstkMeshIO.h rename to Source/MeshIO/imstkMeshIO.h diff --git a/Source/Geometry/Reader/imstkVTKMeshIO.cpp b/Source/MeshIO/imstkVTKMeshIO.cpp similarity index 99% rename from Source/Geometry/Reader/imstkVTKMeshIO.cpp rename to Source/MeshIO/imstkVTKMeshIO.cpp index 08ec904a61531aa7ab5b2fa78c5afe039b01eef8..80b1363fe5b821d4fc52665b3a39a7551eae4cf1 100644 --- a/Source/Geometry/Reader/imstkVTKMeshIO.cpp +++ b/Source/MeshIO/imstkVTKMeshIO.cpp @@ -45,7 +45,7 @@ #include "imstkTetrahedralMesh.h" #include "imstkHexahedralMesh.h" -#include "imstkColor.h" +//#include "imstkColor.h" #include "imstkLogger.h" namespace imstk diff --git a/Source/Geometry/Reader/imstkVTKMeshIO.h b/Source/MeshIO/imstkVTKMeshIO.h similarity index 100% rename from Source/Geometry/Reader/imstkVTKMeshIO.h rename to Source/MeshIO/imstkVTKMeshIO.h diff --git a/Source/Geometry/Reader/imstkVegaMeshIO.cpp b/Source/MeshIO/imstkVegaMeshIO.cpp similarity index 100% rename from Source/Geometry/Reader/imstkVegaMeshIO.cpp rename to Source/MeshIO/imstkVegaMeshIO.cpp diff --git a/Source/Geometry/Reader/imstkVegaMeshIO.h b/Source/MeshIO/imstkVegaMeshIO.h similarity index 100% rename from Source/Geometry/Reader/imstkVegaMeshIO.h rename to Source/MeshIO/imstkVegaMeshIO.h diff --git a/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKLineMeshRenderDelegate.cpp b/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKLineMeshRenderDelegate.cpp index 3aadee943259637fd06e8302f04a702b2cd0ace9..10c5c39b147fdc40aac0f3378fb208f7dd226f9e 100644 --- a/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKLineMeshRenderDelegate.cpp +++ b/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKLineMeshRenderDelegate.cpp @@ -29,6 +29,7 @@ #include <vtkFloatArray.h> #include <vtkLineSource.h> #include <vtkPointData.h> +#include <vtkCellData.h> #include <vtkPolyData.h> #include <vtkPoints.h> #include <vtkLine.h> @@ -70,7 +71,7 @@ VTKLineMeshRenderDelegate::VTKLineMeshRenderDelegate(std::shared_ptr<VisualModel lines->SetLines(lineIndices); // Add colors - if (geometry->getVertexColors().size() == geometry->getNumVertices()) + /*if (geometry->getVertexColors().size() == geometry->getNumVertices()) { auto colors = vtkSmartPointer<vtkUnsignedCharArray>::New(); colors->SetNumberOfComponents(3); @@ -85,7 +86,7 @@ VTKLineMeshRenderDelegate::VTKLineMeshRenderDelegate(std::shared_ptr<VisualModel } lines->GetPointData()->SetScalars(colors); - } + }*/ // Create connection source auto source = vtkSmartPointer<vtkTrivialProducer>::New(); diff --git a/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKRenderDelegate.cpp b/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKRenderDelegate.cpp index 7948cfa712f787043f57f385ee9e81d0e6326740..285453616362c8b3ca185f7ab364b46c43821214 100644 --- a/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKRenderDelegate.cpp +++ b/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKRenderDelegate.cpp @@ -119,28 +119,25 @@ VTKRenderDelegate::makeDelegate(std::shared_ptr<VisualModel> visualModel) } std::shared_ptr<imstk::VTKRenderDelegate> -VTKRenderDelegate::makeDebugDelegate(std::shared_ptr<DebugRenderGeometry> geom) +VTKRenderDelegate::makeDebugDelegate(std::shared_ptr<VisualModel> dbgVizModel) { - switch (geom->getType()) + switch (dbgVizModel->getDebugGeometry()->getType()) { case DebugRenderGeometry::Type::Points: { - auto points = std::dynamic_pointer_cast<DebugRenderPoints>(geom); - return std::make_shared<VTKdbgPointsRenderDelegate>(points); + return std::make_shared<VTKdbgPointsRenderDelegate>(dbgVizModel); } case DebugRenderGeometry::Type::Lines: { - auto lines = std::dynamic_pointer_cast<DebugRenderLines>(geom); - return std::make_shared<VTKdbgLinesRenderDelegate>(lines); + return std::make_shared<VTKdbgLinesRenderDelegate>(dbgVizModel); } case DebugRenderGeometry::Type::Triangles: { - auto triangles = std::dynamic_pointer_cast<DebugRenderTriangles>(geom); - return std::make_shared<VTKdbgTrianglesRenderDelegate>(triangles); + return std::make_shared<VTKdbgTrianglesRenderDelegate>(dbgVizModel); } default: { - LOG(WARNING) << "RenderDelegate::makeDelegate error: Geometry type incorrect."; + LOG(WARNING) << "RenderDelegate::makeDebugDelegate error: Geometry type incorrect."; return nullptr; } } diff --git a/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKRenderDelegate.h b/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKRenderDelegate.h index 4fed20cc4014ee08f535afa542eaa5e79b3d3fca..0b1eab5373dfba373cd57f1f69b159277b519bde 100644 --- a/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKRenderDelegate.h +++ b/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKRenderDelegate.h @@ -57,7 +57,7 @@ public: /// /// \brief Instantiate proper debug render delegate /// - static std::shared_ptr<VTKRenderDelegate> makeDebugDelegate(std::shared_ptr<DebugRenderGeometry> geom); + static std::shared_ptr<VTKRenderDelegate> makeDebugDelegate(std::shared_ptr<VisualModel> dbgVizModel); /// /// \brief Set up normals and mapper diff --git a/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugLinesRenderDelegate.cpp b/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugLinesRenderDelegate.cpp index 4053ff133fd2f7694289b7a1fd8ea9e625932a91..65ac63822f79cc71c26c8a5d12be49ebc4eec667 100644 --- a/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugLinesRenderDelegate.cpp +++ b/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugLinesRenderDelegate.cpp @@ -36,10 +36,14 @@ namespace imstk { -VTKdbgLinesRenderDelegate::VTKdbgLinesRenderDelegate(const std::shared_ptr<DebugRenderLines>& lineData) : - m_RenderGeoData(lineData), +VTKdbgLinesRenderDelegate::VTKdbgLinesRenderDelegate(std::shared_ptr<VisualModel> visualModel) : m_mappedVertexArray(vtkSmartPointer<vtkDoubleArray>::New()) { + m_visualModel = visualModel; + + // assert that the visual model has debug lines + //auto dbgLines = std::static_pointer_cast<DebugRenderLines>(m_visualModel->getGeometry()); + // Map vertices m_mappedVertexArray->SetNumberOfComponents(3); @@ -61,7 +65,7 @@ VTKdbgLinesRenderDelegate::VTKdbgLinesRenderDelegate(const std::shared_ptr<Debug // Update Transform, Render Properties updateActorProperties(); - setUpMapper(source->GetOutputPort(), false, m_RenderGeoData->getRenderMaterial()); + setUpMapper(source->GetOutputPort(), false, visualModel->getRenderMaterial()); //updateDataSource(); } @@ -69,17 +73,18 @@ VTKdbgLinesRenderDelegate::VTKdbgLinesRenderDelegate(const std::shared_ptr<Debug void VTKdbgLinesRenderDelegate::updateDataSource() { - if (m_RenderGeoData->isModified()) + auto dbgLines = std::static_pointer_cast<DebugRenderLines>(m_visualModel->getDebugGeometry()); + + if (dbgLines->isModified()) { - m_RenderGeoData->setDataModified(false); - m_mappedVertexArray->SetArray(m_RenderGeoData->getVertexBufferPtr(), - m_RenderGeoData->getNumVertices() * 3, 1); + dbgLines->setDataModified(false); + m_mappedVertexArray->SetArray(dbgLines->getVertexBufferPtr(), dbgLines->getNumVertices() * 3, 1); - m_points->SetNumberOfPoints(m_RenderGeoData->getNumVertices()); + m_points->SetNumberOfPoints(dbgLines->getNumVertices()); // Set line data int numCurrentLines = m_cellArray->GetNumberOfCells(); - if (numCurrentLines > static_cast<int>(m_RenderGeoData->getNumVertices() / 2)) + if (numCurrentLines > static_cast<int>(dbgLines->getNumVertices() / 2)) { // There should is a better way to modify the existing data, // instead of discarding everything and add from the beginning @@ -88,7 +93,7 @@ VTKdbgLinesRenderDelegate::updateDataSource() } vtkIdType cell[2]; - for (int i = numCurrentLines; i < static_cast<int>(m_RenderGeoData->getNumVertices() / 2); ++i) + for (int i = numCurrentLines; i < static_cast<int>(dbgLines->getNumVertices() / 2); ++i) { cell[0] = 2 * i; cell[1] = cell[0] + 1; diff --git a/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugLinesRenderDelegate.h b/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugLinesRenderDelegate.h index 2724a83fd7cc15ccd745ef527600f7e64d25bf50..c4ebeadbd6248576964deff04836508341c8381c 100644 --- a/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugLinesRenderDelegate.h +++ b/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugLinesRenderDelegate.h @@ -41,7 +41,7 @@ public: /// /// \brief Constructor /// - explicit VTKdbgLinesRenderDelegate(const std::shared_ptr<DebugRenderLines>& lineData); + explicit VTKdbgLinesRenderDelegate(std::shared_ptr<VisualModel> visualModel); /// /// \brief Update polydata source based on the surface mesh geometry @@ -50,8 +50,6 @@ public: protected: - std::shared_ptr<DebugRenderLines> m_RenderGeoData; ///> Geometry to render - // Auxiliary variables for rendering vtkSmartPointer<vtkDoubleArray> m_mappedVertexArray; vtkSmartPointer<vtkPoints> m_points; diff --git a/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugPointsRenderDelegate.cpp b/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugPointsRenderDelegate.cpp index 8d9a73b246c871adcfa578ddc7bc271bc85e5df8..70e09511182df807ff6ae0e8772c0ff6c0aee9c8 100644 --- a/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugPointsRenderDelegate.cpp +++ b/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugPointsRenderDelegate.cpp @@ -38,10 +38,11 @@ namespace imstk { -VTKdbgPointsRenderDelegate::VTKdbgPointsRenderDelegate(const std::shared_ptr<DebugRenderPoints>& pointRenderData) : - m_RenderGeoData(pointRenderData), +VTKdbgPointsRenderDelegate::VTKdbgPointsRenderDelegate(std::shared_ptr<VisualModel> visualModel) : m_mappedVertexArray(vtkSmartPointer<vtkDoubleArray>::New()) { + m_visualModel = visualModel; + // Map vertices m_mappedVertexArray->SetNumberOfComponents(3); @@ -60,7 +61,7 @@ VTKdbgPointsRenderDelegate::VTKdbgPointsRenderDelegate(const std::shared_ptr<Deb // Update Transform, Render Properties updateActorProperties(); - setUpMapper(m_glyph->GetOutputPort(), false, m_RenderGeoData->getRenderMaterial()); + setUpMapper(m_glyph->GetOutputPort(), false, visualModel->getRenderMaterial()); //updateDataSource(); } @@ -68,16 +69,18 @@ VTKdbgPointsRenderDelegate::VTKdbgPointsRenderDelegate(const std::shared_ptr<Deb void VTKdbgPointsRenderDelegate::updateDataSource() { - if (m_RenderGeoData->isModified()) + auto dbgPoints = std::static_pointer_cast<DebugRenderPoints>(m_visualModel->getDebugGeometry()); + + if (dbgPoints->isModified()) { - m_RenderGeoData->setDataModified(false); - m_mappedVertexArray->SetArray(m_RenderGeoData->getVertexBufferPtr(), - m_RenderGeoData->getNumVertices() * 3, 1); + dbgPoints->setDataModified(false); + m_mappedVertexArray->SetArray(dbgPoints->getVertexBufferPtr(), + dbgPoints->getNumVertices() * 3, 1); // Update points geometry // m_Points need to be created from scrach, otherwise program will crash m_points = vtkSmartPointer<vtkPoints>::New(); - m_points->SetNumberOfPoints(m_RenderGeoData->getNumVertices()); + m_points->SetNumberOfPoints(dbgPoints->getNumVertices()); m_points->SetData(m_mappedVertexArray); m_polyData->SetPoints(m_points); diff --git a/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugPointsRenderDelegate.h b/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugPointsRenderDelegate.h index 95925193b47eb5198d1fa4a1b0fce7d5a49f5834..7be631ba8b7f764c69243d8f59e26b4fd95e6748 100644 --- a/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugPointsRenderDelegate.h +++ b/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugPointsRenderDelegate.h @@ -41,7 +41,7 @@ public: /// /// \brief Constructor /// - explicit VTKdbgPointsRenderDelegate(const std::shared_ptr<DebugRenderPoints>& pointData); + explicit VTKdbgPointsRenderDelegate(std::shared_ptr<VisualModel> visualModel); /// /// \brief Update polydata source based on the surface mesh geometry @@ -50,8 +50,6 @@ public: protected: - std::shared_ptr<DebugRenderPoints> m_RenderGeoData; ///> Geometry to render - // Auxiliary variables for rendering vtkSmartPointer<vtkDoubleArray> m_mappedVertexArray; vtkSmartPointer<vtkPoints> m_points; diff --git a/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugTrianglesRenderDelegate.cpp b/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugTrianglesRenderDelegate.cpp index 000c2db02b0558621eb071485d33d46c8fce6474..3c119fcb2df6c00c5c4477a86d1f246a2e0f986a 100644 --- a/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugTrianglesRenderDelegate.cpp +++ b/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugTrianglesRenderDelegate.cpp @@ -32,10 +32,11 @@ namespace imstk { -VTKdbgTrianglesRenderDelegate::VTKdbgTrianglesRenderDelegate(const std::shared_ptr<DebugRenderTriangles>& renderTriangles) : - m_RenderGeoData(renderTriangles), +VTKdbgTrianglesRenderDelegate::VTKdbgTrianglesRenderDelegate(std::shared_ptr<VisualModel> visualModel) : m_pappedVertexArray(vtkSmartPointer<vtkDoubleArray>::New()) { + m_visualModel = visualModel; + // Map vertices in memory m_pappedVertexArray->SetNumberOfComponents(3); @@ -59,24 +60,26 @@ VTKdbgTrianglesRenderDelegate::VTKdbgTrianglesRenderDelegate(const std::shared_p //updateDataSource(); //updateActorProperties(); - setUpMapper(source->GetOutputPort(), true, m_RenderGeoData->getRenderMaterial()); + setUpMapper(source->GetOutputPort(), true, visualModel->getRenderMaterial()); } void VTKdbgTrianglesRenderDelegate::updateDataSource() { - if (m_RenderGeoData->isModified()) + auto dbgTriangles = std::static_pointer_cast<DebugRenderTriangles>(m_visualModel->getDebugGeometry()); + + if (dbgTriangles->isModified()) { - m_RenderGeoData->setDataModified(false); - m_pappedVertexArray->SetArray(m_RenderGeoData->getVertexBufferPtr(), - m_RenderGeoData->getNumVertices() * 3, 1); + dbgTriangles->setDataModified(false); + m_pappedVertexArray->SetArray(dbgTriangles->getVertexBufferPtr(), + dbgTriangles->getNumVertices() * 3, 1); // Set point data - m_points->SetNumberOfPoints(m_RenderGeoData->getNumVertices()); + m_points->SetNumberOfPoints(dbgTriangles->getNumVertices()); // Set tri data int numCurrentTriangles = m_cellArray->GetNumberOfCells(); - if (numCurrentTriangles > static_cast<int>(m_RenderGeoData->getNumVertices() / 3)) + if (numCurrentTriangles > static_cast<int>(dbgTriangles->getNumVertices() / 3)) { // There should is a better way to modify the existing data, // instead of discarding everything and add from the beginning @@ -85,7 +88,7 @@ VTKdbgTrianglesRenderDelegate::updateDataSource() } vtkIdType cell[3]; - for (int i = numCurrentTriangles; i < static_cast<int>(m_RenderGeoData->getNumVertices() / 3); ++i) + for (int i = numCurrentTriangles; i < static_cast<int>(dbgTriangles->getNumVertices() / 3); ++i) { cell[0] = 3 * i; cell[1] = cell[0] + 1; diff --git a/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugTrianglesRenderDelegate.h b/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugTrianglesRenderDelegate.h index 3e856dccdb533df2011854db9f8906df9fcaca14..f9ccf9afa8c288f74c1f34b36021ef78ae8c9d2d 100644 --- a/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugTrianglesRenderDelegate.h +++ b/Source/Rendering/VTKRenderer/RenderDelegate/imstkVTKdebugTrianglesRenderDelegate.h @@ -40,7 +40,7 @@ public: /// /// \brief Constructor /// - explicit VTKdbgTrianglesRenderDelegate(const std::shared_ptr<DebugRenderTriangles>& renderTriangles); + explicit VTKdbgTrianglesRenderDelegate(std::shared_ptr<VisualModel> visualModel); /// /// \brief Update polydata source based on the surface mesh geometry @@ -48,7 +48,6 @@ public: void updateDataSource() override; protected: - std::shared_ptr<DebugRenderTriangles> m_RenderGeoData; ///> Geometry to render // Auxiliary variables for rendering vtkSmartPointer<vtkDoubleArray> m_pappedVertexArray; diff --git a/Source/Rendering/VTKRenderer/imstkVTKRenderer.cpp b/Source/Rendering/VTKRenderer/imstkVTKRenderer.cpp index a42a33311abc15e16020dcdff5c2646ffb43c2bf..db43746cc558a623c94c020b31b8d96e43d3337d 100644 --- a/Source/Rendering/VTKRenderer/imstkVTKRenderer.cpp +++ b/Source/Rendering/VTKRenderer/imstkVTKRenderer.cpp @@ -408,11 +408,12 @@ VTKRenderer::updateRenderDelegates() } // Debug render actors - for (const auto& geom : m_scene->getDebugRenderObjects()) + for (const auto& dbgVizModel : m_scene->getDebugRenderModels()) { - if (geom && !geom->m_renderDelegateCreated) + auto geom = std::static_pointer_cast<DebugRenderGeometry>(dbgVizModel->getDebugGeometry()); + if (dbgVizModel && !dbgVizModel->isRenderDelegateCreated()) { - auto delegate = VTKRenderDelegate::makeDebugDelegate(geom); + auto delegate = VTKRenderDelegate::makeDebugDelegate(dbgVizModel); if (delegate == nullptr) { LOG(WARNING) << "Renderer::Renderer error: Could not create render delegate for '" @@ -423,7 +424,7 @@ VTKRenderer::updateRenderDelegates() m_debugRenderDelegates.push_back(delegate); m_objectVtkActors.push_back(delegate->getVtkActor()); m_vtkRenderer->AddActor(delegate->getVtkActor()); - geom->m_renderDelegateCreated = true; + dbgVizModel->m_renderDelegateCreated = true; } } diff --git a/Source/Scene/CMakeLists.txt b/Source/Scene/CMakeLists.txt index 65ad4d39adf23e366e071b6545bbf4c32133f1df..114253e60cc34d7e2dac0f43841a29db2d0920f5 100644 --- a/Source/Scene/CMakeLists.txt +++ b/Source/Scene/CMakeLists.txt @@ -3,18 +3,12 @@ #----------------------------------------------------------------------------- include(imstkAddLibrary) imstk_add_library( Scene - H_FILES - imstkScene.h - imstkCollisionGraph.h - CPP_FILES - imstkScene.cpp - imstkCollisionGraph.cpp DEPENDS Common - Collision - SceneElements + CollisionDetection + CollisionHandling + SceneEntities Controllers - DynamicalModels ) #----------------------------------------------------------------------------- diff --git a/Source/Collision/CollisionDetection/imstkCollisionDetection.cpp b/Source/Scene/imstkCDObjectFactory.h similarity index 70% rename from Source/Collision/CollisionDetection/imstkCollisionDetection.cpp rename to Source/Scene/imstkCDObjectFactory.h index ed492025909620e3e8a5b0896dc9c705f333c161..58cd39ec7e5ca13dfea5570a5e78cd16b556ad97 100644 --- a/Source/Collision/CollisionDetection/imstkCollisionDetection.cpp +++ b/Source/Scene/imstkCDObjectFactory.h @@ -19,9 +19,12 @@ =========================================================================*/ +#pragma once + #include "imstkCollisionDetection.h" #include "imstkCollisionData.h" #include "imstkOctreeBasedCD.h" +#include "imstkCollidingObject.h" // Points to objects #include "imstkPointSetToCapsuleCD.h" @@ -42,7 +45,6 @@ #include "imstkSphereToCylinderCD.h" #include "imstkSphereToSphereCD.h" -#include "imstkCollidingObject.h" #include "imstkPlane.h" #include "imstkSphere.h" #include "imstkCylinder.h" @@ -50,8 +52,6 @@ #include "imstkSurfaceMesh.h" #include "imstkTetrahedralMesh.h" -#include <g3log/g3log.hpp> - #define IMSTK_CHECK_FOR_VALID_GEOMETRIES(obj1, obj2) \ LOG_IF(FATAL, (obj1 == nullptr || obj2 == nullptr)) << \ "CollisionDetection::makeCollisionDetectionObject() error: " << \ @@ -60,30 +60,37 @@ namespace imstk { +/// +/// \brief Static factory for collision detection sub classes +/// If the collision pair is PointSet to SurfaceMesh, or SurfaceMesh to SurfaceMesh, +/// it will be added to an internal static octree for detecting collision +/// \todo Other collision pair may be considered to use octree too +/// +static std::shared_ptr<CollisionDetection> -CollisionDetection::makeCollisionDetectionObject(const Type type, - std::shared_ptr<CollidingObject> objA, - std::shared_ptr<CollidingObject> objB, - std::shared_ptr<CollisionData> colData) +makeCollisionDetectionObject(const CollisionDetection::Type type, + std::shared_ptr<CollidingObject> objA, + std::shared_ptr<CollidingObject> objB, + std::shared_ptr<CollisionData> colData) { switch (type) { // Points to objects - case Type::PointSetToSphere: + case CollisionDetection::Type::PointSetToSphere: { auto pointset = std::dynamic_pointer_cast<PointSet>(objA->getCollidingGeometry()); auto sphere = std::dynamic_pointer_cast<Sphere>(objB->getCollidingGeometry()); IMSTK_CHECK_FOR_VALID_GEOMETRIES(pointset, sphere) return std::make_shared<PointSetToSphereCD>(pointset, sphere, colData); } - case Type::PointSetToPlane: + case CollisionDetection::Type::PointSetToPlane: { auto pointset = std::dynamic_pointer_cast<PointSet>(objA->getCollidingGeometry()); auto plane = std::dynamic_pointer_cast<Plane>(objB->getCollidingGeometry()); IMSTK_CHECK_FOR_VALID_GEOMETRIES(pointset, plane) return std::make_shared<PointSetToPlaneCD>(pointset, plane, colData); } - case Type::PointSetToCapsule: + case CollisionDetection::Type::PointSetToCapsule: { auto pointset = std::dynamic_pointer_cast<PointSet>(objA->getCollidingGeometry()); auto capsule = std::dynamic_pointer_cast<Capsule>(objB->getCollidingGeometry()); @@ -91,7 +98,7 @@ CollisionDetection::makeCollisionDetectionObject(const Type return std::make_shared<PointSetToCapsuleCD>(pointset, capsule, colData); } #if 0 - case Type::PointSetToSpherePicking: + case CollisionDetection::ype::PointSetToSpherePicking: { auto pointset = std::dynamic_pointer_cast<PointSet>(objA->getCollidingGeometry()); auto sphere = std::dynamic_pointer_cast<Sphere>(objB->getCollidingGeometry()); @@ -99,28 +106,28 @@ CollisionDetection::makeCollisionDetectionObject(const Type return std::make_shared<PointSetToSpherePickingCD>(pointset, sphere, colData); } #endif - case Type::PointSetToSurfaceMesh: + case CollisionDetection::Type::PointSetToSurfaceMesh: { const auto& geomA = objA->getCollidingGeometry(); const auto& geomB = objB->getCollidingGeometry(); auto pointset = std::dynamic_pointer_cast<PointSet>(geomA); auto triMesh = std::dynamic_pointer_cast<SurfaceMesh>(geomB); IMSTK_CHECK_FOR_VALID_GEOMETRIES(pointset, triMesh) - addCollisionPairToOctree(geomA, geomB, type, colData); + CollisionDetection::addCollisionPairToOctree(geomA, geomB, type, colData); return std::make_shared<PointSetToSurfaceMeshCD>(pointset, triMesh, colData); } // Mesh to mesh - case Type::SurfaceMeshToSurfaceMesh: + case CollisionDetection::Type::SurfaceMeshToSurfaceMesh: { const auto& geomA = objA->getCollidingGeometry(); const auto& geomB = objB->getCollidingGeometry(); auto meshA = std::dynamic_pointer_cast<SurfaceMesh>(geomA); auto meshB = std::dynamic_pointer_cast<SurfaceMesh>(geomB); IMSTK_CHECK_FOR_VALID_GEOMETRIES(meshA, meshB) - addCollisionPairToOctree(geomA, geomB, type, colData); + CollisionDetection::addCollisionPairToOctree(geomA, geomB, type, colData); return std::make_shared<SurfaceMeshToSurfaceMeshCD>(meshA, meshB, colData); } - case Type::SurfaceMeshToSurfaceMeshCCD: + case CollisionDetection::Type::SurfaceMeshToSurfaceMeshCCD: { auto meshA = std::dynamic_pointer_cast<SurfaceMesh>(objA->getCollidingGeometry()); auto meshB = std::dynamic_pointer_cast<SurfaceMesh>(objB->getCollidingGeometry()); @@ -128,7 +135,7 @@ CollisionDetection::makeCollisionDetectionObject(const Type return std::make_shared<SurfaceMeshToSurfaceMeshCCD>(meshA, meshB, colData); } - case Type::VolumeMeshToVolumeMesh: + case CollisionDetection::Type::VolumeMeshToVolumeMesh: { auto tet1 = std::dynamic_pointer_cast<TetrahedralMesh>(objA->getCollidingGeometry()); auto tet2 = std::dynamic_pointer_cast<TetrahedralMesh>(objB->getCollidingGeometry()); @@ -137,35 +144,35 @@ CollisionDetection::makeCollisionDetectionObject(const Type } // Analytical object to analytical object - case Type::UnidirectionalPlaneToSphere: + case CollisionDetection::Type::UnidirectionalPlaneToSphere: { auto plane = std::dynamic_pointer_cast<Plane>(objA->getCollidingGeometry()); auto sphere = std::dynamic_pointer_cast<Sphere>(objB->getCollidingGeometry()); IMSTK_CHECK_FOR_VALID_GEOMETRIES(plane, sphere) return std::make_shared<UnidirectionalPlaneToSphereCD>(plane, sphere, colData); } - case Type::BidirectionalPlaneToSphere: + case CollisionDetection::Type::BidirectionalPlaneToSphere: { auto plane = std::dynamic_pointer_cast<Plane>(objA->getCollidingGeometry()); auto sphere = std::dynamic_pointer_cast<Sphere>(objB->getCollidingGeometry()); IMSTK_CHECK_FOR_VALID_GEOMETRIES(plane, sphere) return std::make_shared<BidirectionalPlaneToSphereCD>(plane, sphere, colData); } - case Type::SphereToSphere: + case CollisionDetection::Type::SphereToSphere: { auto sphereA = std::dynamic_pointer_cast<Sphere>(objA->getCollidingGeometry()); auto sphereB = std::dynamic_pointer_cast<Sphere>(objB->getCollidingGeometry()); IMSTK_CHECK_FOR_VALID_GEOMETRIES(sphereA, sphereB) return std::make_shared<SphereToSphereCD>(sphereA, sphereB, colData); } - case Type::SphereToCylinder: + case CollisionDetection::Type::SphereToCylinder: { auto sphere = std::dynamic_pointer_cast<Sphere>(objB->getCollidingGeometry()); auto cylinder = std::dynamic_pointer_cast<Cylinder>(objA->getCollidingGeometry()); IMSTK_CHECK_FOR_VALID_GEOMETRIES(sphere, cylinder) return std::make_shared<SphereToCylinderCD>(sphere, cylinder, colData); } - case Type::MeshToMeshBruteForce: + case CollisionDetection::Type::MeshToMeshBruteForce: { auto meshA = std::dynamic_pointer_cast<SurfaceMesh>(objA->getCollidingGeometry()); auto meshB = std::dynamic_pointer_cast<SurfaceMesh>(objB->getCollidingGeometry()); @@ -174,64 +181,9 @@ CollisionDetection::makeCollisionDetectionObject(const Type } default: { - LOG(FATAL) << "CollisionDetection::makeCollisionDetectionObject error: type not implemented."; + LOG(FATAL) << "makeCollisionDetectionObject error: type not implemented."; return nullptr; } } } - -CollisionDetection::CollisionDetection(const CollisionDetection::Type& type, std::shared_ptr<CollisionData> colData) : m_type(type), - m_colData((colData == nullptr) ? std::make_shared<CollisionData>() : colData) -{ -} - -// Static functions ==> -void -CollisionDetection::addCollisionPairToOctree(const std::shared_ptr<Geometry>& geomA, - const std::shared_ptr<Geometry>& geomB, - const Type collisionType, - const std::shared_ptr<CollisionData>& collisionData) -{ - auto addToOctree = - [&](const std::shared_ptr<Geometry>& geom) { - if (!s_OctreeCD->hasGeometry(geom->getGlobalIndex())) - { - if (geom->getType() == Geometry::Type::PointSet) - { - s_OctreeCD->addPointSet(std::dynamic_pointer_cast<PointSet>(geom)); - } - else if (geom->getType() == Geometry::Type::SurfaceMesh) - { - s_OctreeCD->addTriangleMesh(std::dynamic_pointer_cast<SurfaceMesh>(geom)); - } - else - { - s_OctreeCD->addAnalyticalGeometry(geom); - } - } - }; - - addToOctree(geomA); - addToOctree(geomB); - s_OctreeCD->addCollisionPair(geomA, geomB, collisionType, collisionData); -} - -void -CollisionDetection::updateInternalOctreeAndDetectCollision() -{ - if (s_OctreeCD->getNumCollisionPairs() > 0) - { - s_OctreeCD->update(); - s_OctreeCD->detectCollision(); - } -} - -void -CollisionDetection::clearInternalOctree() -{ - s_OctreeCD->clear(); -} - -// Static octree -std::shared_ptr<OctreeBasedCD> CollisionDetection::s_OctreeCD = std::make_shared<OctreeBasedCD>(Vec3d(0, 0, 0), 100.0, 0.1, 1); } diff --git a/Source/Collision/imstkInteractionPair.cpp b/Source/Scene/imstkInteractionPair.cpp similarity index 97% rename from Source/Collision/imstkInteractionPair.cpp rename to Source/Scene/imstkInteractionPair.cpp index 17d1542a952d59bbd6448ee1243c13e9d63b7e88..b82844816017604575d2bcd9395569084e136e67 100644 --- a/Source/Collision/imstkInteractionPair.cpp +++ b/Source/Scene/imstkInteractionPair.cpp @@ -22,6 +22,7 @@ #include "imstkInteractionPair.h" #include "imstkCollisionData.h" #include "imstkCollidingObject.h" +#include "imstkCDObjectFactory.h" #include <g3log/g3log.hpp> @@ -46,7 +47,7 @@ InteractionPair::InteractionPair(std::shared_ptr<CollidingObject> A, }*/ // Collision Detection - std::shared_ptr<CollisionDetection> CD = CollisionDetection::makeCollisionDetectionObject(CDType, A, B, m_colData); + std::shared_ptr<CollisionDetection> CD = makeCollisionDetectionObject(CDType, A, B, m_colData); CHECK(CD != nullptr) << "InteractionPair error: can not instantiate collision detection algorithm."; diff --git a/Source/Collision/imstkInteractionPair.h b/Source/Scene/imstkInteractionPair.h similarity index 100% rename from Source/Collision/imstkInteractionPair.h rename to Source/Scene/imstkInteractionPair.h diff --git a/Source/Collision/imstkPbdInteractionPair.cpp b/Source/Scene/imstkPbdInteractionPair.cpp similarity index 99% rename from Source/Collision/imstkPbdInteractionPair.cpp rename to Source/Scene/imstkPbdInteractionPair.cpp index e82b0fbd1c3b8ef5ea9f4ba14babff0e2da88349..ddfa7243d7fb0dc25e1df9273c9ae4756d1981b5 100644 --- a/Source/Collision/imstkPbdInteractionPair.cpp +++ b/Source/Scene/imstkPbdInteractionPair.cpp @@ -26,7 +26,7 @@ #include "imstkCollisionUtils.h" #include "imstkPbdModel.h" #include "imstkPbdObject.h" -#include "imstkColor.h" +//#include "imstkColor.h" #include "imstkPbdEdgeEdgeCollisionConstraint.h" #include "imstkPbdPointTriCollisionConstraint.h" diff --git a/Source/Collision/imstkPbdInteractionPair.h b/Source/Scene/imstkPbdInteractionPair.h similarity index 100% rename from Source/Collision/imstkPbdInteractionPair.h rename to Source/Scene/imstkPbdInteractionPair.h diff --git a/Source/Scene/imstkScene.cpp b/Source/Scene/imstkScene.cpp index 2cafd96ba16d14780a8db4af98f3a3da11f8a1d9..4409293f4133b3f07c2a55c074c8771ff5209b0e 100644 --- a/Source/Scene/imstkScene.cpp +++ b/Source/Scene/imstkScene.cpp @@ -21,6 +21,7 @@ #include "imstkScene.h" #include "imstkSceneObject.h" +#include "imstkVisualModel.h" #include "imstkCameraController.h" #include "imstkSceneObjectControllerBase.h" #include "imstkCameraController.h" @@ -126,11 +127,9 @@ Scene::getSceneObjects() const { std::vector<std::shared_ptr<SceneObject>> v; - for (auto it = m_sceneObjectsMap.begin(); - it != m_sceneObjectsMap.end(); - ++it) + for (auto it : m_sceneObjectsMap) { - v.push_back(it->second); + v.push_back(it.second); } return v; @@ -152,16 +151,14 @@ Scene::getSceneObject(const std::string& sceneObjectName) const return m_sceneObjectsMap.at(sceneObjectName); } -const std::vector<std::shared_ptr<DebugRenderGeometry>> -Scene::getDebugRenderObjects() const +const std::vector<std::shared_ptr<VisualModel>> +Scene::getDebugRenderModels() const { - std::vector<std::shared_ptr<DebugRenderGeometry>> v; + std::vector<std::shared_ptr<VisualModel>> v; - for (auto it = m_DebugRenderGeometryMap.begin(); - it != m_DebugRenderGeometryMap.end(); - ++it) + for (auto it : m_DebugRenderModelMap) { - v.push_back(it->second); + v.push_back(it.second); } return v; @@ -184,19 +181,19 @@ Scene::addSceneObject(std::shared_ptr<SceneObject> newSceneObject) } void -Scene::addDebugGeometry(std::shared_ptr<DebugRenderGeometry> newDebugRenderObject) +Scene::addDebugVisualModel(std::shared_ptr<VisualModel> dbgRenderModel) { - std::string name = newDebugRenderObject->getName(); + const std::string name = dbgRenderModel->getDebugGeometry()->getName(); - if (m_sceneObjectsMap.find(name) != m_sceneObjectsMap.end()) + if (m_DebugRenderModelMap.find(name) != m_DebugRenderModelMap.end()) { - LOG(WARNING) << "Can not add debug render object: '" << name + LOG(WARNING) << "Can not add debug render mdoel: '" << name << "' is already registered in this scene."; return; } - m_DebugRenderGeometryMap[name] = newDebugRenderObject; - LOG(INFO) << name << " object added to " << m_name; + m_DebugRenderModelMap[name] = dbgRenderModel; + LOG(INFO) << name << " debug model added to " << m_name; } void diff --git a/Source/Scene/imstkScene.h b/Source/Scene/imstkScene.h index d6c998baaddac9d6e38750e600d7ebde8cb1dfaf..b367f41caf415d267c1a56447c4755a104060697 100644 --- a/Source/Scene/imstkScene.h +++ b/Source/Scene/imstkScene.h @@ -29,6 +29,7 @@ namespace imstk { class SceneObjectControllerBase; +class VisualModel; class CameraController; class DebugRenderGeometry; class SceneObject; @@ -124,7 +125,7 @@ public: /// \brief Return a vector of shared pointers to the scene objects /// NOTE: A separate list might be efficient as this is called runtime /// - const std::vector<std::shared_ptr<DebugRenderGeometry>> getDebugRenderObjects() const; + const std::vector<std::shared_ptr<VisualModel>> getDebugRenderModels() const; /// /// \brief Get the scene object controllers @@ -140,9 +141,13 @@ public: /// \brief Add/remove a scene object /// void addSceneObject(std::shared_ptr<SceneObject> newSceneObject); - void addDebugGeometry(std::shared_ptr<DebugRenderGeometry> newSceneObject); void removeSceneObject(const std::string& sceneObjectName); + /// + /// \brief Add a debug visual model object + /// + void addDebugVisualModel(std::shared_ptr<VisualModel> dbgRenderModel); + /// /// \brief /// @@ -231,9 +236,9 @@ protected: std::shared_ptr<SceneConfig> m_config; std::string m_name; ///> Name of the scene - NamedMap<SceneObject> m_sceneObjectsMap; - NamedMap<DebugRenderGeometry> m_DebugRenderGeometryMap; - NamedMap<Light> m_lightsMap; + NamedMap<SceneObject> m_sceneObjectsMap; + NamedMap<VisualModel> m_DebugRenderModelMap; + NamedMap<Light> m_lightsMap; std::shared_ptr<IBLProbe> m_globalIBLProbe = nullptr; std::shared_ptr<Camera> m_camera = nullptr; std::shared_ptr<CollisionGraph> m_collisionGraph = nullptr; diff --git a/Source/Scene/SceneElements/CMakeLists.txt b/Source/SceneEntities/CMakeLists.txt similarity index 84% rename from Source/Scene/SceneElements/CMakeLists.txt rename to Source/SceneEntities/CMakeLists.txt index 83181b2d4d1459fda599424b815f4fc102acff94..e17ebff50371bb55c64312c1a7dc53ea298eb6ea 100644 --- a/Source/Scene/SceneElements/CMakeLists.txt +++ b/Source/SceneEntities/CMakeLists.txt @@ -2,11 +2,13 @@ # Create target #----------------------------------------------------------------------------- include(imstkAddLibrary) -imstk_add_library( SceneElements - DEPENDS +imstk_add_library( SceneEntities + DEPENDS Common Geometry - DataStructures + GeometryMappers + Materials + MeshIO Constraints Devices DynamicalModels diff --git a/Source/Scene/SceneElements/Camera/imstkCamera.cpp b/Source/SceneEntities/Camera/imstkCamera.cpp similarity index 100% rename from Source/Scene/SceneElements/Camera/imstkCamera.cpp rename to Source/SceneEntities/Camera/imstkCamera.cpp diff --git a/Source/Scene/SceneElements/Camera/imstkCamera.h b/Source/SceneEntities/Camera/imstkCamera.h similarity index 100% rename from Source/Scene/SceneElements/Camera/imstkCamera.h rename to Source/SceneEntities/Camera/imstkCamera.h diff --git a/Source/Scene/SceneElements/Lights/imstkIBLProbe.cpp b/Source/SceneEntities/Lights/imstkIBLProbe.cpp similarity index 100% rename from Source/Scene/SceneElements/Lights/imstkIBLProbe.cpp rename to Source/SceneEntities/Lights/imstkIBLProbe.cpp diff --git a/Source/Scene/SceneElements/Lights/imstkIBLProbe.h b/Source/SceneEntities/Lights/imstkIBLProbe.h similarity index 100% rename from Source/Scene/SceneElements/Lights/imstkIBLProbe.h rename to Source/SceneEntities/Lights/imstkIBLProbe.h diff --git a/Source/Scene/SceneElements/Lights/imstkLight.cpp b/Source/SceneEntities/Lights/imstkLight.cpp similarity index 100% rename from Source/Scene/SceneElements/Lights/imstkLight.cpp rename to Source/SceneEntities/Lights/imstkLight.cpp diff --git a/Source/Scene/SceneElements/Lights/imstkLight.h b/Source/SceneEntities/Lights/imstkLight.h similarity index 100% rename from Source/Scene/SceneElements/Lights/imstkLight.h rename to Source/SceneEntities/Lights/imstkLight.h diff --git a/Source/Scene/SceneElements/Loader/imstkVisualObjectImporter.cpp b/Source/SceneEntities/Loader/imstkVisualObjectImporter.cpp similarity index 100% rename from Source/Scene/SceneElements/Loader/imstkVisualObjectImporter.cpp rename to Source/SceneEntities/Loader/imstkVisualObjectImporter.cpp diff --git a/Source/Scene/SceneElements/Loader/imstkVisualObjectImporter.h b/Source/SceneEntities/Loader/imstkVisualObjectImporter.h similarity index 100% rename from Source/Scene/SceneElements/Loader/imstkVisualObjectImporter.h rename to Source/SceneEntities/Loader/imstkVisualObjectImporter.h diff --git a/Source/Scene/SceneElements/Objects/deprecated/imstkPbdRigidObject.cpp b/Source/SceneEntities/Objects/deprecated/imstkPbdRigidObject.cpp similarity index 100% rename from Source/Scene/SceneElements/Objects/deprecated/imstkPbdRigidObject.cpp rename to Source/SceneEntities/Objects/deprecated/imstkPbdRigidObject.cpp diff --git a/Source/Scene/SceneElements/Objects/deprecated/imstkPbdRigidObject.h b/Source/SceneEntities/Objects/deprecated/imstkPbdRigidObject.h similarity index 100% rename from Source/Scene/SceneElements/Objects/deprecated/imstkPbdRigidObject.h rename to Source/SceneEntities/Objects/deprecated/imstkPbdRigidObject.h diff --git a/Source/Scene/SceneElements/Objects/imstkAnimationModel.cpp b/Source/SceneEntities/Objects/imstkAnimationModel.cpp similarity index 100% rename from Source/Scene/SceneElements/Objects/imstkAnimationModel.cpp rename to Source/SceneEntities/Objects/imstkAnimationModel.cpp diff --git a/Source/Scene/SceneElements/Objects/imstkAnimationModel.h b/Source/SceneEntities/Objects/imstkAnimationModel.h similarity index 100% rename from Source/Scene/SceneElements/Objects/imstkAnimationModel.h rename to Source/SceneEntities/Objects/imstkAnimationModel.h diff --git a/Source/Scene/SceneElements/Objects/imstkAnimationObject.cpp b/Source/SceneEntities/Objects/imstkAnimationObject.cpp similarity index 100% rename from Source/Scene/SceneElements/Objects/imstkAnimationObject.cpp rename to Source/SceneEntities/Objects/imstkAnimationObject.cpp diff --git a/Source/Scene/SceneElements/Objects/imstkAnimationObject.h b/Source/SceneEntities/Objects/imstkAnimationObject.h similarity index 100% rename from Source/Scene/SceneElements/Objects/imstkAnimationObject.h rename to Source/SceneEntities/Objects/imstkAnimationObject.h diff --git a/Source/Scene/SceneElements/Objects/imstkCollidingObject.cpp b/Source/SceneEntities/Objects/imstkCollidingObject.cpp similarity index 100% rename from Source/Scene/SceneElements/Objects/imstkCollidingObject.cpp rename to Source/SceneEntities/Objects/imstkCollidingObject.cpp diff --git a/Source/Scene/SceneElements/Objects/imstkCollidingObject.h b/Source/SceneEntities/Objects/imstkCollidingObject.h similarity index 100% rename from Source/Scene/SceneElements/Objects/imstkCollidingObject.h rename to Source/SceneEntities/Objects/imstkCollidingObject.h diff --git a/Source/Scene/SceneElements/Objects/imstkDeformableObject.cpp b/Source/SceneEntities/Objects/imstkDeformableObject.cpp similarity index 100% rename from Source/Scene/SceneElements/Objects/imstkDeformableObject.cpp rename to Source/SceneEntities/Objects/imstkDeformableObject.cpp diff --git a/Source/Scene/SceneElements/Objects/imstkDeformableObject.h b/Source/SceneEntities/Objects/imstkDeformableObject.h similarity index 100% rename from Source/Scene/SceneElements/Objects/imstkDeformableObject.h rename to Source/SceneEntities/Objects/imstkDeformableObject.h diff --git a/Source/Scene/SceneElements/Objects/imstkDynamicObject.cpp b/Source/SceneEntities/Objects/imstkDynamicObject.cpp similarity index 100% rename from Source/Scene/SceneElements/Objects/imstkDynamicObject.cpp rename to Source/SceneEntities/Objects/imstkDynamicObject.cpp diff --git a/Source/Scene/SceneElements/Objects/imstkDynamicObject.h b/Source/SceneEntities/Objects/imstkDynamicObject.h similarity index 100% rename from Source/Scene/SceneElements/Objects/imstkDynamicObject.h rename to Source/SceneEntities/Objects/imstkDynamicObject.h diff --git a/Source/Scene/SceneElements/Objects/imstkKinematicState.cpp b/Source/SceneEntities/Objects/imstkKinematicState.cpp similarity index 100% rename from Source/Scene/SceneElements/Objects/imstkKinematicState.cpp rename to Source/SceneEntities/Objects/imstkKinematicState.cpp diff --git a/Source/Scene/SceneElements/Objects/imstkPbdObject.cpp b/Source/SceneEntities/Objects/imstkPbdObject.cpp similarity index 100% rename from Source/Scene/SceneElements/Objects/imstkPbdObject.cpp rename to Source/SceneEntities/Objects/imstkPbdObject.cpp diff --git a/Source/Scene/SceneElements/Objects/imstkPbdObject.h b/Source/SceneEntities/Objects/imstkPbdObject.h similarity index 100% rename from Source/Scene/SceneElements/Objects/imstkPbdObject.h rename to Source/SceneEntities/Objects/imstkPbdObject.h diff --git a/Source/Scene/SceneElements/Objects/imstkRigidObject.cpp b/Source/SceneEntities/Objects/imstkRigidObject.cpp similarity index 100% rename from Source/Scene/SceneElements/Objects/imstkRigidObject.cpp rename to Source/SceneEntities/Objects/imstkRigidObject.cpp diff --git a/Source/Scene/SceneElements/Objects/imstkRigidObject.h b/Source/SceneEntities/Objects/imstkRigidObject.h similarity index 100% rename from Source/Scene/SceneElements/Objects/imstkRigidObject.h rename to Source/SceneEntities/Objects/imstkRigidObject.h diff --git a/Source/Scene/SceneElements/Objects/imstkSPHObject.cpp b/Source/SceneEntities/Objects/imstkSPHObject.cpp similarity index 100% rename from Source/Scene/SceneElements/Objects/imstkSPHObject.cpp rename to Source/SceneEntities/Objects/imstkSPHObject.cpp diff --git a/Source/Scene/SceneElements/Objects/imstkSPHObject.h b/Source/SceneEntities/Objects/imstkSPHObject.h similarity index 100% rename from Source/Scene/SceneElements/Objects/imstkSPHObject.h rename to Source/SceneEntities/Objects/imstkSPHObject.h diff --git a/Source/Scene/SceneElements/Objects/imstkSceneObject.cpp b/Source/SceneEntities/Objects/imstkSceneObject.cpp similarity index 100% rename from Source/Scene/SceneElements/Objects/imstkSceneObject.cpp rename to Source/SceneEntities/Objects/imstkSceneObject.cpp diff --git a/Source/Scene/SceneElements/Objects/imstkSceneObject.h b/Source/SceneEntities/Objects/imstkSceneObject.h similarity index 100% rename from Source/Scene/SceneElements/Objects/imstkSceneObject.h rename to Source/SceneEntities/Objects/imstkSceneObject.h diff --git a/Source/Scene/SceneElements/Objects/imstkVisualModel.cpp b/Source/SceneEntities/Objects/imstkVisualModel.cpp similarity index 67% rename from Source/Scene/SceneElements/Objects/imstkVisualModel.cpp rename to Source/SceneEntities/Objects/imstkVisualModel.cpp index 460743e8d1bc1417cdf8e2e66ec159dffcbb8bd9..9ec3c859847206d902339a212c9002ada003887b 100644 --- a/Source/Scene/SceneElements/Objects/imstkVisualModel.cpp +++ b/Source/SceneEntities/Objects/imstkVisualModel.cpp @@ -22,6 +22,7 @@ #include "imstkVisualModel.h" #include "imstkGeometry.h" #include "imstkRenderMaterial.h" +#include "imstkDebugRenderGeometry.h" namespace imstk { @@ -29,6 +30,24 @@ VisualModel::VisualModel(std::shared_ptr<Geometry> geometry) : m_geometry(geomet { } +VisualModel::VisualModel(std::shared_ptr<Geometry> geometry, + std::shared_ptr<RenderMaterial> renderMaterial) : + m_geometry(geometry), + m_renderMaterial(renderMaterial) +{ +} + +VisualModel::VisualModel(std::shared_ptr<DebugRenderGeometry> geometry) : m_DbgGeometry(geometry), m_renderMaterial(std::make_shared<RenderMaterial>()) +{ +} + +VisualModel::VisualModel(std::shared_ptr<DebugRenderGeometry> geometry, + std::shared_ptr<RenderMaterial> renderMaterial) : + m_DbgGeometry(geometry), + m_renderMaterial(renderMaterial) +{ +} + std::shared_ptr<Geometry> VisualModel::getGeometry() { @@ -41,6 +60,18 @@ VisualModel::setGeometry(std::shared_ptr<Geometry> geometry) m_geometry = geometry; } +std::shared_ptr<DebugRenderGeometry> +VisualModel::getDebugGeometry() +{ + return m_DbgGeometry; +} + +void +VisualModel::setDebugGeometry(std::shared_ptr<DebugRenderGeometry> dbgGeometry) +{ + m_DbgGeometry = dbgGeometry; +} + void VisualModel::setRenderMaterial(std::shared_ptr<RenderMaterial> renderMaterial) { diff --git a/Source/Scene/SceneElements/Objects/imstkVisualModel.h b/Source/SceneEntities/Objects/imstkVisualModel.h similarity index 72% rename from Source/Scene/SceneElements/Objects/imstkVisualModel.h rename to Source/SceneEntities/Objects/imstkVisualModel.h index 3b14f4824362b4d406e5e10ceeb077e9b1806801..f087e757ddd17f82c0f9d556108b4568805706c9 100644 --- a/Source/Scene/SceneElements/Objects/imstkVisualModel.h +++ b/Source/SceneEntities/Objects/imstkVisualModel.h @@ -27,6 +27,7 @@ namespace imstk { class Geometry; class RenderMaterial; +class DebugRenderGeometry; /// /// \class VisualModel /// @@ -39,6 +40,11 @@ public: /// \brief Constructor /// explicit VisualModel(std::shared_ptr<Geometry> geometry); + explicit VisualModel(std::shared_ptr<Geometry> geometry, + std::shared_ptr<RenderMaterial> renderMaterial); + explicit VisualModel(std::shared_ptr<DebugRenderGeometry> geometry); + explicit VisualModel(std::shared_ptr<DebugRenderGeometry> geometry, + std::shared_ptr<RenderMaterial> renderMaterial); VisualModel() = delete; @@ -48,6 +54,12 @@ public: std::shared_ptr<Geometry> getGeometry(); void setGeometry(std::shared_ptr<Geometry> geometry); + /// + /// \brief Get/set geometry + /// + std::shared_ptr<DebugRenderGeometry> getDebugGeometry(); + void setDebugGeometry(std::shared_ptr<DebugRenderGeometry> geometry); + /// /// \brief Set/Get render material /// @@ -67,8 +79,9 @@ protected: friend class VulkanRenderDelegate; friend class VTKRenderer; - std::shared_ptr<Geometry> m_geometry = nullptr; - std::shared_ptr<RenderMaterial> m_renderMaterial; + std::shared_ptr<Geometry> m_geometry = nullptr; + std::shared_ptr<DebugRenderGeometry> m_DbgGeometry = nullptr; + std::shared_ptr<RenderMaterial> m_renderMaterial; bool m_isVisible = true; ///< true if mesh is shown, false if mesh is hidden bool m_renderDelegateCreated = false; ///< true if RenderDelegate has been created diff --git a/Source/Scene/SceneElements/imstkSceneEntity.cpp b/Source/SceneEntities/imstkSceneEntity.cpp similarity index 100% rename from Source/Scene/SceneElements/imstkSceneEntity.cpp rename to Source/SceneEntities/imstkSceneEntity.cpp diff --git a/Source/Scene/SceneElements/imstkSceneEntity.h b/Source/SceneEntities/imstkSceneEntity.h similarity index 100% rename from Source/Scene/SceneElements/imstkSceneEntity.h rename to Source/SceneEntities/imstkSceneEntity.h diff --git a/Source/SimulationManager/CMakeLists.txt b/Source/SimulationManager/CMakeLists.txt index e48395893cc32ab22d162f028f6abd859a991d5d..446ecf2392c6ae2c918a6c4337904169e7dbf542 100644 --- a/Source/SimulationManager/CMakeLists.txt +++ b/Source/SimulationManager/CMakeLists.txt @@ -61,8 +61,8 @@ imstk_add_library( SimulationManager SUBDIR_LIST ${SIMULATIONMANAGER_SUBDIR} DEPENDS + Scene Rendering - Controllers ${Vulkan} ) diff --git a/Source/SimulationManager/imstkSimulationManager.cpp b/Source/SimulationManager/imstkSimulationManager.cpp index 03dc71088d5863cab20b5f699565cddc91e33f14..a6b72f5cd23717e526fa4c3bcea612ce09516338 100644 --- a/Source/SimulationManager/imstkSimulationManager.cpp +++ b/Source/SimulationManager/imstkSimulationManager.cpp @@ -35,7 +35,7 @@ namespace imstk { -SimulationManager::SimulationManager(const std::shared_ptr<simManagerConfig> config) : m_config(config) +SimulationManager::SimulationManager(const std::shared_ptr<SimManagerConfig> config) : m_config(config) { // Initialize the logger and add optional sinks if (config->enableFileLogging) diff --git a/Source/SimulationManager/imstkSimulationManager.h b/Source/SimulationManager/imstkSimulationManager.h index 437681ae027bdd51cd0c78fb1413786fed147959..ba3f080b833bb96ae7ea7f273a272e4bea3c3e89 100644 --- a/Source/SimulationManager/imstkSimulationManager.h +++ b/Source/SimulationManager/imstkSimulationManager.h @@ -69,7 +69,7 @@ enum class SimulationMode /// /// \brief Simulation manager configuration /// -struct simManagerConfig +struct SimManagerConfig { // logger bool enableFileLogging = true; @@ -105,7 +105,7 @@ public: /// /// \brief Constructor /// - SimulationManager(const std::shared_ptr<simManagerConfig> config = std::make_shared<simManagerConfig>()); + SimulationManager(const std::shared_ptr<SimManagerConfig> config = std::make_shared<SimManagerConfig>()); /// /// \brief Default destructor @@ -335,7 +335,7 @@ private: bool m_simulationStarted = false; bool m_initialized = false; - std::shared_ptr<simManagerConfig> m_config; + std::shared_ptr<SimManagerConfig> m_config; std::mutex m_mutex; }; diff --git a/Source/Solvers/CMakeLists.txt b/Source/Solvers/CMakeLists.txt index f089a85cfa58df2993c91adb3a0dcd46fef2769e..14b17c8a3dd2ecff8eb109f6dc8d1c4efdcd8a50 100644 --- a/Source/Solvers/CMakeLists.txt +++ b/Source/Solvers/CMakeLists.txt @@ -4,10 +4,8 @@ include(imstkAddLibrary) imstk_add_library( Solvers DEPENDS - Common - DataStructures Constraints - SceneElements + SceneEntities ) #-----------------------------------------------------------------------------