00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef LDM_RESOURCE_PARAMETER_H
00026 #define LDM_RESOURCE_PARAMETER_H
00027
00028 #ifdef _MSC_VER
00029 #pragma warning( push )
00030 #pragma warning(disable:4251)
00031 #endif
00032
00033 #include <Inventor/fields/SoFieldContainer.h>
00034 #include <Inventor/fields/SoSubFieldContainer.h>
00035
00036 #include <Inventor/fields/SoSFString.h>
00037 #include <Inventor/fields/SoSFUShort.h>
00038 #include <Inventor/fields/SoSFInt32.h>
00039 #include <Inventor/fields/SoSFFloat.h>
00040 #include <Inventor/fields/SoSFBool.h>
00041 #include <Inventor/fields/SoSFEnum.h>
00042 #include <Inventor/fields/SoSFString.h>
00043 #include <Inventor/fields/SoSFVec3i32.h>
00044
00045 #include <Inventor/SbBox.h>
00046
00047 #include <Inventor/STL/vector>
00048 #include <Inventor/STL/cassert>
00049
00050 class SoDataSet;
00051 class SoLDMMediator;
00052 class SoLDMTileVisitor;
00053 class SoLDMResourceManager;
00054
00073 class SoLDMResourceParameters : public SoFieldContainer
00074 {
00075 SO_FIELDCONTAINER_HEADER(SoLDMResourceParameters);
00076
00077 public:
00081 struct FixedResolutionReport{
00085 enum ReportCode
00086 {
00097 PROGRESS,
00122 ABORT
00123 };
00127 ReportCode what;
00135 int numTilesToAdd;
00140 int numTilesToLoad;
00145 int numTilesLoaded;
00146 };
00147
00153 typedef void FixedResolutionCB(FixedResolutionReport&, void*);
00154
00158 enum LoadPolicy {
00162 NO_USER_INTERACTION,
00164 ALWAYS,
00166 NEVER
00167 };
00168
00179 enum TileCachePolicy {
00196 NONE,
00197
00213 LOWRES_ONLY,
00214
00231 ALL
00232 };
00233
00234
00238 SoLDMResourceParameters();
00239
00243 virtual ~SoLDMResourceParameters();
00244
00259 SoSFInt32 maxMainMemory;
00260
00275 SoSFInt32 maxTexMemory;
00276
00287 SoSFEnum loadPolicy;
00288
00299 SoSFEnum tileCachePolicy;
00300
00325 SoSFInt32 tex3LoadRate;
00326
00349 SoSFInt32 max2DTexMemory;
00350
00373 SoSFInt32 tex2LoadRate;
00374
00390 SoSFInt32 minResolutionThreshold;
00391
00399 SoSFInt32 maxResolutionThreshold;
00400
00451 SoSFVec3i32 tileDimension;
00452
00464 SoSFVec3i32 subTileDimension;
00465
00483 SoSFInt32 loadNotificationRate;
00484
00494 SoSFFloat tileHalfLife;
00495
00506 SoSFBool fixedResolution;
00507
00517 SoSFInt32 resolution;
00518
00524 SoSFInt32 numPrefetchThread;
00525
00554 SoSFBool tileBorders;
00555
00577 SoSFInt32 minTilesToLoad;
00578
00584 enum ViewpointRefinementPolicy
00585 {
00587 VIEWPOINT_REFINEMENT_OFF,
00588
00595 VIEWPOINT_REFINEMENT_ON,
00596
00601 VIEWPOINT_REFINEMENT_INHERITED_FROM_GLOBAL,
00602 };
00603
00612 SoSFEnum viewpointRefinementPolicy;
00613
00619 enum ScreenResolutionCullingPolicy
00620 {
00622 SCREEN_RESOLUTION_CULLING_OFF,
00623
00633 SCREEN_RESOLUTION_CULLING_ON,
00634
00639 SCREEN_RESOLUTION_CULLING_INHERITED_FROM_GLOBAL,
00640 };
00641
00650 SoSFEnum screenResolutionCullingPolicy;
00651
00661 void setMovingTimeOut(float timeout);
00662
00669 float getMovingTimeOut();
00670
00674 int getDataSize();
00675
00680 void enableFixedResolutionMode(int resolution, FixedResolutionCB* func);
00681
00695 void setGeometryPriority(SoType geometryType, float priority);
00696
00701 SbBool getGeometryPriority(SoType geometryType, float& priority);
00702
00703 private:
00704 typedef struct GeomPriority
00705 {
00706 float m_weight;
00707 SoType m_geomId;
00708 } GeomPriority;
00709
00713 void setDataSet(SoDataSet *ds);
00714
00718 void copyParameters(SoLDMMediator *mediator);
00719
00723 void fprintfResourceManager(FILE *f);
00724
00725
00726
00727
00728 void invalidateData();
00729
00730
00731
00732
00733
00734
00735
00736 void setNumTiles(int numTiles);
00737
00741 int getNumTiles();
00742
00747 SbBox3i32 XYZToVoxel(const SbBox3f &dataBox);
00748
00749
00753 bool isReportDisabled();
00754 void setReportDisabled(bool flag);
00755 FixedResolutionCB* getFixedResCB();
00756 int getNumTilesLoaded();
00757 bool toReport();
00758 void setToReport(bool flag);
00759 void increaseNumTilesLoaded();
00760 void decreaseNumTilesLoaded();
00761 void resetNumTilesLoaded();
00762 void resetFixedResVar();
00763
00764 void sendToLdm(SoDataSet* ds);
00765
00766 void enableParamsNotify(SbBool state);
00767
00768 virtual void notify(SoNotList*);
00769
00770 inline void setResourceManager(SoLDMResourceManager* resourceManager);
00771
00777 inline void forceFixedResolution(bool flag);
00778
00783 inline bool isFixedResolutionForced() const;
00784
00790 enum Resolution {
00795 BEST = -1,
00799 FULL = 0
00800 };
00801
00802 private:
00803
00804 #if 1 SoDEPRECATED
00811 SoSFInt32 overlapping;
00812
00813 #endif
00815 #if 1 SoDEPRECATED
00827 SoSFInt32 maxTilesInMainMem;
00828 SoDEPRECATED
00839 SoSFInt32 maxTilesInTexMem;
00840 SoDEPRECATED
00854 SoSFBool fixedParams;
00855
00856 #endif
00858 #if 1 SoDEPRECATED
00879 SoSFInt32 max2DTextures;
00880
00881
00882 friend class SoLDMResourceManager;
00883 #endif
00885 // Deprecated in 9700 and removed (hidden) in 10000.
00886
00887
00888 SoSFInt32 maxNumTriangles;
00889
00890 bool m_forceFixedResolution;
00891
00895 SoLDMResourceParameters& operator=(const SoLDMResourceParameters& ldmrp);
00896 SoLDMResourceParameters(const SoLDMResourceParameters& );
00897
00898
00899 void updateTileHalfLife(float timeInSec);
00900 void updateTileSize();
00901 void updateMaxResolutionThreshold( int threshold );
00902 void updateMinResolutionThreshold( int threshold );
00903 void updateLoadPolicy( LoadPolicy loadPolicy );
00904 void updateEnableFixedResolutionMode(int resolution, FixedResolutionCB* func);
00905 void updateDisableFixedResolutionMode();
00906
00907 SoDataSet* m_ds;
00908 SoLDMResourceManager* m_resourceMgr;
00909
00910 FixedResolutionCB* m_fixedResCB;
00911 int m_numTilesLoaded;
00912 int m_numTilesNeeded;
00913 bool m_toReport;
00914 bool m_reportDisable;
00915 bool m_isFixedRes;
00916 bool m_bLdmParamDebug;
00917
00919 int m_previousMinThreshold;
00920
00921
00922 LoadPolicy m_policyUsed;
00923 int m_resolution;
00924 SoLDMTileVisitor* m_fixedResVisitor;
00925 SoLDMTileVisitor* m_beforeFixedResVisitor;
00926 bool m_beforeFixedResVisitorFlag;
00927
00928 float m_movingTimeOut;
00929
00930 std::vector<GeomPriority> m_geomPriority;
00931 int getGeometryIndex(SoType geometryType);
00932
00933 static bool s_artForceFixed;
00934 };
00935
00936
00937 inline bool
00938 SoLDMResourceParameters::isReportDisabled()
00939 {
00940 return m_reportDisable;
00941 }
00942
00943
00944 inline void
00945 SoLDMResourceParameters::setReportDisabled(bool flag)
00946 {
00947 m_reportDisable = flag;
00948 }
00949
00950
00951 inline SoLDMResourceParameters::FixedResolutionCB*
00952 SoLDMResourceParameters::getFixedResCB()
00953 {
00954 return m_fixedResCB;
00955 }
00956
00957
00958 inline int
00959 SoLDMResourceParameters::getNumTilesLoaded()
00960 {
00961 return m_numTilesLoaded;
00962 }
00963
00964
00965 inline bool
00966 SoLDMResourceParameters::toReport()
00967 {
00968 return m_toReport;
00969 }
00970
00971
00972 inline void
00973 SoLDMResourceParameters::setToReport(bool flag)
00974 {
00975 m_toReport = flag;
00976 }
00977
00978
00979 inline void
00980 SoLDMResourceParameters::increaseNumTilesLoaded()
00981 {
00982 m_numTilesLoaded++;
00983 }
00984
00985
00986 inline void
00987 SoLDMResourceParameters::decreaseNumTilesLoaded()
00988 {
00989 m_numTilesLoaded--;
00990 }
00991
00992
00993 inline void
00994 SoLDMResourceParameters::resetNumTilesLoaded()
00995 {
00996 m_numTilesLoaded = 0;
00997 }
00998
00999
01000 inline void
01001 SoLDMResourceParameters::setResourceManager(SoLDMResourceManager* resourceManager)
01002 {
01003 m_resourceMgr = resourceManager;
01004 }
01005
01006
01007 inline SoLDMResourceParameters&
01008 SoLDMResourceParameters::operator=(const SoLDMResourceParameters& )
01009 {
01010 assert(0);
01011 return *this;
01012 }
01013
01014
01015 inline void
01016 SoLDMResourceParameters::forceFixedResolution(bool flag)
01017 {
01018 m_forceFixedResolution = flag;
01019 }
01020
01021
01022 inline bool
01023 SoLDMResourceParameters::isFixedResolutionForced() const
01024 {
01025 return m_forceFixedResolution || s_artForceFixed;
01026 }
01027
01028
01029 extern std::ostream& operator << (std::ostream& os, const SoLDMResourceParameters& p);
01030
01031 #ifdef _MSC_VER
01032 #pragma warning( pop )
01033 #endif
01034
01035 #endif
01036
01037
01038