Changeset 2004


Ignore:
Timestamp:
01/21/07 17:25:42 (17 years ago)
Author:
mattausch
Message:

put #triangles into new format. warning! problems with power plant

Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
5 edited

Legend:

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

    r2003 r2004  
    17371737 
    17381738 
    1739 float BvHierarchy::EvalAbsCost(const ObjectContainer &objects)// const 
     1739float BvHierarchy::EvalAbsCost(const ObjectContainer &objects) 
    17401740{ 
    17411741#if USE_BETTER_RENDERCOST_EST 
     
    23462346 
    23472347                frontData.mSortedObjects[i]->reserve((int)sc.mFrontObjects.size()); 
    2348                 backData.mSortedObjects[i]->reserve((int)sc.mFrontObjects.size()); 
     2348                backData.mSortedObjects[i]->reserve((int)sc.mBackObjects.size()); 
    23492349 
    23502350                ObjectContainer::const_iterator oit, oit_end = sc.mParentData.mSortedObjects[i]->end(); 
    23512351 
     2352                // all the front objects are mailed => assign the sorted object lists 
    23522353                for (oit = sc.mParentData.mSortedObjects[i]->begin(); oit != oit_end; ++ oit) 
    23532354                { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp

    r2003 r2004  
    4343                                                        ) 
    4444{ 
    45         cout << "intel ray" << endl; 
     45        //cout << "intel ray" << endl; 
    4646        VssRay *vssRay  = NULL; 
    4747        int hits = 0; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r2003 r2004  
    266266        cout << "binary obj dump available, loading " << filename.c_str() << endl; 
    267267         
    268  
    269268        // table for vertices 
    270269        VertexContainer vertices;  
     
    275274                cout << "not using face parents" << endl; 
    276275 
    277         int dummy = 0; 
    278         vector<Triangle3> triangles; 
    279         //triangles.reserve(sizeof(Triangle3) * 13000000); 
    280         //triangles.reserve(13000000); 
     276        // read in triangle size 
     277        int numTriangles; 
     278 
     279        samplesIn.read(reinterpret_cast<char *>(&numTriangles), sizeof(int)); 
     280        root->mGeometry.reserve(numTriangles); 
     281        cout << "reserved " << numTriangles << " triangles " << endl; 
    281282        //root->mGeometry.reserve(13000000); 
    282  
     283         
     284        cout << "using " << numTriangles * (sizeof(TriangleIntersectable) + sizeof(TriangleIntersectable *)) / (1024 * 1024) << " MBs" << endl; 
     285 
     286        //vector<Triangle3> dummy; 
     287        //cout << "using " << numTriangles * sizeof(Triangle3) / (1024 * 1024) << " MBs" << endl; 
     288        //dummy.reserve(numTriangles); 
     289 
     290        int i = 0; 
    283291        while (1) 
    284292        { 
     
    295303                TriangleIntersectable *obj = new TriangleIntersectable(tri); 
    296304                root->mGeometry.push_back(obj); 
    297                 //triangles.push_back(tri); 
    298                 //dummy ++; 
    299                 //if (dummy % 100000 == 9999) 
    300                 //cout << "idx: " << dummy << endl; 
    301         } 
    302          
    303         //cout << "here411" << endl; 
     305                //dummy.push_back(tri); 
     306                i ++; 
     307         
     308                if (i % 500000 == 0) 
     309                        cout << "idx: " << i << endl; 
     310        } 
     311         
     312        if (i != numTriangles) 
     313        { 
     314                cout << "warning: triangle size does not match with loaded triangle size" << endl; 
     315                return false; 
     316        } 
     317 
     318        cout << "loaded " << numTriangles << " triangles" << endl; 
     319 
    304320        return true; 
    305321} 
     
    308324bool Preprocessor::ExportBinaryObj(const string filename, SceneGraphNode *root) 
    309325{ 
    310         //ifstream samplesIn(filename, ios::binary); 
    311326        ogzstream samplesOut(filename.c_str()); 
     327 
    312328        if (!samplesOut.is_open()) 
    313329                return false; 
     330 
     331        int numTriangles = (int)root->mGeometry.size(); 
     332 
     333        samplesOut.write(reinterpret_cast<char *>(&numTriangles), sizeof(int)); 
    314334 
    315335        ObjectContainer::const_iterator oit, oit_end = root->mGeometry.end(); 
     
    333353        } 
    334354 
     355        cout << "exported " << numTriangles << " triangles" << endl; 
     356 
    335357        return true; 
    336358} 
     
    346368        ObjectContainer::const_iterator oit, oit_end = objects.end(); 
    347369 
    348         AxisAlignedBox3 bbox = mSceneGraph->GetBox(); bbox.Enlarge(30.0); 
     370        //AxisAlignedBox3 bbox = mSceneGraph->GetBox(); bbox.Enlarge(30.0); 
    349371        for (oit = objects.begin(); oit != oit_end; ++ oit) 
    350372        { 
     
    354376                { 
    355377                        Triangle3 tri = dynamic_cast<TriangleIntersectable *>(obj)->GetItem(); 
    356                         //if (bbox.IsInside(tri.mVertices[0]) && bbox.IsInside(tri.mVertices[1]) && bbox.IsInside(tri.mVertices[2])) 
    357                         //{ 
    358                                 samplesOut << "v " << tri.mVertices[0].x << " " << tri.mVertices[0].y << " " << tri.mVertices[0].z << endl; 
    359                                 samplesOut << "v " << tri.mVertices[1].x << " " << tri.mVertices[1].y << " " << tri.mVertices[1].z << endl; 
    360                                 samplesOut << "v " << tri.mVertices[2].x << " " << tri.mVertices[2].y << " " << tri.mVertices[2].z << endl; 
     378                        //if (!(bbox.IsInside(tri.mVertices[0]) && bbox.IsInside(tri.mVertices[1]) && bbox.IsInside(tri.mVertices[2])))continue; 
     379                         
     380                        samplesOut << "v " << tri.mVertices[0].x << " " << tri.mVertices[0].y << " " << tri.mVertices[0].z << endl; 
     381                        samplesOut << "v " << tri.mVertices[1].x << " " << tri.mVertices[1].y << " " << tri.mVertices[1].z << endl; 
     382                        samplesOut << "v " << tri.mVertices[2].x << " " << tri.mVertices[2].y << " " << tri.mVertices[2].z << endl; 
    361383                        //} 
    362384                } 
     
    375397                { 
    376398                        //Triangle3 tri = dynamic_cast<TriangleIntersectable *>(obj)->GetItem(); 
    377                         //if (bbox.IsInside(tri.mVertices[0]) && bbox.IsInside(tri.mVertices[1]) && bbox.IsInside(tri.mVertices[2])) 
    378                         //{ 
    379                                 Triangle3 tri = dynamic_cast<TriangleIntersectable *>(obj)->GetItem(); 
    380                                 samplesOut << "f " << i << " " << i + 1 << " " << i + 2 << endl; 
    381                                 i += 3; 
    382                         //} 
     399                        //if (!(bbox.IsInside(tri.mVertices[0]) && bbox.IsInside(tri.mVertices[1]) && bbox.IsInside(tri.mVertices[2]))) continue; 
     400                         
     401                        Triangle3 tri = dynamic_cast<TriangleIntersectable *>(obj)->GetItem(); 
     402                        samplesOut << "f " << i << " " << i + 1 << " " << i + 2 << endl; 
     403                        i += 3; 
    383404                } 
    384405                else 
     
    408429        if (index < 0) 
    409430        { 
    410                 cerr << "Warning: triangle index smaller zero! " << index << endl; 
     431                //cerr << "Warning: triangle index smaller zero! " << index << endl; 
    411432                return NULL; 
    412433        } 
     
    502523 
    503524                        // hack: load binary dump 
    504                         string binFile = ReplaceSuffix(filename, ".obj", ".bin"); 
    505  
     525                        const string bnFile = ReplaceSuffix(filename, ".obj", ".bn"); 
     526                         
    506527                        if (!mLoadMeshes) 
    507528                        { 
    508                                 result = LoadBinaryObj(binFile, mSceneGraph->GetRoot(), fi); 
     529                                result = LoadBinaryObj(bnFile, mSceneGraph->GetRoot(), fi); 
    509530                        } 
    510531 
    511                         if (!result) 
     532                        // parse obj 
     533            if (!result) 
    512534                        { 
    513535                                cout << "no binary dump available or loading full meshes, parsing file" << endl; 
     
    519541                                                                   fi); 
    520542                                                 
     543                                cout << "loaded " << (int)mSceneGraph->GetRoot()->mGeometry.size() << " entities" << endl; 
    521544                                // only works for triangles 
    522                                 if (!mLoadMeshes) 
     545                                if (result && !mLoadMeshes) 
    523546                                { 
    524                                         cout << "exporting binary obj to " << binFile << "... " << endl; 
    525                                         ExportBinaryObj(binFile, mSceneGraph->GetRoot()); 
     547                                        cout << "exporting binary obj to " << bnFile << "... " << endl; 
     548                                        ExportBinaryObj(bnFile, mSceneGraph->GetRoot()); 
    526549                                        cout << "finished" << endl; 
    527550                                } 
     
    531554                        else if (0) 
    532555                        { 
    533                                 ExportBinaryObj("../data/test.bin", mSceneGraph->GetRoot()); 
     556                                ExportBinaryObj("../data/test.bn", mSceneGraph->GetRoot()); 
    534557                        } 
    535558                } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp

    r2003 r2004  
    653653                                        if (strcmp(curr, "mutation")==0) { 
    654654                                          // temp matt: still no mutationstrategy! 
    655                                           mDistributions.push_back(new MutationBasedDistribution(mPreprocessor)); 
     655                                          //mDistributions.push_back(new MutationBasedDistribution(mPreprocessor)); 
    656656                                        } 
    657657         
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r2003 r2004  
    342342ViewCellsManager::CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects) 
    343343{ 
    344   GetPreprocessor()->mKdTree->CollectObjects(box, objects); 
     344        GetPreprocessor()->mKdTree->CollectObjects(box, objects); 
    345345} 
    346346 
     
    43214321                        exporter->SetWireframe(); 
    43224322 
    4323                         // matt: no kd pvs 
    4324                         /* 
     4323                        // matt: we don't have no kd pvs 
     4324#if 0 
    43254325                        KdPvsMap::iterator kit = object->mKdPvs.mEntries.begin(); 
    43264326                        Intersectable::NewMail(); 
     
    43484348                        exporter->SetForcedMaterial(m); 
    43494349                        exporter->ExportIntersectable(object); 
    4350 */ 
     4350#endif 
    43514351                        delete exporter; 
    43524352                } 
     
    64046404VspOspViewCellsManager::CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects) 
    64056405{ 
    6406   mHierarchyManager->CollectObjects(box, objects); 
     6406        mHierarchyManager->CollectObjects(box, objects); 
    64076407} 
    64086408 
Note: See TracChangeset for help on using the changeset viewer.