7 #include "imstkBackwardEuler.h" 8 #include "imstkCamera.h" 9 #include "imstkDirectionalLight.h" 10 #include "imstkFeDeformableObject.h" 11 #include "imstkFemDeformableBodyModel.h" 12 #include "imstkKeyboardDeviceClient.h" 13 #include "imstkKeyboardSceneControl.h" 14 #include "imstkLogger.h" 15 #include "imstkMeshIO.h" 16 #include "imstkMouseDeviceClient.h" 17 #include "imstkMouseSceneControl.h" 19 #include "imstkPlane.h" 20 #include "imstkPointwiseMap.h" 21 #include "imstkRenderMaterial.h" 22 #include "imstkScene.h" 23 #include "imstkSceneManager.h" 24 #include "imstkSimulationManager.h" 25 #include "imstkSimulationUtils.h" 26 #include "imstkSurfaceMesh.h" 27 #include "imstkTetrahedralMesh.h" 28 #include "imstkVisualModel.h" 29 #include "imstkVTKViewer.h" 31 using namespace imstk;
33 std::shared_ptr<FeDeformableObject> makeFEDeformableObject(std::shared_ptr<TetrahedralMesh> tetMesh);
43 std::string meshFileName;
44 std::vector<std::size_t> fixedNodeIds;
48 const Geom geom = Heart;
63 input.meshFileName = iMSTK_DATA_ROOT
"asianDragon/asianDragon.veg";
64 input.fixedNodeIds = { 50, 126, 177 };
66 else if (geom == Heart)
68 input.meshFileName = iMSTK_DATA_ROOT
"textured_organs/heart_volume.vtk";
69 input.fixedNodeIds = { 75, 82, 84, 94, 95, 105, 110, 124, 139, 150, 161, 171, 350 };
76 cam->setPosition(0.0, 2.0, -25.0);
77 cam->setFocalPoint(0.0, 0.0, 0.0);
80 std::shared_ptr<TetrahedralMesh> tetMesh = MeshIO::read<TetrahedralMesh>(input.meshFileName);
81 CHECK(tetMesh !=
nullptr) <<
"Could not read mesh from file.";
84 std::shared_ptr<FeDeformableObject> deformableObj = makeFEDeformableObject(tetMesh);
89 planeGeom->setWidth(40.0);
92 planeObj->setVisualGeometry(planeGeom);
93 planeObj->setCollidingGeometry(planeGeom);
112 sceneManager->pause();
120 std::shared_ptr<Entity> mouseAndKeyControls =
121 SimulationUtils::createDefaultSceneControl(driver);
130 std::shared_ptr<FeDeformableObject>
131 makeFEDeformableObject(std::shared_ptr<TetrahedralMesh> tetMesh)
133 std::shared_ptr<SurfaceMesh> surfMesh = tetMesh->extractSurfaceMesh();
138 config->m_fixedNodeIds = input.fixedNodeIds;
148 mat->setDisplayMode(RenderMaterial::DisplayMode::WireframeSurface);
149 mat->setPointSize(10.0);
150 mat->setLineWidth(2.0);
151 mat->setEdgeColor(Color::Orange);
155 deformableObj->setVisualGeometry(surfMesh);
157 deformableObj->setPhysicsGeometry(tetMesh);
159 deformableObj->setPhysicsToVisualMap(std::make_shared<PointwiseMap>(tetMesh, surfMesh));
160 deformableObj->setDynamicalModel(dynaModel);
162 return deformableObj;
void setDesiredDt(const double dt)
Sets the target fixed timestep (may violate), seconds This ultimately effects the number of iteration...
void setActiveScene(std::shared_ptr< Scene > scene) override
Set scene to be rendered.
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.
void addModule(std::shared_ptr< Module > module) override
Add a module to run.
void setIntensity(const double intensity)
Set the light intensity. This value is unbounded.
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.
std::shared_ptr< Camera > getActiveCamera() const
Get the active camera for the scene.
void setTimeIntegrator(std::shared_ptr< TimeIntegrator > timeIntegrator)
Get/Set time integrator.
std::shared_ptr< VisualModel > getVisualModel(const int index) const
Get/add visual model.
void addSceneObject(std::shared_ptr< Entity > entity)
Add a scene object.
void addLight(const std::string &name, std::shared_ptr< Light > newLight)
Add light from the scene.
void setFocalPoint(const Vec3d &p)
Get/Set the light focal point.
void setActiveScene(std::string newSceneName)
Sets the currently updating scene.
static LoggerG3 & startLogger()
Starts logger with default sinks, use getInstance to create a logger with no sinks.