Changeset 2691


Ignore:
Timestamp:
05/21/08 01:18:40 (16 years ago)
Author:
mattausch
Message:

fixed several errors

Location:
GTP/trunk/Lib/Vis/Preprocessing
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/run_demo_vienna

    r2689 r2691  
    2525#PREFIX=../work/plots/atlanta2-rss9 
    2626 
    27 DISTRIBUTIONS=mutation+object_direction+spatial 
     27#DISTRIBUTIONS=mutation+object_direction+spatial 
     28DISTRIBUTIONS=object_direction 
    2829#DISTRIBUTIONS=spatial 
    2930 
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh

    r2690 r2691  
    3636-gvs_initial_samples=16 \ 
    3737-gvs_max_viewcells=1 \ 
    38 -gvs_min_contribution=1500 \ 
     38-gvs_min_contribution=3000 \ 
    3939-gvs_per_viewcell=true \ 
    4040-gvs_stats=$LOG_PREFIX-gvsStats.log \ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.cpp

    r2686 r2691  
    23722372} 
    23732373 
     2374 
     2375void AxisAlignedBox3::GetRandomEdgePoint(Vector3 &point, 
     2376                                                                                 Vector3 &normal) 
     2377{ 
     2378        // get random edge 
     2379        const int idx = Random(12);  
     2380        Vector3 a, b; 
     2381        GetEdge(idx, &a, &b); 
     2382         
     2383        const float w = RandomValue(0.0f, 1.0f); 
     2384 
     2385        point = a * w + b * (1.0f - w); 
     2386 
     2387        // TODO 
     2388        normal = Vector3(0); 
     2389} 
     2390 
     2391 
    23742392Vector3 
    23752393AxisAlignedBox3::GetUniformRandomSurfacePoint() const 
  • GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.h

    r2686 r2691  
    200200  Vector3 GetRandomSurfacePoint() const; 
    201201  Vector3 GetUniformRandomSurfacePoint() const; 
     202 
     203  void GetRandomEdgePoint(Vector3 &point, Vector3 &normal); 
    202204 
    203205  Vector3 GetPoint(const Vector3 &p) const { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp

    r2690 r2691  
    4545GvsPreprocessor::GvsPreprocessor():  
    4646Preprocessor(),  
    47 mSamplingType(SamplingStrategy::VIEWCELL_BASED_DISTRIBUTION), 
    4847mProcessedViewCells(0), 
    4948mCurrentViewCell(NULL), 
    50 mCurrentViewPoint(Vector3(0.0f, 0.0f, 0.0f)) 
     49mCurrentViewPoint(Vector3(0.0f, 0.0f, 0.0f)), 
     50mOnlyRandomSampling(false) 
     51//mOnlyRandomSampling(true) 
    5152{ 
    5253        Environment::GetSingleton()->GetIntValue("GvsPreprocessor.totalSamples", mTotalSamples); 
     
    7071        cout << "number of gvs samples per pass: " << mGvsSamplesPerPass << endl; 
    7172        cout << "number of samples per pass: " << mSamplesPerPass << endl; 
     73        cout << "only random sampling: " << mOnlyRandomSampling << endl; 
    7274 
    7375        Debug << "Gvs preprocessor options" << endl; 
     
    8183        Debug << "min contribution: " << mMinContribution << endl; 
    8284 
    83         if (1) 
    84                 mOnlyRandomSampling = false;             
    85         else 
    86                 mOnlyRandomSampling = true; 
     85        mDistribution = new ViewCellBasedDistribution(*this, NULL); 
    8786 
    8887        mGvsStats.Reset(); 
     
    9089        // hack: some generic statistical values that can be read 
    9190        // by an application using the preprocessor 
    92         mGenericStats = 0; 
    93         mGenericStats2 = 0; 
     91        for (int i = 0; i < 2; ++ i) 
     92                mGenericStats[i] = 0; 
    9493} 
    9594 
     
    9796GvsPreprocessor::~GvsPreprocessor() 
    9897{ 
     98        delete mDistribution; 
    9999        ClearRayQueue(); 
    100100} 
     
    177177        { 
    178178                ++ triObj->mCounter; 
    179                 ++ mGenericStats2; 
     179                ++ mGenericStats[1]; 
    180180        } 
    181181} 
     
    221221 
    222222                // counter < 2 => not accounted for yet 
    223                         // test of triangle was accounted for yet 
    224                 if (result = AddTriangleObject(obj)) 
     223                // test of triangle was accounted for yet 
     224                result = AddTriangleObject(obj); 
     225                 
     226                if (mUseKdPvs && (1 || result)) 
    225227                { 
    226228                        // exchange the triangle with the node in the pvs for kd pvs 
    227                         if (mUseKdPvs) 
     229                        KdNode *node = mKdTree->GetPvsNode(ray.mTermination); 
     230 
     231                        //KdNode *node = mKdTree->GetPvsNodeCheck(ray.mTermination, obj); 
     232                        //if (!node) cerr << "e: " << obj->GetBox() << " " << ray.mTermination << endl; else  
     233                        if (!node->Mailed()) 
    228234                        { 
    229                                 KdNode *node = mKdTree->GetPvsNode(ray.mTermination); 
    230  
    231                                 if (!node->Mailed()) 
    232                                 { 
    233                                         // add to pvs 
    234                                         node->Mail(); 
    235                                         KdIntersectable *kdInt = mKdTree->GetOrCreateKdIntersectable(node); 
    236                                         mCurrentViewCell->GetPvs().AddSampleDirty(kdInt, 1.0f); 
    237                                  
    238                                         if (SHOW_QT_VISUALIZATION) UpdateStatsForVisualization(kdInt);   
    239                                 } 
     235                                //cout<<"o"; 
     236                                // add to pvs 
     237                                node->Mail(); 
     238                                KdIntersectable *kdInt = mKdTree->GetOrCreateKdIntersectable(node); 
     239                                mCurrentViewCell->GetPvs().AddSampleDirty(kdInt, 1.0f); 
     240 
     241                                if (SHOW_QT_VISUALIZATION) UpdateStatsForVisualization(kdInt);   
    240242                        } 
    241  
    242                         result = true; 
    243                 } 
    244                 else 
    245                 { 
    246                         result = false; 
    247243                } 
    248244        } 
     
    257253                return false; 
    258254 
    259 //      cout << "t"; 
    260255        if (0 && GVS_DEBUG) 
    261256                mVssRays.push_back(new VssRay(*vssRay)); 
     
    441436        //const int numRandomRays = 0; 
    442437        const int numRandomRays = 16 - (int)simpleRays.size(); 
    443         ViewCellBasedDistribution vcStrat(*this, mCurrentViewCell); 
    444  
    445         GenerateRays(numRandomRays, vcStrat, simpleRays); 
     438 
     439        GenerateRays(numRandomRays, *mDistribution, simpleRays); 
    446440 
    447441 
     
    607601 
    608602 
    609 int GvsPreprocessor::CastInitialSamples(const int numSamples,  
    610                                                                                 const int sampleType) 
     603int GvsPreprocessor::CastInitialSamples(int numSamples) 
    611604{        
    612605        const long startTime = GetTime(); 
     
    615608        SimpleRayContainer simpleRays; 
    616609         
    617         ViewCellBasedDistribution vcStrat(*this, mCurrentViewCell); 
    618     GenerateRays(numSamples, vcStrat, simpleRays); 
     610        ViewCellBorderBasedDistribution vcStrat(*this, mCurrentViewCell); 
     611    GenerateRays(numSamples, *mDistribution, simpleRays); 
    619612 
    620613        //cout << "sr: " << simpleRays.size() << endl; 
     
    880873} 
    881874 
    882 #if 1 
     875 
    883876void GvsPreprocessor::IntersectWithViewCell() 
    884877{ 
    885         mCurrentViewCell->GetMesh()->ComputeBoundingBox(); 
    886         AxisAlignedBox3 box = mCurrentViewCell->GetMesh()->mBox; 
    887          
     878        AxisAlignedBox3 box = mCurrentViewCell->GetBox(); 
     879 
     880        int oldTrianglePvs = (int)mTrianglePvs.size(); 
     881        int newKdObj = 0; 
     882 
     883        // compute pvs kd nodes that intersect view cell 
    888884        ObjectContainer kdobjects; 
     885 
     886        // find intersecting objects not in pvs (i.e., only unmailed) 
    889887        mKdTree->CollectKdObjects(box, kdobjects); 
    890888 
     889        ObjectContainer pvsKdObjects; 
     890 
    891891        ObjectContainer::const_iterator oit, oit_end = kdobjects.end(); 
    892892 
    893893        for (oit = kdobjects.begin(); oit != oit_end; ++ oit) 
    894894        { 
    895         // add to kdnode pvs 
    896                 KdIntersectable *kdInt = static_cast<KdIntersectable *>(*oit); 
    897                  
    898                 mCurrentViewCell->GetPvs().AddSampleDirtyCheck(kdInt, 1.0f); 
    899                 //if (SHOW_QT_VISUALIZATION) mViewCellsManager->UpdateStatsForViewCell(mCurrentViewCell, kdInt); 
    900  
     895        KdIntersectable *kdInt = static_cast<KdIntersectable *>(*oit); 
     896         
    901897                myobjects.clear(); 
    902                 mKdTree->CollectObjects(kdInt->GetItem(), myobjects); 
     898                mKdTree->CollectObjectsWithDublicates(kdInt->GetItem(), myobjects); 
    903899 
    904900                // account for kd object pvs 
     901                bool addkdobj = false; 
     902 
    905903                ObjectContainer::const_iterator oit, oit_end = myobjects.end(); 
    906904 
     
    908906                { 
    909907                        TriangleIntersectable *triObj = static_cast<TriangleIntersectable *>(*oit); 
    910              
    911                         CountObject(triObj); 
    912              
    913                         // the triangle itself intersects 
     908              
     909                        // test if the triangle itself intersects 
    914910                        if (box.Intersects(triObj->GetItem())) 
    915                         { 
    916                                 if ((triObj->mCounter < ACCOUNTED_OBJECT)) 
    917                                 { 
    918                                         triObj->mCounter += ACCOUNTED_OBJECT; 
    919  
    920                                         mTrianglePvs.push_back(triObj); 
    921                                         mGenericStats = (int)mTrianglePvs.size(); 
    922                                 } 
    923                         }                        
    924                 } 
    925         } 
    926         cout << "added " << mTrianglePvs.size() << " triangles (" << mCurrentViewCell->GetPvs().GetSize() << " objects) by intersection" << endl; 
    927  
    928 } 
    929  
    930 #else 
    931  
    932 void GvsPreprocessor::IntersectWithViewCell() 
    933 { 
    934         //Intersectable::NewMail(); 
    935         mCurrentViewCell->GetMesh()->ComputeBoundingBox(); 
    936         AxisAlignedBox3 box = mCurrentViewCell->GetMesh()->mBox; 
    937  
    938         // compute pvs kd nodes that intersect view cell 
    939         ObjectContainer kdobjects; 
    940         mKdTree->CollectKdObjects(box, kdobjects); 
    941  
    942         ObjectContainer pvsKdObjects; 
    943  
    944         ObjectContainer::const_iterator oit, oit_end = kdobjects.end(); 
    945  
    946         for (oit = kdobjects.begin(); oit != oit_end; ++ oit) 
    947         { 
    948         KdIntersectable *kdInt = static_cast<KdIntersectable *>(*oit); 
    949          
    950                 myobjects.clear(); 
    951                 mKdTree->CollectObjects(kdInt->GetItem(), myobjects); 
    952  
    953                 // account for kd object pvs 
    954                 bool addkdobj = false; 
    955  
    956                 ObjectContainer::const_iterator oit, oit_end = myobjects.end(); 
    957  
    958                 for (oit = myobjects.begin(); oit != oit_end; ++ oit) 
    959                 { 
    960                         TriangleIntersectable *triObj = static_cast<TriangleIntersectable *>(*oit); 
    961                         // the triangle itself intersects => add object 
    962                         if (box.Intersects(triObj->GetItem())) 
    963                         { 
    964                                 if ((triObj->mCounter < ACCOUNTED_OBJECT)) 
    965                                 { 
    966                                         triObj->mCounter += ACCOUNTED_OBJECT; 
    967  
    968                                         mTrianglePvs.push_back(triObj); 
    969                                         mGenericStats = (int)mTrianglePvs.size(); 
    970  
    971                                         addkdobj = true; 
    972                                 } 
    973                         } 
     911                                addkdobj = AddTriangleObject(triObj); 
    974912                } 
    975913                 
    976                 // add node to object pvs 
    977                 if (addkdobj) 
    978                         pvsKdObjects.push_back(kdInt); 
    979         } 
    980  
    981         // new mail because objects were mailed for kd tree search 
    982         KdNode::NewMail(); 
    983  
    984         // now actually ADD new objects to object pvs 
    985         oit_end = pvsKdObjects.end(); 
    986  
    987         for (oit = pvsKdObjects.begin(); oit != oit_end; ++ oit) 
    988         { 
    989         KdIntersectable *kdInt = static_cast<KdIntersectable *>(*oit); 
    990          
    991                 kdInt->Mail(); 
    992  
    993                 mCurrentViewCell->GetPvs().AddSampleDirty(kdInt, 1.0f); 
    994                 if (SHOW_QT_VISUALIZATION) UpdateStatsForVisualization(kdInt);   
    995         } 
    996  
    997         cout << "added " << mTrianglePvs.size() << " triangles (" << (int)pvsKdObjects.size() << " objects) by intersection" << endl; 
    998 } 
    999 #endif 
     914                // add node to kd pvs 
     915                if (1 && addkdobj) 
     916                { 
     917                        ++ newKdObj; 
     918                        mCurrentViewCell->GetPvs().AddSampleDirty(kdInt, 1.0f); 
     919                        //mCurrentViewCell->GetPvs().AddSampleDirtyCheck(kdInt, 1.0f); 
     920                        if (SHOW_QT_VISUALIZATION) UpdateStatsForVisualization(kdInt); 
     921                } 
     922        } 
     923 
     924        cout << "added " << (int)mTrianglePvs.size() - oldTrianglePvs << " triangles (" << newKdObj << " objects) by intersection" << endl; 
     925} 
     926 
    1000927 
    1001928void GvsPreprocessor::PerViewCellComputation() 
     
    1009936                        (*oit)->mCounter = NOT_ACCOUNTED_OBJECT; 
    1010937 
     938                mDistribution->SetViewCell(mCurrentViewCell); 
    1011939        ComputeViewCell(); 
    1012940        } 
     
    11141042        { 
    11151043                mRayCaster->InitPass(); 
     1044 
    11161045                // Ray queue empty =>  
    11171046                // cast a number of uniform samples to fill ray queue 
    1118                 int newSamples = CastInitialSamples(mInitialSamples, mSamplingType); 
     1047                int newSamples = CastInitialSamples(mInitialSamples); 
    11191048 
    11201049                if (!mOnlyRandomSampling) 
     
    12861215void GvsPreprocessor::ComputeViewCell() 
    12871216{ 
     1217        mCurrentViewCell->GetMesh()->ComputeBoundingBox(); 
     1218 
    12881219        KdNode::NewMail(); 
    12891220 
     
    12931224                << "computing view cell " << mProcessedViewCells  
    12941225                << " (id: " << mCurrentViewCell->GetId() << ")" << endl; 
    1295  
    1296         // compute the pvs of the current view cell 
    1297         // compute object that directly intersect view cell 
    1298         //IntersectWithViewCell(); 
     1226        cout << "bb: " << mCurrentViewCell->GetBox() << endl; 
    12991227 
    13001228        mGvsStats.mPerViewCellSamples = 0; 
     
    13031231        int passSamples = 0; 
    13041232 
    1305         mGenericStats = 0; 
    1306         mGenericStats2 = 0; 
     1233        for (int i = 0; i < 0; ++ i) 
     1234                mGenericStats[i] = 0; 
    13071235 
    13081236        while (1) 
    13091237        { 
    1310                 int oldPvsSize = 0;//mCurrentViewCell->GetPvs().GetSize(); 
     1238                int oldPvsSize = mCurrentViewCell->GetPvs().GetSize(); 
    13111239 
    13121240                mRayCaster->InitPass(); 
     
    13141242                // Ray queue empty =>  
    13151243                // cast a number of uniform samples to fill ray queue 
    1316                 int newSamples = CastInitialSamples(mInitialSamples, mSamplingType); 
     1244                int newSamples = CastInitialSamples(mInitialSamples); 
    13171245 
    13181246                if (!mOnlyRandomSampling) 
     
    13301258                        if (GVS_DEBUG) VisualizeViewCell(mTrianglePvs); 
    13311259 
     1260                        //const bool convertPerPass = true; 
    13321261                        const bool convertPerPass = false; 
    13331262 
     
    13641293        } 
    13651294         
    1366         // finally add objects that directly intersect the view cell 
    1367         //IntersectWithViewCell(); 
     1295        // at last compute objects that directly intersect view cell 
     1296        IntersectWithViewCell(); 
    13681297 
    13691298                 
     
    14071336                mGvsStats.mPvsCost = 0; // todo objectPvs.EvalPvsCost(); 
    14081337        } 
    1409         else 
    1410         { 
     1338        else if (0) 
     1339        { 
     1340                //KdNode::NewMail(); 
     1341 
     1342                // compute pvs kd nodes that intersect view cell 
     1343                ObjectContainer mykdobjects; 
     1344 
     1345                // extract kd pvs 
     1346                ObjectContainer::const_iterator it, it_end = mTrianglePvs.end(); 
     1347 
     1348                for (it = mTrianglePvs.begin(); it != it_end; ++ it) 
     1349                { 
     1350                        Intersectable *obj = *it; 
     1351                        // find intersecting objects not yet in pvs (i.e., only unmailed) 
     1352                        mKdTree->CollectKdObjects(obj->GetBox(), mykdobjects); 
     1353                } 
     1354 
     1355                // add pvs 
     1356                it_end = mykdobjects.end(); 
     1357 
     1358                for (it = mykdobjects.begin(); it != it_end; ++ it) 
     1359                { 
     1360                        mCurrentViewCell->GetPvs().AddSampleDirty(*it, 1.0f); 
     1361                } 
     1362 
     1363                cout << "added " << (int)mykdobjects.size() << " new objects " << endl; 
     1364 
    14111365                mGvsStats.mPerViewCellPvs = mCurrentViewCell->GetPvs().GetSize(); 
    14121366                mGvsStats.mPvsCost = mCurrentViewCell->GetPvs().EvalPvsCost(); 
     
    14711425 
    14721426                mTrianglePvs.push_back(triObj); 
    1473                 mGenericStats = (int)mTrianglePvs.size(); 
     1427                mGenericStats[0] = (int)mTrianglePvs.size(); 
    14741428                return true; 
    14751429        } 
     
    14781432} 
    14791433 
    1480 } 
     1434 
     1435 
     1436} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h

    r2690 r2691  
    1313class TriangleIntersectable; 
    1414class KdIntersectable; 
    15  
     15class ViewCellBasedDistribution; 
    1616 
    1717/** View space partition statistics. 
     
    128128        /** Generates the rays starting the adaptive visibility sampling process. 
    129129        */ 
    130         int CastInitialSamples(const int numSamples, const int sampleType); 
     130        int CastInitialSamples(int numSamples); 
    131131 
    132132        /** Uses the information gained from the ray for doing adaptive border sampling. 
     
    256256 
    257257        RayQueue mRayQueue;  
    258         int mSamplingType; 
     258        ViewCellBasedDistribution *mDistribution; 
    259259 
    260260        //AxisAlignedBox3 mViewSpaceBox; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp

    r2690 r2691  
    10771077      KdInterior *interior = (KdInterior *)node; 
    10781078           
    1079       if ( box.Max()[interior->mAxis] > interior->mPosition ) 
     1079      if ( box.Max()[interior->mAxis] >= interior->mPosition ) 
    10801080        nodeStack.push(interior->mFront); 
    10811081       
    1082       if (box.Min()[interior->mAxis] < interior->mPosition) 
     1082      if (box.Min()[interior->mAxis] <= interior->mPosition) 
    10831083        nodeStack.push(interior->mBack); 
    10841084    } 
     
    11551155 
    11561156 
    1157 void KdTree::CollectObjectsWithDublicates(KdNode *n, ObjectContainer &objects) 
     1157void KdTree::CollectObjectsWithDublicates(KdNode *n, ObjectContainer &objects) const 
    11581158{ 
    11591159        stack<KdNode *> nodeStack; 
     
    17781778} 
    17791779 
     1780 
     1781KdNode * 
     1782KdTree::GetPvsNodeCheck(const Vector3 &point, Intersectable *obj) const 
     1783{ 
     1784  KdNode *node = mRoot; 
     1785   
     1786  while (node->mPvsTermination == 0 ) { 
     1787    KdInterior *inter = (KdInterior *)node; 
     1788    if (point[inter->mAxis] < inter->mPosition) 
     1789      node = inter->mBack; 
     1790    else 
     1791      node = inter->mFront; 
     1792  } 
     1793   
     1794  ObjectContainer objects; 
     1795  CollectObjectsWithDublicates(node, objects); 
     1796 
     1797  ObjectContainer::const_iterator oit, oit_end = objects.end(); 
     1798 
     1799  bool found = false; 
     1800  for (oit = objects.begin(); oit != oit_end; ++ oit) 
     1801  { 
     1802          if ((*oit)->GetId() == obj->GetId()) 
     1803                  found = true; 
     1804  } 
     1805 
     1806  if (!found) return NULL; 
     1807 
     1808  return node; 
     1809} 
     1810 
    17801811KdNode * 
    17811812KdTree::GetNode(const Vector3 &point, 
  • GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h

    r2690 r2691  
    386386  GetPvsNode(const Vector3 &point) const; 
    387387   
     388 KdNode * 
     389  GetPvsNodeCheck(const Vector3 &point, Intersectable *obj) const; 
    388390 
    389391  void 
     
    406408  /** Collects objects with dublicates (no mailing going on) 
    407409  */ 
    408   void CollectObjectsWithDublicates(KdNode *n, ObjectContainer &objects); 
     410  void CollectObjectsWithDublicates(KdNode *n, ObjectContainer &objects) const; 
    409411  void CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects); 
    410412 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.h

    r2614 r2691  
    241241 
    242242        virtual int CastRay(Ray &ray); 
    243         virtual int CastSimpleRay(const SimpleRay &ray) { return 0;} 
    244         virtual int CastSimpleRay(const SimpleRay &ray, int IndexRay) 
    245         { return 0; } 
     243        virtual int CastSimpleRay(const SimpleRay &ray) { return 0;} 
     244        virtual int CastSimpleRay(const SimpleRay &ray, int IndexRay) 
     245        { return 0; } 
    246246 
    247247        virtual bool IsConvex() const { return mMesh->mIsConvex; } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ObjParser.cpp

    r2672 r2691  
    296296                                        for (tit = triangles.begin(); tit != tit_end; ++ tit) 
    297297                                        { 
    298                                           // test if the triangle is valid (i.e., not degenerated) 
    299                                           if (!TriangleValid(*tit)) 
    300                                                   continue; 
    301  
    302                                           TriangleIntersectable *obj = new TriangleIntersectable(*tit);  
    303                                           root->mGeometry.push_back(obj); 
     298                                                // test if the triangle is valid (i.e., not degenerated) 
     299                                                // matt: removed this option so tris can be mapped to intel 
     300                                                if (0 && !TriangleValid(*tit)) 
     301                                                        continue; 
     302                                                 
     303                                                TriangleIntersectable *obj = new TriangleIntersectable(*tit); 
     304                                                root->mGeometry.push_back(obj); 
    304305                                        } 
    305306                                } 
     
    311312        } 
    312313 
    313         //cout << "\n**** " << root->mGeometry.size() << " " << " lines: " << line << endl; 
     314        cout << "\n*********\n***** " << root->mGeometry.size() << " " << " lines: " << line << endl; 
    314315        if (loadMeshes) 
    315316        { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r2687 r2691  
    10161016        case SamplingStrategy::REVERSE_OBJECT_BASED_DISTRIBUTION: 
    10171017                return new ReverseObjectBasedDistribution(*this); 
    1018         case SamplingStrategy::VIEWCELL_BORDER_BASED_DISTRIBUTION: 
    1019                 return new ViewCellBorderBasedDistribution(*this); 
    1020         case SamplingStrategy::VIEWSPACE_BORDER_BASED_DISTRIBUTION: 
    1021                 return new ViewSpaceBorderBasedDistribution(*this); 
     1018        //case SamplingStrategy::VIEWCELL_BORDER_BASED_DISTRIBUTION: 
     1019        //      return new ViewCellBorderBasedDistribution(*this); 
    10221020        case SamplingStrategy::REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION: 
    10231021                return new ReverseViewSpaceBorderBasedDistribution(*this); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h

    r2678 r2691  
    273273        RayCaster *mRayCaster; 
    274274 
    275         int mGenericStats; 
    276         int mGenericStats2; 
     275        int mGenericStats[2]; 
    277276 
    278277        void ScheduleUpdateDynamicObjects(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp

    r2614 r2691  
    296296        Vector3 origin, direction;  
    297297 
    298         ViewCellContainer &viewCells = mPreprocessor.mViewCellsManager->GetViewCells(); 
     298        //ViewCellContainer &viewCells = mPreprocessor.mViewCellsManager->GetViewCells(); 
    299299 
    300300        Vector3 point; 
    301301        Vector3 normal, normal2; 
    302302         
    303         const int vcIdx = (int)RandomValue(0, (float)viewCells.size() - 0.5f); 
     303        //const int vcIdx = (int)RandomValue(0, (float)viewCells.size() - 0.5f); 
    304304        const int objIdx = (int)RandomValue(0, (float)mPreprocessor.mObjects.size() - 0.5f); 
    305305 
    306306        Intersectable *object = mPreprocessor.mObjects[objIdx]; 
    307         ViewCell *viewCell = viewCells[vcIdx]; 
     307        ViewCell *viewCell = mViewCell;//viewCells[vcIdx]; 
    308308 
    309309        object->GetRandomSurfacePoint(point, normal); 
     
    843843        Vector3 origin, direction;  
    844844 
    845         ViewCellContainer &viewCells =  
    846                 mPreprocessor.mViewCellsManager->GetViewCells(); 
    847  
    848845        Vector3 point; 
    849846        Vector3 normal; 
    850847                 
    851         //Vector normalObj; 
    852         // float r[1]; 
    853         // sHalton.GetNext(1, r); 
    854         // const int objIdx = (int)(r[0] * (float)mPreprocessor.mObjects.size() - 1.0f); 
    855         // Intersectable *object = mPreprocessor.mObjects[objIdx]; 
    856         // object->GetRandomSurfacePoint(point, normal); 
    857         // cout << "obj: " << objIdx << endl; 
    858  
    859848        float r[2]; 
     849        //for (int i=0; i < 2; i++) 
     850        // r[i] = RandomValue(0, 1); 
     851 
    860852        sHalton.GetNext(2, r); 
    861853 
     
    869861 
    870862        // get point on view cell surface 
    871         mViewCell->GetRandomSurfacePoint(origin, normal); 
     863        if (0) 
     864        { 
     865                //mViewCell->GetRandomEdgePoint(origin, normal); 
     866                mViewCell->GetRandomSurfacePoint(origin, normal); 
     867 
     868                // move a little bit back to avoid piercing through walls 
     869                // that bound the view cell 
     870                if (0) origin -= 0.01f * normal; 
     871        } 
     872        else 
     873                origin = mViewCell->GetBox().GetUniformRandomSurfacePoint(); 
    872874 
    873875        //direction = point - origin; 
    874  
    875         // move a little bit back to avoid piercing through walls 
    876         // that bound the view cell 
    877         origin -= 0.01f * normal; 
    878876 
    879877        // $$ jb the pdf is yet not correct for all sampling methods! 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.h

    r2575 r2691  
    194194 public: 
    195195         ViewSpaceBorderBasedDistribution(Preprocessor &preprocessor): 
    196            SamplingStrategy(preprocessor){ 
     196           SamplingStrategy(preprocessor) 
     197           { 
    197198           mType = VIEWSPACE_BORDER_BASED_DISTRIBUTION; 
    198199         } 
     
    220221{ 
    221222 public: 
    222   ViewCellBorderBasedDistribution(Preprocessor &preprocessor): 
    223         SamplingStrategy(preprocessor) { 
    224         mType = VIEWCELL_BORDER_BASED_DISTRIBUTION; 
    225  
    226   } 
     223         ViewCellBorderBasedDistribution(Preprocessor &preprocessor, ViewCell *viewCell) 
     224                 : SamplingStrategy(preprocessor), mViewCell(viewCell) 
     225         { 
     226                 mType = VIEWCELL_BORDER_BASED_DISTRIBUTION; 
     227        } 
    227228 
    228229private: 
    229230  virtual bool GenerateSample(SimpleRay &ray); 
     231 
     232  ViewCell *mViewCell; 
    230233}; 
    231234 
     
    268271        } 
    269272 
    270 private: 
    271  
    272   virtual bool GenerateSample(SimpleRay &ray); 
     273        void SetViewCell(ViewCell *vc) { mViewCell = vc; } 
     274 
     275private: 
     276 
     277        virtual bool GenerateSample(SimpleRay &ray); 
    273278 
    274279        ViewCell *mViewCell; 
Note: See TracChangeset for help on using the changeset viewer.