Ignore:
Timestamp:
06/18/06 03:47:06 (18 years ago)
Author:
mattausch
Message:

worked on view-object space partition
fixed some loading bugs
fixeds some exporting bugs using line segments
enabling other methods for view space sampling in ViewCellsManager? OBJECT_DIRECTION_BASED_DISTRIBUTION)
added class interface for a sampling strategy

File:
1 edited

Legend:

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

    r1006 r1020  
    1212#include "GlRenderer.h" 
    1313#include "PlyParser.h" 
     14#include "SamplingStrategy.h" 
     15 
     16 
    1417 
    1518namespace GtpVisibilityPreprocessor { 
    1619 
     20const static bool ADDITIONAL_GEOMETRY_HACK = false; 
    1721 
    1822Preprocessor *preprocessor; 
     
    7680                //Vector3 boxSize = sceneBox.Size() * Vector3(0.0025, 0.01, 0.0025); 
    7781                Vector3 boxSize = sceneBox.Size() * Vector3(0.005, 0.02, 0.005); 
     82 
    7883                AxisAlignedBox3 box(pt2 + 0.1, pt2 + boxSize); 
    7984                Mesh *mesh = CreateMeshFromBox(box); 
     
    243248        { 
    244249                // HACK  
    245                 //AddGeometry(mSceneGraph); 
    246           mSceneGraph->AssignObjectIds(); 
    247                  
    248           int intersectables, faces; 
    249           mSceneGraph->GetStatistics(intersectables, faces); 
    250  
    251           cout<<filename<<" parsed successfully."<<endl; 
    252           cout<<"#NUM_OBJECTS (Total numner of objects)\n"<<intersectables<<endl; 
    253           cout<<"#NUM_FACES (Total numner of faces)\n"<<faces<<endl; 
    254           mSceneGraph->CollectObjects(&mObjects); 
    255           mSceneGraph->mRoot->UpdateBox(); 
    256  
    257          /* Exporter *exporter = Exporter::GetExporter("testload.x3d"); 
    258  
    259           if (exporter) 
    260           { 
    261                   exporter->ExportGeometry(mObjects); 
    262                   delete exporter; 
    263           }*/ 
    264  
     250                if (ADDITIONAL_GEOMETRY_HACK) 
     251                        AddGeometry(mSceneGraph); 
     252                 
     253                mSceneGraph->AssignObjectIds(); 
     254         
     255                int intersectables, faces; 
     256                mSceneGraph->GetStatistics(intersectables, faces); 
     257         
     258                cout<<filename<<" parsed successfully."<<endl; 
     259                cout<<"#NUM_OBJECTS (Total numner of objects)\n"<<intersectables<<endl; 
     260                cout<<"#NUM_FACES (Total numner of faces)\n"<<faces<<endl; 
     261                mSceneGraph->CollectObjects(&mObjects); 
     262                mSceneGraph->mRoot->UpdateBox(); 
     263 
     264                if (0) 
     265                { 
     266                        Exporter *exporter = Exporter::GetExporter("testload.x3d"); 
     267 
     268                        if (exporter) 
     269                        { 
     270                                exporter->ExportGeometry(mObjects); 
     271                                delete exporter; 
     272                        } 
     273                } 
    265274        } 
    266275         
     
    594603} 
    595604 
    596  
    597  
     605#if 0 // matt: implemented interface samplestrategy 
    598606bool 
    599607Preprocessor::GenerateRays( 
     
    656664  return true; 
    657665} 
    658  
    659 } 
     666#endif 
     667bool Preprocessor::GenerateRays(const int number, 
     668                                                                const int sampleType, 
     669                                                                SimpleRayContainer &rays) 
     670{ 
     671        Vector3 origin, direction;  
     672         
     673        const int startSize = (int)rays.size(); 
     674        SamplingStrategy *strategy = GenerateSamplingStrategy(sampleType); 
     675 
     676        if (!strategy) 
     677                return false; 
     678 
     679        for (int i=0; (int)rays.size() - startSize < number; ++ i)  
     680        { 
     681                SimpleRay newRay; 
     682                bool success = strategy->GenerateSample(newRay); 
     683 
     684                if (success) 
     685                        rays.AddRay(newRay); 
     686        } 
     687 
     688        delete strategy; 
     689 
     690    return true; 
     691} 
     692 
     693 
     694SamplingStrategy *Preprocessor::GenerateSamplingStrategy(const int strategyId) const 
     695{ 
     696        switch (strategyId) 
     697        { 
     698        case OBJECT_BASED_DISTRIBUTION:  
     699                return new ObjectBasedDistribution(*this); 
     700        case OBJECT_DIRECTION_BASED_DISTRIBUTION: 
     701                return new ObjectDirectionBasedDistribution(*this); 
     702        case DIRECTION_BASED_DISTRIBUTION: 
     703                return new DirectionBasedDistribution(*this); 
     704        case DIRECTION_BOX_BASED_DISTRIBUTION:  
     705                return new DirectionBoxBasedDistribution(*this); 
     706        case SPATIAL_BOX_BASED_DISTRIBUTION: 
     707                return new SpatialBoxBasedDistribution(*this); 
     708        case OBJECTS_INTERIOR_DISTRIBUTION: 
     709                return new ObjectsInteriorDistribution(*this); 
     710        default: // no valid strategy 
     711                return NULL; 
     712        } 
     713        // should never come here 
     714        return NULL; 
     715} 
     716 
     717 
     718} 
Note: See TracChangeset for help on using the changeset viewer.