Changeset 1655 for GTP/trunk/Lib/Vis
- Timestamp:
- 10/20/06 08:32:45 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ObjParser.cpp
r1454 r1655 81 81 { 82 82 const int index = (int)strtol(pch, NULL, 10) - 1; 83 //Debug << index << " x "; 84 83 85 84 // store vertex in hash table 86 85 hashTable[index] = vertices[index]; … … 89 88 pch = strtok(NULL, " "); 90 89 } 91 //if (indices.size() > 4) return NULL; 92 90 93 91 return Triangle3(vertices[indices[0]], vertices[indices[1]], vertices[indices[2]]); 94 92 } … … 144 142 Mesh *mesh = mi->GetMesh(); 145 143 144 int i = 0; 146 145 FaceContainer::const_iterator fit, fit_end = mesh->mFaces.end(); 147 int i = 0; 146 148 147 for (fit = mesh->mFaces.begin(); fit != fit_end; ++ fit, i++) 149 148 { … … 210 209 case 'f': 211 210 { 212 // cout << "f"; 213 211 // cout << "f"; 214 212 if (loadMeshes) 215 213 { -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r1634 r1655 224 224 225 225 226 bool Preprocessor::LoadBinaryObj(const string filename, 227 SceneGraphNode *root, 228 const bool loadMeshes, 229 vector<FaceParentInfo> *parents) 230 { 231 ifstream samplesIn(fileName, ios::binary); 232 if (!samplesIn.is_open()) 233 return false; 234 235 236 // table associating indices with vectors 237 map<int, Vector3> hashTable; 238 // table for vertices 239 VertexContainer vertices; 240 FaceContainer faces; 241 242 char str[100]; 243 int meshGrouping; 244 Environment::GetSingleton()->GetIntValue("ObjParser.meshGrouping", meshGrouping); 245 246 int nMaxFaces = meshGrouping; 247 248 while (1) 249 { 250 Triangle3 tri; 251 252 samplesIn.read(reinterpret_cast<char *>(tri.mVertices + 0), sizeof(Vector3)); 253 samplesIn.read(reinterpret_cast<char *>(tri.mVertices + 1), sizeof(Vector3)); 254 samplesIn.read(reinterpret_cast<char *>(tri.mVertices + 2), sizeof(Vector3)); 255 256 // end of file reached 257 if (samplesIn.eof()) 258 break; 259 260 TriangleIntersectable *obj = new TriangleIntersectable(tri); 261 root->mGeometry.push_back(obj); 262 263 // matt: we don't really need to keep an additional data structure 264 // if working with triangles => remove this 265 if (parents) 266 { 267 FaceParentInfo info(obj, 0); 268 parents->push_back(info); 269 } 270 } 271 272 return true; 273 } 274 275 226 276 bool 227 277 Preprocessor::LoadScene(const string filename) 228 278 { 229 279 // use leaf nodes of the original spatial hierarchy as occludees 230 280 mSceneGraph = new SceneGraph; 231 281 … … 248 298 249 299 if (strstr(filename.c_str(), ".x3d")) 250 parser = new X3dParser; 300 { 301 parser = new X3dParser; 302 } 251 303 else 304 { 252 305 if (strstr(filename.c_str(), ".ply") || strstr(filename.c_str(), ".plb")) 253 parser = new PlyParser; 306 { 307 parser = new PlyParser; 308 } 254 309 else if (strstr(filename.c_str(), ".obj")) 255 parser = new ObjParser; 310 { 311 // hack: load binary dump 312 string binFile = ReplaceSuffix(filename, ".obj", ".bin"); 313 314 const bool loaded = 315 LoadBinaryObj(binFile, mSceneGraph->GetRoot(), mLoadMeshes, fi); 316 317 if (loaded) 318 return true; 319 320 parser = new ObjParser; 321 } 256 322 else 323 { 257 324 parser = new UnigraphicsParser; 325 } 326 } 258 327 259 328 cout << filename << endl; 260 329 261 result = parser->ParseFile( 262 filename, 263 mSceneGraph->GetRoot(), 264 mLoadMeshes, 265 fi); 266 330 result = parser->ParseFile(filename, 331 mSceneGraph->GetRoot(), 332 mLoadMeshes, 333 fi); 334 335 // only works for triangles 336 ExportBinaryObj(binFile): 337 267 338 delete parser; 268 339
Note: See TracChangeset
for help on using the changeset viewer.