Commit a386ca37 authored by Sreekanth Arikatla's avatar Sreekanth Arikatla

REFAC: Clean examples

parent 46ab4ff2
......@@ -72,7 +72,7 @@ void playSound(const std::string& filename)
std::cout << std::flush;
}
std::cout << "\n" << std::endl;
#else
#else if
LOG(INFO) << "testSound: Audio is supported only on windows!";
#endif
}
......@@ -117,12 +117,17 @@ void playMusic(const std::string& filename)
/// \brief This example demonstrates the audio feature in imstk.
/// NOTE: Example modified from SFML/Examples
///
void main()
int main()
{
// Initialize g3logger
auto logger = std::make_shared<LogUtility>();
logger->createLogger("audio-Example", "./");
#ifndef iMSTK_AUDIO_ENABLED
LOG(INFO) << "Audio not enabled at build time\n";
return 1;
#endif
LOG(INFO) << "--Testing audio--\n";
// Test a sound
......@@ -130,4 +135,6 @@ void main()
// Test music from an .ogg file
playMusic(iMSTK_DATA_ROOT "/sound/orchestral.ogg");
return 0;
}
\ No newline at end of file
......@@ -40,7 +40,12 @@ using namespace imstk;
///
int main()
{
// SDK and Scene
#ifndef iMSTK_USE_OPENHAPTICS
std::cout << "Audio not enabled at build time" << std::endl;
return 1;
#endif
// Create SDK and Scene
auto sdk = std::make_shared<SimulationManager>();
auto scene = sdk->createNewScene("CameraController");
......@@ -57,7 +62,7 @@ int main()
#endif
// Mesh
// Load Mesh
auto mesh = MeshIO::read(iMSTK_DATA_ROOT "/asianDragon/asianDragon.obj");
auto meshObject = std::make_shared<VisualObject>("meshObject");
meshObject->setVisualGeometry(mesh);
......@@ -68,7 +73,7 @@ int main()
cam->setPosition(Vec3d(0, 0, 10));
#ifdef iMSTK_USE_OPENHAPTICS
auto camControllerInput = std::make_shared<CameraController>(*cam, client);
// Set camera controller
......
......@@ -47,10 +47,7 @@ int main()
scene->getCamera()->setPosition(0, 2.0, 15.0);
// b. Load a tetrahedral mesh
//auto tetMesh = MeshIO::read(iMSTK_DATA_ROOT "/oneTet/oneTet.veg");
auto tetMesh = MeshIO::read(iMSTK_DATA_ROOT "/asianDragon/asianDragon.veg");
//auto tetMesh = MeshIO::read(iMSTK_DATA_ROOT"/liver/liver.veg");
//auto tetMesh = MeshIO::read(iMSTK_DATA_ROOT"/oneTet/oneTet.veg");
if (!tetMesh)
{
LOG(WARNING) << "Could not read mesh from file.";
......@@ -90,10 +87,8 @@ int main()
// Configure dynamic model
auto dynaModel = std::make_shared<FEMDeformableBodyModel>();
//dynaModel->configure(iMSTK_DATA_ROOT "/oneTet/oneTet.config");
dynaModel->configure(iMSTK_DATA_ROOT "/asianDragon/asianDragon.config");
dynaModel->setTimeStepSizeType(TimeSteppingType::realTime);
//dynaModel->configure(iMSTK_DATA_ROOT"/liver/liver.config");
dynaModel->setModelGeometry(volTetMesh);
auto timeIntegrator = std::make_shared<BackwardEuler>(0.001);// Create and add Backward Euler time integrator
dynaModel->setTimeIntegrator(timeIntegrator);
......@@ -105,7 +100,6 @@ int main()
// Scene Object
auto deformableObj = std::make_shared<DeformableObject>("Dragon");
deformableObj->setVisualGeometry(surfMesh);
//deformableObj->setCollidingGeometry(surfMesh);
deformableObj->setPhysicsGeometry(volTetMesh);
deformableObj->setPhysicsToVisualMap(oneToOneNodalMap); //assign the computed map
deformableObj->setDynamicalModel(dynaModel);
......@@ -143,10 +137,7 @@ int main()
nlSystem->setUpdatePreviousStatesFunction(dynaModel->getUpdatePrevStateFunction());
// create a linear solver
//auto linSolver = std::make_shared<ConjugateGradient>();
auto linSolver = std::make_shared<GaussSeidel>();
//auto linSolver = std::make_shared<Jacobi>();
//auto linSolver = std::make_shared<SOR>(0.4);
// create a non-linear solver and add to the scene
auto nlSolver = std::make_shared<NewtonSolver>();
......@@ -168,5 +159,6 @@ int main()
// Run the simulation
sdk->setActiveScene(scene);
sdk->startSimulation(SimulationStatus::PAUSED);
return 0;
}
......@@ -39,6 +39,12 @@ int main()
auto sceneObj = apiutils::createAndAddVisualSceneObject(scene, iMSTK_DATA_ROOT "/asianDragon/asianDragon.obj", "Dragon");
if (!sceneObj)
{
LOG(WARNING) << "ERROR: Unable to create scene object";
return 1;
}
auto surfaceMesh = sceneObj->getVisualGeometry();
surfaceMesh->scale(5., Geometry::TransformType::ConcatenateToTransform);
......@@ -95,5 +101,6 @@ int main()
// Run
sdk->setActiveScene(scene);
sdk->startSimulation(SimulationStatus::RUNNING);
return 0;
}
......@@ -76,5 +76,6 @@ int main()
std::cout << "Press any key to exit!" << std::endl;
getchar();
return 0;
}
......@@ -80,7 +80,9 @@ int main()
sdk->setActiveScene(scene);
sdk->startSimulation(SimulationStatus::PAUSED);
#endif
return 0;
#else if
std::cout << "LaparoscopicToolController example needs haptic device to be enabled at build time" << std::endl;
return 1;
#endif
}
......@@ -45,6 +45,12 @@ int main()
//auto vtkMesh2 = MeshIO::read(iMSTK_DATA_ROOT"/nidus/nidus.vtk");
auto vegaMesh = MeshIO::read(iMSTK_DATA_ROOT "/asianDragon/asianDragon.veg");
if (!vegaMesh)
{
LOG(WARNING) << "Unable to load mesh!";
return 1;
}
// Extract surface mesh
auto volumeMesh = std::dynamic_pointer_cast<VolumetricMesh>(vegaMesh); // change to any volumetric mesh above
volumeMesh->computeAttachedSurfaceMesh();
......@@ -64,5 +70,6 @@ int main()
// Run
sdk->setActiveScene(scene);
sdk->startSimulation(SimulationStatus::PAUSED);
return 0;
}
......@@ -28,7 +28,7 @@ using namespace imstk;
///
/// \brief This example shows how to read .msh and .veg files
///
void MshAndVegaIO()
int main()
{
// SDK and Scene
auto sdk = std::make_shared<SimulationManager>();
......@@ -40,7 +40,7 @@ void MshAndVegaIO()
if (!volMeshA)
{
LOG(WARNING) << "Failed to read msh file : " << ifile;
return;
return 1;
}
// Extract surface mesh
......@@ -65,7 +65,7 @@ void MshAndVegaIO()
if (!volMeshB)
{
LOG(WARNING) << "Failed to extract topology/geometry from the veg file : " << ofile;
return;
return 1;
}
// Extract surface mesh
......@@ -91,10 +91,6 @@ void MshAndVegaIO()
// Run
sdk->setActiveScene(scene);
sdk->startSimulation(SimulationStatus::PAUSED);
}
int main()
{
MshAndVegaIO();
return 0;
}
......@@ -129,6 +129,5 @@ int main()
sdk->setActiveScene(scene);
sdk->startSimulation(SimulationStatus::PAUSED);
return 0;
}
......@@ -249,5 +249,6 @@ int main()
sdk->setActiveScene(scene);
sdk->startSimulation(SimulationStatus::PAUSED);
return 0;
}
......@@ -115,5 +115,6 @@ int main()
sdk->setActiveScene(scene);
sdk->getViewer()->setBackgroundColors(Vec3d(0.3285, 0.3285, 0.6525), Vec3d(0.13836, 0.13836, 0.2748), true);
sdk->startSimulation();
return 0;
}
......@@ -44,6 +44,10 @@ using namespace imstk;
///
int main()
{
#ifndef iMSTK_USE_OPENHAPTICS
std::cout << "LaparoscopicToolController example needs haptic device to be enabled at build time" << std::endl;
return 1;
#else if
// SDK and Scene
auto sdk = std::make_shared<SimulationManager>();
auto scene = sdk->createNewScene("Picking");
......@@ -126,7 +130,6 @@ int main()
//----------------------------------------------------------
// Create object controller
//----------------------------------------------------------
#ifdef iMSTK_USE_OPENHAPTICS
// Device clients
auto client = std::make_shared<HDAPIDeviceClient>(phantomOmni1Name);
......@@ -159,7 +162,6 @@ int main()
// Create collision pair
scene->getCollisionGraph()->addInteractionPair(physicsObj, sphereForPickObj, pickingCD, pickingCH, nullptr);
#endif
// Set Camera configuration
auto cam = scene->getCamera();
......@@ -169,5 +171,7 @@ int main()
// Run
sdk->setActiveScene(scene);
sdk->startSimulation(SimulationStatus::PAUSED);
return 0;
#endif
}
......@@ -43,5 +43,6 @@ int main()
plotterutils::writePlotterVecVsVecMatPlotlib(a, b, "plotXvsY.py");
getchar();
return 0;
}
......@@ -98,6 +98,8 @@ int main()
viewer->disableVSync();
viewer->enableFullscreen();
#endif
sdk->startSimulation(SimulationStatus::PAUSED);
return 0;
}
......@@ -28,8 +28,6 @@ using namespace imstk;
///
int main()
{
// THIS TESTS NEEDS TO DISABLE STANDALONE VIEWER RENDERING
auto sdk = std::make_shared<SimulationManager>();
// Scenes
......
......@@ -100,5 +100,6 @@ int main()
// Run
sdk->setActiveScene(sceneTest);
sdk->startSimulation(SimulationStatus::PAUSED);
return 0;
}
......@@ -72,5 +72,6 @@ int main()
// Run
sdk->setActiveScene(sceneTest);
sdk->startSimulation(SimulationStatus::PAUSED);
return 0;
}
......@@ -38,6 +38,10 @@ using namespace imstk;
///
int main()
{
#ifndef iMSTK_USE_OPENHAPTICS
std::cout << "LaparoscopicToolController example needs haptic device to be enabled at build time" << std::endl;
return 1;
#else if
// SDK and Scene
auto sdk = std::make_shared<SimulationManager>();
auto scene = sdk->createNewScene("VirtualCoupling");
......@@ -52,7 +56,6 @@ int main()
scene->addSceneObject(planeObj);
// Create the virtual coupling object controller
#ifdef iMSTK_USE_OPENHAPTICS
// Device clients
auto client = std::make_shared<HDAPIDeviceClient>(phantomOmni1Name);
......@@ -97,8 +100,6 @@ int main()
colHandlingAlgo->setStiffness(5e-01);
colHandlingAlgo->setDamping(0.005);
#endif
// Move Camera
auto cam = scene->getCamera();
cam->setPosition(Vec3d(200, 200, 200));
......@@ -115,4 +116,5 @@ int main()
sdk->startSimulation(SimulationStatus::RUNNING);
return 0;
#endif
}
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