diff --git a/Examples/Audio/Audio.cpp b/Examples/Audio/Audio.cpp index 37043adfbc35619dcb9544749d78c6fb005e4541..6324fde12a21ce91c0d88d872456283f8c9ca594 100644 --- a/Examples/Audio/Audio.cpp +++ b/Examples/Audio/Audio.cpp @@ -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 diff --git a/Examples/CameraController/CameraController.cpp b/Examples/CameraController/CameraController.cpp index dcbb346e82b5ffd53de0462839a2566156456cd7..d9e61b8367cb53bf478c64e218d7c79ed7d05dfb 100644 --- a/Examples/CameraController/CameraController.cpp +++ b/Examples/CameraController/CameraController.cpp @@ -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 diff --git a/Examples/DeformableBody/DeformableBody.cpp b/Examples/DeformableBody/DeformableBody.cpp index c6ec937d642bb2208b7e9c3a5ce3605eac8ded3b..b48d1e2fae84b61825cba74e20b752e7561b04e8 100644 --- a/Examples/DeformableBody/DeformableBody.cpp +++ b/Examples/DeformableBody/DeformableBody.cpp @@ -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; } diff --git a/Examples/GeometryTransforms/GeometryTransforms.cpp b/Examples/GeometryTransforms/GeometryTransforms.cpp index 9d781087d94d42b684e6fea9e432ea7716ce1ebc..a50ccf6b58f184472c00f4769363ae5c8496c677 100644 --- a/Examples/GeometryTransforms/GeometryTransforms.cpp +++ b/Examples/GeometryTransforms/GeometryTransforms.cpp @@ -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; } diff --git a/Examples/Graph/Graph.cpp b/Examples/Graph/Graph.cpp index b6e57f62f1bcc54ad8a8b04289dce177718928c8..2e0e38a6082ed653e9b2d3a51b3d4322c5aa19fb 100644 --- a/Examples/Graph/Graph.cpp +++ b/Examples/Graph/Graph.cpp @@ -76,5 +76,6 @@ int main() std::cout << "Press any key to exit!" << std::endl; getchar(); + return 0; } diff --git a/Examples/LaparoscopicToolController/LaparoscopicToolController.cpp b/Examples/LaparoscopicToolController/LaparoscopicToolController.cpp index 87189f8d04d4477874ac058ae1e1b98f9fb48ace..c3571d2d7a221b9070bba49ae7f6e83d98673705 100644 --- a/Examples/LaparoscopicToolController/LaparoscopicToolController.cpp +++ b/Examples/LaparoscopicToolController/LaparoscopicToolController.cpp @@ -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 } diff --git a/Examples/MeshIO/MeshIO.cpp b/Examples/MeshIO/MeshIO.cpp index 464fb99695d2224cfcbfc37920bbe28fe4d50595..2d5db554459f53b9e9fa82e2c3ecf796efed1863 100644 --- a/Examples/MeshIO/MeshIO.cpp +++ b/Examples/MeshIO/MeshIO.cpp @@ -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; } diff --git a/Examples/MshVegaIO/MshVegaIO.cpp b/Examples/MshVegaIO/MshVegaIO.cpp index e50b7c976ba4030bd4922b2c5c98fdd5bc977d8a..fb2d42607e548de62c8d1a4fbd074025400b5bca 100644 --- a/Examples/MshVegaIO/MshVegaIO.cpp +++ b/Examples/MshVegaIO/MshVegaIO.cpp @@ -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; } diff --git a/Examples/PBDCloth/pbdClothExample.cpp b/Examples/PBDCloth/pbdClothExample.cpp index d38b7082f9ef80468cbe9544acaead5596455866..4bd09d15bff214222bf9cef50a8cb5943ff0684e 100644 --- a/Examples/PBDCloth/pbdClothExample.cpp +++ b/Examples/PBDCloth/pbdClothExample.cpp @@ -129,6 +129,5 @@ int main() sdk->setActiveScene(scene); sdk->startSimulation(SimulationStatus::PAUSED); - return 0; } diff --git a/Examples/PBDFluids/PBDFluidsExample.cpp b/Examples/PBDFluids/PBDFluidsExample.cpp index 6a85d98fb6a60a45c500b2b2a595008de24f65bb..fd70ea39c56e11cda1c97d60acfce53e6a3682b2 100644 --- a/Examples/PBDFluids/PBDFluidsExample.cpp +++ b/Examples/PBDFluids/PBDFluidsExample.cpp @@ -249,5 +249,6 @@ int main() sdk->setActiveScene(scene); sdk->startSimulation(SimulationStatus::PAUSED); + return 0; } diff --git a/Examples/PBDVolume/PBDVolumeExample.cpp b/Examples/PBDVolume/PBDVolumeExample.cpp index 7c6ef95853be5ca27573888f7554f77e1ffd80dd..eb985c8fb1d39dd0f380107d72cdfb9748ad42e7 100644 --- a/Examples/PBDVolume/PBDVolumeExample.cpp +++ b/Examples/PBDVolume/PBDVolumeExample.cpp @@ -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; } diff --git a/Examples/Picking/Picking.cpp b/Examples/Picking/Picking.cpp index cb61bd4455e829560af23a712d5410e53ceafc40..0be9f4255db9fec75717e107e419701310bb0682 100644 --- a/Examples/Picking/Picking.cpp +++ b/Examples/Picking/Picking.cpp @@ -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 } diff --git a/Examples/PlotVectors/PlotVectors.cpp b/Examples/PlotVectors/PlotVectors.cpp index 95fe9f373d2777a4cdf8c9b21b0483e87f4611d0..c8e946e1bb06d6462cc9db3c2e0f6479f4f467eb 100644 --- a/Examples/PlotVectors/PlotVectors.cpp +++ b/Examples/PlotVectors/PlotVectors.cpp @@ -43,5 +43,6 @@ int main() plotterutils::writePlotterVecVsVecMatPlotlib(a, b, "plotXvsY.py"); getchar(); + return 0; } diff --git a/Examples/Rendering/Rendering.cpp b/Examples/Rendering/Rendering.cpp index 113bbc43e3f6ce05b0acf44ef9705b1f9fd945b0..32fb7b03f2e6882c71f3dca9e8f8b5f9704760c9 100644 --- a/Examples/Rendering/Rendering.cpp +++ b/Examples/Rendering/Rendering.cpp @@ -98,6 +98,8 @@ int main() viewer->disableVSync(); viewer->enableFullscreen(); #endif + sdk->startSimulation(SimulationStatus::PAUSED); + return 0; } diff --git a/Examples/SceneManagement/SceneManagement.cpp b/Examples/SceneManagement/SceneManagement.cpp index 9b5aae1d4304ff1b601ad03a946847fb7417b001..605a66811b82521769f278c55f406cc19f80ba20 100644 --- a/Examples/SceneManagement/SceneManagement.cpp +++ b/Examples/SceneManagement/SceneManagement.cpp @@ -28,8 +28,6 @@ using namespace imstk; /// int main() { - // THIS TESTS NEEDS TO DISABLE STANDALONE VIEWER RENDERING - auto sdk = std::make_shared<SimulationManager>(); // Scenes diff --git a/Examples/Screenshot/Screenshot.cpp b/Examples/Screenshot/Screenshot.cpp index 0c09621df44f3de6e23b2b2ace337b5bdaf5f0ad..2ea5a975e899f8949e9bc0e945a9efd8a4bddadb 100644 --- a/Examples/Screenshot/Screenshot.cpp +++ b/Examples/Screenshot/Screenshot.cpp @@ -100,5 +100,6 @@ int main() // Run sdk->setActiveScene(sceneTest); sdk->startSimulation(SimulationStatus::PAUSED); + return 0; } diff --git a/Examples/Viewer/Viewer.cpp b/Examples/Viewer/Viewer.cpp index 43fccdcf21e27a7b5ce30c8520920f25480a89ba..22c0be275d25a2bc7bb73675e794d0f55b3763e0 100644 --- a/Examples/Viewer/Viewer.cpp +++ b/Examples/Viewer/Viewer.cpp @@ -72,5 +72,6 @@ int main() // Run sdk->setActiveScene(sceneTest); sdk->startSimulation(SimulationStatus::PAUSED); + return 0; } diff --git a/Examples/VirtualCoupling/VirtualCoupling.cpp b/Examples/VirtualCoupling/VirtualCoupling.cpp index 670ee64827c18e1a7384204aa9bc39fcd14258ff..9ce1c0582ed5d952003ff0448f25fb5e20220055 100644 --- a/Examples/VirtualCoupling/VirtualCoupling.cpp +++ b/Examples/VirtualCoupling/VirtualCoupling.cpp @@ -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 }