22 #include "imstkFeDeformableObject.h" 23 #include "imstkRenderMaterial.h" 24 #include "imstkBackwardEuler.h" 25 #include "imstkPlane.h" 26 #include "imstkTetrahedralMesh.h" 27 #include "imstkMeshIO.h" 28 #include "imstkMouseSceneControl.h" 30 #include "imstkOneToOneMap.h" 31 #include "imstkDirectionalLight.h" 32 #include "imstkCamera.h" 33 #include "imstkReducedStVKBodyModel.h" 34 #include "imstkReducedFeDeformableObject.h" 35 #include "imstkSurfaceMesh.h" 36 #include "imstkScene.h" 37 #include "imstkSceneManager.h" 38 #include "imstkVisualModel.h" 39 #include "imstkVTKViewer.h" 40 #include "imstkKeyboardSceneControl.h" 42 using namespace imstk;
44 std::shared_ptr<DynamicObject> createAndAddFEDeformable(std::shared_ptr<Scene> scene, std::shared_ptr<TetrahedralMesh> tetMesh);
55 std::string meshFileName;
56 std::string cubFileName;
57 std::string modesFileName;
76 input.meshFileName = iMSTK_DATA_ROOT
"asianDragon/asianDragon.veg";
77 input.cubFileName = iMSTK_DATA_ROOT
"asianDragon/asianDragon.cub";
78 input.modesFileName = iMSTK_DATA_ROOT
"asianDragon/asianDragon.URendering.float";
80 else if (geom == Heart)
82 input.meshFileName = iMSTK_DATA_ROOT
"/heart/heart.veg";
83 input.cubFileName = iMSTK_DATA_ROOT
"heart/heart.cub";
84 input.modesFileName = iMSTK_DATA_ROOT
"heart/heart.URendering.float";
89 sceneConfig->taskParallelizationEnabled =
false;
93 std::shared_ptr<Camera> cam = scene->getActiveCamera();
94 cam->setPosition(0.0, 2.0, -25.0);
95 cam->setFocalPoint(0.0, 0.0, 0.0);
98 auto tetMesh = MeshIO::read<TetrahedralMesh>(input.meshFileName);
99 CHECK(tetMesh !=
nullptr) <<
"Could not read mesh from file.";
102 std::shared_ptr<DynamicObject> deformableObj = createAndAddFEDeformable(scene, tetMesh);
106 planeGeom->setWidth(40);
109 planeObj->setVisualGeometry(planeGeom);
110 planeObj->setCollidingGeometry(planeGeom);
111 scene->addSceneObject(planeObj);
115 light->setFocalPoint(Vec3d(5.0, -8.0, -5.0));
116 light->setIntensity(1);
117 scene->addLight(light);
124 viewer->setActiveScene(scene);
128 sceneManager->setActiveScene(scene);
129 viewer->addChildThread(sceneManager);
134 mouseControl->setSceneManager(sceneManager);
135 viewer->addControl(mouseControl);
138 keyControl->setSceneManager(sceneManager);
139 keyControl->setViewer(viewer);
140 viewer->addControl(keyControl);
144 sceneManager->requestStatus(ThreadStatus::Paused);
151 std::shared_ptr<DynamicObject>
152 createAndAddFEDeformable(std::shared_ptr<Scene> scene,
153 std::shared_ptr<TetrahedralMesh> tetMesh)
156 tetMesh->extractSurfaceMesh(surfMesh,
true);
161 config->m_cubicPolynomialFilename = input.cubFileName;
162 config->m_modesFileName = input.modesFileName;
172 mat->setDisplayMode(RenderMaterial::DisplayMode::WireframeSurface);
173 mat->setPointSize(10.);
174 mat->setLineWidth(4.);
175 mat->setEdgeColor(Color::Orange);
177 surfMeshModel->setRenderMaterial(mat);
181 deformableObj->addVisualModel(surfMeshModel);
182 deformableObj->setPhysicsGeometry(tetMesh);
184 deformableObj->setPhysicsToVisualMap(std::make_shared<OneToOneMap>(tetMesh, surfMesh));
185 deformableObj->setDynamicalModel(dynaModel);
186 scene->addSceneObject(deformableObj);
188 return deformableObj;
virtual void setTimeStepSizeType(const TimeSteppingType type)
Get/Set the type of approach used to update the time step size after every frame. ...
void configure(const std::string &configFileName)
Configure the force model from external file.
const std::shared_ptr< T > & get() const
Returns const ref to STL smart pointer.
void setTimeIntegrator(std::shared_ptr< TimeIntegrator > timeIntegrator)
Set/Get time integrator.
std::shared_ptr<T> obj = std::make_shared<T>(); equivalent, convenience class for STL shared allocati...
void setModelGeometry(std::shared_ptr< Geometry > geometry)
Sets the model geometry.
void setPosition(const Vec3d p)
Set the local position.
static LoggerG3 & startLogger()
Starts logger with default sinks, use getInstance to create a logger with no sinks.