- Timestamp:
- 01/25/06 11:08:35 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsParser.cpp
r556 r575 61 61 // StdInParseHandlers: Constructors and Destructor 62 62 // --------------------------------------------------------------------------- 63 ViewCellsParseHandlers::ViewCellsParseHandlers(VspBspTree *tree, 64 ViewCellsManager *viewCells, 63 ViewCellsParseHandlers::ViewCellsParseHandlers(ViewCellsManager **viewCells, 65 64 ObjectContainer *objects): 66 65 mElementCount(0) … … 69 68 , mSpaceCount(0) 70 69 { 71 mVspBspTree = tree;72 mCurrentNode = tree->GetRoot();73 mViewCellsManager = viewCells;74 70 mObjects = objects; 75 } 71 viewCells = &mViewCellsManager; 72 //mPreprocessor = preprocessor; 73 } 74 76 75 77 76 ViewCellsParseHandlers::~ViewCellsParseHandlers() … … 90 89 string element(lname.LocalForm()); 91 90 if (element == "Interior") 92 End Interior();91 EndBspInterior(); 93 92 if (element == "ViewCells") 94 93 EndViewCells(); … … 96 95 97 96 98 void ViewCellsParseHandlers::End Interior()97 void ViewCellsParseHandlers::EndBspInterior() 99 98 { 100 99 // go one up in the tree … … 114 113 void ViewCellsParseHandlers::EndViewCells() 115 114 { 116 // sort view cells for easily findingid115 // sort view cells to help associating view cells according to their id 117 116 stable_sort(mViewCells.begin(), mViewCells.end(), vlt); 117 } 118 119 120 121 void ViewCellsParseHandlers::StartHierarchy(AttributeList& attributes) 122 { 123 int len = attributes.getLength(); 124 125 for (int i = 0; i < len; ++ i) 126 { 127 string attrName(StrX(attributes.getName(i)).LocalForm()); 128 129 if (attrName == "name") 130 { 131 StrX attrValue(attributes.getValue(i)); 132 133 const char *ptr = attrValue.LocalForm(); 134 135 CreateViewCellsManager(ptr); 136 } 137 } 138 } 139 140 141 void ViewCellsParseHandlers::startBspElement(string element, 142 AttributeList& attributes) 143 { 144 if (element == "ViewCell") 145 { 146 cout << "v"; 147 StartViewCell(attributes); 148 } 149 150 if (element == "Interior") 151 { 152 cout << "["; 153 StartBspInterior(attributes); 154 } 155 156 if (element == "Leaf") 157 { 158 StartBspLeaf(attributes); 159 } 118 160 } 119 161 … … 125 167 string element(lname.LocalForm()); 126 168 127 if (element == "ViewCell") 128 { 129 cout << "v"; 130 StartViewCell(attributes); 131 } 132 133 if (element == "Interior") 134 { 135 cout << "["; 136 StartInterior(attributes); 137 } 138 139 if (element == "Leaf") 140 { 141 StartLeaf(attributes); 142 } 143 169 if (element == "Hierarchy") 170 { 171 cout << "h"; 172 StartHierarchy(attributes); 173 } 174 175 switch (mViewCellsManager->GetType()) 176 { 177 case ViewCellsManager::BSP: 178 case ViewCellsManager::VSP_BSP: 179 startBspElement(element, attributes); 180 break; 181 182 default: 183 Debug << "not implemented" << endl; 184 break; 185 186 } 187 144 188 ++ mElementCount; 145 189 mAttrCount += attributes.getLength(); … … 228 272 229 273 230 void ViewCellsParseHandlers::Start Leaf(AttributeList& attributes)274 void ViewCellsParseHandlers::StartBspLeaf(AttributeList& attributes) 231 275 { 232 276 BspLeaf * leaf = … … 239 283 else 240 284 { 241 mVspBspTree->mRoot = leaf; 285 if (mViewCellsManager->GetType() == ViewCellsManager::BSP) 286 mBspTree->mRoot = leaf; 287 else 288 mVspBspTree->mRoot = leaf; 242 289 } 243 290 … … 282 329 else 283 330 { 284 leaf->SetViewCell(mVspBspTree->GetOrCreateOutOfBoundsCell()); 285 leaf->SetTreeValid(false); 286 mVspBspTree->PropagateUpValidity(leaf); 287 } 288 } 289 290 291 void ViewCellsParseHandlers::StartInterior(AttributeList& attributes) 331 if (mViewCellsManager->GetType() == ViewCellsManager::VSP_BSP) 332 { 333 leaf->SetViewCell(mVspBspTree->GetOrCreateOutOfBoundsCell()); 334 leaf->SetTreeValid(false); 335 mVspBspTree->PropagateUpValidity(leaf); 336 } 337 } 338 } 339 340 341 void ViewCellsParseHandlers::StartBspInterior(AttributeList& attributes) 292 342 { 293 343 Plane3 plane; … … 318 368 else 319 369 { 320 mVspBspTree->mRoot = interior; 370 if (mViewCellsManager->GetType() == ViewCellsManager::BSP) 371 mBspTree->mRoot = interior; 372 else 373 mVspBspTree->mRoot = interior; 321 374 } 322 375 323 376 mCurrentNode = interior; 377 } 378 379 380 381 void ViewCellsParseHandlers::CreateViewCellsManager(const char *name) 382 { 383 384 if (strcmp(name, "bspTree") == 0) 385 { 386 mBspTree = new BspTree(); 387 388 Debug << "view cell type: Bsp" << endl; 389 390 mCurrentNode = mBspTree->GetRoot(); 391 392 mViewCellsManager = new BspViewCellsManager(mBspTree); 393 } 394 else if (strcmp(name, "vspBspTree") == 0) 395 { 396 mVspBspTree = new VspBspTree(); 397 398 Debug << "view cell type: VspBsp" << endl; 399 mCurrentNode = mVspBspTree->GetRoot(); 400 401 mViewCellsManager = new VspBspViewCellsManager(mVspBspTree); 402 } 403 /*else if (strcmp(name, "vspKdTree") == 0) 404 { 405 mVspKdTree = new VspKdTree(); 406 407 mViewCellsManager = VspKdViewCellsManager(mVspKdTree); 408 }*/ 409 else 410 { 411 cerr<<"Wrong view cells type" << name << endl; 412 exit(1); 413 } 324 414 } 325 415 … … 380 470 381 471 bool ViewCellsParser::ParseFile(const string filename, 382 VspBspTree *tree, 383 ViewCellsManager *viewCells, 472 ViewCellsManager **viewCells, 384 473 ObjectContainer *objects) 385 474 { … … 414 503 // to do. 415 504 // 416 ViewCellsParseHandlers handler( tree,viewCells, objects);505 ViewCellsParseHandlers handler(viewCells, objects); 417 506 parser->setDocumentHandler(&handler); 418 507 parser->setErrorHandler(&handler);
Note: See TracChangeset
for help on using the changeset viewer.