- Timestamp:
- 01/20/07 00:14:25 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.cpp
r1981 r1999 9 9 #include "Mesh.h" 10 10 #include "Halton.h" 11 #include "Triangle3.h" 12 11 13 12 14 namespace GtpVisibilityPreprocessor { … … 556 558 AxisAlignedBox3::IsInside(const Vector3 &v) const 557 559 { 558 return ! ( v.x < mMin.x||559 v.x > mMax.x||560 v.y < mMin.y||561 v.y > mMax.y||562 v.z < mMin.z||563 v.z > mMax.z);560 return ! ((v.x < mMin.x) || 561 (v.x > mMax.x) || 562 (v.y < mMin.y) || 563 (v.y > mMax.y) || 564 (v.z < mMin.z) || 565 (v.z > mMax.z)); 564 566 } 565 567 #endif … … 2353 2355 } 2354 2356 2357 2358 bool AxisAlignedBox3::Intersects(const Mesh &mesh) const 2359 { 2360 VertexContainer::const_iterator vit, vit_end = mesh.mVertices.end(); 2361 2362 for (vit = mesh.mVertices.begin(); vit != vit_end; ++ vit) 2363 { 2364 if (IsInside(*vit)) 2365 return true; 2366 } 2367 2368 return false; 2369 } 2370 2371 2372 bool AxisAlignedBox3::Intersects(const Triangle3 &tri) const 2373 { 2374 if (IsInside(tri.mVertices[0]) || 2375 IsInside(tri.mVertices[1]) || 2376 IsInside(tri.mVertices[2])) 2377 { 2378 return true; 2379 } 2380 2381 return false; 2382 } 2383 2355 2384 /* 2356 2385 int inline GetIntersection(const float fDst1, -
GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.h
r1995 r1999 13 13 class Polygon3; 14 14 class Mesh; 15 struct Triangle3; 15 16 16 17 /** … … 358 359 void ExtractPolys(PolygonContainer &polys) const; 359 360 361 /** Returns true if the mesh intersects the bounding box. 362 */ 363 bool Intersects(const Mesh &mesh) const; 364 /** Returns true if the triangle intersects the bounding box. 365 */ 366 bool Intersects(const Triangle3 &tri) const; 360 367 /** Splits the box into two separate boxes with respect to the split plane 361 368 */ -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1941 r1999 205 205 206 206 BvhInterior::~BvhInterior() 207 { 207 { 208 208 DEL_PTR(mFront); 209 209 DEL_PTR(mBack); -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
r1996 r1999 16 16 { 17 17 18 #define GVS_DEBUG 018 #define GVS_DEBUG 1 19 19 20 20 struct VizStruct … … 31 31 GvsPreprocessor::GvsPreprocessor(): 32 32 Preprocessor(), 33 mSamplingType(SamplingStrategy::VIEWCELL_BASED_DISTRIBUTION),34 //mSamplingType(SamplingStrategy::DIRECTION_BASED_DISTRIBUTION),33 //mSamplingType(SamplingStrategy::VIEWCELL_BASED_DISTRIBUTION), 34 mSamplingType(SamplingStrategy::DIRECTION_BASED_DISTRIBUTION), 35 35 mProcessedViewCells(0), 36 36 mCurrentViewCell(NULL) … … 144 144 delete newRay; 145 145 } 146 else if (0 && GVS_DEBUG && (mVssRays.size() < 9)) 146 147 148 return 1; 149 } 150 151 return 0; 152 } 153 154 // #id: 1270 155 bool GvsPreprocessor::HasContribution(VssRay &ray) 156 { 157 if (!ray.mTerminationObject) 158 return false; 159 160 bool result; 161 162 if (!mPerViewCell) 163 { 164 // store the rays + the intersected view cells 165 const bool storeViewCells = false; //GVS_DEBUG; 166 167 mViewCellsManager->ComputeSampleContribution(ray, 168 true, 169 storeViewCells, 170 true); 171 172 result = ray.mPvsContribution > 0; 173 } 174 else 175 { 176 Intersectable *obj = ray.mTerminationObject; 177 178 if (!obj->mCounter) 147 179 { 148 mVssRays.push_back(new VssRay(oldRay)); 149 mVssRays.push_back(new VssRay(currentRay)); 150 mVssRays.push_back(new VssRay(*newRay)); 151 } 152 153 return 1; 154 } 155 156 return 0; 157 } 158 159 160 bool GvsPreprocessor::HandleRay(VssRay *vssRay) 161 { 162 // store the rays + the intersected view cells 163 const bool storeRaysForViz = false; //GVS_DEBUG; 164 165 if (!mPerViewCell) 166 { 167 mViewCellsManager->ComputeSampleContribution(*vssRay, 168 true, 169 storeRaysForViz, 170 true); 171 } 172 else 173 { 174 mViewCellsManager->ComputeSampleContribution(*vssRay, 180 obj->mCounter = 1; 181 mTrianglePvs.push_back(obj); 182 183 /*mViewCellsManager->ComputeSampleContribution(ray, 175 184 true, 176 185 mCurrentViewCell, 177 true); 178 } 179 180 // some pvs contribution for this ray? 181 if (!vssRay->mPvsContribution) 186 true);*/ 187 188 result = true; 189 } 190 else 191 { 192 result = false; 193 } 194 } 195 196 return result; 197 } 198 199 200 bool GvsPreprocessor::HandleRay(VssRay *vssRay) 201 { 202 if (!HasContribution(*vssRay)) 182 203 return false; 183 204 184 if ( GVS_DEBUG)205 if (0 && GVS_DEBUG) 185 206 mVssRays.push_back(new VssRay(*vssRay)); 186 207 187 208 // add new ray to ray queue 188 209 mRayQueue.push(vssRay); 189 190 if (storeRaysForViz)191 {192 VssRay *nray = new VssRay(*vssRay);193 nray->mFlags = vssRay->mFlags;194 195 // store ray in contributing view cell196 ViewCellContainer::const_iterator vit, vit_end = vssRay->mViewCells.end();197 for (vit = vssRay->mViewCells.begin(); vit != vit_end; ++ vit)198 {199 (*vit)->GetOrCreateRays()->push_back(nray);200 }201 }202 210 203 211 ++ mGvsStats.mTotalContribution; … … 399 407 } 400 408 409 int castRays = (int)simpleRays.size(); 410 411 VssRayContainer invalidSamples; 412 401 413 // handle rays 402 EnqueueRays(vssRays); 403 404 int castRays = simpleRays.size(); 405 414 EnqueueRays(vssRays, invalidSamples); 415 406 416 // recursivly subdivide each edge 407 417 for (int i = 0; i < numBorderSamples; ++ i) … … 414 424 currentRay); 415 425 } 416 426 417 427 mGvsStats.mBorderSamples += castRays; 428 429 CLEAR_CONTAINER(invalidSamples); 418 430 419 431 return castRays; … … 442 454 if (!intersects) 443 455 { 444 cerr << "big error!! no intersection " << pt1 << " " << pt2 << endl;456 //cerr << "big error!! no intersection " << pt1 << " " << pt2 << endl; 445 457 return false; 446 458 } … … 562 574 CastRays(simpleRays, samples, castDoubleRays, pruneInvalidRays); 563 575 576 VssRayContainer invalidSamples; 577 564 578 // add to ray queue 565 EnqueueRays(samples); 566 579 EnqueueRays(samples, invalidSamples); 580 581 CLEAR_CONTAINER(invalidSamples); 567 582 //Debug << "generated " << numSamples << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 568 583 return (int)simpleRays.size(); … … 570 585 571 586 572 void GvsPreprocessor::EnqueueRays(VssRayContainer &samples )587 void GvsPreprocessor::EnqueueRays(VssRayContainer &samples, VssRayContainer &invalidSamples) 573 588 { 574 589 // add samples to ray queue … … 576 591 for (vit = samples.begin(); vit != vit_end; ++ vit) 577 592 { 578 HandleRay(*vit); 593 VssRay *ray = *vit; 594 595 if (!HandleRay(ray)) 596 invalidSamples.push_back(ray); 579 597 } 580 598 } … … 597 615 castSamples += newSamples; 598 616 599 //cout << newSamples << " ";617 //cout << "new samples: " << newSamples << " " << "queue: " << (int)mRayQueue.size() << endl; 600 618 delete ray; 601 619 } … … 639 657 640 658 641 void GvsPreprocessor::VisualizeViewCell(ViewCell *vc) 659 //void GvsPreprocessor::VisualizeViewCell(ViewCell *vc) 660 void GvsPreprocessor::VisualizeViewCell(const ObjectContainer &objects) 642 661 { 643 662 Intersectable::NewMail(); … … 651 670 return; 652 671 653 ObjectPvsIterator pit = vc->GetPvs().GetIterator();672 /*ObjectPvsIterator pit = vc->GetPvs().GetIterator(); 654 673 655 674 // output PVS of view cell … … 669 688 670 689 exporter->ExportIntersectable(intersect); 690 }*/ 691 ObjectContainer::const_iterator oit, oit_end = objects.end(); 692 693 for (oit = objects.begin(); oit != oit_end; ++ oit) 694 { 695 Intersectable *intersect = *oit; 696 697 m = RandomMaterial(); 698 exporter->SetForcedMaterial(m); 699 exporter->ExportIntersectable(intersect); 671 700 } 672 701 … … 682 711 exporter->SetForcedMaterial(m); 683 712 684 mViewCellsManager->ExportViewCellGeometry(exporter, vc, NULL, NULL); 713 //mViewCellsManager->ExportViewCellGeometry(exporter, vc, NULL, NULL); 714 //mViewCellsManager->ExportViewCellGeometry(exporter, mCurrentViewCell, NULL, NULL); 715 716 AxisAlignedBox3 bbox = mCurrentViewCell->GetMesh()->mBox; 717 exporter->ExportBox(bbox); 685 718 //exporter->SetFilled(); 686 719 … … 720 753 void GvsPreprocessor::ProcessViewCell() 721 754 { 755 //Intersectable::NewMail(); 756 // compute direct intersections with view cell 757 IntersectWithViewCell(); 758 722 759 mGvsStats.mPerViewCellSamples = 0; 723 760 int oldContribution = mGvsStats.mTotalContribution; … … 736 773 passSamples += newSamples; 737 774 mGvsStats.mPerViewCellSamples += newSamples; 738 //cout << "here 4" << passSamples % (mSamplesPerPass + 1) << endl;775 //cout << "here2 " << passSamples % (mSamplesPerPass + 1) << endl; 739 776 740 777 if (passSamples >= mSamplesPerPass) … … 774 811 { 775 812 mViewCells.push_back(mViewCellsManager->GetViewCell((int)mViewCells.size())); 813 continue; 776 814 } 777 else 815 816 // HACK 817 const int tries = 10000; 818 int i = 0; 819 820 for (i = 0; i < tries; ++ i) 778 821 { 779 // HACK780 const int tries = 10000;781 int i = 0;782 783 for (i = 0; i < tries; ++ i)822 const int idx = (int)RandomValue(0.0f, (float)mViewCellsManager->GetNumViewCells() - 0.5f); 823 824 ViewCell *viewCell = mViewCellsManager->GetViewCell(idx); 825 826 if (!viewCell->Mailed()) 784 827 { 785 const int idx = (int)RandomValue(0.0f, (float)mViewCellsManager->GetNumViewCells() - 0.5f); 786 787 ViewCell *viewCell = mViewCellsManager->GetViewCell(idx); 788 789 if (!viewCell->Mailed()) 828 viewCell->Mail(); 829 break; 830 } 831 832 mViewCells.push_back(viewCell); 833 } 834 835 if (i == tries) 836 { 837 cerr << "big error! no view cell found" << endl; 838 return; 839 } 840 } 841 } 842 843 844 void GvsPreprocessor::IntersectWithViewCell() 845 { 846 mCurrentViewCell->GetMesh()->ComputeBoundingBox(); 847 AxisAlignedBox3 box = mCurrentViewCell->GetMesh()->mBox; 848 //cout << "box: " << box << endl; 849 vector<KdLeaf *> leaves; 850 851 mKdTree->GetBoxIntersections(box, leaves); 852 853 vector<KdLeaf *>::const_iterator lit, lit_end = leaves.end(); 854 855 for (lit = leaves.begin(); lit != leaves.end(); ++ lit) 856 { 857 KdLeaf *leaf = *lit; 858 ObjectContainer::const_iterator oit, oit_end = leaf->mObjects.end(); 859 860 for (oit = leaf->mObjects.begin(); oit != oit_end; ++ oit) 861 { 862 TriangleIntersectable *triObj = dynamic_cast<TriangleIntersectable *>(*oit); 863 864 if (box.Intersects(triObj->GetItem())) 865 { 866 if (!triObj->mCounter) 790 867 { 791 viewCell->Mail();792 break;868 triObj->mCounter = 1; 869 mTrianglePvs.push_back(triObj); 793 870 } 794 795 mViewCells.push_back(viewCell);796 }797 798 if (i == tries)799 {800 cerr << "big error! no view cell found" << endl;801 return;802 871 } 803 872 } … … 808 877 void GvsPreprocessor::PerViewCellComputation() 809 878 { 879 // hack: reset counter 880 ObjectContainer::const_iterator oit, oit_end = mObjects.end(); 881 882 for (oit = mObjects.begin(); oit != oit_end; ++ oit) 883 { 884 (*oit)->mCounter = 0; 885 } 886 810 887 while (NextViewCell()) 811 888 { 812 cout << "\n***********************\nprocessing view cell " << mProcessedViewCells << endl; 889 cout << "\n***********************\n" 890 << "processing view cell " << mProcessedViewCells 891 << " (id: " << mCurrentViewCell->GetId() << ")" << endl; 813 892 814 893 // compute the pvs of the current view cell 815 894 ProcessViewCell(); 816 895 817 mGvsStats.mTrianglePvs = mCurrentViewCell->GetPvs().GetSize(); 896 //mGvsStats.mTrianglePvs = mCurrentViewCell->GetPvs().GetSize(); 897 mGvsStats.mTrianglePvs = (int)mTrianglePvs.size(); 898 899 ObjectContainer objectPvs; 818 900 819 901 // exchange triangle pvs with objects 820 UpdatePvs(mCurrentViewCell); 821 822 if (GVS_DEBUG) 823 { 824 VisualizeViewCell(mCurrentViewCell); 825 CLEAR_CONTAINER(mVssRays); 826 } 902 //UpdatePvs(mCurrentViewCell); 903 GetObjectPvs(objectPvs); 904 905 cout << "triangle pvs of " << (int)mTrianglePvs.size() << " was converted to object pvs of " << (int)objectPvs.size() << endl; 827 906 828 907 //////// … … 830 909 831 910 mGvsStats.mViewCells = mProcessedViewCells;//mPass; 832 mGvsStats.mPerViewCellPvs = mCurrentViewCell->GetPvs().GetSize(); 833 mGvsStats.mTotalPvs += mCurrentViewCell->GetPvs().GetSize(); 911 //mGvsStats.mPerViewCellPvs = mCurrentViewCell->GetPvs().GetSize(); 912 mGvsStats.mPerViewCellPvs = (int)mTrianglePvs.size(); 913 914 mGvsStats.mTotalPvs += mGvsStats.mPerViewCellPvs; 834 915 mGvsStats.mTotalSamples += mGvsStats.mPerViewCellSamples; 835 916 836 917 mGvsStats.Stop(); 837 918 mGvsStats.Print(mGvsStatsStream); 919 920 mTrianglePvs.clear(); 921 922 if (GVS_DEBUG) 923 { 924 //VisualizeViewCell(mCurrentViewCell); 925 VisualizeViewCell(objectPvs); 926 CLEAR_CONTAINER(mVssRays); 927 } 838 928 839 929 // is this really necessary? … … 871 961 872 962 currentViewCell->SetPvs(newPvs); 963 } 964 965 966 void GvsPreprocessor::GetObjectPvs(ObjectContainer &objectPvs) const 967 { 968 BvhLeaf::NewMail(); 969 970 ObjectContainer::const_iterator oit, oit_end = mTrianglePvs.end(); 971 972 for (oit = mTrianglePvs.begin(); oit != oit_end; ++ oit) 973 { 974 Intersectable *intersect = *oit; 975 976 BvhLeaf *bv = intersect->mBvhLeaf; 977 978 if (!bv || bv->Mailed()) 979 continue; 980 981 bv->Mail(); 982 983 objectPvs.push_back(bv); 984 // hack: reset counter 985 (*oit)->mCounter = 0; 986 } 873 987 } 874 988 … … 978 1092 979 1093 vector<VizStruct>::const_iterator vit, vit_end = vizContainer.end(); 1094 980 1095 for (vit = vizContainer.begin(); vit != vit_end; ++ vit) 981 1096 { … … 989 1104 990 1105 VssRayContainer::const_iterator rit, rit_end = mVssRays.end(); 1106 991 1107 for (rit = mVssRays.begin(); rit != rit_end; ++ rit) 992 1108 { -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h
r1996 r1999 150 150 with respect to the previous ray. 151 151 */ 152 void EnqueueRays(VssRayContainer &samples );152 void EnqueueRays(VssRayContainer &samples, VssRayContainer &invalidSamples); 153 153 154 154 /** Hepler function for adaptive border sampling. It finds … … 191 191 192 192 void VisualizeViewCell(ViewCell *vc); 193 void VisualizeViewCell(const ObjectContainer &objects); 193 194 194 195 /** Exchanges view cell triangle pvs with bvh leaf pvs. … … 201 202 void CompileViewCellsList(); 202 203 204 void GetObjectPvs(ObjectContainer &trianglePvs) const; 205 206 bool HasContribution(VssRay &ray); 207 208 void IntersectWithViewCell(); 203 209 204 210 ////////////////////// … … 220 226 // stats 221 227 222 /*int mSampleContriPerPass;223 int mTotalSampleContri;224 int mReverseSamples;225 int mBorderSamples;226 int mGvsPass;*/227 228 228 ofstream mGvsStatsStream; 229 229 GvsStatistics mGvsStats; … … 241 241 242 242 int mMaxViewCells; 243 244 ObjectContainer mTrianglePvs; 243 245 }; 244 246 -
GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp
r1996 r1999 73 73 if (castDoubleRay) 74 74 { 75 cerr<<"HERE"<<endl;75 //cerr<<"HERE"<<endl; 76 76 Vector3 dir = -simpleRay.mDirection; 77 77 hittriangle = mlrtaIntersectAS( -
GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h
r1990 r1999 32 32 class Intersectable { 33 33 public: 34 // last mail id -> warning not thread safe! 35 // both mailId and mailbox should be unique for each thread!!! 36 static int sMailId; 37 static int sReservedMailboxes; 38 39 /// Mailbox used for traversals 40 int mMailbox; 41 34 42 35 /// unique object Id 43 36 int mId; … … 101 94 int IncMail() { return ++ mMailbox - sMailId; } 102 95 96 // last mail id -> warning not thread safe! 97 // both mailId and mailbox should be unique for each thread!!! 98 static int sMailId; 99 static int sReservedMailboxes; 100 101 /// Mailbox used for traversals 102 int mMailbox; 103 104 103 105 //////////////////////////////////////////////////// 104 106 virtual AxisAlignedBox3 GetBox() const = 0; -
GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.h
r1877 r1999 197 197 198 198 float GetArea() const {return mItem.GetArea();} 199 199 200 int Type() const 200 201 { … … 219 220 220 221 221 222 223 222 } 224 223 -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp
r1995 r1999 38 38 DEL_PTR(mFront); 39 39 DEL_PTR(mBack); 40 } 41 42 43 KdLeaf::~KdLeaf() 44 { 45 DEL_PTR(mViewCell); 40 46 } 41 47 … … 77 83 KdTree::~KdTree() 78 84 { 79 DEL_PTR(mRoot); 85 DEL_PTR(mRoot); 86 87 CLEAR_CONTAINER(mKdIntersectables); 80 88 } 81 89 … … 1439 1447 } 1440 1448 1449 1441 1450 KdIntersectable * 1442 1451 KdTree::GetOrCreateKdIntersectable(KdNode *node) … … 1532 1541 1533 1542 1534 void KdTree::InsertObjects(KdNode *node, const ObjectContainer &objects) 1535 {/* 1536 stack<KdObjectsTraversalData> tStack; 1543 void KdTree::GetBoxIntersections(const AxisAlignedBox3 &box, 1544 vector<KdLeaf *> &leaves) 1545 { 1546 stack<KdNode *> tStack; 1547 1548 tStack.push(mRoot); 1537 1549 1538 1550 while (!tStack.empty()) 1539 1551 { 1540 KdObjectsTraversalData tData = tStack.top(); 1541 tStack.pop(); 1542 1543 KdNode *node = tData.node; 1552 KdNode *node = tStack.top(); 1553 tStack.pop(); 1544 1554 1545 1555 if (node->IsLeaf()) 1546 1556 { 1547 KdLeaf *leaf = dynamic_cast<KdLeaf *>(node); 1548 1549 ObjectContainer::const_iterator oit, oit_end = tData.objects->end(); 1550 1551 for (oit = tData.objects->begin(); oit != oit_end; ++ oit) 1552 { 1553 leaf->mObjects.push_back(*oit); 1554 } 1557 leaves.push_back(dynamic_cast<KdLeaf *>(node)); 1555 1558 } 1556 1559 else // interior 1557 1560 { 1558 KdObjectsTraversalData frontData, backData;1559 1561 KdInterior *interior = dynamic_cast<KdInterior *>(node); 1560 1562 1561 frontData.objects = new ObjectContainer(); 1562 backData.objects = new ObjectContainer(); 1563 1564 ObjectContainer::const_iterator oit, oit_end = tData.objects->end(); 1565 1566 for (oit = tData.objects->begin(); oit != oit_end; ++ oit) 1563 if (box.Max(interior->mAxis) >= interior->mPosition) 1567 1564 { 1568 Intersectable *object = *oit; 1569 1570 // determine the side of this ray with respect to the plane 1571 const AxisAlignedBox3 box = object->GetBox(); 1572 1573 if (box.Max(interior->mAxis) >= interior->mPosition) 1574 { 1575 frontData.objects->push_back(object); 1576 } 1577 1578 if (box.Min(interior->mAxis) < interior->mPosition) 1579 { 1580 backData.objects->push_back(object); 1581 } 1565 tStack.push(interior->mFront); 1582 1566 } 1583 1567 1584 tStack.push(backData); 1585 tStack.push(frontData); 1586 } 1587 1588 DEL_PTR(tData.objects); 1589 }*/ 1590 } 1591 1592 } 1568 if (box.Min(interior->mAxis) < interior->mPosition) 1569 { 1570 tStack.push(interior->mBack); 1571 } 1572 } 1573 } 1574 } 1575 1576 1577 1578 } -
GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h
r1989 r1999 192 192 } 193 193 194 ~KdLeaf() { DEL_PTR(mViewCell); }194 ~KdLeaf(); 195 195 196 196 void AddPassingRay2(const Ray &ray, … … 411 411 KdNode * 412 412 GetNode(const Vector3 &point, const float maxArea) const; 413 414 void GetBoxIntersections(const AxisAlignedBox3 &box, 415 vector<KdLeaf *> &leaves); 413 416 414 417 int -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r1996 r1999 211 211 DEL_PTR(renderer); 212 212 DEL_PTR(mRayCaster); 213 213 214 #ifdef USE_CG 214 215 DEL_PTR(mGlobalLinesRenderer); … … 1110 1111 cout << mKdTree->GetBox() << endl; 1111 1112 1112 if (0)1113 {1114 Exporter *exporter = Exporter::GetExporter("dummykd.x3d");1115 1116 if (exporter)1117 {1118 exporter->ExportKdTree(*mKdTree, true);1119 delete exporter;1120 }1121 }1122 1123 1113 int rayCastMethod; 1124 1114 Environment::GetSingleton()-> -
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp
r1996 r1999 233 233 Vector3 point; 234 234 Vector3 normal; 235 //cout << "y";235 236 236 const int i = (int)RandomValue(0, (float)mPreprocessor.mObjects.size() - 0.5f); 237 237 … … 347 347 Vector3 point; 348 348 Vector3 normal; 349 //cout << "y";349 350 350 const int i = (int)RandomValue(0, (float)mPreprocessor.mObjects.size() - 0.5f); 351 351 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r1890 r1999 517 517 518 518 ViewCellsTree::~ViewCellsTree() 519 { 519 {cout<<"here1002"; 520 520 DEL_PTR(mRoot); 521 521 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h
r1867 r1999 108 108 109 109 int mPvsSizeDecr; 110 111 110 112 111 float mVolume; … … 153 152 154 153 public: 154 155 155 ViewCell(); 156 156 … … 243 243 } 244 244 245 static bool GreaterOrEqualPvs(const ViewCell *a, const ViewCell *b) { 246 return !SmallerPvs(a, b); 247 } 245 static bool GreaterOrEqualPvs(const ViewCell *a, const ViewCell *b) 246 { 247 return !SmallerPvs(a, b); 248 } 248 249 249 250 static bool SmallerRenderCost(const ViewCell *a, const ViewCell *b) … … 260 261 @hack The function is available for leaves also to have a common interface, 261 262 but it should be less than zero for leaves. 262 263 */ 263 264 void SetMergeCost(const float mergeCost); 264 265 … … 269 270 float GetMergeCost() const; 270 271 271 272 mPvsCost = GetPvs().EvalPvsCost();273 274 275 276 mPvsCost = c;277 278 279 280 return mPvsCost;281 272 void UpdatePvsCost() { 273 mPvsCost = GetPvs().EvalPvsCost(); 274 } 275 276 void SetPvsCost(const float c) { 277 mPvsCost = c; 278 } 279 280 float GetPvsCost() const { 281 return mPvsCost; 282 } 282 283 283 284 ////////// 284 285 //-- mailing stuff 285 286 286 287 288 289 290 291 292 293 294 295 296 297 298 287 // static void NewMail(const int reserve = 1) 288 // { 289 // sMailId += sReservedMailboxes; 290 // sReservedMailboxes = reserve; 291 // } 292 293 // void Mail() { mMailbox = sMailId; } 294 // bool Mailed() const { return mMailbox == sMailId; } 295 296 // void Mail(const int mailbox) { mMailbox = sMailId + mailbox; } 297 // bool Mailed(const int mailbox) const { return mMailbox == sMailId + mailbox; } 298 299 // int IncMail() { return ++ mMailbox - sMailId; } 299 300 300 301 … … 302 303 // both mailId and mailbox should be unique for each thread!!! 303 304 304 //static int sMailId; 305 //static int sReservedMailboxes; 306 307 int GetFilteredPvsSize() const { 308 return mFilteredPvsSize; 309 } 310 311 void SetFilteredPvsSize(const int s) { 312 mFilteredPvsSize = s; 305 //static int sMailId; 306 //static int sReservedMailboxes; 307 308 int GetFilteredPvsSize() const 309 { 310 return mFilteredPvsSize; 311 } 312 313 void SetFilteredPvsSize(const int s) { 314 mFilteredPvsSize = s; 313 315 } 314 316 … … 341 343 bool mPvsSizeValid; 342 344 343 /// Filter cost of the pvs 344 int mFilteredPvsSize; 345 346 /// Filter cost of the pvs 347 int mFilteredPvsSize; 345 348 346 349 }; … … 356 359 357 360 ViewCellInterior(Mesh *mesh); 358 361 359 362 /** Sets pointer from parent to child and vice versa. 360 363 */ … … 368 371 mCost = c; 369 372 } 370 373 371 374 float GetCost() const { 372 375 return mCost; 373 376 } 374 375 377 378 ViewCellContainer mChildren; 376 379 377 380 protected: 378 /** overall cost resulting from the merge */ 379 float mCost; 381 382 /// Pverall cost resulting from the merge. 383 float mCost; 380 384 }; 381 385 … … 449 453 450 454 public: 455 451 456 ViewCellsTree(); 457 452 458 /** View cells tree constructor taking a view cell mnanager as parameter 453 459 */ … … 509 515 float GetPvsCost(ViewCell *vc) const; 510 516 511 512 517 /** Returns number of entries associated with this view cell. 513 518 … … 587 592 void ReadEnvironment(); 588 593 589 ///////////////////////////////////////////////////////////////// 590 // merge related stuff // 591 ///////////////////////////////////////////////////////////////// 594 595 ////////////////////////////////////////////////////////////// 596 // merge related stuff // 597 ////////////////////////////////////////////////////////////// 598 592 599 593 600 /** Computes render cost of the merged pvs. … … 623 630 @returns difference in pvs size 624 631 */ 625 ViewCellInterior *MergeViewCells(ViewCell *l, ViewCell *r, float &pvsDiff); //const;632 ViewCellInterior *MergeViewCells(ViewCell *l, ViewCell *r, float &pvsDiff); 626 633 627 634 /** Shuffles, i.e. takes border leaf from view cell 1 and adds it -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1990 r1999 311 311 // question: rather create view cells resource manager? 312 312 if (!ViewCellsTreeConstructed()) 313 { 313 {cout << "here6" << endl; 314 314 CLEAR_CONTAINER(mViewCells); 315 315 } 316 316 else 317 { 317 {cout << "here7" << endl; 318 318 DEL_PTR(mViewCellsTree); 319 319 } … … 682 682 if (success) 683 683 { 684 //vm->ResetViewCells(); 685 //hack 686 vm->mViewCells.clear(); 687 ViewCellContainer leaves; 688 vm->mViewCellsTree->CollectLeaves(vm->mViewCellsTree->GetRoot(), leaves); 689 690 ViewCellContainer::const_iterator it, it_end = leaves.end(); 691 692 for (it = leaves.begin(); it != it_end; ++ it) 693 { 694 vm->mViewCells.push_back(*it); 695 } 684 if (0) 685 { 686 vm->ResetViewCells(); 687 } 688 else 689 { 690 //hack: should work with reset function 691 ViewCellContainer leaves; 692 693 vm->mViewCells.clear(); 694 vm->mViewCellsTree->CollectLeaves(vm->mViewCellsTree->GetRoot(), leaves); 695 696 ViewCellContainer::const_iterator it, it_end = leaves.end(); 697 698 for (it = leaves.begin(); it != it_end; ++ it) 699 { 700 vm->mViewCells.push_back(*it); 701 } 702 } 703 696 704 vm->mViewCellsFinished = true; 697 705 vm->mMaxPvsSize = (int)objects->size(); … … 2943 2951 ) 2944 2952 { 2945 //cout<<"y";2946 2953 PvsFilterStatistics stats; 2947 2954 … … 6387 6394 ViewCellsManager *vm = 6388 6395 ViewCellsManager::LoadViewCells(filename, objects, finalizeViewCells, bconverter); 6389 #if 0 6390 // insert scene objects in tree 6391 mOspTree->InsertObjects(mOspTree->GetRoot(), *objects); 6392 #endif 6396 6393 6397 return vm; 6394 6398 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp
r1928 r1999 883 883 884 884 Debug << "exchanging boxes" << endl; 885 int i = 0;885 int i = 0; 886 886 // remove view cells and exchange them with the 887 887 // view cells specialized for the current hierarchy node type … … 910 910 } 911 911 912 // delete old view cell 912 913 DEL_PTR(vc); 914 913 915 // (*vit).second = bspVc; 914 916 (*vit) = bspVc; … … 924 926 mVspTree->mBoundingBox = mViewSpaceBox; 925 927 926 // ViewCellsMap::iterator vit, vit_end = mViewCells.end(); 927 ViewCellContainer::iterator vit, vit_end = mViewCells.end(); 928 // ViewCellsMap::iterator vit, vit_end = mViewCells.end(); 929 ViewCellContainer::iterator vit, vit_end = mViewCells.end(); 930 928 931 // reset view cells using the current node type 929 932 for (vit = mViewCells.begin(); vit != vit_end; ++ vit) 930 933 { 931 934 //ViewCell *vc = (*vit).second; 932 ViewCell *vc = (*vit); 935 ViewCell *vc = (*vit); 936 937 if (!vc->IsLeaf()) // exchange only leaves 938 continue; 939 933 940 VspViewCell *vspVc = new VspViewCell(); 941 934 942 vspVc->SetPvs(vc->GetPvs()); 935 943 vspVc->SetId(vc->GetId()); 936 937 if (!vc->IsLeaf()) // exchange only leaves938 continue;939 944 940 945 if (vc->IsRoot()) … … 947 952 } 948 953 949 //DEL_PTR(vc); 954 // exchange view cell with new one 955 DEL_PTR(vc); 956 950 957 //(*vit).second = vspVc; 951 958 (*vit) = vspVc; -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParserXerces.h
r1623 r1999 97 97 // typedef map<int, ViewCell *> ViewCellsMap; 98 98 //ViewCellsMap mViewCells; 99 ViewCellContainer mViewCells;99 ViewCellContainer mViewCells; 100 100 101 101 ViewCellsManager *mViewCellsManager; -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r1970 r1999 211 211 //////////// 212 212 //-- initialize external ray caster 213 213 214 214 if (preprocessor->InitRayCast(externKdTree, internKdTree)) 215 215 { … … 258 258 } 259 259 260 260 261 261 bool useHwGlobalLines; 262 262 Environment::GetSingleton()->GetBoolValue("Preprocessor.useHwGlobalLines", … … 272 272 273 273 preprocessor->PrepareHwGlobalLines(); 274 275 274 globalLinesRenderer->Run(); 276 275 … … 367 366 } 368 367 #endif 368 369 369 // release memory 370 370 Cleanup(); 371 delete pt; 371 372 372 373 return returnCode;
Note: See TracChangeset
for help on using the changeset viewer.