Commit 8593b7c5 authored by Sreekanth Arikatla's avatar Sreekanth Arikatla

REFAC: move the code to main() in all examples

parent 0afb2022
......@@ -50,7 +50,7 @@ const std::string phantomOmni1Name = "Phantom1";
using namespace imstk;
void doBoneDrilling()
int main()
{
// SDK and Scene
auto sdk = std::make_shared<SimulationManager>();
......@@ -76,7 +76,7 @@ void doBoneDrilling()
if (!tetMesh)
{
LOG(WARNING) << "Could not read mesh from file.";
return;
return 1;
}
auto bone = std::make_shared<CollidingObject>("Bone");
bone->setCollidingGeometry(tetMesh);
......@@ -100,10 +100,10 @@ void doBoneDrilling()
// Create a collision graph
auto graph = scene->getCollisionGraph();
auto pair = graph->addInteractionPair(bone,
drill,
CollisionDetection::Type::PointSetToSphere,
CollisionHandling::Type::BoneDrilling,
CollisionHandling::Type::None);
drill,
CollisionDetection::Type::PointSetToSphere,
CollisionHandling::Type::BoneDrilling,
CollisionHandling::Type::None);
#endif
......@@ -119,10 +119,5 @@ void doBoneDrilling()
sdk->setActiveScene(scene);
sdk->startSimulation(SimulationStatus::RUNNING);
}
int main()
{
doBoneDrilling();
return 0;
}
......@@ -34,7 +34,7 @@ const std::string phantomOmni1Name = "Phantom1";
using namespace imstk;
void doCameraController()
int main()
{
// SDK and Scene
auto sdk = std::make_shared<SimulationManager>();
......@@ -72,7 +72,7 @@ void doCameraController()
//camController->setTranslationScaling(100);
//LOG(INFO) << camController->getTranslationOffset(); // should be the same than initial cam position
camController->setInversionFlags(CameraController::InvertFlag::rotY |
CameraController::InvertFlag::rotZ);
CameraController::InvertFlag::rotZ);
#endif
// Light
......@@ -84,11 +84,6 @@ void doCameraController()
// Run
sdk->setActiveScene(scene);
sdk->startSimulation(SimulationStatus::PAUSED);
}
int main()
{
doCameraController();
return 0;
}
......@@ -35,7 +35,7 @@
using namespace imstk;
void testDeformableBody()
int main()
{
// a. SDK and Scene
auto sdk = std::make_shared<SimulationManager>();
......@@ -50,7 +50,7 @@ void testDeformableBody()
if (!tetMesh)
{
LOG(WARNING) << "Could not read mesh from file.";
return;
return 1;
}
// c. Extract the surface mesh
......@@ -59,7 +59,7 @@ void testDeformableBody()
if (!volTetMesh)
{
LOG(WARNING) << "Dynamic pointer cast from PointSet to TetrahedralMesh failed!";
return;
return 1;
}
volTetMesh->extractSurfaceMesh(surfMesh, true);
......@@ -164,10 +164,5 @@ void testDeformableBody()
// Run the simulation
sdk->setActiveScene(scene);
sdk->startSimulation(SimulationStatus::PAUSED);
}
int main()
{
testDeformableBody();
return 0;
}
......@@ -28,7 +28,7 @@
using namespace imstk;
void geometryTransforms()
int main()
{
// SDK and Scene
auto sdk = std::make_shared<SimulationManager>();
......@@ -43,7 +43,7 @@ void geometryTransforms()
auto planeGeom = std::make_shared<Plane>();
planeGeom->scale(80, Geometry::TransformType::ConcatenateToTransform);
planeGeom->translate(0, -20, 0, Geometry::TransformType::ConcatenateToTransform);
planeGeom->rotate(Vec3d(0, 1., 0), PI/4, Geometry::TransformType::ConcatenateToTransform);
planeGeom->rotate(Vec3d(0, 1., 0), PI / 4, Geometry::TransformType::ConcatenateToTransform);
auto planeObj = std::make_shared<VisualObject>("Plane");
planeObj->setVisualGeometry(planeGeom);
......@@ -73,9 +73,9 @@ void geometryTransforms()
// Rotate the dragon every frame
auto rotateFunc =
[&surfaceMesh](Module* module)
{
surfaceMesh->rotate(Vec3d(1., 0, 0), PI / 1000, Geometry::TransformType::ApplyToData);
};
{
surfaceMesh->rotate(Vec3d(1., 0, 0), PI / 1000, Geometry::TransformType::ApplyToData);
};
sdk->getSceneManager(scene)->setPostUpdateCallback(rotateFunc);
// Set Camera configuration
......@@ -92,10 +92,5 @@ void geometryTransforms()
// Run
sdk->setActiveScene(scene);
sdk->startSimulation(SimulationStatus::RUNNING);
}
int main()
{
geometryTransforms();
return 0;
}
......@@ -25,7 +25,7 @@
using namespace imstk;
void sampleGraph()
int main()
{
Graph g1(5);
g1.addEdge(0, 1);
......@@ -53,7 +53,7 @@ void sampleGraph()
if (!tetMesh)
{
std::cout << "Could not read mesh from file." << std::endl;
return;
return 1;
}
else
{
......@@ -61,7 +61,7 @@ void sampleGraph()
if (!volMesh)
{
LOG(WARNING) << "Dynamic pointer cast from PointSet to TetrahedralMesh failed!";
return;
return 1;
}
auto colorsGVMesh = volMesh->getMeshGraph().doGreedyColoring(true);
......@@ -73,10 +73,5 @@ void sampleGraph()
std::cout << "Press any key to exit!" << std::endl;
getchar();
}
int main()
{
sampleGraph();
return 0;
}
......@@ -31,6 +31,11 @@ using namespace imstk;
void lapToolController()
{
}
int main()
{
#ifdef iMSTK_USE_OPENHAPTICS
// SDK and Scene
auto sdk = std::make_shared<SimulationManager>();
......@@ -76,11 +81,6 @@ void lapToolController()
sdk->startSimulation(SimulationStatus::PAUSED);
#endif
}
int main()
{
lapToolController();
return 0;
}
......@@ -25,7 +25,7 @@
using namespace imstk;
void readMesh()
int main()
{
// SDK and Scene
auto sdk = std::make_shared<SimulationManager>();
......@@ -61,10 +61,5 @@ void readMesh()
// Run
sdk->setActiveScene(scene);
sdk->startSimulation(SimulationStatus::PAUSED);
}
int main()
{
readMesh();
return 0;
}
......@@ -30,7 +30,7 @@ const std::string phantomOmni1Name = "Phantom1";
using namespace imstk;
void objectController()
int main()
{
#ifdef iMSTK_USE_OPENHAPTICS
// SDK and Scene
......@@ -75,10 +75,5 @@ void objectController()
sdk->setActiveScene(scene);
sdk->startSimulation(SimulationStatus::RUNNING);
#endif
}
int main()
{
objectController();
return 0;
}
......@@ -26,8 +26,10 @@
using namespace imstk;
void pbdCloth()
int main()
{
auto sdk = std::make_shared<SimulationManager>();
auto scene = sdk->createNewScene("PBDCloth");
......@@ -124,11 +126,7 @@ void pbdCloth()
// Start
sdk->setActiveScene(scene);
sdk->startSimulation(SimulationStatus::PAUSED);
}
int main()
{
pbdCloth();
return 0;
}
......@@ -28,7 +28,7 @@
using namespace imstk;
void pbdCollision()
int main()
{
auto sdk = std::make_shared<SimulationManager>();
auto scene = sdk->createNewScene("PbdCollision");
......@@ -40,7 +40,7 @@ void pbdCollision()
if (!tetMesh)
{
LOG(WARNING) << "Could not read mesh from file.";
return;
return 1;
}
auto surfMesh = std::make_shared<SurfaceMesh>();
......@@ -49,7 +49,7 @@ void pbdCollision()
if (!volTetMesh)
{
LOG(WARNING) << "Dynamic pointer cast from PointSet to TetrahedralMesh failed!";
return;
return 1;
}
volTetMesh->extractSurfaceMesh(surfMesh, true);
......@@ -188,7 +188,7 @@ void pbdCollision()
if (!tetMesh1)
{
LOG(WARNING) << "Could not read mesh from file.";
return;
return 1;
}
auto surfMesh1 = std::make_shared<SurfaceMesh>();
......@@ -197,7 +197,7 @@ void pbdCollision()
if (!volTetMesh1)
{
LOG(WARNING) << "Dynamic pointer cast from PointSet to TetrahedralMesh failed!";
return;
return 1;
}
auto vs = volTetMesh1->getInitialVertexPositions();
......@@ -349,10 +349,6 @@ void pbdCollision()
sdk->setActiveScene(scene);
sdk->startSimulation(SimulationStatus::PAUSED);
}
int main()
{
pbdCollision();
return 0;
}
......@@ -28,7 +28,7 @@
using namespace imstk;
void pbdFluid()
int main()
{
auto sdk = std::make_shared<SimulationManager>();
auto scene = sdk->createNewScene("PBDFluid");
......@@ -40,7 +40,7 @@ void pbdFluid()
if (!tetMesh)
{
LOG(WARNING) << "Could not read mesh from file.";
return;
return 1;
}
auto fluidMesh = std::make_shared<PointSet>();
......@@ -124,7 +124,7 @@ void pbdFluid()
const double z = (double)dz*j;
const double x = (double)dx1*i;
vertList[(nPointPerSide)+i*nCols + j] = Vec3d(x - 20, z - 10.0, 20);
vertList[(nPointPerSide*2)+i*nCols + j] = Vec3d(x - 20, z - 10.0, -20);
vertList[(nPointPerSide * 2) + i*nCols + j] = Vec3d(x - 20, z - 10.0, -20);
}
}
......@@ -138,8 +138,8 @@ void pbdFluid()
tri[1] = { { (nPointPerSide)+(i + 1)*nCols + j + 1, (nPointPerSide)+(i + 1)*nCols + j, (nPointPerSide)+i*nCols + j + 1 } };
triangles.push_back(tri[0]);
triangles.push_back(tri[1]);
tri[0] = { { (nPointPerSide*2)+i*nCols + j, (nPointPerSide*2)+i*nCols + j + 1, (nPointPerSide*2)+(i + 1)*nCols + j } };
tri[1] = { { (nPointPerSide*2)+(i + 1)*nCols + j + 1, (nPointPerSide*2)+(i + 1)*nCols + j, (nPointPerSide*2)+i*nCols + j + 1 } };
tri[0] = { { (nPointPerSide * 2) + i*nCols + j, (nPointPerSide * 2) + i*nCols + j + 1, (nPointPerSide * 2) + (i + 1)*nCols + j } };
tri[1] = { { (nPointPerSide * 2) + (i + 1)*nCols + j + 1, (nPointPerSide * 2) + (i + 1)*nCols + j, (nPointPerSide * 2) + i*nCols + j + 1 } };
triangles.push_back(tri[0]);
triangles.push_back(tri[1]);
}
......@@ -158,8 +158,8 @@ void pbdFluid()
{
const double z = (double)dz1*j;
const double y = (double)dy1*i;
vertList[(nPointPerSide * 3)+i*nCols + j] = Vec3d(20, z - 10.0, y-20);
vertList[(nPointPerSide * 4) + i*nCols + j] = Vec3d(-20, z - 10.0, y-20);
vertList[(nPointPerSide * 3) + i*nCols + j] = Vec3d(20, z - 10.0, y - 20);
vertList[(nPointPerSide * 4) + i*nCols + j] = Vec3d(-20, z - 10.0, y - 20);
}
}
......@@ -169,8 +169,8 @@ void pbdFluid()
for (std::size_t j = 0; j < nCols - 1; j++)
{
SurfaceMesh::TriangleArray tri[2];
tri[0] = { { (nPointPerSide * 3)+i*nCols + j, (nPointPerSide * 3)+i*nCols + j + 1, (nPointPerSide * 3)+(i + 1)*nCols + j } };
tri[1] = { { (nPointPerSide * 3)+(i + 1)*nCols + j + 1, (nPointPerSide * 3)+(i + 1)*nCols + j, (nPointPerSide * 3)+i*nCols + j + 1 } };
tri[0] = { { (nPointPerSide * 3) + i*nCols + j, (nPointPerSide * 3) + i*nCols + j + 1, (nPointPerSide * 3) + (i + 1)*nCols + j } };
tri[1] = { { (nPointPerSide * 3) + (i + 1)*nCols + j + 1, (nPointPerSide * 3) + (i + 1)*nCols + j, (nPointPerSide * 3) + i*nCols + j + 1 } };
triangles.push_back(tri[0]);
triangles.push_back(tri[1]);
tri[0] = { { (nPointPerSide * 4) + i*nCols + j, (nPointPerSide * 4) + i*nCols + j + 1, (nPointPerSide * 4) + (i + 1)*nCols + j } };
......@@ -245,10 +245,5 @@ void pbdFluid()
sdk->setActiveScene(scene);
sdk->startSimulation(SimulationStatus::PAUSED);
}
int main()
{
pbdFluid();
return 0;
}
......@@ -28,7 +28,7 @@
using namespace imstk;
void pbdVolume()
int main()
{
auto sdk = std::make_shared<SimulationManager>();
auto scene = sdk->createNewScene("PBDVolume");
......@@ -39,7 +39,7 @@ void pbdVolume()
if (!tetMesh)
{
LOG(WARNING) << "Could not read mesh from file.";
return;
return 1;
}
// c. Extract the surface mesh
......@@ -48,7 +48,7 @@ void pbdVolume()
if (!volTetMesh)
{
LOG(WARNING) << "Dynamic pointer cast from PointSet to TetrahedralMesh failed!";
return;
return 1 ;
}
volTetMesh->extractSurfaceMesh(surfMesh, true);
......@@ -76,7 +76,7 @@ void pbdVolume()
/*TimeStep*/ 0.01,
/*FixedPoint*/ "51 127 178",
/*NumberOfIterationInConstraintSolver*/ 5
);
);
deformableObj->setDynamicalModel(pbdModel);
deformableObj->setVisualGeometry(surfMesh);
......@@ -111,11 +111,5 @@ void pbdVolume()
sdk->setActiveScene(scene);
sdk->getViewer()->setBackgroundColors(Vec3d(0.3285, 0.3285, 0.6525), Vec3d(0.13836, 0.13836, 0.2748), true);
sdk->startSimulation();
}
int main()
{
pbdVolume();
return 0;
}
......@@ -38,7 +38,7 @@ const std::string phantomOmni1Name = "Phantom1";
using namespace imstk;
void pickingSoftObject()
int main()
{
// SDK and Scene
auto sdk = std::make_shared<SimulationManager>();
......@@ -59,14 +59,14 @@ void pickingSoftObject()
if (!tetMesh)
{
LOG(WARNING) << "Could not read mesh from file.";
return;
return 1;
}
// Extract the surface mesh
auto volTetMesh = std::dynamic_pointer_cast<TetrahedralMesh>(tetMesh);
if (!volTetMesh)
{
LOG(WARNING) << "Dynamic pointer cast from PointSet to TetrahedralMesh failed!";
return;
return 1;
}
auto surfMesh = std::make_shared<SurfaceMesh>();
volTetMesh->extractSurfaceMesh(surfMesh);
......@@ -165,10 +165,5 @@ void pickingSoftObject()
// Run
sdk->setActiveScene(scene);
sdk->startSimulation(SimulationStatus::PAUSED);
}
int main()
{
pickingSoftObject();
return 0;
}
......@@ -23,7 +23,7 @@
using namespace imstk;
void doVectorPlotting()
int main()
{
Vectord a;
a.resize(100);
......@@ -40,10 +40,5 @@ void doVectorPlotting()
plotterutils::writePlotterVecVsVecMatPlotlib(a, b, "plotXvsY.py");
getchar();
}
int main()
{
doVectorPlotting();
return 0;
}
......@@ -24,7 +24,7 @@
using namespace imstk;
void sampleRendering()
int main()
{
// SDK and Scene
auto sdk = std::make_shared<SimulationManager>();
......@@ -95,10 +95,5 @@ void sampleRendering()
viewer->enableFullscreen();
#endif
sdk->startSimulation(SimulationStatus::PAUSED);
}
int main()
{
sampleRendering();
return 0;
}
......@@ -23,7 +23,7 @@
using namespace imstk;
void sampleScenesManagement()
int main()
{
// THIS TESTS NEEDS TO DISABLE STANDALONE VIEWER RENDERING
......@@ -67,10 +67,6 @@ void sampleScenesManagement()
// Quit
while (sdk->getStatus() != SimulationStatus::INACTIVE) {}
}
int main()
{
sampleScenesManagement();
return 0;
}
......@@ -26,8 +26,7 @@
using namespace imstk;
void screenShotUtility()
int main()
{
// SDK and Scene
auto sdk = std::make_shared<SimulationManager>();
......@@ -98,11 +97,5 @@ void screenShotUtility()
// Run
sdk->setActiveScene(sceneTest);
sdk->startSimulation(SimulationStatus::PAUSED);
}
int main()
{
screenShotUtility();
return 0;
}
......@@ -24,7 +24,7 @@
using namespace imstk;
void sampleViewer()
int main()
{
// SDK and Scene
auto sdk = std::make_shared<SimulationManager>();
......@@ -68,10 +68,5 @@ void sampleViewer()
// Run
sdk->setActiveScene(sceneTest);
sdk->startSimulation(SimulationStatus::PAUSED);
}
int main()
{
sampleViewer();
return 0;
}
......@@ -32,7 +32,7 @@ const std::string phantomOmni1Name = "Phantom1";
using namespace imstk;
void sampleVirtualCoupling()
int main()
{
// SDK and Scene
auto sdk = std::make_shared<SimulationManager>();
......@@ -84,9 +84,9 @@ void sampleVirtualCoupling()
// Create a collision graph
auto graph = scene->getCollisionGraph();
auto pair = graph->addInteractionPair(planeObj, obj,
CollisionDetection::Type::UnidirectionalPlaneToSphere,
CollisionHandling::Type::None,
CollisionHandling::Type::VirtualCoupling);
CollisionDetection::Type::UnidirectionalPlaneToSphere,
CollisionHandling::Type::None,
CollisionHandling::Type::VirtualCoupling);
// Customize collision handling algorithm
auto colHandlingAlgo = std::dynamic_pointer_cast<VirtualCouplingCH>(pair->getCollisionHandlingB());
......@@ -109,11 +109,6 @@ void sampleVirtualCoupling()
//Run
sdk->setActiveScene(scene);
sdk->startSimulation(SimulationStatus::RUNNING);
}
int main()
{
sampleVirtualCoupling();
return 0;
}
......@@ -25,7 +25,7 @@
using namespace imstk;
void renderDecals()
int main()
{
// SDK and Scene
auto sdk = std::make_shared<SimulationManager>();
......@@ -78,11 +78,6 @@ void renderDecals()
// Run
sdk->setActiveScene(scene);
sdk->startSimulation(SimulationStatus::PAUSED);
}
int main()
{
renderDecals();
return 0;
}
......@@ -25,7 +25,7 @@
using namespace imstk;
void doMeshCCD()
int main()
{
// SDK and Scene
auto sdk = std::make_shared<SimulationManager>();
......@@ -69,9 +69,9 @@ void doMeshCCD()
// Rotate the obj1 every frame
auto rotateFunc = [&](Module* module)
{
mesh1->rotate(Vec3d(1., 0, 0), PI / 1000, Geometry::TransformType::ApplyToData);
};
{
mesh1->rotate(Vec3d(1., 0, 0), PI / 1000, Geometry::TransformType::ApplyToData);
};
sdk->getSceneManager(scene)->setPostUpdateCallback(rotateFunc);
// Light
......@@ -86,11 +86,6 @@ void doMeshCCD()
// Run
sdk->setActiveScene(scene);
sdk->startSimulation(SimulationStatus::PAUSED);
}
int main()
{
doMeshCCD();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment