Ignore:
Timestamp:
05/20/08 17:15:44 (16 years ago)
Author:
mattausch
Message:

strange errors!!

File:
1 edited

Legend:

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

    r2689 r2690  
    152152#endif 
    153153        { 
    154                 //cout << "r"; 
    155154                // apply reverse sampling to find the gap 
    156155                VssRay *newRay = ReverseSampling(currentRay, hitTriangle, oldRay); 
     
    160159 
    161160                // set flag for visualization 
    162                 //newRay->mFlags |= VssRay::ReverseSample; 
     161                if (0) newRay->mFlags |= VssRay::ReverseSample; 
    163162                 
    164163                // check if ray is not further processed (ray not deleted because using ray pool) 
     
    185184void GvsPreprocessor::UpdateStatsForVisualization(KdIntersectable *kdInt) 
    186185{ 
    187         mViewCellsManager->UpdateStatsForViewCell(mCurrentViewCell, kdInt); 
     186        //mViewCellsManager->UpdateStatsForViewCell(mCurrentViewCell, kdInt); 
    188187 
    189188        // count new objects in pvs due to kd node conversion    
     
    222221 
    223222                // counter < 2 => not accounted for yet 
    224                 if (obj->mCounter < ACCOUNTED_OBJECT) 
     223                        // test of triangle was accounted for yet 
     224                if (result = AddTriangleObject(obj)) 
    225225                { 
    226                         obj->mCounter += ACCOUNTED_OBJECT; 
    227                         mTrianglePvs.push_back(obj); 
    228                  
    229                         mGenericStats = (int)mTrianglePvs.size(); 
    230  
    231226                        // exchange the triangle with the node in the pvs for kd pvs 
    232227                        if (mUseKdPvs) 
     
    664659 
    665660        while (!mRayQueue.empty())//&& (mGvsStats.mTotalSamples + castSamples < mTotalSamples) ) 
    666         {//cout<<"r"; 
    667                 //cout << "queue size: " << mRayQueue.size() << endl; 
     661        { 
    668662                // handle next ray 
    669663                VssRay *ray = mRayQueue.top(); 
     
    794788 
    795789 
    796 void GvsPreprocessor::ProcessViewCell() 
    797 { 
    798         // compute object that directly intersect view cell 
    799         IntersectWithViewCell(); 
    800  
    801         mGvsStats.mPerViewCellSamples = 0; 
    802  
    803         int oldContribution = mGvsStats.mTotalContribution; 
    804         int passSamples = 0; 
    805  
    806         mGenericStats = 0; 
    807         mGenericStats2 = 0; 
    808  
    809         while (1) 
    810         { 
    811                 mRayCaster->InitPass(); 
    812  
    813                 // Ray queue empty =>  
    814                 // cast a number of uniform samples to fill ray queue 
    815                 int newSamples = CastInitialSamples(mInitialSamples, mSamplingType); 
    816  
    817                 if (!mOnlyRandomSampling) 
    818                 { 
    819                         int samplesPerRun = ProcessQueue(); 
    820                         newSamples += samplesPerRun; 
    821                         //if (samplesPerRun > 0) cout << "spr: " << samplesPerRun << " "; 
    822                 } 
    823  
    824                 passSamples += newSamples; 
    825         mGvsStats.mPerViewCellSamples += newSamples; 
    826  
    827                 if (passSamples >= mGvsSamplesPerPass) 
    828                 { 
    829                         ++ mPass; 
    830                         mGvsStats.mPassContribution = mGvsStats.mTotalContribution - oldContribution; 
    831  
    832                         //////// 
    833                         //-- stats 
    834  
    835                         mGvsStats.mPass = mPass; 
    836  
    837                         cout << "\nPass " << mPass << " #samples: " << mGvsStats.mPerViewCellSamples << endl; 
    838                         cout << "contribution=" << mGvsStats.mPassContribution << " (of " << mMinContribution << ")" << endl; 
    839  
    840                         //mGenericStats = mGvsStats.mPassContribution; 
    841  
    842                         // termination criterium 
    843                         if (mGvsStats.mPassContribution < mMinContribution) 
    844                                 break; 
    845  
    846                         // reset 
    847                         oldContribution = mGvsStats.mTotalContribution; 
    848                         mGvsStats.mPassContribution = 0; 
    849                         passSamples = 0; 
    850                 } 
    851         } 
    852 } 
    853  
    854  
    855790void GvsPreprocessor::CompileViewCellsFromPointList() 
    856791{ 
     
    945880} 
    946881 
    947 #if 0 
     882#if 1 
    948883void GvsPreprocessor::IntersectWithViewCell() 
    949884{ 
     
    10661001void GvsPreprocessor::PerViewCellComputation() 
    10671002{ 
    1068         ViewCell *vc; 
    1069  
    1070         while (vc = NextViewCell()) 
     1003        while (mCurrentViewCell = NextViewCell()) 
    10711004        { 
    10721005                // hack: reset counters 
     
    10761009                        (*oit)->mCounter = NOT_ACCOUNTED_OBJECT; 
    10771010 
    1078         ComputeViewCell(vc); 
     1011        ComputeViewCell(); 
    10791012        } 
    10801013} 
     
    10881021                        continue; 
    10891022 
    1090         ViewCell *vc = mViewCellsManager->GetViewCell(mRendererWidget->GetViewPoint()); 
     1023        mCurrentViewCell = mViewCellsManager->GetViewCell(mRendererWidget->GetViewPoint()); 
    10911024 
    10921025                // no valid view cell or view cell already computed 
    1093                 if (!vc || !vc->GetPvs().Empty() || !mRendererWidget->mComputeGVS) 
     1026                if (!mCurrentViewCell || !mCurrentViewCell->GetPvs().Empty() || !mRendererWidget->mComputeGVS) 
    10941027                        continue; 
    10951028 
     
    11011034                        (*oit)->mCounter = NOT_ACCOUNTED_OBJECT; 
    11021035 
    1103                 ComputeViewCell(vc); 
     1036                ComputeViewCell(); 
    11041037                ++ mProcessedViewCells; 
    11051038        } 
     
    13221255        app << "#Id\n" << mViewCellId << endl; 
    13231256        app << "#Time\n" << mTimePerViewCell << endl;; 
    1324         app << "#TriaePvs\n" << mTrianglePvs << endl; 
     1257        app << "#TriPvs\n" << mTrianglePvs << endl; 
    13251258        app << "#ObjectPvs\n" << mPerViewCellPvs << endl; 
    13261259        app << "#UpdatedPvs\n" << (int)mPvsCost << endl; 
     
    13511284 
    13521285 
    1353 void GvsPreprocessor::ComputeViewCell(ViewCell *vc) 
     1286void GvsPreprocessor::ComputeViewCell() 
    13541287{ 
    13551288        KdNode::NewMail(); 
    13561289 
    1357         mCurrentViewCell = vc; 
    1358          
    13591290        const long startTime = GetTime(); 
    13601291 
     
    13641295 
    13651296        // compute the pvs of the current view cell 
    1366         ProcessViewCell(); 
    1367  
    1368          
     1297        // compute object that directly intersect view cell 
     1298        //IntersectWithViewCell(); 
     1299 
     1300        mGvsStats.mPerViewCellSamples = 0; 
     1301 
     1302        int oldContribution = mGvsStats.mTotalContribution; 
     1303        int passSamples = 0; 
     1304 
     1305        mGenericStats = 0; 
     1306        mGenericStats2 = 0; 
     1307 
     1308        while (1) 
     1309        { 
     1310                int oldPvsSize = 0;//mCurrentViewCell->GetPvs().GetSize(); 
     1311 
     1312                mRayCaster->InitPass(); 
     1313 
     1314                // Ray queue empty =>  
     1315                // cast a number of uniform samples to fill ray queue 
     1316                int newSamples = CastInitialSamples(mInitialSamples, mSamplingType); 
     1317 
     1318                if (!mOnlyRandomSampling) 
     1319                { 
     1320                        int samplesPerRun = ProcessQueue(); 
     1321                        newSamples += samplesPerRun; 
     1322                        //if (samplesPerRun > 0) cout << "spr: " << samplesPerRun << " "; 
     1323                } 
     1324 
     1325                passSamples += newSamples; 
     1326        mGvsStats.mPerViewCellSamples += newSamples; 
     1327 
     1328                if (passSamples >= mGvsSamplesPerPass) 
     1329                { 
     1330                        if (GVS_DEBUG) VisualizeViewCell(mTrianglePvs); 
     1331 
     1332                        const bool convertPerPass = false; 
     1333 
     1334                        if (convertPerPass) 
     1335                        {        
     1336                                int newObjects = ConvertObjectPvs(); 
     1337 
     1338                                cout << "added " << newObjects << " triangles to triangle pvs" << endl; 
     1339                                mGvsStats.mTotalContribution += newObjects; 
     1340                        } 
     1341 
     1342                        ++ mPass; 
     1343                        mGvsStats.mPassContribution = mGvsStats.mTotalContribution - oldContribution; 
     1344 
     1345 
     1346                        //////// 
     1347                        //-- stats 
     1348 
     1349                        mGvsStats.mPass = mPass; 
     1350 
     1351                        cout << "\nPass " << mPass << " #samples: " << mGvsStats.mPerViewCellSamples << endl; 
     1352                        cout << "contribution=" << mGvsStats.mPassContribution << " (of " << mMinContribution << ")" << endl; 
     1353                        cout << "obj contri=" << mCurrentViewCell->GetPvs().GetSize() - oldPvsSize << " (of " << mMinContribution << ")" << endl; 
     1354 
     1355                        // termination criterium 
     1356                        if (mGvsStats.mPassContribution < mMinContribution) 
     1357                                break; 
     1358 
     1359                        // reset 
     1360                        oldContribution = mGvsStats.mTotalContribution; 
     1361                        mGvsStats.mPassContribution = 0; 
     1362                        passSamples = 0; 
     1363                } 
     1364        } 
     1365         
     1366        // finally add objects that directly intersect the view cell 
     1367        //IntersectWithViewCell(); 
     1368 
     1369                 
    13691370        //////// 
    13701371        //-- stats 
    13711372 
     1373        // timing 
     1374        mGvsStats.mTimePerViewCell = TimeDiff(startTime, GetTime()) * 1e-3f; 
     1375 
     1376        ComputeStats(); 
     1377 
     1378        // clean up 
     1379        mTrianglePvs.clear(); 
     1380} 
     1381 
     1382 
     1383void GvsPreprocessor::ComputeStats() 
     1384{ 
    13721385        // compute pvs size using larger (bvh objects) 
    13731386        // note: for kd pvs we had to do this during gvs computation 
     
    14021415 
    14031416        mGvsStats.mTrianglePvs = (int)mTrianglePvs.size(); 
    1404          
    1405         // timing 
    1406         const long currentTime = GetTime(); 
    1407         mGvsStats.mTimePerViewCell = TimeDiff(startTime, currentTime) * 1e-3f; 
    14081417 
    14091418 
     
    14111420        // global values 
    14121421 
    1413         mGvsStats.mViewCells = mProcessedViewCells;//mPass; 
     1422        mGvsStats.mViewCells = mProcessedViewCells; 
    14141423        mGvsStats.mTotalTrianglePvs += mGvsStats.mTrianglePvs; 
    14151424        mGvsStats.mTotalTime += mGvsStats.mTimePerViewCell; 
     
    14211430 
    14221431        cout << "id: " << mCurrentViewCell->GetId() << " pvs cost: "  
    1423          << mGvsStats.mPvsCost << " pvs tri: " << mTrianglePvs.size() << endl; 
    1424  
    1425  
    1426         mTrianglePvs.clear(); 
    1427 } 
    1428  
    1429 } 
     1432             << mGvsStats.mPvsCost << " pvs tri: " << mTrianglePvs.size() << endl; 
     1433} 
     1434 
     1435 
     1436ObjectContainer triangles; 
     1437 
     1438int GvsPreprocessor::ConvertObjectPvs() 
     1439{ 
     1440        int newObjects = 0; 
     1441 
     1442        ObjectPvsIterator pit = mCurrentViewCell->GetPvs().GetIterator(); 
     1443 
     1444        triangles.clear(); 
     1445 
     1446        // output PVS of view cell 
     1447        while (pit.HasMoreEntries()) 
     1448        {                
     1449                KdIntersectable *kdInt = static_cast<KdIntersectable *>(pit.Next()); 
     1450 
     1451                mKdTree->CollectObjectsWithDublicates(kdInt->GetItem(), triangles); 
     1452 
     1453                ObjectContainer::const_iterator oit, oit_end = triangles.end(); 
     1454 
     1455                for (oit = triangles.begin(); oit != oit_end; ++ oit) 
     1456                { 
     1457                        if (AddTriangleObject(*oit)) 
     1458                                ++ newObjects; 
     1459                } 
     1460        } 
     1461 
     1462        return newObjects; 
     1463} 
     1464 
     1465 
     1466bool GvsPreprocessor::AddTriangleObject(Intersectable *triObj) 
     1467{ 
     1468        if ((triObj->mCounter < ACCOUNTED_OBJECT)) 
     1469        { 
     1470                triObj->mCounter += ACCOUNTED_OBJECT; 
     1471 
     1472                mTrianglePvs.push_back(triObj); 
     1473                mGenericStats = (int)mTrianglePvs.size(); 
     1474                return true; 
     1475        } 
     1476 
     1477        return false; 
     1478} 
     1479 
     1480} 
Note: See TracChangeset for help on using the changeset viewer.