Changeset 639


Ignore:
Timestamp:
02/14/06 17:13:42 (18 years ago)
Author:
mattausch
Message:
 
Files:
2 deleted
8 edited
7 copied

Legend:

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

    r612 r639  
    1313#;../data/vienna/vienna-plane.x3d 
    1414#       filename ../data/vienna/viewcells-25-sel.x3d 
    15         filename ../data/atlanta/atlanta2.x3d 
     15#       filename ../data/atlanta/atlanta2.x3d 
    1616#       filename ../data/soda/soda.dat 
    17 #       filename ../data/soda/soda5.dat 
     17        filename ../data/soda/soda5.dat 
    1818} 
    1919 
     
    2525        type vss 
    2626#       type rss 
    27         detectEmptyViewSpace true 
     27        detectEmptyViewSpace false 
    2828} 
    2929 
     
    3636        loadInitialSamples  false 
    3737        storeInitialSamples false 
    38         useViewSpaceBox true 
     38        useViewSpaceBox false 
    3939#       testBeamSampling true 
    4040} 
     
    181181 
    182182        #number of active view cells 
    183         active 2096 
     183        active 1024 
    184184        maxStaticMemory 40 
    185185 
     
    288288VspBspTree { 
    289289        Construction { 
    290                 samples 300000 
     290                samples 500000 
    291291                epsilon 0.005 
    292292                randomize false 
     
    331331                missTolerance           6 
    332332                 
    333                 maxViewCells            150000 
     333                maxViewCells            256 
    334334                 
    335335                # used for pvs criterium 
     
    344344        useCostHeuristics false 
    345345        splitUseOnlyDrivingAxis false 
    346          
     346        usePolygonSplitIfAvailable false 
     347 
    347348        Visualization { 
    348349                # x3d visualization of the split planes 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Plane3.cpp

    r256 r639  
    3131  return true; 
    3232} 
     33 
     34 
     35Vector3 Plane3::FindIntersection(const Vector3 &a,                                                  
     36                                                                 const Vector3 &b, 
     37                                                                 float *t, 
     38                                                                 bool *coplanar) const  
     39{ 
     40    const Vector3 v = b - a; // line from A to B 
     41    float dv = DotProd(v, mNormal); 
     42     
     43    if (signum(dv) == 0) 
     44        { 
     45                if (coplanar)  
     46                        (*coplanar) = true;      
     47 
     48                if (t)  
     49                        (*t) = 0; 
     50 
     51                return a; 
     52        } 
     53         
     54        if (coplanar)  
     55                (*coplanar) = false; 
     56 
     57    float u = - Distance(a) / dv; // TODO: could be done more efficiently 
     58     
     59        if (t)  
     60                (*t) = u; 
     61         
     62    return a + u * v; 
     63} 
     64 
     65 
     66int Plane3::Side(const Vector3 &v, const float threshold) const  
     67{ 
     68    return signum(Distance(v), threshold); 
     69} 
     70 
     71 
     72float Plane3::FindT(const Vector3 &a, const Vector3 &b) const  
     73{          
     74        const Vector3 v = b - a; // line from A to B 
     75        const float dv = DotProd(v, mNormal); 
     76     
     77        // does not intersect or coincident 
     78 
     79        if (signum(dv) == 0) 
     80                return 0; 
     81         
     82        return - Distance(a) / dv; // TODO: could be done more efficiently 
     83} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Plane3.h

    r504 r639  
    4040  } 
    4141 
    42   int Side(const Vector3 &v, const float threshold = 1e-6) const { 
    43     return signum(Distance(v), threshold); 
    44   } 
     42  /** Returns 1 if v is on front side, -1 if on back side, 0 if on plane. 
     43  */ 
     44  int Side(const Vector3 &v, const float threshold = 1e-6) const; 
    4545 
    4646  /** Finds intersection of line segment between points a and b with plane. 
     
    5353                                                   const Vector3 &b, 
    5454                                                   float *t = NULL, 
    55                                                    bool *coplanar = NULL) const  
    56   { 
    57     const Vector3 v = b - a; // line from A to B 
    58     float dv = DotProd(v, mNormal); 
    59      
    60     if (signum(dv) == 0) 
    61         { 
    62                 if (coplanar) (*coplanar) = true;        
    63                 if (t) (*t) = 0; 
    64                 return a; 
    65         } 
    66          
    67         if (coplanar) (*coplanar) = false; 
    68     float u = - Distance(a) / dv; // TODO: could be done more efficiently 
    69      
    70         if (t) (*t) = u; 
    71          
    72     return a + u * v; 
    73   } 
     55                                                   bool *coplanar = NULL) const; 
    7456   
    7557  /** Finds value of intersection parameter t on line segment from a to b. 
    76       @returns -1 if coplanar, else parameter t 
     58      @returns 0 if coplanar, else parameter t 
    7759  */ 
    78   float FindT(const Vector3 &a, const Vector3 &b) const  
    79   {        
    80           const Vector3 v = b - a; // line from A to B 
    81           const float dv = DotProd(v, mNormal); 
    82      
    83           // does not intersect or coincident 
    84           if (signum(dv) == 0) 
    85                   return 0; 
    86          
    87           return - Distance(a) / dv; // TODO: could be done more efficiently 
    88   } 
     60  float FindT(const Vector3 &a, const Vector3 &b) const; 
    8961 
    9062  friend bool 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RayInfo.cpp

    r508 r639  
    106106                mMaxT = t;  
    107107        } 
    108          
    109108#endif  
     109 
    110110 
    111111int RayInfo::ComputeRayIntersection(const int axis, const float position, float &t) const 
     
    133133{        
    134134        t = splitPlane.FindT(mRay->GetOrigin(), mRay->GetTermination()); 
    135 //      Debug << "t: " << t << " mint " << GetMinT() << " maxt " << GetMaxT() <<  
    136 //      " orig: " << mRay->GetOrigin() << " term " << mRay->GetTermination() << endl; 
     135 
     136        if (0) 
     137                Debug << "t: " << t << " mint " << GetMinT() << " maxt " << GetMaxT()  
     138                      << " orig: " << mRay->GetOrigin() << " term " << mRay->GetTermination() << endl; 
    137139 
    138140        // NOTE: if plane equals end point of ray, the ray should be classified 
    139141        // non-intersecting, otherwise polygon-plane intersections of bsp tree 
    140142        // approaches are not eliminating any rays intersecting the polygon! 
    141 #if 1 
    142         if (t >= GetMaxT() - 1e-20) 
     143        const float thresh = 1 ? 1e-6f : 0.0f; 
     144 
     145        // segment is not intersecting plane: fond out if on front or back side 
     146        if (t >= GetMaxT() - thresh) 
     147        { 
    143148                return splitPlane.Side(ExtrapOrigin()); 
    144         if (t <= GetMinT() + 1e-20) 
     149        } 
     150                 
     151        if (t <= GetMinT() + thresh) 
     152        { 
    145153                return splitPlane.Side(ExtrapTermination()); 
    146 #else 
    147         if (t > GetMaxT()) 
    148                 return splitPlane.Side(ExtrapOrigin()); 
    149         else if (t < GetMinT()) 
    150                 return splitPlane.Side(ExtrapTermination()); 
    151 #endif 
     154        } 
     155         
    152156        return 0; 
    153157} 
     158 
    154159 
    155160float RayInfo::SegmentLength() const 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r612 r639  
    1616#include "RssPreprocessor.h" 
    1717 
    18 #define SAMPLE_AFTER_SUBDIVISION 0 
     18#define SAMPLE_AFTER_SUBDIVISION 1 
    1919 
    2020 
     
    115115 
    116116/// helper function which destroys rays or copies them into the output ray container 
    117 inline void addOutRays(VssRayContainer &rays, VssRayContainer *outRays) 
     117inline void disposeRays(VssRayContainer &rays, VssRayContainer *outRays) 
    118118{ 
    119119        cout << "disposing samples ... "; 
     
    132132        else 
    133133        { 
    134                 CLEAR_CONTAINER(rays); 
    135         } 
     134                VssRayContainer::const_iterator it, it_end = rays.end(); 
     135 
     136                for (it = rays.begin(); it != it_end; ++ it) 
     137                { 
     138                        //(*it)->Unref(); 
     139                        if (!(*it)->IsActive()) 
     140                                delete (*it); 
     141                } 
     142        } 
     143 
    136144        cout << "finished" << endl; 
    137145        Debug << "disposed " << n << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
     
    162170 
    163171        // rays can be passed or deleted 
    164         addOutRays(initialSamples, outRays); 
     172        disposeRays(initialSamples, outRays); 
    165173         
    166174 
     
    196204 
    197205 
    198                 addOutRays(constructionSamples, outRays); 
     206                disposeRays(constructionSamples, outRays); 
    199207 
    200208                cout << "total samples: " << numSamples << endl; 
     
    236244        Visualize(preprocessor->mObjects, visualizationSamples); 
    237245 
    238         addOutRays(visualizationSamples, outRays); 
     246        disposeRays(visualizationSamples, outRays); 
    239247 
    240248        return numSamples; 
     
    30563064                                                                                  const VssRayContainer &rays) 
    30573065{ 
    3058         const int leafOut = 10; 
     3066        const int leafOut = 20; 
    30593067 
    30603068        ViewCell::NewMail(); 
    30613069 
    3062         cout << "visualization using " << mVisualizationSamples << " samples" << endl; 
     3070        cout << "visualization using " << (int)rays.size() << " samples" << endl; 
     3071        Debug << "visualization using " << (int)rays.size() << " samples" << endl; 
    30633072        Debug << "\nOutput view cells: " << endl; 
    30643073 
     
    30663075        if (0) 
    30673076                stable_sort(mViewCells.begin(), mViewCells.end(), vc_gt); 
    3068  
     3077         
    30693078        int limit = min(leafOut, (int)mViewCells.size()); 
    30703079 
    3071         int raysOut; 
     3080        int raysOut = 0; 
    30723081 
    30733082        //-- some rays for output 
    3074         if (1) 
    3075                 raysOut = min((int)rays.size(), mVisualizationSamples); 
    3076  
    30773083        for (int i = 0; i < limit; ++ i) 
    30783084        { 
    30793085                cout << "creating output for view cell " << i << " ... "; 
    30803086 
    3081                 VssRayContainer vcRays; 
    3082                 Intersectable::NewMail(); 
     3087         
    30833088                ViewCell *vc; 
    30843089         
     
    30863091                        vc = mViewCells[i]; 
    30873092                else 
    3088                         vc = mViewCells[Random((int)mViewCells.size())]; 
    3089  
    3090                 vector<ViewCell *> leaves; 
    3091                 mViewCellsTree->CollectLeaves(vc, leaves); 
    3092  
    3093         if (1) 
    3094                 { 
    3095                         // check whether we can add the current ray to the output rays 
    3096                         for (int k = 0; k < raysOut; ++ k) 
    3097                         { 
    3098                                 VssRay *ray = rays[k]; 
    3099                                 for     (int j = 0; j < (int)ray->mViewCells.size(); ++ j) 
    3100                                 { 
    3101                                         ViewCell *rayvc = ray->mViewCells[j]; 
    3102  
    3103                                         if (leaves[0] == rayvc) 
    3104                                                 vcRays.push_back(ray); 
    3105                                 } 
    3106                         } 
    3107                 } 
     3093                        vc = mViewCells[(int)RandomValue(0, (float)mViewCells.size() - 1)]; 
    31083094 
    31093095                //bspLeaves[j]->Mail(); 
    31103096                char s[64]; sprintf(s, "bsp-pvs%04d.x3d", i); 
    31113097                Exporter *exporter = Exporter::GetExporter(s); 
     3098                 
     3099                Debug << i << ": pvs size=" << (int)mViewCellsTree->GetPvsSize(vc) << endl; 
     3100 
     3101                if (1 || mExportRays) 
     3102                { 
     3103                        if (1) 
     3104                        { 
     3105                                VssRayContainer vcRays; 
     3106                VssRayContainer collectRays; 
     3107 
     3108                                raysOut = min((int)rays.size(), 100); 
     3109 
     3110                                // collect intial view cells 
     3111                                ViewCellContainer leaves; 
     3112                                mViewCellsTree->CollectLeaves(vc, leaves); 
     3113 
     3114                                ViewCellContainer::const_iterator vit, vit_end = leaves.end(); 
     3115        
     3116                                for (vit = leaves.begin(); vit != vit_end; ++ vit) 
     3117                                { 
     3118                                        BspLeaf *vcLeaf = dynamic_cast<BspViewCell *>(*vit)->mLeaf; 
     3119                                 
     3120                                        VssRayContainer::const_iterator rit, rit_end = vcLeaf->mVssRays.end(); 
     3121 
     3122                                        for (rit = vcLeaf->mVssRays.begin(); rit != rit_end; ++ rit) 
     3123                                        { 
     3124                                                collectRays.push_back(*rit); 
     3125                                        } 
     3126                                } 
     3127 
     3128                                VssRayContainer::const_iterator rit, rit_end = collectRays.end(); 
     3129 
     3130                                for (rit = collectRays.begin(); rit != rit_end; ++ rit) 
     3131                                { 
     3132                                        float p = RandomValue(0.0f, (float)collectRays.size()); 
     3133                         
     3134                                        if (p < raysOut) 
     3135                                                vcRays.push_back(*rit); 
     3136                                } 
     3137                                //-- export rays piercing this view cell 
     3138                                exporter->ExportRays(vcRays, RgbColor(1, 1, 1)); 
     3139                        } 
     3140 
     3141                         
     3142 
     3143                        if (0) 
     3144                        { 
     3145                                VssRayContainer vcRays; 
     3146                                raysOut = min((int)rays.size(), mVisualizationSamples); 
     3147                                // check whether we can add the current ray to the output rays 
     3148                                for (int k = 0; k < raysOut; ++ k) 
     3149                                { 
     3150                                        VssRay *ray = rays[k]; 
     3151                                        for     (int j = 0; j < (int)ray->mViewCells.size(); ++ j) 
     3152                                        { 
     3153                                                ViewCell *rayvc = ray->mViewCells[j]; 
     3154         
     3155                                                if (rayvc == vc) 
     3156                                                        vcRays.push_back(ray); 
     3157                                        } 
     3158                                }        
     3159                                 
     3160                                //-- export rays piercing this view cell 
     3161                                exporter->ExportRays(vcRays, RgbColor(1, 1, 0)); 
     3162                        } 
     3163 
     3164                } 
     3165                 
     3166                 
     3167 
     3168 
    31123169                exporter->SetWireframe(); 
    31133170 
     
    31173174 
    31183175                ExportViewCellGeometry(exporter, vc); 
    3119  
    3120  
    3121                 Debug << i << ": pvs size=" << (int)mViewCellsTree->GetPvsSize(vc) 
    3122                           << ", piercing rays=" << (int)vcRays.size() << endl; 
    3123                         //  << ", leaves=" << (int)vc->mLeaves.size() << endl; 
    3124  
    3125                  
    3126                 //-- export rays piercing this view cell 
     3176         
     3177 
     3178                m.mDiffuseColor = RgbColor(1, 0, 0); 
     3179            exporter->SetForcedMaterial(m); 
     3180 
     3181                exporter->SetFilled(); 
     3182 
     3183 
    31273184                if (1) 
    31283185                { 
    3129                         exporter->ExportRays(vcRays, RgbColor(1, 1, 1)); 
     3186                        ObjectPvsMap::const_iterator oit, 
     3187                                oit_end = vc->GetPvs().mEntries.end(); 
     3188 
     3189 
     3190                        exporter->SetFilled(); 
     3191 
     3192                        Intersectable::NewMail(); 
     3193         
     3194                        // output PVS of view cell 
     3195                        for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 
     3196                        {                
     3197                                Intersectable *intersect = (*oit).first; 
     3198 
     3199                                if (!intersect->Mailed()) 
     3200                                { 
     3201                                        //m = RandomMaterial(); 
     3202                                        //exporter->SetForcedMaterial(m); 
     3203 
     3204                                        exporter->ExportIntersectable(intersect); 
     3205                                        intersect->Mail(); 
     3206                                } 
     3207                        } 
    31303208                } 
    31313209                else 
    31323210                { 
    3133  
    3134                         ViewCellContainer leaves; 
    3135                         mViewCellsTree->CollectLeaves(vc, leaves); 
    3136  
    3137                         ViewCellContainer::const_iterator lit, lit_end = leaves.end(); 
    3138  
    3139                         for (lit = leaves.begin(); lit != lit_end; ++ lit) 
    3140                         { 
    3141                                 BspLeaf *l = dynamic_cast<BspViewCell *>(*lit)->mLeaf; 
    3142                                 exporter->ExportRays(l->mVssRays); 
    3143                         } 
    3144                 } 
    3145  
    3146          
    3147                 m.mDiffuseColor = RgbColor(1, 0, 0); 
    3148                 exporter->SetForcedMaterial(m); 
    3149  
    3150                 ObjectPvsMap::const_iterator it, 
    3151                         it_end = vc->GetPvs().mEntries.end(); 
    3152  
    3153                 exporter->SetFilled(); 
    3154  
    3155          
    3156                 // output PVS of view cell 
    3157                 for (it = vc->GetPvs().mEntries.begin(); it != it_end; ++ it) 
    3158                 { 
    3159                  
    3160                         Intersectable *intersect = (*it).first; 
    3161  
    3162                         if (!intersect->Mailed()) 
    3163                         { 
    3164                                 Material m = RandomMaterial(); 
    3165                                 exporter->SetForcedMaterial(m); 
    3166  
    3167                                 exporter->ExportIntersectable(intersect); 
    3168                                 intersect->Mail(); 
    3169                         } 
    3170                 } 
    3171  
    3172                  
     3211                        exporter->ExportGeometry(objects); 
     3212                } 
     3213 
    31733214                DEL_PTR(exporter); 
    31743215                cout << "finished" << endl; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r612 r639  
    1818#include "Beam.h" 
    1919 
     20#define USE_FIXEDPOINT_T 0 
     21 
    2022 
    2123//-- static members 
     
    6668mViewCellsManager(NULL), 
    6769mOutOfBoundsCell(NULL), 
    68 mStoreRays(false), 
     70mStoreRays(true), 
    6971mRenderCostWeight(0.5), 
    7072mUseRandomAxis(false), 
     
    602604                        RayInfoContainer::const_iterator it, it_end = tData.mRays->end(); 
    603605                        for (it = tData.mRays->begin(); it != it_end; ++ it) 
     606                        { 
     607                                (*it).mRay->Ref();                       
    604608                                leaf->mVssRays.push_back((*it).mRay); 
     609                        } 
    605610                } 
    606611 
     
    18861891 
    18871892 
     1893void VspBspTree::CollectRays(VssRayContainer &rays) 
     1894{ 
     1895        vector<BspLeaf *> leaves; 
     1896 
     1897        vector<BspLeaf *>::const_iterator lit, lit_end = leaves.end(); 
     1898 
     1899        for (lit = leaves.begin(); lit != lit_end; ++ lit) 
     1900        { 
     1901                BspLeaf *leaf = *lit; 
     1902                VssRayContainer::const_iterator rit, rit_end = leaf->mVssRays.end(); 
     1903 
     1904                for (rit = leaf->mVssRays.begin(); rit != rit_end; ++ rit) 
     1905                        rays.push_back(*rit); 
     1906        } 
     1907} 
     1908 
     1909 
    18881910void VspBspTree::ValidateTree() 
    18891911{ 
     
    19882010                                                  RayInfoContainer &rays, 
    19892011                                                  RayInfoContainer &frontRays, 
    1990                                                   RayInfoContainer &backRays) 
     2012                                                  RayInfoContainer &backRays) const 
    19912013{ 
    19922014        int splits = 0; 
     
    20152037                        { 
    20162038                                //-- split ray 
    2017                                 //-- test if start point behind or in front of plane 
     2039                                //  test if start point behind or in front of plane 
    20182040                                const int side = plane.Side(bRay.ExtrapOrigin()); 
    20192041 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h

    r612 r639  
    310310        void CollapseViewCells(); 
    311311 
     312        /** Collects rays stored in the leaves. 
     313        */ 
     314        void CollectRays(VssRayContainer &rays); 
     315 
     316 
    312317        ViewCellsTree *mViewCellsTree; 
     318 
     319 
    313320protected: 
    314321 
     
    502509                                  RayInfoContainer &rays,  
    503510                              RayInfoContainer &frontRays,  
    504                                   RayInfoContainer &backRays); 
     511                                  RayInfoContainer &backRays) const; 
    505512 
    506513 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp

    r605 r639  
    531531  if (mUseViewSpaceBox) 
    532532  { 
    533           if (0) 
     533          if (1) 
    534534                  mViewSpaceBox = box; 
    535535          else 
Note: See TracChangeset for help on using the changeset viewer.