- Timestamp:
- 01/21/07 00:40:56 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/scripts/power_plant.env
r886 r2003 392 392 } 393 393 394 394 395 BspTree { 395 396 Construction { -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1999 r2003 26 26 #define USE_FIXEDPOINT_T 0 27 27 #define USE_VOLUMES_FOR_HEURISTICS 1 28 29 //int BvhNode::sMailId = 10000; //2147483647; 30 //int BvhNode::sReservedMailboxes = 1; 28 #define TEST_POWERPLANT 0 29 30 //int BvhNode::sMailId = 10000; 31 //int BvhNode::sReservedMailboxes = 1; 31 32 32 33 BvHierarchy *BvHierarchy::BvhSubdivisionCandidate::sBvHierarchy = NULL; … … 382 383 BvhTraversalData &frontData, 383 384 BvhTraversalData &backData) 384 { 385 { 385 386 const BvhTraversalData &tData = sc.mParentData; 386 387 BvhLeaf *leaf = tData.mNode; … … 427 428 ++ mBvhStats.splits; 428 429 429 430 430 431 //////////////////////////////////////// 431 432 //-- fill front and back traversal data with the new values … … 446 447 AssociateObjectsWithLeaf(back); 447 448 AssociateObjectsWithLeaf(front); 448 449 450 //////////// 449 451 //-- compute pvs correction to cope with undersampling 452 450 453 frontData.mPvs = (float)CountViewCells(front->mObjects); 451 454 backData.mPvs = (float)CountViewCells(back->mObjects); … … 453 456 frontData.mCorrectedPvs = sc.mCorrectedFrontPvs; 454 457 backData.mCorrectedPvs = sc.mCorrectedBackPvs; 458 455 459 456 460 // compute probability of this node being visible, … … 462 466 backData.mCorrectedVolume = sc.mCorrectedBackVolume; 463 467 468 464 469 // how often was max cost ratio missed in this branch? 465 470 frontData.mMaxCostMisses = sc.GetMaxCostMisses(); … … 468 473 // set the time stamp so the order of traversal can be reconstructed 469 474 node->SetTimeStamp(mHierarchyManager->mTimeStamp ++); 470 475 471 476 // assign the objects in sorted order 472 if ( mUseGlobalSorting)477 if (!TEST_POWERPLANT && mUseGlobalSorting) 473 478 { 474 479 AssignSortedObjects(sc, frontData, backData); … … 497 502 BvhTraversalData tFrontData; 498 503 BvhTraversalData tBackData; 499 504 500 505 // create new interior node and two leaf node 501 506 currentNode = SubdivideNode(*sc, tFrontData, tBackData); … … 628 633 } 629 634 635 630 636 const BvhTraversalData &tData = splitCandidate.mParentData; 631 637 BvhLeaf *leaf = tData.mNode; … … 671 677 672 678 if (0) 673 cout << "bvh volume cost" 679 { 680 cout << "bvh volume cost" 674 681 << " avg ray contri: " << avgRayContri << " ratio: " << oldRatio 675 682 << " parent: " << parentVol << " old vol: " << oldVolume 676 683 << " frontvol: " << frontVol << " corr. " << splitCandidate.mCorrectedFrontVolume 677 684 << " backvol: " << backVol << " corr. " << splitCandidate.mCorrectedBackVolume << endl; 685 } 678 686 679 687 #ifdef GTP_DEBUG … … 849 857 850 858 851 #if 0859 #if 1 852 860 853 861 /// compute object boundaries using spatial mid split … … 857 865 ObjectContainer &objectsBack) 858 866 { 859 const float maxBox = tData.mBoundingBox.Max(axis); 860 const float minBox = tData.mBoundingBox.Min(axis); 867 AxisAlignedBox3 parentBox = tData.mNode->GetBoundingBox(); 868 869 const float maxBox = parentBox.Max(axis); 870 const float minBox = parentBox.Min(axis); 861 871 862 872 float midPoint = (maxBox + minBox) * 0.5f; … … 882 892 } 883 893 884 const float oldRenderCost = EvalRenderCost(tData.mNode->mObjects); 885 const float newRenderCost = EvalRenderCost(objectsFront) * EvalRenderCost(objectsBack); 894 AxisAlignedBox3 fbox = EvalBoundingBox(objectsFront, &parentBox); 895 AxisAlignedBox3 bbox = EvalBoundingBox(objectsBack, &parentBox); 896 897 const float oldRenderCost = (float)tData.mNode->mObjects.size() * parentBox.SurfaceArea(); 898 const float newRenderCost = (float)objectsFront.size() * fbox.SurfaceArea() + (float)objectsBack.size() * bbox.SurfaceArea(); 886 899 887 900 const float ratio = newRenderCost / oldRenderCost; … … 920 933 921 934 #if 1 935 // hack: always take driving axis 922 936 const float cost = (tData.mNode->GetBoundingBox().Size().DrivingAxis() == axis) ? -1.0f : 0.0f; 923 937 #else 924 938 const float oldRenderCost = EvalRenderCost(tData.mNode->mObjects); 925 const float newRenderCost = EvalRenderCost(objectsFront) *EvalRenderCost(objectsBack);939 const float newRenderCost = EvalRenderCost(objectsFront) + EvalRenderCost(objectsBack); 926 940 927 941 const float cost = newRenderCost / oldRenderCost; … … 986 1000 } 987 1001 988 // temporary surface areas1002 // record surface areas during the sweep 989 1003 float al = 0; 990 1004 float ar = boxArea; … … 1394 1408 void BvHierarchy::CreateLocalSubdivisionCandidates(const ObjectContainer &objects, 1395 1409 SortableEntryContainer **subdivisionCandidates, 1396 const bool sort ,1410 const bool sortEntries, 1397 1411 const int axis) 1398 1412 { … … 1400 1414 1401 1415 // compute requested size and look if subdivision candidate has to be recomputed 1402 const int requestedSize = (int)objects.size() * 2;1416 const int requestedSize = (int)objects.size(); 1403 1417 1404 1418 // creates a sorted split candidates array … … 1423 1437 } 1424 1438 1425 if (sort )1439 if (sortEntries) 1426 1440 { // no presorted candidate list 1427 stable_sort((*subdivisionCandidates)->begin(), (*subdivisionCandidates)->end()); 1441 //stable_sort((*subdivisionCandidates)->begin(), (*subdivisionCandidates)->end()); 1442 sort((*subdivisionCandidates)->begin(), (*subdivisionCandidates)->end()); 1428 1443 } 1429 1444 } … … 2201 2216 // root and bounding box was already constructed 2202 2217 BvhLeaf *bvhLeaf = dynamic_cast<BvhLeaf *>(mRoot); 2203 2218 2204 2219 // only rays intersecting objects in node are interesting 2205 2220 const int nRays = AssociateObjectsWithRays(sampleRays); 2206 2221 //cout << "using " << nRays << " of " << (int)sampleRays.size() << " rays" << endl; 2207 2222 2208 2223 // probability that volume is "seen" from the view cells 2209 2224 const float prop = EvalViewCellsVolume(objects) / GetViewSpaceVolume(); … … 2213 2228 2214 2229 // create sorted object lists for the first data 2215 if ( mUseGlobalSorting)2230 if (!TEST_POWERPLANT && mUseGlobalSorting) 2216 2231 { 2217 2232 AssignInitialSortedObjectList(oData, objects); … … 2257 2272 tQueue.Push(sCandidate); 2258 2273 } 2274 2275 cout << "size of initial bv subdivision: " << GetStatistics().Leaves() << endl; 2259 2276 } 2260 2277 else 2261 { 2278 { 2262 2279 // evaluate priority 2263 2280 EvalSubdivisionCandidate(*oSubdivisionCandidate); … … 2265 2282 2266 2283 tQueue.Push(oSubdivisionCandidate); 2267 } 2268 2269 cout << "size of initial bv subdivision: " << GetStatistics().Leaves() << endl; 2284 cout << "size of initial bv subdivision: " << GetStatistics().Leaves() << endl; 2285 } 2270 2286 } 2271 2287 … … 2304 2320 2305 2321 *(tData.mSortedObjects[3]) = objects; 2306 stable_sort(tData.mSortedObjects[3]->begin(), tData.mSortedObjects[3]->end(), smallerSize); 2322 //stable_sort(tData.mSortedObjects[3]->begin(), tData.mSortedObjects[3]->end(), smallerSize); 2323 sort(tData.mSortedObjects[3]->begin(), tData.mSortedObjects[3]->end(), smallerSize); 2307 2324 } 2308 2325 … … 2375 2392 BvhTraversalData oData(bvhLeaf, 0, prop, nRays); 2376 2393 2377 AssignInitialSortedObjectList(oData, objects); 2394 if (!TEST_POWERPLANT && mUseGlobalSorting) 2395 AssignInitialSortedObjectList(oData, objects); 2378 2396 2379 2397 … … 2657 2675 delete bsc; 2658 2676 } 2659 else // initial preprocessing finished for this candidate 2660 { 2677 else 2678 { 2679 // initial preprocessing finished for this candidate 2661 2680 // add to candidate container 2662 2681 candidateContainer.push_back(bsc); -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r1941 r2003 495 495 float GetPriority() const 496 496 { 497 return mPriority; 497 return (float)-mParentData.mDepth; 498 //return mPriority; 498 499 } 499 500 -
GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp
r1920 r2003 149 149 150 150 SetFilled(); 151 // hack 152 if (1 || (leaf->mObjects.size() < 50000)) 153 ExportGeometry(leaf->mObjects, true, box); 151 152 if (0) 153 ExportGeometry(leaf->mObjects, true, box); 154 else 155 ExportBox(leaf->GetBoundingBox()); 154 156 } 155 157 -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
r2000 r2003 32 32 Preprocessor(), 33 33 mSamplingType(SamplingStrategy::VIEWCELL_BASED_DISTRIBUTION), 34 //mSamplingType(SamplingStrategy::DIRECTION_BASED_DISTRIBUTION),35 34 mProcessedViewCells(0), 36 35 mCurrentViewCell(NULL) … … 203 202 return false; 204 203 205 if ( 0&& GVS_DEBUG)204 if (1 && GVS_DEBUG) 206 205 mVssRays.push_back(new VssRay(*vssRay)); 207 206 … … 653 652 //exporter->ExportRays(vcRays, RgbColor(1, 0, 0)); 654 653 //exporter->ExportRays(vcRays2, RgbColor(0, 1, 0)); 655 //exporter->ExportRays(vcRays3, RgbColor(1, 1, 1));654 exporter->ExportRays(vcRays3, RgbColor(1, 1, 1)); 656 655 } 657 656 … … 773 772 passSamples += newSamples; 774 773 mGvsStats.mPerViewCellSamples += newSamples; 775 //cout << "here2 " << passSamples % (mSamplesPerPass + 1) << endl;774 776 775 777 776 if (passSamples >= mSamplesPerPass) … … 884 883 (*oit)->mCounter = 0; 885 884 } 885 long lastTime = GetTime(); 886 886 887 887 while (NextViewCell()) … … 896 896 //mGvsStats.mTrianglePvs = mCurrentViewCell->GetPvs().GetSize(); 897 897 mGvsStats.mTrianglePvs = (int)mTrianglePvs.size(); 898 mGvsStats.mTotalTrianglePvs += mGvsStats.mTrianglePvs; 898 899 899 900 ObjectContainer objectPvs; … … 910 911 mGvsStats.mViewCells = mProcessedViewCells;//mPass; 911 912 //mGvsStats.mPerViewCellPvs = mCurrentViewCell->GetPvs().GetSize(); 912 mGvsStats.mPerViewCellPvs = (int) mTrianglePvs.size();913 mGvsStats.mPerViewCellPvs = (int)objectPvs.size(); 913 914 914 915 mGvsStats.mTotalPvs += mGvsStats.mPerViewCellPvs; 915 916 mGvsStats.mTotalSamples += mGvsStats.mPerViewCellSamples; 916 917 918 // timing 919 const long currentTime = GetTime(); 920 921 mGvsStats.mTimePerViewCell = TimeDiff(lastTime, currentTime) * 1e-3f; 922 mGvsStats.mTotalTime += mGvsStats.mTimePerViewCell; 923 924 lastTime = currentTime; 925 917 926 mGvsStats.Stop(); 918 927 mGvsStats.Print(mGvsStatsStream); 919 928 920 929 mTrianglePvs.clear(); 921 930 922 931 if (GVS_DEBUG) … … 1037 1046 1038 1047 //Randomize(0); 1039 1040 1048 mGvsStats.Reset(); 1041 1049 mGvsStats.Start(); … … 1119 1127 void GvsStatistics::Print(ostream &app) const 1120 1128 { 1121 app << "# Pass\n" << mPass << endl;1129 app << "#ViewCells\n" << mViewCells << endl; 1122 1130 app << "#ViewCellId\n" << mViewCellId << endl; 1123 app << "#Time\n" << Time() << endl; 1131 app << "#TotalTime\n" << mTotalTime << endl; 1132 app << "#TimePerViewCell\n" << mTimePerViewCell << endl;; 1133 1134 app << "#RaysPerSec\n" << RaysPerSec() << endl; 1135 1136 app << "#TrianglePvs\n" << mTrianglePvs << endl; 1137 app << "#TotalTrianglePvs\n" << mTotalTrianglePvs << endl; 1138 1139 app << "#PerViewCellPvs\n" << mPerViewCellPvs << endl; 1140 app << "#TotalPvs\n" << mTotalPvs << endl; 1141 1142 app << "#PerViewCellSamples\n" << mPerViewCellSamples << endl; 1124 1143 app << "#TotalSamples\n" << mTotalSamples << endl; 1125 app << "#ScDiff\n" << mPassContribution << endl;1126 1144 app << "#SamplesContri\n" << mTotalContribution << endl; 1127 app << "#ReverseSamples\n" << mReverseSamples << endl;1128 app << "#BorderSamples\n" << mBorderSamples << endl;1129 app << "#GvsRuns\n" << mGvsPass << endl;1130 app << "#ViewCells\n" << mViewCells << endl; 1131 app << "#TotalPvs\n" << mTotalPvs << endl;1132 app << "#PerViewCellPvs\n" << mPerViewCellPvs<< endl;1133 app << "#TrianglePvs\n" << mTrianglePvs << endl;1134 app << "#RaysPerSec\n" << RaysPerSec() << endl; 1135 app << "#PerViewCellSamples\n" << mPerViewCellSamples << endl <<endl;1136 } 1137 1138 1139 } 1145 1146 //app << "#ReverseSamples\n" << mReverseSamples << endl; 1147 //app << "#BorderSamples\n" << mBorderSamples << endl; 1148 1149 //app << "#Pass\n" << mPass << endl; 1150 //app << "#ScDiff\n" << mPassContribution << endl; 1151 //app << "#GvsRuns\n" << mGvsPass << endl; 1152 1153 app << endl; 1154 } 1155 1156 1157 } -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h
r1999 r2003 41 41 mTrianglePvs = 0; 42 42 mViewCellId = 0; 43 mTotalTime = 0; 44 mTimePerViewCell = 0; 45 mTotalTrianglePvs = 0; 43 46 } 44 47 … … 53 56 int mBorderSamples; 54 57 int mGvsPass; 55 58 56 59 int mTotalPvs; 57 60 int mViewCells; … … 59 62 int mPerViewCellPvs; 60 63 int mTrianglePvs; 64 int mTotalTrianglePvs; 61 65 int mViewCellId; 62 63 float RaysPerSec() const { if (!Time()) return 0; return (float)mTotalSamples / Time() * 1e-6f; } 66 67 float mTimePerViewCell; 68 float mTotalTime; 69 70 float RaysPerSec() const { if (!mTotalTime) return 0; return (float)mTotalSamples / mTotalTime * 1e-6f; } 64 71 65 72 void Print(ostream &app) const; -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h
r1920 r2003 226 226 */ 227 227 int GetObjectSpaceSubdivisionType() const; 228 228 229 /** The type of view space space subdivison 229 230 */ 230 231 int GetViewSpaceSubdivisionType() const; 232 231 233 /** Sets a pointer to the view cells manager. 232 234 */ 233 235 void SetViewCellsManager(ViewCellsManager *vcm); 236 234 237 /** Sets a pointer to the view cells tree. 235 238 */ 236 239 void SetViewCellsTree(ViewCellsTree *vcTree); 240 237 241 /** Exports the object hierarchy to disc. 238 242 */ -
GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp
r1999 r2003 17 17 RayCaster(preprocessor) 18 18 { 19 InitRayCast(externKdTree); 19 if (!InitRayCast(externKdTree)) 20 cout << "warning: intel ray tracer could not be initialized!" << endl; 20 21 } 21 22 … … 28 29 bool IntelRayCaster::InitRayCast(const string externKdTree) 29 30 { 30 cout<<"Ray Cast file: " << externKdTree << endl; 31 return mlrtaLoadAS(externKdTree.c_str()); 31 cout<<"Intel ray cast file: " << externKdTree << endl; 32 33 return mlrtaLoadAS(externKdTree.c_str()); 32 34 } 33 35 … … 41 43 ) 42 44 { 43 //cout << "intel ray" << endl;45 cout << "intel ray" << endl; 44 46 VssRay *vssRay = NULL; 45 47 int hits = 0; … … 73 75 if (castDoubleRay) 74 76 { 75 76 77 //cerr<<"HERE"<<endl; 78 Vector3 dir = -simpleRay.mDirection; 77 79 hittriangle = mlrtaIntersectAS( 78 80 &simpleRay.mOrigin.x, -
GTP/trunk/Lib/Vis/Preprocessing/src/InternalRayCaster.cpp
r1996 r2003 10 10 11 11 12 InternalRayCaster::InternalRayCaster(const Preprocessor &preprocessor , KdTree *kdTree):13 RayCaster(preprocessor) , mKdTree(kdTree)12 InternalRayCaster::InternalRayCaster(const Preprocessor &preprocessor): 13 RayCaster(preprocessor) 14 14 { 15 15 } … … 50 50 51 51 52 if (m KdTree->CastRay(ray)) {52 if (mPreprocessor.mKdTree->CastRay(ray)) { 53 53 hitA.mObject = ray.intersections[0].mObject; 54 54 hitA.mPoint = ray.Extrap(ray.intersections[0].mT); … … 60 60 ray.mFlags &= ~Ray::CULL_BACKFACES; 61 61 62 if (castDoubleRay && m KdTree->CastRay(ray)) {62 if (castDoubleRay && mPreprocessor.mKdTree->CastRay(ray)) { 63 63 hitB.mObject = ray.intersections[0].mObject; 64 64 hitB.mPoint = ray.Extrap(ray.intersections[0].mT); … … 102 102 VssRay *vssRay; 103 103 104 if (m KdTree->CastRay(ray)) {104 if (mPreprocessor.mKdTree->CastRay(ray)) { 105 105 // sort intersections 106 106 ray.SortIntersections(); -
GTP/trunk/Lib/Vis/Preprocessing/src/InternalRayCaster.h
r1996 r2003 30 30 /** Default constructor initialising e.g., KD tree 31 31 */ 32 InternalRayCaster(const Preprocessor &preprocessor , KdTree *kdTree);32 InternalRayCaster(const Preprocessor &preprocessor); 33 33 virtual ~InternalRayCaster(); 34 34 … … 60 60 protected: 61 61 62 KdTree *mKdTree;62 //KdTree *mKdTree; 63 63 }; 64 64 -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp
r1999 r2003 94 94 95 95 if (!splitCandidates) 96 splitCandidates = new vector<SortableEntry >;96 splitCandidates = new vector<SortableEntry *>; 97 97 98 98 // first construct a leaf that will get subdivide … … 114 114 115 115 // remove the allocated array 116 CLEAR_CONTAINER(*splitCandidates); 116 117 delete splitCandidates; 117 118 … … 460 461 ) 461 462 { 462 splitCandidates->clear(); 463 CLEAR_CONTAINER(*splitCandidates); 464 //splitCandidates->clear(); 463 465 464 466 int requestedSize = 2*(int)node->mObjects.size(); … … 467 469 requestedSize < (int)(splitCandidates->capacity()/10) ) { 468 470 delete splitCandidates; 469 splitCandidates = new vector<SortableEntry >;471 splitCandidates = new vector<SortableEntry *>; 470 472 } 471 473 … … 478 480 AxisAlignedBox3 box = (*mi)->GetBox(); 479 481 480 splitCandidates->push_back( SortableEntry(SortableEntry::BOX_MIN,482 splitCandidates->push_back(new SortableEntry(SortableEntry::BOX_MIN, 481 483 box.Min(axis), 482 484 *mi) … … 484 486 485 487 486 splitCandidates->push_back( SortableEntry(SortableEntry::BOX_MAX,488 splitCandidates->push_back(new SortableEntry(SortableEntry::BOX_MAX, 487 489 box.Max(axis), 488 490 *mi) … … 532 534 533 535 float totalIntersections = 0.0f; 534 vector<SortableEntry >::const_iterator ci;536 vector<SortableEntry *>::const_iterator ci; 535 537 536 538 for(ci = splitCandidates->begin(); 537 539 ci < splitCandidates->end(); 538 540 ci++) 539 if ((*ci) .type == SortableEntry::BOX_MIN) {540 totalIntersections += (*ci) .intersectable->IntersectionComplexity();541 if ((*ci)->type == SortableEntry::BOX_MIN) { 542 totalIntersections += (*ci)->intersectable->IntersectionComplexity(); 541 543 } 542 544 … … 558 560 ci < splitCandidates->end(); 559 561 ci++) { 560 switch ((*ci) .type) {562 switch ((*ci)->type) { 561 563 case SortableEntry::BOX_MIN: 562 564 objectsLeft++; 563 intersectionsLeft += (*ci) .intersectable->IntersectionComplexity();565 intersectionsLeft += (*ci)->intersectable->IntersectionComplexity(); 564 566 break; 565 567 case SortableEntry::BOX_MAX: 566 568 objectsRight--; 567 intersectionsRight -= (*ci) .intersectable->IntersectionComplexity();569 intersectionsRight -= (*ci)->intersectable->IntersectionComplexity(); 568 570 break; 569 571 } 570 572 571 if ((*ci) .value > minBand && (*ci).value < maxBand) {573 if ((*ci)->value > minBand && (*ci)->value < maxBand) { 572 574 AxisAlignedBox3 lbox = box; 573 575 AxisAlignedBox3 rbox = box; 574 lbox.SetMax(axis, (*ci) .value);575 rbox.SetMin(axis, (*ci) .value);576 lbox.SetMax(axis, (*ci)->value); 577 rbox.SetMin(axis, (*ci)->value); 576 578 577 579 float sum; … … 589 591 float newCost = mCt_div_ci + sum/boxArea; 590 592 float ratio = newCost/oldCost; 591 costStream<<(*ci) .value<<" "<<ratio<<endl;593 costStream<<(*ci)->value<<" "<<ratio<<endl; 592 594 } 593 595 #endif … … 595 597 if (sum < minSum) { 596 598 minSum = sum; 597 position = (*ci) .value;599 position = (*ci)->value; 598 600 599 601 objectsBack = objectsLeft; … … 1264 1266 if ((oit != objects.end()) && ((*oit)->GetId() == objId)) 1265 1267 { 1266 leaf->mObjects.push_back(*oit);1268 if (1) leaf->mObjects.push_back(*oit); 1267 1269 } 1268 1270 else -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h
r1999 r2003 548 548 549 549 // reusable array of split candidates 550 vector<SortableEntry > *splitCandidates;550 vector<SortableEntry *> *splitCandidates; 551 551 552 552 float -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r2002 r2003 265 265 266 266 cout << "binary obj dump available, loading " << filename.c_str() << endl; 267 // table associating indices with vectors 268 map<int, Vector3> hashTable; 267 269 268 270 269 // table for vertices 271 270 VertexContainer vertices; 272 FaceContainer faces; 273 271 274 272 if (parents) 275 273 cout << "using face parents" << endl; … … 277 275 cout << "not using face parents" << endl; 278 276 277 int dummy = 0; 278 vector<Triangle3> triangles; 279 //triangles.reserve(sizeof(Triangle3) * 13000000); 280 //triangles.reserve(13000000); 281 //root->mGeometry.reserve(13000000); 282 279 283 while (1) 280 284 { … … 291 295 TriangleIntersectable *obj = new TriangleIntersectable(tri); 292 296 root->mGeometry.push_back(obj); 293 294 // matt: we don't really need to keep an additional data structure 295 // if working with triangles => remove this 296 if (parents) 297 { 298 FaceParentInfo info(obj, 0); 299 parents->push_back(info); 300 } 301 } 302 297 //triangles.push_back(tri); 298 //dummy ++; 299 //if (dummy % 100000 == 9999) 300 //cout << "idx: " << dummy << endl; 301 } 302 303 //cout << "here411" << endl; 303 304 return true; 304 305 } … … 405 406 Intersectable *Preprocessor::GetParentObject(const int index) const 406 407 { 407 if (index == -1) 408 return NULL; 408 if (index < 0) 409 { 410 cerr << "Warning: triangle index smaller zero! " << index << endl; 411 return NULL; 412 } 409 413 410 414 if (!mFaceParents.empty()) … … 421 425 } 422 426 else 423 { 424 if (index >= (int)mObjects.size()) { 425 cerr<<"Warning: triangle index out of range! "<<index<<endl; 426 return NULL; 427 } 428 else 429 { 430 return mObjects[index]; 431 } 432 } 427 { 428 if (index >= (int)mObjects.size()) 429 { 430 cerr<<"Warning: triangle index out of range! " << index << endl; 431 return NULL; 432 } 433 else 434 { 435 return mObjects[index]; 436 } 437 } 433 438 } 434 439 … … 1078 1083 1079 1084 1080 bool Preprocessor::InitRayCast(const string externKdTree, 1081 const string internKdTree) 1085 bool Preprocessor::LoadInternKdTree( const string internKdTree) 1082 1086 { 1083 1087 // always try to load the kd tree … … 1111 1115 cout << mKdTree->GetBox() << endl; 1112 1116 1117 return true; 1118 } 1119 1120 1121 bool Preprocessor::InitRayCast(const string externKdTree, 1122 const string internKdTree) 1123 { 1124 // always try to load the kd tree 1125 /* cout << "loading kd tree file " << internKdTree << " ... " << endl; 1126 1127 if (!LoadKdTree(internKdTree)) 1128 { 1129 cout << "error loading kd tree with filename " 1130 << internKdTree << ", rebuilding it instead ... " << endl; 1131 // build new kd tree from scene geometry 1132 BuildKdTree(); 1133 1134 // export kd tree? 1135 const long startTime = GetTime(); 1136 cout << "exporting kd tree ... "; 1137 1138 if (!ExportKdTree(internKdTree)) 1139 { 1140 cout << " error exporting kd tree with filename " 1141 << internKdTree << endl; 1142 } 1143 else 1144 { 1145 cout << "finished in " 1146 << TimeDiff(startTime, GetTime()) * 1e-3 1147 << " secs" << endl; 1148 } 1149 } 1150 1151 KdTreeStatistics(cout); 1152 cout << mKdTree->GetBox() << endl; 1153 */ 1113 1154 int rayCastMethod; 1114 1155 Environment::GetSingleton()-> … … 1118 1159 { 1119 1160 cout << "ray cast method: internal" << endl; 1120 mRayCaster = new InternalRayCaster(*this , mKdTree);1161 mRayCaster = new InternalRayCaster(*this); 1121 1162 } 1122 1163 else … … 1140 1181 ) 1141 1182 { 1142 1143 1144 1183 const long t1 = GetTime(); 1145 1184 -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
r2002 r2003 164 164 bool InitRayCast(const string externKdTree, const string internKdTree); 165 165 166 bool LoadInternKdTree(const string internKdTree); 167 166 168 bool ExportObj(const string filename, const ObjectContainer &objects); 167 169 -
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp
r2001 r2003 748 748 749 749 Vector3 point; 750 Vector3 normal, normal2; 751 750 Vector3 normal; 751 752 //Vector normalObj; 752 753 // float r[1]; 753 754 // sHalton.GetNext(1, r); … … 769 770 770 771 // get point on view cell surface 771 mViewCell->GetRandomSurfacePoint(origin, normal 2);772 mViewCell->GetRandomSurfacePoint(origin, normal); 772 773 773 774 //direction = point - origin; … … 775 776 // move a little bit back to avoid piercing through walls 776 777 // that bound the view cell 777 origin -= 0.01f * normal 2;778 origin -= 0.01f * normal; 778 779 779 780 // $$ jb the pdf is yet not correct for all sampling methods! -
GTP/trunk/Lib/Vis/Preprocessing/src/Statistics.h
r860 r2003 17 17 static inline double TimeDiff(long time1, long time2) // in s 18 18 { 19 const double clk =1.0E-6; // ticks per second20 long t =time2-time1;19 const double clk = 1.0E-6; // ticks per second 20 long t = time2 - time1; 21 21 22 return ((t <0)?-t:t)*clk;22 return ((t < 0) ? -t : t) * clk; 23 23 } 24 24 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r1999 r2003 517 517 518 518 ViewCellsTree::~ViewCellsTree() 519 { cout<<"here1002";519 { 520 520 DEL_PTR(mRoot); 521 521 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1999 r2003 311 311 // question: rather create view cells resource manager? 312 312 if (!ViewCellsTreeConstructed()) 313 { cout << "here6" << endl;313 { 314 314 CLEAR_CONTAINER(mViewCells); 315 315 } 316 316 else 317 { cout << "here7" << endl;317 { 318 318 DEL_PTR(mViewCellsTree); 319 319 } … … 5962 5962 } 5963 5963 5964 // hack color code (show pvs size)5964 // hack color code 5965 5965 const int savedColorCode = mColorCode; 5966 5966 … … 6005 6005 6006 6006 mColorCode = 1; // 0 = random, 1 = export pvs 6007 // don't visualize render cost 6007 6008 const float maxRenderCost = -1; 6008 6009 6009 if ( 0)6010 if (1) 6010 6011 mHierarchyManager->ExportObjectSpaceHierarchy(exporter, objects, 6011 6012 CLAMP_TO_BOX ? &bbox : NULL, maxRenderCost, false); … … 6013 6014 6014 6015 //ExportViewCellsForViz(exporter, CLAMP_TO_BOX ? &bbox : NULL, mColorCode, GetClipPlane()); 6015 ExportViewCellsForViz(exporter, NULL, mColorCode, GetClipPlane()); 6016 if (0) 6017 ExportViewCellsForViz(exporter, NULL, mColorCode, GetClipPlane()); 6016 6018 6017 6019 delete exporter; -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1990 r2003 1135 1135 } 1136 1136 1137 stable_sort(mLocalSubdivisionCandidates->begin(), mLocalSubdivisionCandidates->end()); 1137 //stable_sort(mLocalSubdivisionCandidates->begin(), mLocalSubdivisionCandidates->end()); 1138 sort(mLocalSubdivisionCandidates->begin(), mLocalSubdivisionCandidates->end()); 1138 1139 } 1139 1140 -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h
r1977 r2003 514 514 float GetPriority() const 515 515 { 516 return mPriority; 516 return (float)-mParentData.mDepth; 517 //return mPriority; 517 518 } 518 519 -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r1999 r2003 192 192 } 193 193 194 Environment::GetSingleton()->GetStringValue("Scene.filename", buff); 195 string filename(buff); 196 197 const string externKdTree = ReplaceSuffix(filename, ".obj", ".kdf"); 198 const string internKdTree = GetInternFilename(filename, preprocessor->mLoadMeshes ? ".kdm" : ".kdt"); 199 200 if (preprocessor->InitRayCast(externKdTree, internKdTree)) 201 { 202 cout << "ray casting initialized!" << endl; 203 } 204 else 205 { 206 cout << "ray casting initialization failed!" << endl; 207 Cleanup(); 208 exit(1); 209 } 210 211 194 212 ///////////// 195 213 //-- load scene 196 214 197 Environment::GetSingleton()->GetStringValue("Scene.filename", buff);198 string filename(buff);199 200 201 215 if (!preprocessor->LoadScene(filename)) 202 216 { … … 206 220 } 207 221 208 const string externKdTree = ReplaceSuffix(filename, ".obj", ".kdf");209 const string internKdTree = GetInternFilename(filename, preprocessor->mLoadMeshes ? ".kdm" : ".kdt");210 222 211 223 //////////// 212 224 //-- initialize external ray caster 213 225 214 if (preprocessor-> InitRayCast(externKdTree,internKdTree))215 { 216 cout << " ray casting initialized!" << endl;226 if (preprocessor->LoadInternKdTree(internKdTree)) 227 { 228 cout << "intern kd tree loaded!" << endl; 217 229 } 218 230 else 219 231 { 220 cout << " ray casting initialization failed" << endl;232 cout << "loading intern kd tree failed!" << endl; 221 233 Cleanup(); 222 234 exit(1);
Note: See TracChangeset
for help on using the changeset viewer.