Changeset 840


Ignore:
Timestamp:
04/27/06 11:57:28 (18 years ago)
Author:
mattausch
Message:

implementing bounding box hack

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

Legend:

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

    r704 r840  
    202202                if (poly) 
    203203                { 
    204                         poly->AddToMesh(*mMesh); 
     204                        IncludePolyInMesh(*poly, *mMesh); 
    205205                } 
    206206        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r837 r840  
    13191319                                        "false"); 
    13201320 
    1321         RegisterOption("ViewCells.pvsExportMode", 
    1322                                         optInt, 
    1323                                         "view_cells_export_bounding_boxes=", 
    1324                                         "2"); 
     1321        RegisterOption("ViewCells.exportBboxesForPvs", 
     1322                                        optBool, 
     1323                                        "view_cells_export_bboxes=", 
     1324                                        "true"); 
     1325 
     1326         
     1327        RegisterOption("ViewCells.boxesFilename", 
     1328                                        optString, 
     1329                                        "view_cells_boxes_filename=", 
     1330                                        "boxes.out"); 
     1331 
    13251332 
    13261333        RegisterOption("ViewCells.PostProcess.emptyViewCellsMerge", 
  • GTP/trunk/Lib/Vis/Preprocessing/src/FromPointVisibilityTree.cpp

    r822 r840  
    19541954 
    19551955#if 1 
    1956         // take render cost of node into account 
     1956        // also take render cost of node into account to avoid unsubdivided regions which 
     1957        // could reduce the render cost after some subdivisions 
    19571958        const float normalizedOldRenderCost = oldRenderCost / mBox.GetVolume(); 
    1958         //Debug << "rendercostdecr: " << 0.99f * renderCostDecrease << " old render cost: " << 0.01f * normalizedOldRenderCost << endl; 
    1959         //return 0.5f * renderCostDecrease + 0.5f * normalizedOldRenderCost; 
    19601959        return 0.99f * renderCostDecrease + 0.01f * normalizedOldRenderCost; 
    19611960#else 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.cpp

    r683 r840  
    498498 
    499499 
    500 void Polygon3::Triangulate(vector<Triangle3> &triangles) 
     500void Polygon3::Triangulate(vector<Triangle3> &triangles) const 
    501501{ 
    502502        int i = 1; 
     
    517517 
    518518 
    519 void Polygon3::Triangulate(VertexIndexContainer &indices) 
     519void Polygon3::Triangulate(VertexIndexContainer &indices) const 
    520520{ 
    521521        int i = 1; 
     
    539539 
    540540 
    541 void Polygon3::AddToMesh(Mesh &mesh) 
     541void IncludePolyInMesh(const Polygon3 &poly, Mesh &mesh) 
    542542{ 
    543543        const int n = (int)mesh.mVertices.size(); 
    544544 
    545545    //-- add the vertices 
    546     VertexContainer::const_iterator vit, vit_end = mVertices.end(); 
    547         for (vit = mVertices.begin(); vit != vit_end; ++ vit) 
     546    VertexContainer::const_iterator vit, vit_end = poly.mVertices.end(); 
     547        for (vit = poly.mVertices.begin(); vit != vit_end; ++ vit) 
    548548        { 
    549549                mesh.mVertices.push_back(*vit); 
     
    551551 
    552552        // one quad => no triangulation necessary 
    553         if ((int)mVertices.size() == 4) 
     553        if (poly.mVertices.size() == 4) 
    554554        { 
    555555                mesh.AddFace(new Face(n, n + 1, n + 2, n + 3)); 
    556         } 
    557         else 
    558         { 
    559                 VertexIndexContainer indices; 
    560                 Triangulate(indices); 
    561  
    562                 // add indices of triangle strip 
    563                 for (int i = 0; i < (int)indices.size(); i += 3) 
    564                 { 
    565                         Face *face = new Face(n + indices[i],  
    566                                                                   n + indices[i + 1],  
    567                                                                   n + indices[i + 2]); 
    568                         mesh.AddFace(face); 
    569                 } 
    570         } 
    571 } 
     556                return; 
     557        } 
     558         
     559        VertexIndexContainer indices; 
     560        poly.Triangulate(indices); 
     561 
     562        // add indices of triangle strip 
     563        for (int i = 0; i < (int)indices.size(); i += 3) 
     564        { 
     565                Face *face = new Face(n + indices[i],  
     566                                                          n + indices[i + 1],  
     567                                                          n + indices[i + 2]); 
     568                mesh.AddFace(face); 
     569        } 
     570} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.h

    r752 r840  
    100100        /** The polygon is converted to triangles. 
    101101        */ 
    102         void Triangulate(vector<Triangle3> &triangles); 
    103         /** 
    104                 Adds polygon to mesh description as a face 
    105         */ 
    106         void AddToMesh(Mesh &mesh); 
     102        void Triangulate(vector<Triangle3> &triangles) const; 
     103 
    107104        /**  
    108105                Triangle strip indices are created from this polgon. 
    109106        */ 
    110         void Triangulate(VertexIndexContainer &indices); 
     107        void Triangulate(VertexIndexContainer &indices) const; 
    111108         
    112109        /** The piercing rays of the polygon are inherited by the child fragments 
     
    153150        */ 
    154151        static float GetArea(const PolygonContainer &cell); 
     152 
     153        /** 
     154                Adds polygon to mesh description as a face 
     155        */ 
     156        friend void IncludePolyInMesh(const Polygon3 &poly, Mesh &mesh); 
    155157}; 
    156158 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r837 r840  
    1717 
    1818 
     19// HACK 
    1920static void AddGeometry(SceneGraph *scene) 
    2021{ 
     
    2627 
    2728        if (0){ 
    28         // form grrid of meshes 
     29        // form grid of boxes 
    2930        for (int i = 0; i < n; ++ i) 
    3031        { 
     
    3334                        const Vector3 scale2((float)j * 0.8 / n + 0.1,  0.05, (float)i * 0.8  / (float)n + 0.1); 
    3435                 
    35                         Vector3 pt2 = sceneBox.Min() + scale2 * (sceneBox.Max() - sceneBox.Min()); 
    36                  
    37                         Vector3 boxSize = sceneBox.Size() * Vector3(0.0025, 0.01, 0.0025); 
     36                        const Vector3 pt2 = sceneBox.Min() + scale2 * (sceneBox.Max() - sceneBox.Min()); 
     37                 
     38                        const Vector3 boxSize = sceneBox.Size() * Vector3(0.0025f, 0.01f, 0.0025f); 
    3839                        AxisAlignedBox3 box(pt2, pt2 + boxSize); 
    3940                        Mesh *mesh = CreateBox(box); 
     
    8485        scene->mRoot->UpdateBox(); 
    8586        } 
    86 // plane separating areas 
    87 if(1) 
    88 { 
    89 const Vector3 scale(1.0, 0.0, 0); 
    90  
    91     Vector3 pt = sceneBox.Min() + scale * (sceneBox.Max() - sceneBox.Min()); 
    92  
    93         Plane3 cuttingPlane(Vector3(1, 0, 0), pt); 
    94          
    95         Mesh *planeMesh = new Mesh(); 
    96          
    97         Polygon3 *poly = sceneBox.CrossSection(cuttingPlane); 
    98  
    99         poly->AddToMesh(*planeMesh); 
    100  
    101         planeMesh->Preprocess(); 
    102  
    103     MeshInstance *planeMi = new MeshInstance(planeMesh); 
    104     scene->mRoot->mGeometry.push_back(planeMi); 
    105 }        
     87         
     88        // plane separating view space regions 
     89        if (1) 
     90        { 
     91                const Vector3 scale(1.0, 0.0, 0); 
     92 
     93                Vector3 pt = sceneBox.Min() + scale * (sceneBox.Max() - sceneBox.Min()); 
     94 
     95                Plane3 cuttingPlane(Vector3(1, 0, 0), pt); 
     96                Mesh *planeMesh = new Mesh(); 
     97                 
     98                Polygon3 *poly = sceneBox.CrossSection(cuttingPlane); 
     99                IncludePolyInMesh(*poly, *planeMesh); 
     100                 
     101                planeMesh->Preprocess(); 
     102                 
     103                MeshInstance *planeMi = new MeshInstance(planeMesh); 
     104                scene->mRoot->mGeometry.push_back(planeMi); 
     105        }        
    106106} 
    107107 
     
    114114mViewCellsManager(NULL) 
    115115{ 
    116   environment->GetBoolValue("Preprocessor.useGlRenderer", mUseGlRenderer); 
     116        environment->GetBoolValue("Preprocessor.useGlRenderer", mUseGlRenderer); 
    117117   
    118   // renderer will be constructed when the scene graph and viewcell manager will be known 
    119   renderer = NULL; 
     118        // renderer will be constructed when the scene graph and viewcell manager will be known 
     119        renderer = NULL; 
    120120   
    121   environment->GetBoolValue("Preprocessor.useGlDebugger", mUseGlDebugger); 
    122   environment->GetBoolValue("Preprocessor.loadPolygonsAsMeshes", mLoadPolygonsAsMeshes); 
    123   environment->GetBoolValue("Preprocessor.quitOnFinish", mQuitOnFinish); 
    124   environment->GetBoolValue("Preprocessor.computeVisibility", mComputeVisibility); 
    125   environment->GetBoolValue("Preprocessor.detectEmptyViewSpace", mDetectEmptyViewSpace); 
    126    
    127   Debug << "detect empty view space=" << mDetectEmptyViewSpace << endl; 
    128   Debug << "load polygons as meshes: " << mLoadPolygonsAsMeshes << endl; 
    129  
     121        environment->GetBoolValue("Preprocessor.useGlDebugger", mUseGlDebugger); 
     122        environment->GetBoolValue("Preprocessor.loadPolygonsAsMeshes", mLoadPolygonsAsMeshes); 
     123        environment->GetBoolValue("Preprocessor.quitOnFinish", mQuitOnFinish); 
     124        environment->GetBoolValue("Preprocessor.computeVisibility", mComputeVisibility); 
     125        environment->GetBoolValue("Preprocessor.detectEmptyViewSpace", mDetectEmptyViewSpace); 
     126 
     127        Debug << "detect empty view space=" << mDetectEmptyViewSpace << endl; 
     128        Debug << "load polygons as meshes: " << mLoadPolygonsAsMeshes << endl; 
    130129} 
    131130 
     
    143142  cout << "done.\n"; 
    144143 
    145   cout<<"Deleting kd tree...\n"; 
     144  cout << "Deleting kd tree...\n"; 
    146145  DEL_PTR(mKdTree); 
    147   cout<<"done.\n"; 
     146  cout << "done.\n"; 
    148147   
    149   cout<<"Deleting vspkd tree...\n"; 
     148  cout << "Deleting vspkd tree...\n"; 
    150149  DEL_PTR(mVspKdTree); 
    151   cout<<"done.\n"; 
    152  
    153   cout<<"Deleting vspbsp tree...\n"; 
     150  cout << "done.\n"; 
     151 
     152  cout << "Deleting vspbsp tree...\n"; 
    154153  DEL_PTR(mVspBspTree); 
    155   cout<<"done.\n"; 
     154  cout << "done.\n"; 
    156155} 
    157156 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r837 r840  
    19591959 
    19601960 
    1961 bool ViewCellsTree::Export(ofstream &stream, const int pvsType) 
    1962 { 
    1963         // export recurvivly all view cells from the root 
    1964         ExportViewCell(mRoot, stream, pvsType); 
     1961bool ViewCellsTree::Export(ofstream &stream) 
     1962{ 
     1963        // export recursivly all view cells from the root 
     1964        ExportViewCell(mRoot, stream); 
    19651965 
    19661966        return true; 
     
    19961996 
    19971997 
    1998 void ViewCellsTree::ExportPvs(ViewCell *viewCell, ofstream &stream, const int pvsType) 
     1998void ViewCellsTree::ExportPvs(ViewCell *viewCell, ofstream &stream) 
    19991999{ 
    20002000        ObjectPvsMap::iterator it, it_end = viewCell->GetPvs().mEntries.end(); 
     
    20022002        for (it = viewCell->GetPvs().mEntries.begin(); it != it_end; ++ it) 
    20032003        { 
    2004                 switch (pvsType) 
    2005                 { 
    2006                 case EXPORT_IDS: 
    2007             { 
    2008                                 stream << (*it).first->GetId() << " "; 
    2009                         } 
    2010                         break; 
    2011                 case EXPORT_BBOXES: 
    2012                         { 
    2013                                 Debug << "here24 " << pvsType << endl; 
    2014                                 MeshInstance *mi = dynamic_cast<MeshInstance *>((*it).first); 
    2015                                 AxisAlignedBox3 box = mi->GetBox(); 
    2016                                 stream << "<BoundingBox"  
    2017                                            << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\"" 
    2018                                            << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl; 
    2019                         } 
    2020                         break; 
    2021                 case EXPORT_EMPTY_PVS: 
    2022                 default: 
    2023                         break; 
    2024                 } 
    2025         } 
    2026 } 
    2027  
    2028  
    2029 void ViewCellsTree::ExportViewCell(ViewCell *viewCell, ofstream &stream, const int pvsType) 
     2004                stream << (*it).first->GetId() << " "; 
     2005        } 
     2006} 
     2007 
     2008 
     2009void ViewCellsTree::ExportViewCell(ViewCell *viewCell, ofstream &stream) 
    20302010{ 
    20312011        if (viewCell->IsLeaf()) 
     
    20382018                 
    20392019                //-- export pvs 
    2040                 Debug << "here66 " << pvsType << endl; 
    2041                 ExportPvs(viewCell, stream, pvsType); 
     2020                if (0) 
     2021                        ExportPvs(viewCell, stream); 
    20422022         
    20432023                stream << "\" />" << endl; 
     
    20582038                { 
    20592039                        stream << "pvs=\""; 
    2060                         ExportPvs(viewCell, stream, pvsType); 
     2040                        ExportPvs(viewCell, stream); 
    20612041                } 
    20622042 
     
    20682048                for (it = interior->mChildren.begin(); it != it_end; ++ it) 
    20692049                { 
    2070                         ExportViewCell(*it, stream, pvsType); 
     2050                        ExportViewCell(*it, stream); 
    20712051                } 
    20722052 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h

    r837 r840  
    388388        enum {PVS_IN_INTERIORS, COMPRESSED, PVS_IN_LEAVES}; 
    389389 
    390         enum {EXPORT_EMPTY_PVS, EXPORT_IDS, EXPORT_BBOXES}; 
    391  
     390         
    392391        /** If view cells in this tree have compressed pvs. 
    393392        */ 
     
    408407        /** Exports view cells to file. 
    409408        */ 
    410     bool Export(ofstream &stream, const int pvsType = EXPORT_EMPTY_PVS); 
     409    bool Export(ofstream &stream); 
    411410 
    412411        /** Export statistics of this view cell tree. 
     
    512511                NOTE: should be in exporter!! 
    513512        */ 
    514         void ExportViewCell(ViewCell *viewCell, ofstream &stream, const int pvsType); 
     513        void ExportViewCell(ViewCell *viewCell, ofstream &stream); 
    515514 
    516515        /** Exports pvs of a view cell. 
    517516        */ 
    518         void ExportPvs(ViewCell *viewCell, ofstream &stream, const int pvsType); 
     517        void ExportPvs(ViewCell *viewCell, ofstream &stream); 
    519518 
    520519 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp

    r744 r840  
    30753075} 
    30763076 
    3077  
    3078 void BspNodeGeometry::AddToMesh(Mesh &mesh) 
    3079 { 
    3080         PolygonContainer::const_iterator it, it_end = mPolys.end(); 
    3081          
    3082         for (it = mPolys.begin(); it != mPolys.end(); ++ it) 
    3083         { 
    3084                 (*it)->AddToMesh(mesh); 
     3077void IncludeNodeGeomInMesh(const BspNodeGeometry &geom, Mesh &mesh) 
     3078{ 
     3079        // add single polygons to mesh 
     3080        PolygonContainer::const_iterator it, it_end = geom.mPolys.end(); 
     3081         
     3082        for (it = geom.mPolys.begin(); it != geom.mPolys.end(); ++ it) 
     3083        { 
     3084                Polygon3 *poly = (*it); 
     3085                IncludePolyInMesh(*poly, mesh); 
    30853086        } 
    30863087} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.h

    r748 r840  
    8282        Polygon3 *SplitPolygon(Polygon3 *poly, const float epsilon) const; 
    8383 
    84         /** Adds node geometry to mesh. 
    85                 @note the mesh vertices will not be connected 
    86         */ 
    87         void AddToMesh(Mesh &mesh); 
    88  
    8984        /** Computes mass center of bsp node geometry. 
    9085        */ 
     
    109104        */ 
    110105        void Add(Polygon3 *p, const Plane3 &plane); 
     106 
     107        /** Adds node geometry to mesh. 
     108                @note the mesh vertices will not be connected 
     109        */ 
     110        friend void IncludeNodeGeomInMesh(const BspNodeGeometry &geom, Mesh &mesh); 
    111111 
    112112protected: 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r837 r840  
    9393        environment->GetIntValue("ViewCells.renderCostEvaluationType", mRenderCostEvaluationType); 
    9494 
    95         environment->GetIntValue("ViewCells.pvsExportMode", mPvsExportMode); 
     95        environment->GetBoolValue("ViewCells.exportBboxesForPvs", mExportBboxesForPvs); 
    9696 
    9797        char buf[100]; 
     
    16771677                if (viewcell->GetValid()) 
    16781678                { 
    1679                         // HACK 
    1680 #if TEST_EMPTY_VIEW_CELLS 
    1681                                 for (int i = 0; i < mEmptyViewCells.size(); ++i) 
    1682                                 { 
    1683                                         if (viewcell == mEmptyViewCells[i]) 
    1684                                         { 
    1685                                                 viewcell->mPiercingRays.push_back(new Ray(ray)); 
    1686                                                 Debug << "empty view cell ray found: " << ray.mOriginObject << ", " << ray.mTerminationObject << endl; 
    1687                                         } 
    1688                                 } 
    1689 #endif 
    16901679                        // if ray not outside of view space 
    16911680                        float contribution; 
     
    16991688                        } 
    17001689 
    1701                         //for directional sampling it is important to count only contributions 
     1690                        // for directional sampling it is important to count only contributions 
    17021691                        // made in one direction!!! 
    17031692                        // the other contributions of this sample will be counted for the oposite ray! 
     
    18581847} 
    18591848 
     1849 
     1850int ViewCellsManager::GetMaxFilterSize() const 
     1851{ 
     1852        return mMaxFilterSize;   
     1853} 
     1854 
     1855static const bool USE_ASCII = true; 
     1856 
     1857bool ViewCellsManager::ExportBoundingBoxes(const string filename,  
     1858                                                                                   const ObjectContainer &objects) const 
     1859{ 
     1860        ObjectContainer::const_iterator it, it_end = objects.end(); 
     1861         
     1862        if (USE_ASCII) 
     1863        { 
     1864                ofstream boxesOut(filename.c_str()); 
     1865                if (!boxesOut.is_open()) 
     1866                        return false; 
     1867 
     1868                for (it = objects.begin(); it != it_end; ++ it) 
     1869                { 
     1870                        MeshInstance *mi = dynamic_cast<MeshInstance *>(*it); 
     1871                        const AxisAlignedBox3 box = mi->GetBox(); 
     1872 
     1873                        boxesOut << mi->GetId() << " "  
     1874                                         << box.Min().x << " "  
     1875                                         << box.Min().y << " "  
     1876                                         << box.Min().z << " "  
     1877                                         << box.Max().x << " "  
     1878                                         << box.Max().y << " "  
     1879                     << box.Max().z << endl;     
     1880                } 
     1881 
     1882                boxesOut.close(); 
     1883        } 
     1884        else 
     1885        { 
     1886                ofstream boxesOut(filename.c_str(), ios::binary); 
     1887 
     1888                if (!boxesOut.is_open()) 
     1889                        return false; 
     1890 
     1891                for (it = objects.begin(); it != it_end; ++ it) 
     1892                {        
     1893                        MeshInstance *mi = dynamic_cast<MeshInstance *>(*it); 
     1894                        const AxisAlignedBox3 box = mi->GetBox(); 
     1895                        Vector3 bmin = box.Min(); 
     1896                        Vector3 bmax = box.Max(); 
     1897 
     1898                        boxesOut.write(reinterpret_cast<char *>(&bmin), sizeof(Vector3)); 
     1899                        boxesOut.write(reinterpret_cast<char *>(&bmax), sizeof(Vector3)); 
     1900                } 
     1901                 
     1902                boxesOut.close(); 
     1903        } 
     1904 
     1905 
     1906        return true; 
     1907} 
     1908 
     1909 
     1910// use ascii format to store rays 
     1911#define USE_ASCII 0 
     1912 
     1913 
     1914inline bool ilt(Intersectable *obj1, Intersectable *obj2) 
     1915{ 
     1916        return obj1->mId < obj2->mId; 
     1917} 
     1918 
     1919/* 
     1920bool Preprocessor::LoadBoundingBoxes(const string filename,  
     1921                                                                         const ObjectContainer &objects) const 
     1922{ 
     1923        std::stable_sort(objects.begin(), objects.end(), ilt); 
     1924        char fileName[100]; 
     1925        environment->GetStringValue("Preprocessor.samplesFilename", fileName); 
     1926         
     1927    Vector3 origin, termination; 
     1928        // HACK: needed only for lower_bound algorithm to find the  
     1929        // intersected objects 
     1930        MeshInstance sObj(NULL); 
     1931        MeshInstance tObj(NULL); 
     1932 
     1933#if USE_ASCII 
     1934        ifstream samplesIn(fileName); 
     1935        if (!samplesIn.is_open()) 
     1936                return false; 
     1937 
     1938        string buf; 
     1939        while (!(getline(samplesIn, buf)).eof()) 
     1940        { 
     1941                sscanf(buf.c_str(), "%f %f %f %f %f %f %d %d",  
     1942                           &origin.x, &origin.y, &origin.z, 
     1943                           &termination.x, &termination.y, &termination.z,  
     1944                           &(sObj.mId), &(tObj.mId)); 
     1945                 
     1946                Intersectable *sourceObj = NULL; 
     1947                Intersectable *termObj = NULL; 
     1948                 
     1949                if (sObj.mId >= 0) 
     1950                { 
     1951                        ObjectContainer::iterator oit = 
     1952                                lower_bound(objects.begin(), objects.end(), &sObj, ilt); 
     1953                        sourceObj = *oit; 
     1954                } 
     1955                 
     1956                if (tObj.mId >= 0) 
     1957                { 
     1958                        ObjectContainer::iterator oit = 
     1959                                lower_bound(objects.begin(), objects.end(), &tObj, ilt); 
     1960                        termObj = *oit; 
     1961                } 
     1962 
     1963                samples.push_back(new VssRay(origin, termination, sourceObj, termObj)); 
     1964        } 
     1965#else 
     1966        ifstream samplesIn(fileName, ios::binary); 
     1967        if (!samplesIn.is_open()) 
     1968                return false; 
     1969 
     1970        while (1) 
     1971        { 
     1972                 samplesIn.read(reinterpret_cast<char *>(&origin), sizeof(Vector3)); 
     1973                 samplesIn.read(reinterpret_cast<char *>(&termination), sizeof(Vector3)); 
     1974                 samplesIn.read(reinterpret_cast<char *>(&(sObj.mId)), sizeof(int)); 
     1975                 samplesIn.read(reinterpret_cast<char *>(&(tObj.mId)), sizeof(int)); 
     1976                 
     1977                 if (samplesIn.eof()) 
     1978                        break; 
     1979 
     1980                Intersectable *sourceObj = NULL; 
     1981                Intersectable *termObj = NULL; 
     1982                 
     1983                if (sObj.mId >= 0) 
     1984                { 
     1985                        ObjectContainer::iterator oit = 
     1986                                lower_bound(objects.begin(), objects.end(), &sObj, ilt); 
     1987                        sourceObj = *oit; 
     1988                } 
     1989                 
     1990                if (tObj.mId >= 0) 
     1991                { 
     1992                        ObjectContainer::iterator oit = 
     1993                                lower_bound(objects.begin(), objects.end(), &tObj, ilt); 
     1994                        termObj = *oit; 
     1995                } 
     1996 
     1997                samples.push_back(new VssRay(origin, termination, sourceObj, termObj)); 
     1998        } 
     1999 
     2000#endif 
     2001        samplesIn.close(); 
     2002 
     2003        return true; 
     2004}*/ 
     2005 
    18602006/**********************************************************************/ 
    18612007/*                   BspViewCellsManager implementation               */ 
     
    21172263        if (mExportViewCells) 
    21182264        { 
    2119                 char buff[100]; 
    2120                 environment->GetStringValue("ViewCells.filename", buff); 
    2121                 string vcFilename(buff); 
    2122  
    2123                 ExportViewCells(buff); 
    2124         } 
     2265                char filename[100]; 
     2266                environment->GetStringValue("ViewCells.filename", filename); 
     2267                ExportViewCells(filename); 
     2268        } 
     2269         
     2270        // export bounding boxes 
     2271        if (mExportBboxesForPvs) 
     2272        { 
     2273                char filename[100]; 
     2274                environment->GetStringValue("ViewCells.boxesFilename", filename); 
     2275                ExportBoundingBoxes(filename, objects); 
     2276        } 
     2277 
    21252278 
    21262279        return 0; 
     
    24842637        Mesh *mesh = new Mesh(); 
    24852638 
    2486         geom.AddToMesh(*mesh); 
     2639        IncludeNodeGeomInMesh(geom, *mesh); 
    24872640        vc->SetMesh(mesh); 
     2641 
    24882642        // put mesh into mesh container so we can savely delete it 
    24892643        mMeshContainer.push_back(mesh); 
     
    25782732        //-- the type of the view cells hierarchy 
    25792733        //stream << "<Hierarchy name=\"bspTree\" />" << endl; 
    2580         stream << "<Hierarchy name=\"vspBspTree\" />" << endl; // write vsp bsp here because can use same tree and is bug free 
     2734        // NOTE: load in vsp bsp here because bsp and vsp bsp can use same tree and vsp bsp is bug free 
     2735        stream << "<Hierarchy name=\"vspBspTree\" />" << endl;  
     2736         
    25812737        //-- load the view cells itself, i.e., the ids and the pvs 
    25822738        stream << "<ViewCells>" << endl; 
    25832739 
    2584         mViewCellsTree->Export(stream, mPvsExportMode); 
     2740        mViewCellsTree->Export(stream); 
    25852741 
    25862742        stream << "</ViewCells>" << endl; 
     
    25972753 
    25982754        return true; 
    2599 } 
    2600  
    2601  
    2602 void BspViewCellsManager::AddCurrentViewCellsToHierarchy() 
    2603 { 
    2604         ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 
    2605         for (it = mViewCells.begin(); it != it_end; ++ it) 
    2606         { 
    2607                 ViewCell *vc = *it; 
    2608                 ViewCellContainer leaves; 
    2609                 mViewCellsTree->CollectLeaves(vc, leaves); 
    2610                  
    2611                 ViewCellContainer::const_iterator lit, lit_end = leaves.end(); 
    2612  
    2613                 for (lit = leaves.begin(); lit != lit_end; ++ lit) 
    2614                 { 
    2615                         BspViewCell *bspVc = dynamic_cast<BspViewCell *>(*lit); 
    2616                         bspVc->mLeaf->SetViewCell(vc); 
    2617                 } 
    2618         } 
    26192755} 
    26202756 
     
    37233859int VspBspViewCellsManager::PostProcess(const ObjectContainer &objects, 
    37243860                                                                                const VssRayContainer &rays) 
    3725 {Debug << "here8773" << endl; 
     3861{ 
    37263862        if (!ViewCellsConstructed()) 
    37273863        { 
     
    38123948 
    38133949        // collapse sibling leaves that share the same view cell 
    3814         if (0) 
    3815                 mVspBspTree->CollapseTree(); 
     3950        if (0) mVspBspTree->CollapseTree(); 
    38163951 
    38173952        // recompute view cell list and statistics 
     
    38213956        if (1) FinalizeViewCells(true); 
    38223957 
    3823  
    3824         Debug << "here3" << endl; 
    38253958        // write view cells to disc 
    38263959        if (mExportViewCells) 
    38273960        { 
    3828         Debug << "here4" << endl; 
    3829                 char buff[100]; 
    3830                 environment->GetStringValue("ViewCells.filename", buff); 
    3831                 string vcFilename(buff); 
    3832  
    3833                 ExportViewCells(buff); 
     3961                char filename[100]; 
     3962                environment->GetStringValue("ViewCells.filename", filename); 
     3963                ExportViewCells(filename); 
     3964        } 
     3965 
     3966         
     3967        // export bounding boxes 
     3968        if (mExportBboxesForPvs) 
     3969        { 
     3970                char filename[100]; 
     3971                environment->GetStringValue("ViewCells.boxesFilename", filename); 
     3972                ExportBoundingBoxes(filename, objects); 
    38343973        } 
    38353974 
     
    45064645         
    45074646        Mesh *mesh = new Mesh(); 
    4508         geom.AddToMesh(*mesh); 
     4647        IncludeNodeGeomInMesh(geom, *mesh); 
     4648 
    45094649        vc->SetMesh(mesh); 
    45104650        // put mesh into mesh container so we can savely delete it 
     
    45434683} 
    45444684 
    4545  
    4546 inline bool ilt(Intersectable *obj1, Intersectable *obj2) 
    4547 { 
    4548         return obj1->mId < obj2->mId; 
    4549 } 
    45504685 
    45514686 
     
    45674702                   << " max=\"" << mViewSpaceBox.Max().x << " " << mViewSpaceBox.Max().y << " " << mViewSpaceBox.Max().z << "\" />" << endl; 
    45684703 
     4704 
     4705 
    45694706        //-- the type of the view cells hierarchy 
    45704707        stream << "<Hierarchy name=\"vspBspTree\" />" << endl; 
    45714708 
    4572         //-- export the view cells itself, i.e., the ids and the pvs 
     4709        //-- export the view cells and the pvs 
    45734710        stream << "<ViewCells>" << endl; 
    4574         Debug << "**************************** mode: " << mPvsExportMode << endl; 
    4575         mViewCellsTree->Export(stream, mPvsExportMode); 
     4711         
     4712        mViewCellsTree->Export(stream); 
    45764713 
    45774714        stream << "</ViewCells>" << endl; 
     4715 
    45784716 
    45794717        //-- export the hierarchy 
     
    45814719        mVspBspTree->Export(stream); 
    45824720        stream << endl << "</Hierarchy>" << endl; 
     4721 
     4722 
    45834723 
    45844724        stream << "</Visibility_Solution>" << endl; 
     
    47344874 
    47354875 
    4736 void VspBspViewCellsManager::AddCurrentViewCellsToHierarchy() 
    4737 { 
    4738         ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 
    4739         for (it = mViewCells.begin(); it != it_end; ++ it) 
    4740         { 
    4741         } 
    4742 } 
    4743  
    47444876////////////////////////////////// 
    47454877ViewCellsManager *ViewCellsManagerFactory::Create(const string mName) 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r837 r840  
    392392        void SetMaxFilterSize(const int size); 
    393393 
    394   int GetMaxFilterSize() { 
    395         return mMaxFilterSize; 
    396   } 
    397  
    398   /** deletes interior nodes from the tree which have negative merge cost set (local merge) */ 
    399   void 
    400   DeleteLocalMergeTree(ViewCell *vc 
    401                                            ) const; 
     394        /** Returns maximal filter size. 
     395        */ 
     396        int GetMaxFilterSize() const; 
     397 
     398        /** Deletes interior nodes from the tree which have negative merge cost set (local merge). 
     399        */   
     400        void DeleteLocalMergeTree(ViewCell *vc) const; 
    402401   
    403402        /** Evaluautes histogram for a given number of view cells. 
     
    412411        */ 
    413412        float EvalRenderCost(Intersectable *obj) const; 
     413 
     414        /** Exports bounding boxes of objects to file. 
     415        */ 
     416        bool ExportBoundingBoxes(const string filename, const ObjectContainer &objects) const; 
     417 
    414418 
    415419protected: 
     
    499503 
    500504 
    501         int mPvsExportMode; 
     505 
     506 
     507 
     508        /// if bounding boxes should also be exported 
     509        bool mExportBboxesForPvs; 
     510                 
    502511 
    503512        Plane3 mClipPlane; 
     
    645654 
    646655 
    647         /** HACK 
    648         */ 
    649         void AddCurrentViewCellsToHierarchy(); 
    650  
    651656        void CollectViewCells(); 
    652657 
    653658        void ExportColor(Exporter *exporter, ViewCell *vc) const; 
    654659         
    655  
    656  
    657660        /// the BSP tree. 
    658661        BspTree *mBspTree; 
     
    873876        BspNode *GetSpatialNode(ViewCell *viewCell) const; 
    874877 
    875         /** HACK 
    876         */ 
    877         void AddCurrentViewCellsToHierarchy(); 
    878  
    879878        /** Merges the view cells. 
    880879        */ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VrmlExporter.cpp

    r712 r840  
    12381238        for (pit = polys.begin(); pit != pit_end; ++ pit) 
    12391239        { 
    1240                 (*pit)->AddToMesh(dummyMesh); 
     1240                Polygon3 *poly = (*pit); 
     1241                IncludePolyInMesh(*poly, dummyMesh); 
    12411242        } 
    12421243         
  • GTP/trunk/Lib/Vis/Preprocessing/src/X3dExporter.cpp

    r726 r840  
    11671167        for (pit = polys.begin(); pit != pit_end; ++ pit) 
    11681168        { 
    1169                 (*pit)->AddToMesh(dummyMesh); 
     1169                Polygon3 *poly = (*pit); 
     1170                IncludePolyInMesh(*poly, dummyMesh); 
    11701171        } 
    11711172         
  • GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp

    r822 r840  
    136136   
    137137  // clean up 
    138   //  DEL_PTR(p); 
    139   //  DEL_PTR(environment); 
     138  DEL_PTR(p); 
     139  DEL_PTR(environment); 
     140 
    140141  if (app) 
    141142        return app->exec(); 
Note: See TracChangeset for help on using the changeset viewer.