Changeset 2114 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
- Timestamp:
- 02/12/07 09:05:33 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
r2113 r2114 103 103 , nObjects(0) 104 104 { 105 // pvs objects empty => have to create new ones 105 106 mCreatePvsObjects = mPvsObjects.empty(); 106 107 … … 278 279 { 279 280 // sort view cells to help associating view cells according to their id 280 s table_sort(mViewCells.begin(), mViewCells.end(), vlt);281 sort(mViewCells.begin(), mViewCells.end(), vlt); 281 282 282 283 // not parsing view cells anymore … … 287 288 void ViewCellsParseHandlers::EndBoundingBoxes() 288 289 { 289 // all bounding boxes gathered in this step =>290 // associate object ids with bounding boxes291 290 const long startTime = GetTime(); 292 291 293 292 if (mBoundingBoxConverter) 294 293 { 294 // all bounding boxes gathered in this step => 295 // associate object ids with bounding boxes 295 296 mBoundingBoxConverter->IdentifyObjects(mIBoundingBoxes, mPvsObjects); 296 297 } … … 458 459 459 460 460 void ViewCellsParseHandlers::ExchangeElements() 461 { 461 void ViewCellsParseHandlers::ReplacePvs() 462 { 463 // sort the pvs entries 464 sort(mPvsObjects.begin(), mPvsObjects.end(), ilt); 465 462 466 ViewCellContainer::const_iterator vit, vit_end = mViewCells.end(); 463 467 464 sort(mBvhLeaves.begin(), mBvhLeaves.end(), ilt);465 466 468 //cout << "viewcells : " << mViewCells.size() << endl; 467 469 for (vit = mViewCells.begin(); vit != vit_end; ++ vit) … … 583 585 for (it = objIndices.begin(); it != it_end; ++ it) 584 586 { 585 #if PVS_HACK 586 //cout << "u"; 587 pvs.AddSample(new DummyIntersectable(*it), 1); 588 #else 589 const int objId = *it; 590 dummyInst.SetId(objId); 591 592 ObjectContainer::iterator oit = 587 if (mCreatePvsObjects) 588 { 589 // pvs entries will be created => just use dummy proxy 590 pvs.AddSample(new DummyIntersectable(*it), 1); 591 } 592 else 593 { 594 const int objId = *it; 595 dummyInst.SetId(objId); 596 597 ObjectContainer::iterator oit = 593 598 lower_bound(mPvsObjects.begin(), 594 599 mPvsObjects.end(), 595 600 (Intersectable *)&dummyInst, ilt); 596 601 597 if ((oit != mPvsObjects.end()) && ((*oit)->GetId() == objId)) 598 { 599 // $$JB we should store a float a per object which corresponds 600 // to sumof pdfs, i.e. its relative visibility 601 // temporarily set to 1.0f 602 pvs.AddSample(*oit, 1.0f); 603 //Debug << "y"; 604 } 605 else 606 { 607 Debug << "x"; 608 //Debug << "StartViewCellPvs error: object with id " << objId << " does not exist" << endl; 609 } 610 #endif 602 if ((oit != mPvsObjects.end()) && ((*oit)->GetId() == objId)) 603 { 604 // $$JB we should store a float a per object which corresponds 605 // to sumof pdfs, i.e. its relative visibility 606 // temporarily set to 1.0f 607 pvs.AddSample(*oit, 1.0f); 608 } 609 else 610 { 611 //Debug << "x"; 612 //Debug << "StartViewCellPvs error: object with id " << objId << " does not exist" << endl; 613 } 614 } 611 615 } 612 616 } … … 1306 1310 BvHierarchy::AssociateObjectsWithLeaf(leaf); 1307 1311 1308 if ( PVS_HACK)1309 { 1310 if (0) // Temp matt:should already have right id1311 1312 if (mCreatePvsObjects) 1313 { 1314 // Temp matt: leaves should already have right id 1315 if (0) leaf->SetId((int)mBvhLeaves.size()); 1312 1316 1313 m BvhLeaves.push_back(leaf);1317 mPvsObjects.push_back(leaf); 1314 1318 } 1315 1319 } … … 1437 1441 BoundingBoxConverter *bconverter) 1438 1442 { 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 {1486 const unsigned long startMillis = XMLPlatformUtils::getCurrentMillis();1443 // Initialize the XML4C system 1444 try { 1445 XMLPlatformUtils::Initialize(); 1446 } 1447 1448 catch (const XMLException& toCatch) 1449 { 1450 XERCES_STD_QUALIFIER cerr << "Error during initialization! Message:\n" 1451 << StrX(toCatch.getMessage()) << XERCES_STD_QUALIFIER endl; 1452 return false; 1453 } 1454 1455 // cout<<"parsing started"<<endl<<flush; 1456 1457 // 1458 // Create a SAX parser object. Then, according to what we were told on 1459 // the command line, set the options. 1460 // 1461 SAXParser* parser = new SAXParser; 1462 parser->setValidationScheme(valScheme); 1463 parser->setDoNamespaces(doNamespaces); 1464 parser->setDoSchema(doSchema); 1465 parser->setValidationSchemaFullChecking(schemaFullChecking); 1466 1467 1468 // 1469 // Create our SAX handler object and install it on the parser, as the 1470 // document and error handler. We are responsible for cleaning them 1471 // up, but since its just stack based here, there's nothing special 1472 // to do. 1473 // 1474 ViewCellsParseHandlers handler(pvsObjects, preprocessorObjects, bconverter); 1475 parser->setDocumentHandler(&handler); 1476 parser->setErrorHandler(&handler); 1477 1478 unsigned long duration; 1479 int errorCount = 0; 1480 // create a faux scope so that 'src' destructor is called before 1481 // XMLPlatformUtils::Terminate 1482 { 1483 // 1484 // Kick off the parse and catch any exceptions. Create a standard 1485 // input input source and tell the parser to parse from that. 1486 // 1487 // StdInInputSource src; 1488 try 1489 { 1490 const unsigned long startMillis = XMLPlatformUtils::getCurrentMillis(); 1487 1491 1488 1492 #if USE_GZLIB 1489 XMLCh *myFilePath = XMLString::transcode(filename.c_str());1490 1491 GzFileInputSource isource(myFilePath);1492 parser->parse(isource);1493 XMLCh *myFilePath = XMLString::transcode(filename.c_str()); 1494 1495 GzFileInputSource isource(myFilePath); 1496 parser->parse(isource); 1493 1497 #else 1494 parser->parse(filename.c_str());1498 parser->parse(filename.c_str()); 1495 1499 1496 1500 #endif 1497 1501 1498 if (1 && PVS_HACK)1499 handler.ExchangeElements();1500 1501 const unsigned long endMillis = XMLPlatformUtils::getCurrentMillis();1502 duration = endMillis - startMillis;1503 errorCount = parser->getErrorCount();1504 1505 1506 1507 XERCES_STD_QUALIFIER cerr << "OutOfMemoryException" << XERCES_STD_QUALIFIER endl;1508 errorCount = 2;1509 return false;1510 1511 1512 1502 //if (mCreatePvsObjects) 1503 // handler.ReplacePvs(); 1504 1505 const unsigned long endMillis = XMLPlatformUtils::getCurrentMillis(); 1506 duration = endMillis - startMillis; 1507 errorCount = parser->getErrorCount(); 1508 } 1509 catch (const OutOfMemoryException&) 1510 { 1511 XERCES_STD_QUALIFIER cerr << "OutOfMemoryException" << XERCES_STD_QUALIFIER endl; 1512 errorCount = 2; 1513 return false; 1514 } 1515 catch (const XMLException& e) 1516 { 1513 1517 XERCES_STD_QUALIFIER cerr << "\nError during parsing: \n" 1514 1515 1518 << StrX(e.getMessage()) 1519 << "\n" << XERCES_STD_QUALIFIER endl; 1516 1520 errorCount = 1; 1517 1521 return false; 1518 } 1519 1520 1521 // Print out the stats that we collected and time taken 1522 if (!errorCount) { 1523 XERCES_STD_QUALIFIER cerr << filename << ": " << duration << " ms (" 1522 } 1523 1524 1525 // Print out the stats that we collected and time taken 1526 if (!errorCount) 1527 { 1528 XERCES_STD_QUALIFIER cerr << filename << ": " << duration << " ms (" 1524 1529 << handler.GetElementCount() << " elems, " 1525 1530 << handler.GetAttrCount() << " attrs, " 1526 1531 << handler.GetSpaceCount() << " spaces, " 1527 1532 << handler.GetCharacterCount() << " chars)" << XERCES_STD_QUALIFIER endl; 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 } 1547 1548 } 1533 } 1534 } 1535 1536 cout<<"parsed - will delete the parser"<<endl<<flush; 1537 // 1538 // Delete the parser itself. Must be done prior to calling Terminate, below. 1539 // 1540 delete parser; 1541 1542 XMLPlatformUtils::Terminate(); 1543 1544 //-- assign new view cells manager 1545 *viewCells = handler.mViewCellsManager; 1546 1547 if (errorCount > 0) 1548 return false; 1549 else 1550 return true; 1551 } 1552 1553 }
Note: See TracChangeset
for help on using the changeset viewer.