MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/PositionBasedDynamics / loadTetFile

Method loadTetFile

Utils/TetGenLoader.cpp:11–109  ·  view source on GitHub ↗

Call this function to load a model from a *.tet file

Source from the content-addressed store, hash-verified

9
10// Call this function to load a model from a *.tet file
11void TetGenLoader::loadTetFile(const std::string &filename, std::vector<Vector3r>& vertices, std::vector<unsigned int>& tets)
12{
13 LOG_INFO << "Loading " << filename;
14
15 // variables
16 size_t i, num_materials, num_vertices, num_tetras, num_triangles;
17 Real value;
18 string line, label;
19 stringstream sStream;
20 // try to open the file
21 ifstream fin(filename.c_str());
22 if(!fin)
23 {
24 LOG_ERR << "'" + filename + "' file not found.";
25 return;
26 }
27
28 // load tet version 1.2
29 getline(fin, line);
30 sStream << line;
31 sStream >> label; // tet
32 sStream >> label; // version
33 sStream >> value;
34 sStream.clear();
35 // load number of materials
36 getline(fin, line); // num_materials x
37 sStream << line;
38 sStream >> label;
39 sStream >> num_materials;
40 sStream.clear();
41 // load number of vertices
42 getline(fin, line); // num_vertices x
43 sStream << line;
44 sStream >> label;
45 sStream >> num_vertices;
46 sStream.clear();
47 // reverse the order of the vertices
48 vertices.resize(num_vertices);
49 //// read number of tetraeders
50 getline(fin, line); // num_tetras x
51 sStream << line;
52 sStream >> label;
53 sStream >> num_tetras;
54 sStream.clear();
55 tets.resize(4*num_tetras);
56
57 // read number of triangles
58 getline(fin, line); // num_triangles x
59 sStream << line;
60 sStream >> label;
61 sStream >> num_triangles;
62 sStream.clear();
63
64 // skip materials
65 getline(fin, line);
66 for(i = 0; i < num_materials; ++i)
67 getline(fin, line);
68 // skip the VERTICES label

Callers

nothing calls this directly

Calls 3

c_strMethod · 0.80
clearMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected