Ignore:
Timestamp:
09/09/05 15:03:48 (19 years ago)
Author:
mattausch
Message:

debugged bsp

Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/data/atlanta/atlanta_viewcells_large.x3d

    r261 r262  
    11<?xml version="1.0" encoding="UTF-8"?> 
    2 <X3D> 
    3 <Scene> 
    4 <Shape> 
    5 <Appearance> 
    6 <Material diffuseColor="0.500626 0.781793 0.596652" specularColor="0.0 0.0 0.0"/> 
    7 </Appearance> 
    8 <IndexedFaceSet ccw="TRUE" coordIndex=" 
    9 0 1 2 -1 
    10 5 4 3 -1 
    11 0 3 4 1 -1 
    12 1 4 5 2 -1 
    13 0 2 5 3 -1 
    14 " > 
    15 <Coordinate  point=" 
    16 3588 0 -2541, 
    17 3568 0 -2541, 
    18 3588 0 -2561, 
    19 3568 -10 -2541, 
    20 3568 -10 -2541, 
    21 3568 -10 -2541, 
    22 " > 
    23 </Coordinate> 
    24 </IndexedFaceSet> 
    25 </Shape> 
    26 <Shape> 
    27 <Appearance> 
    28 <Material diffuseColor="0.90437 0.792505 0.739937" specularColor="0.0 0.0 0.0"/> 
    29 </Appearance> 
    30 <IndexedFaceSet ccw="TRUE" coordIndex=" 
    31 0 1 2 -1 
    32 5 4 3 -1 
    33 0 3 4 1 -1 
    34 1 4 5 2 -1 
    35 0 2 5 3 -1 
    36 " > 
    37 <Coordinate  point=" 
    38 3558 0 -2540, 
    39 3578 0 -2540, 
    40 3558 0 -2560, 
    41 3578 10 -2540, 
    42 3578 10 -2540, 
    43 3578 10 -2540, 
    44 " > 
    45 </Coordinate> 
    46 </IndexedFaceSet> 
    47 </Shape> 
    48 <Shape> 
    49 <Appearance> 
    50 <Material diffuseColor="0.675146 0.947981 0.91142" specularColor="0.0 0.0 0.0"/> 
    51 </Appearance> 
    52 <IndexedFaceSet ccw="TRUE" coordIndex=" 
    53 0 1 2 -1 
    54 5 4 3 -1 
    55 0 3 4 1 -1 
    56 1 4 5 2 -1 
    57 0 2 5 3 -1 
    58 " > 
    59 <Coordinate  point=" 
    60 3552 0 -2921, 
    61 3572 0 -2921, 
    62 3552 0 -2941, 
    63 3572 10 -2921, 
    64 3572 10 -2921, 
    65 3572 10 -2921, 
    66 " > 
    67 </Coordinate> 
    68 </IndexedFaceSet> 
    69 </Shape> 
    70 <Shape> 
    71 <Appearance> 
    72 <Material diffuseColor="0.873302 0.587054 0.929472" specularColor="0.0 0.0 0.0"/> 
    73 </Appearance> 
    74 <IndexedFaceSet ccw="TRUE" coordIndex=" 
    75 0 1 2 -1 
    76 5 4 3 -1 
    77 0 3 4 1 -1 
    78 1 4 5 2 -1 
    79 0 2 5 3 -1 
    80 " > 
    81 <Coordinate  point=" 
    82 3484 0 -3315, 
    83 3504 0 -3315, 
    84 3484 0 -3335, 
    85 3504 10 -3315, 
    86 3504 10 -3315, 
    87 3504 10 -3315, 
    88 " > 
    89 </Coordinate> 
    90 </IndexedFaceSet> 
    91 </Shape> 
    92 <Shape> 
    93 <Appearance> 
    94 <Material diffuseColor="0.855251 0.756767 0.651997" specularColor="0.0 0.0 0.0"/> 
    95 </Appearance> 
    96 <IndexedFaceSet ccw="TRUE" coordIndex=" 
    97 0 1 2 -1 
    98 5 4 3 -1 
    99 0 3 4 1 -1 
    100 1 4 5 2 -1 
    101 0 2 5 3 -1 
    102 " > 
    103 <Coordinate  point=" 
    104 3175 0 -3323, 
    105 3195 0 -3323, 
    106 3175 0 -3343, 
    107 3195 10 -3323, 
    108 3195 10 -3323, 
    109 3195 10 -3323, 
    110 " > 
    111 </Coordinate> 
    112 </IndexedFaceSet> 
    113 </Shape> 
    114 <Shape> 
    115 <Appearance> 
    116 <Material diffuseColor="0.507492 0.545701 0.682226" specularColor="0.0 0.0 0.0"/> 
    117 </Appearance> 
    118 <IndexedFaceSet ccw="TRUE" coordIndex=" 
    119 0 1 2 -1 
    120 5 4 3 -1 
    121 0 3 4 1 -1 
    122 1 4 5 2 -1 
    123 0 2 5 3 -1 
    124 " > 
    125 <Coordinate  point=" 
    126 4034 0 -3655, 
    127 4054 0 -3655, 
    128 4034 0 -3675, 
    129 4054 10 -3655, 
    130 4054 10 -3655, 
    131 4054 10 -3655, 
    132 " > 
    133 </Coordinate> 
    134 </IndexedFaceSet> 
    135 </Shape> 
    136 <Shape> 
    137 <Appearance> 
    138 <Material diffuseColor="0.573656 0.582949 0.994263" specularColor="0.0 0.0 0.0"/> 
    139 </Appearance> 
    140 <IndexedFaceSet ccw="TRUE" coordIndex=" 
    141 0 1 2 -1 
    142 5 4 3 -1 
    143 0 3 4 1 -1 
    144 1 4 5 2 -1 
    145 0 2 5 3 -1 
    146 " > 
    147 <Coordinate  point=" 
    148 3407 0 -4380, 
    149 3427 0 -4380, 
    150 3407 0 -4400, 
    151 3427 10 -4380, 
    152 3427 10 -4380, 
    153 3427 10 -4380, 
    154 " > 
    155 </Coordinate> 
    156 </IndexedFaceSet> 
    157 </Shape> 
    158 <Shape> 
    159 <Appearance> 
    160 <Material diffuseColor="0.722846 0.559542 0.502335" specularColor="0.0 0.0 0.0"/> 
    161 </Appearance> 
    162 <IndexedFaceSet ccw="TRUE" coordIndex=" 
    163 0 1 2 -1 
    164 5 4 3 -1 
    165 0 3 4 1 -1 
    166 1 4 5 2 -1 
    167 0 2 5 3 -1 
    168 " > 
    169 <Coordinate  point=" 
    170 3005 0 -4968, 
    171 3025 0 -4968, 
    172 3005 0 -4988, 
    173 3025 10 -4968, 
    174 3025 10 -4968, 
    175 3025 10 -4968, 
    176 " > 
    177 </Coordinate> 
    178 </IndexedFaceSet> 
    179 </Shape> 
    180 <Shape> 
    181 <Appearance> 
    182 <Material diffuseColor="0.504456 0.68894 0.765831" specularColor="0.0 0.0 0.0"/> 
    183 </Appearance> 
    184 <IndexedFaceSet ccw="TRUE" coordIndex=" 
    185 0 1 2 -1 
    186 5 4 3 -1 
    187 0 3 4 1 -1 
    188 1 4 5 2 -1 
    189 0 2 5 3 -1 
    190 " > 
    191 <Coordinate  point=" 
    192 5143 0 -4990, 
    193 5163 0 -4990, 
    194 5143 0 -5010, 
    195 5163 10 -4990, 
    196 5163 10 -4990, 
    197 5163 10 -4990, 
    198 " > 
    199 </Coordinate> 
    200 </IndexedFaceSet> 
    201 </Shape> 
    202 <Shape> 
    203 <Appearance> 
    204 <Material diffuseColor="0.785592 0.800882 0.803583" specularColor="0.0 0.0 0.0"/> 
    205 </Appearance> 
    206 <IndexedFaceSet ccw="TRUE" coordIndex=" 
    207 0 1 2 -1 
    208 5 4 3 -1 
    209 0 3 4 1 -1 
    210 1 4 5 2 -1 
    211 0 2 5 3 -1 
    212 " > 
    213 <Coordinate  point=" 
    214 5355 0 -4195, 
    215 5375 0 -4195, 
    216 5355 0 -4205, 
    217 5375 10 -4195, 
    218 5375 10 -4195, 
    219 5375 10 -4195, 
    220 " > 
    221 </Coordinate> 
    222 </IndexedFaceSet> 
    223 </Shape> 
     2<X3D profile="Full"> 
     3  <Scene> 
     4  <Shape > 
     5      <IndexedFaceSet  coordIndex=" 0 1 2 -1 3 4 5 -1 6 7 8 -1 9 10 11 -1 12 13 14 -1 15 16 17 -1 18 19 20 -1 21 22 23 -1 24 25 26 -1 27 28 29 -1"> 
     6          <Coordinate  point="3588.0 0.0 -2541.0, 3568.0 0.0 -2541.0, 3588.0 0.0 -2561.0, 3558.0 0.0 -2540.0, 3578.0 0.0 -2540.0, 3558.0 0.0 -2560.0, 3552.0 0.0 -2921.0, 3572.0 0.0 -2921.0, 3552.0 0.0 -2941.0, 3484.0 0.0 -3315.0, 3504.0 0.0 -3315.0, 3484.0 0.0 -3335.0, 3175.0 0.0 -3323.0, 3195.0 0.0 -3323.0, 3175.0 0.0 -3343.0, 4034.0 0.0 -3655.0, 4054.0 0.0 -3655.0, 4034.0 0.0 -3675.0, 3407.0 0.0 -4380.0, 3427.0 0.0 -4380.0, 3407.0 0.0 -4400.0, 3005.0 0.0 -4968.0, 3025.0 0.0 -4968.0, 3005.0 0.0 -4988.0, 5143.0 0.0 -4990.0, 5163.0 0.0 -4990.0, 5143.0 0.0 -5010.0, 5355.0 0.0 -4195.0, 5375.0 0.0 -4195.0, 5355.0 0.0 -4205.0, "/> 
     7      </IndexedFaceSet> 
     8  </Shape> 
     9  </Scene> 
     10 
     11</X3D> 
  • trunk/VUT/GtpVisibilityPreprocessor/include/Polygon3.h

    r238 r262  
    4646        int Side(Plane3 *plane); 
    4747 
    48         /** Deletes all polygons om the queue. 
    49         */ 
    50         static void DeletePolygons(PolygonContainer *polys); 
    51  
    5248        /// vertices are connected in counterclockwise order. 
    5349        VertexContainer mVertices; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.cpp

    r261 r262  
    1212Polygon3::Polygon3(Face *face, Mesh *parent) 
    1313{ 
    14         VertexIndexContainer::const_iterator it; 
     14        VertexIndexContainer::reverse_iterator it = face->mVertexIndices.rbegin(); 
    1515 
    16         for (it = face->mVertexIndices.begin(); it != face->mVertexIndices.end(); ++ it) 
     16        for (; it != face->mVertexIndices.rend();  ++it) 
    1717        { 
    1818                mVertices.push_back(parent->mVertices[*it]); 
    1919                mMaterial = parent->mMaterial; 
    2020                 
    21                 Debug << parent->mVertices[*it] << endl; 
     21                //Debug << parent->mVertices[*it] << endl; 
    2222        } 
    2323} 
     
    3131#endif 
    3232        return Plane3(mVertices[0], mVertices[1], mVertices[2]); 
    33 } 
    34  
    35 void Polygon3::DeletePolygons(PolygonContainer *polys) 
    36 { 
    37         while(!polys->empty()) 
    38         { 
    39                 DEL_PTR(polys->back()); 
    40                 polys->pop_back(); 
    41         } 
    4233} 
    4334 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.h

    r256 r262  
    6262 
    6363                 
    64         /** Deletes all polygons om the queue. 
    65         */ 
    66         static void DeletePolygons(PolygonContainer *polys); 
    67  
    6864        /// vertices are connected in counterclockwise order. 
    6965        VertexContainer mVertices; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp

    r261 r262  
    77#include "Environment.h" 
    88 
     9Preprocessor::Preprocessor(): 
     10mKdTree(NULL), 
     11mBspTree(NULL) 
     12{ 
     13} 
    914 
    1015Preprocessor::~Preprocessor() 
    1116{ 
    12   // delete view cells 
    13   while (!mViewCells.empty()) 
    14   { 
    15           DEL_PTR(mViewCells.back()); 
    16           mViewCells.pop_back(); 
    17   } 
    18  
    19   // delete psp tree 
     17  CLEAR_CONTAINER(mViewCells); 
    2018  DEL_PTR(mBspTree); 
     19  DEL_PTR(mKdTree); 
    2120} 
    2221 
     
    2524{ 
    2625        X3dParser *parser = new X3dParser; 
    27  
    28         delete parser; 
    2926 
    3027        bool result = parser->ParseFile(filename, mViewCells); 
     
    3229        if (result) 
    3330        { 
    34                 Exporter *exporter = Exporter::GetExporter(filename); 
     31                Exporter *exporter = Exporter::GetExporter("viewcells.x3d"); 
    3532 
    3633                if (exporter)  
     34                { 
    3735                        exporter->ExportViewCells(&mViewCells); 
    38  
     36                        delete exporter; 
     37                } 
     38 
     39                Debug << "Generating view cells" << endl; 
    3940                GenerateViewCells(); 
     41                Debug << "Generated view cells" << endl; 
    4042        } 
     43 
     44        DEL_PTR(parser); 
     45         
     46 
    4147        return result; 
    4248} 
     
    9197Preprocessor::BuildBspTree() 
    9298{ 
    93         ObjectContainer objects; 
    94         mSceneGraph->CollectObjects(&objects); 
    95  
     99        DEL_PTR(mBspTree); 
    96100        mBspTree = new BspTree(); 
    97101 
     
    116120    } 
    117121 
     122        ObjectContainer objects; 
     123        RayContainer rays; 
     124 
    118125        switch (constructionMethod) 
    119126        { 
    120127        case BspTree::VIEWCELLS: 
     128                Debug << "Construction method: view cells\n"; 
     129 
    121130                // derive view cells from the scene objects 
    122                 //ViewCell::DeriveViewCells(objects, mViewCells, maxViewCells); 
     131                if (mViewCells.empty())          
     132                { 
     133                        Debug << "View cells empty => generating new ones\n"; Debug.flush(); 
     134                        mSceneGraph->CollectObjects(&objects); 
     135                        ViewCell::DeriveViewCells(objects, mViewCells, maxViewCells); 
     136                } 
     137 
     138                mBspTree->Construct(mViewCells); 
     139                break; 
     140        case BspTree::SCENE_GEOMETRY: 
     141                Debug << "Construction method: geometry\n"; 
     142 
     143        CLEAR_CONTAINER(mViewCells); // we generate new view cells 
     144                mSceneGraph->CollectObjects(&objects); 
     145 
     146                mBspTree->Construct(objects, &mViewCells); 
     147                break; 
     148        case BspTree::RAYS: 
     149                Debug << "Construction method: rays\n"; 
     150 
     151                CLEAR_CONTAINER(mViewCells); // we generate new view cells 
    123152                 
    124                 mBspTree->Construct(mViewCells); 
    125                 break; 
    126         case BspTree::SCENE_GEOMETRY: 
    127                 CLEAR_CONTAINER(mViewCells); 
    128                 mBspTree->Construct(objects, &mViewCells); 
    129                 break; 
    130         case BspTree::RAYS: 
    131                 CLEAR_CONTAINER(mViewCells); 
    132                 mBspTree->Construct(objects, &mViewCells); 
     153                mBspTree->Construct(rays, &mViewCells); 
    133154                break; 
    134155        default: 
     156                Debug << "Error: Method not available\n"; 
    135157                break; 
    136158        } 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.h

    r261 r262  
    2525class Preprocessor { 
    2626public: 
     27        /** Default constructor initialising e.g., KD tree and BSP tree. 
     28        */ 
     29        Preprocessor(); 
     30 
    2731   ~Preprocessor(); 
    2832 
     
    8892  /// scene graph loaded from file 
    8993  SceneGraph *mSceneGraph; 
    90   /// BSP tree representing the viewcells 
    91   BspTree *mViewCellBspTree; 
     94   
    9295  /// kD-tree organizing the scene graph (occluders + occludees) + viewcells 
    9396  KdTree *mKdTree; 
     
    100103  ViewCellContainer mViewCells; 
    101104   
    102   BspTree * mBspTree; 
     105  /// BSP tree representing the viewcells 
     106  BspTree *mBspTree; 
    103107}; 
    104108 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.cpp

    r261 r262  
    1111ViewCell::~ViewCell() 
    1212{ 
    13         // NOTE: should I really do this here? 
     13        // NOTE: should I really do this here? (I know that there is only one mesh per view cell) 
    1414        DEL_PTR(mMesh); 
    1515} 
     
    114114        // add top vertices      
    115115        for (int i = 0; i < 3; ++i) 
    116                 mesh->mVertices.push_back(topTri.mVertices[1]); 
     116                mesh->mVertices.push_back(topTri.mVertices[i]); 
    117117         
    118118        return new ViewCell(mesh); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.h

    r261 r262  
    6767 
    6868}; 
    69    
     69 
    7070//}; // GtpVisibilityPreprocessor 
    7171 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp

    r261 r262  
    1111#include <time.h> 
    1212#include <iomanip> 
     13#include "Exporter.h" 
    1314 
    1415#define INITIAL_COST 999999// unreachable high initial cost for heuristic evaluation 
     
    200201mRoot(NULL),  
    201202mIsIncremential(false), 
    202 mStorePolys(false) 
     203mStorePolys(true) 
    203204{ 
    204205        Randomize(); // initialise random generator for heuristics 
     
    279280            tStack.pop(); 
    280281         
    281                 /// if we store 
    282                 if (mStorePolys) 
    283                         Polygon3::DeletePolygons(&node->mPolygons); 
     282                /// if we stored the polygons 
     283                CLEAR_CONTAINER(node->mPolygons); 
    284284 
    285285                if (!node->IsLeaf()) 
     
    365365        mTermMaxDepth = maxDepth; 
    366366        mStat.nodes = 1; 
     367         
    367368        mBox.Initialize();      // initialise bsp tree bounding box 
    368369} 
     
    438439        const int maxPolygons = 0; 
    439440        const int maxDepth = 99999; 
     441         
    440442        InitTree(maxPolygons, maxDepth); 
    441443         
    442  
    443         // tree is completely constructed before  
    444         // view cells are not inserted one after another => better tree behaviour 
     444        // tree is completely constructed once before  
     445        // view cells are inserted one after another =>  
     446        // global tree optimization possible 
    445447        if (!mIsIncremential) 
    446448        { 
     449                Debug << "Not incremential => constructing tree in advance\n"; 
    447450                // copy view cell meshes into one big polygon soup 
    448451                PolygonContainer *polys = new PolygonContainer(); 
     
    451454                // construct tree from viewcell polygons 
    452455                Construct(polys); 
    453         } 
    454  
    455         // insert all viewcells 
     456 
     457                Export("bsp.x3d"); 
     458        } 
     459         
     460        //-- insert all viewcells 
    456461        ViewCellContainer::const_iterator it; 
    457462 
     463        int counter = 0; 
     464 
     465        Debug << "View cells insertion...\n"; Debug.flush(); 
    458466        for (it = viewCells.begin(); it != viewCells.end(); ++ it) 
    459467        { 
     468                Debug << "Inserting view cell " << ++counter; 
    460469                InsertViewCell(*it); 
    461470        } 
     471        Debug << "finished view cells insertion"; 
    462472} 
    463473 
     
    465475void BspTree::Construct(const ObjectContainer &objects, ViewCellContainer *viewCells) 
    466476{ 
    467 #ifdef _DEBUG 
    468         Debug << "Constructing tree using object container\n"; 
    469 #endif 
    470477        // take termination criteria from globals 
    471478        InitTree(mTermMaxPolygons, mTermMaxDepth); 
    472  
     479        Debug << "HAHAHAHHA";Debug.flush(); 
    473480        PolygonContainer *polys = new PolygonContainer(); 
    474481         
     
    490497{ 
    491498        std::stack<BspTraversalData> tStack; 
    492         // new root corresponding to unbounded space 
    493         BspTraversalData tData(new BspLeaf(), mRoot->GetParent(), polys, 0); 
     499        Debug << "HDDHDH"; Debug.flush(); 
     500 
     501        BspTraversalData tData(new BspLeaf(), NULL, polys, 0); 
    494502 
    495503        tStack.push(tData); 
    496504 
     505        Debug << "Contructing tree using objects..."; Debug.flush(); 
    497506        while (!tStack.empty())  
    498507        { 
     
    500509            tStack.pop(); 
    501510 
     511         
    502512                // subdivide leaf node 
    503513                BspNode *root = Subdivide(tStack, tData); 
    504514 
    505                 if (!mRoot) // empty tree => new root 
     515                // empty tree => // new root corresponding to unbounded space 
     516                if (!mRoot)  
    506517                        mRoot = root; 
    507518        } 
     519 
     520        Debug << "finished\n"; 
    508521} 
    509522 
     
    543556} 
    544557 
     558bool BspTree::ProcessPolygons(PolygonContainer *polys, BspLeaf *leaf) 
     559{ 
     560        bool result = false; 
     561 
     562        if (mStorePolys) 
     563        { 
     564                leaf->AddPolygons(polys); 
     565                result = true; 
     566        } 
     567        else 
     568                CLEAR_CONTAINER(*polys); 
     569 
     570        delete polys; 
     571        return result; 
     572} 
     573 
    545574BspNode *BspTree::SubdivideNode(BspLeaf *leaf,  
    546575                                                                BspInterior *parent,  
     
    554583        { 
    555584                // add or delete remaining polygons 
    556                 if (mStorePolys) 
    557                         leaf->AddPolygons(polys); 
    558                 else 
    559                         Polygon3::DeletePolygons(polys); 
    560  
    561                 delete polys; 
     585                ProcessPolygons(polys, leaf); 
    562586 
    563587                return leaf; 
     
    572596        Debug << node << endl; 
    573597#endif 
     598 
    574599        // split polygon according to current plane 
    575600        int splits = 0; 
     
    795820        return mStorePolys; 
    796821} 
     822 
    797823void BspTree::EvaluateLeafStats(const BspTraversalData &data) 
    798824{ 
     
    929955} 
    930956 
     957bool BspTree::Export(const string filename) 
     958{ 
     959        Exporter *exporter = Exporter::GetExporter(filename); 
     960 
     961        if (exporter)  
     962        { 
     963                exporter->ExportBspTree(*this); 
     964                delete exporter; 
     965 
     966                return true; 
     967        }        
     968 
     969        return false; 
     970} 
    931971//} // GtpVisibilityPreprocessor 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h

    r261 r262  
    286286        bool StorePolys() const; 
    287287 
     288        /** Exports Bsp tree to file. 
     289        */ 
     290        bool Export(const string filename); 
     291 
     292 
    288293protected: 
    289294         
     
    386391        int CastRay(Ray &ray); 
    387392 
     393        /** Discards or stores polygons in leaf and deletes the container. 
     394                @param polys the polygons 
     395                @param leaf the leaf where polygons are stored 
     396        */ 
     397        bool ProcessPolygons(PolygonContainer *polys, BspLeaf *node); 
     398 
    388399        /// Pointer to the root of the tree 
    389400        BspNode *mRoot; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp

    r261 r262  
    237237 
    238238 
     239        //-- create and write indices 
    239240        if (mWireframe) 
    240241                stream << "<IndexedLineSet ccw=\"TRUE\" coordIndex=\"" << endl; 
     
    242243                stream << "<IndexedFaceSet ccw=\"TRUE\" coordIndex=\"" << endl; 
    243244 
    244         VertexContainer::const_iterator vi = poly->mVertices.begin(); 
    245  
     245        int index = 0; 
     246         
     247        VertexContainer::const_iterator vi;   
     248         
     249        for (vi = poly->mVertices.begin(); vi != poly->mVertices.end(); ++vi)  
     250        { 
     251                stream << index ++ << " "; 
     252        } 
     253        stream << "-1" << endl; 
     254 
     255        stream << "\" >" << endl; 
     256         
    246257        stream << "<Coordinate  point=\"" << endl; 
    247258   
    248         for (; vi != poly->mVertices.end(); ++vi)  
     259        for (vi = poly->mVertices.begin(); vi != poly->mVertices.end(); ++vi)  
    249260        { 
    250261                stream << (*vi).x << " " << (*vi).y << " " << (*vi).z; 
     
    252263        } 
    253264   
    254         stream<<"\" >"<<endl; 
    255         stream<<"</Coordinate>"<<endl; 
     265        stream << "\" >" << endl; 
     266        stream << "</Coordinate>" << endl; 
    256267 
    257268        if (mWireframe) 
     
    303314        Mesh *mesh = new Mesh; 
    304315 
    305         //AxisAlignedBox3 box = tree.GetBoundingBox(); 
    306         //ExportBox(box); 
     316        AxisAlignedBox3 box = tree.GetBoundingBox(); 
     317        ExportBox(box); 
    307318          
    308319        while (!tStack.empty())  
     
    332343                { 
    333344                        BspLeaf *leaf = dynamic_cast<BspLeaf *>(node); 
     345                         
    334346                        // export view cell geometry 
     347                         
    335348                        if (!tree.StorePolys() && leaf->GetViewCell()) 
     349                        { 
    336350                                ExportViewCell(leaf->GetViewCell()); 
     351                        } 
     352                         
    337353                } 
    338354  } 
  • trunk/VUT/GtpVisibilityPreprocessor/src/X3dParser.cpp

    r261 r262  
    378378 
    379379/*********************************************************** 
    380  *         class X3dViewCellsParseHandlers implemenation          * 
     380 *         class X3dViewCellsParseHandlers implemenation   * 
    381381 ***********************************************************/ 
    382382 
     
    421421        int len = attributes.getLength(); 
    422422        int i; 
    423          
     423        // clear previous vertex indices 
     424        mCurrentVertexIndices.clear(); 
    424425        for (i=0; i < len; i++)  
    425426        { 
     
    460461         
    461462        VertexContainer vertices; 
    462  
     463         
    463464        for (int i=0; i < len; i++)  
    464465        { 
     
    498499 
    499500                                Vector3 v(x, y, z); 
    500                                 vertices.push_back(v); 
     501                                vertices.push_back(v);                           
    501502                        } 
    502503                } 
    503504        } 
    504  
    505505 
    506506 
     
    511511                                                  vertices[mCurrentVertexIndices[i+2]]); 
    512512 
    513             // create view cell from base triangle 
     513                // create view cell from base triangle 
    514514                const float height = 10; 
    515515                mViewCells->push_back(ViewCell::ExtrudeViewCell(baseTri, height)); 
     516 
     517                Mesh *mesh = mViewCells->back()->GetMesh(); 
     518#ifdef _DEBUG 
     519                Debug << "Viewcell :"  
     520                          << mesh->mVertices[0] << " " << mesh->mVertices[1] << " " << mesh->mVertices[2] << " "  
     521                          << mesh->mVertices[3] << " " << mesh->mVertices[4] << " " << mesh->mVertices[5] << "\n"; 
     522#endif 
    516523        } 
    517524} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/common.h

    r261 r262  
    128128 
    129129#ifndef DEL_PTR 
    130 #define DEL_PTR(ptr) while (0) {if (ptr) {delete (ptr); (ptr) = NULL;}} 
    131 #endif 
    132  
     130#define DEL_PTR(ptr) do {if (ptr) {        \ 
     131                           delete (ptr);   \ 
     132                                                   (ptr) = 0;}}    \ 
     133                     while (0) 
     134#endif 
     135// Clears a container (i.e., a vector of pointers) and deletes the pointers 
    133136#ifndef CLEAR_CONTAINER 
    134 #define CLEAR_CONTAINER(co) while (!co.empty()) {delete co.back(); co.pop_back();} 
     137#define CLEAR_CONTAINER(co) do { while (!(co).empty()) {   \ 
     138                                                           DEL_PTR((co).back());     \ 
     139                                                                   (co).pop_back();}}      \ 
     140                                                        while (0) 
    135141#endif 
    136142 
Note: See TracChangeset for help on using the changeset viewer.