Changeset 1563


Ignore:
Timestamp:
10/03/06 22:03:58 (18 years ago)
Author:
mattausch
Message:

fixed bug with view space box

Location:
GTP/trunk/Lib/Vis/Preprocessing
Files:
2 added
23 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/FrontEnd/preprocessorFrontEnd.cpp

    r1558 r1563  
    3131IMPLEMENT_APP(MyApp) 
    3232 
     33 
    3334bool MyApp::OnInit() 
    3435{ 
    3536    // Create the main window 
    36     MyFrame *frame = new MyFrame( wxT("Notebook sample") ); 
     37    MyFrame *frame = new MyFrame(wxT("Preprocessor Frontend")); 
    3738 
    3839    // Problem with generic wxNotebook implementation whereby it doesn't size 
    3940    // properly unless you set the size again 
    40 #if defined(__WXMOTIF__) 
     41//#if defined(__WXMOTIF__) 
     42//      frame->SetSize(wxDefaultCoord, wxDefaultCoord, 1024, 768); 
    4143    int width, height; 
    42     frame->GetSize(& width, & height); 
     44    frame->GetSize(&width, &height); 
    4345    frame->SetSize(wxDefaultCoord, wxDefaultCoord, width, height); 
    44 #endif 
     46//#endif 
    4547 
    4648    frame->Show(); 
     
    4951} 
    5052 
    51 wxPanel *CreateUserCreatedPage(wxBookCtrlBase *parent) 
     53 
     54wxPanel *MyFrame::CreateUserCreatedPage(wxBookCtrlBase *parent) 
    5255{ 
    5356    wxPanel *panel = new wxPanel(parent); 
    5457 
    55     (void) new wxButton( panel, wxID_ANY, wxT("Button"), 
    56         wxPoint(10, 10), wxDefaultSize ); 
     58    (void) new wxButton(panel, wxID_ANY, wxT("Button"), 
     59        wxPoint(10, 10), wxDefaultSize); 
    5760 
    5861    return panel; 
    5962} 
    6063 
    61 wxPanel *CreateRadioButtonsPage(wxBookCtrlBase *parent) 
     64 
     65wxPanel *MyFrame::CreatePreprocessorPage(wxBookCtrlBase *parent) 
    6266{ 
    6367    wxPanel *panel = new wxPanel(parent); 
    6468 
    65     wxString animals[] = { wxT("Fox"), wxT("Hare"), wxT("Rabbit"), 
    66         wxT("Sabre-toothed tiger"), wxT("T Rex") }; 
    67  
    68     wxRadioBox *radiobox1 = new wxRadioBox(panel, wxID_ANY, wxT("Choose one"), 
    69         wxDefaultPosition, wxDefaultSize, 5, animals, 2, wxRA_SPECIFY_ROWS); 
    70  
    71     wxString computers[] = { wxT("Amiga"), wxT("Commodore 64"), wxT("PET"), 
    72         wxT("Another") }; 
    73  
    74     wxRadioBox *radiobox2 = new wxRadioBox(panel, wxID_ANY, 
    75         wxT("Choose your favourite"), wxDefaultPosition, wxDefaultSize, 
    76         4, computers, 0, wxRA_SPECIFY_COLS); 
     69        wxString preprocessorType[] = {wxT("Rss"), wxT("Gvs"), wxT("None")}; 
     70 
     71    wxRadioBox *radiobox1 = new wxRadioBox(panel, wxID_ANY, wxT("Choose preprocessor type"), 
     72        wxDefaultPosition, wxDefaultSize, 3, preprocessorType, 1, wxRA_SPECIFY_ROWS); 
     73 
     74        mDetectEmptyViewSpaceText = new wxTextCtrl(panel, wxID_ANY, "detect emtpy view space", 
     75                wxDefaultPosition, wxDefaultSize); 
     76 
     77        //mDetectEmptyViewSpaceCheckBox = new wxCheckBox(panel, wxID_ANY); 
    7778 
    7879    wxBoxSizer *sizerPanel = new wxBoxSizer(wxVERTICAL); 
    79     sizerPanel->Add(radiobox1, 2, wxEXPAND); 
    80     sizerPanel->Add(radiobox2, 1, wxEXPAND); 
     80    sizerPanel->Add(radiobox1, 1, wxEXPAND); 
     81        sizerPanel->Add(mDetectEmptyViewSpaceText, 1); 
     82        sizerPanel->Add(mDetectEmptyViewSpaceCheckBox, 1); 
     83 
    8184    panel->SetSizer(sizerPanel); 
    8285 
     
    8487} 
    8588 
    86 wxPanel *CreateVetoPage(wxBookCtrlBase *parent) 
     89 
     90wxPanel *MyFrame::CreateViewCellsPage(wxBookCtrlBase *parent) 
     91{ 
     92    wxPanel *panel = new wxPanel(parent); 
     93 
     94        wxString viewSpaceHierarchy[] = {wxT("vspBsp"), wxT("vspOsp"), wxT("bsp")}; 
     95 
     96    wxRadioBox *radiobox1 = new wxRadioBox(panel, wxID_ANY, wxT("Choose view space hierarchy type"), 
     97        wxDefaultPosition, wxDefaultSize, 3, viewSpaceHierarchy, 1, wxRA_SPECIFY_ROWS); 
     98 
     99    wxBoxSizer *sizerPanel = new wxBoxSizer(wxVERTICAL); 
     100    sizerPanel->Add(radiobox1, 1, wxEXPAND); 
     101    panel->SetSizer(sizerPanel); 
     102 
     103    return panel; 
     104} 
     105 
     106 
     107/*wxPanel *CreateVetoPage(wxBookCtrlBase *parent) 
    87108{ 
    88109    wxPanel *panel = new wxPanel(parent); 
     
    92113 
    93114    return panel; 
    94 } 
    95  
    96 wxPanel *CreateBigButtonPage(wxBookCtrlBase *parent) 
    97 { 
    98     wxPanel *panel = new wxPanel(parent); 
    99  
    100     wxButton *buttonBig = new wxButton(panel, wxID_ANY, wxT("Maximized button")); 
    101  
    102     wxBoxSizer *sizerPanel = new wxBoxSizer(wxVERTICAL); 
    103     sizerPanel->Add(buttonBig, 1, wxEXPAND); 
    104     panel->SetSizer(sizerPanel); 
    105  
    106     return panel; 
    107 } 
    108  
    109  
    110 wxPanel *CreateInsertPage(wxBookCtrlBase *parent) 
     115}*/ 
     116 
     117 
     118/*wxPanel *CreateInsertPage(wxBookCtrlBase *parent) 
    111119{ 
    112120    wxPanel *panel = new wxPanel(parent); 
     
    117125 
    118126    return panel; 
    119 } 
     127}*/ 
     128 
    120129 
    121130int GetIconIndex(wxBookCtrlBase* bookCtrl) 
     
    133142} 
    134143 
    135 void CreateInitialPages(wxBookCtrlBase *parent) 
     144 
     145void MyFrame::CreateInitialPages(wxBookCtrlBase *parent) 
    136146{ 
    137147    // Create and add some panels to the notebook 
    138  
    139     wxPanel *panel = CreateRadioButtonsPage(parent); 
    140     parent->AddPage( panel, RADIOBUTTONS_PAGE_NAME, false, GetIconIndex(parent) ); 
    141  
    142     panel = CreateVetoPage(parent); 
    143     parent->AddPage( panel, VETO_PAGE_NAME, false, GetIconIndex(parent) ); 
    144  
    145     panel = CreateBigButtonPage(parent); 
    146     parent->AddPage( panel, MAXIMIZED_BUTTON_PAGE_NAME, false, GetIconIndex(parent) ); 
    147  
    148     panel = CreateInsertPage(parent); 
    149     parent->InsertPage( 0, panel, I_WAS_INSERTED_PAGE_NAME, false, GetIconIndex(parent) ); 
     148    wxPanel *panel = CreatePreprocessorPage(parent); 
     149    parent->AddPage(panel, PREPROCESSOR_PAGE_NAME, false, GetIconIndex(parent)); 
     150 
     151        panel = CreateViewCellsPage(parent); 
     152    parent->AddPage(panel, VIEWCELLS_PAGE_NAME, false, GetIconIndex(parent)); 
     153 
     154    //panel = CreateVetoPage(parent); 
     155    //parent->AddPage( panel, VETO_PAGE_NAME, false, GetIconIndex(parent) ); 
     156 
     157    //panel = CreateInsertPage(parent); 
     158    //parent->InsertPage( 0, panel, I_WAS_INSERTED_PAGE_NAME, false, GetIconIndex(parent) ); 
    150159 
    151160    parent->SetSelection(1); 
    152161} 
    153162 
    154 wxPanel *CreatePage(wxBookCtrlBase *parent, const wxString&pageName) 
    155 { 
    156     if 
    157     ( 
    158         pageName.Contains(INSERTED_PAGE_NAME) 
    159         || pageName.Contains(ADDED_PAGE_NAME) 
    160     ) 
    161     { 
    162         return CreateUserCreatedPage(parent); 
    163     } 
    164  
    165     if (pageName == I_WAS_INSERTED_PAGE_NAME) 
    166     { 
    167         return CreateInsertPage(parent); 
    168     } 
    169  
    170     if (pageName == VETO_PAGE_NAME) 
    171     { 
    172         return CreateVetoPage(parent); 
    173     } 
    174  
    175     if (pageName == RADIOBUTTONS_PAGE_NAME) 
    176     { 
    177         return CreateRadioButtonsPage(parent); 
    178     } 
    179  
    180  
    181     if (pageName == MAXIMIZED_BUTTON_PAGE_NAME) 
    182     { 
    183         return CreateBigButtonPage(parent); 
     163 
     164wxPanel *MyFrame::CreatePage(wxBookCtrlBase *parent, const wxString&pageName) 
     165{ 
     166    
     167    if (pageName == VIEWCELLS_PAGE_NAME) 
     168    { 
     169        return CreateViewCellsPage(parent); 
     170    } 
     171 
     172        if (pageName == PREPROCESSOR_PAGE_NAME) 
     173    { 
     174        return CreatePreprocessorPage(parent); 
    184175    } 
    185176 
     
    189180} 
    190181 
    191 MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, 
     182MyFrame::MyFrame(const wxString& title,  
     183                                 const wxPoint& pos,  
     184                                 const wxSize& size, 
    192185                 long style) 
    193186    : wxFrame((wxWindow *) NULL, wxID_ANY, title, pos, size, style) 
    194187{ 
    195188#if wxUSE_NOTEBOOK 
    196     m_type = ID_BOOK_NOTEBOOK; 
     189    mType = ID_BOOK_NOTEBOOK; 
    197190#elif wxUSE_CHOICEBOOK 
    198     m_type = ID_BOOK_CHOICEBOOK; 
     191    mType = ID_BOOK_CHOICEBOOK; 
    199192#elif wxUSE_LISTBOOK 
    200     m_type = ID_BOOK_LISTBOOK; 
     193    mType = ID_BOOK_LISTBOOK; 
    201194#elif 
    202195    #error "Don't use Notebook sample without any book enabled in wxWidgets build!" 
    203196#endif 
    204197 
    205     m_orient = ID_ORIENT_DEFAULT; 
    206     m_chkShowImages = true; 
    207     m_multi = false; 
     198    mOrient = ID_ORIENT_DEFAULT; 
     199    mChkShowImages = true; 
     200    mMulti = false; 
    208201 
    209202    SetIcon(wxICON(sample)); 
     
    212205    wxMenu *menuType = new wxMenu; 
    213206#if wxUSE_NOTEBOOK 
    214     menuType->AppendRadioItem(ID_BOOK_NOTEBOOK,   wxT("&Notebook\tCtrl-1")); 
     207    menuType->AppendRadioItem(ID_BOOK_NOTEBOOK, wxT("&Notebook\tCtrl-1")); 
    215208#endif 
    216209#if wxUSE_LISTBOOK 
    217     menuType->AppendRadioItem(ID_BOOK_LISTBOOK,   wxT("&Listbook\tCtrl-2")); 
     210    menuType->AppendRadioItem(ID_BOOK_LISTBOOK, wxT("&Listbook\tCtrl-2")); 
    218211#endif 
    219212#if wxUSE_CHOICEBOOK 
    220213    menuType->AppendRadioItem(ID_BOOK_CHOICEBOOK, wxT("&Choicebook\tCtrl-3")); 
    221214#endif 
    222     menuType->Check(m_type, true); 
     215 
     216    menuType->Check(mType, true); 
    223217 
    224218    wxMenu *menuOrient = new wxMenu; 
     
    243237    menuFile->AppendSeparator(); 
    244238    menuFile->Append(wxID_EXIT, wxT("E&xit"), wxT("Quits the application")); 
    245     menuFile->Check(ID_SHOW_IMAGES, m_chkShowImages); 
    246     menuFile->Check(ID_MULTI, m_multi); 
     239    menuFile->Check(ID_SHOW_IMAGES, mChkShowImages); 
     240    menuFile->Check(ID_MULTI, mMulti); 
    247241 
    248242    wxMenuBar *menuBar = new wxMenuBar; 
     
    253247    // books creation 
    254248 
    255     m_panel      = (wxPanel *)      NULL; 
     249    mPanel      = (wxPanel *) NULL; 
    256250#if wxUSE_NOTEBOOK 
    257     m_notebook   = (wxNotebook *)  NULL; 
     251    mNotebook   = (wxNotebook *) NULL; 
    258252#endif 
    259253#if wxUSE_CHOICEBOOK 
    260     m_choicebook = (wxChoicebook *) NULL; 
     254    mChoicebook = (wxChoicebook *) NULL; 
    261255#endif 
    262256#if wxUSE_LISTBOOK 
    263     m_listbook   = (wxListbook *)  NULL; 
     257    mListbook   = (wxListbook *) NULL; 
    264258#endif 
    265259 
     
    267261    wxSize imageSize(32, 32); 
    268262 
    269     m_imageList 
     263    mImageList 
    270264        = new wxImageList( imageSize.GetWidth(), imageSize.GetHeight() ); 
    271265 
    272     m_imageList->Add 
     266    mImageList->Add 
    273267        ( 
    274268            wxArtProvider::GetIcon(wxART_INFORMATION, wxART_OTHER, imageSize) 
    275269        ); 
    276270 
    277     m_imageList->Add 
     271    mImageList->Add 
    278272        ( 
    279273            wxArtProvider::GetIcon(wxART_QUESTION, wxART_OTHER, imageSize) 
    280274        ); 
    281275 
    282     m_imageList->Add 
     276    mImageList->Add 
    283277        ( 
    284278            wxArtProvider::GetIcon(wxART_WARNING, wxART_OTHER, imageSize) 
    285279        ); 
    286280 
    287     m_imageList->Add 
     281    mImageList->Add 
    288282        ( 
    289283            wxArtProvider::GetIcon(wxART_ERROR, wxART_OTHER, imageSize) 
    290284        ); 
    291285 
    292     m_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 
     286    mPanel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 
    293287        wxTAB_TRAVERSAL | wxCLIP_CHILDREN | wxNO_BORDER | wxNO_FULL_REPAINT_ON_RESIZE); 
    294288 
    295289#if USE_LOG 
    296     m_text = new wxTextCtrl(m_panel, wxID_ANY, wxEmptyString, 
     290    mText = new wxTextCtrl(mPanel, wxID_ANY, wxEmptyString, 
    297291        wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY); 
    298292 
    299     m_logTargetOld = wxLog::SetActiveTarget( new wxLogTextCtrl(m_text) ); 
     293    mLogTargetOld = wxLog::SetActiveTarget( new wxLogTextCtrl(mText) ); 
    300294#endif // USE_LOG 
    301295 
    302296    // Set sizers 
    303     m_sizerFrame = new wxBoxSizer(wxVERTICAL); 
     297    mSizerFrame = new wxBoxSizer(wxVERTICAL); 
    304298 
    305299#if USE_LOG 
    306     m_sizerFrame->Add(m_text, 1, wxEXPAND); 
     300    mSizerFrame->Add(mText, 1, wxEXPAND); 
    307301#endif // USE_LOG 
    308302 
     303        // create preprocessor front end 
     304        //mPreprocessorFrontEnd = new PreprocessorFrontEnd(); 
    309305    RecreateBooks(); 
    310  
    311     m_panel->SetSizer(m_sizerFrame); 
    312  
    313     m_sizerFrame->Fit(this); 
    314     m_sizerFrame->SetSizeHints(this); 
     306    mPanel->SetSizer(mSizerFrame); 
     307 
     308    mSizerFrame->Fit(this); 
     309    mSizerFrame->SetSizeHints(this); 
    315310 
    316311    Centre(wxBOTH); 
    317312} 
    318313 
     314 
    319315MyFrame::~MyFrame() 
    320316{ 
    321317#if USE_LOG 
    322     delete wxLog::SetActiveTarget(m_logTargetOld); 
     318    delete wxLog::SetActiveTarget(mLogTargetOld); 
    323319#endif // USE_LOG 
    324320 
    325     if (m_imageList) 
    326     { 
    327         delete m_imageList; 
    328         m_imageList = (wxImageList *) NULL; 
     321    if (mImageList) 
     322    { 
     323        delete mImageList; 
     324        mImageList = (wxImageList *) NULL; 
    329325    } 
    330326} 
     
    347343#endif 
    348344 
    349 #define RECREATE( wxBookType , idBook, oldBook , newBook )                         \ 
     345#define RECREATE(wxBookType , idBook, oldBook, newBook)                            \ 
    350346{                                                                                  \ 
    351347    int flags;                                                                     \ 
    352348                                                                                   \ 
    353     switch ( m_orient )                                                            \ 
     349    switch (mOrient)                                                               \ 
    354350    {                                                                              \ 
    355351        case ID_ORIENT_TOP:                                                        \ 
     
    372368            flags = SelectFlag(idBook, wxNB_DEFAULT, wxLB_DEFAULT, wxCHB_DEFAULT); \ 
    373369    }                                                                              \ 
    374                                                                                    \ 
    375     if ( m_multi && ( idBook == ID_NOTEBOOK ) )                                    \ 
     370                                                                                                                                                                   \ 
     371    if (mMulti && (idBook == ID_NOTEBOOK))                                         \ 
    376372        flags |= wxNB_MULTILINE;                                                   \ 
    377373                                                                                   \ 
    378374    wxBookType *oldBook = newBook;                                                 \ 
    379375                                                                                   \ 
    380     newBook = new wxBookType(m_panel, idBook,                                      \ 
     376    newBook = new wxBookType(mPanel, idBook,                                       \ 
    381377                             wxDefaultPosition, wxDefaultSize,                     \ 
    382378                             flags);                                               \ 
    383379                                                                                   \ 
    384     if ( m_chkShowImages )                                                         \ 
     380    if (mChkShowImages)                                                            \ 
    385381    {                                                                              \ 
    386         newBook->SetImageList(m_imageList);                                        \ 
     382        newBook->SetImageList(mImageList);                                         \ 
    387383    }                                                                              \ 
    388384                                                                                   \ 
     
    400396        }                                                                          \ 
    401397                                                                                   \ 
    402         m_sizerFrame->Detach(oldBook);                                             \ 
     398        mSizerFrame->Detach(oldBook);                                              \ 
    403399                                                                                   \ 
    404400        delete oldBook;                                                            \ 
     
    414410        CreateInitialPages(newBook);                                               \ 
    415411    }                                                                              \ 
    416                                                                                    \ 
    417     m_sizerFrame->Insert(0, newBook, 5, wxEXPAND | wxALL, MARGIN);                 \ 
    418                                                                                    \ 
    419     m_sizerFrame->Hide(newBook);                                                   \ 
    420 } 
     412                                                                                                                                                                   \ 
     413        mSizerFrame->Insert(0, newBook, 5, wxEXPAND | wxALL, MARGIN);                              \ 
     414        mSizerFrame->Hide(newBook);                                                    \ 
     415} 
     416 
    421417 
    422418void MyFrame::RecreateBooks() 
    423419{ 
    424420#if wxUSE_NOTEBOOK 
    425     RECREATE( wxNotebook   , ID_NOTEBOOK   , notebook   , m_notebook ); 
     421    RECREATE(wxNotebook, ID_NOTEBOOK, notebook, mNotebook); 
    426422#endif 
    427423#if wxUSE_LISTBOOK 
    428     RECREATE( wxListbook   , ID_LISTBOOK   , listbook   , m_listbook ); 
     424//    RECREATE(wxListbook, ID_LISTBOOK, listbook, mListbook); 
    429425#endif 
    430426#if wxUSE_CHOICEBOOK 
    431     RECREATE( wxChoicebook , ID_CHOICEBOOK , choicebook , m_choicebook ); 
     427    RECREATE(wxChoicebook, ID_CHOICEBOOK, choicebook, mChoicebook); 
    432428#endif 
    433429 
     
    435431} 
    436432 
     433 
    437434wxBookCtrlBase *MyFrame::GetCurrentBook() 
    438435{ 
    439     switch (m_type) 
     436    switch (mType) 
    440437    { 
    441438#if wxUSE_NOTEBOOK 
    442         case ID_BOOK_NOTEBOOK:   return m_notebook; 
     439        case ID_BOOK_NOTEBOOK:   return mNotebook; 
    443440#endif 
    444441#if wxUSE_LISTBOOK 
    445         case ID_BOOK_LISTBOOK:   return m_listbook; 
     442        case ID_BOOK_LISTBOOK:   return mListbook; 
    446443#endif 
    447444#if wxUSE_CHOICEBOOK 
    448         case ID_BOOK_CHOICEBOOK: return m_choicebook; 
     445        case ID_BOOK_CHOICEBOOK: return mChoicebook; 
    449446#endif 
    450447    } 
     
    454451void MyFrame::ShowCurrentBook() 
    455452{ 
    456     switch(m_type) 
     453    switch(mType) 
    457454    { 
    458455#if wxUSE_NOTEBOOK 
    459         case ID_BOOK_NOTEBOOK:   if(m_notebook)   m_sizerFrame->Show(m_notebook);   break; 
     456        case ID_BOOK_NOTEBOOK:  
     457                        if (mNotebook)    
     458                        { 
     459                                mSizerFrame->Show(mNotebook);    
     460                        } 
     461                         
     462                        break; 
    460463#endif 
    461464#if wxUSE_LISTBOOK 
    462         case ID_BOOK_LISTBOOK:   if(m_listbook)   m_sizerFrame->Show(m_listbook);   break; 
     465        case ID_BOOK_LISTBOOK:    
     466                        if (mListbook)    
     467                        { 
     468                                mSizerFrame->Show(mListbook);    
     469                                break; 
     470                        } 
    463471#endif 
    464472#if wxUSE_CHOICEBOOK 
    465         case ID_BOOK_CHOICEBOOK: if(m_choicebook) m_sizerFrame->Show(m_choicebook); break; 
    466 #endif 
    467     } 
    468  
    469     m_sizerFrame->Layout(); 
     473        case ID_BOOK_CHOICEBOOK:  
     474                        if (mChoicebook)  
     475                        { 
     476                                mSizerFrame->Show(mChoicebook);  
     477                                break; 
     478                        } 
     479#endif 
     480    } 
     481 
     482    mSizerFrame->Layout(); 
    470483} 
    471484 
     
    507520    wxBookCtrlBase *currBook = GetCurrentBook(); 
    508521 
    509     m_type = event.GetId(); 
     522    mType = event.GetId(); 
    510523 
    511524    if (currBook) 
    512         m_sizerFrame->Hide(currBook); 
     525        mSizerFrame->Hide(currBook); 
    513526 
    514527    ShowCurrentBook(); 
     
    517530void MyFrame::OnOrient(wxCommandEvent& event) 
    518531{ 
    519     m_orient = event.GetId(); 
     532    mOrient = event.GetId(); 
    520533    RecreateBooks(); 
    521     m_sizerFrame->Layout(); 
     534    mSizerFrame->Layout(); 
    522535} 
    523536 
    524537void MyFrame::OnShowImages(wxCommandEvent& event) 
    525538{ 
    526     m_chkShowImages = event.IsChecked(); 
     539    mChkShowImages = event.IsChecked(); 
    527540    RecreateBooks(); 
    528     m_sizerFrame->Layout(); 
     541    mSizerFrame->Layout(); 
    529542} 
    530543 
    531544void MyFrame::OnMulti(wxCommandEvent& event) 
    532545{ 
    533     m_multi = event.IsChecked(); 
     546    mMulti = event.IsChecked(); 
    534547    RecreateBooks(); 
    535     m_sizerFrame->Layout(); 
     548    mSizerFrame->Layout(); 
    536549    wxLogMessage(_T("Multiline setting works only in wxNotebook.")); 
    537550} 
     
    548561    wxBookCtrlBase *currBook = GetCurrentBook(); 
    549562 
    550     if ( currBook ) 
    551     { 
    552         wxPanel *panel = new wxPanel( currBook, wxID_ANY ); 
     563    if (currBook) 
     564    { 
     565        wxPanel *panel = new wxPanel(currBook, wxID_ANY); 
     566 
    553567        (void) new wxButton( panel, wxID_ANY, wxT("First button"), 
    554568            wxPoint(10, 10), wxDefaultSize ); 
     
    556570            wxPoint(50, 100), wxDefaultSize ); 
    557571 
    558         currBook->AddPage(panel, wxString::Format(ADDED_PAGE_NAME wxT("%u"), 
    559             ++s_pageAdded), true, GetIconIndex(currBook) ); 
    560     } 
    561 } 
     572        currBook->AddPage( 
     573                        panel, wxString::Format(ADDED_PAGE_NAME wxT("%u"), 
     574            ++ s_pageAdded), true, GetIconIndex(currBook) ); 
     575    } 
     576} 
     577 
    562578 
    563579void MyFrame::OnInsertPage(wxCommandEvent& WXUNUSED(event)) 
     
    567583    wxBookCtrlBase *currBook = GetCurrentBook(); 
    568584 
    569     if ( currBook ) 
    570     { 
    571         wxPanel *panel = CreateUserCreatedPage( currBook ); 
     585    if (currBook) 
     586    { 
     587        wxPanel *panel = CreateUserCreatedPage(currBook); 
    572588 
    573589        currBook->InsertPage( 0, panel, 
    574             wxString::Format(INSERTED_PAGE_NAME wxT("%u"), ++s_pageIns), false, 
     590            wxString::Format(INSERTED_PAGE_NAME wxT("%u"), ++ s_pageIns), false, 
    575591            GetIconIndex(currBook) ); 
    576592 
     
    579595} 
    580596 
     597 
    581598void MyFrame::OnDeleteCurPage(wxCommandEvent& WXUNUSED(event)) 
    582599{ 
    583600    wxBookCtrlBase *currBook = GetCurrentBook(); 
    584601 
    585     if ( currBook ) 
    586     { 
    587         int sel = currBook->GetSelection(); 
     602    if (currBook) 
     603    { 
     604        const int sel = currBook->GetSelection(); 
    588605 
    589606        if (sel != wxNOT_FOUND) 
     
    600617    if ( currBook ) 
    601618    { 
    602         int page = currBook->GetPageCount(); 
     619        const int page = currBook->GetPageCount(); 
    603620 
    604621        if ( page != 0 ) 
     
    613630    wxBookCtrlBase *currBook = GetCurrentBook(); 
    614631 
    615     if ( currBook ) 
     632    if (currBook) 
    616633    { 
    617634        currBook->AdvanceSelection(); 
     
    643660 
    644661        wxString title; 
    645         title.Printf(wxT("Notebook and friends (%d pages, selection: %s)"), nPages, selection.c_str()); 
     662        title.Printf(wxT("Preprocessor (%d pages, selection: %s)"), nPages, selection.c_str()); 
    646663 
    647664        SetTitle(title); 
     
    650667 
    651668#if USE_LOG 
    652     #define BOOKEVENT_LOG m_text->SetInsertionPointEnd(); 
     669    #define BOOKEVENT_LOG mText->SetInsertionPointEnd(); 
    653670#else 
    654671    #define BOOKEVENT_LOG 
  • GTP/trunk/Lib/Vis/Preprocessing/FrontEnd/preprocessorFrontEnd.h

    r1558 r1563  
    2929DECLARE_APP(MyApp) 
    3030 
     31 
    3132class MyFrame : public wxFrame 
    3233{ 
    3334public: 
    34     MyFrame(const wxString& title, const wxPoint& pos = wxDefaultPosition, 
    35         const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE|wxCLIP_CHILDREN|wxNO_FULL_REPAINT_ON_RESIZE); 
     35    MyFrame(const wxString& title,  
     36                        const wxPoint& pos = wxDefaultPosition, 
     37                        const wxSize& size = wxDefaultSize,  
     38                        long style = wxDEFAULT_FRAME_STYLE | wxCLIP_CHILDREN | wxNO_FULL_REPAINT_ON_RESIZE); 
    3639 
    3740    virtual ~MyFrame(); 
     
    6366    wxBookCtrlBase *GetCurrentBook(); 
    6467 
     68        wxPanel *CreateUserCreatedPage(wxBookCtrlBase *parent); 
     69        wxPanel *CreatePreprocessorPage(wxBookCtrlBase *parent); 
     70        wxPanel *CreateViewCellsPage(wxBookCtrlBase *parent); 
     71        void CreateInitialPages(wxBookCtrlBase *parent); 
     72        wxPanel *CreatePage(wxBookCtrlBase *parent, const wxString&pageName); 
     73 
    6574private: 
    66     wxLog *m_logTargetOld; 
    6775 
    6876    int SelectFlag(int id, int nb, int lb, int chb); 
     
    7179 
    7280    // Sample setup 
    73     int m_type; 
    74     int m_orient; 
    75     bool m_chkShowImages; 
    76     bool m_multi; 
     81    int mType; 
     82    int mOrient; 
     83    bool mChkShowImages; 
     84    bool mMulti; 
    7785 
     86        wxLog *mLogTargetOld; 
     87 
     88        ///////// 
    7889    // Controls 
    7990 
    80     wxPanel *m_panel; // Panel containing notebook and other controls 
     91        /// Panel containing notebook and other controls 
     92    wxPanel *mPanel; 
    8193 
    8294#if wxUSE_NOTEBOOK 
    83     wxNotebook   *m_notebook; 
     95    wxNotebook   *mNotebook; 
    8496#endif 
    8597#if wxUSE_CHOICEBOOK 
    86     wxChoicebook *m_choicebook; 
     98    wxChoicebook *mChoicebook; 
    8799#endif 
    88100#if wxUSE_LISTBOOK 
    89     wxListbook   *m_listbook; 
     101    wxListbook   *mListbook; 
    90102#endif 
    91103 
    92104#if USE_LOG 
    93105    // Log window 
    94     wxTextCtrl *m_text; 
     106    wxTextCtrl *mText; 
    95107#endif // USE_LOG 
    96108 
    97     wxBoxSizer *m_sizerFrame; 
     109        wxTextCtrl *mDetectEmptyViewSpaceText; 
     110        wxCheckBox *mDetectEmptyViewSpaceCheckBox; 
    98111 
    99     wxImageList *m_imageList; 
     112    wxBoxSizer *mSizerFrame; 
     113    wxImageList *mImageList; 
    100114 
    101115    DECLARE_EVENT_TABLE() 
     
    126140}; 
    127141 
     142 
     143/*class PreprocessorFrontEnd 
     144{ 
     145        wxPanel *CreateUserCreatedPage(wxBookCtrlBase *parent); 
     146        wxPanel *CreatePreprocessorPage(wxBookCtrlBase *parent); 
     147        wxPanel *CreateViewCellsPage(wxBookCtrlBase *parent); 
     148 
     149        MyFrame *mFrame; 
     150}*/ 
     151 
     152 
    128153/* 
    129154Name of each notebook page. 
     
    131156to decide what type of page it is. 
    132157*/ 
     158#define PREPROCESSOR_PAGE_NAME wxT("Preprocessor") 
     159#define VIEWCELLS_PAGE_NAME  wxT("ViewCells") 
    133160 
    134161#define I_WAS_INSERTED_PAGE_NAME  wxT("Inserted") 
    135 #define RADIOBUTTONS_PAGE_NAME wxT("Radiobuttons") 
    136162#define VETO_PAGE_NAME wxT("Veto") 
    137163#define MAXIMIZED_BUTTON_PAGE_NAME wxT("Maximized button") 
  • GTP/trunk/Lib/Vis/Preprocessing/FrontEnd/preprocessorFrontEnd.vcproj

    r1558 r1563  
    9292                                Optimization="2" 
    9393                                InlineFunctionExpansion="1" 
    94                                 AdditionalIncludeDirectories="$(WXWIN)\lib\vc_lib\msw,$(WXWIN)\include,.,$(WXWIN)\samples" 
     94                                AdditionalIncludeDirectories=""$(WXWIN)\lib\vc_lib\msw";"$(WXWIN)\include";.;"$(WXWIN)\samples"" 
    9595                                PreprocessorDefinitions="WIN32;__WXMSW__;_WINDOWS;NOPCH" 
    9696                                StringPooling="TRUE" 
     
    564564                                AdditionalOptions="/EHsc " 
    565565                                Optimization="0" 
    566                                 AdditionalIncludeDirectories="$(WXWIN)\lib\vc_lib\mswd,$(WXWIN)\include,.,$(WXWIN)\samples" 
     566                                AdditionalIncludeDirectories=""$(WXWIN)\lib\vc_lib\mswd";"$(WXWIN)\include";.;"$(WXWIN)\samples";"$(WXWIN)\include\msvc"" 
    567567                                PreprocessorDefinitions="WIN32;_DEBUG;__WXMSW__;__WXDEBUG__;_WINDOWS;NOPCH" 
    568568                                BasicRuntimeChecks="3" 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp

    r1551 r1563  
    892892        int nObjectsLeft = 0; 
    893893        const int nTotalObjects = (int)tData.mNode->mObjects.size(); 
    894         const float viewSpaceVol = mHierarchyManager->GetViewSpaceBox().GetVolume(); 
     894        const float viewSpaceVol = mViewCellsManager->GetViewSpaceBox().GetVolume(); 
    895895 
    896896        SortableEntryContainer::const_iterator backObjectsStart = mSubdivisionCandidates->begin(); 
     
    12941294                const float area = box.SurfaceArea(); 
    12951295 
    1296                 return (float)objects.size() * area / mHierarchyManager->GetViewSpaceBox().SurfaceArea(); 
     1296                return (float)objects.size() * area / mViewCellsManager->GetViewSpaceBox().SurfaceArea(); 
    12971297        } 
    12981298        else 
     
    13001300                //-- render cost heuristics 
    13011301 
    1302                 const float viewSpaceVol = mHierarchyManager->GetViewSpaceBox().GetVolume(); 
     1302                const float viewSpaceVol = mViewCellsManager->GetViewSpaceBox().GetVolume(); 
    13031303                // probability that view point lies in a view cell which sees this node 
    13041304                const float p = EvalViewCellsVolume(objects) / viewSpaceVol;     
     
    17121712        bvhLeaf->SetSubdivisionCandidate(oSubdivisionCandidate); 
    17131713 
    1714         const float viewSpaceVol = mHierarchyManager->GetViewSpaceBox().GetVolume(); 
     1714        const float viewSpaceVol = mViewCellsManager->GetViewSpaceBox().GetVolume(); 
    17151715        mTotalCost = (float)objects.size() * prop / viewSpaceVol; 
    17161716 
     
    18221822        bvhLeaf->SetSubdivisionCandidate(oSubdivisionCandidate); 
    18231823 
    1824         const float viewSpaceVol = mHierarchyManager->GetViewSpaceBox().GetVolume(); 
     1824        const float viewSpaceVol = mViewCellsManager->GetViewSpaceBox().GetVolume(); 
    18251825        mTotalCost = (float)objects.size() * prop / viewSpaceVol; 
    18261826 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp

    r1551 r1563  
    184184                SimpleRay sray(oldRay.mOrigin, p - oldRay.mOrigin); 
    185185         
    186                 VssRay *newRay = mRayCaster->CastRay(sray, mViewSpaceBox, false); 
     186                VssRay *newRay = mRayCaster->CastRay(sray, mViewCellsManager->GetViewSpaceBox(), false); 
    187187                //cout << "\np1: " << p1 << "\np : " <<  p << "\np2: " << p2 << endl; 
    188188                if (!newRay) return 0; 
     
    293293                                                                                 const VssRay &oldRay) 
    294294{ 
    295         cout << "r"; 
    296295        ++ mReverseSamples; 
    297296 
     
    393392        const long startTime = GetTime(); 
    394393 
    395         mViewSpaceBox = mKdTree->GetBox(); 
    396394        Randomize(0); 
    397395         
     
    406404 
    407405        if (!mLoadViewCells) 
    408         {       /// construct the view cells from the scratch 
    409                 ConstructViewCells(mViewSpaceBox); 
    410                 cout << "view cells loaded" << endl; 
     406        {        
     407                /// construct the view cells from the scratch 
     408                ConstructViewCells(); 
     409                cout << "finished view cell construction" << endl; 
    411410        } 
    412411        else if (1) 
    413         {        cout << "here2255566" << endl;  
     412        {        
    414413                //-- load view cells from file 
    415414                //-- test successful view cells loading by exporting them again 
    416415                VssRayContainer dummies; 
    417416                mViewCellsManager->Visualize(mObjects, dummies); 
    418                 mViewCellsManager->ExportViewCells("test.xml.zip", mViewCellsManager->GetExportPvs(), mObjects); 
     417                mViewCellsManager->ExportViewCells("test.xml.gz", mViewCellsManager->GetExportPvs(), mObjects); 
    419418        } 
    420419 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h

    r1545 r1563  
    128128        int mSamplingType; 
    129129 
    130         AxisAlignedBox3 mViewSpaceBox; 
     130        //AxisAlignedBox3 mViewSpaceBox; 
    131131        float mEps; 
    132132        float mThreshold; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GzBinFileInputStream.h

    r1294 r1563  
    134134inline bool GzBinFileInputStream::getIsOpen() const 
    135135{ 
    136         return bool (mStream.is_open());//(fSource != 0); 
     136        return mStream.is_open() != 0;//(fSource != 0); 
    137137} 
    138138 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1557 r1563  
    163163} 
    164164 
    165  
     165/* 
    166166AxisAlignedBox3 HierarchyManager::GetViewSpaceBox() const 
    167167{ 
    168168        return mVspTree->mBoundingBox; 
    169 } 
     169}*/ 
    170170 
    171171 
     
    312312        cout << "\nfinished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
    313313 
    314 #if _DEBUG 
     314/*#if _DEBUG 
    315315        cout << "view space: " << GetViewSpaceBox() << endl; 
    316316        cout << "object space:  " << GetObjectSpaceBox() << endl; 
    317 #endif 
     317#endif*/ 
    318318 
    319319        mObjectSpaceSubdivisionType = mSavedObjectSpaceSubdivisionType; 
     
    709709        cout << "\nfinished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
    710710 
    711 #if _DEBUG 
     711/*#if _DEBUG 
    712712        cout << "view space: " << GetViewSpaceBox() << endl; 
    713713        cout << "object space:  " << GetObjectSpaceBox() << endl; 
    714 #endif 
     714#endif*/ 
    715715 
    716716        mHierarchyStats.Stop(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h

    r1557 r1563  
    195195        /** Returns view space bounding box. 
    196196        */ 
    197         AxisAlignedBox3 GetViewSpaceBox() const; 
     197        //AxisAlignedBox3 GetViewSpaceBox() const; 
    198198        /** Returns object space bounding box. 
    199199        */ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r1545 r1563  
    422422        /////// 
    423423        //-- parse view cells construction method 
     424 
    424425        Environment::GetSingleton()->GetBoolValue("ViewCells.loadFromFile", mLoadViewCells); 
    425426        char buf[100]; 
     
    429430                Environment::GetSingleton()->GetStringValue("ViewCells.filename", buf); 
    430431                cout << "loading view cells from " << buf << endl; 
     432                 
    431433                mViewCellsManager = ViewCellsManager::LoadViewCells(buf, &mObjects, true); 
     434 
    432435                if (!mViewCellsManager) 
    433436                        return false; 
     
    440443 
    441444                // default view space is the extent of the scene 
    442                 mViewCellsManager->SetViewSpaceBox(mSceneGraph->GetBox()); 
    443  
     445                AxisAlignedBox3 box = mSceneGraph->GetBox(); 
     446                                         
     447                if (0) 
     448                { 
     449                        // use a small box outside of the scene 
     450                        box.Scale(Vector3(0.1f,0.5f,0.5f)); 
     451                        box.Translate(Vector3(Magnitude(mSceneGraph->GetBox().Size())*0.5f, 0, 0)); 
     452                } 
     453 
     454                mViewCellsManager->SetViewSpaceBox(box); 
     455          
    444456                bool loadVcGeometry; 
    445457                Environment::GetSingleton()->GetBoolValue("ViewCells.loadGeometry", loadVcGeometry); 
     
    492504 
    493505   
    494 bool Preprocessor::ConstructViewCells(const AxisAlignedBox3 &viewSpaceBox) 
    495 { 
    496         mViewCellsManager->SetViewSpaceBox(viewSpaceBox); 
    497          
     506bool Preprocessor::ConstructViewCells() 
     507{ 
    498508        // construct view cells using it's own set of samples 
    499509        mViewCellsManager->Construct(this); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h

    r1545 r1563  
    9292  /** Construct viewcells from the scratch  
    9393  */ 
    94   bool ConstructViewCells(const AxisAlignedBox3 &viewSpaceBox); 
     94  bool ConstructViewCells(); 
    9595 
    9696  /** Returns the specified sample strategy, NULL if no valid strategy. 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp

    r1520 r1563  
    283283  exporter->SetWireframe(); 
    284284 
    285   if (1 || mViewSpaceBox) { 
     285  if (1) { 
    286286        exporter->SetForcedMaterial(RgbColor(1,0,1)); 
    287287        exporter->ExportBox(mViewCellsManager->GetViewSpaceBox()); 
     
    321321  exporter->SetWireframe(); 
    322322 
    323   if (1 || mViewSpaceBox) { 
     323  if (1) { 
    324324        exporter->SetForcedMaterial(RgbColor(1,0,1)); 
    325325        exporter->ExportBox(mViewCellsManager->GetViewSpaceBox()); 
     
    361361  exporter->SetWireframe(); 
    362362  exporter->ExportKdTree(*mKdTree); 
    363          
    364   if (mViewSpaceBox) { 
    365         exporter->SetForcedMaterial(RgbColor(1,0,0)); 
    366         exporter->ExportBox(*mViewSpaceBox); 
    367         exporter->ResetForcedMaterial(); 
    368   } 
    369363         
    370364  exporter->SetForcedMaterial(RgbColor(0,0,1)); 
     
    510504  int totalSamples = 0; 
    511505 
    512   mViewSpaceBox = NULL; 
    513  
    514506  // if not already loaded, construct view cells from file 
    515507  if (!mLoadViewCells) 
    516508  { 
    517         if (1)  
    518           mViewCellsManager->SetViewSpaceBox(mKdTree->GetBox()); 
    519         else { 
    520           AxisAlignedBox3 box = mKdTree->GetBox(); 
    521            
    522           if (1) { 
    523                 // use a small box outside of the scene 
    524                 box.Scale(Vector3(0.1f,0.5f,0.5f)); 
    525                 box.Translate(Vector3(Magnitude(mKdTree->GetBox().Size())*0.5f, 0, 0)); 
    526           } else { 
    527                 float s = box.Size(0); 
    528                 box.Scale(0.1f); 
    529                 box.SetMin(0, box.Min(0) + s); 
    530                 box.SetMax(0, box.Max(0) + s); 
    531           } 
    532           
    533           mViewCellsManager->SetViewSpaceBox(box); 
    534         } 
    535          
    536         // construct view cells using it's own set of samples 
    537         mViewCellsManager->Construct(this); 
    538          
    539         //-- several visualizations and statistics 
    540         Debug << "view cells construction finished: " << endl; 
    541         mViewCellsManager->PrintStatistics(Debug); 
    542   } 
    543    
     509          // construct view cells using it's own set of samples 
     510          mViewCellsManager->Construct(this); 
     511 
     512          //-- several visualizations and statistics 
     513          Debug << "view cells construction finished: " << endl; 
     514          mViewCellsManager->PrintStatistics(Debug); 
     515  } 
     516 
    544517   
    545518  int rssPass = 0; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.h

    r1281 r1563  
    3838  bool mDirectionalSampling; 
    3939   
    40   AxisAlignedBox3 *mViewSpaceBox; 
     40  //AxisAlignedBox3 *mViewSpaceBox; 
    4141 
    4242  ofstream mStats; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RssTree.cpp

    r1548 r1563  
    348348  } else { 
    349349        mRoots.resize(1); 
    350         RssTreeLeaf *leaf = new RssTreeLeaf(NULL, rays.size()); 
     350        RssTreeLeaf *leaf = new RssTreeLeaf(NULL, (int)rays.size()); 
    351351        leaf->bbox.Initialize(); 
    352352        leaf->dirBBox.Initialize(); 
     
    18971897  } 
    18981898 
    1899   return rays.size(); 
     1899  return (int)rays.size(); 
    19001900} 
    19011901 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SamplingPreprocessor.cpp

    r1520 r1563  
    118118 
    119119  Randomize(0); 
    120    
    121   long startTime = GetTime(); 
    122    
     120  const long startTime = GetTime(); 
    123121  int totalSamples = 0; 
    124122 
     
    126124  if (!mLoadViewCells) 
    127125  { 
    128           ConstructViewCells(mKdTree->GetBox()); 
    129   } 
    130    
    131  
    132    
     126          ConstructViewCells(); 
     127  } 
     128     
    133129  int samples = 0; 
    134130  int i=0; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp

    r1558 r1563  
    171171mTimeStamp(1), 
    172172mViewCellsTree(NULL), 
    173 mOutOfBoundsCellPartOfTree(false) 
     173mOutOfBoundsCellPartOfTree(false), 
     174mOutOfBoundsCell(NULL) 
    174175{ 
    175176        Randomize(); // initialise random generator for heuristics 
     
    956957        { 
    957958                tData = tStack.top(); 
    958  
    959959            tStack.pop(); 
    960960 
     
    10101010                if (!mUsePredefinedViewCells) 
    10111011                {       // generate new view cell for each leaf 
    1012                         viewCell = new BspViewCell(); 
     1012                        viewCell = new BspViewCell();cout << "g"; 
    10131013                } 
    10141014                else 
    1015                 { 
     1015                {        
    10161016                        // add predefined view cell to leaf 
    10171017                        viewCell = dynamic_cast<BspViewCell *>(tData.mViewCell); 
    1018  
    10191018                        // from now on out of bounds cell can be handled as any other cell, 
    10201019                        // responsibility for deleting has been shifted 
    1021                         if (viewCell == mOutOfBoundsCell) 
     1020                        if (IsOutOfBounds(viewCell)) 
    10221021                        { 
    10231022                                mOutOfBoundsCellPartOfTree = true; 
    10241023                        } 
     1024                 
    10251025                } 
    10261026 
     
    10351035                else 
    10361036                        viewCell->SetVolume(probability); 
    1037  
    10381037                 
    10391038                /////////// 
     
    10491048                } 
    10501049 
    1051                 if (1)EvaluateLeafStats(tData); 
    1052                  
    1053  
     1050                if (1) EvaluateLeafStats(tData); 
     1051                 
    10541052                //////// 
    10551053                //-- clean up 
     
    23992397        { 
    24002398                // per definition out of bounds cell has zero volume 
    2401                 if ((*it) == mOutOfBoundsCell) 
     2399                if (IsOutOfBounds(*it)) 
    24022400                        continue; 
    24032401 
     
    33253323ViewCell *BspTree::GetViewCell(const Vector3 &point) 
    33263324{ 
    3327   if (mRoot == NULL) 
    3328         return NULL; 
    3329    
    3330  
    3331   stack<BspNode *> nodeStack; 
    3332   nodeStack.push(mRoot); 
    3333    
    3334   ViewCellLeaf *viewcell = NULL; 
    3335    
    3336   while (!nodeStack.empty())  { 
    3337         BspNode *node = nodeStack.top(); 
    3338         nodeStack.pop(); 
    3339          
    3340         if (node->IsLeaf()) { 
    3341           viewcell = dynamic_cast<BspLeaf *>(node)->mViewCell; 
    3342           break; 
    3343         } else { 
    3344            
    3345           BspInterior *interior = dynamic_cast<BspInterior *>(node); 
    3346                  
    3347           // random decision 
    3348           if (interior->GetPlane().Side(point) < 0) 
    3349                 nodeStack.push(interior->GetBack()); 
    3350           else 
    3351                 nodeStack.push(interior->GetFront()); 
    3352         } 
    3353   } 
    3354    
    3355   return viewcell; 
     3325        if (mRoot == NULL) 
     3326                return NULL; 
     3327 
     3328        stack<BspNode *> nodeStack; 
     3329        nodeStack.push(mRoot); 
     3330 
     3331        ViewCellLeaf *viewcell = NULL; 
     3332 
     3333        while (!nodeStack.empty())  { 
     3334                BspNode *node = nodeStack.top(); 
     3335                nodeStack.pop(); 
     3336 
     3337                if (node->IsLeaf())  
     3338                { 
     3339                        viewcell = dynamic_cast<BspLeaf *>(node)->mViewCell; 
     3340                        break; 
     3341                }  
     3342                else  
     3343                { 
     3344 
     3345                        BspInterior *interior = dynamic_cast<BspInterior *>(node); 
     3346 
     3347                        // random decision 
     3348                        if (interior->GetPlane().Side(point) < 0) 
     3349                        { 
     3350                                nodeStack.push(interior->GetBack()); 
     3351                        } 
     3352                        else 
     3353                        { 
     3354                                nodeStack.push(interior->GetFront()); 
     3355                        } 
     3356                } 
     3357        } 
     3358 
     3359        return viewcell; 
    33563360} 
    33573361 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.h

    r1558 r1563  
    625625        int     _CastRay(Ray &ray); 
    626626 
     627        /** Casts line segment between origin and termination and returns 
     628                view cells which are touched by the line. 
     629        */ 
    627630        int     CastLineSegment(const Vector3 &origin, 
    628631                                                const Vector3 &termination, 
     
    630633                                                ); 
    631634 
     635        /** Returns view cell this point is located in. 
     636        */ 
    632637        ViewCell *GetViewCell(const Vector3 &point); 
    633638   
     
    665670        */ 
    666671        BspLeaf *GetRandomLeaf(const bool onlyUnmailed = false); 
    667  
    668672 
    669673        /** Returns epsilon of this tree. 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1557 r1563  
    233233  Mesh *m = vc->GetMesh(); 
    234234   
    235   if (m) { 
    236         m->ComputeBoundingBox(); 
    237         return m->mBox; 
     235  if (m)  
     236  { 
     237          m->ComputeBoundingBox(); 
     238          return m->mBox; 
    238239  } 
    239240 
    240241  AxisAlignedBox3 box; 
    241    
    242242  box.Initialize(); 
    243243   
     
    289289        { 
    290290                VssRayContainer::const_iterator it, it_end = rays.end(); 
    291  
    292291                for (it = rays.begin(); it != it_end; ++ it) 
    293292                { 
     
    298297        { 
    299298                VssRayContainer::const_iterator it, it_end = rays.end(); 
    300  
    301299                for (it = rays.begin(); it != it_end; ++ it) 
    302300                { 
    303                         //(*it)->Unref(); 
    304301                        if (!(*it)->IsActive()) 
    305302                                delete (*it); 
     
    322319        mPreprocessor = preprocessor; 
    323320         
    324          
     321 
    325322        /////////////////////////////////////////////////////// 
    326323        //-- Initial sampling for the construction of the view cell hierarchy.  
     
    361358        { 
    362359                //-- export initial view cell partition 
    363                 Debug << "\nView cells after initial sampling:\n"  
    364                           << mCurrentViewCellsStats << endl; 
     360                Debug << "\nView cells after initial sampling:\n" << mCurrentViewCellsStats << endl; 
    365361 
    366362                const string filename("viewcells.wrl"); 
     
    428424 
    429425         
    430 #if 0 
    431         /////////////// 
    432         //-- Get stats after the additional sampling step 
    433         //-- and before the bottom-up merge step 
    434  
    435         EvaluateViewCellsStats(); 
    436         Debug << "\noriginal view cell partition before post process:\n"  
    437                   << mCurrentViewCellsStats << endl; 
    438  
    439         mRenderer->RenderScene(); 
    440         SimulationStatistics ss; 
    441         dynamic_cast<RenderSimulator *>(mRenderer)->GetStatistics(ss); 
    442  
    443     Debug << ss << endl; 
    444 #endif 
    445  
     426        if (0) 
     427        { 
     428                /////////////// 
     429                //-- Get stats after the additional sampling step 
     430                //-- and before the bottom-up merge step 
     431 
     432                EvaluateViewCellsStats(); 
     433                Debug << "\noriginal view cell partition before post process:\n"  
     434                          << mCurrentViewCellsStats << endl; 
     435         
     436                mRenderer->RenderScene(); 
     437                SimulationStatistics ss; 
     438                dynamic_cast<RenderSimulator *>(mRenderer)->GetStatistics(ss); 
     439 
     440                Debug << ss << endl; 
     441        } 
    446442 
    447443        //////////////////// 
     
    612608{ 
    613609        ViewCellsParser parser; 
    614  
    615610        ViewCellsManager *vm = NULL; 
    616611 
    617612        if (parser.ParseViewCellsFile(filename, &vm, objects, bconverter)) 
    618613        { 
    619                 long startTime = GetTime(); 
     614                const long startTime = GetTime(); 
    620615 
    621616                vm->ResetViewCells(); 
     
    671666                for (oit = objects.begin(); oit != oit_end; ++ oit) 
    672667                { 
    673                         MeshInstance *mi = dynamic_cast<MeshInstance *>(*oit); 
    674                         const AxisAlignedBox3 box = mi->GetBox(); 
     668                        const AxisAlignedBox3 box = (*oit)->GetBox(); 
    675669 
    676670                        //////////// 
    677671                        //-- the bounding boxes 
    678                         stream << "<BoundingBox" << " id=\"" << mi->GetId() << "\"" 
     672                        stream << "<BoundingBox" << " id=\"" << (*oit)->GetId() << "\"" 
    679673                                   << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\"" 
    680674                                   << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl; 
     
    12621256                                                                                         const bool extrudeBaseTriangles) 
    12631257{ 
    1264         bool success; 
    1265  
    12661258        /// we use predefined view cells from now on 
    12671259        mUsePredefinedViewCells = true; 
     
    12711263        { 
    12721264                Environment::GetSingleton()->GetFloatValue("ViewCells.height", parser.mViewCellHeight); 
    1273                 success = parser.ParseFile(filename, *this); 
     1265                const bool success = parser.ParseFile(filename, *this); 
     1266 
     1267                if (!success) 
     1268                        return false; 
    12741269        } 
    12751270        else 
     
    12771272                // hack: use standard mesh loading 
    12781273                // create temporary scene graph for loading the view cells geometry 
     1274                // note: delete the meshes as they are created two times for transformed mesh instances. 
    12791275                SceneGraphNode *root = new SceneGraphNode(); 
    1280                 success = parser.ParseFile(filename, root, true); 
    1281                                  
    1282                 if (success) 
    1283                 { 
    1284                         ObjectContainer::const_iterator oit, oit_end = root->mGeometry.end(); 
    1285                         for (oit = root->mGeometry.begin(); oit != oit_end; ++ oit) 
     1276                const bool success = parser.ParseFile(filename, root, true); 
     1277                 
     1278                if (!success) 
     1279                { 
     1280                        DEL_PTR(root); 
     1281                        return false; 
     1282                } 
     1283 
     1284                ObjectContainer::const_iterator oit, oit_end = root->mGeometry.end(); 
     1285                 
     1286                for (oit = root->mGeometry.begin(); oit != oit_end; ++ oit) 
     1287                { 
     1288                        Mesh *mesh; 
     1289                        if ((*oit)->Type() == Intersectable::TRANSFORMED_MESH_INSTANCE) 
    12861290                        { 
    1287                                 if ((*oit)->Type() == Intersectable::TRANSFORMED_MESH_INSTANCE) 
    1288                                 { 
    1289                                         TransformedMeshInstance *mit = dynamic_cast<TransformedMeshInstance *>(*oit); 
    1290                                         Mesh *mesh = MeshManager::GetSingleton()->CreateResource(); 
    1291                                         mit->GetTransformedMesh(*mesh); 
    1292                                         mesh->ComputeBoundingBox(); 
    1293                                         mViewCells.push_back(GenerateViewCell(mesh)); 
    1294                                 } 
    1295                                 else if ((*oit)->Type() == Intersectable::MESH_INSTANCE) 
    1296                                 { 
    1297                                         MeshInstance *mit = dynamic_cast<MeshInstance *>(*oit); 
    1298                                         mViewCells.push_back(GenerateViewCell(mit->GetMesh())); 
    1299                                 }                        
     1291                                TransformedMeshInstance *mit = dynamic_cast<TransformedMeshInstance *>(*oit); 
     1292                                mesh = MeshManager::GetSingleton()->CreateResource(); 
     1293                                mit->GetTransformedMesh(*mesh); 
    13001294                        } 
    1301                 } 
     1295                        else if ((*oit)->Type() == Intersectable::MESH_INSTANCE) 
     1296                        { 
     1297                                MeshInstance *mit = dynamic_cast<MeshInstance *>(*oit); 
     1298                                mesh = mit->GetMesh(); 
     1299                        } 
     1300                        mesh->ComputeBoundingBox(); 
     1301                        mViewCells.push_back(GenerateViewCell(mesh)); 
     1302                } 
     1303 
    13021304                DEL_PTR(root); 
    13031305        } 
    13041306 
    1305         if (success) 
    1306         { 
    1307                 // set view space box to bounding box of the view cells 
    1308                 AxisAlignedBox3 bbox; 
    1309                 bbox.Initialize(); 
    1310                 ViewCellContainer::iterator it = mViewCells.begin(), it_end = mViewCells.end(); 
    1311                 for (; it != it_end; ++ it)  
    1312                 { 
    1313                         bbox.Include(GetViewCellBox(*it)); 
    1314                 } 
    1315                 SetViewSpaceBox(bbox); 
    1316          
    1317                 cout << "generated " << (int)mViewCells.size() << " view cells using the geometry from file " << filename << endl; 
    1318         } 
    1319  
    1320         return success; 
     1307        // set view space box to bounding box of the view cells 
     1308        AxisAlignedBox3 bbox; 
     1309        bbox.Initialize(); 
     1310        ViewCellContainer::iterator it = mViewCells.begin(), it_end = mViewCells.end(); 
     1311 
     1312        for (; it != it_end; ++ it)  
     1313        { 
     1314                bbox.Include((*it)->GetMesh()->mBox); 
     1315        } 
     1316 
     1317        SetViewSpaceBox(bbox); 
     1318        cout << "view space box: " << bbox << endl; 
     1319        cout << "generated " << (int)mViewCells.size() << " view cells using the geometry " << filename << endl; 
     1320 
     1321        return true; 
    13211322} 
    13221323 
     
    25392540        VssRayContainer savedRays; 
    25402541 
     2542        // choose a a number of rays based on the ratio of cast rays / requested rays 
    25412543        const int limit = min(mInitialSamples, (int)rays.size()); 
    2542  
    25432544        VssRayContainer::const_iterator it, it_end = rays.end(); 
    25442545 
    25452546        const float prop = (float)limit / ((float)rays.size() + Limits::Small); 
    2546  
    25472547        for (it = rays.begin(); it != it_end; ++ it) 
    25482548        { 
     
    27852785                return; 
    27862786         
    2787         int savedColorCode = mColorCode; 
     2787        const int savedColorCode = mColorCode; 
    27882788         
    27892789        if (1) // export final view cells 
     
    29892989                                                                                                 const AxisAlignedBox3 *sceneBox, 
    29902990                                                                                                 const AxisAlignedPlane *clipPlane 
    2991                                                                                                  ) const 
    2992 { 
    2993         // out of bounds cell 
    2994         //if (vc->GetId() == OUT_OF_BOUNDS_ID) return; 
    2995  
    2996         // export mesh if available 
    2997         if (vc->GetMesh()) 
    2998         { 
    2999                 exporter->ExportMesh(vc->GetMesh()); 
    3000                 return; 
    3001         } 
    3002  
    3003         // otherwise construct from leaves 
     2991                                                                                                        ) const 
     2992{ 
    30042993        if (clipPlane) 
    30052994        { 
     
    30183007                        mBspTree->ConstructGeometry(*it, geom); 
    30193008 
    3020                         const float eps = 0.00000001f; 
     3009                        const float eps = 0.0001f; 
    30213010                        const int cf = geom.Side(plane, eps); 
    30223011 
     
    30323021                                                                   mViewSpaceBox,  
    30333022                                                                   eps); 
    3034          
     3023 
    30353024                                if (back.Valid()) 
    3036                                 {        
     3025                                { 
    30373026                                        exporter->ExportPolygons(back.GetPolys()); 
    30383027                                }                        
     
    30423031        else 
    30433032        { 
    3044                 BspNodeGeometry geom; 
    3045                 mBspTree->ConstructGeometry(vc, geom); 
    3046                 exporter->ExportPolygons(geom.GetPolys()); 
     3033                // export mesh if available 
     3034                // TODO: some bug here? 
     3035                if (1 && vc->GetMesh()) 
     3036                { 
     3037                        exporter->ExportMesh(vc->GetMesh()); 
     3038                } 
     3039                else 
     3040                { 
     3041                        BspNodeGeometry geom; 
     3042                        mBspTree->ConstructGeometry(vc, geom); 
     3043                        exporter->ExportPolygons(geom.GetPolys()); 
     3044                } 
    30473045        } 
    30483046} 
     
    31583156                for (oit = objects.begin(); oit != oit_end; ++ oit) 
    31593157                { 
    3160                         MeshInstance *mi = dynamic_cast<MeshInstance *>(*oit); 
    3161                         const AxisAlignedBox3 box = mi->GetBox(); 
     3158                        const AxisAlignedBox3 box = (*oit)->GetBox(); 
    31623159                         
    3163                         stream << "<BoundingBox" << " id=\"" << mi->GetId() << "\"" 
     3160                        stream << "<BoundingBox" << " id=\"" << (*oit)->GetId() << "\"" 
    31643161                                   << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\"" 
    31653162                                   << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl; 
     
    41234120                { 
    41244121                        cout << "exporting view cells after post process ... "; 
    4125  
    41264122                        if (0) 
    4127                         { 
    4128                                 // export view space box 
     4123                        {       // export view space box 
    41294124                                exporter->SetWireframe(); 
    41304125                                exporter->ExportBox(mViewSpaceBox); 
     
    41334128 
    41344129                        Material m;  
    4135  
    41364130                        m.mDiffuseColor.r = 0.0f; 
    41374131                        m.mDiffuseColor.g = 0.5f; 
     
    41404134            exporter->SetForcedMaterial(m); 
    41414135 
    4142                         if (0 && mExportGeometry) 
     4136                        if (1 && mExportGeometry) 
    41434137                        { 
    41444138                                exporter->ExportGeometry(objects); 
    41454139                        } 
    41464140 
    4147                         // export rays 
    41484141                        if (0 && mExportRays) 
    41494142                        { 
    41504143                                exporter->ExportRays(visRays, RgbColor(1, 0, 0)); 
    41514144                        } 
    4152  
    41534145                        ExportViewCellsForViz(exporter, NULL, GetClipPlane()); 
    41544146 
     
    45004492                                                                                                        ) const 
    45014493{ 
    4502         // out of bounds cell 
    4503         //if (vc->GetId() == OUT_OF_BOUNDS_ID)  return; 
    45044494        if (clipPlane) 
    45054495        { 
     
    45134503                { 
    45144504                        BspNodeGeometry geom; 
    4515  
    45164505                        BspNodeGeometry front; 
    45174506                        BspNodeGeometry back; 
     
    45454534                // export mesh if available 
    45464535                // TODO: some bug here? 
    4547                 if (0 && vc->GetMesh()) 
     4536                if (1 && vc->GetMesh()) 
    45484537                { 
    45494538                        exporter->ExportMesh(vc->GetMesh()); 
     
    50705059 
    50715060                        // matt: hack for clamping scene 
    5072                         AxisAlignedBox3 bbox = mHierarchyManager->GetViewSpaceBox(); 
     5061                        AxisAlignedBox3 bbox = mViewSpaceBox; 
    50735062                        bbox.Scale(Vector3(0.5, 1, 0.5)); 
    50745063                        if (CLAMP_TO_BOX) 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp

    r1558 r1563  
    850850 
    851851                // set view space box 
    852                 mVspBspTree->mBox = mViewSpaceBox; 
     852                mVspBspTree->mBoundingBox = mViewSpaceBox; 
    853853 
    854854                ViewCellsMap::iterator vit, vit_end = mViewCells.end(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r1558 r1563  
    277277                if (mesh)  
    278278                {       // // copy the mesh into polygons and add to BSP tree aabb 
    279                         mBox.Include(viewCells[i]->GetBox());  
     279                        mBoundingBox.Include(viewCells[i]->GetBox());  
    280280                        polysSize += AddMeshToPolygons(mesh, 
    281281                                                                                   polys, 
     
    326326        if (mesh) // copy the mesh data to polygons 
    327327                { 
    328                         mBox.Include(object->GetBox()); // add to BSP tree aabb 
     328                        mBoundingBox.Include(object->GetBox()); // add to BSP tree aabb 
    329329                        AddMeshToPolygons(mesh, polys, NULL); 
    330330 
     
    344344        if (forcedBoundingBox) 
    345345        { 
    346                 mBox = *forcedBoundingBox; 
     346                mBoundingBox = *forcedBoundingBox; 
    347347        } 
    348348        else // compute vsp tree bounding box 
    349349        { 
    350                 mBox.Initialize(); 
     350                mBoundingBox.Initialize(); 
    351351 
    352352                VssRayContainer::const_iterator rit, rit_end = sampleRays.end(); 
     
    358358 
    359359                        // compute bounding box of view space 
    360                         mBox.Include(ray->GetTermination()); 
    361                         mBox.Include(ray->GetOrigin()); 
     360                        mBoundingBox.Include(ray->GetTermination()); 
     361                        mBoundingBox.Include(ray->GetOrigin()); 
    362362                } 
    363363        } 
     
    393393                        Intersectable *obj = ray->mTerminationObject; 
    394394 
    395                         if ((mBox.IsInside(ray->mTermination) || !forcedBoundingBox) && 
     395                        if ((mBoundingBox.IsInside(ray->mTermination) || !forcedBoundingBox) && 
    396396                                obj && !obj->Mailed()) 
    397397                        { 
     
    419419                                //-- compute bounding box 
    420420                                if (!forcedBoundingBox) 
    421                                         mBox.Include(ray->mTermination); 
    422                         } 
    423  
    424                         if ((mBox.IsInside(ray->mOrigin) || !forcedBoundingBox) && 
     421                                        mBoundingBox.Include(ray->mTermination); 
     422                        } 
     423 
     424                        if ((mBoundingBox.IsInside(ray->mOrigin) || !forcedBoundingBox) && 
    425425                                ray->mOriginObject &&  
    426426                                !ray->mOriginObject->Mailed()) 
     
    460460 
    461461                // TODO: not very efficient to implictly cast between rays types 
    462                 if (mBox.GetRaySegment(hray, minT, maxT)) 
     462                if (mBoundingBox.GetRaySegment(hray, minT, maxT)) 
    463463                { 
    464464                        float len = ray->Length(); 
     
    473473        // normalize 
    474474        if (mUseAreaForPvs) 
    475                 mTermMinProbability *= mBox.SurfaceArea();  
     475                mTermMinProbability *= mBoundingBox.SurfaceArea();  
    476476        else  
    477                 mTermMinProbability *= mBox.GetVolume(); 
     477                mTermMinProbability *= mBoundingBox.GetVolume(); 
    478478 
    479479 
     
    547547 
    548548 
    549         mTotalCost = tData.mPvs * tData.mProbability / mBox.GetVolume(); 
     549        mTotalCost = tData.mPvs * tData.mProbability / mBoundingBox.GetVolume(); 
    550550        mTotalPvsSize = tData.mPvs; 
    551551         
     
    652652        tQueue.push(splitCandidate); 
    653653 
    654         mTotalCost = tData.mPvs * tData.mProbability / mBox.GetVolume(); 
     654        mTotalCost = tData.mPvs * tData.mProbability / mBoundingBox.GetVolume(); 
    655655        mTotalPvsSize = tData.mPvs; 
    656656         
     
    948948                         
    949949                        float costDecr =  
    950                                 (cFront + cBack - cData) / mBox.GetVolume(); 
     950                                (cFront + cBack - cData) / mBoundingBox.GetVolume(); 
    951951 
    952952                        mTotalCost += costDecr; 
     
    11091109         
    11101110        const float costDecr =  
    1111                 (cFront + cBack - cData) / mBox.GetVolume(); 
     1111                (cFront + cBack - cData) / mBoundingBox.GetVolume(); 
    11121112 
    11131113        mTotalCost += costDecr; 
     
    11621162                                                                           *backData.mGeometry, 
    11631163                                                                           splitPlane, 
    1164                                                                            mBox, 
     1164                                                                           mBoundingBox, 
    11651165                                                                           //0.0f); 
    11661166                                                                           mEpsilon); 
     
    20032003                                                                  geomBack, 
    20042004                                                                  candidatePlane, 
    2005                                                                   mBox, 
     2005                                                                  mBoundingBox, 
    20062006                                                                  //0.0f); 
    20072007                                                                  mEpsilon); 
     
    20412041        const float newRenderCost = penaltyFront * pFront + penaltyBack * pBack; 
    20422042 
    2043         const float renderCostDecrease = (oldRenderCost - newRenderCost) / mBox.GetVolume(); 
     2043        const float renderCostDecrease = (oldRenderCost - newRenderCost) / mBoundingBox.GetVolume(); 
    20442044         
    20452045        // take render cost of node into account to avoid being stuck in a local minimum 
    2046         normalizedOldRenderCost = oldRenderCost / mBox.GetVolume(); 
     2046        normalizedOldRenderCost = oldRenderCost / mBoundingBox.GetVolume(); 
    20472047         
    20482048        return renderCostDecrease; 
     
    21082108                                                                                                                  geomBack, 
    21092109                                                                                                                  candidatePlane, 
    2110                                                                                                                   mBox, 
     2110                                                                                                                  mBoundingBox, 
    21112111                                                                                                                  //0.0f); 
    21122112                                                                                                                  mEpsilon); 
     
    22362236                                                                        *secondGeom, 
    22372237                                                                        interior->GetPlane(), 
    2238                                                                         mBox, 
     2238                                                                        mBoundingBox, 
    22392239                                                                        //0.0000001f); 
    22402240                                                                        mEpsilon); 
     
    24272427AxisAlignedBox3 VspBspTree::GetBoundingBox() const 
    24282428{ 
    2429         return mBox; 
     2429        return mBoundingBox; 
    24302430} 
    24312431 
     
    25002500        float maxt, mint; 
    25012501 
    2502         if (!mBox.GetRaySegment(ray, mint, maxt)) 
     2502        if (!mBoundingBox.GetRaySegment(ray, mint, maxt)) 
    25032503                return 0; 
    25042504 
     
    27612761        PolygonContainer boxPolys; 
    27622762         
    2763         mBox.ExtractPolys(boxPolys); 
     2763        mBoundingBox.ExtractPolys(boxPolys); 
    27642764        vector<Plane3> boxPlanes; 
    27652765 
     
    29302930 
    29312931                for (int j = 0; j < 4; ++ j) 
    2932                         vertices.push_back(mBox.GetFace(i).mVertices[j]); 
     2932                { 
     2933                        vertices.push_back(mBoundingBox.GetFace(i).mVertices[j]); 
     2934                } 
    29332935 
    29342936                Polygon3 *poly = new Polygon3(vertices); 
     
    29672969 
    29682970                                        if (backPoly->Valid(mEpsilon)) 
     2971                                        { 
    29692972                                                candidatePolys[i] = backPoly; 
     2973                                        } 
    29702974                                        else 
     2975                                        { 
    29712976                                                DEL_PTR(backPoly); 
     2977                                        } 
    29722978 
    29732979                                        // outside, don't need this 
    29742980                                        DEL_PTR(frontPoly); 
    29752981                                        break; 
     2982 
    29762983                                // polygon outside of halfspace 
    29772984                                case Polygon3::FRONT_SIDE: 
    29782985                                        DEL_PTR(candidatePolys[i]); 
    29792986                                        break; 
     2987 
    29802988                                // just take polygon as it is 
    29812989                                case Polygon3::BACK_SIDE: 
     
    29892997                { 
    29902998                        geom.Add(candidatePolys[i], candidatePlanes[i]); 
    2991                         //      geom.mPolys.push_back(candidates[i]); 
    2992                 } 
    2993         } 
     2999                } 
     3000        } 
     3001} 
     3002 
     3003 
     3004bool VspBspTree::IsOutOfBounds(ViewCell *vc) const 
     3005{ 
     3006        return vc->GetId() == OUT_OF_BOUNDS_ID; 
     3007} 
     3008 
     3009 
     3010void VspBspTree::SetViewCellsTree(ViewCellsTree *viewCellsTree) 
     3011{ 
     3012        mViewCellsTree = viewCellsTree; 
    29943013} 
    29953014 
     
    30093028        for (it = leaves.begin(); it != it_end; ++ it) 
    30103029        { 
    3011                 if ((*it) == mOutOfBoundsCell) 
     3030                if (IsOutOfBounds(*it)) 
    30123031                        continue; 
    30133032                 
     
    31203139                                                                *bGeom, 
    31213140                                                                interior->GetPlane(), 
    3122                                                                 mBox, 
     3141                                                                mBoundingBox, 
    31233142                                                                //0.0000001f); 
    31243143                                                                eps); 
     
    32143233                                                                *bGeom, 
    32153234                                                                interior->GetPlane(), 
    3216                                                                 mBox, 
     3235                                                                mBoundingBox, 
    32173236                                                                //0.0000001f); 
    32183237                                                                eps); 
     
    37093728                                                                        *secondGeom, 
    37103729                                                                        interior->GetPlane(), 
    3711                                                                         mBox, 
     3730                                                                        mBoundingBox, 
    37123731                                                                        //0.0000001f); 
    37133732                                                                        mEpsilon); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.h

    r1545 r1563  
    356356        int ComputeBoxIntersections(const AxisAlignedBox3 &box, ViewCellContainer &viewCells) const; 
    357357 
    358         /// pointer to the hierarchy of view cells 
    359         ViewCellsTree *mViewCellsTree; 
    360  
     358        /** Pointer to the view cells tree. 
     359        */ 
     360        void SetViewCellsTree(ViewCellsTree *vct); 
     361         
     362        /** Returns true if this view cell prepresents 
     363                invalid view space. 
     364        */ 
     365        bool IsOutOfBounds(ViewCell *vc) const; 
     366 
     367         
    361368 
    362369protected: 
     
    736743 
    737744        /// box around the whole view domain 
    738         AxisAlignedBox3 mBox; 
    739  
    740          
     745        AxisAlignedBox3 mBoundingBox; 
     746 
     747        /// pointer to the hierarchy of view cells 
     748        ViewCellsTree *mViewCellsTree; 
     749 
     750 
    741751        //-- termination critera 
    742752 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp

    r1528 r1563  
    4040   
    4141  useViewspacePlane = mUseViewSpaceBox; //hack 
    42  
    43   mViewSpaceBox.Initialize(); 
    4442   
    4543  Debug << "*********** vss preprocessor options **************" << endl; 
     
    158156 
    159157  exporter->SetForcedMaterial(RgbColor(1,0,1)); 
    160   exporter->ExportBox(mViewSpaceBox); 
     158  exporter->ExportBox(mViewCellsManager->GetViewSpaceBox()); 
    161159  exporter->ResetForcedMaterial(); 
    162160 
     
    201199 
    202200  exporter->SetForcedMaterial(RgbColor(1,0,0)); 
    203   exporter->ExportBox(mViewSpaceBox); 
     201  exporter->ExportBox(mViewCellsManager->GetViewSpaceBox()); 
    204202  exporter->ResetForcedMaterial(); 
    205203 
     
    373371        Debug << "type: vss" << endl; 
    374372 
    375   long startTime = GetTime(); 
    376  
    377   int totalSamples = 0; 
    378  
    379  
    380   AxisAlignedBox3 box(mKdTree->GetBox()); 
    381    
    382   if (!useViewspacePlane) { 
    383         float size = 0.05f; 
    384         float s = 0.5f - size; 
    385         float olds = Magnitude(box.Size()); 
    386         box.Enlarge(box.Size()*Vector3(-s)); 
    387         Vector3 translation = Vector3(-olds*0.1f, 0, 0); 
    388         box.SetMin(box.Min() + translation); 
    389         box.SetMax(box.Max() + translation); 
    390   } else { 
    391  
    392         // sample city like heights 
    393         box.SetMin(1, box.Min(1) + box.Size(1)*0.2f); 
    394         box.SetMax(1, box.Min(1) + box.Size(1)*0.3f); 
    395   } 
    396  
    397   if (use2dSampling) 
    398         box.SetMax(1, box.Min(1)); 
    399  
    400   cout << "use view space box=" << mUseViewSpaceBox << endl; 
    401  
    402    
    403   if (mUseViewSpaceBox) 
    404   { 
    405           if (!mEnlargeViewSpace) 
    406           { 
    407                   mViewSpaceBox = AxisAlignedBox3(box); 
    408           } 
    409           else 
    410           { 
    411                   mViewSpaceBox = AxisAlignedBox3(mKdTree->GetBox()); 
    412  
    413                   if (0)  
    414                   { 
    415                           // HACK: enlarge in y directon 
    416                           Vector3 size = mViewSpaceBox.Size(); 
    417                          
    418                           size[1] *= 1.25; 
    419                           Vector3 enlarge(size[0] * 0.25f, size[1] * 0.0f, size[2] * 0.25f); 
    420                           //Vector3 enlarge(size[0] * 4.0f, 0.0f, 0.0f); 
    421  
    422                           mViewSpaceBox.Enlarge(enlarge); 
    423                           mViewSpaceBox.SetMax(mViewSpaceBox.Max() + enlarge); 
    424                   }  
    425                   else  
    426                   { 
    427                           AxisAlignedBox3 tbox(mViewSpaceBox); 
    428  
    429                           Vector3 size = mViewSpaceBox.Size(); 
    430                           tbox.SetMax(0, mViewSpaceBox.Max(0) + size[0] * 0.5f); 
    431                           tbox.SetMin(0, mViewSpaceBox.Min(0) + size[0]); 
    432                           mViewSpaceBox = tbox; 
    433                   }              
    434           } 
    435   } 
    436   else 
    437   { 
    438           mViewSpaceBox = AxisAlignedBox3(mKdTree->GetBox()); 
    439   } 
    440    
    441   mSceneGraph->CollectObjects(&mObjects); 
    442  
    443   if (!mLoadViewCells) 
    444   { 
    445           //-- generate new view cells from the scratch 
    446           //-- for construction the manager uses it's own set of samples 
    447           ConstructViewCells(mViewSpaceBox); 
    448   } 
     373        const long startTime = GetTime(); 
     374        int totalSamples = 0; 
     375 
     376        if (mUseViewSpaceBox) 
     377        { 
     378                AxisAlignedBox3 viewSpaceBox; 
     379                viewSpaceBox.Initialize(); 
     380 
     381                viewSpaceBox = AxisAlignedBox3(mKdTree->GetBox()); 
     382                AxisAlignedBox3 tbox(mViewCellsManager->GetViewSpaceBox()); 
     383 
     384                const Vector3 size = tbox.Size(); 
     385                viewSpaceBox.SetMax(0, tbox.Max(0) + size[0] * 0.5f); 
     386                viewSpaceBox.SetMin(0, tbox.Min(0) + size[0]); 
     387                  
     388                // change the view space of the view cells manager 
     389                mViewCellsManager->SetViewSpaceBox(viewSpaceBox); 
     390        } 
     391 
     392 
     393        mSceneGraph->CollectObjects(&mObjects); 
     394 
     395        if (!mLoadViewCells) 
     396        { 
     397                //-- generate new view cells from the scratch 
     398                //-- for construction the manager uses it's own set of samples 
     399                ConstructViewCells(); 
     400        } 
    449401#if 0 
    450   else  
    451   {       
    452           //-- load view cells from file 
    453           //-- test successful view cells loading by exporting them again 
    454       VssRayContainer dummies; 
    455           mViewCellsManager->Visualize(mObjects, dummies); 
    456           mViewCellsManager->ExportViewCells("test.xml.zip", mViewCellsManager->GetExportPvs(), mObjects); 
    457   } 
     402        else  
     403        {         
     404                //-- load view cells from file 
     405                //-- test successful view cells loading by exporting them again 
     406                VssRayContainer dummies; 
     407                mViewCellsManager->Visualize(mObjects, dummies); 
     408                mViewCellsManager->ExportViewCells("test.xml.zip", mViewCellsManager->GetExportPvs(), mObjects); 
     409        } 
    458410#endif 
    459411 
    460   VssTree *vssTree = NULL;  
    461   const long initialTime = GetTime(); 
    462  
    463   if (mLoadInitialSamples) 
    464   { 
    465           cout << "Loading samples from file ... "; 
    466           LoadSamples(mVssRays, mObjects); 
    467           cout << "finished\n" << endl; 
    468           totalSamples = (int)mVssRays.size(); 
    469   } 
    470   else 
    471   { 
    472         while (totalSamples < mInitialSamples) { 
    473                 int passContributingSamples = 0; 
    474                 int passSampleContributions = 0; 
    475                 int passSamples = 0; 
    476  
    477                 int index = 0; 
    478  
    479                 int sampleContributions; 
    480  
    481                 int s = Min(mSamplesPerPass, mInitialSamples); 
    482                 for (int k=0; k < s; k++)  
     412        VssTree *vssTree = NULL;  
     413        const long initialTime = GetTime(); 
     414 
     415        if (mLoadInitialSamples) 
     416        { 
     417                cout << "Loading samples from file ... "; 
     418                LoadSamples(mVssRays, mObjects); 
     419                cout << "finished\n" << endl; 
     420                totalSamples = (int)mVssRays.size(); 
     421        } 
     422        else 
     423        { 
     424                while (totalSamples < mInitialSamples) { 
     425                        int passContributingSamples = 0; 
     426                        int passSampleContributions = 0; 
     427                        int passSamples = 0; 
     428 
     429                        int index = 0; 
     430 
     431                        int sampleContributions; 
     432 
     433                        int s = Min(mSamplesPerPass, mInitialSamples); 
     434                        for (int k=0; k < s; k++)  
     435                        { 
     436                                Vector3 viewpoint;  
     437 
     438                                mViewCellsManager->GetViewPoint(viewpoint); 
     439                                const Vector3 direction = GetDirection(viewpoint, &mViewCellsManager->GetViewSpaceBox()); 
     440 
     441                                const SimpleRay sray(viewpoint, direction); 
     442                                sampleContributions = mRayCaster->CastRay(sray, mVssRays, mViewCellsManager->GetViewSpaceBox(), true); 
     443 
     444                                if (sampleContributions) { 
     445                                        passContributingSamples ++; 
     446                                        passSampleContributions += sampleContributions; 
     447                                } 
     448                                passSamples++; 
     449                                totalSamples++; 
     450                        } 
     451 
     452                        mPass++; 
     453                        int pvsSize = 0; 
     454                        float avgRayContrib = (passContributingSamples > 0) ? 
     455                                passSampleContributions/(float)passContributingSamples : 0; 
     456 
     457                        cout << "#Pass " << mPass << " : t = " << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; 
     458                        cout << "#TotalSamples=" << totalSamples/1000 
     459                                << "#SampleContributions=" << passSampleContributions << " (" 
     460                                << 100*passContributingSamples/(float)passSamples<<"%)" << " avgPVS=" 
     461                                << pvsSize/(float)mObjects.size() << endl 
     462                                << "avg ray contrib=" << avgRayContrib << endl; 
     463 
     464                        mStats << 
     465                                "#Pass\n" <<mPass<<endl<< 
     466                                "#Time\n" << TimeDiff(startTime, GetTime())*1e-3 << endl<< 
     467                                "#TotalSamples\n" << totalSamples<< endl<< 
     468                                "#SampleContributions\n" << passSampleContributions << endl << 
     469                                "#PContributingSamples\n"<<100*passContributingSamples/(float)passSamples<<endl << 
     470                                "#AvgPVS\n"<< pvsSize/(float)mObjects.size() << endl << 
     471                                "#AvgRayContrib\n" << avgRayContrib << endl; 
     472                } 
     473 
     474                cout << "#totalPvsSize=" << mKdTree->CollectLeafPvs() << endl; 
     475 
     476 
     477 
     478        } 
     479 
     480 
     481        cout << "#totalRayStackSize=" << (int)mVssRays.size() << endl << flush; 
     482        Debug << (int)mVssRays.size() << " rays generated in "  
     483                << TimeDiff(initialTime, GetTime()) * 1e-3 << " seconds" << endl; 
     484 
     485        if (mStoreInitialSamples) 
     486        { 
     487                cout << "Writing " << (int)mVssRays.size() << " samples to file ... "; 
     488                ExportSamples(mVssRays); 
     489                cout << "finished\n" << endl; 
     490 
     491                /*VssRayContainer dummyRays; 
     492                LoadSamples(dummyRays, mObjects); 
     493                Debug << "rays " << (int)mVssRays.size() << " " << dummyRays.size() << endl; 
     494 
     495                for (int i = 0; i < (int)mVssRays.size(); ++ i) 
    483496                { 
    484                         Vector3 viewpoint;  
    485                  
    486                         mViewCellsManager->GetViewPoint(viewpoint); 
    487                         const Vector3 direction = GetDirection(viewpoint, &mViewSpaceBox); 
    488  
    489                         const SimpleRay sray(viewpoint, direction); 
    490                         sampleContributions = mRayCaster->CastRay(sray, mVssRays, mViewSpaceBox, true); 
    491  
    492                         if (sampleContributions) { 
    493                                 passContributingSamples ++; 
    494                                 passSampleContributions += sampleContributions; 
     497                Debug << mVssRays[i]->GetOrigin() << " " << mVssRays[i]->GetTermination() << " " << mVssRays[i]->mOriginObject << " " << mVssRays[i]->mTerminationObject << endl; 
     498                Debug << dummyRays[i]->GetOrigin() << " " << dummyRays[i]->GetTermination() << " " << dummyRays[i]->mOriginObject << " " << dummyRays[i]->mTerminationObject << endl << endl; 
     499                }*/ 
     500        } 
     501 
     502 
     503        //int numExportRays = 2000; 
     504        int numExportRays = 0; 
     505 
     506        if (numExportRays) { 
     507                char filename[64]; 
     508                sprintf(filename, "vss-rays-initial.x3d"); 
     509                ExportRays(filename, mVssRays, numExportRays); 
     510        } 
     511 
     512        vssTree = new VssTree; 
     513        // viewcells = Construct(mVssRays); 
     514 
     515        vssTree->Construct(mVssRays, NULL); 
     516        cout<<"VssTree root PVS size = "<<vssTree->GetRootPvsSize()<<endl; 
     517 
     518        if (0) ExportRays("kdtree.x3d", mVssRays, 10); 
     519 
     520        if (0) 
     521        { 
     522                ExportVssTree("vss-tree-100.x3d", vssTree, Vector3(1,0,0)); 
     523                ExportVssTree("vss-tree-001.x3d", vssTree, Vector3(0,0,1)); 
     524                ExportVssTree("vss-tree-101.x3d", vssTree, Vector3(1,0,1)); 
     525                ExportVssTree("vss-tree-101m.x3d", vssTree, Vector3(-1,0,-1)); 
     526                ExportVssTreeLeaves(vssTree, 10); 
     527        } 
     528 
     529        // viewcells->UpdatePVS(newVssRays); 
     530        // get viewcells as kd tree boxes 
     531        vector<AxisAlignedBox3> kdViewcells; 
     532        if (0) { 
     533                vector<KdLeaf *> leaves; 
     534                mKdTree->CollectLeaves(leaves); 
     535                vector<KdLeaf *>::const_iterator it; 
     536                int targetLeaves = 50; 
     537                float prob = targetLeaves/(float)leaves.size(); 
     538                for (it = leaves.begin(); it != leaves.end(); ++it) 
     539                        if (RandomValue(0.0f,1.0f) < prob) 
     540                                kdViewcells.push_back(mKdTree->GetBox(*it)); 
     541 
     542                float avgPvs = GetAvgPvsSize(vssTree, kdViewcells); 
     543                cout<<"Initial average PVS size = "<<avgPvs<<endl; 
     544        } 
     545 
     546 
     547        int samples = 0; 
     548        int pass = 0; 
     549 
     550 
     551        // cast view cell samples 
     552        while (samples < mVssSamples)  
     553        { 
     554 
     555                int num = mVssSamplesPerPass; 
     556                SimpleRayContainer rays; 
     557                VssRayContainer vssRays; 
     558 
     559                if (!mUseImportanceSampling) { 
     560                        for (int j=0; j < num; j++) { 
     561                                Vector3 viewpoint;  
     562                                mViewCellsManager->GetViewPoint(viewpoint); 
     563                                Vector3 direction = GetDirection(viewpoint, NULL); 
     564                                rays.push_back(SimpleRay(viewpoint, direction)); 
    495565                        } 
    496                         passSamples++; 
    497                         totalSamples++; 
     566                } else { 
     567                        num = GenerateImportanceRays(vssTree, num, rays); 
    498568                } 
    499569 
    500                 mPass++; 
    501                 int pvsSize = 0; 
    502                 float avgRayContrib = (passContributingSamples > 0) ? 
    503                         passSampleContributions/(float)passContributingSamples : 0; 
    504  
    505                 cout << "#Pass " << mPass << " : t = " << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; 
    506                 cout << "#TotalSamples=" << totalSamples/1000 
    507                         << "#SampleContributions=" << passSampleContributions << " (" 
    508                         << 100*passContributingSamples/(float)passSamples<<"%)" << " avgPVS=" 
    509                         << pvsSize/(float)mObjects.size() << endl 
    510                         << "avg ray contrib=" << avgRayContrib << endl; 
    511  
    512                 mStats << 
    513                         "#Pass\n" <<mPass<<endl<< 
    514                         "#Time\n" << TimeDiff(startTime, GetTime())*1e-3 << endl<< 
    515                         "#TotalSamples\n" << totalSamples<< endl<< 
    516                         "#SampleContributions\n" << passSampleContributions << endl << 
    517                         "#PContributingSamples\n"<<100*passContributingSamples/(float)passSamples<<endl << 
    518                         "#AvgPVS\n"<< pvsSize/(float)mObjects.size() << endl << 
    519                         "#AvgRayContrib\n" << avgRayContrib << endl; 
    520           } 
    521   
    522           cout << "#totalPvsSize=" << mKdTree->CollectLeafPvs() << endl; 
    523  
    524  
    525            
    526   } 
    527   
    528  
    529   cout << "#totalRayStackSize=" << (int)mVssRays.size() << endl << flush; 
    530   Debug << (int)mVssRays.size() << " rays generated in "  
    531             << TimeDiff(initialTime, GetTime()) * 1e-3 << " seconds" << endl; 
    532  
    533   if (mStoreInitialSamples) 
    534   { 
    535           cout << "Writing " << (int)mVssRays.size() << " samples to file ... "; 
    536           ExportSamples(mVssRays); 
    537           cout << "finished\n" << endl; 
    538  
    539           /*VssRayContainer dummyRays; 
    540           LoadSamples(dummyRays, mObjects); 
    541           Debug << "rays " << (int)mVssRays.size() << " " << dummyRays.size() << endl; 
    542  
    543           for (int i = 0; i < (int)mVssRays.size(); ++ i) 
    544           { 
    545                   Debug << mVssRays[i]->GetOrigin() << " " << mVssRays[i]->GetTermination() << " " << mVssRays[i]->mOriginObject << " " << mVssRays[i]->mTerminationObject << endl; 
    546                   Debug << dummyRays[i]->GetOrigin() << " " << dummyRays[i]->GetTermination() << " " << dummyRays[i]->mOriginObject << " " << dummyRays[i]->mTerminationObject << endl << endl; 
    547           }*/ 
    548   } 
    549  
    550    
    551   //int numExportRays = 2000; 
    552   int numExportRays = 0; 
    553  
    554   if (numExportRays) { 
    555         char filename[64]; 
    556         sprintf(filename, "vss-rays-initial.x3d"); 
    557         ExportRays(filename, mVssRays, numExportRays); 
    558   } 
    559  
    560   vssTree = new VssTree; 
    561   // viewcells = Construct(mVssRays); 
    562  
    563   vssTree->Construct(mVssRays, NULL); 
    564   cout<<"VssTree root PVS size = "<<vssTree->GetRootPvsSize()<<endl; 
    565  
    566   if (0) ExportRays("kdtree.x3d", mVssRays, 10); 
    567  
    568   if (0) 
    569   { 
    570           ExportVssTree("vss-tree-100.x3d", vssTree, Vector3(1,0,0)); 
    571           ExportVssTree("vss-tree-001.x3d", vssTree, Vector3(0,0,1)); 
    572           ExportVssTree("vss-tree-101.x3d", vssTree, Vector3(1,0,1)); 
    573           ExportVssTree("vss-tree-101m.x3d", vssTree, Vector3(-1,0,-1)); 
    574           ExportVssTreeLeaves(vssTree, 10); 
    575   } 
    576  
    577   // viewcells->UpdatePVS(newVssRays); 
    578   // get viewcells as kd tree boxes 
    579   vector<AxisAlignedBox3> kdViewcells; 
    580   if (0) { 
    581         vector<KdLeaf *> leaves; 
    582         mKdTree->CollectLeaves(leaves); 
    583         vector<KdLeaf *>::const_iterator it; 
    584         int targetLeaves = 50; 
    585         float prob = targetLeaves/(float)leaves.size(); 
    586         for (it = leaves.begin(); it != leaves.end(); ++it) 
    587           if (RandomValue(0.0f,1.0f) < prob) 
    588                 kdViewcells.push_back(mKdTree->GetBox(*it)); 
    589  
    590         float avgPvs = GetAvgPvsSize(vssTree, kdViewcells); 
    591         cout<<"Initial average PVS size = "<<avgPvs<<endl; 
    592   } 
    593  
    594  
    595   int samples = 0; 
    596   int pass = 0; 
    597  
    598    
    599   // cast view cell samples 
    600   while (samples < mVssSamples)  
    601   { 
    602          
    603         int num = mVssSamplesPerPass; 
    604         SimpleRayContainer rays; 
    605         VssRayContainer vssRays; 
    606  
    607         if (!mUseImportanceSampling) { 
    608           for (int j=0; j < num; j++) { 
    609                 Vector3 viewpoint;  
    610                 mViewCellsManager->GetViewPoint(viewpoint); 
    611                 Vector3 direction = GetDirection(viewpoint, NULL); 
    612                 rays.push_back(SimpleRay(viewpoint, direction)); 
    613           } 
    614         } else { 
    615           num = GenerateImportanceRays(vssTree, num, rays); 
    616         } 
    617  
    618         CastRays(rays, vssRays, true); 
    619         vssTree->AddRays(vssRays); 
    620  
    621         if (0) { 
    622           int subdivided = vssTree->UpdateSubdivision(); 
    623           cout<<"subdivided leafs = "<<subdivided<<endl; 
    624         } 
    625  
    626         float avgPvs = GetAvgPvsSize(vssTree, kdViewcells); 
    627         cout<<"Average PVS size = "<<avgPvs<<endl; 
    628  
    629         /// compute view cell contribution of rays 
    630         mViewCellsManager->ComputeSampleContributions(vssRays, true, false); 
    631          
    632         if (numExportRays) { 
    633           char filename[64]; 
    634           if (mUseImportanceSampling) 
    635                 sprintf(filename, "vss-rays-i%04d.x3d", pass); 
    636           else 
    637                 sprintf(filename, "vss-rays-%04d.x3d", pass); 
    638  
    639           ExportRays(filename, vssRays, numExportRays); 
    640         } 
    641  
    642         samples+=num; 
    643         float pvs = vssTree->GetAvgPvsSize(); 
    644         cout<<"*****************************\n"; 
    645         cout<<samples<<" avgPVS ="<<pvs<<endl; 
    646         cout<<"VssTree root PVS size = "<<vssTree->GetRootPvsSize()<<endl; 
    647         cout<<"*****************************\n"; 
    648 //      if (samples >= mVssSamples) break; 
    649         pass ++; 
    650   } 
    651  
    652   if (mTestBeamSampling && mUseGlRenderer) 
    653   {      
    654           TestBeamCasting(vssTree, mViewCellsManager, mObjects); 
    655   } 
    656  
    657   if (0)  Debug << vssTree->stat << endl; 
    658  
    659   if (0) 
    660   { 
    661           VssRayContainer viewCellRays; 
    662           // compute rays used for view cells construction 
    663           const int numRays = mViewCellsManager->GetVisualizationSamples(); 
    664           vssTree->CollectRays(viewCellRays, numRays); 
    665   } 
    666  
    667  
    668   //////////////////// 
    669   //-- render simulation after construction 
    670  
    671   mRenderSimulator->RenderScene(); 
    672   SimulationStatistics ss; 
    673   mRenderSimulator->GetStatistics(ss); 
    674   Debug << "\nFinal view cells partition render time\n" << ss << endl; 
    675   cout << "\nFinal view cells partition render time\n" << ss << endl; 
    676  
    677   delete vssTree; 
    678    
    679   return true; 
    680 } 
    681  
    682 } 
     570                CastRays(rays, vssRays, true); 
     571                vssTree->AddRays(vssRays); 
     572 
     573                if (0) { 
     574                        int subdivided = vssTree->UpdateSubdivision(); 
     575                        cout<<"subdivided leafs = "<<subdivided<<endl; 
     576                } 
     577 
     578                float avgPvs = GetAvgPvsSize(vssTree, kdViewcells); 
     579                cout<<"Average PVS size = "<<avgPvs<<endl; 
     580 
     581                /// compute view cell contribution of rays 
     582                mViewCellsManager->ComputeSampleContributions(vssRays, true, false); 
     583 
     584                if (numExportRays) { 
     585                        char filename[64]; 
     586                        if (mUseImportanceSampling) 
     587                                sprintf(filename, "vss-rays-i%04d.x3d", pass); 
     588                        else 
     589                                sprintf(filename, "vss-rays-%04d.x3d", pass); 
     590 
     591                        ExportRays(filename, vssRays, numExportRays); 
     592                } 
     593 
     594                samples+=num; 
     595                float pvs = vssTree->GetAvgPvsSize(); 
     596                cout<<"*****************************\n"; 
     597                cout<<samples<<" avgPVS ="<<pvs<<endl; 
     598                cout<<"VssTree root PVS size = "<<vssTree->GetRootPvsSize()<<endl; 
     599                cout<<"*****************************\n"; 
     600                //      if (samples >= mVssSamples) break; 
     601                pass ++; 
     602        } 
     603 
     604        if (mTestBeamSampling && mUseGlRenderer) 
     605        {        
     606                TestBeamCasting(vssTree, mViewCellsManager, mObjects); 
     607        } 
     608 
     609        if (0)  Debug << vssTree->stat << endl; 
     610 
     611        if (0) 
     612        { 
     613                VssRayContainer viewCellRays; 
     614                // compute rays used for view cells construction 
     615                const int numRays = mViewCellsManager->GetVisualizationSamples(); 
     616                vssTree->CollectRays(viewCellRays, numRays); 
     617        } 
     618 
     619 
     620        //////////////////// 
     621        //-- render simulation after construction 
     622 
     623        mRenderSimulator->RenderScene(); 
     624        SimulationStatistics ss; 
     625        mRenderSimulator->GetStatistics(ss); 
     626        Debug << "\nFinal view cells partition render time\n" << ss << endl; 
     627        cout << "\nFinal view cells partition render time\n" << ss << endl; 
     628 
     629        delete vssTree; 
     630 
     631        return true; 
     632} 
     633 
     634} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.h

    r1486 r1563  
    2626  bool mUseImportanceSampling; 
    2727  bool mEnlargeViewSpace; 
    28   AxisAlignedBox3 mViewSpaceBox; 
     28  //AxisAlignedBox3 mViewSpaceBox; 
    2929 
    3030  ofstream mStats; 
Note: See TracChangeset for help on using the changeset viewer.