Commit 1695e5ca authored by Sreekanth Arikatla's avatar Sreekanth Arikatla

REFAC: Use forward declerations where possible

parent b9ea62a0
......@@ -22,6 +22,7 @@
#include "imstkMath.h"
#include "imstkTimer.h"
#include "imstkSimulationManager.h"
#include "imstkScene.h"
// Objects
#include "imstkSceneObject.h"
......@@ -35,6 +36,7 @@
#include "imstkMeshIO.h"
// Devices and controllers
#include "imstkDeviceTracker.h"
#include "imstkHDAPIDeviceClient.h"
#include "imstkHDAPIDeviceServer.h"
#include "imstkSceneObjectController.h"
......
......@@ -24,6 +24,7 @@
#include "imstkLight.h"
#include "imstkCamera.h"
#include "imstkMeshIO.h"
#include "imstkScene.h"
// Devices and controllers
#include "imstkHDAPIDeviceClient.h"
......@@ -31,6 +32,8 @@
#include "imstkCameraController.h"
#include "imstkCollisionGraph.h"
#include "imstkScene.h"
const std::string phantomOmni1Name = "Phantom1";
using namespace imstk;
......
......@@ -28,6 +28,14 @@
#include "imstkTimer.h"
#include "imstkVTKTextStatusManager.h"
#include "imstkCollisionData.h"
#include "imstkCamera.h"
#include "imstkDebugRenderGeometry.h"
#include "imstkCollidingObject.h"
#include "imstkSceneManager.h"
#include "imstkSurfaceMesh.h"
#include "imstkCollisionGraph.h"
#include "imstkScene.h"
#include "imstkVTKRenderer.h"
// This is for collision detection between geometries
#include "imstkOctreeBasedCD.h"
......
......@@ -21,12 +21,15 @@
#include "imstkSimulationManager.h"
#include "imstkLight.h"
#include "imstkCamera.h"
#include "imstkCollisionGraph.h"
#include "imstkAPIUtilities.h"
#include "imstkSurfaceMesh.h"
#include "imstkTetrahedralMesh.h"
#include "imstkMeshIO.h"
#include "imstkVTKMeshIO.h"
#include "imstkGeometryUtilities.h"
#include "imstkScene.h"
using namespace imstk;
......
......@@ -22,10 +22,15 @@
#include "imstkSimulationManager.h"
#include "imstkSceneObject.h"
#include "imstkLight.h"
#include "imstkCamera.h"
#include "imstkSceneManager.h"
#include "imstkCollisionGraph.h"
#include "imstkDebugRenderGeometry.h"
#include "imstkAPIUtilities.h"
#include "imstkVTKViewer.h"
#include "imstkVTKRenderer.h"
#include "imstkVTKTextStatusManager.h"
#include "imstkScene.h"
#include <thread>
#include <chrono>
......
......@@ -33,6 +33,11 @@
#include "imstkAPIUtilities.h"
#include "imstkConjugateGradient.h"
#include "imstkLight.h"
#include "imstkCamera.h"
#include "imstkFEMDeformableBodyModel.h"
#include "imstkCollisionGraph.h"
#include "imstkSurfaceMesh.h"
#include "imstkScene.h"
using namespace imstk;
......
......@@ -27,6 +27,12 @@
#include "imstkCube.h"
#include "imstkAPIUtilities.h"
#include "imstkGeometryUtilities.h"
#include "imstkCamera.h"
#include "imstkMeshIO.h"
#include "imstkSurfaceMesh.h"
#include "imstkTetrahedralMesh.h"
#include "imstkCollisionGraph.h"
#include "imstkScene.h"
using namespace imstk;
......
......@@ -20,6 +20,8 @@
=========================================================================*/
#include "imstkSimulationManager.h"
#include "imstkSceneManager.h"
#include "imstkCollisionGraph.h"
#include "imstkSceneObject.h"
#include "imstkCamera.h"
#include "imstkLight.h"
......@@ -27,6 +29,7 @@
#include "imstkCylinder.h"
#include "imstkCube.h"
#include "imstkAPIUtilities.h"
#include "imstkScene.h"
using namespace imstk;
......
......@@ -23,6 +23,7 @@
#include "imstkTetrahedralMesh.h"
#include "imstkMeshIO.h"
#include "imstkAPIUtilities.h"
#include "imstkSurfaceMesh.h"
#include <iostream>
......
......@@ -20,8 +20,11 @@
=========================================================================*/
#include "imstkSimulationManager.h"
#include "imstkCollisionGraph.h"
#include "imstkAPIUtilities.h"
#include "imstkCamera.h"
#include "imstkLineMesh.h"
#include "imstkScene.h"
using namespace imstk;
......
......@@ -24,6 +24,13 @@
#include "imstkPbdObject.h"
#include "imstkAPIUtilities.h"
#include "imstkOneToOneMap.h"
#include "imstkCamera.h"
#include "imstkSurfaceMesh.h"
#include "imstkMeshIO.h"
#include "imstkTetrahedralMesh.h"
#include "imstkCollisionGraph.h"
#include "imstkPlane.h"
#include "imstkScene.h"
using namespace imstk;
......
......@@ -28,6 +28,8 @@
#include "imstkHDAPIDeviceServer.h"
#include "imstkSceneObjectController.h"
#include "imstkCollisionGraph.h"
#include "imstkDeviceTracker.h"
#include "imstkScene.h"
// global variables
const std::string phantomOmni1Name = "Phantom1";
......
......@@ -27,7 +27,9 @@
#include "imstkSceneManager.h"
#include "imstkCube.h"
#include "imstkDummyClient.h"
#include "imstkDeviceTracker.h"
#include "imstkSceneObjectController.h"
#include "imstkScene.h"
using namespace imstk;
......
......@@ -27,7 +27,13 @@
#include "imstkVTKViewer.h"
#include "imstkTimer.h"
#include "imstkLight.h"
#include "imstkSurfaceMesh.h"
#include "imstkSceneManager.h"
#include "imstkCamera.h"
#include "imstkVTKTextStatusManager.h"
#include "imstkCollisionGraph.h"
#include "imstkScene.h"
#include "imstkVTKRenderer.h"
#include <thread>
#include <chrono>
......
......@@ -23,7 +23,11 @@
#include "imstkPbdModel.h"
#include "imstkPbdObject.h"
#include "imstkAPIUtilities.h"
#include "imstkSurfaceMesh.h"
#include "imstkCollisionGraph.h"
#include "imstkCamera.h"
#include "imstkLight.h"
#include "imstkScene.h"
using namespace imstk;
......
......@@ -33,6 +33,8 @@
#include "imstkPBDCollisionHandling.h"
#include "imstkVTKTextStatusManager.h"
#include "imstkCollisionData.h"
#include "imstkSurfaceMesh.h"
#include "imstkScene.h"
// Enable this macro to generate many dragons
#define BIG_SCENE
......
......@@ -31,6 +31,8 @@
#include "imstkMeshToMeshBruteForceCD.h"
#include "imstkPBDCollisionHandling.h"
#include "imstkTetraTriangleMap.h"
#include "imstkSurfaceMesh.h"
#include "imstkScene.h"
using namespace imstk;
......
......@@ -31,62 +31,65 @@
#include "imstkTetrahedralMesh.h"
#include "imstkTetraTriangleMap.h"
#include "imstkCollisionGraph.h"
#include "imstkSurfaceMesh.h"
#include "imstkLight.h"
#include "imstkScene.h"
using namespace imstk;
// Creates a non-manifold top part of a staircase
static std::unique_ptr<SurfaceMesh> buildStairs(int nSteps, double width, double height, double depth)
static std::unique_ptr<SurfaceMesh>
buildStairs(int nSteps, double width, double height, double depth)
{
// Build stair geometry
const double halfWidth = width * 0.5;
const double halfHeight = height * 0.5;
const double halfDepth = depth * 0.5;
const double dz = depth / static_cast<double>(nSteps);
const double dy = height / static_cast<double>(nSteps);
// Create vertices
StdVectorOfVec3d vertList;
// 4 verts per step, 2 back, then 2 bottom
vertList.reserve(nSteps * 4 + 4);
for (size_t i = 0; i < nSteps; i++)
{
const double z = static_cast<double>(dz * i) - halfDepth;
const double y1 = static_cast<double>(dy * i) - halfHeight;
vertList.push_back(Vec3d(-halfWidth, y1, z));
vertList.push_back(Vec3d(halfWidth, y1, z));
const double y2 = static_cast<double>(dy * (i + 1)) - halfHeight;
vertList.push_back(Vec3d(-halfWidth, y2, z));
vertList.push_back(Vec3d(halfWidth, y2, z));
}
{
const double z = static_cast<double>(dz * nSteps) - halfDepth;
const double yTop = static_cast<double>(dy * nSteps) - halfHeight;
vertList.push_back(Vec3d(-halfWidth, yTop, z));
vertList.push_back(Vec3d(halfWidth, yTop, z));
const double yBot = -halfHeight;
vertList.push_back(Vec3d(-halfWidth, yBot, z));
vertList.push_back(Vec3d(halfWidth, yBot, z));
}
// Create cells
std::vector<SurfaceMesh::TriangleArray> triangles;
// Create sides and tops of steps
for (std::size_t i = 0; i < nSteps; ++i)
{
// Stair front side
triangles.push_back({ { i * 4 + 3, i * 4 + 1, i * 4 } });
triangles.push_back({ { i * 4 + 2, i * 4 + 3, i * 4 } });
// Stair top
triangles.push_back({ { (i + 1) * 4, i * 4 + 3, i * 4 + 2 } });
triangles.push_back({ { (i + 1) * 4, (i + 1) * 4 + 1, i * 4 + 3 } });
}
std::unique_ptr<SurfaceMesh> stairMesh = std::make_unique<SurfaceMesh>();
stairMesh->initialize(vertList, triangles);
return stairMesh;
// Build stair geometry
const double halfWidth = width * 0.5;
const double halfHeight = height * 0.5;
const double halfDepth = depth * 0.5;
const double dz = depth / static_cast<double>(nSteps);
const double dy = height / static_cast<double>(nSteps);
// Create vertices
StdVectorOfVec3d vertList;
// 4 verts per step, 2 back, then 2 bottom
vertList.reserve(nSteps * 4 + 4);
for (size_t i = 0; i < nSteps; i++)
{
const double z = static_cast<double>(dz * i) - halfDepth;
const double y1 = static_cast<double>(dy * i) - halfHeight;
vertList.push_back(Vec3d(-halfWidth, y1, z));
vertList.push_back(Vec3d(halfWidth, y1, z));
const double y2 = static_cast<double>(dy * (i + 1)) - halfHeight;
vertList.push_back(Vec3d(-halfWidth, y2, z));
vertList.push_back(Vec3d(halfWidth, y2, z));
}
{
const double z = static_cast<double>(dz * nSteps) - halfDepth;
const double yTop = static_cast<double>(dy * nSteps) - halfHeight;
vertList.push_back(Vec3d(-halfWidth, yTop, z));
vertList.push_back(Vec3d(halfWidth, yTop, z));
const double yBot = -halfHeight;
vertList.push_back(Vec3d(-halfWidth, yBot, z));
vertList.push_back(Vec3d(halfWidth, yBot, z));
}
// Create cells
std::vector<SurfaceMesh::TriangleArray> triangles;
// Create sides and tops of steps
for (std::size_t i = 0; i < nSteps; ++i)
{
// Stair front side
triangles.push_back({ { i* 4 + 3, i* 4 + 1, i* 4 } });
triangles.push_back({ { i* 4 + 2, i* 4 + 3, i* 4 } });
// Stair top
triangles.push_back({ { (i + 1) * 4, i * 4 + 3, i * 4 + 2 } });
triangles.push_back({ { (i + 1) * 4, (i + 1) * 4 + 1, i * 4 + 3 } });
}
std::unique_ptr<SurfaceMesh> stairMesh = std::make_unique<SurfaceMesh>();
stairMesh->initialize(vertList, triangles);
return stairMesh;
}
///
......@@ -96,101 +99,101 @@ static std::unique_ptr<SurfaceMesh> buildStairs(int nSteps, double width, double
int
main()
{
auto simManager = std::make_shared<SimulationManager>();
auto scene = simManager->createNewScene("PbdCollision");
scene->getCamera()->setPosition(0.0, 0.0, -30.0);
scene->getCamera()->setFocalPoint(0.0, 0.0, 0.0);
auto deformableObj = std::make_shared<PbdObject>("DeformableObj");
{
// Read in the dragon mesh
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"));
highResSurfMesh->translate(Vec3d(0.0f, 10.0f, 0.0f), Geometry::TransformType::ApplyToData);
coarseTetMesh->translate(Vec3d(0.0f, 10.0f, 0.0f), Geometry::TransformType::ApplyToData);
auto coarseSurfMesh = std::make_shared<SurfaceMesh>();
coarseTetMesh->extractSurfaceMesh(coarseSurfMesh, true);
// Setup parameters
auto pbdParams = std::make_shared<PBDModelConfig>();
pbdParams->m_YoungModulus = 1000.0;
pbdParams->m_PoissonRatio = 0.3;
pbdParams->enableFEMConstraint(PbdConstraint::Type::FEMTet,
PbdFEMConstraint::MaterialType::StVK);
pbdParams->m_uniformMassValue = 1.0;
pbdParams->m_gravity = Vec3d(0, -10.0, 0);
pbdParams->m_DefaultDt = 0.01;
pbdParams->m_maxIter = 5;
pbdParams->m_proximity = 0.3;
pbdParams->m_contactStiffness = 0.1;
// Setup Model
auto pbdModel = std::make_shared<PbdModel>();
pbdModel->setModelGeometry(coarseTetMesh);
pbdModel->configure(pbdParams);
// Setup VisualModel
auto material = std::make_shared<RenderMaterial>();
material->setDisplayMode(RenderMaterial::DisplayMode::WireframeSurface);
auto surfMeshModel = std::make_shared<VisualModel>(highResSurfMesh);
surfMeshModel->setRenderMaterial(material);
// Setup Object
deformableObj->addVisualModel(surfMeshModel);
deformableObj->setCollidingGeometry(coarseSurfMesh);
deformableObj->setPhysicsGeometry(coarseTetMesh);
deformableObj->setPhysicsToCollidingMap(std::make_shared<OneToOneMap>(coarseTetMesh, coarseSurfMesh));
deformableObj->setPhysicsToVisualMap(std::make_shared<TetraTriangleMap>(coarseTetMesh, highResSurfMesh));
deformableObj->setDynamicalModel(pbdModel);
// Add to scene
scene->addSceneObject(deformableObj);
}
auto stairObj = std::make_shared<PbdObject>("Floor");
{
std::shared_ptr<SurfaceMesh> stairMesh(std::move(buildStairs(15, 20.0, 10.0, 20.0)));
// Setup parameters
auto pbdParams2 = std::make_shared<PBDModelConfig>();
pbdParams2->m_uniformMassValue = 0.0;
pbdParams2->m_proximity = 0.1;
pbdParams2->m_contactStiffness = 1.0;
pbdParams2->m_maxIter = 0;
// Setup model
auto pbdModel2 = std::make_shared<PbdModel>();
pbdModel2->setModelGeometry(stairMesh);
pbdModel2->configure(pbdParams2);
// Setup VisualModel
auto stairMaterial = std::make_shared<RenderMaterial>();
stairMaterial->setDisplayMode(RenderMaterial::DisplayMode::WireframeSurface);
auto stairMeshModel = std::make_shared<VisualModel>(stairMesh);
stairMeshModel->setRenderMaterial(stairMaterial);
stairObj->addVisualModel(stairMeshModel);
stairObj->setDynamicalModel(pbdModel2);
stairObj->setCollidingGeometry(stairMesh);
stairObj->setVisualGeometry(stairMesh);
stairObj->setPhysicsGeometry(stairMesh);
scene->addSceneObject(stairObj);
}
// Collision
scene->getCollisionGraph()->addInteractionPair(deformableObj, stairObj,
CollisionDetection::Type::MeshToMeshBruteForce,
CollisionHandling::Type::PBD,
CollisionHandling::Type::None);
// Light
auto light = std::make_shared<DirectionalLight>("light");
light->setFocalPoint(Vec3d(5, -8, 5));
scene->addLight(light);
simManager->setActiveScene(scene);
simManager->start(SimulationStatus::Paused);
auto simManager = std::make_shared<SimulationManager>();
auto scene = simManager->createNewScene("PbdCollision");
scene->getCamera()->setPosition(0.0, 0.0, -30.0);
scene->getCamera()->setFocalPoint(0.0, 0.0, 0.0);
auto deformableObj = std::make_shared<PbdObject>("DeformableObj");
{
// Read in the dragon mesh
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"));
highResSurfMesh->translate(Vec3d(0.0f, 10.0f, 0.0f), Geometry::TransformType::ApplyToData);
coarseTetMesh->translate(Vec3d(0.0f, 10.0f, 0.0f), Geometry::TransformType::ApplyToData);
auto coarseSurfMesh = std::make_shared<SurfaceMesh>();
coarseTetMesh->extractSurfaceMesh(coarseSurfMesh, true);
// Setup parameters
auto pbdParams = std::make_shared<PBDModelConfig>();
pbdParams->m_YoungModulus = 1000.0;
pbdParams->m_PoissonRatio = 0.3;
pbdParams->enableFEMConstraint(PbdConstraint::Type::FEMTet,
PbdFEMConstraint::MaterialType::StVK);
pbdParams->m_uniformMassValue = 1.0;
pbdParams->m_gravity = Vec3d(0, -10.0, 0);
pbdParams->m_DefaultDt = 0.01;
pbdParams->m_maxIter = 5;
pbdParams->m_proximity = 0.3;
pbdParams->m_contactStiffness = 0.1;
// Setup Model
auto pbdModel = std::make_shared<PbdModel>();
pbdModel->setModelGeometry(coarseTetMesh);
pbdModel->configure(pbdParams);
// Setup VisualModel
auto material = std::make_shared<RenderMaterial>();
material->setDisplayMode(RenderMaterial::DisplayMode::WireframeSurface);
auto surfMeshModel = std::make_shared<VisualModel>(highResSurfMesh);
surfMeshModel->setRenderMaterial(material);
// Setup Object
deformableObj->addVisualModel(surfMeshModel);
deformableObj->setCollidingGeometry(coarseSurfMesh);
deformableObj->setPhysicsGeometry(coarseTetMesh);
deformableObj->setPhysicsToCollidingMap(std::make_shared<OneToOneMap>(coarseTetMesh, coarseSurfMesh));
deformableObj->setPhysicsToVisualMap(std::make_shared<TetraTriangleMap>(coarseTetMesh, highResSurfMesh));
deformableObj->setDynamicalModel(pbdModel);
// Add to scene
scene->addSceneObject(deformableObj);
}
auto stairObj = std::make_shared<PbdObject>("Floor");
{
std::shared_ptr<SurfaceMesh> stairMesh(std::move(buildStairs(15, 20.0, 10.0, 20.0)));
// Setup parameters
auto pbdParams2 = std::make_shared<PBDModelConfig>();
pbdParams2->m_uniformMassValue = 0.0;
pbdParams2->m_proximity = 0.1;
pbdParams2->m_contactStiffness = 1.0;
pbdParams2->m_maxIter = 0;
// Setup model
auto pbdModel2 = std::make_shared<PbdModel>();
pbdModel2->setModelGeometry(stairMesh);
pbdModel2->configure(pbdParams2);
// Setup VisualModel
auto stairMaterial = std::make_shared<RenderMaterial>();
stairMaterial->setDisplayMode(RenderMaterial::DisplayMode::WireframeSurface);
auto stairMeshModel = std::make_shared<VisualModel>(stairMesh);
stairMeshModel->setRenderMaterial(stairMaterial);
stairObj->addVisualModel(stairMeshModel);
stairObj->setDynamicalModel(pbdModel2);
stairObj->setCollidingGeometry(stairMesh);
stairObj->setVisualGeometry(stairMesh);
stairObj->setPhysicsGeometry(stairMesh);
scene->addSceneObject(stairObj);
}
// Collision
scene->getCollisionGraph()->addInteractionPair(deformableObj, stairObj,
CollisionDetection::Type::MeshToMeshBruteForce,
CollisionHandling::Type::PBD,
CollisionHandling::Type::None);
// Light
auto light = std::make_shared<DirectionalLight>("light");
light->setFocalPoint(Vec3d(5, -8, 5));
scene->addLight(light);
simManager->setActiveScene(scene);
simManager->start(SimulationStatus::Paused);
return 0;
}
......@@ -27,6 +27,13 @@
#include "imstkOneToOneMap.h"
#include "imstkAPIUtilities.h"
#include "imstkTetraTriangleMap.h"
#include "imstkCollisionGraph.h"
#include "imstkSurfaceMesh.h"
#include "imstkCamera.h"
#include "imstkPlane.h"
#include "imstkScene.h"