Ignore:
Timestamp:
09/14/05 18:32:40 (19 years ago)
Author:
mattausch
Message:

did bsp stuff

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp

    r267 r268  
    3333const int FACTOR_LEAST_SPLITS = 1; 
    3434 
     35int counter = 0; 
     36bool BspTree::displayDebug = false; 
    3537/****************************************************************/ 
    3638/*                  class BspNode implementation                */ 
    3739/****************************************************************/ 
    3840 
    39 BspNode::BspNode(): mParent(NULL), mPolygons(NULL) 
     41BspNode::BspNode(): mParent(NULL), mPolygons(NULL),mViewCellIdx(0) 
    4042{} 
    4143 
    42 BspNode::BspNode(BspInterior *parent): mParent(parent), mPolygons(NULL) 
     44BspNode::BspNode(BspInterior *parent): mParent(parent), mPolygons(NULL),mViewCellIdx(0) 
    4345{} 
    4446 
     
    147149                                                                int &splits, bool storePolys) 
    148150{ 
    149 #ifdef _Debug 
     151//#ifdef _Debug 
     152        if (BspTree::displayDebug) 
    150153        Debug << "Splitting polygons of node " << this << " with plane " << mPlane << endl; 
    151 #endif 
     154//#endif 
    152155        bool inside = false; 
    153156 
     
    157160                polys->pop_back(); 
    158161 
     162                if (BspTree::displayDebug) Debug << "New polygon with plane: " << poly->GetSupportingPlane() << "\n"; 
     163 
    159164                // test if split is neccessary 
    160165                int classification = poly->ClassifyPlane(mPlane); 
     
    162167                Polygon3 *front_piece = NULL; 
    163168                Polygon3 *back_piece = NULL; 
    164                  
     169         
    165170                switch (classification) 
    166171                { 
     
    170175                                        // same surface normal 
    171176                                        inside = (DotProd(mPlane.mNormal, poly->GetSupportingPlane().mNormal) > 0); 
    172                                          
    173                                 //Debug << "coincident" << endl; 
     177                                        if (BspTree::displayDebug)       
     178                                Debug << "coincident" << endl; 
    174179                                // discard polygons or saves them in node 
    175180                                ProcessPolygon(poly, storePolys); 
    176181                                break; 
    177                         case Polygon3::FRONT_SIDE: 
    178                                 //Debug << "front" << endl; 
     182                        case Polygon3::FRONT_SIDE:      if (BspTree::displayDebug) 
     183                                Debug << "front" << endl; 
    179184                                frontPolys->push_back(poly); 
    180185                                break; 
    181186                        case Polygon3::BACK_SIDE: 
    182                                 inside = true; 
    183                                 //Debug << "back" << endl; 
     187                                inside = true;  if (BspTree::displayDebug) 
     188                                Debug << "back" << endl; 
    184189                                backPolys->push_back(poly); 
    185190                                break; 
    186191                        case Polygon3::SPLIT: 
    187                                 inside = true; 
    188                                 //Debug << "split " << poly << endl; 
     192                                inside = true;                           
    189193 
    190194                                front_piece = new Polygon3(); 
     
    197201                                backPolys->push_back(back_piece); 
    198202 
    199 #ifdef _DEBUG 
    200                                 Debug << "split " << *poly << endl << *front_piece << endl << *back_piece << endl; 
    201 #endif 
     203//#ifdef _DEBUG 
     204                                if (BspTree::displayDebug)Debug << "split " << *poly << endl << *front_piece << endl << *back_piece << endl; 
     205//#endif 
    202206                                // save or discard polygons 
    203207                                ProcessPolygon(poly, storePolys); 
     
    258262mRoot(NULL),  
    259263mIsIncremential(false), 
    260 mStorePolys(false) 
     264mStorePolys(true) 
    261265{ 
    262266        Randomize(); // initialise random generator for heuristics 
     
    440444                Polygon3 *poly = new Polygon3((*fi), mesh); 
    441445                polys.push_back(poly); 
     446                if (displayDebug) 
     447                        Debug << *poly << endl; 
    442448                polysNum ++; 
    443449        } 
     
    531537 
    532538        long startTime = GetTime(); 
    533  
    534         int counter = 0; 
     539displayDebug = true; 
     540        counter = 0; 
    535541        Debug << "**** Starting view cell insertion ****" << endl; 
    536542        for (it = viewCells.begin(); it != viewCells.end(); ++ it) 
    537543        { 
    538                 Debug << "** inserting view cell " << counter ++ << " **" << endl; 
    539                 InsertViewCell(*it); 
     544                if ((counter == 12) || (counter == 14)) 
     545                {Debug << "** inserting view cell " << counter << " **" << endl; 
     546                InsertViewCell(*it);} 
     547                counter ++; 
    540548        } 
    541549 
     
    609617        { 
    610618//#ifdef _DEBUG 
    611                 Debug << "subdivision terminated at depth " << tData.mDepth << ", #polys: " << (int)tData.mPolygons->size() << endl; 
     619                if (displayDebug) 
     620                        Debug << "subdivision terminated at depth " << tData.mDepth << ", #polys: " << (int)tData.mPolygons->size() << endl; 
    612621//#endif 
    613622 
     
    620629 
    621630                        if (leaf->GetViewCell()) 
    622                                 Debug << "ERROR: leaf already has view cell" << endl; 
    623  
     631                                Debug << "ERROR: leaf already has view cell " << leaf->mViewCellIdx << endl; 
     632 
     633                        leaf->mViewCellIdx = counter; 
    624634                        Debug << "insert view cell" << endl; 
    625635                        leaf->SetViewCell(viewCell); 
Note: See TracChangeset for help on using the changeset viewer.