iMSTK
Interactive Medical Simulation Toolkit
testGeometry.cs
1 using System;
2 using Imstk;
3 
4 public class PbdCloth
5 {
6  public static void Main(string[] args)
7  {
8  // Write log to stdout and file
9  Logger.startLogger();
10 
11  VecDataArray4i conn = new VecDataArray4i(1);
12  Vec4i vec4i = new Vec4i();
13  vec4i[0] = 0;
14  vec4i[1] = 1;
15  vec4i[2] = 2;
16  vec4i[3] = 3;
17  conn[0] = vec4i;
18 
19  VecDataArray3d coords = new VecDataArray3d(4);
20  Vec3d xyz = new Vec3d();
21  xyz[0] = 0.0;
22  xyz[1] = 0.0;
23  xyz[2] = 0.0;
24  coords[0] = xyz;
25  uint id = 0;
26  Console.WriteLine("coords[{0}] = [{1}, {2}, {3}]", id, coords[id][0], coords[id][1], coords[id][2]);
27 
28  xyz[0] = 1.0;
29  xyz[1] = 0.0;
30  xyz[2] = 0.0;
31  coords[1] = xyz;
32  id = 1;
33  Console.WriteLine("coords[{0}] = [{1}, {2}, {3}]", id, coords[id][0], coords[id][1], coords[id][2]);
34 
35  xyz[0] = 0.0;
36  xyz[1] = 1.0;
37  xyz[2] = 0.0;
38  coords[2] = xyz;
39  id = 2;
40  id = 2;
41  Console.WriteLine("coords[{0}] = [{1}, {2}, {3}]", id, coords[id][0], coords[id][1], coords[id][2]);
42 
43  xyz[0] = 0.0;
44  xyz[1] = 0.0;
45  xyz[2] = 1.0;
46  coords[3] = xyz;
47  id = 3;
48  Console.WriteLine("coords[{0}] = [{1}, {2}, {3}]", id, coords[id][0], coords[id][1], coords[id][2]);
49 
50  TetrahedralMesh tetMesh = new TetrahedralMesh();
51  tetMesh.initialize(coords, conn);
52 
53  Console.WriteLine("vol = {0}", tetMesh.getVolume());
54  Console.WriteLine("numberOfTets = {0}", tetMesh.getNumTetrahedra());
55  Vec4i conn_tet = tetMesh.getCells()[0];
56  Console.WriteLine("conn[0] = [{0}, {1}, {2}, {3}]", conn_tet[0], conn_tet[1], conn_tet[2], conn_tet[3]);
57 
58  {
59  VecDataArray4i conn2 = tetMesh.getTetrahedraIndices();
60  conn2[0] = new Vec4i(1, 2, 3, 0);
61  Vec4i new_conn_tet = tetMesh.getCells()[0];
62  Console.WriteLine("conn[0] = [{0}, {1}, {2}, {3}]", new_conn_tet[0], new_conn_tet[1], new_conn_tet[2], new_conn_tet[3]);
63  }
64 
65  PointSet asianDragonMesh = MeshIO.read("/home/jianfeng/Documents/imstk/build_csharp_shared/install/data/asianDragon/asianDragon.veg");
66  // asianDragonMesh.print();
67  Console.WriteLine("asianDragon.getVolume() = {0}", asianDragonMesh.getVolume());
68  Console.WriteLine("asianDragon.getNumVertices() = {0}", asianDragonMesh.getNumVertices());
69  }
70 }
71 
lazy initialized singleton