diff --git a/Examples/DeformableBody/DeformableBodyExample.cpp b/Examples/DeformableBody/DeformableBodyExample.cpp index 79a176a6d80776f7f3a823f4577a340c5909fb1c..63d3e634e886d96088840529e59886f053290e7c 100644 --- a/Examples/DeformableBody/DeformableBodyExample.cpp +++ b/Examples/DeformableBody/DeformableBodyExample.cpp @@ -37,9 +37,14 @@ #include "imstkFEMDeformableBodyModel.h" #include "imstkSurfaceMesh.h" #include "imstkScene.h" +#include <memory> using namespace imstk; +std::shared_ptr<DynamicObject> createAndAddFEDeformable(std::shared_ptr<Scene> scene, std::shared_ptr<PointSet> tetMesh); + +const std::string meshFileName = iMSTK_DATA_ROOT "/asianDragon/asianDragon.veg"; + /// /// \brief This example demonstrates the soft body simulation /// using Finite elements @@ -55,25 +60,48 @@ main() scene->getCamera()->setPosition(0, 2.0, 15.0); // Load a tetrahedral mesh - auto tetMesh = MeshIO::read(iMSTK_DATA_ROOT "/asianDragon/asianDragon.veg"); + auto tetMesh = MeshIO::read(meshFileName); CHECK(tetMesh != nullptr) << "Could not read mesh from file."; - // Extract the surface mesh - auto surfMesh = std::make_shared<SurfaceMesh>(); - auto volTetMesh = std::dynamic_pointer_cast<TetrahedralMesh>(tetMesh); + // Scene object 1: fe-FeDeformableObject + auto deformableObj = createAndAddFEDeformable(scene, tetMesh); + auto dynaModel = std::dynamic_pointer_cast<FEMDeformableBodyModel>(deformableObj->getDynamicalModel()); - CHECK(volTetMesh != nullptr) << "Dynamic pointer cast from PointSet to TetrahedralMesh failed!"; + // Scene object 2: Plane + auto planeGeom = std::make_shared<Plane>(); + planeGeom->setWidth(40); + planeGeom->setPosition(0, -6, 0); + auto planeObj = std::make_shared<CollidingObject>("Plane"); + planeObj->setVisualGeometry(planeGeom); + planeObj->setCollidingGeometry(planeGeom); + scene->addSceneObject(planeObj); - volTetMesh->extractSurfaceMesh(surfMesh, true); + // Light + auto light = std::make_shared<DirectionalLight>("light"); + light->setFocalPoint(Vec3d(5, -8, -5)); + light->setIntensity(1); + scene->addLight(light); - // Construct one to one nodal map based on the above meshes - auto oneToOneNodalMap = std::make_shared<OneToOneMap>(tetMesh, surfMesh); + // Run the simulation + simManager->setActiveScene(scene); + simManager->start(SimulationStatus::Paused); + + return 0; +} + +std::shared_ptr<DynamicObject> +createAndAddFEDeformable(std::shared_ptr<Scene> scene, + std::shared_ptr<PointSet> tetMesh) +{ + auto volTetMesh = std::dynamic_pointer_cast<TetrahedralMesh>(tetMesh); + CHECK(volTetMesh != nullptr) << "Dynamic pointer cast from PointSet to TetrahedralMesh failed!"; + auto surfMesh = std::make_shared<SurfaceMesh>(); + volTetMesh->extractSurfaceMesh(surfMesh, true); // Configure dynamic model auto dynaModel = std::make_shared<FEMDeformableBodyModel>(); - - auto config = std::make_shared<FEMModelConfig>(); + auto config = std::make_shared<FEMModelConfig>(); config->m_fixedNodeIds = { 50, 126, 177 }; dynaModel->configure(config); //dynaModel->configure(iMSTK_DATA_ROOT "/asianDragon/asianDragon.config"); @@ -94,29 +122,14 @@ main() // Scene object 1: Dragon auto deformableObj = std::make_shared<FeDeformableObject>("Dragon"); deformableObj->addVisualModel(surfMeshModel); + deformableObj->setPhysicsGeometry(volTetMesh); + + // Construct one to one nodal map based on the above meshes + auto oneToOneNodalMap = std::make_shared<OneToOneMap>(tetMesh, surfMesh); deformableObj->setPhysicsToVisualMap(oneToOneNodalMap); //assign the computed map deformableObj->setDynamicalModel(dynaModel); scene->addSceneObject(deformableObj); - // Scene object 2: Plane - auto planeGeom = std::make_shared<Plane>(); - planeGeom->setWidth(40); - planeGeom->setPosition(0, -6, 0); - auto planeObj = std::make_shared<CollidingObject>("Plane"); - planeObj->setVisualGeometry(planeGeom); - planeObj->setCollidingGeometry(planeGeom); - scene->addSceneObject(planeObj); - - // Light - auto light = std::make_shared<DirectionalLight>("light"); - light->setFocalPoint(Vec3d(5, -8, -5)); - light->setIntensity(1); - scene->addLight(light); - - // Run the simulation - simManager->setActiveScene(scene); - simManager->start(SimulationStatus::Paused); - - return 0; + return deformableObj; } diff --git a/Examples/LineMesh/CMakeLists.txt b/Examples/LineMesh/CMakeLists.txt deleted file mode 100644 index 03e15e02d19586547c1fcc736c2f956f0983fd15..0000000000000000000000000000000000000000 --- a/Examples/LineMesh/CMakeLists.txt +++ /dev/null @@ -1,34 +0,0 @@ -########################################################################### -# -# Copyright (c) Kitware, Inc. -# -# 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. -# -########################################################################### - -project(Example-LineMesh) - -#----------------------------------------------------------------------------- -# Create executable -#----------------------------------------------------------------------------- -imstk_add_executable(${PROJECT_NAME} LineMeshExample.cpp) - -#----------------------------------------------------------------------------- -# Add the target to Examples folder -#----------------------------------------------------------------------------- -SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES FOLDER Examples) - -#----------------------------------------------------------------------------- -# Link libraries to executable -#----------------------------------------------------------------------------- -target_link_libraries(${PROJECT_NAME} SimulationManager apiUtilities) diff --git a/Examples/LineMesh/LineMeshExample.cpp b/Examples/LineMesh/LineMeshExample.cpp deleted file mode 100644 index be7d8e395126b1e3a674fca48612bd890faf3172..0000000000000000000000000000000000000000 --- a/Examples/LineMesh/LineMeshExample.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/*========================================================================= - - Library: iMSTK - - Copyright (c) Kitware, Inc. & Center for Modeling, Simulation, - & Imaging in Medicine, Rensselaer Polytechnic Institute. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0.txt - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -=========================================================================*/ - -#include "imstkSimulationManager.h" -#include "imstkAPIUtilities.h" -#include "imstkCamera.h" -#include "imstkLineMesh.h" -#include "imstkScene.h" - -using namespace imstk; - -/// -/// \brief This example demonstrates line mesh rendering -/// -int -main() -{ - // simManager and Scene - auto simManager = std::make_shared<SimulationManager>(); - auto scene = simManager->createNewScene("LineMeshRenderingTest"); - - // Construct line mesh - auto lineMesh = std::make_shared<LineMesh>(); - auto lineObject = std::make_shared<VisualObject>("lineMesh"); - - std::vector<LineMesh::LineArray> lines; - StdVectorOfVec3d points; - std::vector<Color> colors; - - size_t resolution = 16; - size_t numVoxels = resolution * resolution * resolution; - - points.resize(numVoxels * 8); - lines.resize(numVoxels * 12); - - size_t index = 0; - size_t lineIndex = 0; - - for (int z = 0; z < resolution; z++) - { - for (int y = 0; y < resolution; y++) - { - for (int x = 0; x < resolution; x++) - { - Color color = Color((float)x / resolution, (float)y / resolution, (float)z / resolution); - - points[index + 0] = Vec3d(x, y, z); - points[index + 1] = Vec3d(x, y, z + 1); - points[index + 2] = Vec3d(x, y + 1, z); - points[index + 3] = Vec3d(x, y + 1, z + 1); - points[index + 4] = Vec3d(x + 1, y, z); - points[index + 5] = Vec3d(x + 1, y, z + 1); - points[index + 6] = Vec3d(x + 1, y + 1, z); - points[index + 7] = Vec3d(x + 1, y + 1, z + 1); - - lines[lineIndex + 0][0] = index + 0; - lines[lineIndex + 0][1] = index + 1; - lines[lineIndex + 1][0] = index + 2; - lines[lineIndex + 1][1] = index + 3; - lines[lineIndex + 2][0] = index + 4; - lines[lineIndex + 2][1] = index + 5; - lines[lineIndex + 3][0] = index + 6; - lines[lineIndex + 3][1] = index + 7; - - lines[lineIndex + 4][0] = index + 0; - lines[lineIndex + 4][1] = index + 2; - lines[lineIndex + 5][0] = index + 1; - lines[lineIndex + 5][1] = index + 3; - lines[lineIndex + 6][0] = index + 4; - lines[lineIndex + 6][1] = index + 6; - lines[lineIndex + 7][0] = index + 5; - lines[lineIndex + 7][1] = index + 7; - - lines[lineIndex + 8][0] = index + 0; - lines[lineIndex + 8][1] = index + 4; - lines[lineIndex + 9][0] = index + 1; - lines[lineIndex + 9][1] = index + 5; - lines[lineIndex + 10][0] = index + 2; - lines[lineIndex + 10][1] = index + 6; - lines[lineIndex + 11][0] = index + 3; - lines[lineIndex + 11][1] = index + 7; - - index += 8; - lineIndex += 12; - } - } - } - - lineMesh->initialize(points, lines); - auto lineModel = std::make_shared<VisualModel>(lineMesh); - auto lineMeshMaterial = std::make_shared<RenderMaterial>(); - lineMeshMaterial->setDisplayMode(RenderMaterial::DisplayMode::WireframeSurface); - lineMeshMaterial->setLineWidth(2.); - lineMeshMaterial->setPointSize(6.); - lineMeshMaterial->setColor(Color::Orange); - lineModel->setRenderMaterial(lineMeshMaterial); - lineObject->addVisualModel(lineModel); - - auto camera = scene->getCamera(); - camera->setPosition(resolution / 2.0, resolution / 2.0, resolution * 4.0); - camera->setFocalPoint(resolution / 2.0, resolution / 2.0, resolution / 2.0); - - lineObject->setVisualGeometry(lineMesh); - scene->addSceneObject(lineObject); - - // Start simulation - simManager->setActiveScene(scene); - simManager->start(); -} diff --git a/Examples/NonlinearSolver/nonlinearSolver.cpp b/Examples/NonlinearSolver/nonlinearSolver.cpp index 1e50fa5a3f7ba643b2ef9eb0466e52ce2ab20dd6..c8a94e2490573e1be1cc9490b0f078e1ae108513 100644 --- a/Examples/NonlinearSolver/nonlinearSolver.cpp +++ b/Examples/NonlinearSolver/nonlinearSolver.cpp @@ -31,6 +31,9 @@ using namespace imstk; +/// +/// \brief This example is for demonstration of how to use a NewtonSolver and its verification +/// int main(int argc, char** argv) { @@ -88,4 +91,9 @@ main(int argc, char** argv) nlSolver->solve(); std::cout << "final_error = " << std::setprecision(12) << std::scientific << (x - xe).norm() << std::endl; + + x[0] = 100.0; + x[1] = 100.0; + nlSolver->solveGivenState(x); + std::cout << "final_error = " << std::setprecision(12) << std::scientific << (x - xe).norm() << std::endl; } diff --git a/Examples/PBD/PBDCloth/pbdClothExample.cpp b/Examples/PBD/PBDCloth/pbdClothExample.cpp index 30289cab718e0246749e2ef0f2df24ed285233da..e642d54f549cdc51f0b6a68e3bc295a7813aa30f 100644 --- a/Examples/PBD/PBDCloth/pbdClothExample.cpp +++ b/Examples/PBD/PBDCloth/pbdClothExample.cpp @@ -30,23 +30,23 @@ using namespace imstk; +// Parameters to play with +const double width = 10.0; +const double height = 10.0; +const int nRows = 16; +const int nCols = 16; + /// -/// \brief This example demonstrates the cloth simulation -/// using Position based dynamics +/// \brief Creates cloth geometry /// -int -main() +static std::unique_ptr<SurfaceMesh> +makeClothGeometry( + const double width, const double height, const int nRows, const int nCols) { - auto simManager = std::make_shared<SimulationManager>(); - auto scene = simManager->createNewScene("PBDCloth"); - // Create surface mesh - auto surfMesh = std::make_shared<SurfaceMesh>(); - StdVectorOfVec3d vertList; - const double width = 10.0; - const double height = 10.0; - const int nRows = 16; - const int nCols = 16; + std::unique_ptr<SurfaceMesh> clothMesh = std::make_unique<SurfaceMesh>(); + StdVectorOfVec3d vertList; + vertList.resize(nRows * nCols); const double dy = width / (double)(nCols - 1); const double dx = height / (double)(nRows - 1); @@ -57,8 +57,8 @@ main() vertList[i * nCols + j] = Vec3d((double)dx * i, 1.0, (double)dy * j); } } - surfMesh->setInitialVertexPositions(vertList); - surfMesh->setVertexPositions(vertList); + clothMesh->setInitialVertexPositions(vertList); + clothMesh->setVertexPositions(vertList); // Add connectivity data std::vector<SurfaceMesh::TriangleArray> triangles; @@ -88,49 +88,71 @@ main() } } - surfMesh->setTrianglesVertices(triangles); + clothMesh->setTrianglesVertices(triangles); - // Create Object & Model - auto deformableObj = std::make_shared<PbdObject>("Cloth"); - auto pbdModel = std::make_shared<PbdModel>(); - pbdModel->setModelGeometry(surfMesh); + return clothMesh; +} - // configure model - auto pbdParams = std::make_shared<PBDModelConfig>(); +/// +/// \brief Creates cloth object +/// +static std::shared_ptr<PbdObject> +makeClothObj(const std::string& name, double width, double height, int nRows, int nCols) +{ + auto clothObj = std::make_shared<PbdObject>(name); - // Constraints - // pbdParams->enableConstraint(PbdConstraint::Type::Distance, 0.1); - // pbdParams->enableConstraint(PbdConstraint::Type::Dihedral, 1e2); - // pbdParams->m_solverType = PbdConstraint::SolverType::PBD; + // Setup the Geometry + std::shared_ptr<SurfaceMesh> clothMesh(std::move(makeClothGeometry(width, height, nRows, nCols))); + + // Setup the Parameters + auto pbdParams = std::make_shared<PBDModelConfig>(); pbdParams->enableConstraint(PbdConstraint::Type::Distance, 1e2); pbdParams->enableConstraint(PbdConstraint::Type::Dihedral, 1e1); - std::vector<size_t> fixedNodes = { 0, nCols - 1 }; - pbdParams->m_fixedNodeIds = fixedNodes; - - // Other parameters + pbdParams->m_fixedNodeIds = { 0, static_cast<size_t>(nCols) - 1 }; pbdParams->m_uniformMassValue = width * height / (nRows * nCols); pbdParams->m_gravity = Vec3d(0, -9.8, 0); pbdParams->m_defaultDt = 0.005; pbdParams->m_iterations = 5; - // Set the parameters + // Setup the Model + auto pbdModel = std::make_shared<PbdModel>(); + pbdModel->setModelGeometry(clothMesh); pbdModel->configure(pbdParams); - deformableObj->setDynamicalModel(pbdModel); - deformableObj->setPhysicsGeometry(surfMesh); + // Setup the VisualModel auto material = std::make_shared<RenderMaterial>(); material->setBackFaceCulling(false); material->setDisplayMode(RenderMaterial::DisplayMode::WireframeSurface); - material->setPointSize(6.); - material->setLineWidth(4.); - auto surfMeshModel = std::make_shared<VisualModel>(surfMesh); - surfMeshModel->setRenderMaterial(material); - deformableObj->addVisualModel(surfMeshModel); + + auto clothVisualModel = std::make_shared<VisualModel>(clothMesh); + clothVisualModel->setRenderMaterial(material); + + // Setup the Object + clothObj->addVisualModel(clothVisualModel); + clothObj->setPhysicsGeometry(clothMesh); + clothObj->setDynamicalModel(pbdModel); + + return clothObj; +} + +/// +/// \brief This example demonstrates the cloth simulation +/// using Position based dynamics +/// +int +main() +{ + auto simManager = std::make_shared<SimulationManager>(); + auto scene = simManager->createNewScene("PBDCloth"); + + std::shared_ptr<PbdObject> clothObj = makeClothObj("Cloth", width, height, nRows, nCols); + scene->addSceneObject(clothObj); // Light (white) auto whiteLight = std::make_shared<DirectionalLight>("whiteLight"); whiteLight->setFocalPoint(Vec3d(5, -8, -5)); whiteLight->setIntensity(1.); + scene->addLight(whiteLight); // Light (red) auto colorLight = std::make_shared<SpotLight>("colorLight"); @@ -139,12 +161,9 @@ main() colorLight->setIntensity(100); colorLight->setColor(Color::Red); colorLight->setSpotAngle(30); - - // Add in scene - scene->addLight(whiteLight); scene->addLight(colorLight); - scene->addSceneObject(deformableObj); + // Adjust camera scene->getCamera()->setFocalPoint(0, -5, 5); scene->getCamera()->setPosition(-15., -5.0, 15.0); diff --git a/Examples/PBD/PBDCollisionMultipleObjects/PBDCollisionMultipleObjectsExample.cpp b/Examples/PBD/PBDCollisionMultipleObjects/PBDCollisionMultipleObjectsExample.cpp index e497925a05e2f6ee1981528fad234e87fd1adb9b..d3e1595ff899d422b8d7f298a520316161ee45c3 100644 --- a/Examples/PBD/PBDCollisionMultipleObjects/PBDCollisionMultipleObjectsExample.cpp +++ b/Examples/PBD/PBDCollisionMultipleObjects/PBDCollisionMultipleObjectsExample.cpp @@ -137,6 +137,13 @@ generateDragon(const std::shared_ptr<imstk::Scene>& scene, scene->addSceneObject(deformableObj); } +/// +/// \brief Create a surface mesh +/// \param nRows number of vertices in x-direction +/// \param nCols number of vertices in y-direction +/// +std::shared_ptr<SurfaceMesh> createUniformSurfaceMesh(const double width, const double height, const size_t nRows, const size_t nCols); + /// /// \brief This example demonstrates the collision interaction /// using Position based dynamics @@ -151,68 +158,31 @@ main() auto viewer = std::dynamic_pointer_cast<VTKViewer>(simManager->getViewer()); viewer->getVtkRenderWindow()->SetSize(1920, 1080); - // Build floor geometry - const double width = 100.0; - const double height = 100.0; - const size_t nRows = 2; - const size_t nCols = 2; - const double dy = width / static_cast<double>(nCols - 1); - const double dx = height / static_cast<double>(nRows - 1); + auto floorMesh = createUniformSurfaceMesh(100.0, 100.0, 2, 2); - StdVectorOfVec3d vertList; - vertList.resize(nRows * nCols); - for (size_t i = 0; i < nRows; ++i) - { - for (size_t j = 0; j < nCols; j++) - { - const double y = static_cast<double>(dy * j); - const double x = static_cast<double>(dx * i); - vertList[i * nCols + j] = Vec3d(x - 50, -10.0, y - 50); - } - } - - // c. Add connectivity data - std::vector<SurfaceMesh::TriangleArray> triangles; - for (std::size_t i = 0; i < nRows - 1; ++i) - { - for (std::size_t j = 0; j < nCols - 1; j++) - { - SurfaceMesh::TriangleArray tri[2]; - tri[0] = { { i* nCols + j, i* nCols + j + 1, (i + 1) * nCols + j } }; - tri[1] = { { (i + 1) * nCols + j + 1, (i + 1) * nCols + j, i* nCols + j + 1 } }; - triangles.push_back(tri[0]); - triangles.push_back(tri[1]); - } - } + auto materialFloor = std::make_shared<RenderMaterial>(); + materialFloor->setDisplayMode(RenderMaterial::DisplayMode::WireframeSurface); + auto floorMeshModel = std::make_shared<VisualModel>(floorMesh); + floorMeshModel->setRenderMaterial(materialFloor); auto floorObj = std::make_shared<PbdObject>("Floor"); - { - auto floorMesh = std::make_shared<SurfaceMesh>(); - floorMesh->initialize(vertList, triangles); - - auto materialFloor = std::make_shared<RenderMaterial>(); - materialFloor->setDisplayMode(RenderMaterial::DisplayMode::WireframeSurface); - auto floorMeshModel = std::make_shared<VisualModel>(floorMesh); - floorMeshModel->setRenderMaterial(materialFloor); - - floorObj->setCollidingGeometry(floorMesh); - floorObj->setVisualGeometry(floorMesh); - floorObj->setPhysicsGeometry(floorMesh); - - auto pbdFloorModel = std::make_shared<PbdModel>(); - pbdFloorModel->setModelGeometry(floorMesh); - - // Configure floor - auto pbdFloorConfig = std::make_shared<PBDModelConfig>(); - pbdFloorConfig->m_uniformMassValue = 0.0; - pbdFloorConfig->collisionParams->m_proximity = -0.1; - pbdFloorConfig->m_iterations = 0; - - // Set the parameters - pbdFloorModel->configure(pbdFloorConfig); - floorObj->setDynamicalModel(pbdFloorModel); - scene->addSceneObject(floorObj); - } + floorObj->setCollidingGeometry(floorMesh); + floorObj->setVisualGeometry(floorMesh); + floorObj->setPhysicsGeometry(floorMesh); + + auto pbdModel2 = std::make_shared<PbdModel>(); + pbdModel2->setModelGeometry(floorMesh); + + // configure model + auto pbdParams2 = std::make_shared<PBDModelConfig>(); + pbdParams2->m_uniformMassValue = 0.0; + pbdParams2->collisionParams->m_proximity = 0.1; + pbdParams2->m_iterations = 0; + + // Set the parameters + pbdModel2->configure(pbdParams2); + floorObj->setDynamicalModel(pbdModel2); + scene->addSceneObject(floorObj); #ifdef BIG_SCENE const int expandsXZ = 1; @@ -227,19 +197,15 @@ main() #ifdef BIG_SCENE for (int i = -expandsXZ; i < expandsXZ; ++i) -#else - int i = 0; -#endif { -#ifdef BIG_SCENE for (int j = 0; j < expandsY; ++j) -#else - int j = 0; -#endif { -#ifdef BIG_SCENE for (int k = -expandsXZ; k < expandsXZ; ++k) #else + int i = 0; + { + int j = 0; + { int k = 0; #endif { @@ -281,3 +247,46 @@ main() return 0; } + +std::shared_ptr<SurfaceMesh> +createUniformSurfaceMesh(const double width, const double height, const size_t nRows, const size_t nCols) +{ + // Build floor geometry + // const double width = 100.0; + // const double height = 100.0; + // const size_t nRows = 2; + // const size_t nCols = 2; + const double dy = width / static_cast<double>(nCols - 1); + const double dx = height / static_cast<double>(nRows - 1); + + StdVectorOfVec3d vertList; + vertList.resize(nRows * nCols); + for (size_t i = 0; i < nRows; ++i) + { + for (size_t j = 0; j < nCols; j++) + { + const double y = static_cast<double>(dy * j); + const double x = static_cast<double>(dx * i); + vertList[i * nCols + j] = Vec3d(x - height * 0.5, -10.0, y - width * 0.5); + } + } + + // c. Add connectivity data + std::vector<SurfaceMesh::TriangleArray> triangles; + for (std::size_t i = 0; i < nRows - 1; ++i) + { + for (std::size_t j = 0; j < nCols - 1; j++) + { + SurfaceMesh::TriangleArray tri[2]; + tri[0] = { { i* nCols + j, i* nCols + j + 1, (i + 1) * nCols + j } }; + tri[1] = { { (i + 1) * nCols + j + 1, (i + 1) * nCols + j, i* nCols + j + 1 } }; + triangles.push_back(tri[0]); + triangles.push_back(tri[1]); + } + } + + auto surfMesh = std::make_shared<SurfaceMesh>(); + surfMesh->initialize(vertList, triangles); + + return surfMesh; +} diff --git a/Examples/PBD/PBDCollisionOneObject/PBDCollisionOneObjectExample.cpp b/Examples/PBD/PBDCollisionOneObject/PBDCollisionOneObjectExample.cpp index 172919501963349b2bfdabf9549d0b09fa8402a0..d41458514a75c2b38318811cc5f24e44fdc5fc30 100644 --- a/Examples/PBD/PBDCollisionOneObject/PBDCollisionOneObjectExample.cpp +++ b/Examples/PBD/PBDCollisionOneObject/PBDCollisionOneObjectExample.cpp @@ -35,6 +35,23 @@ using namespace imstk; +// mesh file names +const std::string surfMeshFileName = iMSTK_DATA_ROOT "/asianDragon/asianDragon.obj"; +const std::string tetMeshFileName = iMSTK_DATA_ROOT "/asianDragon/asianDragon.veg"; +/// +/// \brief Create a surface mesh +/// \param nRows number of vertices in x-direction +/// \param nCols number of vertices in y-direction +/// +std::shared_ptr<SurfaceMesh> createUniformSurfaceMesh(const double width, const double height, const size_t nRows, const size_t nCols); + +// parameters to play with +const double youngModulus = 1000.0; +const double poissonRatio = 0.3; +const double timeStep = 0.01; +const double contactStiffness = 0.1; +const int maxIter = 5; + /// /// \brief This example demonstrates the collision interaction /// using Position based dynamics @@ -48,8 +65,8 @@ main() scene->getCamera()->setFocalPoint(0.0, -10.0, 0.0); // set up the meshes - auto highResSurfMesh = std::dynamic_pointer_cast<SurfaceMesh>(MeshIO::read(iMSTK_DATA_ROOT "/asianDragon/asianDragon.obj")); - auto coarseTetMesh = std::dynamic_pointer_cast<TetrahedralMesh>(MeshIO::read(iMSTK_DATA_ROOT "/asianDragon/asianDragon.veg")); + auto highResSurfMesh = std::dynamic_pointer_cast<SurfaceMesh>(MeshIO::read(surfMeshFileName)); + auto coarseTetMesh = std::dynamic_pointer_cast<TetrahedralMesh>(MeshIO::read(tetMeshFileName)); auto coarseSurfMesh = std::make_shared<SurfaceMesh>(); coarseTetMesh->extractSurfaceMesh(coarseSurfMesh, true); @@ -82,16 +99,18 @@ main() auto pbdParams = std::make_shared<PBDModelConfig>(); // FEM constraint - pbdParams->m_femParams->m_YoungModulus = 1000.0; - pbdParams->m_femParams->m_PoissonRatio = 0.3; + pbdParams->m_femParams->m_YoungModulus = youngModulus; + pbdParams->m_femParams->m_PoissonRatio = poissonRatio; pbdParams->enableFEMConstraint(PbdConstraint::Type::FEMTet, PbdFEMConstraint::MaterialType::Corotation); // Other parameters + // \todo use lumped mass pbdParams->m_uniformMassValue = 1.0; + pbdParams->m_gravity = Vec3d(0, -10.0, 0); - pbdParams->m_defaultDt = 0.01; - pbdParams->m_iterations = 5; + pbdParams->m_defaultDt = timeStep; + pbdParams->m_iterations = maxIter; pbdParams->collisionParams->m_proximity = 0.3; pbdParams->collisionParams->m_stiffness = 0.1; @@ -101,41 +120,7 @@ main() scene->addSceneObject(deformableObj); // Build floor geometry - const double width = 100.0; - const double height = 100.0; - const size_t nRows = 2; - const size_t nCols = 2; - const double dy = width / static_cast<double>(nCols - 1); - const double dx = height / static_cast<double>(nRows - 1); - - StdVectorOfVec3d vertList; - vertList.resize(nRows * nCols); - for (size_t i = 0; i < nRows; ++i) - { - for (size_t j = 0; j < nCols; j++) - { - const double y = static_cast<double>(dy * j); - const double x = static_cast<double>(dx * i); - vertList[i * nCols + j] = Vec3d(x - width * 0.5, -10.0, y - height * 0.5); - } - } - - // c. Add connectivity data - std::vector<SurfaceMesh::TriangleArray> triangles; - for (std::size_t i = 0; i < nRows - 1; ++i) - { - for (std::size_t j = 0; j < nCols - 1; j++) - { - SurfaceMesh::TriangleArray tri[2]; - tri[0] = { { i* nCols + j, i* nCols + j + 1, (i + 1) * nCols + j } }; - tri[1] = { { (i + 1) * nCols + j + 1, (i + 1) * nCols + j, i* nCols + j + 1 } }; - triangles.push_back(tri[0]); - triangles.push_back(tri[1]); - } - } - - auto floorMesh = std::make_shared<SurfaceMesh>(); - floorMesh->initialize(vertList, triangles); + auto floorMesh = createUniformSurfaceMesh(100.0, 100.0, 2, 2); auto materialFloor = std::make_shared<RenderMaterial>(); materialFloor->setDisplayMode(RenderMaterial::DisplayMode::WireframeSurface); @@ -177,3 +162,41 @@ main() return 0; } + +std::shared_ptr<SurfaceMesh> +createUniformSurfaceMesh(const double width, const double height, const size_t nRows, const size_t nCols) +{ + const double dy = width / static_cast<double>(nCols - 1); + const double dx = height / static_cast<double>(nRows - 1); + + StdVectorOfVec3d vertList; + vertList.resize(nRows * nCols); + + for (size_t i = 0; i < nRows; ++i) + { + for (size_t j = 0; j < nCols; j++) + { + const double y = static_cast<double>(dy * j); + const double x = static_cast<double>(dx * i); + vertList[i * nCols + j] = Vec3d(x - height * 0.5, -10.0, y - width * 0.5); + } + } + + // c. Add connectivity data + std::vector<SurfaceMesh::TriangleArray> triangles; + for (std::size_t i = 0; i < nRows - 1; ++i) + { + for (std::size_t j = 0; j < nCols - 1; j++) + { + SurfaceMesh::TriangleArray tri[2]; + tri[0] = { { i* nCols + j, i* nCols + j + 1, (i + 1) * nCols + j } }; + tri[1] = { { (i + 1) * nCols + j + 1, (i + 1) * nCols + j, i* nCols + j + 1 } }; + triangles.push_back(tri[0]); + triangles.push_back(tri[1]); + } + } + + auto surfMesh = std::make_shared<SurfaceMesh>(); + surfMesh->initialize(vertList, triangles); + return surfMesh; +} diff --git a/Examples/PBD/PBDCollisionStairs/PBDCollisionStairsExample.cpp b/Examples/PBD/PBDCollisionStairs/PBDCollisionStairsExample.cpp index f14c7df8d337bc6187ba9ac0a515d049c55637bc..a88d0e31303a06d79fe6f767371ea597f7a474be 100644 --- a/Examples/PBD/PBDCollisionStairs/PBDCollisionStairsExample.cpp +++ b/Examples/PBD/PBDCollisionStairs/PBDCollisionStairsExample.cpp @@ -38,7 +38,9 @@ using namespace imstk; -// Creates a non-manifold top part of a staircase +/// +/// \brief Creates a non-manifold top part of a staircase +//. static std::unique_ptr<SurfaceMesh> buildStairs(int nSteps, double width, double height, double depth) { diff --git a/Examples/PBD/PBDDeformableObject/PBD3DDeformableObject.cpp b/Examples/PBD/PBDDeformableObject/PBD3DDeformableObject.cpp index 925ae79cce40699377c0c54e960e9ecf21e727f9..2d411318e30509d6480df164ba8c1352e820e3c7 100644 --- a/Examples/PBD/PBDDeformableObject/PBD3DDeformableObject.cpp +++ b/Examples/PBD/PBDDeformableObject/PBD3DDeformableObject.cpp @@ -33,9 +33,21 @@ #include "imstkScene.h" #include <array> +#include <string> using namespace imstk; +/// +/// \brief Create a PbdObject and add it to a \p scene +/// +std::shared_ptr<PbdObject> createAndAddPbdObject(std::shared_ptr<Scene> scene, + const std::string& surfMeshName, + const std::string& tetMeshName); + +// mesh file names +const std::string& surfMeshFileName = iMSTK_DATA_ROOT "/asianDragon/asianDragon.obj"; +const std::string& tetMeshFileName = iMSTK_DATA_ROOT "/asianDragon/asianDragon.veg"; + /// /// \brief This example demonstrates the soft body simulation /// using Position based dynamics @@ -47,8 +59,38 @@ main() auto scene = simManager->createNewScene("PBDVolume"); scene->getCamera()->setPosition(0, 2.0, 15.0); - auto surfMesh = std::dynamic_pointer_cast<SurfaceMesh>(MeshIO::read(iMSTK_DATA_ROOT "/asianDragon/asianDragon.obj")); - auto tetMesh = std::dynamic_pointer_cast<TetrahedralMesh>(MeshIO::read(iMSTK_DATA_ROOT "/asianDragon/asianDragon.veg")); + // create and add a PBD object + createAndAddPbdObject(scene, surfMeshFileName, tetMeshFileName); + + // Setup plane + auto planeGeom = std::make_shared<Plane>(); + planeGeom->setWidth(40); + planeGeom->setTranslation(0, -6, 0); + auto planeObj = std::make_shared<CollidingObject>("Plane"); + planeObj->setVisualGeometry(planeGeom); + planeObj->setCollidingGeometry(planeGeom); + scene->addSceneObject(planeObj); + + // Light + auto light = std::make_shared<DirectionalLight>("light"); + light->setFocalPoint(Vec3d(5, -8, -5)); + light->setIntensity(1); + scene->addLight(light); + + simManager->setActiveScene(scene); + simManager->getViewer()->setBackgroundColors(Vec3d(0.3285, 0.3285, 0.6525), Vec3d(0.13836, 0.13836, 0.2748), true); + simManager->start(SimulationStatus::Paused); + + return 0; +} + +std::shared_ptr<PbdObject> +createAndAddPbdObject(std::shared_ptr<Scene> scene, + const std::string& surfMeshName, + const std::string& tetMeshName) +{ + auto surfMesh = std::dynamic_pointer_cast<SurfaceMesh>(MeshIO::read(surfMeshName)); + auto tetMesh = std::dynamic_pointer_cast<TetrahedralMesh>(MeshIO::read(tetMeshName)); //auto tetMesh = TetrahedralMesh::createTetrahedralMeshCover(surfMesh, 10, 6, 6); auto map = std::make_shared<TetraTriangleMap>(tetMesh, surfMesh); @@ -89,23 +131,5 @@ main() scene->addSceneObject(deformableObj); - // Setup plane - auto planeGeom = std::make_shared<Plane>(); - planeGeom->setWidth(40); - planeGeom->setTranslation(0, -6, 0); - auto planeObj = std::make_shared<CollidingObject>("Plane"); - planeObj->setVisualGeometry(planeGeom); - planeObj->setCollidingGeometry(planeGeom); - scene->addSceneObject(planeObj); - - // Light - auto light = std::make_shared<DirectionalLight>("light"); - light->setFocalPoint(Vec3d(5, -8, -5)); - scene->addLight(light); - - simManager->setActiveScene(scene); - simManager->getViewer()->setBackgroundColors(Vec3d(0.3285, 0.3285, 0.6525), Vec3d(0.13836, 0.13836, 0.2748), true); - simManager->start(SimulationStatus::Paused); - - return 0; + return deformableObj; } diff --git a/Examples/PBD/PBDFluids/PBDFluidsExample.cpp b/Examples/PBD/PBDFluids/PBDFluidsExample.cpp index 4af5e4ce16d5db25090b6df7732351326983afaa..eb4639c3735215d94fecbaaba031851a7d1adb4d 100644 --- a/Examples/PBD/PBDFluids/PBDFluidsExample.cpp +++ b/Examples/PBD/PBDFluids/PBDFluidsExample.cpp @@ -35,6 +35,20 @@ using namespace imstk; +/// +/// \brief create a PbdObject for fluids +/// +std::shared_ptr<PbdObject> createAndAddPbdObject(std::shared_ptr<Scene> scene, + const std::string& tetMeshName); + +/// +/// \brief Create a box mesh to hold the fluid +/// +std::shared_ptr<SurfaceMesh> createCollidingSurfaceMesh(); + +// mesh file name +const std::string tetMeshFileName = iMSTK_DATA_ROOT "/asianDragon/asianDragon.veg"; + /// /// \brief This example demonstrates the fluids simulation /// using Position based dynamics @@ -47,8 +61,58 @@ main() scene->getCamera()->setPosition(0, 10.0, 15.0); + auto deformableObj = createAndAddPbdObject(scene, tetMeshFileName); + auto floorMeshColliding = createCollidingSurfaceMesh(); + auto floorMeshVisual = std::make_shared<SurfaceMesh>(); + floorMeshVisual->initialize(floorMeshColliding->getVertexPositions(), floorMeshColliding->getTrianglesVertices()); + auto floorMeshPhysics = std::make_shared<SurfaceMesh>(); + floorMeshPhysics->initialize(floorMeshColliding->getVertexPositions(), floorMeshColliding->getTrianglesVertices()); + + auto floor = std::make_shared<PbdObject>("Floor"); + floor->setCollidingGeometry(floorMeshColliding); + floor->setVisualGeometry(floorMeshVisual); + floor->setPhysicsGeometry(floorMeshPhysics); + + auto pbdModel2 = std::make_shared<PbdModel>(); + pbdModel2->setModelGeometry(floorMeshPhysics); + + // Configure model + auto pbdParams2 = std::make_shared<PBDModelConfig>(); + pbdParams2->m_uniformMassValue = 0.0; + pbdParams2->collisionParams->m_proximity = 0.1; + + pbdModel2->configure(pbdParams2); + floor->setDynamicalModel(pbdModel2); + + scene->addSceneObject(floor); + + // Collisions + scene->getCollisionGraph()->addInteraction(makeObjectInteractionPair(deformableObj, floor, + InteractionType::PbdObjToPbdObjCollision, + CollisionDetection::Type::MeshToMeshBruteForce)); + + // Light (white) + auto whiteLight = std::make_shared<DirectionalLight>("whiteLight"); + whiteLight->setFocalPoint(Vec3d(5, -8, -5)); + whiteLight->setIntensity(7); + scene->addLight(whiteLight); + + // print UPS + scene->getConfig()->trackFPS = true; + apiutils::printUPS(simManager->getSceneManager(scene)); + + simManager->setActiveScene(scene); + simManager->start(SimulationStatus::Paused); + + return 0; +} + +std::shared_ptr<PbdObject> +createAndAddPbdObject(std::shared_ptr<Scene> scene, + const std::string& tetMeshName) +{ // Load a sample mesh - auto tetMesh = MeshIO::read(iMSTK_DATA_ROOT "/asianDragon/asianDragon.veg"); + auto tetMesh = MeshIO::read(tetMeshName); auto fluidMesh = std::make_shared<PointSet>(); fluidMesh->initialize(tetMesh->getInitialVertexPositions()); @@ -89,7 +153,12 @@ main() scene->addSceneObject(deformableObj); - // Create a box to hold the fluid + return deformableObj; +} + +std::shared_ptr<SurfaceMesh> +createCollidingSurfaceMesh() +{ StdVectorOfVec3d vertList; int nSides = 5; double width = 40.0; @@ -196,45 +265,5 @@ main() auto floorMeshColliding = std::make_shared<SurfaceMesh>(); floorMeshColliding->initialize(vertList, triangles); - auto floorMeshVisual = std::make_shared<SurfaceMesh>(); - floorMeshVisual->initialize(vertList, triangles); - auto floorMeshPhysics = std::make_shared<SurfaceMesh>(); - floorMeshPhysics->initialize(vertList, triangles); - - auto floor = std::make_shared<PbdObject>("Floor"); - floor->setCollidingGeometry(floorMeshColliding); - floor->setVisualGeometry(floorMeshVisual); - floor->setPhysicsGeometry(floorMeshPhysics); - - auto pbdModel2 = std::make_shared<PbdModel>(); - pbdModel2->setModelGeometry(floorMeshPhysics); - - // Configure model - auto pbdParams2 = std::make_shared<PBDModelConfig>(); - pbdParams2->m_uniformMassValue = 0.0; - pbdParams2->collisionParams->m_proximity = 0.1; - - pbdModel2->configure(pbdParams2); - floor->setDynamicalModel(pbdModel2); - - scene->addSceneObject(floor); - - // Collisions - scene->getCollisionGraph()->addInteraction(makeObjectInteractionPair(deformableObj, floor, - InteractionType::PbdObjToPbdObjCollision, CollisionDetection::Type::MeshToMeshBruteForce)); - - // Light (white) - auto whiteLight = std::make_shared<DirectionalLight>("whiteLight"); - whiteLight->setFocalPoint(Vec3d(5, -8, -5)); - whiteLight->setIntensity(7); - scene->addLight(whiteLight); - - // print UPS - scene->getConfig()->trackFPS = true; - apiutils::printUPS(simManager->getSceneManager(scene)); - - simManager->setActiveScene(scene); - simManager->start(SimulationStatus::Paused); - - return 0; + return floorMeshColliding; } diff --git a/Examples/PBD/PBDString/pbdStringExample.cpp b/Examples/PBD/PBDString/pbdStringExample.cpp index 9fdb87c79b356c379bb1d365ccbd4392a9b099d8..655e95df4e43e82b61e37bf27f790022b8c9eeb7 100644 --- a/Examples/PBD/PBDString/pbdStringExample.cpp +++ b/Examples/PBD/PBDString/pbdStringExample.cpp @@ -19,17 +19,135 @@ =========================================================================*/ -#include "imstkAPIUtilities.h" +#include "imstkCamera.h" #include "imstkLineMesh.h" #include "imstkPbdModel.h" #include "imstkPbdObject.h" -#include "imstkSimulationManager.h" -#include "imstkSceneManager.h" -#include "imstkCamera.h" #include "imstkScene.h" +#include "imstkSceneManager.h" +#include "imstkSimulationManager.h" using namespace imstk; +/// +/// \brief Create pbd string geometry +/// +static std::shared_ptr<LineMesh> +makeStringGeometry(const Vec3d& pos, const size_t numVerts, const double stringLength) +{ + // Create the geometry + std::shared_ptr<LineMesh> stringGeometry = std::make_shared<LineMesh>(); + + StdVectorOfVec3d vertList; + vertList.resize(numVerts); + const double vertexSpacing = stringLength / numVerts; + for (size_t j = 0; j < numVerts; j++) + { + vertList[j] = pos - Vec3d(0.0, static_cast<double>(j) * vertexSpacing, 0.0); + } + stringGeometry->setInitialVertexPositions(vertList); + stringGeometry->setVertexPositions(vertList); + + // Add connectivity data + std::vector<LineMesh::LineArray> segments; + for (size_t j = 0; j < numVerts - 1; j++) + { + LineMesh::LineArray seg = { j, j + 1 }; + segments.push_back(seg); + } + + stringGeometry->setLinesVertices(segments); + return stringGeometry; +} + +/// +/// \brief Create pbd string object +/// +static std::shared_ptr<PbdObject> +makePbdString( + const std::string& name, + const Vec3d& pos, + const size_t numVerts, + const double stringLength, + const double bendStiffness, + const Color& color) +{ + std::shared_ptr<PbdObject> stringObj = std::make_shared<PbdObject>(name); + + // Setup the Geometry + std::shared_ptr<LineMesh> stringMesh = makeStringGeometry(pos, numVerts, stringLength); + + // Setup the Parameters + auto pbdParams = std::make_shared<PBDModelConfig>(); + pbdParams->enableConstraint(PbdConstraint::Type::Distance, 1e7); + pbdParams->enableConstraint(PbdConstraint::Type::Bend, bendStiffness); + pbdParams->m_fixedNodeIds = { 0 }; + pbdParams->m_uniformMassValue = 5.0; + pbdParams->m_gravity = Vec3d(0, -9.8, 0); + pbdParams->m_defaultDt = 0.0005; + pbdParams->m_iterations = 5; + + // Setup the Model + std::shared_ptr<PbdModel> pbdModel = std::make_shared<PbdModel>(); + pbdModel->setModelGeometry(stringMesh); + pbdModel->configure(pbdParams); + + // Setup the VisualModel + std::shared_ptr<RenderMaterial> material = std::make_shared<RenderMaterial>(); + material->setBackFaceCulling(false); + material->setColor(color); + material->setLineWidth(2.0f); + material->setDisplayMode(RenderMaterial::DisplayMode::Wireframe); + + std::shared_ptr<VisualModel> visualModel = std::make_shared<VisualModel>(stringMesh); + visualModel->setRenderMaterial(material); + + // Setup the Object + stringObj->addVisualModel(visualModel); + stringObj->setPhysicsGeometry(stringMesh); + stringObj->setDynamicalModel(pbdModel); + + return stringObj; +} + +static std::vector<std::shared_ptr<PbdObject>> +makePbdStrings(const size_t numStrings, + const size_t numVerts, + const double stringSpacing, + const double stringLength, + const Color& startColor, + const Color& endColor) +{ + std::vector<std::shared_ptr<PbdObject>> pbdStringObjs(numStrings); + + const double size = stringSpacing * (numStrings - 1); + + for (unsigned int i = 0; i < numStrings; i++) + { + const Vec3d tipPos = Vec3d(static_cast<double>(i) * stringSpacing - size * 0.5, stringLength * 0.5, 0.0); + const double t = static_cast<double>(i) / (numStrings - 1); + + pbdStringObjs[i] = makePbdString( + "String " + std::to_string(i), + tipPos, + numVerts, + stringLength, + (static_cast<double>(i) * 0.1 / numStrings + 0.001) * 1e6, + Color::lerpRgb(startColor, endColor, t)); + } + + return pbdStringObjs; +} + +const double dt = 0.0005; +const double radius = 1.5; +const size_t numStrings = 8; // Number of strings +const size_t numVerts = 30; // Number of vertices on each string +const double stringSpacing = 2.0; // How far each string is apart +const double stringLength = 10.0; // Total length of string +const Color startColor = Color(1.0, 0.0, 0.0); // Color of first string +const Color endColor = Color(0.0, 1.0, 0.0); // Color of last string + /// /// \brief This example demonstrates string simulation /// using Position based dynamics with varying bend stiffnesses @@ -40,81 +158,12 @@ main() auto simManager = std::make_shared<SimulationManager>(); auto scene = simManager->createNewScene("PBDString"); - // Setup N separate string simulations with varying bend stiffnesses - const unsigned int numStrings = 8; - const unsigned int numVerts = 30; - const double stringSpacing = 2.0; // How far each string is apart - const double stringLength = 10.0; // Total length of string - const Color startColor = Color::Red; // Color of first string - const Color endColor = Color::Green; // Color of last string - - struct PbdSim + // Setup N separate strings with varying bend stiffnesses + std::vector<std::shared_ptr<PbdObject>> pbdStringObjs = + makePbdStrings(numStrings, numVerts, stringSpacing, stringLength, startColor, endColor); + for (std::shared_ptr<PbdObject> obj : pbdStringObjs) { - std::shared_ptr<LineMesh> geometry; - std::shared_ptr<PbdObject> object; - std::shared_ptr<PbdModel> model; - std::shared_ptr<PBDModelConfig> params; - std::shared_ptr<VisualModel> visualModel; - }; - std::vector<PbdSim> sims(numStrings); - - const double size = stringSpacing * (numStrings - 1); - const double vertexSpacing = stringLength / numVerts; - for (unsigned int i = 0; i < numStrings; i++) - { - // Setup the line mesh - sims[i].geometry = std::make_shared<LineMesh>(); - StdVectorOfVec3d vertList; - vertList.resize(numVerts); - for (size_t j = 0; j < numVerts; j++) - { - vertList[j] = Vec3d( - static_cast<double>(i) * stringSpacing - size * 0.5, - stringLength * 0.5 - static_cast<double>(j) * vertexSpacing, 0.0); - } - sims[i].geometry->setInitialVertexPositions(vertList); - sims[i].geometry->setVertexPositions(vertList); - - // Add connectivity data - std::vector<LineMesh::LineArray> segments; - for (size_t j = 0; j < numVerts - 1; j++) - { - LineMesh::LineArray seg = { j, j + 1 }; - segments.push_back(seg); - } - - sims[i].geometry->setLinesVertices(segments); - - sims[i].object = std::make_shared<PbdObject>("String " + std::to_string(i)); - sims[i].model = std::make_shared<PbdModel>(); - sims[i].model->setModelGeometry(sims[i].geometry); - - // Configure the parameters with bend stiffnesses varying from 0.001 to ~0.1 - sims[i].params = std::make_shared<PBDModelConfig>(); - sims[i].params->enableConstraint(PbdConstraint::Type::Distance, 1e7); - sims[i].params->enableConstraint(PbdConstraint::Type::Bend, (static_cast<double>(i) * 0.1 / numStrings + 0.001) * 1e6); - sims[i].params->m_fixedNodeIds = { 0 }; - sims[i].params->m_uniformMassValue = 5.0; - sims[i].params->m_gravity = Vec3d(0, -9.8, 0); - sims[i].params->m_defaultDt = 0.0005; - sims[i].params->m_iterations = 5; - - // Set the parameters - sims[i].model->configure(sims[i].params); - sims[i].object->setDynamicalModel(sims[i].model); - sims[i].object->setPhysicsGeometry(sims[i].geometry); - - sims[i].visualModel = std::make_shared<VisualModel>(sims[i].geometry); - auto material = std::make_shared<RenderMaterial>(); - material->setDisplayMode(RenderMaterial::DisplayMode::WireframeSurface); - material->setLineWidth(2.); - material->setPointSize(6.); - material->setColor(Color::lerpRgb(startColor, endColor, static_cast<double>(i) / (numStrings - 1))); - sims[i].visualModel->setRenderMaterial(material); - sims[i].object->addVisualModel(sims[i].visualModel); - - // Add in scene - scene->addSceneObject(sims[i].object); + scene->addSceneObject(obj); } // Adjust the camera @@ -122,20 +171,21 @@ main() scene->getCamera()->setPosition(0.0, 0.0, 15.0); // Move the points every frame - double t = 0.0; - const double dt = 0.0005; - const double radius = 1.5; - auto movePoints = - [&sims, &t, dt, radius](Module* module) + double t = 0.0; + + auto movePoints = + [&pbdStringObjs, &t](Module* module) { - for (unsigned int i = 0; i < sims.size(); i++) + for (unsigned int i = 0; i < pbdStringObjs.size(); i++) { - Vec3d pos = sims[i].model->getCurrentState()->getVertexPosition(0); + std::shared_ptr<PbdModel> model = pbdStringObjs[i]->getPbdModel(); + const Vec3d pos = model->getCurrentState()->getVertexPosition(0); // Move in circle, derivatives of parametric eq of circle - sims[i].model->getCurrentState()->setVertexPosition(0, imstk::Vec3d( + const Vec3d newPos = Vec3d( pos.x() + -std::sin(t) * radius * dt, pos.y(), - pos.z() + std::cos(t) * radius * dt)); + pos.z() + std::cos(t) * radius * dt); + model->getCurrentState()->setVertexPosition(0, newPos); } t += dt; }; @@ -146,4 +196,4 @@ main() simManager->start(); return 0; -} +} \ No newline at end of file diff --git a/Examples/TaskGraph/Configuration/taskGraphConfigureExample.cpp b/Examples/TaskGraph/Configuration/taskGraphConfigureExample.cpp index 6cbfc8178d9da8e1d46a25d73a70e60df1bc9230..959db56f400dfbdac734b864a5d1a69fa95cefa8 100644 --- a/Examples/TaskGraph/Configuration/taskGraphConfigureExample.cpp +++ b/Examples/TaskGraph/Configuration/taskGraphConfigureExample.cpp @@ -22,6 +22,7 @@ #include "imstkAPIUtilities.h" #include "imstkCamera.h" #include "imstkLight.h" +#include "imstkLogger.h" #include "imstkPbdModel.h" #include "imstkPbdObject.h" #include "imstkScene.h" @@ -33,7 +34,7 @@ using namespace imstk; static std::unique_ptr<SurfaceMesh> -makeCloth( +makeClothGeometry( const double width, const double height, const int nRows, const int nCols) { // Create surface mesh @@ -91,23 +92,17 @@ makeClothObj(const std::string& name, double width, double height, int nRows, in { auto clothObj = std::make_shared<PbdObject>(name); - std::shared_ptr<SurfaceMesh> clothMesh(std::move(makeCloth(width, height, nRows, nCols))); + std::shared_ptr<SurfaceMesh> clothMesh(std::move(makeClothGeometry(width, height, nRows, nCols))); // Setup the Parameters auto pbdParams = std::make_shared<PBDModelConfig>(); - pbdParams->m_uniformMassValue = 1.0; + pbdParams->enableConstraint(PbdConstraint::Type::Distance, 1e2); + pbdParams->enableConstraint(PbdConstraint::Type::Dihedral, 1e1); + pbdParams->m_fixedNodeIds = { 0, static_cast<size_t>(nCols) - 1 }; + pbdParams->m_uniformMassValue = width * height / (nRows * nCols); pbdParams->m_gravity = Vec3d(0, -9.8, 0); pbdParams->m_defaultDt = 0.005; pbdParams->m_iterations = 5; - pbdParams->m_viscousDampingCoeff = 0.05; - pbdParams->enableConstraint(PbdConstraint::Type::Distance, 0.1); - pbdParams->enableConstraint(PbdConstraint::Type::Dihedral, 0.001); - std::vector<size_t> fixedNodes(nCols); - for (size_t i = 0; i < fixedNodes.size(); i++) - { - fixedNodes[i] = i; - } - pbdParams->m_fixedNodeIds = fixedNodes; // Setup the Model auto pbdModel = std::make_shared<PbdModel>(); @@ -166,7 +161,7 @@ main() scene->getCamera()->setFocalPoint(0, -5, 5); scene->getCamera()->setPosition(-15., -5.0, 15.0); - // Adds a custom physics step to print out intermediate velocities + // Adds a custom physics step to print out maximum velocity { std::shared_ptr<PbdModel> pbdModel = clothObj->getPbdModel(); scene->setTaskGraphConfigureCallback([&](Scene* scene) @@ -180,22 +175,28 @@ main() writer.setFileName("taskGraphConfigureExampleOld.svg"); writer.write(); - std::shared_ptr<TaskNode> printVelocities = std::make_shared<TaskNode>([&]() + std::shared_ptr<TaskNode> printMaxVelocity = std::make_shared<TaskNode>([&]() { const StdVectorOfVec3d& velocities = *pbdModel->getCurrentState()->getVelocities(); + double maxVel = std::numeric_limits<double>::min(); for (size_t i = 0; i < velocities.size(); i++) { - printf("Velocity: %f, %f, %f\n", velocities[i].x(), velocities[i].y(), velocities[i].z()); + const double vel = velocities[i].squaredNorm(); + if (vel > maxVel) + { + maxVel = vel; + } } - }, "PrintVelocities"); + LOG(INFO) << "Max Velocity: " << std::sqrt(maxVel); + }, "PrintMaxVelocity"); // After IntegratePosition - graph->insertAfter(pbdModel->getIntegratePositionNode(), printVelocities); + graph->insertAfter(pbdModel->getIntegratePositionNode(), printMaxVelocity); // Write the modified graph writer.setFileName("taskGraphConfigureExampleNew.svg"); writer.write(); - }); + }); } // Start diff --git a/Examples/TaskGraph/Timing/taskGraphTimingExample.cpp b/Examples/TaskGraph/Timing/taskGraphTimingExample.cpp index 56f4fdcd40a8d8bf9b53670656717906a844a578..c438c94549a04b57a805af7c4a541b16578d3597 100644 --- a/Examples/TaskGraph/Timing/taskGraphTimingExample.cpp +++ b/Examples/TaskGraph/Timing/taskGraphTimingExample.cpp @@ -32,7 +32,126 @@ limitations under the License. using namespace imstk; /// -/// \brief This examples uses the timing features of the task graph This allows one +/// \brief Create pbd string geometry +/// +static std::shared_ptr<LineMesh> +makeStringGeometry(const Vec3d& pos, const size_t numVerts, const double stringLength) +{ + // Create the geometry + std::shared_ptr<LineMesh> stringGeometry = std::make_shared<LineMesh>(); + + StdVectorOfVec3d vertList; + vertList.resize(numVerts); + const double vertexSpacing = stringLength / numVerts; + for (size_t j = 0; j < numVerts; j++) + { + vertList[j] = pos - Vec3d(0.0, static_cast<double>(j) * vertexSpacing, 0.0); + } + stringGeometry->setInitialVertexPositions(vertList); + stringGeometry->setVertexPositions(vertList); + + // Add connectivity data + std::vector<LineMesh::LineArray> segments; + for (size_t j = 0; j < numVerts - 1; j++) + { + LineMesh::LineArray seg = { j, j + 1 }; + segments.push_back(seg); + } + + stringGeometry->setLinesVertices(segments); + return stringGeometry; +} + +/// +/// \brief Create pbd string object +/// +static std::shared_ptr<PbdObject> +makePbdString( + const std::string& name, + const Vec3d& pos, + const size_t numVerts, + const double stringLength, + const double bendStiffness, + const Color& color) +{ + std::shared_ptr<PbdObject> stringObj = std::make_shared<PbdObject>(name); + + // Setup the Geometry + std::shared_ptr<LineMesh> stringMesh = makeStringGeometry(pos, numVerts, stringLength); + + // Setup the Parameters + auto pbdParams = std::make_shared<PBDModelConfig>(); + pbdParams->enableConstraint(PbdConstraint::Type::Distance, 1e7); + pbdParams->enableConstraint(PbdConstraint::Type::Bend, bendStiffness); + pbdParams->m_fixedNodeIds = { 0 }; + pbdParams->m_uniformMassValue = 5.0; + pbdParams->m_gravity = Vec3d(0, -9.8, 0); + pbdParams->m_defaultDt = 0.0005; + pbdParams->m_iterations = 5; + + // Setup the Model + std::shared_ptr<PbdModel> pbdModel = std::make_shared<PbdModel>(); + pbdModel->setModelGeometry(stringMesh); + pbdModel->configure(pbdParams); + + // Setup the VisualModel + std::shared_ptr<RenderMaterial> material = std::make_shared<RenderMaterial>(); + material->setBackFaceCulling(false); + material->setColor(color); + material->setLineWidth(2.0f); + material->setDisplayMode(RenderMaterial::DisplayMode::Wireframe); + + std::shared_ptr<VisualModel> visualModel = std::make_shared<VisualModel>(stringMesh); + visualModel->setRenderMaterial(material); + + // Setup the Object + stringObj->addVisualModel(visualModel); + stringObj->setPhysicsGeometry(stringMesh); + stringObj->setDynamicalModel(pbdModel); + + return stringObj; +} + +static std::vector<std::shared_ptr<PbdObject>> +makePbdStrings(const size_t numStrings, + const size_t numVerts, + const double stringSpacing, + const double stringLength, + const Color& startColor, + const Color& endColor) +{ + std::vector<std::shared_ptr<PbdObject>> pbdStringObjs(numStrings); + + const double size = stringSpacing * (numStrings - 1); + + for (unsigned int i = 0; i < numStrings; i++) + { + const Vec3d tipPos = Vec3d(static_cast<double>(i) * stringSpacing - size * 0.5, stringLength * 0.5, 0.0); + const double t = static_cast<double>(i) / (numStrings - 1); + + pbdStringObjs[i] = makePbdString( + "String " + std::to_string(i), + tipPos, + numVerts, + stringLength, + (static_cast<double>(i) * 0.1 / numStrings + 0.001) * 1e6, + Color::lerpRgb(startColor, endColor, t)); + } + + return pbdStringObjs; +} + +const double dt = 0.0005; +const double radius = 1.5; +const size_t numStrings = 8; // Number of strings +const size_t numVerts = 30; // Number of vertices on each string +const double stringSpacing = 2.0; // How far each string is apart +const double stringLength = 10.0; // Total length of string +const Color startColor = Color(1.0, 0.0, 0.0); // Color of first string +const Color endColor = Color(0.0, 1.0, 0.0); // Color of last string + +/// +/// \brief This examples uses the timing features of the task graph. This allows one /// to see the elapsed time of every step of iMSTK as well as export the computational /// graph and show information such as the critical path /// @@ -43,80 +162,12 @@ main() auto scene = simManager->createNewScene("PBDString"); scene->getConfig()->taskTimingEnabled = true; - // Setup N separate string simulations with varying bend stiffnesses - const unsigned int numStrings = 8; - const unsigned int numVerts = 30; - const double stringSpacing = 2.0; // How far each string is apart - const double stringLength = 10.0; // Total length of string - const Color startColor = Color::Red; // Color of first string - const Color endColor = Color::Green; // Color of last string - - struct PbdSim + // Setup N separate strings with varying bend stiffnesses + std::vector<std::shared_ptr<PbdObject>> pbdStringObjs = + makePbdStrings(numStrings, numVerts, stringSpacing, stringLength, startColor, endColor); + for (std::shared_ptr<PbdObject> obj : pbdStringObjs) { - std::shared_ptr<LineMesh> geometry; - std::shared_ptr<PbdObject> object; - std::shared_ptr<PbdModel> model; - std::shared_ptr<PBDModelConfig> params; - std::shared_ptr<VisualModel> visualModel; - }; - std::vector<PbdSim> sims(numStrings); - - const double size = stringSpacing * (numStrings - 1); - const double vertexSpacing = stringLength / numVerts; - for (unsigned int i = 0; i < numStrings; i++) - { - // Setup the line mesh - sims[i].geometry = std::make_shared<LineMesh>(); - StdVectorOfVec3d vertList; - vertList.resize(numVerts); - for (size_t j = 0; j < numVerts; j++) - { - vertList[j] = Vec3d( - static_cast<double>(i) * stringSpacing - size * 0.5, - stringLength * 0.5 - static_cast<double>(j) * vertexSpacing, 0.0); - } - sims[i].geometry->setInitialVertexPositions(vertList); - sims[i].geometry->setVertexPositions(vertList); - - // Add connectivity data - std::vector<LineMesh::LineArray> segments; - for (size_t j = 0; j < numVerts - 1; j++) - { - LineMesh::LineArray seg = { j, j + 1 }; - segments.push_back(seg); - } - - sims[i].geometry->setLinesVertices(segments); - - sims[i].object = std::make_shared<PbdObject>("String " + std::to_string(i)); - sims[i].model = std::make_shared<PbdModel>(); - sims[i].model->setModelGeometry(sims[i].geometry); - - // Configure the parameters with bend stiffnesses varying from 0.001 to ~0.1 - sims[i].params = std::make_shared<PBDModelConfig>(); - sims[i].params->enableConstraint(PbdConstraint::Type::Distance, 0.001); - sims[i].params->enableConstraint(PbdConstraint::Type::Bend, static_cast<double>(i) * 0.1 / numStrings + 0.001); - sims[i].params->m_fixedNodeIds = { 0 }; - sims[i].params->m_uniformMassValue = 5.0; - sims[i].params->m_gravity = Vec3d(0, -9.8, 0); - sims[i].params->m_defaultDt = 0.0005; - sims[i].params->m_iterations = 5; - - // Set the parameters - sims[i].model->configure(sims[i].params); - sims[i].object->setDynamicalModel(sims[i].model); - sims[i].object->setPhysicsGeometry(sims[i].geometry); - - sims[i].visualModel = std::make_shared<VisualModel>(sims[i].geometry); - std::shared_ptr<RenderMaterial> material = std::make_shared<RenderMaterial>(); - material->setDisplayMode(RenderMaterial::DisplayMode::Wireframe); - material->setColor(Color::lerpRgb(startColor, endColor, static_cast<double>(i) / (numStrings - 1))); - material->setLineWidth(2.0f); - sims[i].visualModel->setRenderMaterial(material); - sims[i].object->addVisualModel(sims[i].visualModel); - - // Add in scene - scene->addSceneObject(sims[i].object); + scene->addSceneObject(obj); } // Adjust the camera @@ -124,20 +175,21 @@ main() scene->getCamera()->setPosition(0.0, 0.0, 15.0); // Move the points every frame - double t = 0.0; - const double dt = 0.0005; - const double radius = 1.5; - auto movePoints = - [&sims, &t, dt, radius](Module* module) + double t = 0.0; + + auto movePoints = + [&pbdStringObjs, &t](Module* module) { - for (unsigned int i = 0; i < sims.size(); i++) + for (unsigned int i = 0; i < pbdStringObjs.size(); i++) { - Vec3d pos = sims[i].model->getCurrentState()->getVertexPosition(0); + std::shared_ptr<PbdModel> model = pbdStringObjs[i]->getPbdModel(); + const Vec3d pos = model->getCurrentState()->getVertexPosition(0); // Move in circle, derivatives of parametric eq of circle - sims[i].model->getCurrentState()->setVertexPosition(0, imstk::Vec3d( + const Vec3d newPos = Vec3d( pos.x() + -std::sin(t) * radius * dt, pos.y(), - pos.z() + std::cos(t) * radius * dt)); + pos.z() + std::cos(t) * radius * dt); + model->getCurrentState()->setVertexPosition(0, newPos); } t += dt; }; diff --git a/Source/CollisionDetection/CollisionDetection/imstkCollisionUtils.h b/Source/CollisionDetection/CollisionDetection/imstkCollisionUtils.h index f4a8762b6dba288d8d4d806437858aa45f511462..72652233599915cc63fccaf5e61fd03c4c2ae550 100644 --- a/Source/CollisionDetection/CollisionDetection/imstkCollisionUtils.h +++ b/Source/CollisionDetection/CollisionDetection/imstkCollisionUtils.h @@ -29,7 +29,7 @@ namespace imstk namespace CollisionUtils { /// -/// \brief Do ranges [a,b] and [c,d] intersect? +/// \brief Do ranges [\p a,\p b] and [\p c,\p d] intersect? /// inline bool isIntersect(const double a, const double b, const double c, const double d) diff --git a/Source/CollisionDetection/Testing/imstkOctreeBasedCDTest.cpp b/Source/CollisionDetection/Testing/imstkOctreeBasedCDTest.cpp index 479b148074a256aad3e56f37b16a7a61bc863599..302a489fd75ca8c2cc41c6b1c6c6dd1bd64f32c4 100644 --- a/Source/CollisionDetection/Testing/imstkOctreeBasedCDTest.cpp +++ b/Source/CollisionDetection/Testing/imstkOctreeBasedCDTest.cpp @@ -546,6 +546,9 @@ TEST_F(OctreeBasedCDTest, TestMeshMeshUsingSurfaceMeshToSurfaceMeshCD) } } +/// +/// \brief TODO +/// int imstkOctreeBasedCDTest(int argc, char* argv[]) { diff --git a/Source/CollisionDetection/Testing/imstkTetraToTetraCDTest.cpp b/Source/CollisionDetection/Testing/imstkTetraToTetraCDTest.cpp index 423d55cf5cdfad7d6b3f3264f54244e907b8e39b..49536eb89ffde4edffe624c2ef54f9d191d881be 100644 --- a/Source/CollisionDetection/Testing/imstkTetraToTetraCDTest.cpp +++ b/Source/CollisionDetection/Testing/imstkTetraToTetraCDTest.cpp @@ -31,12 +31,18 @@ using namespace imstk; +/// +/// \brief TODO +/// class imstkTetraToTetraCDTest : public ::testing::Test { protected: TetraToTetraCD* m_CD; }; +/// +/// \brief TODO +/// std::shared_ptr<TetrahedralMesh> loadMesh(const std::string& externalDataSuffix) { @@ -49,12 +55,18 @@ loadMesh(const std::string& externalDataSuffix) return volMesh; } +/// +/// \brief TODO +/// std::shared_ptr<TetrahedralMesh> duplicate(std::shared_ptr<TetrahedralMesh> mesh) { return std::make_shared<TetrahedralMesh>(*mesh.get()); } +/// +/// \brief TODO +/// TEST_F(imstkTetraToTetraCDTest, NoSelfIntersection) { std::shared_ptr<TetrahedralMesh> a = loadMesh("/asianDragon/asianDragon.veg"); @@ -71,6 +83,9 @@ TEST_F(imstkTetraToTetraCDTest, NoSelfIntersection) EXPECT_EQ(cd->PTColData.getSize(), 0); } +/// +/// \brief TODO +/// TEST_F(imstkTetraToTetraCDTest, IntersectionThenNoIntersection1T) { std::shared_ptr<TetrahedralMesh> a = loadMesh("/oneTet/oneTet.veg"); @@ -105,6 +120,9 @@ TEST_F(imstkTetraToTetraCDTest, IntersectionThenNoIntersection1T) EXPECT_EQ(cd->PTColData.getSize(), 0); } +/// +/// \brief TODO +/// TEST_F(imstkTetraToTetraCDTest, DISABLED_IntersectionThenNoIntersectionHuman) { std::shared_ptr<TetrahedralMesh> a = loadMesh("/human/human.veg"); @@ -146,6 +164,9 @@ TEST_F(imstkTetraToTetraCDTest, DISABLED_IntersectionThenNoIntersectionHuman) EXPECT_EQ(cd->PTColData.getSize(), 0); } +/// +/// \brief TODO +/// TEST_F(imstkTetraToTetraCDTest, DISABLED_IntersectionOfDifferentMeshes) { std::shared_ptr<TetrahedralMesh> a = loadMesh("/asianDragon/asianDragon.veg"); @@ -157,6 +178,9 @@ TEST_F(imstkTetraToTetraCDTest, DISABLED_IntersectionOfDifferentMeshes) EXPECT_EQ(cd->PTColData.getSize(), 595); } +/// +/// \brief TODO +/// int imstkTetraToTetraCDTest(int argc, char* argv[]) { diff --git a/Source/CollisionHandling/imstkBoneDrillingCH.h b/Source/CollisionHandling/imstkBoneDrillingCH.h index 25bfe35077f74ee10a35943d019d78d16560c8fe..476ec97701262e814ac24cd104313638e0a27f5e 100644 --- a/Source/CollisionHandling/imstkBoneDrillingCH.h +++ b/Source/CollisionHandling/imstkBoneDrillingCH.h @@ -69,12 +69,18 @@ public: /// \brief Get stiffness /// double getStiffness() const { return m_stiffness; } + /// + /// \brief Set stiffness + /// void setStiffness(const double k) { m_stiffness = k; } /// /// \brief Get damping coefficient /// double getDamping() const { return m_damping; } + /// + /// \brief Set damping coefficient + /// void setDamping(const double d) { m_damping = d; } private: diff --git a/Source/CollisionHandling/imstkPenaltyCH.h b/Source/CollisionHandling/imstkPenaltyCH.h index 35b3724034bc90c0cb26bd141eb20640b372f121..a252c55181779efc1abf309010fb6c30e9093c4f 100644 --- a/Source/CollisionHandling/imstkPenaltyCH.h +++ b/Source/CollisionHandling/imstkPenaltyCH.h @@ -57,7 +57,13 @@ public: /// \brief Compute forces based on collision data /// void processCollisionData() override; + /// + /// \brief TODO + /// void computeContactForcesAnalyticRigid(const std::shared_ptr<CollidingObject>& analyticObj); + /// + /// \brief TODO + /// void computeContactForcesDiscreteDeformable(const std::shared_ptr<FeDeformableObject>& deformableObj); /// diff --git a/Source/Common/Parallel/imstkParallelReduce.h b/Source/Common/Parallel/imstkParallelReduce.h index 26a72af7b7638d3653e0a7b06aa0df94b21ba165..f26c0e7e76887f3a5cea161458507805c3b4c54f 100644 --- a/Source/Common/Parallel/imstkParallelReduce.h +++ b/Source/Common/Parallel/imstkParallelReduce.h @@ -76,6 +76,9 @@ public: AABBFunctor() = delete; AABBFunctor& operator=(const AABBFunctor&) = delete; + /// + /// \brief Compute the lower and upper corner of \p this in range \p r + /// void operator()(const tbb::blocked_range<size_t>& r) { for (size_t i = r.begin(); i != r.end(); ++i) @@ -89,6 +92,9 @@ public: } } + /// + /// \brief Compute the AABB of \p this and anohter object \p pObj as a whole + /// void join(AABBFunctor& pObj) { for (int j = 0; j < 3; ++j) @@ -98,7 +104,13 @@ public: } } + /// + /// \brief Get the lower corner + /// const Vec3r& getLowerCorner() const { return m_LowerCorner; } + /// + /// \brief Get the upper corner + /// const Vec3r& getUpperCorner() const { return m_UpperCorner; } private: diff --git a/Source/Common/Testing/imstkModuleTest.cpp b/Source/Common/Testing/imstkModuleTest.cpp index 32719c77b0377d2c9c8f84261f00b6c1fe5c8077..c86ed5936381f35294d14413aa70100d6f9f9d38 100644 --- a/Source/Common/Testing/imstkModuleTest.cpp +++ b/Source/Common/Testing/imstkModuleTest.cpp @@ -31,6 +31,9 @@ namespace imstk { +/// +/// \brief TODO +/// class ModuleMock : public Module { public: @@ -52,6 +55,9 @@ protected: using namespace imstk; +/// +/// \brief TODO +/// class imstkModuleTest : public ::testing::Test { protected: @@ -192,6 +198,9 @@ TEST_F(imstkModuleTest, ControlModule) t.join(); } +/// +/// \brief TODO +/// int imstkModuleTest(int argc, char* argv[]) { diff --git a/Source/Common/imstkLogger.h b/Source/Common/imstkLogger.h index 487711ce43728762b8b480ad9693f17765b2669e..3485c10d0c0f58bf8aec750a17ff75a05cf1960e 100644 --- a/Source/Common/imstkLogger.h +++ b/Source/Common/imstkLogger.h @@ -76,6 +76,9 @@ using StdoutSinkHandle = g3::SinkHandle<stdSink>; class Logger { public: + /// + /// \brief TODO + /// static Logger& getInstance() { // Thread safe in C++11 ("magic statics") diff --git a/Source/Common/imstkModule.h b/Source/Common/imstkModule.h index d9c1efadb2aa9d9a32e7c5d634f634e1add16382..9344e78233746276285089187cbea69fff6cb921 100644 --- a/Source/Common/imstkModule.h +++ b/Source/Common/imstkModule.h @@ -83,10 +83,19 @@ public: /// void end(); + /// + /// \brief Set callback function for initialization + /// inline void setPreInitCallback(CallbackFunction foo) { m_preInitCallback = foo; } inline void setPostInitCallback(CallbackFunction foo) { m_postInitCallback = foo; } + /// + /// \brief Set callback function for update + /// inline void setPreUpdateCallback(CallbackFunction foo) { m_preUpdateCallback = foo; } inline void setPostUpdateCallback(CallbackFunction foo) { m_postUpdateCallback = foo; } + /// + /// \brief Set callback function for cleanup + /// inline void setPreCleanUpCallback(CallbackFunction foo) { m_preCleanUpCallback = foo; } inline void setPostCleanUpCallback(CallbackFunction foo) { m_postCleanUpCallback = foo; } @@ -120,8 +129,16 @@ public: /// void setFrequency(const double f); + /// + /// \brief Enable frame count + /// void enableFrameCount() { m_trackFPS = true; }; + /// + /// \brief Disable frame count + /// void disableFrameCount() { m_trackFPS = false; }; + + /// \return true is frame count is already enabled bool isFrameCountEnabled() const { return m_trackFPS; }; unsigned int getUPS(); diff --git a/Source/Constraint/PbdConstraints/imstkPbdConstraint.h b/Source/Constraint/PbdConstraints/imstkPbdConstraint.h index df262bde52637e109077a4004ccf9e765b8521a0..d3c2336fd843ddf8cf9fe3554e237e763ced6002 100644 --- a/Source/Constraint/PbdConstraints/imstkPbdConstraint.h +++ b/Source/Constraint/PbdConstraints/imstkPbdConstraint.h @@ -122,6 +122,7 @@ public: /// \brief Update positions by projecting constraints. /// virtual void projectConstraint(const StdVectorOfReal& currInvMasses, const double dt, const SolverType& type, StdVectorOfVec3d& pos); + protected: std::vector<size_t> m_vertexIds; ///> index of points for the constraint double m_epsilon = 1.0e-16; ///> Tolerance used for the costraints diff --git a/Source/Controllers/imstkCameraController.h b/Source/Controllers/imstkCameraController.h index 0cb899f40f8e78c87d5601c54e1557115b57d447..2e7272ba097eede43a09324ecd552fc4c4e72eec 100644 --- a/Source/Controllers/imstkCameraController.h +++ b/Source/Controllers/imstkCameraController.h @@ -37,7 +37,7 @@ class CameraController : public Module, public DeviceTracker { public: /// - /// \brief + /// \brief TODO /// CameraController(std::shared_ptr<Camera> camera, std::shared_ptr<DeviceClient> deviceClient); @@ -65,17 +65,17 @@ public: protected: /// - /// \brief + /// \brief TODO /// virtual void initModule() override {}; /// - /// \brief + /// \brief TODO /// virtual void runModule() override; /// - /// \brief + /// \brief TODO /// void cleanUpModule() override {}; diff --git a/Source/Controllers/imstkDeviceTracker.h b/Source/Controllers/imstkDeviceTracker.h index aca78be53703651f05a2da9e0385872649dbd32d..6b6914f382766a01315448f7872137cf89c202f3 100644 --- a/Source/Controllers/imstkDeviceTracker.h +++ b/Source/Controllers/imstkDeviceTracker.h @@ -36,6 +36,10 @@ class DeviceTracker { public: + /// + /// \enum + /// \brief TODO + /// enum InvertFlag { transX = 0x01, diff --git a/Source/DataStructures/Testing/imstkLooseOctreeTest.cpp b/Source/DataStructures/Testing/imstkLooseOctreeTest.cpp index e7d88ff03acddd542e4ba2b2c9ce1f37330cff2d..f012ed0a4fa139ec3d63e56a8ba7c6ca670a16d2 100644 --- a/Source/DataStructures/Testing/imstkLooseOctreeTest.cpp +++ b/Source/DataStructures/Testing/imstkLooseOctreeTest.cpp @@ -139,16 +139,25 @@ randomizePositions(const std::shared_ptr<SurfaceMesh>& mesh) namespace imstk { +/// +/// \brief TODO +/// class LooseOctreeTest : public ::testing::Test { public: LooseOctreeTest() {} + /// + /// \brief TODO + /// void reset() { m_Octree.reset(new LooseOctree(Vec3d(0, 0, 0), 100.0, 0.1, 4)); } + /// + /// \brief TODO + /// void buildExample() { reset(); @@ -168,6 +177,9 @@ public: m_Octree->build(); } + /// + /// \brief TODO + /// void testOctree() { m_Octree->update(); @@ -253,6 +265,9 @@ public: } } + /// + /// \brief TODO + /// void testDummyPrimitives(bool bRebuild) { // Test points @@ -368,6 +383,9 @@ TEST_F(LooseOctreeTest, TestDummyPrimitives) testDummyPrimitives(false); } +/// +/// \brief TODO +/// int imstkLooseOctreeTest(int argc, char* argv[]) { diff --git a/Source/DataStructures/Testing/imstkNeighborSearchTest.cpp b/Source/DataStructures/Testing/imstkNeighborSearchTest.cpp index e7efbd15d488597d469a37afb6efd39effd16a4f..f83dcd2c441b32ecb0142d114767b9347bf23772 100644 --- a/Source/DataStructures/Testing/imstkNeighborSearchTest.cpp +++ b/Source/DataStructures/Testing/imstkNeighborSearchTest.cpp @@ -311,6 +311,9 @@ TEST_F(dummyClass, TestGridSearchFromDifferentPointSet) } } +/// +/// \brief TODO +/// int imstkNeighborSearchTest(int argc, char* argv[]) { diff --git a/Source/DataStructures/imstkSpatialHashTableSeparateChaining.h b/Source/DataStructures/imstkSpatialHashTableSeparateChaining.h index 83292740955320e81563c0bb1652238db2d2132b..84b4bafd4dfb7b33d5de20591b187d703e2782ed 100644 --- a/Source/DataStructures/imstkSpatialHashTableSeparateChaining.h +++ b/Source/DataStructures/imstkSpatialHashTableSeparateChaining.h @@ -38,6 +38,10 @@ struct PointEntry namespace std { +/// +/// \struct hash +/// \brief Returns a hash value for a \ref PointEntry +/// template<> struct hash<imstk::PointEntry> { size_t operator()(const imstk::PointEntry& point) const @@ -50,6 +54,10 @@ template<> struct hash<imstk::PointEntry> } }; +/// +/// \struct equal_to +/// \brief Test if two points are the same or not by comparing their id and coordinates +/// template<> struct equal_to<imstk::PointEntry> { size_t operator()(const imstk::PointEntry& point1, const imstk::PointEntry& point2) const diff --git a/Source/Devices/imstkVRPNArduinoDeviceClient.h b/Source/Devices/imstkVRPNArduinoDeviceClient.h index c47b61c752b094a32407b1773c3a3f416ebf7f81..728d2e53ddf06b86da07fa8b7cf7fc02d0d21272 100644 --- a/Source/Devices/imstkVRPNArduinoDeviceClient.h +++ b/Source/Devices/imstkVRPNArduinoDeviceClient.h @@ -53,9 +53,19 @@ public: virtual ~VRPNArduinoDeviceClient() {} + /// + /// \brief Get YPR + /// Vec3d& getYPR() { return m_ypr; } + /// + /// \brief Get acceleration + /// Vec3d& getAcceleration() { return m_accel; } + + /// + /// \brief Get the roll + /// float getRoll() { return m_roll; } protected: diff --git a/Source/Devices/imstkVRPNDeviceServer.h b/Source/Devices/imstkVRPNDeviceServer.h index 430f6846f9e44db7e208af2a5fe70010ddd59ccd..ea36587b654fef45adb9f0f7af9aebd8e6466aa2 100644 --- a/Source/Devices/imstkVRPNDeviceServer.h +++ b/Source/Devices/imstkVRPNDeviceServer.h @@ -98,6 +98,10 @@ protected: private: + /// + /// \struct + /// \brief TODO + /// struct SerialInfo { int baudRate; diff --git a/Source/DynamicalModels/InternalForceModel/imstkCorotationalFEMForceModel.h b/Source/DynamicalModels/InternalForceModel/imstkCorotationalFEMForceModel.h index 0608b49e089fbc6cd8cc9c00c478bbc161d4485d..bd9337ba0e05a228bfef1e051b9c5148a7226f86 100644 --- a/Source/DynamicalModels/InternalForceModel/imstkCorotationalFEMForceModel.h +++ b/Source/DynamicalModels/InternalForceModel/imstkCorotationalFEMForceModel.h @@ -42,7 +42,8 @@ class CorotationalFEMForceModel : public InternalForceModel { public: /// - /// \brief + /// \brief Constructor using \p mesh + /// \param warp if use warp /// explicit CorotationalFEMForceModel(std::shared_ptr<vega::VolumetricMesh> mesh, const int warp = 1); CorotationalFEMForceModel() = delete; @@ -53,32 +54,32 @@ public: virtual ~CorotationalFEMForceModel() = default; /// - /// \brief + /// \brief Compute internal force \p internalForce at state \p u /// void getInternalForce(const Vectord& u, Vectord& internalForce) override; /// - /// \brief + /// \brief Compute stiffness matrix \p tangentStiffnessMatrix at state \u /// void getTangentStiffnessMatrix(const Vectord& u, SparseMatrixd& tangentStiffnessMatrix) override; /// - /// \brief + /// \brief Build the sparsity pattern for stiffness matrix /// void getTangentStiffnessMatrixTopology(vega::SparseMatrix** tangentStiffnessMatrix) override; /// - /// \brief + /// \brief Compute internal force \p internalForce and stiffness matrix \p tangentStiffnessMatrix at state \u /// void getForceAndMatrix(const Vectord& u, Vectord& internalForce, SparseMatrixd& tangentStiffnessMatrix) override; /// - /// \brief + /// \brief Turn on/off warp /// void setWarp(const int warp); /// - /// \brief + /// \brief Specify tangent stiffness matrix /// void setTangentStiffness(std::shared_ptr<vega::SparseMatrix> K) override; diff --git a/Source/DynamicalModels/InternalForceModel/imstkInternalForceModel.h b/Source/DynamicalModels/InternalForceModel/imstkInternalForceModel.h index c8b5e17c771d8514cb8ec3a9e6881e6dafe5f122..09fc5adf65107e09dbf3493005538ac9c90f11da 100644 --- a/Source/DynamicalModels/InternalForceModel/imstkInternalForceModel.h +++ b/Source/DynamicalModels/InternalForceModel/imstkInternalForceModel.h @@ -53,22 +53,22 @@ public: virtual ~InternalForceModel() = default; /// - /// \brief Get the internal force given the present state + /// \brief Compute internal force \p internalForce at state \p u /// virtual void getInternalForce(const Vectord& u, Vectord& internalForce) = 0; /// - /// \brief Return the tangent stiffness matrix the present state + /// \brief Compute stiffness matrix \p tangentStiffnessMatrix at state \u /// virtual void getTangentStiffnessMatrix(const Vectord& u, SparseMatrixd& tangentStiffnessMatrix) = 0; /// - /// \brief Return the tangent stiffness matrix the present state + /// \brief Build the sparsity pattern for stiffness matrix /// virtual void getTangentStiffnessMatrixTopology(vega::SparseMatrix** tangentStiffnessMatrix) = 0; /// - /// \brief Return both internal force and tangent stiffness matrix given the present state + /// \brief Compute both internal force \p internalForce and stiffness matrix \p tangentStiffnessMatrix at state \u /// virtual void getForceAndMatrix(const Vectord& u, Vectord& internalForce, SparseMatrixd& tangentStiffnessMatrix) = 0; @@ -78,7 +78,7 @@ public: static void updateValuesFromMatrix(std::shared_ptr<vega::SparseMatrix> vegaMatrix, double* values); /// - /// \brief + /// \brief Specify tangent stiffness matrix /// virtual void setTangentStiffness(std::shared_ptr<vega::SparseMatrix> K) = 0; }; diff --git a/Source/DynamicalModels/InternalForceModel/imstkInternalForceModelTypes.h b/Source/DynamicalModels/InternalForceModel/imstkInternalForceModelTypes.h index 6c47031ab8dff05b471e9cd19fb862d9b1807b6b..2889185fd72a34d93ddc123c583457362a7ee6a3 100644 --- a/Source/DynamicalModels/InternalForceModel/imstkInternalForceModelTypes.h +++ b/Source/DynamicalModels/InternalForceModel/imstkInternalForceModelTypes.h @@ -23,6 +23,10 @@ namespace imstk { +/// +/// \enum class +/// \brief Finite element material type +/// enum class FEMMethodType { StVK, diff --git a/Source/DynamicalModels/InternalForceModel/imstkLinearFEMForceModel.h b/Source/DynamicalModels/InternalForceModel/imstkLinearFEMForceModel.h index 7282614a67f0c09ea4672acd4e7b19694f04df46..28ebf8c784f188a446bf5cea009800835c4a71ed 100644 --- a/Source/DynamicalModels/InternalForceModel/imstkLinearFEMForceModel.h +++ b/Source/DynamicalModels/InternalForceModel/imstkLinearFEMForceModel.h @@ -77,7 +77,7 @@ public: }; /// - /// \brief Get the internal force + /// \brief Compute the internal force /// inline void getInternalForce(const Vectord& u, Vectord& internalForce) override { diff --git a/Source/DynamicalModels/InternalForceModel/imstkStVKForceModel.h b/Source/DynamicalModels/InternalForceModel/imstkStVKForceModel.h index 7e06e4742866a938a2a06ed54bb4c0b844f35398..dbd5837d25874ecdab899c9cd8ac2b4c409b0b92 100644 --- a/Source/DynamicalModels/InternalForceModel/imstkStVKForceModel.h +++ b/Source/DynamicalModels/InternalForceModel/imstkStVKForceModel.h @@ -95,7 +95,7 @@ public: } /// - /// \brief + /// \brief Speficy tangent stiffness matrix /// inline void setTangentStiffness(std::shared_ptr<vega::SparseMatrix> K) override { diff --git a/Source/DynamicalModels/ObjectModels/imstkFEMDeformableBodyModel.h b/Source/DynamicalModels/ObjectModels/imstkFEMDeformableBodyModel.h index 01c1b9ea94fd57850b15fff607979ac2a1a487ae..97d0f58d9ddd234aed821f806921b2519edcae0b 100644 --- a/Source/DynamicalModels/ObjectModels/imstkFEMDeformableBodyModel.h +++ b/Source/DynamicalModels/ObjectModels/imstkFEMDeformableBodyModel.h @@ -42,6 +42,9 @@ class TimeIntegrator; class SolverBase; class VegaMeshIO; +/// +/// \strut FEMModelConfig +/// \brief Parameters for finite element model struct FEMModelConfig { FEMMethodType m_femMethod = FEMMethodType::Invertible; @@ -64,7 +67,7 @@ struct FEMModelConfig /// \class FEMDeformableBodyModel /// /// \brief Mathematical model of the physics governing the dynamic deformable object -/// Note: Vega specifics will removed in future when the inertial and damping calculations +/// \note Vega specifics will removed in future when the inertial and damping calculations /// are done with in-house code /// class FEMDeformableBodyModel : public DynamicalModel<FeDeformBodyState> @@ -268,6 +271,9 @@ public: std::shared_ptr<TaskNode> getSolveNode() const { return m_solveNode; } + /// + /// \brief Get/Set the solver pointer + /// std::shared_ptr<SolverBase> getSolver() const { return m_solver; } void setSolver(std::shared_ptr<SolverBase> solver) { this->m_solver = solver; } diff --git a/Source/DynamicalModels/ObjectModels/imstkPbdModel.h b/Source/DynamicalModels/ObjectModels/imstkPbdModel.h index 3cb8f5f587db0eb0be2026b6763c9edc72606856..691ad576ccbb71b76fd6e08cfdfaf8a8c7c5c5af 100644 --- a/Source/DynamicalModels/ObjectModels/imstkPbdModel.h +++ b/Source/DynamicalModels/ObjectModels/imstkPbdModel.h @@ -200,12 +200,12 @@ public: double getDefaultTimeStep() const { return m_parameters->m_defaultDt; } /// - /// \brief + /// \brief Return all constraints that are solved sequentially /// std::shared_ptr<PBDConstraintVector> getConstraints() { return m_constraints; } /// - /// \brief + /// \brief Return the constraints that are colored and run in parallel /// std::shared_ptr<std::vector<PBDConstraintVector>> getPartitionedConstraints() { return m_partitionedConstraints; } diff --git a/Source/DynamicalModels/ObjectModels/imstkRigidBodyModel.h b/Source/DynamicalModels/ObjectModels/imstkRigidBodyModel.h index 7c9e020342cfe46e1bfbcbff817a80e89916bcd7..89a90ee285d6e7c003d07992c8954ce009e621bd 100644 --- a/Source/DynamicalModels/ObjectModels/imstkRigidBodyModel.h +++ b/Source/DynamicalModels/ObjectModels/imstkRigidBodyModel.h @@ -107,7 +107,7 @@ public: void setKinematicTarget(const PxTransform& destination); /// - /// \brief + /// \brief Get the pointer to \ref RigidBodyWorld /// RigidBodyWorld* getRigidBodyWorld() { return m_rigidBodyWorld; } @@ -127,6 +127,9 @@ public: /// double getTimeStep() const { return 0; } + /// + /// \brief Reset to initial state + /// void resetToInitialState() override { if (m_pxDynamicActor) @@ -158,6 +161,9 @@ protected: private: RigidBodyWorld* m_rigidBodyWorld = NULL; + /// + /// \brief TODO + /// PxTriangleMesh* createBV34TriangleMesh(PxU32 numVertices, const PxVec3* vertices, PxU32 numTriangles, @@ -167,11 +173,26 @@ private: bool inserted, const PxU32 numTrisPerLeaf); + /// + /// \brief TODO + /// void setupCommonCookingParams(PxCookingParams& params, bool skipMeshCleanup, bool skipEdgeData); + /// + /// \brief TODO + /// void createSphere(); + /// + /// \brief TODO + /// void createPlane(); + /// + /// \brief TODO + /// void createCube(); + /// + /// \brief TODO + /// void createMesh(); }; -} // imstk \ No newline at end of file +} // imstk diff --git a/Source/DynamicalModels/ObjectModels/imstkSPHKernels.h b/Source/DynamicalModels/ObjectModels/imstkSPHKernels.h index 7b0030908c6dc951e14e79880563d32f94cde31d..beb5777955b2f7a68c4e4717d0fe8c73c3e04c77 100644 --- a/Source/DynamicalModels/ObjectModels/imstkSPHKernels.h +++ b/Source/DynamicalModels/ObjectModels/imstkSPHKernels.h @@ -31,6 +31,10 @@ namespace imstk { namespace SPH { +/// +/// \class Poly6Kernel +/// \brief The poly6 Kernel +/// template<int N> class Poly6Kernel { @@ -136,6 +140,10 @@ protected: Real m_W0; ///> Precomputed W(0) }; +/// +/// \class SpikyKernel +/// \brief Spiky Kernel +/// template<int N> class SpikyKernel { @@ -221,6 +229,10 @@ protected: Real m_W0; ///> Precomputed W(0) }; +/// +/// \class CohesionKernel +/// \brief Cohesion Kernel +/// template<int N> class CohesionKernel { @@ -311,6 +323,10 @@ protected: Real m_W0; ///> Precomputed W(0) }; +/// +/// \class AdhesionKernel +/// \brief Adhesion kernel +/// template<int N> class AdhesionKernel { @@ -386,6 +402,10 @@ protected: Real m_W0; ///> Precomputed W(0) }; +/// +/// \class ViscosityKernel +/// \brief Viscosity kernel +/// template<int N> class ViscosityKernel { @@ -437,6 +457,9 @@ protected: class SPHSimulationKernels { public: + /// + /// \brief Initialize with kernel radius \p kernelRadius + /// void initialize(const Real kernelRadius) { m_poly6.setRadius(kernelRadius); diff --git a/Source/Geometry/Analytic/imstkAnalyticalGeometry.h b/Source/Geometry/Analytic/imstkAnalyticalGeometry.h index d129df16332a7d1b02c4267c9713777fcda5157d..a58fccc6e0287646ee0d7fac81cb48b1ab137802 100644 --- a/Source/Geometry/Analytic/imstkAnalyticalGeometry.h +++ b/Source/Geometry/Analytic/imstkAnalyticalGeometry.h @@ -58,8 +58,17 @@ protected: explicit AnalyticalGeometry(Type type, const std::string& name = std::string("")); + /// + /// \brief Apply translation vector \p t + /// void applyTranslation(const Vec3d t) override; + /// + /// \brief Apply rotation matrix \p r + /// void applyRotation(const Mat3d r) override; + /// + /// \brief Update point positions + /// virtual void updatePostTransformData() const override; Vec3d m_position; ///> position diff --git a/Source/Geometry/Decal/imstkDecalPool.h b/Source/Geometry/Decal/imstkDecalPool.h index e19a847c8bbbcf775838aa07b57a59b5c79f1559..35c4ec5e3dd3eb4b8af5a5ae2ab2b4beb68009ef 100644 --- a/Source/Geometry/Decal/imstkDecalPool.h +++ b/Source/Geometry/Decal/imstkDecalPool.h @@ -35,16 +35,35 @@ class DecalPool : public Geometry public: DecalPool(unsigned int maxNumDecals = 128, const std::string& name = std::string("")); + /// + /// \brief Add a \ref Decal object to this pool + /// std::shared_ptr<Decal> addDecal(); + /// + /// \brief Remove a \ref Decal object to this pool + /// void removeDecal(); + /// + /// \brief Get all decals + /// std::deque<std::shared_ptr<Decal>>& getDecals(); + /// + /// \brief Set/Get recyle + /// void setRecycle(bool recycle); bool getRecycle(); + /// + /// \brief Get the number of decals + /// unsigned int getNumDecals(); + + /// + /// \brief Get the max number of decals + /// unsigned int getMaxNumDecals(); /// diff --git a/Source/Geometry/Mesh/imstkSurfaceMesh.h b/Source/Geometry/Mesh/imstkSurfaceMesh.h index 5e73e98a458b818f4862765a02c6985934a4036d..d3d439f459a71d57b562436665b3aefd590fd900 100644 --- a/Source/Geometry/Mesh/imstkSurfaceMesh.h +++ b/Source/Geometry/Mesh/imstkSurfaceMesh.h @@ -40,9 +40,12 @@ struct NormalGroup }; } -// This method is defined to allow for the map to be properly indexed by Texture objects namespace std { +/// +/// \struct less +/// \brief This method is defined to allow for the map to be properly indexed by Texture objects +/// template<> struct less<imstk::NormalGroup> { bool operator()(const imstk::NormalGroup& group1, diff --git a/Source/Geometry/Mesh/imstkTetrahedralMesh.h b/Source/Geometry/Mesh/imstkTetrahedralMesh.h index 0324193bddb08b788bcfb24b495d6abfc8c2df74..a01a7b16af012a47d0b1fb321927ada198f9a320 100644 --- a/Source/Geometry/Mesh/imstkTetrahedralMesh.h +++ b/Source/Geometry/Mesh/imstkTetrahedralMesh.h @@ -79,6 +79,7 @@ public: /// (b) Checks and flips the triangle connectivity order if it is not consistent /// (c) Renumbers the vertices /// (d) optionally enforces the consistency of winding of resulting surface triangles + /// bool extractSurfaceMesh(std::shared_ptr<SurfaceMesh> surfaceMesh, const bool enforceWindingConsistency = false); /// diff --git a/Source/Geometry/Particles/imstkRenderParticles.h b/Source/Geometry/Particles/imstkRenderParticles.h index 9e65f0caae6ee000f600b7af1f2f2f07728fe641..7199f0ff7b31d356f25ca7179d4986f542f0216c 100644 --- a/Source/Geometry/Particles/imstkRenderParticles.h +++ b/Source/Geometry/Particles/imstkRenderParticles.h @@ -103,7 +103,7 @@ public: /// /// \brief Get volume - /// As these are particles, the volume is 0 + /// \note As these are particles, the volume is 0 /// double getVolume() const override { return 0; } diff --git a/Source/Geometry/Testing/imstkCubeTest.cpp b/Source/Geometry/Testing/imstkCubeTest.cpp index 12bb5f2961816d62d9b142b776abd17cbea2951f..d317df1e162c2936b73a697c6f4800825427eff3 100644 --- a/Source/Geometry/Testing/imstkCubeTest.cpp +++ b/Source/Geometry/Testing/imstkCubeTest.cpp @@ -32,6 +32,9 @@ protected: Cube m_cube; }; +/// +/// \brief TODO +/// TEST_F(imstkCubeTest, SetGetWidth) { m_cube.setWidth(2); @@ -50,6 +53,9 @@ TEST_F(imstkCubeTest, SetGetWidth) EXPECT_GT(m_cube.getWidth(), 0); } +/// +/// \brief TODO +/// TEST_F(imstkCubeTest, GetVolume) { m_cube.setWidth(2); @@ -63,6 +69,9 @@ TEST_F(imstkCubeTest, GetVolume) EXPECT_EQ(m_cube.getVolume(), w * w * w); } +/// +/// \brief TODO +/// int imstkCubeTest(int argc, char* argv[]) { diff --git a/Source/Geometry/Testing/imstkGeometryTest.cpp b/Source/Geometry/Testing/imstkGeometryTest.cpp index af0f761a45d60ca8f5d9a58f8f41aa8bf6799598..834996391ea245cf21b063d00f178ca4390350ba 100644 --- a/Source/Geometry/Testing/imstkGeometryTest.cpp +++ b/Source/Geometry/Testing/imstkGeometryTest.cpp @@ -27,12 +27,18 @@ using namespace imstk; +/// +/// \brief TODO +/// class imstkGeometryTest : public ::testing::Test { protected: Plane m_geometry; // Can't use imstk::Geometry since pure virtual. Should use google mock class. }; +/// +/// \brief TODO +/// TEST_F(imstkGeometryTest, GetSetScaling) { m_geometry.setScaling(2); @@ -51,6 +57,9 @@ TEST_F(imstkGeometryTest, GetSetScaling) EXPECT_GT(m_geometry.getScaling(), 0); } +/// +/// \brief TODO +/// TEST_F(imstkGeometryTest, GetSetTranslation) { auto p1 = Vec3d(12, 0.0005, -400000); @@ -69,6 +78,9 @@ TEST_F(imstkGeometryTest, GetSetTranslation) EXPECT_EQ(m_geometry.getTranslation(), p2); } +/// +/// \brief TODO +/// TEST_F(imstkGeometryTest, GetSetRotation) { auto angle1 = 15; @@ -99,6 +111,9 @@ TEST_F(imstkGeometryTest, GetSetRotation) EXPECT_TRUE(m_geometry.getRotation().isApprox(mat3)); } +/// +/// \brief TODO +/// int imstkGeometryTest(int argc, char* argv[]) { diff --git a/Source/Geometry/Testing/imstkPlaneTest.cpp b/Source/Geometry/Testing/imstkPlaneTest.cpp index 6e43df63a97a245274c7913667c724973ffb30fb..7d50d6a08e453defd0b1097e88570919103f79ac 100644 --- a/Source/Geometry/Testing/imstkPlaneTest.cpp +++ b/Source/Geometry/Testing/imstkPlaneTest.cpp @@ -26,12 +26,18 @@ #include "imstkPlane.h" using namespace imstk; +/// +/// \brief TODO +/// class imstkPlaneTest : public ::testing::Test { protected: Plane m_plane; }; +/// +/// \brief TODO +/// TEST_F(imstkPlaneTest, SetGetWidth) { m_plane.setWidth(2); @@ -50,6 +56,9 @@ TEST_F(imstkPlaneTest, SetGetWidth) EXPECT_GT(m_plane.getWidth(), 0); } +/// +/// \brief TODO +/// TEST_F(imstkPlaneTest, SetGetNormal) { Vec3d n1 = Vec3d(0.2, -0.3, 0.9); @@ -69,11 +78,17 @@ TEST_F(imstkPlaneTest, SetGetNormal) EXPECT_FALSE(m_plane.getNormal().isApprox(Vec3d(0, 0, 0))); } +/// +/// \brief TODO +/// TEST_F(imstkPlaneTest, GetVolume) { EXPECT_EQ(m_plane.getVolume(), 0); } +/// +/// \brief TODO +/// int imstkPlaneTest(int argc, char* argv[]) { diff --git a/Source/Geometry/Testing/imstkSphereTest.cpp b/Source/Geometry/Testing/imstkSphereTest.cpp index 304c500bf001b88403da2f0263d78c7d54eb28c4..38fc48c358fba5aee70cff0bbd183cc2683d1791 100644 --- a/Source/Geometry/Testing/imstkSphereTest.cpp +++ b/Source/Geometry/Testing/imstkSphereTest.cpp @@ -26,12 +26,18 @@ #include "imstkSphere.h" using namespace imstk; +/// +/// \brief TODO +/// class imstkSphereTest : public ::testing::Test { protected: Sphere m_sphere; }; +/// +/// \brief TODO +/// TEST_F(imstkSphereTest, SetGetRadius) { m_sphere.setRadius(2); @@ -63,6 +69,9 @@ TEST_F(imstkSphereTest, GetVolume) EXPECT_EQ(m_sphere.getVolume(), 4.0 / 3.0 * PI * r * r * r); } +/// +/// \brief TODO +/// int imstkSphereTest(int argc, char* argv[]) { diff --git a/Source/MeshIO/imstkVTKMeshIO.h b/Source/MeshIO/imstkVTKMeshIO.h index b6d1e96730488bb5b1c7be4ca5ba6c70829c2639..08d53279b01139c19e23ff9d77e2d0bdae4e115f 100644 --- a/Source/MeshIO/imstkVTKMeshIO.h +++ b/Source/MeshIO/imstkVTKMeshIO.h @@ -109,19 +109,19 @@ protected: static bool writeVtkUnstructuredGrid(const std::shared_ptr<HexahedralMesh> hMesh, const std::string& filePath); /// - /// \brief + /// \brief Reads vtk unstructured grid /// template<typename ReaderType> static std::shared_ptr<VolumetricMesh> readVtkUnstructuredGrid(const std::string& filePath); /// - /// \brief + /// \brief Reads vtk image data /// template<typename ReaderType> static std::shared_ptr<ImageData> readVtkImageData(const std::string& filePath); /// - /// \brief + /// \brief TODO /// static std::shared_ptr<ImageData> readVtkImageDataDICOM(const std::string& filePath); }; diff --git a/Source/Rendering/Materials/imstkRenderMaterial.h b/Source/Rendering/Materials/imstkRenderMaterial.h index df67a6c18f3ad6717361c33be69749222ef7e68e..9f3364a447d2a644d99da57742a98f970522e171 100644 --- a/Source/Rendering/Materials/imstkRenderMaterial.h +++ b/Source/Rendering/Materials/imstkRenderMaterial.h @@ -28,9 +28,14 @@ namespace imstk { class Texture; +/// +/// \class RenderMaterial +/// \brief TODO +/// class RenderMaterial { public: + /// Display mode for the scene objects enum class DisplayMode { Surface, diff --git a/Source/Rendering/Materials/imstkTexture.h b/Source/Rendering/Materials/imstkTexture.h index 90d3538b0d33376a61b4af237cda7094384bf8f8..19ec07e6a925afdc4e4654e486fd7ff15528e23a 100644 --- a/Source/Rendering/Materials/imstkTexture.h +++ b/Source/Rendering/Materials/imstkTexture.h @@ -55,6 +55,9 @@ public: None }; + /// + /// \brief TODO + /// enum class FileType { Unknown, @@ -129,9 +132,12 @@ protected: }; } -// This method is defined to allow for the map to be properly indexed by Texture objects namespace std { +/// +/// \struct less +/// \brief This method is defined to allow for the map to be properly indexed by Texture objects +/// template<> struct less<std::shared_ptr<imstk::Texture>> { bool operator()(const std::shared_ptr<imstk::Texture>& texture1, diff --git a/Source/Rendering/Materials/imstkVolumeRenderMaterialPresets.h b/Source/Rendering/Materials/imstkVolumeRenderMaterialPresets.h index b791d7ec96b7de0782a2ad14c45b695a6e34d10e..6ad6c443d1d7fb487afb71d4e1191f8d3a43fc41 100644 --- a/Source/Rendering/Materials/imstkVolumeRenderMaterialPresets.h +++ b/Source/Rendering/Materials/imstkVolumeRenderMaterialPresets.h @@ -28,6 +28,9 @@ namespace imstk // forward declarations class VolumeRenderMaterial; +/// +/// \brief TODO +/// class VolumeRenderMaterialPresets { public: @@ -62,6 +65,9 @@ public: NUM_PRESETS }; + /// + /// \brief TODO + /// static std::shared_ptr<VolumeRenderMaterial> getPreset(int p = CT_BONES); // Convenience API to get preset names diff --git a/Source/Rendering/VTKRenderer/imstkVTKCustomPolyDataMapper.h b/Source/Rendering/VTKRenderer/imstkVTKCustomPolyDataMapper.h new file mode 100644 index 0000000000000000000000000000000000000000..2b9e7ba03275a5e9a0c3848bcb120cff3547f3f8 --- /dev/null +++ b/Source/Rendering/VTKRenderer/imstkVTKCustomPolyDataMapper.h @@ -0,0 +1,143 @@ +/*========================================================================= + + Library: iMSTK + + Copyright (c) Kitware, Inc. & Center for Modeling, Simulation, + & Imaging in Medicine, Rensselaer Polytechnic Institute. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0.txt + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +=========================================================================*/ + +#pragma once + +#include "imstkRenderMaterial.h" + +#include "vtkSetGet.h" +#include "vtkOpenGLPolyDataMapper.h" + +class vtkOpenGLPolyDataMapper; +class vtkOpenGLBufferObject; +class vtkOpenGLHelper; +class vtkOpenGLHelper; +class vtkRenderer; +class vtkShader; +class vtkActor; + +namespace imstk +{ +/// +/// \class VTKCustomPolyDataMapper +/// +/// \brief Custom interface between shaders and iMSTK. +/// +/// This class overrides behavior in VTK regarding shading. +/// +class VTKCustomPolyDataMapper : public vtkOpenGLPolyDataMapper +{ +public: + vtkTypeMacro(VTKCustomPolyDataMapper, vtkOpenGLPolyDataMapper); + + /// + /// \brief Create a new object + /// + static VTKCustomPolyDataMapper* New(); + + /// + /// \brief Set the render material + /// + void setRenderMaterial(std::shared_ptr<RenderMaterial> renderMat); + + /// + /// \brief Let the polydata mapper know if it is for the surface mesh + /// + void setIsSurfaceMapper(const bool val) { m_isSurfaceMapper = val; }; + +protected: + /// + /// \brief Sets up the VBO and VAO + /// + void BuildBufferObjects(vtkRenderer* renderer, vtkActor* actor) override; + + /// + /// \brief Overridden method to prevent shader overwriting + /// + virtual void ReplaceShaderValues( + std::map<vtkShader::Type, vtkShader*> shaders, + vtkRenderer* renderer, + vtkActor* actor) override; + + /// + /// \brief Loads the shader and injects preprocessor commands + /// + virtual void GetShaderTemplate( + std::map<vtkShader::Type, vtkShader*> shaders, + vtkRenderer* renderer, + vtkActor* actor) override; + + /// + /// \brief Does all of the uniform/texture setting + /// + virtual void SetMapperShaderParameters( + vtkOpenGLHelper& helper, + vtkRenderer* renderer, + vtkActor* actor) override; + + /// + /// \brief Overwritten to prevent extra uniform assignment + /// + virtual void SetCameraShaderParameters( + vtkOpenGLHelper& helper, + vtkRenderer* renderer, + vtkActor* actor) override; + + /// + /// \brief Overwritten to prevent extra uniform assignment + /// + virtual void SetLightingShaderParameters( + vtkOpenGLHelper& helper, + vtkRenderer* renderer, + vtkActor* actor) override; + + /// + /// \brief Overwritten to prevent extra uniform assignment + /// + virtual void SetPropertyShaderParameters( + vtkOpenGLHelper& helper, + vtkRenderer* renderer, + vtkActor* actor) override; + + /// + /// \brief Allows for debugging interaction with VTK + /// + virtual void UpdateShaders(vtkOpenGLHelper& helper, + vtkRenderer* renderer, + vtkActor* actor) override; + + /// + /// \brief Loads a shader + /// + void loadShader(const std::string& filename, std::string& source); + + std::shared_ptr<RenderMaterial> m_renderMaterial; ///< Geometry reference + + std::string m_vertexShaderSource = ""; ///< Source for vertex shader + std::string m_fragmentShaderSource = ""; ///< Source for fragment shader + + vtkOpenGLBufferObject* m_positionsVBO; ///< Vertex positions VBO + vtkOpenGLBufferObject* m_normalsVBO; ///< Vertex normals VBO + vtkOpenGLBufferObject* m_uvVBO; ///< Vertex UVs VBO + + bool m_isSurfaceMapper = false; +}; +} diff --git a/Source/Rendering/VTKRenderer/imstkVTKRenderer.h b/Source/Rendering/VTKRenderer/imstkVTKRenderer.h index e04806c823fc6e6390993a60b667271ae1614290..22e13ea70d9067b8c6234cdad61bba07251450b7 100644 --- a/Source/Rendering/VTKRenderer/imstkVTKRenderer.h +++ b/Source/Rendering/VTKRenderer/imstkVTKRenderer.h @@ -180,7 +180,6 @@ protected: vtkSmartPointer<vtkChartXY> m_timeTableChart = nullptr; vtkSmartPointer<vtkContextActor> m_timeTableChartActor = nullptr; vtkSmartPointer<vtkTable> m_timeTable = nullptr; - vtkPlotBar* m_timeTablePlot = nullptr; int m_timeTableIter = 0; }; diff --git a/Source/Rendering/VulkanRenderer/imstkVulkanFramebuffer.h b/Source/Rendering/VulkanRenderer/imstkVulkanFramebuffer.h index 1a23968946526714f8de3ec9e1caa59f18216e83..f80863b95c6183a38ba4014c7d84f3e0334c94c7 100644 --- a/Source/Rendering/VulkanRenderer/imstkVulkanFramebuffer.h +++ b/Source/Rendering/VulkanRenderer/imstkVulkanFramebuffer.h @@ -30,39 +30,63 @@ namespace imstk { +/// +/// \brief TODO +/// class VulkanFramebuffer { public: + /// + /// \brief TODO + /// VulkanFramebuffer( VulkanMemoryManager& memoryManager, unsigned int width, unsigned int height, VkSampleCountFlagBits samples = VK_SAMPLE_COUNT_1_BIT); + /// + /// \brief TODO + /// void setColor(VulkanInternalImage* image, VkImageView* imageView, VkFormat format, VkImageLayout layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); + /// + /// \brief TODO + /// void setSpecular(VulkanInternalImage* image, VkImageView* imageView, VkFormat format, VkImageLayout layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); + /// + /// \brief TODO + /// void setDepth(VulkanInternalImage* image, VkImageView* imageView, VkFormat format, VkImageLayout layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL); + /// + /// \brief TODO + /// void setNormal(VulkanInternalImage* image, VkImageView* imageView, VkFormat format, VkImageLayout layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); + /// + /// \brief TODO + /// void initializeFramebuffer(VkRenderPass* renderPass); ~VulkanFramebuffer() {}; + /// + /// \brief TODO + /// void changeImageLayout(VkCommandBuffer& commandBuffer, VkImage& image, VkImageLayout layout1, @@ -71,6 +95,9 @@ public: VkAccessFlags destinationFlags, VkImageSubresourceRange range); + /// + /// \brief TODO + /// void clear(VkDevice* device); private: diff --git a/Source/Rendering/VulkanRenderer/imstkVulkanMaterialDelegate.h b/Source/Rendering/VulkanRenderer/imstkVulkanMaterialDelegate.h index 071caa2d688b768d94bab4b8b519f579d672a1fd..d75c1fa8e7994c9060032f4f061e3147f2cf9071 100644 --- a/Source/Rendering/VulkanRenderer/imstkVulkanMaterialDelegate.h +++ b/Source/Rendering/VulkanRenderer/imstkVulkanMaterialDelegate.h @@ -44,7 +44,10 @@ enum class VulkanMaterialType class VulkanRenderer; -// Large struct to contain pipeline components for later pipeline creation +/// +/// \struct VulkanMaterialPipelineComponents +/// \brief Large struct to contain pipeline components for later pipeline creation +/// struct VulkanMaterialPipelineComponents { VkShaderModule fragmentShader; @@ -71,6 +74,10 @@ struct VulkanMaterialPipelineComponents std::vector<VkDynamicState> dynamicStates; }; +/// +/// \struct VulkanMaterialConstants +/// \brief TODO +/// struct VulkanMaterialConstants { unsigned int numLights; @@ -88,6 +95,10 @@ struct VulkanMaterialConstants bool brdfLUTTexture; }; +/// +/// \class VulkanMaterialDelegate +/// \brief TODO +/// class VulkanMaterialDelegate { public: diff --git a/Source/Rendering/VulkanRenderer/imstkVulkanMemoryManager.h b/Source/Rendering/VulkanRenderer/imstkVulkanMemoryManager.h index f4584bcfcbabac1b3e3b8d1becc7d2716e8e45ef..df8015c88cefaa8cbbd059d6044c11de146f7dad 100644 --- a/Source/Rendering/VulkanRenderer/imstkVulkanMemoryManager.h +++ b/Source/Rendering/VulkanRenderer/imstkVulkanMemoryManager.h @@ -31,11 +31,19 @@ namespace imstk { +/// +/// \class VulkanMemoryManager +/// \brief TODO +/// class VulkanMemoryManager { public: VulkanMemoryManager(); + + /// \brief TODO void setup(VkPhysicalDevice* device); + + /// \brief TODO void clear(); /// diff --git a/Source/Rendering/VulkanRenderer/imstkVulkanRenderPassGenerator.h b/Source/Rendering/VulkanRenderer/imstkVulkanRenderPassGenerator.h index 8d9b1cf9365f4712b19752126a73140e9c2dc5b4..bfe38ceba0b2edaa4ff90bccb4a0b174ae1d32c7 100644 --- a/Source/Rendering/VulkanRenderer/imstkVulkanRenderPassGenerator.h +++ b/Source/Rendering/VulkanRenderer/imstkVulkanRenderPassGenerator.h @@ -26,45 +26,56 @@ namespace imstk { +/// +/// \class VulkanRenderPassGenerator +/// \brief TODO +/// class VulkanRenderPassGenerator { public: + /// \brief TODO static void generateDepthRenderPass( VkDevice& device, VkRenderPass& renderPass, VkSampleCountFlagBits& samples, const uint32_t numViews); + /// \brief TODO static void generateOpaqueRenderPass( VkDevice& device, VkRenderPass& renderPass, VkSampleCountFlagBits& samples, const uint32_t numViews); + /// \brief TODO static void generateDecalRenderPass( VkDevice& device, VkRenderPass& renderPass, VkSampleCountFlagBits& samples, const uint32_t numViews); + /// \brief TODO static void generateParticleRenderPass( VkDevice& device, VkRenderPass& renderPass, VkSampleCountFlagBits& samples, const uint32_t numViews); + /// \brief TODO static void generateShadowRenderPass( VkDevice& device, VkRenderPass& renderPass, VkSampleCountFlagBits& samples, const uint32_t numViews); + /// \brief TODO static void generateGUIRenderPass( VkDevice& device, VkRenderPass& renderPass, VkSampleCountFlagBits& samples, const uint32_t numViews); + /// \brief TODO static void generateRenderPassMultiviewCreateInfo( VkRenderPassMultiviewCreateInfo& multiviewInfo, const uint32_t& viewMask, diff --git a/Source/Rendering/VulkanRenderer/imstkVulkanRenderer.h b/Source/Rendering/VulkanRenderer/imstkVulkanRenderer.h index dc29a043b800f7f6cb85adac58dae3b8caf7c167..1e87b500cf2386d3fa1e9a648c2e285f722573cf 100644 --- a/Source/Rendering/VulkanRenderer/imstkVulkanRenderer.h +++ b/Source/Rendering/VulkanRenderer/imstkVulkanRenderer.h @@ -64,24 +64,38 @@ namespace imstk { +/// +/// \struct VulkanRendererConstants +/// \brief TODO +/// struct VulkanRendererConstants { unsigned int numLights; }; +/// +/// \struct VulkanRenderer +/// \brief TODO +/// class VulkanRenderer : public Renderer { public: explicit VulkanRenderer(std::shared_ptr<Scene> scene); ~VulkanRenderer(); + /// \brief TODO void setShadowMapResolution(uint32_t resolution); + /// \brief TODO void setResolution(unsigned int width, unsigned int height); + /// \brief TODO void setBloomOn(); + + /// \brief TODO void setBloomOff(); + /// \brief TODO void enableLensDistortion(const float distortion); protected: @@ -186,12 +200,16 @@ protected: friend class VulkanPostProcess; friend class VulkanPostProcessingChain; + /// \brief TODO void createInstance(); + /// \brief TODO void initialize(const unsigned int width, const unsigned int height, const unsigned int windowWidth, const unsigned int windowHeight); + + /// \brief TODO void loadAllVisualModels(); /// diff --git a/Source/Rendering/VulkanRenderer/imstkVulkanResources.h b/Source/Rendering/VulkanRenderer/imstkVulkanResources.h index f8696eeb2915932be1bd28c1af10ed8203a01a23..c6e31eb62ded26eab7accc635b27c042ec14b509 100644 --- a/Source/Rendering/VulkanRenderer/imstkVulkanResources.h +++ b/Source/Rendering/VulkanRenderer/imstkVulkanResources.h @@ -25,6 +25,7 @@ namespace imstk { +/// \brief TODO enum VulkanMemoryType { TEXTURE, @@ -38,6 +39,7 @@ enum VulkanMemoryType FRAMEBUFFER }; +/// \brief TODO class VulkanInternalMemory { protected: @@ -46,6 +48,7 @@ protected: friend class VulkanInternalImage; friend class VulkanInternalResource; + /// \brief TODO VulkanInternalMemory() { m_memory = new VkDeviceMemory(); @@ -62,6 +65,7 @@ protected: } }; +/// \brief TODO class VulkanInternalResource { public: @@ -80,9 +84,12 @@ protected: VkDeviceSize m_size; }; +/// \brief TODO class VulkanInternalImage : public VulkanInternalResource { public: + + /// \brief Constructor VulkanInternalImage(VkImage* image = nullptr) { if (image) @@ -95,16 +102,21 @@ public: } }; + /// \brief Get the image VkImage* getImage() { return m_image; } + /// \brief TODO void mapMemory(VkDevice& device, void** data) { vkMapMemory(device, *m_memory->m_memory, m_memoryOffset, m_size, 0, data); } + /// + /// \brief Set imange layout + /// void setImageLayout(const VkImageLayout imageLayout) { m_imageLayout = imageLayout; @@ -123,20 +135,30 @@ protected: VkImageLayout m_imageLayout; }; +/// \brief class VulkanInternalBufferGroup : public VulkanInternalResource { public: + /// + /// \brief Constructor + /// explicit VulkanInternalBufferGroup(VulkanMemoryType type) { m_type = type; m_buffer = new VkBuffer(); }; + /// + /// \brief TODO + /// VkBuffer* getBuffer() { return m_buffer; } + /// + /// \brief TODO + /// VkDeviceSize getSize() { return m_size; @@ -155,21 +177,25 @@ protected: class VulkanInternalBuffer { public: + /// \brief TODO explicit VulkanInternalBuffer(VulkanInternalBufferGroup* bufferGroup) { m_bufferGroup = bufferGroup; }; + /// \brief TODO VkBuffer* getBuffer() { return m_bufferGroup->getBuffer(); } + /// \brief TODO VulkanInternalMemory* getMemory() { return m_bufferGroup->getMemory(); } + /// \brief TODO void* getMemoryData(VkDevice& device) { void* data; @@ -189,16 +215,19 @@ public: return &m_bufferGroup->m_data[m_offset]; } + /// \brief TODO void unmapMemory(VkDevice& device) { vkUnmapMemory(device, *m_bufferGroup->getMemory()->m_memory); } + /// \brief TODO VkDeviceSize getSize() { return m_size; } + /// \brief TODO VkDeviceSize getOffset() { return m_offset; diff --git a/Source/Rendering/VulkanRenderer/imstkVulkanUniformBuffer.h b/Source/Rendering/VulkanRenderer/imstkVulkanUniformBuffer.h index 70a43cfd3ec15e1a7b199f93fff493eb51e9cb12..1aaee7870103f728e5959d57bc7159c26a5b96e6 100644 --- a/Source/Rendering/VulkanRenderer/imstkVulkanUniformBuffer.h +++ b/Source/Rendering/VulkanRenderer/imstkVulkanUniformBuffer.h @@ -32,21 +32,25 @@ namespace imstk { +/// \brief TODO struct VulkanLocalVertexUniforms { glm::mat4 transform; }; +/// \brief TODO struct VulkanLocalDecalVertexUniforms { glm::mat4 transforms[128]; }; +/// \brief TODO struct VulkanLocalParticleVertexUniforms { glm::mat4 transform[128]; }; +/// \brief TODO struct VulkanLocalFragmentUniforms { glm::mat4 transform; @@ -58,6 +62,7 @@ struct VulkanLocalFragmentUniforms glm::vec4 debugColor; }; +/// \brief TODO struct VulkanLocalDecalFragmentUniforms { glm::mat4 inverses[128]; @@ -68,6 +73,7 @@ struct VulkanLocalDecalFragmentUniforms float metalness; }; +/// \brief TODO struct VulkanLocalParticleFragmentUniforms { glm::vec4 color[128]; @@ -77,6 +83,7 @@ struct VulkanLocalParticleFragmentUniforms float metalness[128]; }; +/// \brief TODO struct VulkanLight { glm::vec4 position; // 3 position @@ -85,6 +92,7 @@ struct VulkanLight glm::ivec4 state; // 1 type, 1 shadow map index }; +/// \brief TODO struct VulkanGlobalVertexUniforms { glm::mat4 projectionMatrices[2]; @@ -93,6 +101,7 @@ struct VulkanGlobalVertexUniforms VulkanLight lights[16]; }; +/// \brief TODO struct VulkanGlobalFragmentUniforms { glm::mat4 inverseViewMatrices[2]; @@ -102,11 +111,14 @@ struct VulkanGlobalFragmentUniforms glm::mat4 lightMatrices[16]; }; +/// \brief TODO class VulkanUniformBuffer : public VulkanBuffer { public: + /// \brief TODO VulkanUniformBuffer(VulkanMemoryManager& memoryManager, uint32_t uniformSize); + /// \brief TODO void updateUniforms(uint32_t uniformSize, void* uniformData, uint32_t frameIndex); ~VulkanUniformBuffer() = default; @@ -115,8 +127,10 @@ protected: friend class VulkanRenderer; friend class VulkanMaterialDelegate; + /// \brief TODO VulkanInternalBuffer* getUniformBuffer(); + /// \brief TODO void* getUniformMemory(); VulkanInternalBuffer* m_uniformBuffer; diff --git a/Source/Rendering/VulkanRenderer/imstkVulkanUtilities.h b/Source/Rendering/VulkanRenderer/imstkVulkanUtilities.h index e28078c1f4b3ce92007bd6e508a5f7ee1aaf65cf..3def0d8837988ca89e489f44e6a0ba001882c81c 100644 --- a/Source/Rendering/VulkanRenderer/imstkVulkanUtilities.h +++ b/Source/Rendering/VulkanRenderer/imstkVulkanUtilities.h @@ -40,9 +40,11 @@ const std::string Mesh("../data/shaders/VulkanShaders/mesh/"); const std::string PostProcessing("../data/shaders/VulkanShaders/PostProcessing/"); } +/// \brief TODO class VulkanShaderLoader { public: + /// \brief TODO VulkanShaderLoader(std::string filename, VkDevice& device, VkShaderModule& module) { std::ifstream file(filename, std::ios_base::binary); @@ -63,17 +65,21 @@ public: } }; + /// \brief TODO uint32_t getShaderLength() { return (uint32_t)m_data->size(); }; + /// \brief TODO uint32_t* getShaderData() { return (uint32_t*)m_data->data(); }; protected: std::shared_ptr<std::vector<char>> m_data; }; +/// \brief TODO class VulkanAttachmentBarriers { public: + /// \brief TODO static void changeImageLayout( VkCommandBuffer* commandBuffer, uint32_t queueFamilyIndex, @@ -127,6 +133,7 @@ public: image->setImageLayout(newLayout); }; + /// \brief TODO static const VkAccessFlags getAccessFlags(VkImageLayout imageLayout) { switch (imageLayout) @@ -150,6 +157,7 @@ public: ; } + /// \brief TODO static const VkPipelineStageFlags getPipelineStageFlags(VkImageLayout imageLayout) { switch (imageLayout) @@ -173,6 +181,7 @@ public: ; } + /// \brief TODO static void addDepthAttachmentBarrier(VkCommandBuffer* commandBuffer, uint32_t queueFamilyIndex, VkImage* image) { VkImageSubresourceRange range; @@ -203,6 +212,7 @@ public: 1, &barrier); // image barriers }; + /// \brief TODO static void addShadowAttachmentBarrier(VkCommandBuffer* commandBuffer, uint32_t queueFamilyIndex, VkImage* image) { VkImageSubresourceRange range; @@ -234,6 +244,7 @@ public: }; }; +/// \brief TODO class VulkanDefaults { public: diff --git a/Source/Rendering/VulkanRenderer/imstkVulkanValidation.h b/Source/Rendering/VulkanRenderer/imstkVulkanValidation.h index 258bcd9712a9ab4d5a93e3b6f9bb941bf81249fd..8e330244f65c2e874ec71b991919636ade216fbf 100644 --- a/Source/Rendering/VulkanRenderer/imstkVulkanValidation.h +++ b/Source/Rendering/VulkanRenderer/imstkVulkanValidation.h @@ -25,19 +25,23 @@ namespace imstk { +/// \brief TODO class VulkanValidation { public: + /// \brief TODO static char* getValidationLayer() { return "VK_LAYER_LUNARG_standard_validation"; }; + /// \brief TODO static char* getValidationExtension() { return "VK_EXT_debug_report"; }; + /// \brief TODO static VKAPI_ATTR VkBool32 VKAPI_CALL debugReportCallback(VkDebugReportFlagsEXT debugReportFlags, VkDebugReportObjectTypeEXT debugReportObjectType, uint64_t callbackObject, diff --git a/Source/Rendering/VulkanRenderer/imstkVulkanVertexBuffer.h b/Source/Rendering/VulkanRenderer/imstkVulkanVertexBuffer.h index 97d3ca6a217abb16d0fd16b92c190c1f86f2db17..97be853b8b2cee83ba622292b2c3fb38f0e8a3f0 100644 --- a/Source/Rendering/VulkanRenderer/imstkVulkanVertexBuffer.h +++ b/Source/Rendering/VulkanRenderer/imstkVulkanVertexBuffer.h @@ -31,12 +31,14 @@ namespace imstk { +/// \brief TODO enum VulkanVertexBufferMode { VERTEX_BUFFER_STATIC, VERTEX_BUFFER_DYNAMIC }; +/// \brief TODO struct VulkanBasicVertex { glm::vec3 position; @@ -46,9 +48,11 @@ struct VulkanBasicVertex glm::vec3 color; }; +/// \brief TODO class VulkanVertexBuffer : public VulkanBuffer { public: + /// \brief TODO VulkanVertexBuffer(VulkanMemoryManager& memoryManager, unsigned int numVertices, unsigned int vertexSize, @@ -56,8 +60,10 @@ public: double loadFactor = 1.0, VulkanVertexBufferMode mode = VERTEX_BUFFER_STATIC); + /// \brief TODO void* getVertexMemory(uint32_t frameIndex = 0); + /// \brief TODO void* getIndexMemory(uint32_t frameIndex = 0); ~VulkanVertexBuffer() = default; @@ -68,12 +74,16 @@ public: void updateVertexBuffer(std::vector<VulkanBasicVertex>* vertices, std::vector<std::array<uint32_t, 3>>* triangles); + /// \brief TODO void uploadBuffers(VkCommandBuffer& commandBuffer); + /// \brief TODO void initializeBuffers(VulkanMemoryManager& memoryManager); + /// \brief TODO void setNumIndices(uint32_t numIndices); + /// \brief TODO void bindBuffers(VkCommandBuffer* commandBuffer, uint32_t frameIndex); /// @@ -82,6 +92,7 @@ public: /// void setModified(); + /// \brief TODO VulkanVertexBufferMode getMode(); private: diff --git a/Source/Rendering/imstkVtkCapsuleSource.h b/Source/Rendering/imstkVtkCapsuleSource.h index 48891cb4d0cc0749614fc6a24e73c1fc1a4b3f84..86085932aa3b836ad498557cc2e29a68d771ff13 100644 --- a/Source/Rendering/imstkVtkCapsuleSource.h +++ b/Source/Rendering/imstkVtkCapsuleSource.h @@ -40,6 +40,7 @@ #define VTK_MAX_SPHERE_RESOLUTION 1024 +/// \brief TODO class vtkCapsuleSource : public vtkPolyDataAlgorithm { public: diff --git a/Source/Scene/imstkCollisionPair.h b/Source/Scene/imstkCollisionPair.h index 3ed5e23782c86503e25aa0104c9e32286f27fab2..41147bbc5bb57e1887c394c372c61ca14b73a927 100644 --- a/Source/Scene/imstkCollisionPair.h +++ b/Source/Scene/imstkCollisionPair.h @@ -60,11 +60,13 @@ public: ~CollisionPair() = default; public: + /// \brief TODO void setCollisionDetection(std::shared_ptr<CollisionDetection> colDetect); void setCollisionHandlingA(std::shared_ptr<CollisionHandling> colHandlingA); void setCollisionHandlingB(std::shared_ptr<CollisionHandling> colHandlingB); void setCollisionHandlingAB(std::shared_ptr<CollisionHandling> colHandlingAB); + /// \brief TODO std::shared_ptr<CollisionDetection> getCollisionDetection() const { return m_colDetect; } std::shared_ptr<CollisionHandling> getCollisionHandlingA() const { return m_colHandlingA; } std::shared_ptr<CollisionHandling> getCollisionHandlingB() const { return m_colHandlingB; } diff --git a/Source/Scene/imstkObjectInteractionFactory.h b/Source/Scene/imstkObjectInteractionFactory.h index 4f861d8090b638259a29e66623ffbd695e60d1e1..6e19f3134e1e3382114057addb2799fe7837f0ea 100644 --- a/Source/Scene/imstkObjectInteractionFactory.h +++ b/Source/Scene/imstkObjectInteractionFactory.h @@ -50,4 +50,4 @@ enum class InteractionType /// extern std::shared_ptr<ObjectInteractionPair> makeObjectInteractionPair(std::shared_ptr<CollidingObject> obj1, std::shared_ptr<CollidingObject> obj2, InteractionType intType, CollisionDetection::Type cdType); -} \ No newline at end of file +} diff --git a/Source/Scene/imstkObjectInteractionPair.h b/Source/Scene/imstkObjectInteractionPair.h index dc7e4d1a477ad70b396cf25839e9b29a0d9b748b..35f92499ecd7ccef9b60aad126cae80eaa563c0e 100644 --- a/Source/Scene/imstkObjectInteractionPair.h +++ b/Source/Scene/imstkObjectInteractionPair.h @@ -46,6 +46,7 @@ protected: virtual ~ObjectInteractionPair() override = default; public: + /// \brief TODO const SceneObjectPair& getObjectsPair() const { return m_objects; } public: @@ -57,4 +58,4 @@ public: protected: SceneObjectPair m_objects; ///> The two objects interacting }; -} \ No newline at end of file +} diff --git a/Source/SceneEntities/Lights/imstkIBLProbe.h b/Source/SceneEntities/Lights/imstkIBLProbe.h index 4e6e8998a1debc6fd32588dbacab34cc8f3c3461..e1ad0ed9b04f21044be0ec6d9b75f4673a7b750c 100644 --- a/Source/SceneEntities/Lights/imstkIBLProbe.h +++ b/Source/SceneEntities/Lights/imstkIBLProbe.h @@ -59,8 +59,11 @@ public: Texture::Type::RadianceCubeMap)), m_brdfLUTTexture(std::make_shared<Texture>(brdfLUTPath, Texture::Type::BRDF_LUT)) {} + /// \brief TODO std::shared_ptr<Texture> getIrradianceCubemapTexture(); + /// \brief TODO std::shared_ptr<Texture> getRadianceCubemapTexture(); + /// \brief TODO std::shared_ptr<Texture> getBrdfLUTTexture(); protected: diff --git a/Source/SceneEntities/Objects/imstkAnimationObject.h b/Source/SceneEntities/Objects/imstkAnimationObject.h index 89bb6a51ff0d152f2cea4622b5758ce1fdf7df0c..06e178e1560449dbf3359ab22a1671f4eac31565 100644 --- a/Source/SceneEntities/Objects/imstkAnimationObject.h +++ b/Source/SceneEntities/Objects/imstkAnimationObject.h @@ -28,6 +28,9 @@ namespace imstk class Geometry; class AnimationModel; +/// +/// \brief TODO +/// class AnimationObject : public SceneObject { public: diff --git a/Source/SceneEntities/Objects/imstkCollidingObject.h b/Source/SceneEntities/Objects/imstkCollidingObject.h index 512f1ab55de7aa72f44107a1909a17ba42b332d4..abdbf60e11a6ee6a70953ab2bb464f63b94520e5 100644 --- a/Source/SceneEntities/Objects/imstkCollidingObject.h +++ b/Source/SceneEntities/Objects/imstkCollidingObject.h @@ -30,6 +30,7 @@ namespace imstk class Geometry; class GeometryMap; +/// \brief TODO class CollidingObject : public SceneObject { public: diff --git a/Source/SceneEntities/Objects/imstkVisualModel.h b/Source/SceneEntities/Objects/imstkVisualModel.h index f087e757ddd17f82c0f9d556108b4568805706c9..3af9f8692763a531e7eac6e2dc74beaafc8f38eb 100644 --- a/Source/SceneEntities/Objects/imstkVisualModel.h +++ b/Source/SceneEntities/Objects/imstkVisualModel.h @@ -73,6 +73,9 @@ public: void hide(); bool isVisible() const; + /// + /// \brief Return true if renderer delegate is created + /// bool isRenderDelegateCreated(); protected: diff --git a/Source/SimulationManager/VTKRenderer/imstkOpenVRCommand.h b/Source/SimulationManager/VTKRenderer/imstkOpenVRCommand.h index aec820653d16e0e919c90f42f3ad45239b31a19f..93d561e6427841905aab1dad4cfb393141df4cee 100644 --- a/Source/SimulationManager/VTKRenderer/imstkOpenVRCommand.h +++ b/Source/SimulationManager/VTKRenderer/imstkOpenVRCommand.h @@ -27,6 +27,8 @@ limitations under the License. namespace imstk { class SimulationManager; + +/// \brief TODO class OpenVRCommand : public vtkCommand { public: @@ -35,11 +37,17 @@ public: return new OpenVRCommand; } + /// + /// \brief Set the simulation manager + /// void SetSimulationManager(SimulationManager* manager = nullptr) { m_simManager = manager; } + /// + /// \brief TODO + /// virtual void Execute( vtkObject* caller, unsigned long eventId, diff --git a/Source/SimulationManager/VTKRenderer/imstkVTKInteractorStyle.h b/Source/SimulationManager/VTKRenderer/imstkVTKInteractorStyle.h index fde971efd920b0830b90426bfcc1c7023d5d2ca7..69a9c3d3bebc06a5d21deca5bc38eb70f6e1756e 100644 --- a/Source/SimulationManager/VTKRenderer/imstkVTKInteractorStyle.h +++ b/Source/SimulationManager/VTKRenderer/imstkVTKInteractorStyle.h @@ -38,7 +38,7 @@ using vtkBaseInteractorStyle = vtkInteractorStyleTrackballCamera; /// /// \class VTKInteractorStyle /// -/// \brief +/// \brief TODO /// class VTKInteractorStyle : public vtkBaseInteractorStyle, public InteractorStyle { diff --git a/Source/SimulationManager/VTKRenderer/imstkVTKScreenCaptureUtility.h b/Source/SimulationManager/VTKRenderer/imstkVTKScreenCaptureUtility.h index b6f2d92699ae7b72fd1ac1e160938678382d5770..c10b5b23d311e176fe0e29aa74cd9a2e5de6d579 100644 --- a/Source/SimulationManager/VTKRenderer/imstkVTKScreenCaptureUtility.h +++ b/Source/SimulationManager/VTKRenderer/imstkVTKScreenCaptureUtility.h @@ -55,10 +55,19 @@ public: /// virtual void saveScreenShot(); + /// + /// \brief Get screen shot number + /// unsigned int getScreenShotNumber() const; + /// + /// \brief Set screen shot prefix + /// void setScreenShotPrefix(const std::string newPrefix); + /// + /// \brief Reset screen shot number to zero + /// void resetScreenShotNumber(); protected: diff --git a/Source/SimulationManager/VTKRenderer/imstkVTKViewer.h b/Source/SimulationManager/VTKRenderer/imstkVTKViewer.h index 812d7fd829ca9b73dd460a33a2753f95e784ef02..5280057247dc4684ddddba2b2681000f43f7aed3 100644 --- a/Source/SimulationManager/VTKRenderer/imstkVTKViewer.h +++ b/Source/SimulationManager/VTKRenderer/imstkVTKViewer.h @@ -110,6 +110,7 @@ public: const std::shared_ptr<VTKTextStatusManager>& getTextStatusManager(); protected: + /// \brief TODO static void timerCallback(vtkObject* caller, long unsigned int eventId, void* clientData, void* callData); vtkSmartPointer<vtkRenderWindow> m_vtkRenderWindow; diff --git a/Source/SimulationManager/imstkInteractorStyle.h b/Source/SimulationManager/imstkInteractorStyle.h index 0ca96775b1e30f52bb0f132f8aee6143d88e5bb7..ed6f85225da433167437fe07484e84623967c6c9 100644 --- a/Source/SimulationManager/imstkInteractorStyle.h +++ b/Source/SimulationManager/imstkInteractorStyle.h @@ -32,6 +32,10 @@ class InteractorStyle; /// Return true to override base class behavior, or false to maintain it. using EventHandlerFunction = std::function<bool (InteractorStyle* iStyle)>; +/// +/// \class InteractorStyle +/// \brief TODO +/// class InteractorStyle { public: diff --git a/Source/SimulationManager/imstkSceneManager.h b/Source/SimulationManager/imstkSceneManager.h index d055f7d272fdfdc2d1a7d225cf8fb1c10d3edc60..e56b932a6528c8694e51ab35665d8b3b313b48d6 100644 --- a/Source/SimulationManager/imstkSceneManager.h +++ b/Source/SimulationManager/imstkSceneManager.h @@ -69,7 +69,7 @@ protected: void cleanUpModule() override; /// - /// \brief + /// \brief TODO /// void startModuleInNewThread(std::shared_ptr<Module> module); diff --git a/Source/Solvers/imstkDirectLinearSolver.h b/Source/Solvers/imstkDirectLinearSolver.h index baaf133e5b79247b15e27777415aaf6e0dd0461e..09e3ac4ab891d1c6a9b2ed97bbf30cdc9332cf6d 100644 --- a/Source/Solvers/imstkDirectLinearSolver.h +++ b/Source/Solvers/imstkDirectLinearSolver.h @@ -84,6 +84,7 @@ public: }; private: + /// \todo: only works for SPB matrices Eigen::LDLT<Matrixd> m_solver; }; diff --git a/Source/Solvers/imstkPbdSolver.h b/Source/Solvers/imstkPbdSolver.h index f7012d6b5766bd9e6315db03f85812299793909b..73feaf9fef5a47026dde13638737f3b9ec5f4fcf 100644 --- a/Source/Solvers/imstkPbdSolver.h +++ b/Source/Solvers/imstkPbdSolver.h @@ -28,6 +28,10 @@ namespace imstk { +/// +/// \struct CollisionConstraintData +/// \brief Stores positions and masses of two colliding objects +/// struct CollisionConstraintData { CollisionConstraintData(std::shared_ptr<StdVectorOfVec3d> posA, @@ -48,7 +52,7 @@ struct CollisionConstraintData /// \class PbdSolver /// /// \brief Position Based Dynamics solver -/// This solver can operate on both partitioned constraints (unordered_set of vector'd constraints) in parallel +/// This solver can solve both partitioned constraints (unordered_set of vector'd constraints) in parallel /// and sequentially on vector'd constraints. It requires a set of constraints, positions, and invMasses. /// class PbdSolver : public SolverBase @@ -130,6 +134,12 @@ private: PbdConstraint::SolverType m_solverType = PbdConstraint::SolverType::xPBD; }; +/// +/// \class PbdCollisionSolver +/// +/// \brief Position Based Dynamics collision solver +/// This solver can sequentially solve constraints in a list +/// class PbdCollisionSolver : SolverBase { public: diff --git a/Source/apiUtilities/imstkAPIUtilities.h b/Source/apiUtilities/imstkAPIUtilities.h index 8a929f125554ba9c91a75f12b5e0320696cfa25e..e1ee8ddae31321d422fdc44d08c759925fc603fb 100644 --- a/Source/apiUtilities/imstkAPIUtilities.h +++ b/Source/apiUtilities/imstkAPIUtilities.h @@ -75,10 +75,11 @@ std::shared_ptr<NonLinearSystem<SparseMatrixd>> createNonLinearSystem(std::share /// void printUPS(std::shared_ptr<SceneManager> sceneManager); +/// +/// \brief Create a \ref Graph ref +/// std::shared_ptr<Graph> getMeshGraph(std::shared_ptr<PointSet> m); - std::shared_ptr<Graph> getMeshGraph(std::shared_ptr<SurfaceMesh> m); - std::shared_ptr<Graph> getMeshGraph(std::shared_ptr<TetrahedralMesh> m); } //apiutils } // imstk diff --git a/Source/apiUtilities/imstkPlotterUtils.h b/Source/apiUtilities/imstkPlotterUtils.h index 77d2b35d846fe503a136ea7ca89a68aeb45fc392..d592c7665ac3bd65a9395863f709a0e522ce76f6 100644 --- a/Source/apiUtilities/imstkPlotterUtils.h +++ b/Source/apiUtilities/imstkPlotterUtils.h @@ -126,7 +126,7 @@ writePlotterVectorMatPlotlib(Vectord& x, const char* fileName) } /// -/// \brief Write a MatPlotlib script to plot X vs Y where X, Y are input vectors of same +/// \brief Write a MatPlotlib script to plot \p x vs \p y where \p x, \p y are of same /// size /// static void