Changeset 1627


Ignore:
Timestamp:
10/16/06 18:59:01 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1626 r1627  
    262262                                                                 AxisAlignedBox3 *forcedViewSpace) 
    263263{ 
    264         if (mUseMultiLevelConstruction) 
    265         { 
     264        switch (mConstructionType) 
     265        { 
     266        case MULTILEVEL: 
    266267                ConstructMultiLevel(sampleRays, objects, forcedViewSpace); 
    267         } 
    268         else 
    269         { 
     268                break; 
     269        case INTERLEAVED: 
     270        case SEQUENTIAL: 
    270271                ConstructInterleaved(sampleRays, objects, forcedViewSpace); 
     272                break; 
     273        case GRADIENT: 
     274                ConstructInterleavedWithGradient(sampleRays, objects, forcedViewSpace); 
     275                break; 
     276        default: 
     277                break; 
    271278        } 
    272279} 
     
    424431                PrepareObjectSpaceSubdivision(sampleRays, objects); 
    425432        } 
    426  
     433cout << "****************555555555555555555555555" << endl; 
    427434        // begin subdivision 
    428435        RunConstruction(mRepairQueue, sampleRays, objects, forcedViewSpace); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h

    r1626 r1627  
    419419protected: 
    420420 
    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 
    422429        /// type of hierarchy construction 
    423430        int mConstructionType; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r1626 r1627  
    470470                Environment::GetSingleton()->GetStringValue("ViewCells.geometryFilename", vcGeomFilename); 
    471471                 
    472                 if (mViewCellsManager->GetType() == ViewCellsManager::BSP) 
    473                 { 
    474                         if (!mViewCellsManager->LoadViewCellsGeometry(vcGeomFilename, extrudeBaseTriangles)) 
     472                if (loadVcGeometry) 
     473                { 
     474                        if (mViewCellsManager->GetType() == ViewCellsManager::BSP) 
    475475                        { 
    476                                 cerr << "loading view cells geometry failed" << endl; 
     476                                if (!mViewCellsManager->LoadViewCellsGeometry(vcGeomFilename, extrudeBaseTriangles)) 
     477                                { 
     478                                        cerr << "loading view cells geometry failed" << endl; 
     479                                } 
    477480                        } 
    478                 } 
    479                 else 
    480                 { 
    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                        } 
    482485                } 
    483486        } 
     
    513516bool Preprocessor::ConstructViewCells() 
    514517{ 
    515   // construct view cells using it's own set of samples 
    516   mViewCellsManager->Construct(this); 
    517    
    518   // visualizations and statistics 
    519   Debug << "finished view cells:" << endl; 
    520   mViewCellsManager->PrintStatistics(Debug); 
    521    
    522   return true; 
     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; 
    523526} 
    524527 
     
    815818 
    816819 
    817 bool Preprocessor::InitRayCast(const string externKdTree, const string internkdtree) 
     820bool Preprocessor::InitRayCast(const string externKdTree, const string internKdTree) 
    818821{ 
    819822        bool loadKdTree = true; 
     
    830833        else 
    831834        { 
    832                 const long startTime = GetTime(); 
    833                 cout << "loading kd tree file " << internkdtree << " ... "; 
    834  
    835                 if (!LoadKdTree(internkdtree)) 
    836                 { 
    837                         cout << "error loading kd tree with filename " << internkdtree << ", 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; 
    838841 
    839842                        BuildKdTree(); 
     
    852855                                delete exporter; 
    853856                        } 
     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; 
    854870                } 
    855871        } 
     
    909925                  } 
    910926                if (i % 10000 == 0) 
    911                   cout<<"\r"<<i<<"/"<<rays.size()<<"\r"; 
     927                  cout<<"\r"<<i<<"/"<<(int)rays.size()<<"\r"; 
    912928        } 
    913929        cout<<endl; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/UnigraphicsParser.cpp

    r1577 r1627  
    1313#include "Environment.h" 
    1414#include "ResourceManager.h" 
     15#include "Triangle3.h" 
     16#include "IntersectableWrapper.h" 
     17#include "Polygon3.h" 
    1518 
    1619 
     
    6063    return false; 
    6164 
    62   Mesh *currentMesh = MeshManager::GetSingleton()->CreateResource(); 
    63  
    6465  int meshGrouping; 
    6566  Environment::GetSingleton()->GetIntValue("Unigraphics.meshGrouping", 
    6667                           meshGrouping); 
     68 
     69  Mesh *currentMesh = MeshManager::GetSingleton()->CreateResource(); 
    6770 
    6871  while(fscanf(file,"%s",str)!=EOF)  
     
    8386                  break; 
    8487 
    85  
    8688          case 'v':            // is it v ? 
    8789                  cout<<"."; 
     
    98100                  { 
    99101                          cout << "+"; 
    100                           vector<Vector3> vertices; 
     102                          VertexContainer vertices; 
    101103                          VertexIndexContainer vertexIndices; 
    102104 
     
    151153                                        Material *mat = MaterialManager::GetSingleton()->CreateResource(); 
    152154                                        if (c != cht.end())  
    153                           { 
    154                                   mat->mDiffuseColor = RgbColor((*c).second.x, (*c).second.y, (*c).second.z); 
    155                                   currentMesh->mMaterial = mat; 
    156                           } 
     155                                        { 
     156                                                mat->mDiffuseColor = RgbColor((*c).second.x, (*c).second.y, (*c).second.z); 
     157                                                currentMesh->mMaterial = mat; 
     158                                        } 
    157159                                        else 
    158                           { 
    159                                   currentMesh->AssignRandomMaterial(); 
    160                           } 
     160                                        { 
     161                                                currentMesh->AssignRandomMaterial(); 
     162                                        } 
    161163                                } 
    162164                        } 
    163165 
    164166                        currentMesh->AddFace(face); 
    165                         if (meshGrouping != 0 && currentMesh->mFaces.size() >=  meshGrouping)  
     167 
     168                        if (loadMeshes && 
     169                                (meshGrouping != 0 && currentMesh->mFaces.size() >=  meshGrouping))  
    166170                        { 
    167171                                if (ROTATE_SCENE) 
     
    176180                                currentMesh = MeshManager::GetSingleton()->CreateResource(); 
    177181                        } 
    178                 } 
     182                  } 
    179183                break; 
    180184        }      /* end face */ 
     
    191195          } 
    192196 
    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          } 
    196238  } 
    197239 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1621 r1627  
    3030 
    3131// $$JB HACK 
    32 #define USE_KD_PVS 1 
     32#define USE_KD_PVS 0 
    3333#define KD_PVS_AREA 1e-3f 
    3434 
     
    56365636        const bool startFromZero = true; 
    56375637 
    5638         // reset pvs and start over from zero 
    56395638        if (startFromZero) 
    56405639        { 
     5640                // reset pvs and start over from zero 
    56415641                mViewCellsTree->ResetPvs(); 
    56425642        } 
    56435643        else  
    56445644        { 
    5645                 // start from current sampless 
    56465645                // statistics before casting more samples 
    56475646                cout << "compute new statistics ... "; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp

    r1545 r1627  
    265265                                } 
    266266                        } 
    267 #if 0 
    268                         // we create a new mesh for each face from the current mesh 
    269                         Mesh *mesh = MeshManager::GetSingleton()->CreateResource(); 
    270  
    271                                  
    272                         // dummy vertex indices container 
    273                         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 vertices 
    282                                 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 mesh 
    290                         // note: could be transformed in parent mesh, save some transformations 
    291                         ApplyTransformations(mTransformations, mesh); 
    292  
    293                         mesh->Preprocess(); 
    294  
    295                         if (mesh->mFaces.empty()) 
    296                         { 
    297                                 cout << "error: empy mesh" << endl; 
    298                         } 
    299                         else 
    300                         { 
    301                                 // make an instance of this mesh 
    302                                 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 yet 
    308                                         mCurrentMesh->mMaterial = mCurrentMaterial; 
    309                                 } 
    310                         } 
    311 #endif 
    312267                } 
    313268 
  • GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp

    r1626 r1627  
    161161                Cleanup(); 
    162162                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                 else 
    178                 { 
    179                         cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
    180                 } 
    181163        } 
    182164 
Note: See TracChangeset for help on using the changeset viewer.