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 unsigned char m_tileVisitorState;
00280
00281 private:
00282 typedef std::vector<SbMatrix> MatrixVec;
00283 typedef std::map<int, MatrixVec> CtxMatrixVecMap;
00284 typedef std::map<int, SbMatrix> CtxMatrixMap;
00285 typedef std::map<int, SbViewVolume> CtxViewVolMap;
00286
00287 float getScreenDistance(SbVec3f& A) const;
00288 SbVec3f getProjectedPoint(const SbMatrix& mvp, const SbVec3f& point) const;
00289 CtxMatrixVecMap m_ModelViewProjMatMap;
00290 SbMatrix m_ModelMat;
00291
00292 float getViewPointWeight(const SbBox3f&) const;
00293
00294 int m_screenWidthPixel;
00295 int m_screenHeightPixel;
00296 CtxViewVolMap m_viewVolumeMap;
00297
00298 inline int getDistanceMax() const
00299 {return m_distanceMax;}
00300
00301 private :
00302
00304 template<typename MapCont> void removeUnusuedContext(MapCont& m);
00305
00307 void clearMatrixList(int ctx);
00308
00310 float getVoxelPixelSize(const MatrixVec& matVec,
00311 const SbViewVolume& viewVol,
00312 const SbBox3f& geomBox,
00313 unsigned int numVoxels) const;
00317 float getVoxelPixelSize(const SbBox3f& screenBbox, unsigned int numVoxels) const;
00318
00320 bool isCulled(const MatrixVec& matVec, const SbBox3f& tileBox,
00321 float& distToScreenCenter);
00325 float getViewPointWeight(const SbBox3f& box, const SbViewVolume& viewVol) const;
00326
00327
00329 void initPerTileInfoInternal(const SoLDMTileID& tileID);
00330
00335 float getTileWeightInternal( SoLDMTileID tileID, SoLDMTileVisitor::NodeStatus& status);
00336
00337
00338
00339
00340
00341 SbBool getTileWeightInternal( SoLDMTileID tileID,
00342 float parentWeight,
00343 float& weight,
00344 int subsampleLevel,
00345 NodeStatus& status,
00346 SbBool scheduleLoad=TRUE);
00347
00352 inline SbBox3f getGeomPosInternal(const SoLDMTileID& tileID)
00353 { return m_mapTileInit[tileID].second; }
00354
00356 void initFactor();
00357
00359 float getViewPointWeightOiv8(const SbBox3f& box, const SbViewVolume& viewVol) const;
00360
00362 float getViewPointWeightOiv6(const SbBox3f& box, const SbViewVolume& viewVol) const;
00363
00364
00365 int m_cullBits;
00366 SbVec3i32 m_eye;
00367
00371 SbPList m_geomList;
00372 size_t m_numGeoms;
00373
00374
00375
00376
00377
00378
00379
00380
00384 bool m_handleTransparentTiles;
00385
00390 std::vector<float> m_minIntersecintWeights;
00391
00392
00393 int m_distanceMax;
00394
00395 SbBox3f m_volExtent;
00396 SbVec3i32 m_volDim;
00397 float m_xFactor,m_yFactor,m_zFactor;
00398
00399 SbBox3f m_rootBboxXyz;
00400 SbBox3f m_rootBboxXyzModelSpace;
00401
00402
00403
00404
00405
00406
00410 CtxMatrixMap m_affineProjMatMap;
00411
00415 void getViewVolMatrix(const CtxViewVolMap::value_type v);
00416
00418 static SbBool s_useOiv6Weight;
00419
00420 static const float s_epsilon;
00421
00426 typedef std::pair<SbBox3i32, SbBox3f> pairBox;
00427 std::map<SoLDMTileID, pairBox> m_mapTileInit;
00428
00429 };
00430
00431
00432 #ifdef _MSC_VER
00433 #pragma warning( pop )
00434 #endif
00435
00436 #endif // _SO_LDM_TILE_VISITOR_
00437
00438
00439