Changeset 310


Ignore:
Timestamp:
10/05/05 18:36:16 (19 years ago)
Author:
mattausch
Message:

updated input file behaviour. started to use pvs templates. removed raycast bugs

Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env

    r309 r310  
    1414#       filename ../data/soda/soda.dat 
    1515#       filename ../data/soda/soda5.dat 
    16 #       viewcells ../data/atlanta/atlanta_viewcells_large.x3d 
    17 #       viewcells ../data/atlanta/atlanta_viewcells_large2.x3d 
    18         viewcells ../data/vienna/viewcells-25-sel.x3d 
    19 #       viewcells ../data/vienna/viewcells-25.x3d 
    20 #       viewcells ../data/vienna/viewcells-large-sel.x3d 
    2116} 
    2217 
     
    6358        totalSamples    1000000 
    6459        samplesPerPass  5 
    65         viewCells    BSP 
    66         #viewCells    KD 
    6760} 
    6861 
     62ViewCells { 
     63        hierarchyType bspTree 
     64        #hierarchyType kdTree 
     65        #hierarchyType sceneDependent 
     66#       filename ../data/atlanta/atlanta_viewcells_large.x3d 
     67#       filename ../data/atlanta/atlanta_viewcells_large2.x3d 
     68        filename ../data/vienna/viewcells-25-sel.x3d 
     69#       filename ../data/vienna/viewcells-25.x3d 
     70#       filename ../data/vienna/viewcells-large-sel.x3d 
     71} 
    6972 
    7073BspTree { 
     74#       constructionMethod fromRays 
     75        constructionMethod fromViewCells 
     76#       constructionMethod fromSceneGeometry 
     77 
    7178        # next polygon         = 1 
    7279        # axis aligned         = 2 
     
    93100        #splitPlaneStrategy 72 
    94101         
    95 #       constructionMethod rays 
    96         constructionMethod viewCells 
    97 #       constructionMethod sceneGeometry 
    98102        maxCandidates 50 
    99103        maxViewCells 999999 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp

    r309 r310  
    10681068                 "atlanta2.x3d"); 
    10691069 
    1070   RegisterOption("Scene.viewcells", 
    1071                  optString, 
    1072                  "-viewcells_filename=", 
    1073                  "atlanta_viewcells_large.x3d"); 
    1074  
    10751070  RegisterOption("Unigraphics.meshGrouping", 
    10761071                 optInt, 
     
    11091104                 "0.1"); 
    11101105 
    1111  
    11121106  RegisterOption("KdTree.sahUseFaces", 
    11131107                 optBool, 
     
    11511145                 "1000000"); 
    11521146 
    1153   RegisterOption("Sampling.viewCells", 
    1154                  optString, 
    1155                  "-view_cells", 
    1156                  "BSP"); 
    1157  
    11581147  RegisterOption("Sampling.samplesPerPass", 
    11591148                 optInt, 
     
    11611150                 "10"); 
    11621151 
     1152  RegisterOption("ViewCells.type", 
     1153                 optString, 
     1154                 "-view_cells", 
     1155                 "BSP"); 
     1156 
     1157  RegisterOption("ViewCells.filename", 
     1158                 optString, 
     1159                 "-viewcells_filename=", 
     1160                 "atlanta_viewcells_large.x3d"); 
     1161 
     1162 
     1163  RegisterOption("BspTree.constructionMethod", 
     1164          optString, 
     1165          "-bsp_construction_method=", 
     1166          "fromViewCells"); 
     1167 
    11631168  RegisterOption("BspTree.Termination.maxPolygons", 
    11641169                 optInt, 
     
    11801185                "-bsp_split_method=", 
    11811186                "leastSplits"); 
    1182  
    1183   RegisterOption("BspTree.constructionMethod", 
    1184           optString, 
    1185           "-bsp_construction_method=", 
    1186           "viewCells"); 
    11871187 
    11881188  RegisterOption("BspTree.maxCandidates", 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp

    r309 r310  
    3030} 
    3131 
     32bool Preprocessor::ParseViewCellsOptions() 
     33{ 
     34        // parse type of view cells 
     35        char viewCellsStr[64]; 
     36        environment->GetStringValue("ViewCells.hierarchyType", viewCellsStr); 
     37 
     38        int vcType = BSP_VIEW_CELLS; 
     39   
     40        if (strcmp(viewCellsStr, "bspTree") == 0) 
     41                vcType = BSP_VIEW_CELLS; 
     42        else if (strcmp(viewCellsStr, "kdTree") == 0) 
     43                vcType = KD_VIEW_CELLS; 
     44        else if (strcmp(viewCellsStr, "sceneDependent") == 0) 
     45                vcType = SCENE_DEPENDENT; 
     46        else 
     47        { 
     48                cerr<<"Wrong view cells type" << viewCellsStr << endl; 
     49                exit(1); 
     50        } 
     51 
     52        // decide about view cell subdivision type used for preprocessing 
     53        switch (vcType) 
     54        { 
     55        case BSP_VIEW_CELLS: 
     56        case KD_VIEW_CELLS: 
     57                mViewCellsType = vcType; 
     58                break; 
     59        case SCENE_DEPENDENT: 
     60                mViewCellsType = BSP_VIEW_CELLS; // TODO 
     61                break; 
     62        } 
     63 
     64        return true; 
     65} 
     66 
    3267void Preprocessor::DeleteViewCells() 
    3368{ 
     
    108143        switch (BspTree::sConstructionMethod) 
    109144        { 
    110         case BspTree::VIEW_CELLS: 
     145        case BspTree::FROM_INPUT_VIEW_CELLS: 
    111146                mBspTree->Construct(mViewCells); 
    112147                break; 
    113         case BspTree::SCENE_GEOMETRY: 
     148        case BspTree::FROM_SCENE_GEOMETRY: 
    114149                DeleteViewCells(); // we generate new view cells 
    115150                mSceneGraph->CollectObjects(&objects); 
    116151                mBspTree->Construct(objects, &mViewCells); 
    117152                break; 
    118         case BspTree::RAYS: 
     153        case BspTree::FROM_RAYS: 
    119154                DeleteViewCells(); // we generate new view cells         
    120155                mBspTree->Construct(rays, &mViewCells); 
     
    126161        return true; 
    127162} 
     163 
    128164 
    129165 
     
    169205  return false; 
    170206} 
    171  
    172  
    173  
  • trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.h

    r309 r310  
    9292  void DeleteViewCells(); 
    9393 
     94  /** Parses the view cell options 
     95  */ 
     96  bool ParseViewCellsOptions(); 
     97 
    9498  /// scene graph loaded from file 
    9599  SceneGraph *mSceneGraph; 
     
    111115  ViewCell *mRootViewCell; 
    112116 
    113   enum {BSP_VIEW_CELLS, KD_VIEW_CELLS}; 
     117  /// view cell hierarchy types 
     118  enum {BSP_VIEW_CELLS, KD_VIEW_CELLS, SCENE_DEPENDENT}; 
    114119 
     120  /// type of the view cells 
    115121  int mViewCellsType; 
    116122}; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Pvs.cpp

    r308 r310  
    44#include "Intersectable.h" 
    55 
     6 
     7/* 
     8int mypvs::AddSample(T *sample) 
     9{ 
     10  int result; 
     11   
     12  PvsData<typename T> *data = Find(sample); 
     13  if (data) { 
     14    data->mVisibleSamples++; 
     15    result = 0; 
     16  } else { 
     17    mEntries[node] = PvsData<typename T>(1); 
     18    result = 1; 
     19  } 
     20  return  result; 
     21} 
     22 
     23 
     24 
     25*/ 
    626KdPvsData * 
    727KdPvs::Find(KdNode *node) 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Pvs.h

    r308 r310  
    88class Ray; 
    99class Intersectable; 
     10 
     11 
     12template<typename T> 
     13struct LtSample { 
     14    bool operator()(const T *a, const T *b) const 
     15    { 
     16                return a < b; 
     17        }  
     18}; 
     19 
     20//typedef std::map<T *, PvsData<T>, LtSample<T>> PvsMap<T>; 
     21 
     22template<typename T>  
     23struct PvsData { 
     24  int mVisibleSamples; 
     25  PvsData<T>() {} 
     26  PvsData<T>(const int samples):mVisibleSamples(samples) {} 
     27}; 
     28 
     29template<typename T> 
     30class mypvs  
     31{ 
     32public: 
     33    mypvs(): mSamples(0), mEntries() {} 
     34        int mSamples; 
     35 
     36        //int Compress() {return 0;} 
     37        int GetSize() {return (int)mEntries.size();} 
     38 
     39        PvsData<T> *Find(T sample); 
     40        int AddSample(T sample); 
     41 
     42        void GetData(const int index, 
     43               T &entry, 
     44               PvsData<T> &data); 
     45        std::map<T, PvsData<T>, LtSample<T> > mEntries; 
     46}; 
     47 
     48 
     49template <typename T> 
     50PvsData<T> *mypvs<T>::Find(T sample) 
     51{ 
     52  /*std::map<T *, PvsData<T>, LtSample<T> >::iterator i = mEntries.find(sample); 
     53  if (i != mEntries.end()) { 
     54    return &(*i).second; 
     55  } else*/ 
     56    return NULL; 
     57} 
     58 
     59template <typename T> 
     60void mypvs<T>::GetData(const int index, 
     61               T &entry, 
     62               PvsData<T> &data) 
     63{ 
     64  /*PvsMap<typename T>::iterator i = mEntries.begin(); 
     65  for (int k = 0; k != index && i != mEntries.end(); i++, k++); 
     66 
     67  entry = (*i).first; 
     68  data = (*i).second;*/ 
     69} 
    1070 
    1171struct LtKdNode 
  • trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp

    r309 r310  
    1414  environment->GetIntValue("Sampling.totalSamples", mTotalSamples); 
    1515   
    16   char viewCellsStr[64]; 
    17   environment->GetStringValue("Sampling.viewCells", viewCellsStr); 
    18  
    19   mViewCellsType = BSP_VIEW_CELLS; 
    20  
    21   if (strcmp(viewCellsStr, "BSP") == 0) 
    22           mViewCellsType = BSP_VIEW_CELLS; 
    23   else if (strcmp(viewCellsStr, "KD") == 0) 
    24       mViewCellsType= KD_VIEW_CELLS; 
    25   else  
    26   { 
    27           cerr<<"Wrong view cells type" << viewCellsStr << endl; 
    28           exit(1); 
    29   } 
    30  
    3116  mKdPvsDepth = 100; 
    3217  mStats.open("stats.log"); 
     
    117102        int sampleContributions = 0; 
    118103 
    119         if (mViewCellsType == KD_VIEW_CELLS) 
     104        if (mViewCellsType == BSP_VIEW_CELLS) 
     105        { 
     106                // cast ray to KD tree to find intersection with other objects 
     107                mKdTree->CastRay(ray); 
     108                 
     109                // cast ray to BSP tree to get intersection with view cells 
     110                mBspTree->CastRay(ray); 
     111 
     112                sampleContributions += sampleContributions += AddObjectSamples(object, ray); 
     113 
     114                if (ray.intersections.size() > 0) // view cell found 
     115                { 
     116                        if (ray.intersections.size())  
     117                                sampleContributions += AddObjectSamples(ray.intersections[0].mObject, ray); 
     118                } 
     119        } 
     120        else 
    120121        { 
    121122                mKdTree->CastRay(ray); 
     
    128129                        } 
    129130                }  
    130         } else   
    131         { 
    132                 mBspTree->CastRay(ray); 
    133  
    134                 if (ray.viewCells.size() > 0) // view cell found 
    135                 { 
    136                         sampleContributions += sampleContributions += AddObjectSamples(object, ray); 
     131        }        
    137132         
    138                         // cast ray to KD tree to find intersections with other objects 
    139                         mKdTree->CastRay(ray); 
    140  
    141                         if (ray.intersections.size())  
    142                                 sampleContributions += AddObjectSamples(ray.intersections[0].mObject, ray); 
    143                 } 
    144         } 
    145  
    146133        return sampleContributions; 
    147134} 
     
    251238                int passSamples = 0; 
    252239                int index = 0; 
    253                 Debug << "************************************" << endl; 
    254                  
     240                                 
    255241                for (i = 0; i < objects.size(); i++) { 
    256242                        KdNode *nodeToSample = NULL; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.h

    r308 r310  
    4545        void AddPassingRay(const Ray &ray, const int contributions);     
    4646 
     47        static bool ParseEnvironment(); 
     48 
     49 
    4750protected: 
    4851 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp

    r309 r310  
    1717int BspTree::sMaxCandidates = 10; 
    1818int BspTree::sSplitPlaneStrategy = NEXT_POLYGON;  
    19 int BspTree::sConstructionMethod = VIEW_CELLS; 
     19int BspTree::sConstructionMethod = FROM_INPUT_VIEW_CELLS; 
    2020int BspTree::sTermMaxPolysForAxisAligned = 50; 
    2121 
     
    263263mStoreSplitPolys(false) 
    264264{ 
     265        mypvs<BspNode *> testpvs; testpvs.Find(mRoot); 
    265266        Randomize(); // initialise random generator for heuristics 
    266267} 
     
    10591060void BspTree::ParseEnvironment() 
    10601061{ 
     1062        //-- parse bsp cell tree construction method 
     1063        char constructionMethodStr[60]; 
     1064         
     1065        environment->GetStringValue("BspTree.constructionMethod", constructionMethodStr); 
     1066 
     1067        sConstructionMethod = FROM_INPUT_VIEW_CELLS; 
     1068         
     1069        if (strcmp(constructionMethodStr, "fromViewCells") == 0) 
     1070                sConstructionMethod = FROM_INPUT_VIEW_CELLS; 
     1071        else if (strcmp(constructionMethodStr, "fromSceneGeometry") == 0) 
     1072                sConstructionMethod = FROM_SCENE_GEOMETRY; 
     1073        else if (strcmp(constructionMethodStr, "fromRays") == 0) 
     1074                sConstructionMethod = FROM_RAYS; 
     1075        else  
     1076        { 
     1077                cerr << "Wrong construction method " << constructionMethodStr << endl; 
     1078                exit(1); 
     1079    } 
     1080 
     1081        Debug << "Construction method: " << constructionMethodStr << endl; 
     1082 
    10611083        environment->GetIntValue("BspTree.Termination.maxDepth", sTermMaxDepth); 
    10621084        environment->GetIntValue("BspTree.Termination.maxPolygons", sTermMaxPolygons); 
     
    10921114 
    10931115        Debug << endl; 
    1094  
    1095         //-- parse BSP tree construction method 
    1096         char constructionMethodStr[60]; 
    1097          
    1098         environment->GetStringValue("BspTree.constructionMethod", constructionMethodStr); 
    1099  
    1100         sConstructionMethod = BspTree::VIEW_CELLS; 
    1101          
    1102         if (strcmp(constructionMethodStr, "viewCells") == 0) 
    1103                 sConstructionMethod = BspTree::VIEW_CELLS; 
    1104         else if (strcmp(constructionMethodStr, "sceneGeometry") == 0) 
    1105                 sConstructionMethod = BspTree::SCENE_GEOMETRY; 
    1106         else if (strcmp(constructionMethodStr, "rays") == 0) 
    1107                 sConstructionMethod = BspTree::RAYS; 
    1108         else  
    1109         { 
    1110                 cerr << "Wrong bsp construction method " << constructionMethodStr << endl; 
    1111                 exit(1); 
    1112     } 
    1113  
    1114         Debug << "Construction method: " << constructionMethodStr << endl; 
    11151116} 
    11161117 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h

    r308 r310  
    244244}; 
    245245 
    246 /** Implementation of the ViewCell BSP tree. */ 
     246/** Implementation of the view cell BSP tree.  
     247*/ 
    247248class BspTree  
    248249{ 
     
    271272        typedef std::stack<BspTraversalData> BspTraversalStack; 
    272273 
    273         /// BSP tree construction type 
    274         enum {VIEW_CELLS, SCENE_GEOMETRY, RAYS}; 
    275  
    276274        /** Default constructor creating an empty tree. 
    277275                @param viewCell view cell corresponding to unbounded space 
     
    335333        int CastRay(Ray &ray); 
    336334 
    337         //static bool displayDebug; 
     335        /// bsp tree construction types 
     336        enum {FROM_INPUT_VIEW_CELLS, FROM_SCENE_GEOMETRY, FROM_RAYS}; 
     337 
    338338protected: 
    339339         
  • trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp

    r309 r310  
    99#include "Exporter.h" 
    1010#include "X3dExporter.h" // delete later 
     11#include "ViewCell.h" 
    1112 
    1213#define USE_EXE_PATH false 
     
    3334  p->BuildKdTree(); 
    3435  p->KdTreeStatistics(cout); 
    35  
     36   
     37  // parse view cell hierarchy options 
     38  p->ParseViewCellsOptions(); 
    3639 
    3740  if (p->mViewCellsType == Preprocessor::BSP_VIEW_CELLS) 
    3841  { 
    39            // if BSP tree construction method needs predefined view cells 
    40           if (BspTree::sConstructionMethod == BspTree::VIEW_CELLS) 
     42          if (BspTree::sConstructionMethod == BspTree::FROM_INPUT_VIEW_CELLS) 
    4143          { 
    42                   environment->GetStringValue("Scene.viewcells", buff); 
    43                    
     44                   // view cells input file name 
     45                  environment->GetStringValue("ViewCells.filename", buff); 
    4446                  string vcFilename(buff); 
    45                   
     47 
    4648                  if (vcFilename != "") 
    47                   p->LoadViewCells(vcFilename); 
     49                          p->LoadViewCells(vcFilename); 
    4850                  else 
    4951                          p->GenerateViewCells(); 
    5052 
    51                    Debug << "Viewcells loaded / generated. Number of view cells: " << (int)p->mViewCells.size() << endl; 
     53                  Debug << "Viewcells loaded / generated. Number of view cells: " << (int)p->mViewCells.size() << endl; 
    5254          } 
     55         
     56          p->BuildBspTree(); 
    5357           
    54           p->BuildBspTree(); 
    5558          p->BspTreeStatistics(Debug); 
    5659          p->Export("vc_bsptree2.x3d", false, false, true); 
Note: See TracChangeset for help on using the changeset viewer.