Changeset 1757


Ignore:
Timestamp:
11/15/06 14:56:00 (18 years ago)
Author:
bittner
Message:

pvs updates

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

Legend:

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

    r1749 r1757  
    24242424 
    24252425 
    2426 void BvHierarchy::CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects) 
     2426void BvHierarchy::CollectObjects(const AxisAlignedBox3 &box, 
     2427                                                                 ObjectContainer &objects) 
    24272428{ 
    24282429  stack<BvhNode *> nodeStack; 
     
    24302431  nodeStack.push(mRoot); 
    24312432 
    2432   while (!nodeStack.empty())  
    2433         { 
    2434           BvhNode *node = nodeStack.top(); 
     2433  while (!nodeStack.empty()) { 
     2434        BvhNode *node = nodeStack.top(); 
     2435         
     2436        nodeStack.pop(); 
     2437         
     2438        if (node->IsLeaf()) { 
     2439          BvhLeaf *leaf = (BvhLeaf *)node; 
     2440          if (Overlap(box, leaf->GetBoundingBox())) { 
     2441                Intersectable *object = GetOrCreateBvhIntersectable(leaf); 
     2442                if (!object->Mailed()) { 
     2443                  object->Mail(); 
     2444                  objects.push_back(object); 
     2445                } 
     2446          } 
     2447        }  
     2448        else  { 
     2449          BvhInterior *interior = (BvhInterior *)node; 
    24352450           
    2436           nodeStack.pop(); 
     2451          if (Overlap(box, interior->GetBoundingBox())) 
     2452                nodeStack.push(interior->GetFront()); 
    24372453           
    2438           if (node->IsLeaf())  
    2439                 { 
    2440                   BvhLeaf *leaf = (BvhLeaf *)node; 
    2441                   if (Overlap(box, leaf->GetBoundingBox())) { 
    2442                         Intersectable *object = GetOrCreateBvhIntersectable(leaf); 
    2443                         if (!object->Mailed()) { 
    2444                           object->Mail(); 
    2445                           objects.push_back(object); 
    2446                         } 
    2447                   } 
    2448                 }  
    2449           else  
    2450                 { 
    2451                   BvhInterior *interior = (BvhInterior *)node; 
    2452                    
    2453                   if (Overlap(box, interior->GetBoundingBox())) 
    2454                         nodeStack.push(interior->GetFront()); 
    2455                    
    2456                   if (Overlap(box, interior->GetBoundingBox())) 
    2457                         nodeStack.push(interior->GetBack()); 
    2458                 } 
    2459         } 
    2460 } 
    2461  
    2462 } 
     2454          if (Overlap(box, interior->GetBoundingBox())) 
     2455                nodeStack.push(interior->GetBack()); 
     2456        } 
     2457  } 
     2458} 
     2459 
     2460} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r1756 r1757  
    17321732        RegisterOption("Preprocessor.useGlRenderer", 
    17331733                                        optBool, 
    1734                                         "preprocessor_use_gl_renderer=", 
     1734                                        "preprocessor_use_gl_renderer", 
    17351735                                        "false"); 
    17361736 
    17371737        RegisterOption("Preprocessor.useGlDebugger", 
    17381738                                        optBool, 
    1739                                         "preprocessor_use_gl_debugger=", 
     1739                                        "preprocessor_use_gl_debugger", 
    17401740                                        "false"); 
    17411741 
     
    26252625    strcpy(filename, "default.env"); 
    26262626  } 
     2627 
    26272628   
    26282629  if (useExePath) { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp

    r1533 r1757  
    66#include "ArchModeler2MLRT.hxx" 
    77 
    8 #define DEBUG_RAYCAST 0 
     8#define DEBUG_RAYCAST 0  
    99 
    1010 
     
    131131 
    132132        for (i=0; i < num; i++) { 
    133                 mlrtaStoreRayAS16(&rays[index + i].mOrigin.x, 
    134                         &rays[index + i].mDirection.x, 
    135                         i); 
    136         } 
     133          mlrtaStoreRayAS16(&rays[index + i].mOrigin.x, 
     134                                                &rays[index + i].mDirection.x, 
     135                                                i); 
     136        } 
     137 
     138#if DEBUG_RAYCAST 
     139                Debug<<"TA\n"<<flush; 
     140#endif 
    137141 
    138142        mlrtaTraverseGroupAS16(&min.x, 
    139                 &max.x, 
    140                 forward_hit_triangles, 
    141                 forward_dist); 
    142  
     143                                                   &max.x, 
     144                                                   forward_hit_triangles, 
     145                                                   forward_dist); 
     146         
    143147        if (castDoubleRay) 
    144         { 
     148          { 
    145149                for (i=0; i < num; i++)  
    146                 { 
     150                  { 
    147151                        Vector3 dir = -rays[index + i].mDirection; 
    148152                        mlrtaStoreRayAS16(&rays[index+i].mOrigin.x, 
    149                                 &dir.x, 
    150                                 i); 
    151                 } 
     153                                                          &dir.x, 
     154                                                          i); 
     155                  } 
     156 
     157#if DEBUG_RAYCAST 
     158                Debug<<"TB\n"<<flush; 
     159#endif 
    152160 
    153161                mlrtaTraverseGroupAS16(&min.x, 
    154                         &max.x, 
    155                         backward_hit_triangles, 
    156                         backward_dist); 
    157         } 
     162                                                           &max.x, 
     163                                                           backward_hit_triangles, 
     164                                                           backward_dist); 
     165          } 
     166 
     167#if DEBUG_RAYCAST 
     168        Debug<<"BBB\n"<<flush; 
     169#endif 
    158170 
    159171        for (i=0; i < num; i++)  
    160         { 
     172          { 
    161173                Intersection hitA(rays[i].mOrigin), hitB(rays[i].mOrigin); 
     174 
     175#if DEBUG_RAYCAST 
     176          Debug<<"FH\n"<<flush; 
     177#endif 
    162178                 
    163179                if (forward_hit_triangles[i] != -1 ) { 
    164                         if (forward_hit_triangles[i] >= mPreprocessor.mFaceParents.size()) 
    165                                 cerr<<"Warning: triangle index out of range! "<<forward_hit_triangles[i]<<endl; 
    166                         else {  
    167                                 hitA.mObject = mPreprocessor.mFaceParents[forward_hit_triangles[i]].mObject; 
    168                                 // Get the normal of that face 
    169                                 hitA.mNormal = hitA.mObject->GetNormal(mPreprocessor.mFaceParents[forward_hit_triangles[i]].mFaceIndex); 
    170                                 //-rays[index+i].mDirection; // $$ temporary 
    171                                 hitA.mPoint = rays[index+i].Extrap(forward_dist[i]); 
     180                  if (forward_hit_triangles[i] >= mPreprocessor.mFaceParents.size()) 
     181                        cerr<<"Warning: triangle index out of range! "<<forward_hit_triangles[i]<<endl; 
     182                  else {  
     183                        hitA.mObject = mPreprocessor.mFaceParents[forward_hit_triangles[i]].mObject; 
     184                        // Get the normal of that face 
     185                        hitA.mNormal = hitA.mObject->GetNormal(mPreprocessor.mFaceParents[forward_hit_triangles[i]].mFaceIndex); 
     186                        //-rays[index+i].mDirection; // $$ temporary 
     187                        hitA.mPoint = rays[index+i].Extrap(forward_dist[i]); 
    172188                        } 
     189          } 
     190#if DEBUG_RAYCAST 
     191          Debug<<"BH\n"<<flush; 
     192#endif 
     193           
     194          if (castDoubleRay && (backward_hit_triangles[i] != -1)) { 
     195                if (backward_hit_triangles[i] >= mPreprocessor.mFaceParents.size()) 
     196                  cerr<<"Warning: triangle  index out of range! "<<backward_hit_triangles[i]<<endl; 
     197                else {  
     198                  hitB.mObject = mPreprocessor.mFaceParents[backward_hit_triangles[i]].mObject; 
     199                  hitB.mNormal = hitB.mObject->GetNormal(mPreprocessor.mFaceParents[backward_hit_triangles[i]].mFaceIndex); 
     200                   
     201                  // normalB = rays[index+i].mDirection; // $$ temporary 
     202                  hitB.mPoint = rays[index+i].Extrap(-backward_dist[i]); 
    173203                } 
    174  
    175                 if (castDoubleRay && (backward_hit_triangles[i] != -1)) { 
    176                         if (backward_hit_triangles[i] >= mPreprocessor.mFaceParents.size()) 
    177                                 cerr<<"Warning: triangle  index out of range! "<<backward_hit_triangles[i]<<endl; 
    178                         else {  
    179                                 hitB.mObject = mPreprocessor.mFaceParents[backward_hit_triangles[i]].mObject; 
    180                                 hitB.mNormal = hitB.mObject->GetNormal(mPreprocessor.mFaceParents[forward_hit_triangles[i]].mFaceIndex); 
    181  
    182                                 // normalB = rays[index+i].mDirection; // $$ temporary 
    183                                 hitB.mPoint = rays[index+i].Extrap(-backward_dist[i]); 
    184                         } 
    185                 } 
    186  
    187                 ProcessRay( 
    188                         rays[index + i], 
    189                         hitA, 
    190                         hitB, 
    191                         vssRays, 
    192                         sbox, 
    193                         castDoubleRay, 
    194                         pruneInvalidRays 
    195                         ); 
    196         } 
    197  
     204          } 
     205           
     206#if DEBUG_RAYCAST 
     207          Debug<<"PR\n"<<flush; 
     208#endif 
     209           
     210          ProcessRay( 
     211                                 rays[index + i], 
     212                                 hitA, 
     213                                 hitB, 
     214                                 vssRays, 
     215                                 sbox, 
     216                                 castDoubleRay, 
     217                                 pruneInvalidRays 
     218                                 ); 
     219        } 
     220         
    198221#if DEBUG_RAYCAST 
    199222        Debug<<"C16F\n"<<flush; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Makefile

    r1743 r1757  
    11############################################################################# 
    22# Makefile for building: preprocessor 
    3 # Generated by qmake (2.00a) (Qt 4.1.2) on: po 13. XI 15:12:57 2006 
     3# Generated by qmake (2.00a) (Qt 4.1.2) on: Tue Nov 14 23:59:07 2006 
    44# Project:  preprocessor.pro 
    55# Template: app 
     
    6363        $(MAKE) -f $(MAKEFILE).Debug uninstall 
    6464 
    65 Makefile: preprocessor.pro  C:/Qt/4.1.2/mkspecs/win32-msvc.net\qmake.conf C:/Qt/4.1.2/mkspecs/qconfig.pri \ 
     65Makefile: preprocessor.pro  C:/Qt/4.1.2/mkspecs/win32-msvc2005\qmake.conf C:/Qt/4.1.2/mkspecs/qconfig.pri \ 
    6666                C:\Qt\4.1.2\mkspecs\features\qt_config.prf \ 
    6767                C:\Qt\4.1.2\mkspecs\features\exclusive_builds.prf \ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r1749 r1757  
    10591059                                           ) 
    10601060{ 
    1061         const long t1 = GetTime(); 
     1061  const long t1 = GetTime(); 
    10621062 
    10631063        for (int i = 0; i < (int)rays.size();) 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h

    r1751 r1757  
    159159public: 
    160160 
    161         Pvs(): mSamples(0), mEntries() {} 
     161        Pvs(): mSamples(0), mEntries(), mLastSorted(0) {} 
    162162 
    163163        /** creates pvs and initializes it with the given entries.  
     
    205205        */ 
    206206        float AddSample(T sample, const float pdf); 
    207          
     207 
     208  /** Adds sample to PVS without checking for presence of the sample 
     209          pvs remians unsorted! 
     210  */ 
     211  void AddSampleDirty(T sample, const float pdf); 
     212 
     213  /** Sort pvs entries - this should always be called after a 
     214          sequence of AddSampleDirty calls */ 
     215  void Sort(); 
     216   
    208217        /** Adds sample to PVS. Assumes that the pvs is sorted 
    209218                @returns contribution of sample (0 or 1) 
     
    271280        /// Number of samples used to create the PVS 
    272281        int mSamples; 
     282   
     283  /// Last sorted entry in the pvs (important for find and merge 
     284  int mLastSorted; 
     285   
    273286}; 
    274287 
     
    279292        mEntries.reserve(samples.size()); 
    280293        mEntries = samples; 
    281 } 
    282  
     294        mLastSorted = 0; 
     295} 
     296 
     297template <typename T, typename S> 
     298void Pvs<T, S>::Sort() 
     299{ 
     300  std::vector<PvsEntry<T, S> >::iterator it = mEntries.begin(); 
     301  it.inc(mLastSorted); 
     302  sort(it, mEntries.end()); 
     303  mLastSorted = mEntries.size() - 1; 
     304} 
    283305 
    284306/** 
     
    500522 
    501523template <typename T, typename S> 
     524void Pvs<T, S>::AddSampleDirty(T sample, const float pdf) 
     525{ 
     526  ++ mSamples; 
     527  mEntries.push_back(PvsEntry<T, S>(sample, pdf)); 
     528} 
     529                                          
     530 
     531template <typename T, typename S> 
    502532typename vector< PvsEntry<T, S> >::iterator Pvs<T, S>::AddSample2(T sample, const float pdf) 
    503533{ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtGlRenderer.cpp

    r1743 r1757  
    1515#include "QtPreprocessorThread.h" 
    1616 
    17  
     17#define USE_CG 1 
     18 
     19#ifdef USE_CG 
    1820#include <Cg/cg.h> 
    1921#include <Cg/cgGL.h> 
     22#endif 
    2023 
    2124#include <QVBoxLayout> 
     
    4851} 
    4952 
    50  
     53#if USE_CG 
    5154static void handleCgError()  
    5255{ 
     
    5457    exit(1); 
    5558} 
     59#endif 
    5660 
    5761void 
     
    150154QtGlRendererBuffer::~QtGlRendererBuffer() 
    151155{ 
    152         if (sCgFragmentProgram) 
     156#if USE_CG 
     157  if (sCgFragmentProgram) 
    153158                cgDestroyProgram(sCgFragmentProgram); 
    154159        if (sCgContext) 
    155160                cgDestroyContext(sCgContext); 
     161#endif 
    156162} 
    157163 
     
    604610        glEnable(GL_TEXTURE_2D); 
    605611         
     612#if USE_CG 
    606613        // bind pixel shader implementing the front depth buffer functionality 
    607614        cgGLBindProgram(sCgFragmentProgram); 
    608615        cgGLEnableProfile(sCgFragmentProfile); 
    609  
     616#endif 
    610617 
    611618        // 5. render all objects inside the beam  
     
    752759        glEnable(GL_CULL_FACE); 
    753760        glDisable(GL_STENCIL_TEST); 
     761#if USE_CG 
    754762        cgGLDisableProfile(sCgFragmentProfile); 
     763#endif 
    755764        glDisable(GL_TEXTURE_2D); 
    756765 
     
    822831        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); 
    823832 
     833#if USE_CG 
    824834        // cg initialization 
    825835        cgSetErrorCallback(handleCgError); 
     
    840850  } 
    841851 
    842  
    843852 sCgFragmentProgram = cgCreateProgramFromFile(sCgContext, 
    844853                                                                                           CG_SOURCE, "../src/dual_depth.cg", 
     
    855864  Debug << "---- PROGRAM BEGIN ----\n" << 
    856865          cgGetProgramString(sCgFragmentProgram, CG_COMPILED_PROGRAM) << "---- PROGRAM END ----\n"; 
     866 
     867#endif 
    857868 
    858869#endif 
     
    15701581          } 
    15711582 
    1572           for (int i=0;  pow(10, i) < maxCost; i+=1) { 
     1583          for (int i=0;  pow(10.0f, i) < maxCost; i+=1) { 
    15731584                float y = i*scaley; 
    15741585                //              QString s; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtGlRenderer.h

    r1743 r1757  
    174174struct PvsCache { 
    175175  PvsCache():mViewCell(NULL) {} 
    176   Reset() { mViewCell = NULL; mPvs.Clear(); } 
     176  void Reset() { mViewCell = NULL; mPvs.Clear(); } 
    177177  ViewCell *mViewCell; 
    178178  ObjectPvs mPvs; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp

    r1584 r1757  
    8888 
    8989#if DEBUG_RAYCAST 
    90         Debug<<"PR "; 
     90        Debug<<"PRA"<<flush; 
    9191#endif 
    9292         
     
    101101        const bool validA =  
    102102          ValidateRay(simpleRay.mOrigin, simpleRay.mDirection, box, hitA); 
     103 
     104#if DEBUG_RAYCAST 
     105        Debug<<"PR1"<<flush; 
     106#endif 
    103107         
    104108        if (!validA && pruneInvalidRays) 
     
    116120 
    117121        const bool validSample = !pruneInvalidRays || (hitA.mObject != hitB.mObject); 
    118          
     122 
     123#if DEBUG_RAYCAST 
     124        Debug<<"PR2"<<flush; 
     125#endif 
     126 
    119127        if (validSample)  
    120128        { 
     
    134142                  //cout << "vssray 1: " << *vssRay << " " << vssRay->mTermination - vssRay->mOrigin << endl; 
    135143                } 
    136            
     144 
     145#if DEBUG_RAYCAST 
     146        Debug<<"PR3"<<flush; 
     147#endif 
     148 
    137149          if (castDoubleRay && (!pruneInvalidRays || hitB.mObject)) 
    138150                { 
     
    151163                } 
    152164        } 
    153          
     165 
     166#if DEBUG_RAYCAST 
     167        Debug<<"PR4"<<flush; 
     168#endif 
     169 
    154170        return hits; 
    155171} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RssTree.cpp

    r1715 r1757  
    22722272  float density = 1.0f; 
    22732273  float p = 1.0f/density; //(box.GetVolume()*dirBox.GetVolume())/i; 
    2274   for (i=startIndex; i < rays.size(); i++) { 
     2274  for (int i=startIndex; i < rays.size(); i++) { 
    22752275        rays[i].mPdf = p; 
    22762276  } 
     
    24612461 
    24622462  float p = 1.0f/density; //(box.GetVolume()*dirBox.GetVolume())/i; 
    2463   for (i=startIndex; i < rays.size(); i++) { 
     2463  for (int i=startIndex; i < rays.size(); i++) { 
    24642464        rays[i].mPdf = p; 
    24652465  } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SamplingPreprocessor.cpp

    r1749 r1757  
    126126                 
    127127          for (int j=0; j < vssRays.size(); j++) { 
    128                 Intersectable *obj = mViewCellsManager->GetIntersectable(*(vssRays[j]), true); 
     128                Intersectable *obj = mViewCellsManager->GetIntersectable(*(vssRays[j]), 
     129                                                                                                                                 true); 
    129130                if (obj) { 
    130131                  // if ray not outside of view space 
     
    148149        } 
    149150 
     151#if 0 
    150152        Debug<<"Valid viewcells before set validity: "<<mViewCellsManager->CountValidViewcells()<<endl; 
    151153        mViewCellsManager->SetValidity(0, intersectables/2); 
    152154        Debug<<"Valid viewcells after set validity: "<<mViewCellsManager->CountValidViewcells()<<endl; 
    153  
     155#endif 
     156         
    154157        //      mVssRays.PrintStatistics(mStats); 
    155158        mStats << 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1756 r1757  
    18351835          stat.avgPvs += pvsCost; 
    18361836 
    1837           if (0) { 
     1837          const bool evaluateFilter = true; 
     1838           
     1839          if (evaluateFilter) { 
    18381840                ObjectPvs filteredPvs = viewcell->GetPvs(); 
    18391841                ApplyFilter2(viewcell, false, 1.0f, filteredPvs); 
     
    18411843                stat.avgFilteredPvs += filteredCost; 
    18421844                stat.avgFilterContribution += filteredCost - pvsCost; 
     1845          } else { 
     1846                stat.avgFilteredPvs += pvsCost; 
     1847                stat.avgFilterContribution += 0; 
    18431848          } 
    18441849           
     
    25942599  AxisAlignedBox3 vbox = GetViewCellBox(viewCell); 
    25952600  Vector3 center = vbox.Center(); 
    2596   // first determine the average size of the filter 
    2597  
    2598   pvs = viewCell->GetPvs(); 
     2601   
     2602  // COpy the PVS 
     2603  ObjectPvs basePvs = viewCell->GetPvs(); 
    25992604  Intersectable::NewMail(); 
    2600    
    2601   ObjectPvsIterator pit = pvs.GetIterator(); 
     2605 
     2606  ObjectPvsIterator pit = basePvs.GetIterator(); 
    26022607 
    26032608  // first mark all object from this pvs 
    2604   while (pit.HasMoreEntries()) 
    2605   {              
    2606           ObjectPvsEntry entry = pit.Next(); 
    2607  
    2608           Intersectable *object = entry.mObject; 
    2609           object->Mail(); 
     2609  while (pit.HasMoreEntries()) {                 
     2610        ObjectPvsEntry entry = pit.Next(); 
     2611         
     2612        Intersectable *object = entry.mObject; 
     2613        object->Mail(); 
    26102614  } 
    26112615 
    2612   ObjectPvs nPvs; 
     2616 
    26132617  int pvsSize = 0; 
    26142618  int nPvsSize = 0; 
    26152619  float samples = (float)pvs.GetSamples(); 
    2616   cout<<"Samples = "<<samples<<endl; 
    2617    cout<<"pvs size = "<<pvs.GetSize() <<endl; 
     2620 
     2621  //  cout<<"#s"<<samples<<endl; 
     2622  //  cout<<"pvs size = "<<pvs.GetSize() <<endl; 
    26182623  //  cout<<"Filter size = "<<filterSize<<endl; 
    26192624  //  cout<<"vbox = "<<vbox<<endl; 
     
    26212626 
    26222627 
     2628   // Minimal number of local samples to take into account 
     2629   // the local sampling density. 
     2630   // The size of the filter is a minimum of the conservative 
     2631   // local sampling density estimate (#rays intersecting teh viewcell and 
     2632   // the object) 
     2633   // and gobal estimate for the view cell 
     2634   // (total #rays intersecting the viewcell) 
    26232635#define MIN_LOCAL_SAMPLES 5 
    26242636 
    2625   // compute the average filter radius 
    26262637  float globalC = 2.0f*filterSize/sqrt(samples); 
    2627  
    2628   float sumRadius = 0.0f; 
    2629  
    2630   ObjectPvsIterator pit2 = pvs.GetIterator(); 
    2631  
    2632   // first mark all object from this pvs 
    2633    for (; pit2.HasMoreEntries(); pvsSize++) { 
    2634   ObjectPvsEntry entry = pit2.Next(); 
    2635         Intersectable *object = entry.mObject; 
    2636         // compute filter size based on the distance and the numebr of samples 
    2637         AxisAlignedBox3 box = object->GetBox(); 
    2638  
    2639         float distance = Distance(center, box.Center()); 
    2640         float globalRadius = distance*globalC; 
    2641  
    2642         int objectSamples = (int)entry.mData.mSumPdf; 
    2643         float localRadius = MAX_FLOAT; 
    2644          
    2645         if (objectSamples > MIN_LOCAL_SAMPLES) 
    2646           localRadius = 0.5f*Magnitude(box.Diagonal())/sqrt((float)objectSamples); 
    2647          
    2648         // now compute the filter size 
    2649         float radius = Min(localRadius, globalRadius); 
    2650          
    2651         sumRadius +=radius; 
    2652   } 
    2653    
    2654   float avgRadius = sumRadius/pvsSize; 
    26552638  float viewCellRadius = 0.5f*Magnitude(vbox.Diagonal()); 
    2656   cout<<"radius ratio = "<<avgRadius/viewCellRadius<<endl; 
    26572639   
    26582640  // now compute the filter box around the current viewCell 
    2659  
     2641   
    26602642  if (useViewSpaceFilter) { 
    26612643        //      float radius = Max(viewCellRadius/100.0f, avgRadius - viewCellRadius); 
     
    26662648        ComputeBoxIntersections(vbox, viewCells); 
    26672649         
    2668         //  cout<<"box="<<box<<endl; 
    2669         ViewCellContainer::const_iterator it = viewCells.begin(), it_end = viewCells.end(); 
    2670          
    2671         int i; 
     2650        ViewCellContainer::const_iterator it = viewCells.begin(), 
     2651          it_end = viewCells.end(); 
     2652        int i = 0; 
    26722653        for (i=0; it != it_end; ++ it, ++ i) 
    26732654          if ((*it) != viewCell) { 
    26742655                //cout<<"v"<<i<<" pvs="<<(*it)->GetPvs().mEntries.size()<<endl; 
    2675                   pvs.MergeInPlace((*it)->GetPvs()); 
     2656                basePvs.MergeInPlace((*it)->GetPvs()); 
    26762657          } 
    2677  
     2658         
    26782659        // update samples and globalC 
    26792660        samples = (float)pvs.GetSamples(); 
    26802661        globalC = 2.0f*filterSize/sqrt(samples); 
    2681         cout<<"neighboring viewcells = "<<i-1<<endl; 
    2682         cout<<"Samples' = "<<samples<<endl; 
     2662        //      cout<<"neighboring viewcells = "<<i-1<<endl; 
     2663        //      cout<<"Samples' = "<<samples<<endl; 
    26832664  } 
    26842665   
    2685   pit = pvs.GetIterator(); 
    2686  
    2687   // first mark all object from this pvs 
     2666  pit = basePvs.GetIterator(); 
     2667 
     2668  ObjectContainer objects; 
     2669 
    26882670  while (pit.HasMoreEntries()) 
    26892671  {              
    2690           ObjectPvsEntry entry = pit.Next(); 
    2691  
    2692           Intersectable *object = entry.mObject; 
    2693           // compute filter size based on the distance and the numebr of samples 
    2694           AxisAlignedBox3 box = object->GetBox(); 
    2695  
    2696           float distance = Distance(center, box.Center()); 
    2697           float globalRadius = distance*globalC; 
    2698  
    2699           int objectSamples = (int)entry.mData.mSumPdf; 
    2700           float localRadius = MAX_FLOAT; 
    2701           if (objectSamples > MIN_LOCAL_SAMPLES) 
    2702                   localRadius = filterSize*0.5f*Magnitude(box.Diagonal())/sqrt((float)objectSamples); 
    2703  
    2704           //    cout<<"lr="<<localRadius<<" gr="<<globalRadius<<endl; 
    2705  
    2706           // now compute the filter size 
    2707           float radius = Min(localRadius, globalRadius); 
    2708  
    2709           // cout<<"box = "<<box<<endl; 
    2710           //    cout<<"distance = "<<distance<<endl; 
    2711           //    cout<<"radiues = "<<radius<<endl; 
    2712  
    2713           box.Enlarge(Vector3(radius)); 
    2714  
    2715            
    2716           ObjectContainer objects; 
    2717           // $$ warning collect objects takes only unmailed ones! 
    2718           CollectObjects(box, objects); 
    2719           //    cout<<"collected objects="<<objects.size()<<endl; 
    2720           ObjectContainer::const_iterator noi = objects.begin(); 
    2721           for (; noi != objects.end(); ++ noi) { 
    2722                 Intersectable *o = *noi; 
    2723                 // $$ JB warning: pdfs are not correct at this point!      
    2724                 nPvs.AddSample(o, Limits::Small); 
    2725                 nPvsSize ++; 
    2726           } 
     2672        ObjectPvsEntry entry = pit.Next(); 
     2673 
     2674        Intersectable *object = entry.mObject; 
     2675        // compute filter size based on the distance and the numebr of samples 
     2676        AxisAlignedBox3 box = object->GetBox(); 
     2677         
     2678        float distance = Distance(center, box.Center()); 
     2679        float globalRadius = distance*globalC; 
     2680         
     2681        int objectSamples = (int)entry.mData.mSumPdf; 
     2682        float localRadius = MAX_FLOAT; 
     2683        if (objectSamples > MIN_LOCAL_SAMPLES) 
     2684          localRadius = filterSize*0.5f*Magnitude(box.Diagonal())/ 
     2685                sqrt((float)objectSamples); 
     2686         
     2687        //      cout<<"lr="<<localRadius<<" gr="<<globalRadius<<endl; 
     2688         
     2689        // now compute the filter size 
     2690        float radius = Min(localRadius, globalRadius); 
     2691         
     2692        // cout<<"box = "<<box<<endl; 
     2693        //      cout<<"distance = "<<distance<<endl; 
     2694        //      cout<<"radiues = "<<radius<<endl; 
     2695         
     2696        box.Enlarge(Vector3(radius)); 
     2697         
     2698        objects.clear(); 
     2699        // $$ warning collect objects takes only unmailed ones! 
     2700        CollectObjects(box, objects); 
     2701        //      cout<<"collected objects="<<objects.size()<<endl; 
     2702        ObjectContainer::const_iterator noi = objects.begin(); 
     2703        for (; noi != objects.end(); ++ noi) { 
     2704          Intersectable *o = *noi; 
     2705          // $$ JB warning: pdfs are not correct at this point!    
     2706          pvs.AddSampleDirty(o, Limits::Small); 
     2707        } 
    27272708  } 
    2728   cout<<"nPvs size = "<<nPvsSize<<endl; 
    2729    
    2730   pvs.MergeInPlace(nPvs); 
     2709 
     2710  //  cout<<"nPvs size = "<<pvs.GetSize()<<endl; 
     2711 
     2712  // copy the base pvs to the new pvs 
     2713  pit = basePvs.GetIterator(); 
     2714  while (pit.HasMoreEntries()) {                 
     2715        ObjectPvsEntry entry = pit.Next(); 
     2716        pvs.AddSampleDirty(entry.mObject, entry.mData.mSumPdf); 
     2717  } 
    27312718   
    27322719  Intersectable::NewMail(); 
     
    39083895                        exporter->ExportKdTree(*mKdTree); 
    39093896 
    3910                         for (i = 0; i < pvsOut; i++) 
     3897                        for (int i = 0; i < pvsOut; i++) 
    39113898                                exporter->ExportRays(rays[i], RgbColor(1, 0, 0)); 
    39123899 
     
    39183905                { 
    39193906                        Intersectable *object = objects[k]; 
    3920                         char str[64]; sprintf(str, "viewcell%04d.wrl", i); 
     3907                        char str[64]; sprintf(str, "viewcell%04d.wrl", k); 
    39213908 
    39223909                        Exporter *exporter = Exporter::GetExporter(str); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/common.h

    r1717 r1757  
    5454#else // __WATCOMC__ 
    5555#define M_PI        3.14159265358979323846 
    56 #define MAXFLOAT    3.40282347e+38F 
     56#define MAXFLOAT    3.40282347e+37F 
    5757#endif // __WATCOMC__ 
    5858 
  • GTP/trunk/Lib/Vis/Preprocessing/src/default.env

    r1743 r1757  
    7575 
    7676SamplingPreprocessor { 
    77         totalSamples 100000000 
    78         samplesPerPass 1000000 
     77        totalSamples 50000000 
     78        samplesPerPass 3000000 
    7979} 
    8080 
     
    8282        samplesPerPass 1000 
    8383        initialSamples 2000000 
    84         vssSamples 100000000 
     84        vssSamples 50000000 
    8585#       vssSamples 1000000 
    8686        vssSamplesPerPass 3000000 
     
    289289#       filename ../data/vienna/vsposp-seq-viewCells.xml.gz 
    290290 
    291         filename ../data/vienna/vienna_cropped-gradient-2-viewcells.xml.gz 
     291        filename ../data/vienna/vienna_cropped-gradient-viewcells.xml.gz 
    292292 
    293293#       filename ../data/vienna/vienna_cropped-2-sequential-30000-viewcells.xml.gz 
  • GTP/trunk/Lib/Vis/Preprocessing/src/preprocessor.pro

    r1715 r1757  
    1 CONFIG -= qt debug 
    2 CONFIG  += console warn_off thread release mlrt qt 
     1CONFIG += qt release 
     2CONFIG += console warn_off thread mlrt qt 
    33 
    44TEMPLATE = app 
    5  
    65 
    76TARGET = preprocessor 
     
    2019 
    2120CONFIG(qt) { 
    22 win32:INCLUDEPATH += "d:/Programs/NVIDIA Corporation/Cg/include" 
     21win32:INCLUDEPATH += "c:/Program Files/NVIDIA Corporation/Cg/include" 
    2322} 
    2423 
     
    3231 
    3332CONFIG(qt) { 
    34 win32:LIBPATH += "d:/Programs/NVIDIA Corporation/Cg/lib" 
    35 CONFIG(debug) { 
    36 LIBPATH += QtRenderer/debug 
    37 } 
    38  
    39 CONFIG(release) { 
    40 LIBPATH += QtRenderer/release 
    41 } 
     33win32:LIBPATH += "c:/Program Files/NVIDIA Corporation/Cg/lib" 
    4234} 
    4335 
     
    4739 
    4840 
    49 # RELEASE CONFIG 
    50 #CONFIG         += windows warn_on thread release 
    5141 
    5242# DEPENDPATH    = ../../include 
     
    8878CONFIG(qt) { 
    8979win32:LIBS += cg.lib cgGL.lib 
    90 #LIBS += QtRenderer.lib 
    9180DEFINES += USE_QT 
    9281} 
     
    116105OspTree.cpp HierarchyManager.cpp ObjParser.cpp \ 
    117106BvHierarchy.cpp  \ 
    118 BoostPreprocessorThread.cpp InternalRayCaster.cpp IntelRayCaster.cpp \ 
     107InternalRayCaster.cpp IntelRayCaster.cpp \ 
    119108RayCaster.cpp PreprocessorFactory.cpp GvsPreprocessor.cpp \ 
    120109Trackball.cpp ObjExporter.cpp SubdivisionCandidate.cpp 
    121110 
    122111 
     112SOURCES += BoostPreprocessorThread.cpp  
    123113 
    124114CONFIG(qt) { 
    125115HEADERS += QtPreprocessorThread.h QtGlRenderer.h 
    126116SOURCES += OcclusionQuery.cpp QtPreprocessorThread.cpp QtGlRenderer.cpp 
     117} else { 
     118SOURCES += BoostPreprocessorThread.cpp  
    127119} 
    128120 
  • GTP/trunk/Lib/Vis/Preprocessing/src/run_test2

    r1756 r1757  
    22 
    33#COMMAND="./release/preprocessor.exe -preprocessor_quit_on_finish+" 
    4 COMMAND="../scripts/preprocessor.sh -preprocessor_quit_on_finish+" 
     4COMMAND="../scripts/preprocessor.sh -preprocessor_quit_on_finish+ -preprocessor_use_gl_renderer-" 
    55 
    66#SCENE="../data/vienna/vienna-buildings.x3d;../data/vienna/vienna-roofs.x3d;../data/vienna/vienna-roads.x3d" 
     
    2727 
    2828SCENE=../data/vienna/vienna_cropped.obj 
    29 VIEWCELLS=../data/vienna/vienna_cropped-gradient-2-viewcells.xml.gz 
     29VIEWCELLS=../data/vienna/vienna_cropped-gradient-viewcells.xml.gz 
    3030 
    3131PREFIX=../work/plots/osp-rss 
     
    3737#mv stats.log $PREFIX-i-combined-b3.log 
    3838 
    39 # $COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
    40 # -rss_use_importance+ -rss_update_subdivision+ -rss_split=regular \ 
    41 # -view_cells_filter_max_size=1 
     39#$COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
     40#-rss_use_importance+ -rss_update_subdivision+ -rss_split=regular \ 
     41#-view_cells_filter_max_size=1 
    4242  
    43 # mv stats.log $PREFIX-i-combined-update-ccb3.log  
     43#mv stats.log $PREFIX-i-combined-update-ccb3.log  
    4444 
    4545# $COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
     
    5454 
    5555 
    56 # $COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
    57 # -rss_use_importance+ -rss_update_subdivision+ -rss_split=hybrid -hybrid_depth=10 \ 
    58 # -view_cells_filter_max_size=1 
    59 # mv stats.log $PREFIX-i-combined-update-ccb12.log  
     56$COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
     57 -rss_use_importance+ -rss_update_subdivision+ -rss_split=hybrid -hybrid_depth=10 \ 
     58 -view_cells_filter_max_size=1 
     59 mv stats.log $PREFIX-i-combined-update-ccb12.log  
    6060 
    6161 
    6262 
    63 # ####### 
    64 # ####### 
    65 # $COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
    66 # -rss_use_importance- -rss_object_based_sampling- -rss_directional_sampling+ \ 
    67 # -view_cells_filter_max_size=1 
    68 # mv stats.log $PREFIX-r-directional-based-b3.log 
     63####### 
     64####### 
     65$COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
     66-rss_use_importance- -rss_object_based_sampling- -rss_directional_sampling+ \ 
     67-view_cells_filter_max_size=1 
     68mv stats.log $PREFIX-r-directional-based-b3.log 
    6969 
    7070 
    71 # $COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
    72 # -rss_use_importance- -rss_object_based_sampling- -rss_directional_sampling- \ 
    73 # -view_cells_filter_max_size=1 
    74 # mv stats.log $PREFIX-r-spatial-based-bb3.log 
     71$COMMAND -scene_filename=$SCENE -view_cells_filename=$VIEWCELLS \ 
     72-rss_use_importance- -rss_object_based_sampling- -rss_directional_sampling- \ 
     73-view_cells_filter_max_size=1 
     74mv stats.log $PREFIX-r-spatial-based-bb3.log 
    7575 
    7676 
    7777 
    78 #$COMMAND -scene_filename=$SCENE -rss_use_importance- -rss_object_based_sampling- -rss_directional_sampling+ 
    79 #mv stats.log $PREFIX-r-direction-based-b3.log 
     78$COMMAND -scene_filename=$SCENE -rss_use_importance- -rss_object_based_sampling- -rss_directional_sampling+ 
     79mv stats.log $PREFIX-r-direction-based-b3.log 
    8080 
    8181 
Note: See TracChangeset for help on using the changeset viewer.