Ignore:
Timestamp:
03/02/07 13:13:24 (17 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r2172 r2183  
    2222#include "InternalRayCaster.h" 
    2323#include "GlobalLinesRenderer.h" 
     24#include "ObjectsParser.h" 
    2425 
    2526 
     
    2728#define SHOW_RAYCAST_TIMING 1 
    2829 
     30using namespace std; 
    2931 
    3032namespace GtpVisibilityPreprocessor { 
     
    265267 
    266268 
    267 bool Preprocessor::LoadBinaryObj(const string filename, 
     269bool Preprocessor::LoadBinaryObj(const string &filename, 
    268270                                                                 SceneGraphNode *root, 
    269271                                                                 vector<FaceParentInfo> *parents) 
     
    277279        cout << "binary obj dump available, loading " << filename.c_str() << endl; 
    278280         
    279         // table for vertices 
    280         VertexContainer vertices;  
    281          
    282         if (parents) 
    283                 cout << "using face parents" << endl; 
    284         else 
    285                 cout << "not using face parents" << endl; 
    286  
    287281        // read in triangle size 
    288282        int numTriangles; 
     
    309303                root->mGeometry.push_back(obj); 
    310304                 
    311                 i ++; 
    312          
    313                 if (i % 500000 == 499999) 
     305                if ((i ++) % 500000 == 499999) 
    314306                         cout<<"\r"<<i<<"/"<<numTriangles<<"\r"; 
    315307        } 
     
    488480        const int files = SplitFilenames(filename, filenames); 
    489481        cout << "number of input files: " << files << endl; 
     482 
    490483        bool result = false; 
    491484        bool isObj = false; 
     
    547540                                                 
    548541                                cout << "loaded " << (int)mSceneGraph->GetRoot()->mGeometry.size() << " entities" << endl; 
     542 
    549543                                // only works for triangles 
    550544                                if (result && !mLoadMeshes) 
    551545                                { 
    552546                                        cout << "exporting binary obj to " << bnFile << "... " << endl; 
     547 
    553548                                        ExportBinaryObj(bnFile, mSceneGraph->GetRoot()); 
     549                                 
    554550                                        cout << "finished" << endl; 
    555551                                } 
    556552 
    557553                                delete parser; 
    558                         } 
    559                         else if (0) 
    560                         { 
    561                                 ExportBinaryObj("../data/test.bn", mSceneGraph->GetRoot()); 
    562554                        } 
    563555                } 
     
    740732        if (mLoadViewCells) 
    741733        {        
     734                 
     735#ifdef USE_BIT_PVS 
     736                // HACK: for kd pvs, set pvs size to maximal number of kd nodes 
     737                vector<KdLeaf *> leaves; 
     738                preprocessor->mKdTree->CollectLeaves(leaves); 
     739 
     740                ObjectPvs::SetPvsSize((int)leaves.size()); 
     741#endif 
     742 
    742743                Environment::GetSingleton()->GetStringValue("ViewCells.filename", buf); 
    743                 cout << "loading view cells from " << buf << endl<<flush; 
    744  
    745                 mViewCellsManager = ViewCellsManager::LoadViewCells(buf, &mObjects, true, NULL); 
     744                cout << "loading objects from " << buf << endl; 
     745 
     746                // load objects which will be used as pvs entries 
     747                ObjectContainer pvsObjects; 
     748                if (0) LoadObjects(buf, pvsObjects, mObjects); 
     749 
     750                const bool finalizeViewCells = true; 
     751                cout << "loading view cells from " << buf << endl; 
     752 
     753                mViewCellsManager = ViewCellsManager::LoadViewCells(buf,  
     754                                                                                                                        pvsObjects, 
     755                                                                                                                        mObjects,  
     756                                                                                                                        finalizeViewCells,  
     757                                                                                                                        NULL); 
    746758 
    747759                cout << "view cells loaded." << endl<<flush; 
     
    12621274        const long t1 = GetTime(); 
    12631275         
    1264         if (0 && (int)rays.size() > 10000) { 
     1276        if ((int)rays.size() > 10000) { 
    12651277         
    12661278                mRayCaster->SortRays(rays); 
     
    13561368         
    13571369                if ((int)rays.size() > 100000 && i % 100000 == 0) 
    1358                         //cout << "here2 " << vssRays.size()<<endl; 
    13591370                        cout<<"\r"<<i<<"/"<<(int)rays.size()<<"\r"; 
    13601371        } 
     
    16321643 
    16331644 
    1634 } 
     1645bool Preprocessor::LoadObjects(const string &filename, 
     1646                                                           ObjectContainer &pvsObjects,  
     1647                                                           const ObjectContainer &preprocessorObjects) 
     1648{ 
     1649        ObjectsParser parser; 
     1650 
     1651        const bool success = parser.ParseObjects(filename,  
     1652                                                                                         pvsObjects,  
     1653                                                                                         preprocessorObjects); 
     1654 
     1655        if (!success) 
     1656        { 
     1657                Debug << "Error: loading objects failed!" << endl; 
     1658        } 
     1659 
     1660        // hack: no bvh object could be found => take preprocessor objects 
     1661        if (pvsObjects.empty()) 
     1662        { 
     1663                Debug << "no objects" << endl; 
     1664                pvsObjects = preprocessorObjects; 
     1665        } 
     1666 
     1667        return success; 
     1668} 
     1669 
     1670 
     1671} 
Note: See TracChangeset for help on using the changeset viewer.