Changeset 1763 for GTP/trunk/Lib/Vis
- Timestamp:
- 11/16/06 19:41:44 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp
r1761 r1763 84 84 } 85 85 86 87 int BvhNode::GetRandomEdgePoint(Vector3 &point, 88 Vector3 &normal) 89 { 90 // get random edge 91 const int idx = Random(12); 92 Vector3 a, b; 93 mBoundingBox.GetEdge(idx, &a, &b); 94 95 const float factor = RandomValue(0.0f, 1.0f); 96 97 point = a * factor + b * (1 - factor); 98 //normal = mBoundingBox.GetNormal(); 99 100 return idx; 101 } 86 102 87 103 … … 415 431 416 432 // set the time stamp so the order of traversal can be reconstructed 417 node-> mTimeStamp = mHierarchyManager->mTimeStamp ++;433 node->SetTimeStamp(mHierarchyManager->mTimeStamp ++); 418 434 419 435 // assign the objects in sorted order … … 1699 1715 numRays += CollectViewCells(*oit, viewCells, true, setCounter, onlyMailedRays); 1700 1716 } 1701 //cout << "here4 " << numRays << " boj: " << objects.size() << " " << onlyMailedRays << endl;1702 1717 1703 1718 return numRays; … … 1818 1833 int numRays = CollectViewCells(node->mObjects, viewCells, false, false); 1819 1834 1820 //cout << "here6 " << numRays << endl;1821 1835 if (0) cout << "collected " << (int)viewCells.size() << " dirty candidates" << endl; 1822 1836 … … 2353 2367 BvhSubdivisionCandidate *backCandidate = new BvhSubdivisionCandidate(tBackData); 2354 2368 2355 frontCandidate->SetPriority((float)-oldInterior->GetFront()-> mTimeStamp);2356 backCandidate->SetPriority((float)-oldInterior->GetBack()-> mTimeStamp);2369 frontCandidate->SetPriority((float)-oldInterior->GetFront()->GetTimeStamp()); 2370 backCandidate->SetPriority((float)-oldInterior->GetBack()->GetTimeStamp()); 2357 2371 2358 2372 frontCandidate->mEvaluationHack = oldInterior->GetFront(); -
GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h
r1761 r1763 63 63 { return rayRefs / (double)Leaves(); } 64 64 65 65 66 66 void Reset() 67 67 { … … 201 201 float GetMergeCost() {return (float)-mTimeStamp; } 202 202 203 int mTimeStamp; 203 virtual int GetRandomEdgePoint(Vector3 &point, 204 Vector3 &normal); 205 206 inline int GetTimeStamp() const { return mTimeStamp; } 207 inline void SetTimeStamp(const int timeStamp) { mTimeStamp = timeStamp; }; 204 208 205 209 ///////////////////////////////////// … … 269 273 /// parent of this node 270 274 BvhInterior *mParent; 275 int mTimeStamp; 271 276 }; 272 277 -
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1760 r1763 741 741 if (!success) // split was not taken 742 742 { 743 cout << "x"; 743 744 return false; 744 745 } … … 1731 1732 int Type() const { return BVH_NODE; } 1732 1733 1733 float GetMergeCost() const { return (float)-mNode-> mTimeStamp; };1734 float GetMergeCost() const { return (float)-mNode->GetTimeStamp(); }; 1734 1735 1735 1736 bool IsLeaf() const { return mNode->IsLeaf(); } … … 1856 1857 ++ pvsEntries; 1857 1858 rc += mBvHierarchy->EvalAbsCost(objects); 1858 //cout << " pvs: " << mBvHierarchy->EvalAbsCost(leaf->mObjects);1859 1859 } 1860 1860 } … … 1910 1910 // collect best set of view cells for this #splits 1911 1911 CollectBestSet(maxSplits, maxMemoryCost, viewCells, bvhNodes); 1912 //cout << "here5 " << bvhNodes.size() << endl;1913 1912 vector<BvhNode *>::const_iterator bit, bit_end = bvhNodes.end(); 1914 1913 … … 2111 2110 2112 2111 firstVsp->SetPriority((float)-oldVspRoot->mTimeStamp); 2113 firstBvh->SetPriority((float)-oldBvhRoot-> mTimeStamp);2112 firstBvh->SetPriority((float)-oldBvhRoot->GetTimeStamp()); 2114 2113 2115 2114 tQueue.Push(firstVsp); … … 2214 2213 mOldViewCells.clear(); 2215 2214 2215 // reset active nodes 2216 vector<BvhLeaf *> bvhLeaves; 2217 2218 mBvHierarchy->CollectLeaves(mBvHierarchy->GetRoot(), bvhLeaves); 2219 2220 vector<BvhLeaf *>::const_iterator bit, bit_end = bvhLeaves.end(); 2221 2222 for (bit = bvhLeaves.begin(); bit != bit_end; ++ bit) 2223 { 2224 (*bit)->SetActiveNode(*bit); 2225 } 2226 2216 2227 cout << endl; 2217 2228 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h
r1743 r1763 113 113 virtual int GetRandomSurfacePoint(Vector3 &point, Vector3 &normal) = 0; 114 114 115 virtual int GetRandomEdgePoint(Vector3 &point, 116 Vector3 &normal) = 0; 117 115 118 virtual int GetRandomVisibleSurfacePoint(Vector3 &point, 116 119 Vector3 &normal, -
GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.cpp
r1758 r1763 92 92 93 93 94 int TriangleIntersectable::GetRandomEdgePoint(Vector3 &point, 95 Vector3 &normal) 96 { 97 int edge = Random(3); 98 99 Vector3 a = mItem.mVertices[edge]; 100 Vector3 b = mItem.mVertices[(edge + 1) % 3]; 101 102 const float factor = RandomValue(0.0f, 1.0f); 103 104 point = a * factor + b * factor; 105 normal = mItem.GetNormal(); 106 107 return edge; 108 } 109 110 94 111 KdIntersectable::KdIntersectable(KdNode *item, const AxisAlignedBox3 &box) : 95 112 IntersectableWrapper<KdNode *>(item) -
GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.h
r1758 r1763 62 62 ostream &Describe(ostream &s); 63 63 64 64 int GetRandomEdgePoint(Vector3 &point, Vector3 &normal); 65 65 protected: 66 66 … … 111 111 } 112 112 113 113 114 template<typename T> 114 115 float IntersectableWrapper<T>::IntersectionComplexity() … … 117 118 } 118 119 120 119 121 template<typename T> 120 122 int IntersectableWrapper<T>::NumberOfFaces() const … … 122 124 return 0; 123 125 } 126 124 127 125 128 template<typename T> … … 129 132 return 0; 130 133 } 134 135 136 template<typename T> 137 int IntersectableWrapper<T>::GetRandomEdgePoint(Vector3 &point, 138 Vector3 &normal) 139 { 140 return 0; 141 } 142 131 143 132 144 template<typename T> … … 193 205 const Vector3 &viewpoint, 194 206 const int maxTries); 207 208 int GetRandomEdgePoint(Vector3 &point, Vector3 &normal); 209 195 210 }; 196 211 -
GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp
r1587 r1763 795 795 796 796 797 int MeshInstance::GetRandomEdgePoint(Vector3 &point, Vector3 &normal) 798 { 799 // TODO 800 return mMesh->GetRandomSurfacePoint(point, normal); 801 } 802 797 803 798 804 /*************************************************************/ -
GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.h
r1419 r1763 245 245 246 246 public: 247 MeshInstance(Mesh *mesh):Intersectable(), mMesh(mesh), mMaterial(NULL) 248 { 249 } 250 251 int GetRandomSurfacePoint(Vector3 &point, Vector3 &normal); 252 253 int 254 GetRandomVisibleSurfacePoint(Vector3 &point, 255 Vector3 &normal, 256 const Vector3 &viewpoint, 257 const int maxTries 258 ); 259 260 261 Mesh *GetMesh() { return mMesh; } 262 263 virtual AxisAlignedBox3 GetBox() const { 264 return mMesh->mBox; 265 } 266 267 virtual int CastRay(Ray &ray); 268 269 virtual bool IsConvex() const { return mMesh->mIsConvex; } 270 virtual bool IsWatertight() const { return mMesh->mIsWatertight; } 271 virtual float IntersectionComplexity() { return (float)mMesh->mFaces.size(); } 272 273 virtual int NumberOfFaces() const { return (int)mMesh->mFaces.size(); } 274 275 virtual int Type() const { return MESH_INSTANCE; } 276 277 virtual int 278 CastRay( 279 Ray &ray, 280 const vector<int> &faces 281 ); 247 MeshInstance(Mesh *mesh):Intersectable(), mMesh(mesh), mMaterial(NULL) 248 { 249 } 250 251 int GetRandomSurfacePoint(Vector3 &point, Vector3 &normal); 252 253 int GetRandomVisibleSurfacePoint(Vector3 &point, 254 Vector3 &normal, 255 const Vector3 &viewpoint, 256 const int maxTries 257 ); 258 259 260 virtual int GetRandomEdgePoint(Vector3 &point, 261 Vector3 &normal); 262 263 Mesh *GetMesh() { return mMesh; } 264 265 virtual AxisAlignedBox3 GetBox() const { 266 return mMesh->mBox; 267 } 268 269 virtual int CastRay(Ray &ray); 270 271 virtual bool IsConvex() const { return mMesh->mIsConvex; } 272 virtual bool IsWatertight() const { return mMesh->mIsWatertight; } 273 virtual float IntersectionComplexity() { return (float)mMesh->mFaces.size(); } 274 275 virtual int NumberOfFaces() const { return (int)mMesh->mFaces.size(); } 276 277 virtual int Type() const { return MESH_INSTANCE; } 278 279 virtual int 280 CastRay( 281 Ray &ray, 282 const vector<int> &faces 283 ); 282 284 283 285 … … 286 288 return mMesh->Describe(s); 287 289 } 288 290 289 291 /** Sets the material. this overrides the material from 290 292 the mesh itself. 291 293 */ 292 294 void SetMaterial(Material *mat); 293 295 294 296 /** Returns the material of this mesh instance. 295 297 if not defined, returns the material of the mesh itself. 296 298 */ 297 299 Material *GetMaterial() const; -
GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.cpp
r1758 r1763 143 143 Intersectable::NewMail(); 144 144 KdLeaf::NewMail(); 145 Bvh Leaf::NewMail();145 BvhNode::NewMail(); 146 146 147 147 ObjectPvsEntries::const_iterator it, it_end = mEntries.end(); -
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp
r1695 r1763 183 183 } 184 184 185 186 bool ViewCellBorderBasedDistribution::GenerateSample(SimpleRay &ray) const 187 { 188 Vector3 origin, direction; 189 190 ViewCellContainer &viewCells = mPreprocessor.mViewCellsManager->GetViewCells(); 191 192 Vector3 point; 193 Vector3 normal, normal2; 194 195 //cout << "y"; 196 const int vcIdx = (int)RandomValue(0, (float)viewCells.size() - 0.5f); 197 const int objIdx = (int)RandomValue(0, (float)mPreprocessor.mObjects.size() - 0.5f); 198 199 Intersectable *object = mPreprocessor.mObjects[objIdx]; 200 ViewCell *viewCell = viewCells[vcIdx]; 201 202 object->GetRandomSurfacePoint(point, normal); 203 viewCell->GetRandomEdgePoint(origin, normal2); 204 205 direction = point - origin; 206 207 // $$ jb the pdf is yet not correct for all sampling methods! 208 const float c = Magnitude(direction); 209 210 if (c <= Limits::Small) 211 return false; 212 213 // $$ jb the pdf is yet not correct for all sampling methods! 214 const float pdf = 1.0f; 215 //cout << "p: " << point << " "; 216 direction *= 1.0f / c; 217 ray = SimpleRay(origin, direction, pdf); 218 219 return true; 220 } 221 185 222 #if 0 186 223 bool ObjectsInteriorDistribution::GenerateSample(SimpleRay &ray) const -
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.h
r1695 r1763 109 109 110 110 111 class ViewCellBorderBasedDistribution: public SamplingStrategy 112 { 113 public: 114 ViewCellBorderBasedDistribution(const Preprocessor &preprocessor): 115 SamplingStrategy(preprocessor) {} 116 117 virtual bool GenerateSample(SimpleRay &ray) const; 118 }; 119 120 111 121 /** This strategy generates samples inside of the objects, e.g., 112 122 for sampling the inside of a colon. -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r1758 r1763 1785 1785 ViewCellContainer::const_iterator it, it_end = leaves.end(); 1786 1786 1787 Intersectable::NewMail();1788 1787 ObjectPvs newPvs; 1789 1788 … … 1791 1790 for (it = leaves.begin(); it != it_end; ++ it) 1792 1791 { 1793 ObjectPvsIterator oit = (*it)->GetPvs().GetIterator(); 1794 1795 while (oit.HasMoreEntries()) 1796 { 1797 ObjectPvsEntry entry = oit.Next(); 1798 Intersectable *intersect = entry.mObject; 1799 1800 if (!intersect->Mailed()) 1801 { 1802 intersect->Mail(); 1803 newPvs.AddSample(intersect, entry.mData.mSumPdf); 1804 } 1805 } 1792 newPvs.MergeInPlace((*it)->GetPvs()); 1806 1793 } 1807 1794 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1761 r1763 1579 1579 mViewCellsTree->UpdateViewCellsStats(*it, mCurrentViewCellsStats); 1580 1580 } 1581 cout << "here44 " << mCurrentViewCellsStats.maxPvs << endl;1582 1581 } 1583 1582 … … 2214 2213 { 2215 2214 ViewCellContainer::const_iterator it, it_end = mViewCells.end(); 2216 cout << "here2" << endl; 2215 2217 2216 for (it = mViewCells.begin(); it != it_end; ++ it) 2218 { cout << "here4 " << mOnlyValidViewCells << " " << (*it)->GetValid() << endl;2217 { 2219 2218 if (!mOnlyValidViewCells || (*it)->GetValid()) 2220 { cout << "here5 " << mColorCode << endl;2219 { 2221 2220 ExportColor(exporter, *it, colorCode); 2222 2221 ExportViewCellGeometry(exporter, *it, sceneBox, clipPlane); … … 2789 2788 2790 2789 case 1: // pvs 2791 { //cout << "here22 " << mCurrentViewCellsStats.maxPvs << endl;2790 { 2792 2791 if (mCurrentViewCellsStats.maxPvs) 2793 2792 { 2794 //cout << "pvscost : " << (float)mViewCellsTree->GetPvsCost(vc) << endl; 2795 //cout << "maxPvs : " << (float)mCurrentViewCellsStats.maxPvs << endl; 2796 2797 importance = 2798 (float)mViewCellsTree->GetPvsCost(vc) / 2799 (float)mCurrentViewCellsStats.maxPvs; 2793 importance = (float)mViewCellsTree->GetPvsCost(vc) / 2794 (float)mCurrentViewCellsStats.maxPvs; 2800 2795 } 2801 2796 } … … 2817 2812 #endif 2818 2813 default: 2819 cout << "here10" << endl;2820 2814 break; 2821 2815 } … … 3057 3051 const int savedColorCode = mColorCode; 3058 3052 3053 Exporter *exporter; 3054 3055 #if 0 3059 3056 // export merged view cells 3060 3057 mColorCode = 0; // use random colors 3061 3058 3062 Exporter *exporter = Exporter::GetExporter("merged_view_cells.wrl");3059 exporter = Exporter::GetExporter("merged_view_cells.wrl"); 3063 3060 3064 3061 cout << "exporting view cells after merge ... "; … … 3077 3074 } 3078 3075 cout << "finished" << endl; 3076 #endif 3079 3077 3080 3078 // export merged view cells using pvs color coding 3081 3082 3079 exporter = Exporter::GetExporter("merged_view_cells_pvs.wrl"); 3083 3080 cout << "exporting view cells after merge (pvs size) ... "; … … 3092 3089 exporter->SetFilled(); 3093 3090 mColorCode = 1; 3094 cout << "here49 " << mColorCode << endl; 3091 3095 3092 ExportViewCellsForViz(exporter, NULL, mColorCode, GetClipPlane()); 3096 3093 … … 3183 3180 3184 3181 // visualization of the view cells 3185 if ( 0) ExportMergedViewCells(objects);3182 if (1) ExportMergedViewCells(objects); 3186 3183 3187 3184 // compute final meshes and volume / area … … 5504 5501 Exporter *exporter = Exporter::GetExporter("final_view_cells.wrl"); 5505 5502 5503 Vector3 scale(1.0f, 0.9f, 1.0f); 5506 5504 if (exporter) 5507 5505 { 5506 EvaluateViewCellsStats(); 5507 5508 5508 // hack color code (show pvs size) 5509 5509 const int savedColorCode = mColorCode; 5510 mColorCode = 0;5510 mColorCode = 1; // export pvs 5511 5511 5512 5512 const long starttime = GetTime(); … … 5515 5515 // matt: hack for clamping scene 5516 5516 AxisAlignedBox3 bbox = mViewSpaceBox; 5517 bbox.Scale( Vector3(0.5, 1, 0.5));5517 bbox.Scale(scale); 5518 5518 5519 5519 if (CLAMP_TO_BOX) … … 5536 5536 mHierarchyManager->ExportObjectSpaceHierarchy(exporter, objects, 5537 5537 CLAMP_TO_BOX ? &bbox : NULL, false); 5538 ExportViewCellsForViz(exporter, CLAMP_TO_BOX ? &bbox : NULL, mColorCode, GetClipPlane()); 5538 5539 //ExportViewCellsForViz(exporter, CLAMP_TO_BOX ? &bbox : NULL, mColorCode, GetClipPlane()); 5540 ExportViewCellsForViz(exporter, NULL, mColorCode, GetClipPlane()); 5539 5541 5540 5542 delete exporter; … … 5553 5555 // matt: hack for making visualization smaller in size 5554 5556 AxisAlignedBox3 bbox = mHierarchyManager->GetObjectSpaceBox(); 5555 bbox.Scale( Vector3(0.5, 1, 0.5));5557 bbox.Scale(scale); 5556 5558 5557 5559 cout << "exporting object space hierarchy ... "; … … 5562 5564 } 5563 5565 5564 cout << "here92 " << mHierarchyManager->GetVspTree()->GetStatistics().maxPvs << endl;5565 5566 5566 // visualization of the view cells 5567 if ( 1)5567 if (0) 5568 5568 { 5569 EvaluateViewCellsStats();5570 5569 ExportMergedViewCells(objects); 5571 5570 } -
GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp
r1760 r1763 505 505 Debug << "vsp mem const: " << mMemoryConst << endl; 506 506 507 cout << "use cost heuristics: " << mUseCostHeuristics << endl; 508 507 509 Debug << endl; 508 510 }
Note: See TracChangeset
for help on using the changeset viewer.