17 public string meshFileName;
18 public VectorSizet fixedNodeIds;
23 private const Geom geom = Geom.Heart;
24 private static Input input;
26 public static void Main(
string[] args)
32 if (geom == Geom.Dragon)
34 input.meshFileName =
"../data/asianDragon/asianDragon.veg";
35 input.fixedNodeIds =
new VectorSizet(3);
36 input.fixedNodeIds.Add(50);
37 input.fixedNodeIds.Add(126);
38 input.fixedNodeIds.Add(177);
40 else if (geom == Geom.Heart)
42 input.meshFileName =
"../data/textured_organs/heart_volume.vtk";
43 input.fixedNodeIds =
new VectorSizet(13);
44 input.fixedNodeIds.Add(75);
45 input.fixedNodeIds.Add(82);
46 input.fixedNodeIds.Add(84);
47 input.fixedNodeIds.Add(94);
48 input.fixedNodeIds.Add(95);
49 input.fixedNodeIds.Add(105);
50 input.fixedNodeIds.Add(110);
51 input.fixedNodeIds.Add(124);
52 input.fixedNodeIds.Add(139);
53 input.fixedNodeIds.Add(150);
54 input.fixedNodeIds.Add(161);
55 input.fixedNodeIds.Add(171);
56 input.fixedNodeIds.Add(350);
60 Scene scene =
new Scene(
"DeformableBodyFEM");
62 Camera cam = scene.getActiveCamera();
63 cam.setPosition(0.0, 2.0, -25.0);
64 cam.setFocalPoint(0.0, 0.0, 0.0);
67 TetrahedralMesh tetMesh = MeshIO.readTetrahedralMesh(input.meshFileName);
71 FeDeformableObject deformableObj = makeFEDeformableObject(tetMesh);
72 scene.addSceneObject(deformableObj);
75 Plane planeGeom =
new Plane();
76 planeGeom.setWidth(40.0);
77 planeGeom.setPosition(0.0, -8.0, 0.0);
78 CollidingObject planeObj =
new CollidingObject(
"Plane");
79 planeObj.setVisualGeometry(planeGeom);
80 planeObj.setCollidingGeometry(planeGeom);
81 scene.addSceneObject(planeObj);
84 DirectionalLight light =
new DirectionalLight();
85 light.setFocalPoint(
new Vec3d(5.0, -8.0, -5.0));
86 light.setIntensity(1);
87 scene.addLight(
"light", light);
93 VTKViewer viewer =
new VTKViewer(
"Viewer");
94 viewer.setActiveScene(scene);
97 SceneManager sceneManager =
new SceneManager(
"Scene Manager");
98 sceneManager.setActiveScene(scene);
101 SimulationManager driver =
new SimulationManager();
102 driver.addModule(viewer);
103 driver.addModule(sceneManager);
107 MouseSceneControl mouseControl =
new MouseSceneControl();
108 mouseControl.setDevice(viewer.getMouseDevice());
109 mouseControl.setSceneManager(sceneManager);
110 scene.addControl(mouseControl);
112 KeyboardSceneControl keyControl =
new KeyboardSceneControl();
113 keyControl.setDevice(viewer.getKeyboardDevice());
114 keyControl.setSceneManager(
new SceneManagerWeakPtr(sceneManager));
115 keyControl.setModuleDriver(
new ModuleDriverWeakPtr(driver));
116 scene.addControl(keyControl);
123 private static FeDeformableObject makeFEDeformableObject(TetrahedralMesh tetMesh)
125 SurfaceMesh surfMesh = tetMesh.extractSurfaceMesh();
129 FemDeformableBodyModel dynaModel =
new FemDeformableBodyModel();
130 FemModelConfig config =
new FemModelConfig();
131 config.m_fixedNodeIds = input.fixedNodeIds;
132 dynaModel.configure(config);
135 dynaModel.setTimeStepSizeType(TimeSteppingType.Fixed);
136 dynaModel.setModelGeometry(tetMesh);
137 BackwardEuler timeIntegrator =
new BackwardEuler(0.01);
138 dynaModel.setTimeIntegrator(timeIntegrator);
140 RenderMaterial mat =
new RenderMaterial();
141 mat.setDisplayMode(RenderMaterial.DisplayMode.WireframeSurface);
142 mat.setPointSize(10.0f);
143 mat.setLineWidth(2.0f);
144 mat.setEdgeColor(Color.Orange);
145 VisualModel surfMeshModel =
new VisualModel();
146 surfMeshModel.setGeometry(surfMesh);
147 surfMeshModel.setRenderMaterial(mat);
150 FeDeformableObject deformableObj =
new FeDeformableObject(
"Dragon");
151 deformableObj.addVisualModel(surfMeshModel);
152 deformableObj.setPhysicsGeometry(tetMesh);
154 deformableObj.setPhysicsToVisualMap(
new PointwiseMap(tetMesh, surfMesh));
155 deformableObj.setDynamicalModel(dynaModel);
157 return deformableObj;
lazy initialized singleton