00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _SO_LDM_TILE_VISITOR_
00025 #define _SO_LDM_TILE_VISITOR_
00026
00027 #include <LDM/SoLDMLargeDataManagement.h>
00028
00029 #include <LDM/SoLDMTileID.h>
00030 #include <Inventor/STL/vector>
00031 #include <Inventor/SbBox.h>
00032 #include <Inventor/SbViewVolume.h>
00033 #include <SoDeprecationRules.h>
00034
00035 #ifdef _MSC_VER
00036 #pragma warning( push )
00037 #pragma warning(disable:4251)
00038 #endif
00039
00040 class SoSeparator;
00041 class SoState;
00042 class SoLDMGeomElement;
00076 SoEXTENDER_Documented class SoDEPRECATED SoLDMTileVisitor : public SoLDMLargeDataManagement {
00077 public:
00078
00082 SoLDMTileVisitor();
00083
00087 ~SoLDMTileVisitor();
00088
00095 struct NodeStatus
00096 {
00100 bool m_visible;
00104 bool m_inROI;
00108 bool m_inSubVolume;
00109 };
00116 virtual float getTileWeight( SoLDMTileID tileID, NodeStatus& status);
00117
00124 bool isCulled(const SbBox3f& tileBox, float& distToScreenCenter, int cullbits = 7);
00125
00135 virtual float getCullWeight(float distToScreen);
00136
00144 virtual float getScreenResCullWeight(float voxelsize);
00145
00159 virtual float getSurfaceGeomWeight(float distToGeom, float geometryPriority);
00160
00174 virtual float getVolumeGeomWeight(float distToGeom, float geometryPriority);
00175
00187 virtual float getROIWeight(int distToROI, float geometryPriority);
00188
00194 virtual float combineParentWeight(float parentWeight, float weight);
00195
00196
00197
00201 virtual void reset();
00202
00208 const SbMatrix* getMVPMatrixPtr()
00209 {
00210 const MatrixVec& matVec = m_ModelViewProjMatMap.begin()->second;
00211 return &matVec[0];
00212 }
00213
00217 void valuationChangeNotify();
00218
00219
00220 private:
00221
00222 static void initClass();
00223
00231 bool isTransparent(SoLDMGeomElement* g, SoLDMTileID tileID);
00232
00233 std::vector<SoLDMTileID> m_tileIDs;
00234 std::vector<SoLDMTileID>& getLastValuated(){return m_tileIDs;};
00235
00237 void clearRegisteredViewVolumes();
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249 SbBool getTileWeight( SoLDMTileID tileID,
00250 float parentWeight,
00251 float& weight,
00252 int subsampleLevel,
00253 NodeStatus& status,
00254 SbBool scheduleLoad=TRUE);
00255
00256 SbVec3f getGeomCenter(const SoLDMTileID& tileID);
00257 SbBox3f getGeomPos(const SoLDMTileID& tileID);
00258
00259
00260 void setMVPMatrixPtr(SoState* state, const SbMatrix* MVP, const SbMatrix* Model);
00261
00262
00263 void setScreenPixelSizeAndView(SoState* state);
00264
00265
00266
00267 void resetCullBits();
00268
00272 void init();
00273
00277 void clearContextCache(SoState* state);
00278
00279 private:
00280 typedef std::vector<SbMatrix> MatrixVec;
00281 typedef std::map<int, MatrixVec> CtxMatrixVecMap;
00282 typedef std::map<int, SbMatrix> CtxMatrixMap;
00283 typedef std::map<int, SbViewVolume> CtxViewVolMap;
00284
00285 float getScreenDistance(SbVec3f& A) const;
00286 SbVec3f getProjectedPoint(const SbMatrix& mvp, const SbVec3f& point) const;
00287 CtxMatrixVecMap m_ModelViewProjMatMap;
00288 SbMatrix m_ModelMat;
00289
00290 float getViewPointWeight(const SbBox3f&) const;
00291
00292 int m_screenWidthPixel;
00293 int m_screenHeightPixel;
00294 CtxViewVolMap m_viewVolumeMap;
00295
00296 inline int getDistanceMax() const
00297 {return m_distanceMax;}
00298
00299 private :
00300
00302 template<typename MapCont> void removeUnusuedContext(MapCont& m);
00303
00305 void clearMatrixList(int ctx);
00306
00308 float getVoxelPixelSize(const MatrixVec& matVec,
00309 const SbViewVolume& viewVol,
00310 const SbBox3f& geomBox,
00311 unsigned int numVoxels, float lmax) const;
00312
00314 bool isCulled(const MatrixVec& matVec, const SbBox3f& tileBox,
00315 float& distToScreenCenter);
00319 float getViewPointWeight(const SbBox3f& box, const SbViewVolume& viewVol) const;
00320
00321
00323 void initPerTileInfoInternal(const SoLDMTileID& tileID);
00324
00329 float getTileWeightInternal( SoLDMTileID tileID, SoLDMTileVisitor::NodeStatus& status);
00330
00331
00332
00333
00334
00335 SbBool getTileWeightInternal( SoLDMTileID tileID,
00336 float parentWeight,
00337 float& weight,
00338 int subsampleLevel,
00339 NodeStatus& status,
00340 SbBool scheduleLoad=TRUE);
00341
00346 inline SbBox3f getGeomPosInternal(const SoLDMTileID& tileID)
00347 { return m_mapTileInit[tileID].second; }
00348
00350 void initFactor();
00351
00353 float getViewPointWeightOiv8(const SbBox3f& box, const SbViewVolume& viewVol) const;
00354
00356 float getViewPointWeightOiv6(const SbBox3f& box, const SbViewVolume& viewVol) const;
00357
00358
00359 int m_cullBits;
00360 SbVec3i32 m_eye;
00361
00365 float getVoxelPixelSize(const SbBox3f& geomBox);
00366
00370 float getVoxelPixelSize(const SbBox3f& screenBbox, unsigned int numVoxels) const;
00371
00375 SbPList m_geomList;
00376 size_t m_numGeoms;
00377
00378
00379
00380
00381
00382
00383
00384
00388 bool m_handleTransparentTiles;
00389
00394 std::vector<float> m_minIntersecintWeights;
00395
00396
00397 int m_distanceMax;
00398
00399 SbBox3f m_volExtent;
00400 SbVec3i32 m_volDim;
00401 float m_xFactor,m_yFactor,m_zFactor;
00402
00403 SbBox3f m_rootBboxXyz;
00404 SbBox3f m_rootBboxXyzModelSpace;
00405
00406
00407
00408
00409
00410
00414 CtxMatrixMap m_affineProjMatMap;
00415
00419 void getViewVolMatrix(const CtxViewVolMap::value_type v);
00420
00422 static SbBool s_useOiv6Weight;
00423
00424 static const float s_epsilon;
00425
00430 typedef std::pair<SbBox3i32, SbBox3f> pairBox;
00431 std::map<SoLDMTileID, pairBox> m_mapTileInit;
00432
00433 };
00434
00435
00436 #ifdef _MSC_VER
00437 #pragma warning( pop )
00438 #endif
00439
00440 #endif // _SO_LDM_TILE_VISITOR_
00441
00442
00443