Changeset 2003


Ignore:
Timestamp:
01/21/07 00:40:56 (17 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/power_plant.env

    r886 r2003  
    392392} 
    393393 
     394 
    394395BspTree { 
    395396        Construction { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp

    r1999 r2003  
    2626#define USE_FIXEDPOINT_T 0 
    2727#define USE_VOLUMES_FOR_HEURISTICS 1 
    28  
    29   //int BvhNode::sMailId = 10000; //2147483647; 
    30   //int BvhNode::sReservedMailboxes = 1; 
     28#define TEST_POWERPLANT 0 
     29   
     30//int BvhNode::sMailId = 10000; 
     31//int BvhNode::sReservedMailboxes = 1; 
    3132 
    3233BvHierarchy *BvHierarchy::BvhSubdivisionCandidate::sBvHierarchy = NULL; 
     
    382383                                                                                BvhTraversalData &frontData, 
    383384                                                                                BvhTraversalData &backData) 
    384 { 
     385{  
    385386        const BvhTraversalData &tData = sc.mParentData; 
    386387        BvhLeaf *leaf = tData.mNode; 
     
    427428        ++ mBvhStats.splits; 
    428429 
    429  
     430  
    430431        //////////////////////////////////////// 
    431432        //-- fill front and back traversal data with the new values 
     
    446447        AssociateObjectsWithLeaf(back); 
    447448        AssociateObjectsWithLeaf(front); 
    448     
     449   
     450        //////////// 
    449451        //-- compute pvs correction to cope with undersampling 
     452 
    450453        frontData.mPvs = (float)CountViewCells(front->mObjects); 
    451454        backData.mPvs = (float)CountViewCells(back->mObjects); 
     
    453456        frontData.mCorrectedPvs = sc.mCorrectedFrontPvs; 
    454457        backData.mCorrectedPvs = sc.mCorrectedBackPvs; 
     458 
    455459 
    456460        // compute probability of this node being visible,  
     
    462466        backData.mCorrectedVolume = sc.mCorrectedBackVolume; 
    463467 
     468 
    464469    // how often was max cost ratio missed in this branch? 
    465470        frontData.mMaxCostMisses = sc.GetMaxCostMisses(); 
     
    468473        // set the time stamp so the order of traversal can be reconstructed 
    469474        node->SetTimeStamp(mHierarchyManager->mTimeStamp ++); 
    470                  
     475          
    471476        // assign the objects in sorted order 
    472         if (mUseGlobalSorting) 
     477        if (!TEST_POWERPLANT && mUseGlobalSorting) 
    473478        { 
    474479                AssignSortedObjects(sc, frontData, backData); 
     
    497502                BvhTraversalData tFrontData; 
    498503                BvhTraversalData tBackData; 
    499                          
     504                 
    500505                // create new interior node and two leaf node 
    501506                currentNode = SubdivideNode(*sc, tFrontData, tBackData); 
     
    628633        } 
    629634 
     635 
    630636        const BvhTraversalData &tData = splitCandidate.mParentData; 
    631637        BvhLeaf *leaf = tData.mNode; 
     
    671677 
    672678        if (0) 
    673         cout << "bvh volume cost" 
     679        { 
     680                cout << "bvh volume cost" 
    674681                 << " avg ray contri: " << avgRayContri << " ratio: " << oldRatio  
    675682                 << " parent: " << parentVol << " old vol: " << oldVolume  
    676683                 << " frontvol: " << frontVol << " corr. " << splitCandidate.mCorrectedFrontVolume  
    677684                 << " backvol: " << backVol << " corr. " << splitCandidate.mCorrectedBackVolume << endl; 
     685        } 
    678686 
    679687#ifdef GTP_DEBUG 
     
    849857 
    850858 
    851 #if 0 
     859#if 1 
    852860 
    853861/// compute object boundaries using spatial mid split 
     
    857865                                                                                        ObjectContainer &objectsBack) 
    858866{ 
    859         const float maxBox = tData.mBoundingBox.Max(axis); 
    860         const float minBox = tData.mBoundingBox.Min(axis); 
     867        AxisAlignedBox3 parentBox = tData.mNode->GetBoundingBox(); 
     868 
     869        const float maxBox = parentBox.Max(axis); 
     870        const float minBox = parentBox.Min(axis); 
    861871 
    862872        float midPoint = (maxBox + minBox) * 0.5f; 
     
    882892        } 
    883893 
    884         const float oldRenderCost = EvalRenderCost(tData.mNode->mObjects); 
    885         const float newRenderCost = EvalRenderCost(objectsFront) * EvalRenderCost(objectsBack); 
     894        AxisAlignedBox3 fbox = EvalBoundingBox(objectsFront, &parentBox); 
     895        AxisAlignedBox3 bbox = EvalBoundingBox(objectsBack, &parentBox); 
     896 
     897        const float oldRenderCost = (float)tData.mNode->mObjects.size() * parentBox.SurfaceArea(); 
     898        const float newRenderCost = (float)objectsFront.size() * fbox.SurfaceArea() +  (float)objectsBack.size() * bbox.SurfaceArea(); 
    886899 
    887900        const float ratio = newRenderCost / oldRenderCost; 
     
    920933 
    921934#if 1 
     935        // hack: always take driving axis 
    922936        const float cost = (tData.mNode->GetBoundingBox().Size().DrivingAxis() == axis) ? -1.0f : 0.0f; 
    923937#else 
    924938        const float oldRenderCost = EvalRenderCost(tData.mNode->mObjects); 
    925         const float newRenderCost = EvalRenderCost(objectsFront) * EvalRenderCost(objectsBack); 
     939        const float newRenderCost = EvalRenderCost(objectsFront) + EvalRenderCost(objectsBack); 
    926940 
    927941        const float cost = newRenderCost / oldRenderCost; 
     
    9861000        } 
    9871001 
    988         // temporary surface areas 
     1002        // record surface areas during the sweep 
    9891003        float al = 0; 
    9901004        float ar = boxArea; 
     
    13941408void BvHierarchy::CreateLocalSubdivisionCandidates(const ObjectContainer &objects,  
    13951409                                                                                                  SortableEntryContainer **subdivisionCandidates,  
    1396                                                                                                   const bool sort, 
     1410                                                                                                  const bool sortEntries, 
    13971411                                                                                                  const int axis) 
    13981412{ 
     
    14001414 
    14011415        // compute requested size and look if subdivision candidate has to be recomputed 
    1402         const int requestedSize = (int)objects.size() * 2; 
     1416        const int requestedSize = (int)objects.size(); 
    14031417         
    14041418        // creates a sorted split candidates array 
     
    14231437        } 
    14241438 
    1425         if (sort) 
     1439        if (sortEntries) 
    14261440        {       // no presorted candidate list 
    1427                 stable_sort((*subdivisionCandidates)->begin(), (*subdivisionCandidates)->end()); 
     1441                //stable_sort((*subdivisionCandidates)->begin(), (*subdivisionCandidates)->end()); 
     1442                sort((*subdivisionCandidates)->begin(), (*subdivisionCandidates)->end()); 
    14281443        } 
    14291444} 
     
    22012216        // root and bounding box was already constructed 
    22022217        BvhLeaf *bvhLeaf = dynamic_cast<BvhLeaf *>(mRoot); 
    2203  
     2218         
    22042219        // only rays intersecting objects in node are interesting 
    22052220        const int nRays = AssociateObjectsWithRays(sampleRays); 
    22062221        //cout << "using " << nRays << " of " << (int)sampleRays.size() << " rays" << endl; 
    2207  
     2222         
    22082223        // probability that volume is "seen" from the view cells 
    22092224        const float prop = EvalViewCellsVolume(objects) / GetViewSpaceVolume(); 
     
    22132228         
    22142229        // create sorted object lists for the first data 
    2215         if (mUseGlobalSorting) 
     2230        if (!TEST_POWERPLANT && mUseGlobalSorting) 
    22162231        { 
    22172232                AssignInitialSortedObjectList(oData, objects); 
     
    22572272                        tQueue.Push(sCandidate); 
    22582273                } 
     2274 
     2275                cout << "size of initial bv subdivision: " << GetStatistics().Leaves() << endl; 
    22592276        } 
    22602277        else 
    2261         { 
     2278        {        
    22622279                // evaluate priority 
    22632280                EvalSubdivisionCandidate(*oSubdivisionCandidate); 
     
    22652282 
    22662283                tQueue.Push(oSubdivisionCandidate); 
    2267         } 
    2268                  
    2269         cout << "size of initial bv subdivision: " << GetStatistics().Leaves() << endl; 
     2284                cout << "size of initial bv subdivision: " << GetStatistics().Leaves() << endl; 
     2285        } 
    22702286} 
    22712287 
     
    23042320 
    23052321        *(tData.mSortedObjects[3]) = objects; 
    2306         stable_sort(tData.mSortedObjects[3]->begin(), tData.mSortedObjects[3]->end(), smallerSize); 
     2322        //stable_sort(tData.mSortedObjects[3]->begin(), tData.mSortedObjects[3]->end(), smallerSize); 
     2323        sort(tData.mSortedObjects[3]->begin(), tData.mSortedObjects[3]->end(), smallerSize); 
    23072324} 
    23082325 
     
    23752392        BvhTraversalData oData(bvhLeaf, 0, prop, nRays); 
    23762393 
    2377         AssignInitialSortedObjectList(oData, objects); 
     2394        if (!TEST_POWERPLANT && mUseGlobalSorting) 
     2395                AssignInitialSortedObjectList(oData, objects); 
    23782396         
    23792397 
     
    26572675                        delete bsc; 
    26582676                } 
    2659                 else // initial preprocessing  finished for this candidate 
    2660                 { 
     2677                else  
     2678                { 
     2679                        // initial preprocessing  finished for this candidate 
    26612680                        // add to candidate container 
    26622681                        candidateContainer.push_back(bsc); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h

    r1941 r2003  
    495495                float GetPriority() const 
    496496                { 
    497                         return mPriority; 
     497                        return (float)-mParentData.mDepth; 
     498                        //return mPriority; 
    498499                } 
    499500 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp

    r1920 r2003  
    149149 
    150150                SetFilled(); 
    151                 // hack 
    152                 if (1 || (leaf->mObjects.size() < 50000)) 
    153                 ExportGeometry(leaf->mObjects, true, box); 
     151                 
     152                if (0) 
     153                        ExportGeometry(leaf->mObjects, true, box); 
     154                else 
     155                        ExportBox(leaf->GetBoundingBox()); 
    154156        } 
    155157 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp

    r2000 r2003  
    3232Preprocessor(),  
    3333mSamplingType(SamplingStrategy::VIEWCELL_BASED_DISTRIBUTION), 
    34 //mSamplingType(SamplingStrategy::DIRECTION_BASED_DISTRIBUTION), 
    3534mProcessedViewCells(0), 
    3635mCurrentViewCell(NULL) 
     
    203202                return false; 
    204203 
    205         if (0 && GVS_DEBUG) 
     204        if (1 && GVS_DEBUG) 
    206205                mVssRays.push_back(new VssRay(*vssRay)); 
    207206 
     
    653652        //exporter->ExportRays(vcRays, RgbColor(1, 0, 0)); 
    654653        //exporter->ExportRays(vcRays2, RgbColor(0, 1, 0)); 
    655         //exporter->ExportRays(vcRays3, RgbColor(1, 1, 1)); 
     654        exporter->ExportRays(vcRays3, RgbColor(1, 1, 1)); 
    656655} 
    657656 
     
    773772                passSamples += newSamples; 
    774773                mGvsStats.mPerViewCellSamples += newSamples; 
    775                 //cout << "here2 " << passSamples % (mSamplesPerPass + 1) << endl; 
     774                 
    776775 
    777776                if (passSamples >= mSamplesPerPass) 
     
    884883                (*oit)->mCounter = 0; 
    885884        } 
     885        long lastTime = GetTime(); 
    886886 
    887887        while (NextViewCell()) 
     
    896896                //mGvsStats.mTrianglePvs = mCurrentViewCell->GetPvs().GetSize(); 
    897897                mGvsStats.mTrianglePvs = (int)mTrianglePvs.size(); 
     898                mGvsStats.mTotalTrianglePvs += mGvsStats.mTrianglePvs; 
    898899 
    899900                ObjectContainer objectPvs; 
     
    910911                mGvsStats.mViewCells = mProcessedViewCells;//mPass; 
    911912                //mGvsStats.mPerViewCellPvs = mCurrentViewCell->GetPvs().GetSize(); 
    912                 mGvsStats.mPerViewCellPvs = (int)mTrianglePvs.size(); 
     913                mGvsStats.mPerViewCellPvs = (int)objectPvs.size(); 
    913914 
    914915                mGvsStats.mTotalPvs += mGvsStats.mPerViewCellPvs; 
    915916                mGvsStats.mTotalSamples += mGvsStats.mPerViewCellSamples; 
    916917 
     918                // timing 
     919                const long currentTime = GetTime(); 
     920         
     921                mGvsStats.mTimePerViewCell = TimeDiff(lastTime, currentTime) * 1e-3f; 
     922                mGvsStats.mTotalTime += mGvsStats.mTimePerViewCell; 
     923 
     924                lastTime = currentTime; 
     925 
    917926                mGvsStats.Stop(); 
    918927                mGvsStats.Print(mGvsStatsStream); 
    919928 
    920                 mTrianglePvs.clear(); 
     929        mTrianglePvs.clear(); 
    921930 
    922931                if (GVS_DEBUG) 
     
    10371046 
    10381047        //Randomize(0); 
    1039          
    10401048        mGvsStats.Reset(); 
    10411049        mGvsStats.Start(); 
     
    11191127void GvsStatistics::Print(ostream &app) const 
    11201128{ 
    1121         app << "#Pass\n" << mPass << endl; 
     1129        app << "#ViewCells\n" << mViewCells << endl; 
    11221130        app << "#ViewCellId\n" << mViewCellId << endl; 
    1123         app << "#Time\n" << Time() << endl; 
     1131        app << "#TotalTime\n" << mTotalTime << endl; 
     1132        app << "#TimePerViewCell\n" << mTimePerViewCell << endl;; 
     1133 
     1134        app << "#RaysPerSec\n" << RaysPerSec() << endl; 
     1135 
     1136        app << "#TrianglePvs\n" << mTrianglePvs << endl; 
     1137        app << "#TotalTrianglePvs\n" << mTotalTrianglePvs << endl; 
     1138 
     1139        app << "#PerViewCellPvs\n" << mPerViewCellPvs << endl; 
     1140        app << "#TotalPvs\n" << mTotalPvs << endl; 
     1141         
     1142        app << "#PerViewCellSamples\n" << mPerViewCellSamples << endl; 
    11241143        app << "#TotalSamples\n" << mTotalSamples << endl; 
    1125         app << "#ScDiff\n" << mPassContribution << endl; 
    11261144        app     << "#SamplesContri\n" << mTotalContribution << endl; 
    1127         app << "#ReverseSamples\n" << mReverseSamples << endl; 
    1128         app << "#BorderSamples\n" << mBorderSamples << endl;             
    1129         app << "#GvsRuns\n" << mGvsPass << endl; 
    1130         app << "#ViewCells\n" << mViewCells << endl; 
    1131         app << "#TotalPvs\n" << mTotalPvs << endl; 
    1132         app << "#PerViewCellPvs\n" << mPerViewCellPvs << endl; 
    1133         app << "#TrianglePvs\n" << mTrianglePvs << endl; 
    1134         app << "#RaysPerSec\n" << RaysPerSec() << endl; 
    1135         app << "#PerViewCellSamples\n" << mPerViewCellSamples << endl << endl; 
    1136 } 
    1137  
    1138  
    1139 } 
     1145                 
     1146        //app << "#ReverseSamples\n" << mReverseSamples << endl; 
     1147        //app << "#BorderSamples\n" << mBorderSamples << endl; 
     1148 
     1149        //app << "#Pass\n" << mPass << endl; 
     1150        //app << "#ScDiff\n" << mPassContribution << endl; 
     1151        //app << "#GvsRuns\n" << mGvsPass << endl;       
     1152 
     1153        app << endl; 
     1154} 
     1155 
     1156 
     1157} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h

    r1999 r2003  
    4141                mTrianglePvs = 0; 
    4242                mViewCellId = 0; 
     43                mTotalTime = 0; 
     44                mTimePerViewCell = 0; 
     45                mTotalTrianglePvs = 0; 
    4346        } 
    4447 
     
    5356        int mBorderSamples; 
    5457        int mGvsPass; 
    55          
     58 
    5659        int mTotalPvs; 
    5760        int mViewCells; 
     
    5962        int mPerViewCellPvs; 
    6063        int mTrianglePvs; 
     64        int mTotalTrianglePvs; 
    6165        int mViewCellId; 
    62          
    63         float RaysPerSec() const { if (!Time()) return 0; return (float)mTotalSamples / Time() * 1e-6f; } 
     66 
     67        float mTimePerViewCell; 
     68        float mTotalTime; 
     69 
     70        float RaysPerSec() const { if (!mTotalTime) return 0; return (float)mTotalSamples / mTotalTime * 1e-6f; } 
    6471 
    6572        void Print(ostream &app) const; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h

    r1920 r2003  
    226226        */ 
    227227        int GetObjectSpaceSubdivisionType() const;       
     228         
    228229        /** The type of view space space subdivison 
    229230        */ 
    230231        int GetViewSpaceSubdivisionType() const; 
     232         
    231233        /** Sets a pointer to the view cells manager. 
    232234        */               
    233235        void SetViewCellsManager(ViewCellsManager *vcm); 
     236         
    234237        /** Sets a pointer to the view cells tree. 
    235238        */ 
    236239        void SetViewCellsTree(ViewCellsTree *vcTree); 
     240 
    237241        /** Exports the object hierarchy to disc. 
    238242        */ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp

    r1999 r2003  
    1717RayCaster(preprocessor) 
    1818{ 
    19         InitRayCast(externKdTree); 
     19        if (!InitRayCast(externKdTree)) 
     20                cout << "warning: intel ray tracer could not be initialized!" << endl; 
    2021} 
    2122 
     
    2829bool IntelRayCaster::InitRayCast(const string externKdTree) 
    2930{ 
    30   cout<<"Ray Cast file: " << externKdTree << endl; 
    31   return mlrtaLoadAS(externKdTree.c_str()); 
     31        cout<<"Intel ray cast file: " << externKdTree << endl; 
     32         
     33        return mlrtaLoadAS(externKdTree.c_str()); 
    3234} 
    3335 
     
    4143                                                        ) 
    4244{ 
    43         //cout << "intel ray" << endl; 
     45        cout << "intel ray" << endl; 
    4446        VssRay *vssRay  = NULL; 
    4547        int hits = 0; 
     
    7375        if (castDoubleRay) 
    7476        { 
    75           //cerr<<"HERE"<<endl; 
    76           Vector3 dir = -simpleRay.mDirection; 
     77                //cerr<<"HERE"<<endl; 
     78                Vector3 dir = -simpleRay.mDirection; 
    7779                hittriangle = mlrtaIntersectAS( 
    7880                                                                                &simpleRay.mOrigin.x, 
  • GTP/trunk/Lib/Vis/Preprocessing/src/InternalRayCaster.cpp

    r1996 r2003  
    1010 
    1111 
    12 InternalRayCaster::InternalRayCaster(const Preprocessor &preprocessor, KdTree *kdTree): 
    13 RayCaster(preprocessor), mKdTree(kdTree) 
     12InternalRayCaster::InternalRayCaster(const Preprocessor &preprocessor): 
     13RayCaster(preprocessor) 
    1414{ 
    1515} 
     
    5050 
    5151   
    52   if (mKdTree->CastRay(ray)) { 
     52  if (mPreprocessor.mKdTree->CastRay(ray)) { 
    5353        hitA.mObject = ray.intersections[0].mObject; 
    5454        hitA.mPoint = ray.Extrap(ray.intersections[0].mT); 
     
    6060  ray.mFlags &= ~Ray::CULL_BACKFACES; 
    6161   
    62   if (castDoubleRay && mKdTree->CastRay(ray)) { 
     62  if (castDoubleRay && mPreprocessor.mKdTree->CastRay(ray)) { 
    6363        hitB.mObject = ray.intersections[0].mObject; 
    6464        hitB.mPoint = ray.Extrap(ray.intersections[0].mT); 
     
    102102  VssRay *vssRay; 
    103103   
    104   if (mKdTree->CastRay(ray)) { 
     104  if (mPreprocessor.mKdTree->CastRay(ray)) { 
    105105        // sort intersections 
    106106        ray.SortIntersections(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/InternalRayCaster.h

    r1996 r2003  
    3030        /** Default constructor initialising e.g., KD tree 
    3131        */ 
    32         InternalRayCaster(const Preprocessor &preprocessor, KdTree *kdTree); 
     32        InternalRayCaster(const Preprocessor &preprocessor); 
    3333        virtual ~InternalRayCaster(); 
    3434 
     
    6060protected: 
    6161 
    62         KdTree *mKdTree; 
     62        //KdTree *mKdTree; 
    6363}; 
    6464 
  • GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp

    r1999 r2003  
    9494 
    9595  if (!splitCandidates) 
    96     splitCandidates = new vector<SortableEntry>; 
     96    splitCandidates = new vector<SortableEntry *>; 
    9797 
    9898  // first construct a leaf that will get subdivide 
     
    114114 
    115115  // remove the allocated array 
     116  CLEAR_CONTAINER(*splitCandidates); 
    116117  delete splitCandidates; 
    117118 
     
    460461                            ) 
    461462{ 
    462   splitCandidates->clear(); 
     463        CLEAR_CONTAINER(*splitCandidates); 
     464  //splitCandidates->clear(); 
    463465   
    464466  int requestedSize = 2*(int)node->mObjects.size(); 
     
    467469      requestedSize < (int)(splitCandidates->capacity()/10) ) { 
    468470    delete splitCandidates; 
    469     splitCandidates = new vector<SortableEntry>; 
     471    splitCandidates = new vector<SortableEntry *>; 
    470472  } 
    471473   
     
    478480    AxisAlignedBox3 box = (*mi)->GetBox(); 
    479481 
    480     splitCandidates->push_back(SortableEntry(SortableEntry::BOX_MIN, 
     482    splitCandidates->push_back(new SortableEntry(SortableEntry::BOX_MIN, 
    481483                                                                                         box.Min(axis), 
    482484                                                                                         *mi) 
     
    484486     
    485487     
    486     splitCandidates->push_back(SortableEntry(SortableEntry::BOX_MAX, 
     488    splitCandidates->push_back(new SortableEntry(SortableEntry::BOX_MAX, 
    487489                                                                                         box.Max(axis), 
    488490                                                                                         *mi) 
     
    532534 
    533535  float totalIntersections = 0.0f; 
    534   vector<SortableEntry>::const_iterator ci; 
     536  vector<SortableEntry *>::const_iterator ci; 
    535537 
    536538  for(ci = splitCandidates->begin(); 
    537539      ci < splitCandidates->end(); 
    538540      ci++)  
    539     if ((*ci).type == SortableEntry::BOX_MIN) { 
    540       totalIntersections += (*ci).intersectable->IntersectionComplexity(); 
     541    if ((*ci)->type == SortableEntry::BOX_MIN) { 
     542      totalIntersections += (*ci)->intersectable->IntersectionComplexity(); 
    541543    } 
    542544         
     
    558560      ci < splitCandidates->end(); 
    559561      ci++) { 
    560     switch ((*ci).type) { 
     562    switch ((*ci)->type) { 
    561563    case SortableEntry::BOX_MIN: 
    562564      objectsLeft++; 
    563       intersectionsLeft += (*ci).intersectable->IntersectionComplexity(); 
     565      intersectionsLeft += (*ci)->intersectable->IntersectionComplexity(); 
    564566      break; 
    565567    case SortableEntry::BOX_MAX: 
    566568      objectsRight--; 
    567       intersectionsRight -= (*ci).intersectable->IntersectionComplexity(); 
     569      intersectionsRight -= (*ci)->intersectable->IntersectionComplexity(); 
    568570      break; 
    569571    } 
    570572 
    571     if ((*ci).value > minBand && (*ci).value < maxBand) { 
     573    if ((*ci)->value > minBand && (*ci)->value < maxBand) { 
    572574      AxisAlignedBox3 lbox = box; 
    573575      AxisAlignedBox3 rbox = box; 
    574       lbox.SetMax(axis, (*ci).value); 
    575       rbox.SetMin(axis, (*ci).value); 
     576      lbox.SetMax(axis, (*ci)->value); 
     577      rbox.SetMin(axis, (*ci)->value); 
    576578 
    577579      float sum; 
     
    589591        float newCost = mCt_div_ci + sum/boxArea; 
    590592        float ratio = newCost/oldCost; 
    591         costStream<<(*ci).value<<" "<<ratio<<endl; 
     593        costStream<<(*ci)->value<<" "<<ratio<<endl; 
    592594  } 
    593595#endif 
     
    595597      if (sum < minSum) { 
    596598                minSum = sum; 
    597                 position = (*ci).value; 
     599                position = (*ci)->value; 
    598600                 
    599601                objectsBack = objectsLeft; 
     
    12641266                if ((oit != objects.end()) && ((*oit)->GetId() == objId)) 
    12651267                { 
    1266                         leaf->mObjects.push_back(*oit); 
     1268                        if (1) leaf->mObjects.push_back(*oit); 
    12671269                } 
    12681270                else 
  • GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h

    r1999 r2003  
    548548   
    549549  // reusable array of split candidates 
    550   vector<SortableEntry> *splitCandidates; 
     550  vector<SortableEntry *> *splitCandidates; 
    551551 
    552552  float 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r2002 r2003  
    265265 
    266266        cout << "binary obj dump available, loading " << filename.c_str() << endl; 
    267         // table associating indices with vectors 
    268         map<int, Vector3> hashTable; 
     267         
    269268 
    270269        // table for vertices 
    271270        VertexContainer vertices;  
    272         FaceContainer faces; 
    273  
     271         
    274272        if (parents) 
    275273                cout << "using face parents" << endl; 
     
    277275                cout << "not using face parents" << endl; 
    278276 
     277        int dummy = 0; 
     278        vector<Triangle3> triangles; 
     279        //triangles.reserve(sizeof(Triangle3) * 13000000); 
     280        //triangles.reserve(13000000); 
     281        //root->mGeometry.reserve(13000000); 
     282 
    279283        while (1) 
    280284        { 
     
    291295                TriangleIntersectable *obj = new TriangleIntersectable(tri); 
    292296                root->mGeometry.push_back(obj); 
    293  
    294                 // matt: we don't really need to keep an additional data structure 
    295                 // if working with triangles => remove this 
    296                 if (parents)  
    297                 { 
    298                         FaceParentInfo info(obj, 0); 
    299                         parents->push_back(info); 
    300                 }        
    301         } 
    302          
     297                //triangles.push_back(tri); 
     298                //dummy ++; 
     299                //if (dummy % 100000 == 9999) 
     300                //cout << "idx: " << dummy << endl; 
     301        } 
     302         
     303        //cout << "here411" << endl; 
    303304        return true; 
    304305} 
     
    405406Intersectable *Preprocessor::GetParentObject(const int index) const 
    406407{ 
    407         if (index == -1) 
    408           return NULL; 
     408        if (index < 0) 
     409        { 
     410                cerr << "Warning: triangle index smaller zero! " << index << endl; 
     411                return NULL; 
     412        } 
    409413         
    410414        if (!mFaceParents.empty()) 
     
    421425        } 
    422426        else 
    423           { 
    424           if (index >= (int)mObjects.size()) { 
    425                 cerr<<"Warning: triangle  index out of range! "<<index<<endl; 
    426                 return NULL; 
    427           } 
    428           else 
    429                 { 
    430                   return mObjects[index]; 
    431                 } 
    432           } 
     427        { 
     428                  if (index >= (int)mObjects.size())  
     429                  { 
     430                          cerr<<"Warning: triangle  index out of range! " << index << endl; 
     431                          return NULL; 
     432                  } 
     433                  else 
     434                  { 
     435                          return mObjects[index]; 
     436                  } 
     437        } 
    433438} 
    434439 
     
    10781083 
    10791084 
    1080 bool Preprocessor::InitRayCast(const string externKdTree,  
    1081                                                            const string internKdTree) 
     1085bool Preprocessor::LoadInternKdTree( const string internKdTree) 
    10821086{ 
    10831087        // always try to load the kd tree 
     
    11111115        cout << mKdTree->GetBox() << endl; 
    11121116 
     1117        return true; 
     1118} 
     1119 
     1120 
     1121bool Preprocessor::InitRayCast(const string externKdTree,  
     1122                                                           const string internKdTree) 
     1123{ 
     1124        // always try to load the kd tree 
     1125/*      cout << "loading kd tree file " << internKdTree << " ... " << endl; 
     1126 
     1127        if (!LoadKdTree(internKdTree)) 
     1128        { 
     1129                cout << "error loading kd tree with filename "  
     1130                         << internKdTree << ", rebuilding it instead ... " << endl; 
     1131                // build new kd tree from scene geometry 
     1132                BuildKdTree(); 
     1133 
     1134                // export kd tree? 
     1135                const long startTime = GetTime(); 
     1136                cout << "exporting kd tree ... "; 
     1137 
     1138                if (!ExportKdTree(internKdTree)) 
     1139                { 
     1140                        cout << " error exporting kd tree with filename "  
     1141                                 << internKdTree << endl; 
     1142                } 
     1143                else 
     1144                { 
     1145                        cout << "finished in "  
     1146                                 << TimeDiff(startTime, GetTime()) * 1e-3  
     1147                                 << " secs" << endl; 
     1148                } 
     1149        } 
     1150         
     1151        KdTreeStatistics(cout); 
     1152        cout << mKdTree->GetBox() << endl; 
     1153*/ 
    11131154        int rayCastMethod; 
    11141155        Environment::GetSingleton()-> 
     
    11181159        { 
    11191160                cout << "ray cast method: internal" << endl; 
    1120                 mRayCaster = new InternalRayCaster(*this, mKdTree); 
     1161                mRayCaster = new InternalRayCaster(*this); 
    11211162        } 
    11221163        else 
     
    11401181                                           ) 
    11411182{ 
    1142  
    1143  
    11441183  const long t1 = GetTime(); 
    11451184 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h

    r2002 r2003  
    164164        bool InitRayCast(const string externKdTree, const string internKdTree); 
    165165 
     166        bool LoadInternKdTree(const string internKdTree); 
     167 
    166168        bool ExportObj(const string filename, const ObjectContainer &objects); 
    167169 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp

    r2001 r2003  
    748748 
    749749        Vector3 point; 
    750         Vector3 normal, normal2; 
    751          
     750        Vector3 normal; 
     751                 
     752        //Vector normalObj; 
    752753        // float r[1]; 
    753754        // sHalton.GetNext(1, r); 
     
    769770 
    770771        // get point on view cell surface 
    771         mViewCell->GetRandomSurfacePoint(origin, normal2); 
     772        mViewCell->GetRandomSurfacePoint(origin, normal); 
    772773 
    773774        //direction = point - origin; 
     
    775776        // move a little bit back to avoid piercing through walls 
    776777        // that bound the view cell 
    777         origin -= 0.01f * normal2; 
     778        origin -= 0.01f * normal; 
    778779 
    779780        // $$ jb the pdf is yet not correct for all sampling methods! 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Statistics.h

    r860 r2003  
    1717  static inline double TimeDiff(long time1, long time2) // in s 
    1818  { 
    19     const double clk=1.0E-6; // ticks per second 
    20     long t=time2-time1; 
     19    const double clk = 1.0E-6; // ticks per second 
     20    long t = time2 - time1; 
    2121                 
    22     return ((t<0)?-t:t)*clk; 
     22    return ((t < 0) ? -t : t) * clk; 
    2323  } 
    2424         
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r1999 r2003  
    517517 
    518518ViewCellsTree::~ViewCellsTree() 
    519 {cout<<"here1002"; 
     519{ 
    520520        DEL_PTR(mRoot); 
    521521} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1999 r2003  
    311311        // question: rather create view cells resource manager? 
    312312        if (!ViewCellsTreeConstructed()) 
    313         {cout << "here6" << endl; 
     313        { 
    314314                CLEAR_CONTAINER(mViewCells); 
    315315        } 
    316316        else 
    317         {cout << "here7" << endl; 
     317        { 
    318318                DEL_PTR(mViewCellsTree); 
    319319        } 
     
    59625962                } 
    59635963 
    5964                 // hack color code (show pvs size) 
     5964                // hack color code 
    59655965                const int savedColorCode = mColorCode; 
    59665966 
     
    60056005 
    60066006                mColorCode = 1; // 0 = random, 1 = export pvs 
     6007                // don't visualize render cost 
    60076008                const float maxRenderCost = -1; 
    60086009 
    6009                 if (0) 
     6010                if (1) 
    60106011                mHierarchyManager->ExportObjectSpaceHierarchy(exporter, objects,  
    60116012                                                                                                          CLAMP_TO_BOX ? &bbox : NULL, maxRenderCost, false); 
     
    60136014 
    60146015                //ExportViewCellsForViz(exporter, CLAMP_TO_BOX ? &bbox : NULL, mColorCode, GetClipPlane()); 
    6015                 ExportViewCellsForViz(exporter, NULL, mColorCode, GetClipPlane()); 
     6016                if (0) 
     6017                        ExportViewCellsForViz(exporter, NULL, mColorCode, GetClipPlane()); 
    60166018 
    60176019                delete exporter; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r1990 r2003  
    11351135        } 
    11361136 
    1137         stable_sort(mLocalSubdivisionCandidates->begin(), mLocalSubdivisionCandidates->end()); 
     1137        //stable_sort(mLocalSubdivisionCandidates->begin(), mLocalSubdivisionCandidates->end()); 
     1138        sort(mLocalSubdivisionCandidates->begin(), mLocalSubdivisionCandidates->end()); 
    11381139} 
    11391140 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h

    r1977 r2003  
    514514                float GetPriority() const 
    515515                { 
    516                         return mPriority; 
     516                        return (float)-mParentData.mDepth; 
     517                        //return mPriority; 
    517518                } 
    518519 
  • GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp

    r1999 r2003  
    192192        } 
    193193 
     194        Environment::GetSingleton()->GetStringValue("Scene.filename", buff); 
     195        string filename(buff); 
     196         
     197        const string externKdTree = ReplaceSuffix(filename, ".obj", ".kdf"); 
     198        const string internKdTree = GetInternFilename(filename, preprocessor->mLoadMeshes ? ".kdm" : ".kdt"); 
     199 
     200        if (preprocessor->InitRayCast(externKdTree, internKdTree)) 
     201        { 
     202                cout << "ray casting initialized!" << endl; 
     203        } 
     204        else 
     205        { 
     206                cout << "ray casting initialization failed!" << endl; 
     207                Cleanup(); 
     208                exit(1); 
     209        } 
     210 
     211 
    194212        ///////////// 
    195213        //-- load scene  
    196214 
    197         Environment::GetSingleton()->GetStringValue("Scene.filename", buff); 
    198         string filename(buff); 
    199          
    200  
    201215        if (!preprocessor->LoadScene(filename)) 
    202216        { 
     
    206220        } 
    207221         
    208         const string externKdTree = ReplaceSuffix(filename, ".obj", ".kdf"); 
    209         const string internKdTree = GetInternFilename(filename, preprocessor->mLoadMeshes ? ".kdm" : ".kdt"); 
    210222 
    211223        //////////// 
    212224        //-- initialize external ray caster 
    213225 
    214         if (preprocessor->InitRayCast(externKdTree, internKdTree)) 
    215         { 
    216                 cout << "ray casting initialized!" << endl; 
     226        if (preprocessor->LoadInternKdTree(internKdTree)) 
     227        { 
     228                cout << "intern kd tree loaded!" << endl; 
    217229        } 
    218230        else 
    219231        { 
    220                 cout << "ray casting initialization failed" << endl; 
     232                cout << "loading intern kd tree failed!" << endl; 
    221233                Cleanup(); 
    222234                exit(1); 
Note: See TracChangeset for help on using the changeset viewer.