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

Method loadTetgenModel

Utils/TetGenLoader.cpp:113–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111
112
113void TetGenLoader::loadTetgenModel(const std::string &nodeFilename, const std::string &eleFilename, std::vector<Vector3r>& vertices, std::vector<unsigned int>& tets)
114{
115 LOG_INFO << "Loading " << nodeFilename;
116 LOG_INFO << "Loading " << eleFilename;
117
118 // variables
119 size_t i, num_vertices, num_tetras;
120 string nodeLine, eleLine, label;
121 stringstream sStream;
122 // try to open the file
123 ifstream finNode(nodeFilename.c_str());
124 ifstream finEle(eleFilename.c_str());
125 if(!finNode)
126 {
127 LOG_ERR << "'" + nodeFilename + "' file not found.";
128 return;
129 }
130 if(!finEle)
131 {
132 LOG_ERR << "'" + eleFilename + "' file not found.";
133 return;
134 }
135
136 // get num vertices
137 getline(finNode, nodeLine);
138 sStream << nodeLine;
139 sStream >> num_vertices;
140 sStream >> label; // 3
141 sStream >> label; // 0
142 sStream >> label; // 0
143 sStream.clear();
144
145 // get num tetras
146 getline(finEle, eleLine);
147 sStream << eleLine;
148 sStream >> num_tetras;
149 sStream >> label; // 4
150 sStream >> label; // 0
151 sStream >> label; // 0
152 sStream.clear();
153
154 vertices.resize(num_vertices);
155 tets.resize(4u*num_tetras);
156
157 // read vertices
158 for(i = 0; i < num_vertices; ++i)
159 {
160 unsigned nodeInd;
161 Real x, y, z;
162 getline(finNode, nodeLine);
163 sStream << nodeLine;
164 sStream >> nodeInd >> x >> y >> z;
165 getline(sStream, nodeLine);
166 sStream.clear();
167
168 vertices[i] = Vector3r(x, y, z);
169 }
170

Callers 1

createMeshFunction · 0.80

Calls 3

c_strMethod · 0.80
clearMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected