Changeset 1627 for GTP/trunk/Lib/Vis
- Timestamp:
- 10/16/06 18:59:01 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1626 r1627 262 262 AxisAlignedBox3 *forcedViewSpace) 263 263 { 264 if (mUseMultiLevelConstruction) 265 { 264 switch (mConstructionType) 265 { 266 case MULTILEVEL: 266 267 ConstructMultiLevel(sampleRays, objects, forcedViewSpace); 267 }268 else269 {268 break; 269 case INTERLEAVED: 270 case SEQUENTIAL: 270 271 ConstructInterleaved(sampleRays, objects, forcedViewSpace); 272 break; 273 case GRADIENT: 274 ConstructInterleavedWithGradient(sampleRays, objects, forcedViewSpace); 275 break; 276 default: 277 break; 271 278 } 272 279 } … … 424 431 PrepareObjectSpaceSubdivision(sampleRays, objects); 425 432 } 426 433 cout << "****************555555555555555555555555" << endl; 427 434 // begin subdivision 428 435 RunConstruction(mRepairQueue, sampleRays, objects, forcedViewSpace); -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r1626 r1627 419 419 protected: 420 420 421 enum {SEQUENTIAL, INTERLEAVED}; 421 /** construction types 422 sequential: construct first view space, then object space 423 interleaved: construct view space and object space fully interleaved 424 gradient: construct view space / object space until a threshold is reached 425 multilevel: iterate until subdivisions converge to the optimum. 426 */ 427 enum {SEQUENTIAL, INTERLEAVED, GRADIENT, MULTILEVEL}; 428 422 429 /// type of hierarchy construction 423 430 int mConstructionType; -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r1626 r1627 470 470 Environment::GetSingleton()->GetStringValue("ViewCells.geometryFilename", vcGeomFilename); 471 471 472 if ( mViewCellsManager->GetType() == ViewCellsManager::BSP)473 { 474 if ( !mViewCellsManager->LoadViewCellsGeometry(vcGeomFilename, extrudeBaseTriangles))472 if (loadVcGeometry) 473 { 474 if (mViewCellsManager->GetType() == ViewCellsManager::BSP) 475 475 { 476 cerr << "loading view cells geometry failed" << endl; 476 if (!mViewCellsManager->LoadViewCellsGeometry(vcGeomFilename, extrudeBaseTriangles)) 477 { 478 cerr << "loading view cells geometry failed" << endl; 479 } 477 480 } 478 }479 else480 {481 cerr << "loading view cells geometry is not implemented for this manager" << endl;481 else 482 { 483 cerr << "loading view cells geometry is not implemented for this manager" << endl; 484 } 482 485 } 483 486 } … … 513 516 bool Preprocessor::ConstructViewCells() 514 517 { 515 516 517 518 519 520 521 522 518 // construct view cells using it's own set of samples 519 mViewCellsManager->Construct(this); 520 521 // visualizations and statistics 522 Debug << "finished view cells:" << endl; 523 mViewCellsManager->PrintStatistics(Debug); 524 525 return true; 523 526 } 524 527 … … 815 818 816 819 817 bool Preprocessor::InitRayCast(const string externKdTree, const string intern kdtree)820 bool Preprocessor::InitRayCast(const string externKdTree, const string internKdTree) 818 821 { 819 822 bool loadKdTree = true; … … 830 833 else 831 834 { 832 constlong startTime = GetTime();833 cout << "loading kd tree file " << intern kdtree << " ... ";834 835 if (!LoadKdTree(intern kdtree))836 { 837 cout << "error loading kd tree with filename " << intern kdtree << ", rebuilding it instead ..." << endl;835 long startTime = GetTime(); 836 cout << "loading kd tree file " << internKdTree << " ... "; 837 838 if (!LoadKdTree(internKdTree)) 839 { 840 cout << "error loading kd tree with filename " << internKdTree << ", rebuilding it instead ..." << endl; 838 841 839 842 BuildKdTree(); … … 852 855 delete exporter; 853 856 } 857 } 858 859 // export kd tree? 860 startTime = GetTime(); 861 cout << "exporting kd tree ... "; 862 863 if (!ExportKdTree(internKdTree)) 864 { 865 cout << " error exporting kd tree with filename " << internKdTree << endl; 866 } 867 else 868 { 869 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 854 870 } 855 871 } … … 909 925 } 910 926 if (i % 10000 == 0) 911 cout<<"\r"<<i<<"/"<< rays.size()<<"\r";927 cout<<"\r"<<i<<"/"<<(int)rays.size()<<"\r"; 912 928 } 913 929 cout<<endl; -
GTP/trunk/Lib/Vis/Preprocessing/src/UnigraphicsParser.cpp
r1577 r1627 13 13 #include "Environment.h" 14 14 #include "ResourceManager.h" 15 #include "Triangle3.h" 16 #include "IntersectableWrapper.h" 17 #include "Polygon3.h" 15 18 16 19 … … 60 63 return false; 61 64 62 Mesh *currentMesh = MeshManager::GetSingleton()->CreateResource();63 64 65 int meshGrouping; 65 66 Environment::GetSingleton()->GetIntValue("Unigraphics.meshGrouping", 66 67 meshGrouping); 68 69 Mesh *currentMesh = MeshManager::GetSingleton()->CreateResource(); 67 70 68 71 while(fscanf(file,"%s",str)!=EOF) … … 83 86 break; 84 87 85 86 88 case 'v': // is it v ? 87 89 cout<<"."; … … 98 100 { 99 101 cout << "+"; 100 vector<Vector3>vertices;102 VertexContainer vertices; 101 103 VertexIndexContainer vertexIndices; 102 104 … … 151 153 Material *mat = MaterialManager::GetSingleton()->CreateResource(); 152 154 if (c != cht.end()) 153 154 155 156 155 { 156 mat->mDiffuseColor = RgbColor((*c).second.x, (*c).second.y, (*c).second.z); 157 currentMesh->mMaterial = mat; 158 } 157 159 else 158 159 160 160 { 161 currentMesh->AssignRandomMaterial(); 162 } 161 163 } 162 164 } 163 165 164 166 currentMesh->AddFace(face); 165 if (meshGrouping != 0 && currentMesh->mFaces.size() >= meshGrouping) 167 168 if (loadMeshes && 169 (meshGrouping != 0 && currentMesh->mFaces.size() >= meshGrouping)) 166 170 { 167 171 if (ROTATE_SCENE) … … 176 180 currentMesh = MeshManager::GetSingleton()->CreateResource(); 177 181 } 178 }182 } 179 183 break; 180 184 } /* end face */ … … 191 195 } 192 196 193 currentMesh->Preprocess(); 194 MeshInstance *mi = new MeshInstance(currentMesh); 195 root->mGeometry.push_back(mi); 197 if (!loadMeshes) 198 { 199 // hack: just triangulate current mesh 200 FaceContainer::const_iterator fit, fit_begin = currentMesh->mFaces.begin(), 201 fit_end = currentMesh->mFaces.end(); 202 203 for (fit = fit_begin; fit != fit_end; ++ fit) 204 { 205 // triangulate the faces 206 Face *face = *fit; 207 vector<Triangle3> triangles; 208 209 Polygon3 poly(face, currentMesh); 210 poly.Triangulate(triangles); 211 212 vector<Triangle3>::const_iterator tit, tit_end = triangles.end(); 213 214 for (tit = triangles.begin(); tit != tit_end; ++ tit) 215 { 216 if ((*tit).CheckValidity()) 217 { 218 // create new triangle intersectable 219 TriangleIntersectable *ti = new TriangleIntersectable(*tit); 220 //cout << "t: " << (*tit) << endl; 221 root->mGeometry.push_back(ti); 222 } 223 else 224 { 225 cout << "error tri:\n" << (*tit) << endl; 226 } 227 } 228 } 229 // not needed anymore 230 MeshManager::GetSingleton()->DestroyEntry(currentMesh->GetId()); 231 } 232 else 233 { 234 currentMesh->Preprocess(); 235 MeshInstance *mi = new MeshInstance(currentMesh); 236 root->mGeometry.push_back(mi); 237 } 196 238 } 197 239 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1621 r1627 30 30 31 31 // $$JB HACK 32 #define USE_KD_PVS 132 #define USE_KD_PVS 0 33 33 #define KD_PVS_AREA 1e-3f 34 34 … … 5636 5636 const bool startFromZero = true; 5637 5637 5638 // reset pvs and start over from zero5639 5638 if (startFromZero) 5640 5639 { 5640 // reset pvs and start over from zero 5641 5641 mViewCellsTree->ResetPvs(); 5642 5642 } 5643 5643 else 5644 5644 { 5645 // start from current sampless5646 5645 // statistics before casting more samples 5647 5646 cout << "compute new statistics ... "; -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp
r1545 r1627 265 265 } 266 266 } 267 #if 0268 // we create a new mesh for each face from the current mesh269 Mesh *mesh = MeshManager::GetSingleton()->CreateResource();270 271 272 // dummy vertex indices container273 VertexIndexContainer vcIndices;274 VertexIndexContainer::const_iterator vit, vit_end = face->mVertexIndices.end();275 int i = 0;276 277 for (vit = face->mVertexIndices.begin(); vit != vit_end; ++ vit, ++ i)278 {279 cout << "i";280 const int index = (*vit);281 // add vertices282 mesh->mVertices.push_back(mCurrentMesh->mVertices[index]);283 // indices don't make much sense if mesh == face, but we need them anyway ...284 vcIndices.push_back(i);285 }286 287 mesh->mFaces.push_back(new Face(vcIndices));288 289 // write transformations directly into the mesh290 // note: could be transformed in parent mesh, save some transformations291 ApplyTransformations(mTransformations, mesh);292 293 mesh->Preprocess();294 295 if (mesh->mFaces.empty())296 {297 cout << "error: empy mesh" << endl;298 }299 else300 {301 // make an instance of this mesh302 MeshInstance *mi = new MeshInstance(mesh);303 mCurrentNode->mGeometry.push_back(mi);304 305 if (mCurrentMaterial && !mCurrentMesh->mMaterial)306 {307 // HACK: add the material to the mesh directly if no material yet308 mCurrentMesh->mMaterial = mCurrentMaterial;309 }310 }311 #endif312 267 } 313 268 -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r1626 r1627 161 161 Cleanup(); 162 162 exit(1); 163 }164 165 // export kd tree?166 bool exportKdTree;167 Environment::GetSingleton()->GetBoolValue("Preprocessor.exportKdTree", exportKdTree);168 if (exportKdTree)169 {170 const long startTime = GetTime();171 cout << "exporting kd tree ... ";172 173 if (!preprocessor->ExportKdTree(internKdTree))174 {175 cout << " error exporting kd tree with filename " << internKdTree << endl;176 }177 else178 {179 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl;180 }181 163 } 182 164
Note: See TracChangeset
for help on using the changeset viewer.