Changeset 651 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
- Timestamp:
- 02/18/06 18:02:12 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
r590 r651 70 70 , mVspBspTree(NULL) 71 71 , mBspTree(NULL) 72 , mViewCellsTree(NULL) 73 , mParseViewCells(true) 74 , mCurrentViewCell(NULL) 75 , mCurrentBspNode(NULL) 72 76 { 73 77 mObjects = objects; … … 89 93 StrX lname(name); 90 94 string element(lname.LocalForm()); 91 if (element == "Interior") 92 EndBspInterior(); 95 93 96 if (element == "ViewCells") 94 97 EndViewCells(); 98 99 if (mParseViewCells) 100 { 101 if (element == "Interior") 102 EndViewCellInterior(); 103 } 104 else 105 { 106 if (element == "Interior") 107 EndBspInterior(); 108 } 95 109 } 96 110 … … 105 119 } 106 120 121 122 void ViewCellsParseHandlers::EndViewCellInterior() 123 { 124 // go one up in the tree 125 if (mCurrentViewCell->GetParent()) 126 { cout << "]"; 127 mCurrentViewCell = mCurrentViewCell->GetParent(); 128 } 129 } 107 130 108 131 inline bool vlt(ViewCell *v1, ViewCell *v2) … … 151 174 if (element == "Leaf") 152 175 { 176 cout << "l"; 177 Debug << "leaf" << endl; 153 178 StartBspLeaf(attributes); 154 179 } … … 163 188 164 189 // decides the used view cell hierarchy 190 if (element == "ViewCells") 191 { 192 cout << "parsing view cells" << endl; 193 mParseViewCells = true; 194 } 195 165 196 if (element == "Hierarchy") 166 197 { 167 cout << "h"; 198 cout << "parsing spatial hierarchy" << endl; 199 mParseViewCells = false; 168 200 StartHierarchy(attributes); 169 201 } … … 172 204 if (element == "ViewSpaceBox") 173 205 { 174 cout << " vsb";206 cout << "b"; 175 207 StartViewSpaceBox(attributes); 176 208 } 177 209 178 if (element == "ViewCell")179 {180 cout << "v";181 StartViewCell(attributes);182 }183 210 184 211 // use different methods for the given view cell hierarchy types 185 if (mViewCellsManager) 186 { 187 switch (mViewCellsManager->GetType()) 188 { 189 case ViewCellsManager::BSP: 190 case ViewCellsManager::VSP_BSP: 191 startBspElement(element, attributes); 192 break; 212 if (!mParseViewCells) 213 { 214 if (mViewCellsManager) 215 { 216 switch (mViewCellsManager->GetType()) 217 { 218 case ViewCellsManager::BSP: 219 case ViewCellsManager::VSP_BSP: 220 startBspElement(element, attributes); 221 break; 193 222 194 default: 195 Debug << "not implemented" << endl; 196 break; 223 default: 224 Debug << "not implemented" << endl; 225 break; 226 } 227 } 228 } 229 else 230 { 231 if (element == "Interior") 232 { 233 cout << "["; 234 StartViewCellInterior(attributes); 235 } 236 237 if (element == "Leaf") 238 { 239 cout << "l"; 240 StartViewCellLeaf(attributes); 197 241 } 198 242 } … … 209 253 210 254 211 void ViewCellsParseHandlers::StartViewCell( AttributeList& attributes)255 void ViewCellsParseHandlers::StartViewCell(ViewCell *viewCell, AttributeList& attributes) 212 256 { 213 257 int len = attributes.getLength(); 214 258 vector<int> objIndices; 215 216 //hack!! 217 218 ViewCell *viewCell = new ViewCellInterior();//mViewCellsManager->GenerateViewCell(); 219 viewCell->mIsActive = true; 220 221 mViewCells.push_back(viewCell); 222 259 223 260 for (int i = 0; i < len; ++ i) 224 261 { … … 284 321 viewCell->SetId(id); 285 322 } 323 else if (attrName == "active") 324 { 325 StrX attrValue(attributes.getValue(i)); 326 327 const char *ptr = attrValue.LocalForm(); 328 char *endptr = NULL; 329 const bool isActive = (bool)strtol(ptr, &endptr, 10); 330 331 viewCell->mIsActive = isActive; 332 } 333 else if (attrName == "mergecost") 334 { 335 StrX attrValue(attributes.getValue(i)); 336 337 const char *ptr = attrValue.LocalForm(); 338 char *endptr = NULL; 339 const float cost = (float)strtod(ptr, &endptr); 340 341 viewCell->SetMergeCost(cost); 342 } 286 343 } 287 344 } … … 357 414 } 358 415 } 359 416 Debug << "here22" << endl; 360 417 361 418 if (viewCellId >= 0) // valid view cell … … 368 425 lower_bound(mViewCells.begin(), mViewCells.end(), &dummyVc, vlt); 369 426 370 ViewCellInterior *viewCell = dynamic_cast<ViewCellInterior *>(*vit); 371 372 // giant hack!! 373 BspViewCell *l = dynamic_cast<BspViewCell *>(mViewCellsManager->GenerateViewCell()); 374 viewCell->SetupChildLink(l); 427 BspViewCell *viewCell = dynamic_cast<BspViewCell *>(*vit); 428 429 Debug << "here44" << endl; 375 430 376 431 if (viewCell->GetId() == viewCellId) 377 432 { 378 leaf->SetViewCell( l);379 l->mLeaf = leaf;433 leaf->SetViewCell(viewCell); 434 viewCell->mLeaf = leaf; 380 435 } 381 436 else … … 392 447 mVspBspTree->PropagateUpValidity(leaf); 393 448 } 394 } 449 }Debug << "here33" << endl; 395 450 } 396 451 … … 439 494 440 495 496 void ViewCellsParseHandlers::StartViewCellLeaf(AttributeList& attributes) 497 { 498 Debug << "here111" << endl; 499 BspViewCell *viewCell = new BspViewCell(); 500 501 if (mCurrentViewCell) // replace front or (if not NULL) back child 502 { 503 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(mCurrentViewCell); 504 interior->SetupChildLink(viewCell); 505 } 506 else // root 507 { 508 mViewCellsTree->SetRoot(viewCell); 509 } 510 511 StartViewCell(viewCell, attributes); 512 513 // collect leaves 514 mViewCells.push_back(viewCell); 515 } 516 517 518 void ViewCellsParseHandlers::StartViewCellInterior(AttributeList& attributes) 519 { 520 Debug << "here222" << endl; 521 ViewCellInterior* interior = new ViewCellInterior(); 522 523 if (mCurrentViewCell) // replace NULL child of parent with current node 524 { 525 ViewCellInterior *current = dynamic_cast<ViewCellInterior *>(mCurrentViewCell); 526 527 current->SetupChildLink(interior); 528 } 529 else 530 { 531 mViewCellsTree->SetRoot(interior); 532 } 533 534 mCurrentViewCell = interior; 535 536 StartViewCell(interior, attributes); 537 } 538 539 441 540 442 541 void ViewCellsParseHandlers::CreateViewCellsManager(const char *name) … … 448 547 mBspTree = new BspTree(); 449 548 mBspTree->mBox = mViewSpaceBox; 450 mCurrentBspNode = mBspTree->GetRoot();549 //mCurrentBspNode = mBspTree->GetRoot(); 451 550 452 551 mViewCellsManager = new BspViewCellsManager(mBspTree); … … 457 556 458 557 mVspBspTree = new VspBspTree(); 459 mCurrentBspNode = mVspBspTree->GetRoot();558 //mCurrentBspNode = mVspBspTree->GetRoot(); 460 559 461 560 mViewCellsManager = new VspBspViewCellsManager(mVspBspTree); … … 476 575 } 477 576 577 mViewCellsTree = mViewCellsManager->GetViewCellsTree(); 478 578 mViewCellsManager->SetViewSpaceBox(mViewSpaceBox); 479 579 } … … 625 725 // assign new view cells manager 626 726 *viewCells = handler.mViewCellsManager; 627 727 628 728 if (errorCount > 0) 629 729 return false;
Note: See TracChangeset
for help on using the changeset viewer.