Ignore:
Timestamp:
05/02/06 10:26:43 (18 years ago)
Author:
mattausch
Message:

added pvs

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

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.h

    r863 r870  
    142142        between 0 (no overlap) and 1 (same box). 
    143143  */ 
    144   friend inline float FactorOfOverlap(const AxisAlignedBox3 &, const AxisAlignedBox3 &); 
     144  friend inline float RatioOfOverlap(const AxisAlignedBox3 &, const AxisAlignedBox3 &); 
    145145 
    146146  /** Includes returns true if a includes b (completely) 
     
    540540} 
    541541 
    542 inline float FactorOfOverlap(const AxisAlignedBox3 &box1, const AxisAlignedBox3 &box2) 
    543 { 
    544         const AxisAlignedBox3 isect = Intersect(box1, box2); 
    545         return isect.GetVolume() / box1.GetVolume(); 
     542inline float RatioOfOverlap(const AxisAlignedBox3 &box1, const AxisAlignedBox3 &box2) 
     543{ 
     544        // return ratio of intersection to union 
     545        const AxisAlignedBox3 bisect = Intersect(box1, box2); 
     546        const AxisAlignedBox3 bunion = Union(box1, box2); 
     547 
     548        return bisect.GetVolume() / bunion.GetVolume(); 
    546549} 
    547550 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h

    r860 r870  
    4949 
    5050    virtual AxisAlignedBox3 GetBox() = 0; 
    51         virtual int CastRay(Ray &ray) = 0; 
     51        virtual int CastRay(GtpVisibilityPreprocessor::Ray &ray) = 0; 
    5252         
    5353        virtual bool IsConvex() = 0; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp

    r863 r870  
    6969Mesh::Preprocess() 
    7070{ 
    71  Cleanup(); 
     71        Cleanup(); 
    7272    
    73    ComputeBoundingBox(); 
     73        ComputeBoundingBox(); 
    7474    
    75   /** true if it is a watertight convex mesh */ 
    76   mIsConvex = false; 
    77    
    78   if (mFaces.size() > MeshKdTree::mTermMinCost) { 
    79     mKdTree = new MeshKdTree(this); 
    80     MeshKdLeaf *root = (MeshKdLeaf *)mKdTree->GetRoot(); 
    81     for (int i = 0; i < mFaces.size(); i++) 
    82       root->mFaces.push_back(i); 
    83     cout<<"KD"; 
    84     mKdTree->Construct(); 
    85          
    86     if (mKdTree->GetRoot()->IsLeaf()) { 
    87       cout<<"d"; 
    88       delete mKdTree; 
    89           mKdTree = NULL; 
    90     } 
    91   } 
     75        /** true if it is a watertight convex mesh  
     76        */ 
     77        mIsConvex = false; 
     78 
     79        if (mFaces.size() > MeshKdTree::mTermMinCost)  
     80        { 
     81                mKdTree = new MeshKdTree(this); 
     82                MeshKdLeaf *root = (MeshKdLeaf *)mKdTree->GetRoot(); 
     83                 
     84                for (int i = 0; i < mFaces.size(); i++) 
     85                        root->mFaces.push_back(i); 
     86                 
     87                cout<<"KD"; 
     88                mKdTree->Construct(); 
     89 
     90                if (mKdTree->GetRoot()->IsLeaf())  
     91                { 
     92                        cout<<"d"; 
     93                        delete mKdTree; 
     94                        mKdTree = NULL; 
     95                } 
     96        } 
    9297} 
    9398 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.h

    r863 r870  
    2222 
    2323/// vertex index container 
    24 typedef std::vector<short> VertexIndexContainer; 
    25  
     24//typedef std::vector<short> VertexIndexContainer; 
     25typedef std::vector<int> VertexIndexContainer; 
    2626 
    2727/** Patch used as an element of the mesh */ 
     
    5858/// default vertex container for Mesh 
    5959typedef vector<Vector3> VertexContainer; 
    60  
    61 /// vertex index container 
    62 typedef vector<short> VertexIndexContainer; 
    6360 
    6461/// default patch container for Mesh 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r863 r870  
    374374                Debug << "view cell type: VspBsp" << endl; 
    375375 
    376                 mVspBspTree = new VspBspTree(); 
     376                mVspBspTree = new VspBspTree(environment); 
    377377                mViewCellsManager = new VspBspViewCellsManager(mVspBspTree); 
    378378        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r863 r870  
    20332033                stream << "active=\"" << viewCell->IsActive() << "\" "; 
    20342034                stream << "mergecost=\"" << viewCell->GetMergeCost() << "\" "; 
     2035                stream << "pvs=\""; 
     2036 
     2037                //-- NOTE: do not export pvss for interior view cells because 
     2038                // they can be completely reconstructed from the leaf pvss 
     2039                if (0) 
     2040                        ExportPvs(viewCell, stream); 
    20352041                 
    2036                 //-- NOTE: do not export pvss for interior view cells because 
    2037                 // they can be compeletely reconstructed from the leaf pvss 
    2038                 if (0) 
    2039                 { 
    2040                         stream << "pvs=\""; 
    2041                         ExportPvs(viewCell, stream); 
    2042                 } 
    2043  
    20442042                stream << "\" >" << endl; 
    20452043 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r863 r870  
    46834683        ViewCellsManager *vm = NULL; 
    46844684 
     4685        Debug << "vc filename: " << filename << endl; 
     4686 
    46854687        if (parser.ParseFile(filename, &vm, objects)) 
    46864688        { 
     
    46994701        else 
    47004702        { 
    4701                 Debug << "failed loading view cells" << endl; 
     4703                Debug << "Error: loading view cells failed!" << endl; 
    47024704                DEL_PTR(vm); 
    47034705        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r860 r870  
    362362        virtual void FinalizeViewCells(const bool createMesh); 
    363363 
    364  
    365         /** Loads view cells from file. The view cells manager is created with  
    366                 respect to the loaded view cells. 
    367  
    368                 @returns the view cells manager if loading was successful, false otherwise 
    369         */ 
    370         static ViewCellsManager *LoadViewCells(const string filename,  
    371                                                                                    ObjectContainer *objects); 
    372  
    373364        /** Evaluates statistics values on view cells. 
    374365        */ 
     
    432423                                ); 
    433424 
    434   AxisAlignedBox3 
    435   GetViewCellBox(ViewCell *vc); 
     425        /** Returns bounding box of a view cell. 
     426        */ 
     427        AxisAlignedBox3 GetViewCellBox(ViewCell *vc); 
    436428 
    437429        /** Exports bounding boxes of objects to file. 
     
    442434        */ 
    443435        bool LoadBoundingBoxes(const string filename, IndexedBoundingBoxContainer &boxes) const; 
     436 
     437 
     438        /** Loads view cells from file. The view cells manager is created with  
     439                respect to the loaded view cells. 
     440 
     441                @returns the view cells manager if loading was successful, false otherwise 
     442        */ 
     443        static ViewCellsManager *LoadViewCells(const string filename, ObjectContainer *objects); 
    444444 
    445445protected: 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp

    r863 r870  
    117117        // go one up in the tree 
    118118        if (mCurrentBspNode->GetParent()) 
    119         {       cout << "]"; 
     119        {       Debug << "]"; 
    120120                mCurrentBspNode = mCurrentBspNode->GetParent(); 
    121121        } 
     
    127127        // go one up in the tree 
    128128        if (mCurrentViewCell->GetParent()) 
    129         {       cout << "]"; 
     129        {       Debug << "]"; 
    130130                mCurrentViewCell = mCurrentViewCell->GetParent(); 
    131131        } 
     
    160160                        const char *ptr = attrValue.LocalForm(); 
    161161                         
     162                        //-- the view cells manager is created here 
    162163                        CreateViewCellsManager(ptr); 
    163164                } 
     
    171172        if (element == "Interior")  
    172173        { 
    173                 cout << "["; 
     174                Debug << "["; 
    174175                StartBspInterior(attributes); 
    175176        } 
     
    177178        if (element == "Leaf")  
    178179        { 
    179                 cout << "l"; 
     180                Debug << "l"; 
    180181                Debug << "leaf" << endl; 
    181182                StartBspLeaf(attributes); 
     
    189190        StrX lname(name); 
    190191        string element(lname.LocalForm()); 
    191  
     192         
    192193        // decides the used view cell hierarchy 
    193194        if (element == "ViewCells") 
    194195        { 
    195                 cout << "parsing view cells" << endl; 
     196                Debug << "parsing view cells" << endl; 
    196197                mParseViewCells = true; 
    197198        } 
     
    199200        if (element == "Hierarchy") 
    200201        { 
    201                 cout << "parsing spatial hierarchy" << endl; 
     202                Debug << "parsing spatial hierarchy" << endl; 
    202203                mParseViewCells = false; 
    203204                StartHierarchy(attributes); 
     
    207208        if (element == "ViewSpaceBox") 
    208209        { 
    209                 cout << "b"; 
     210                Debug << "b"; 
    210211                StartViewSpaceBox(attributes); 
    211212        } 
     
    234235                if (element == "Interior")  
    235236                { 
    236                         cout << "["; 
     237                        Debug << "["; 
    237238                        StartViewCellInterior(attributes); 
    238239                } 
     
    240241                if (element == "Leaf")  
    241242                { 
    242                         cout << "l"; 
     243                        Debug << "l"; 
    243244                        StartViewCellLeaf(attributes); 
    244245                } 
     
    306307                                  // to sumof pdfs, i.e. its relative visibility 
    307308                                  // temporarily set to 1.0f 
    308                                         viewCell->GetPvs().AddSample(obj, 1.0f); 
     309                                        viewCell->GetPvs().AddSample(obj, 1.0f);                                 
    309310                                } 
    310311                                else 
     
    559560                mVspBspTree = new VspBspTree(); 
    560561                //mCurrentBspNode = mVspBspTree->GetRoot(); 
    561  
    562562                mViewCellsManager = new VspBspViewCellsManager(mVspBspTree); 
    563563 
     
    573573        else 
    574574        { 
    575                 cerr<<"Wrong view cells type " << name << "!!!" << endl; 
     575                cerr << "Wrong view cells type: " << name << endl; 
    576576                exit(1); 
    577577        } 
     
    700700    catch (const XMLException& e) 
    701701      { 
    702         XERCES_STD_QUALIFIER cerr << "\nError during parsing: \n" 
     702                        XERCES_STD_QUALIFIER cerr << "\nError during parsing: \n" 
    703703                                  << StrX(e.getMessage()) 
    704704                                  << "\n" << XERCES_STD_QUALIFIER endl; 
    705         errorCount = 1; 
    706         return false; 
     705                        errorCount = 1; 
     706                        return false; 
    707707      } 
    708708 
     
    710710    // Print out the stats that we collected and time taken 
    711711    if (!errorCount) { 
    712       XERCES_STD_QUALIFIER cout << filename << ": " << duration << " ms (" 
     712                XERCES_STD_QUALIFIER cerr << filename << ": " << duration << " ms (" 
    713713                                << handler.GetElementCount() << " elems, " 
    714714                                << handler.GetAttrCount() << " attrs, " 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r863 r870  
    5555 
    5656 
    57 VspBspTree::VspBspTree(): 
     57VspBspTree::VspBspTree(Environment *env): 
    5858mRoot(NULL), 
    5959mUseAreaForPvs(false), 
     
    6767{ 
    6868        bool randomize = false; 
    69         environment->GetBoolValue("VspBspTree.Construction.randomize", randomize); 
     69        env->GetBoolValue("VspBspTree.Construction.randomize", randomize); 
    7070        if (randomize) 
    7171                Randomize(); // initialise random generator for heuristics 
    7272 
    7373        //-- termination criteria for autopartition 
    74         environment->GetIntValue("VspBspTree.Termination.maxDepth", mTermMaxDepth); 
    75         environment->GetIntValue("VspBspTree.Termination.minPvs", mTermMinPvs); 
    76         environment->GetIntValue("VspBspTree.Termination.minRays", mTermMinRays); 
    77         environment->GetFloatValue("VspBspTree.Termination.minProbability", mTermMinProbability); 
    78         environment->GetFloatValue("VspBspTree.Termination.maxRayContribution", mTermMaxRayContribution); 
    79         environment->GetFloatValue("VspBspTree.Termination.minAccRayLenght", mTermMinAccRayLength); 
    80         environment->GetFloatValue("VspBspTree.Termination.maxCostRatio", mTermMaxCostRatio); 
    81         environment->GetIntValue("VspBspTree.Termination.missTolerance", mTermMissTolerance); 
    82         environment->GetIntValue("VspBspTree.Termination.maxViewCells", mMaxViewCells); 
     74        env->GetIntValue("VspBspTree.Termination.maxDepth", mTermMaxDepth); 
     75        env->GetIntValue("VspBspTree.Termination.minPvs", mTermMinPvs); 
     76        env->GetIntValue("VspBspTree.Termination.minRays", mTermMinRays); 
     77        env->GetFloatValue("VspBspTree.Termination.minProbability", mTermMinProbability); 
     78        env->GetFloatValue("VspBspTree.Termination.maxRayContribution", mTermMaxRayContribution); 
     79        env->GetFloatValue("VspBspTree.Termination.minAccRayLenght", mTermMinAccRayLength); 
     80        env->GetFloatValue("VspBspTree.Termination.maxCostRatio", mTermMaxCostRatio); 
     81        env->GetIntValue("VspBspTree.Termination.missTolerance", mTermMissTolerance); 
     82        env->GetIntValue("VspBspTree.Termination.maxViewCells", mMaxViewCells); 
    8383 
    8484        //-- max cost ratio for early tree termination 
    85         environment->GetFloatValue("VspBspTree.Termination.maxCostRatio", mTermMaxCostRatio); 
    86  
    87         environment->GetFloatValue("VspBspTree.Termination.minGlobalCostRatio", mTermMinGlobalCostRatio); 
    88         environment->GetIntValue("VspBspTree.Termination.globalCostMissTolerance", mTermGlobalCostMissTolerance); 
     85        env->GetFloatValue("VspBspTree.Termination.maxCostRatio", mTermMaxCostRatio); 
     86 
     87        env->GetFloatValue("VspBspTree.Termination.minGlobalCostRatio", mTermMinGlobalCostRatio); 
     88        env->GetIntValue("VspBspTree.Termination.globalCostMissTolerance", mTermGlobalCostMissTolerance); 
    8989 
    9090        // HACK//mTermMinPolygons = 25; 
    9191 
    9292        //-- factors for bsp tree split plane heuristics 
    93         environment->GetFloatValue("VspBspTree.Factor.pvs", mPvsFactor); 
    94         environment->GetFloatValue("VspBspTree.Termination.ct_div_ci", mCtDivCi); 
     93        env->GetFloatValue("VspBspTree.Factor.pvs", mPvsFactor); 
     94        env->GetFloatValue("VspBspTree.Termination.ct_div_ci", mCtDivCi); 
    9595 
    9696 
    9797        //-- partition criteria 
    98         environment->GetIntValue("VspBspTree.maxPolyCandidates", mMaxPolyCandidates); 
    99         environment->GetIntValue("VspBspTree.maxRayCandidates", mMaxRayCandidates); 
    100         environment->GetIntValue("VspBspTree.splitPlaneStrategy", mSplitPlaneStrategy); 
    101  
    102         environment->GetFloatValue("VspBspTree.Construction.epsilon", mEpsilon); 
    103         environment->GetIntValue("VspBspTree.maxTests", mMaxTests); 
     98        env->GetIntValue("VspBspTree.maxPolyCandidates", mMaxPolyCandidates); 
     99        env->GetIntValue("VspBspTree.maxRayCandidates", mMaxRayCandidates); 
     100        env->GetIntValue("VspBspTree.splitPlaneStrategy", mSplitPlaneStrategy); 
     101 
     102        env->GetFloatValue("VspBspTree.Construction.epsilon", mEpsilon); 
     103        env->GetIntValue("VspBspTree.maxTests", mMaxTests); 
    104104 
    105105        // if only the driving axis is used for axis aligned split 
    106         environment->GetBoolValue("VspBspTree.splitUseOnlyDrivingAxis", mOnlyDrivingAxis); 
     106        env->GetBoolValue("VspBspTree.splitUseOnlyDrivingAxis", mOnlyDrivingAxis); 
    107107         
    108108        //-- termination criteria for axis aligned split 
    109         environment->GetFloatValue("VspBspTree.Termination.AxisAligned.maxRayContribution",  
     109        env->GetFloatValue("VspBspTree.Termination.AxisAligned.maxRayContribution",  
    110110                                                                mTermMaxRayContriForAxisAligned); 
    111         environment->GetIntValue("VspBspTree.Termination.AxisAligned.minRays", 
     111        env->GetIntValue("VspBspTree.Termination.AxisAligned.minRays", 
    112112                                                         mTermMinRaysForAxisAligned); 
    113113 
    114         //environment->GetFloatValue("VspBspTree.maxTotalMemory", mMaxTotalMemory); 
    115         environment->GetFloatValue("VspBspTree.maxStaticMemory", mMaxMemory); 
    116  
    117         environment->GetFloatValue("VspBspTree.Construction.renderCostWeight", mRenderCostWeight); 
    118         environment->GetBoolValue("VspBspTree.usePolygonSplitIfAvailable", mUsePolygonSplitIfAvailable); 
    119  
    120         environment->GetBoolValue("VspBspTree.useCostHeuristics", mUseCostHeuristics); 
    121         environment->GetBoolValue("VspBspTree.useSplitCostQueue", mUseSplitCostQueue); 
    122         environment->GetBoolValue("VspBspTree.simulateOctree", mCirculatingAxis); 
    123         environment->GetBoolValue("VspBspTree.useRandomAxis", mUseRandomAxis); 
    124         environment->GetIntValue("VspBspTree.nodePriorityQueueType", mNodePriorityQueueType); 
    125  
    126         environment->GetBoolValue("ViewCells.PostProcess.emptyViewCellsMerge", mEmptyViewCellsMergeAllowed); 
     114        //env->GetFloatValue("VspBspTree.maxTotalMemory", mMaxTotalMemory); 
     115        env->GetFloatValue("VspBspTree.maxStaticMemory", mMaxMemory); 
     116 
     117        env->GetFloatValue("VspBspTree.Construction.renderCostWeight", mRenderCostWeight); 
     118        env->GetBoolValue("VspBspTree.usePolygonSplitIfAvailable", mUsePolygonSplitIfAvailable); 
     119 
     120        env->GetBoolValue("VspBspTree.useCostHeuristics", mUseCostHeuristics); 
     121        env->GetBoolValue("VspBspTree.useSplitCostQueue", mUseSplitCostQueue); 
     122        env->GetBoolValue("VspBspTree.simulateOctree", mCirculatingAxis); 
     123        env->GetBoolValue("VspBspTree.useRandomAxis", mUseRandomAxis); 
     124        env->GetIntValue("VspBspTree.nodePriorityQueueType", mNodePriorityQueueType); 
     125 
     126        env->GetBoolValue("ViewCells.PostProcess.emptyViewCellsMerge", mEmptyViewCellsMergeAllowed); 
    127127         
    128128        char subdivisionStatsLog[100]; 
    129         environment->GetStringValue("VspBspTree.subdivisionStats", subdivisionStatsLog); 
     129        env->GetStringValue("VspBspTree.subdivisionStats", subdivisionStatsLog); 
    130130        mSubdivisionStats.open(subdivisionStatsLog); 
    131131 
    132         environment->GetFloatValue("VspBspTree.Construction.minBand", mMinBand); 
    133         environment->GetFloatValue("VspBspTree.Construction.maxBand", mMaxBand); 
    134         environment->GetBoolValue("VspBspTree.Construction.useDrivingAxisForMaxCost", mUseDrivingAxisForMaxCost); 
     132        env->GetFloatValue("VspBspTree.Construction.minBand", mMinBand); 
     133        env->GetFloatValue("VspBspTree.Construction.maxBand", mMaxBand); 
     134        env->GetBoolValue("VspBspTree.Construction.useDrivingAxisForMaxCost", mUseDrivingAxisForMaxCost); 
    135135 
    136136        //-- debug output 
     
    199199} 
    200200 
     201VspBspTree::VspBspTree(): 
     202mRoot(NULL), 
     203mUseAreaForPvs(false), 
     204mCostNormalizer(Limits::Small), 
     205mViewCellsManager(NULL), 
     206mOutOfBoundsCell(NULL), 
     207mStoreRays(false), 
     208mRenderCostWeight(0.5), 
     209mUseRandomAxis(false), 
     210mTimeStamp(1), 
     211mEpsilon(1e-6f) 
     212{ 
     213} 
    201214 
    202215BspViewCell *VspBspTree::GetOutOfBoundsCell() 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h

    r863 r870  
    2626class Beam; 
    2727class ViewCellsTree; 
    28  
     28class Environment; 
    2929 
    3030/** 
     
    199199        VspBspTree(); 
    200200 
     201         
     202        /** Constructor creating an empty tree. Loads parameters  
     203                from an environment file. 
     204        */  
     205        VspBspTree(Environment *env); 
     206 
    201207        /** Default destructor. 
    202208        */ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp

    r863 r870  
    219219        if (mLoadPolygonsAsMeshes) 
    220220        { 
    221                  
    222                 /*vector<VertexIndexContainer>::const_iterator it,  
    223                         it_end = mCurrentVertexIndices.end(); 
    224  
    225                 for (it = mCurrentVertexIndices.begin(); it != it_end; ++ it) 
    226                 { 
    227                         // only one face per mesh 
    228                         Mesh *mesh = new Mesh(); 
    229  
    230                         VertexIndexContainer vc; 
    231  
    232                         // add vertices 
    233                         for (int i = 0; i < (int)(*it).size(); ++ i) 
    234                         { 
    235                                 mesh->mVertices.push_back(mCurrentVertices[(*it)[i]]); 
    236                                 vc.push_back(i); 
    237                         } 
    238                          
    239                         mesh->mFaces.push_back(new Face(vc)); 
    240                          
    241                         // NOTE: should rather be written into trafo of mesh instance 
    242                         ApplyTransformations(mTransformations, mesh); 
    243  
    244                         mesh->Preprocess(); 
    245                         // make an instance of this mesh 
    246                         MeshInstance *mi = new MeshInstance(mesh); 
    247                         mCurrentNode->mGeometry.push_back(mi); 
    248  
    249                 }*/ 
    250  
    251221                //if (mCurrentMesh->mFaces.empty())     cout << "error!" << endl; 
    252222 
Note: See TracChangeset for help on using the changeset viewer.