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 #include <LDM/SoLDMResourceManager.h>
00050
00051 class SoDataSet;
00052 class SoLDMMediator;
00053 class SoLDMTileVisitor;
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
00535 void setMovingTimeOut(float timeout);
00536
00543 float getMovingTimeOut();
00544
00548 int getDataSize();
00549
00554 void enableFixedResolutionMode(int resolution, FixedResolutionCB* func);
00555
00569 void setGeometryPriority(SoType geometryType, float priority);
00570
00575 SbBool getGeometryPriority(SoType geometryType, float& priority);
00576
00577 private:
00578 typedef struct GeomPriority
00579 {
00580 float m_weight;
00581 SoType m_geomId;
00582 } GeomPriority;
00583
00587 void setDataSet(SoDataSet *ds);
00588
00592 void copyParameters(SoLDMMediator *mediator);
00593
00597 void fprintfResourceManager(FILE *f);
00598
00599
00600
00601
00602 void invalidateData();
00603
00604
00605
00606
00607
00608
00609
00610 void setNumTiles(int numTiles);
00611
00615 int getNumTiles();
00616
00621 SbBox3i32 XYZToVoxel(const SbBox3f &dataBox);
00622
00623
00627 bool isReportDisabled();
00628 void setReportDisabled(bool flag);
00629 FixedResolutionCB* getFixedResCB();
00630 int getNumTilesLoaded();
00631 bool toReport();
00632 void setToReport(bool flag);
00633 void increaseNumTilesLoaded();
00634 void decreaseNumTilesLoaded();
00635 void resetNumTilesLoaded();
00636 void resetFixedResVar();
00637
00638 void sendToLdm(SoDataSet* ds);
00639
00640 void enableParamsNotify(SbBool state);
00641
00642 virtual void notify(SoNotList*);
00643
00644 inline void setResourceManager(SoLDMResourceManager* resourceManager);
00645
00651 inline void forceFixedResolution(bool flag);
00652
00657 inline bool isFixedResolutionForced() const;
00658
00664 enum Resolution {
00669 BEST = -1,
00673 FULL = 0
00674 };
00675
00676 private:
00677
00678 #if 1 SoDEPRECATED
00685 SoSFInt32 overlapping;
00686
00687 #endif
00689 #if 1 SoDEPRECATED
00701 SoSFInt32 maxTilesInMainMem;
00702 SoDEPRECATED
00713 SoSFInt32 maxTilesInTexMem;
00714 SoDEPRECATED
00728 SoSFBool fixedParams;
00729
00730 #endif
00732 #if 1 SoDEPRECATED
00753 SoSFInt32 max2DTextures;
00754
00755
00756 friend class SoLDMResourceManager;
00757 #endif
00759 // Deprecated in 9700 and removed (hidden) in 10000.
00760
00761
00762 SoSFInt32 maxNumTriangles;
00763
00764 bool m_forceFixedResolution;
00765
00769 SoLDMResourceParameters& operator=(const SoLDMResourceParameters& ldmrp);
00770 SoLDMResourceParameters(const SoLDMResourceParameters& );
00771
00772
00773 void updateTileHalfLife(float timeInSec);
00774 void updateTileSize();
00775 void updateMaxResolutionThreshold( int threshold );
00776 void updateMinResolutionThreshold( int threshold );
00777 void updateLoadPolicy( SoLDMResourceManager::LoadPolicy loadPolicy );
00778 void updateEnableFixedResolutionMode(int resolution, FixedResolutionCB* func);
00779 void updateDisableFixedResolutionMode();
00780
00781 SoDataSet* m_ds;
00782 SoLDMResourceManager* m_resourceMgr;
00783
00784 FixedResolutionCB* m_fixedResCB;
00785 int m_numTilesLoaded;
00786 int m_numTilesNeeded;
00787 bool m_toReport;
00788 bool m_reportDisable;
00789 bool m_isFixedRes;
00790 bool m_bLdmParamDebug;
00791
00793 int m_previousMinThreshold;
00794
00795
00796 LoadPolicy m_policyUsed;
00797 int m_resolution;
00798 SoLDMTileVisitor* m_fixedResVisitor;
00799 SoLDMTileVisitor* m_beforeFixedResVisitor;
00800 bool m_beforeFixedResVisitorFlag;
00801
00802 float m_movingTimeOut;
00803
00804 std::vector<GeomPriority> m_geomPriority;
00805 int getGeometryIndex(SoType geometryType);
00806
00807 static bool s_artForceFixed;
00808 };
00809
00810
00811 inline bool
00812 SoLDMResourceParameters::isReportDisabled()
00813 {
00814 return m_reportDisable;
00815 }
00816
00817
00818 inline void
00819 SoLDMResourceParameters::setReportDisabled(bool flag)
00820 {
00821 m_reportDisable = flag;
00822 }
00823
00824
00825 inline SoLDMResourceParameters::FixedResolutionCB*
00826 SoLDMResourceParameters::getFixedResCB()
00827 {
00828 return m_fixedResCB;
00829 }
00830
00831
00832 inline int
00833 SoLDMResourceParameters::getNumTilesLoaded()
00834 {
00835 return m_numTilesLoaded;
00836 }
00837
00838
00839 inline bool
00840 SoLDMResourceParameters::toReport()
00841 {
00842 return m_toReport;
00843 }
00844
00845
00846 inline void
00847 SoLDMResourceParameters::setToReport(bool flag)
00848 {
00849 m_toReport = flag;
00850 }
00851
00852
00853 inline void
00854 SoLDMResourceParameters::increaseNumTilesLoaded()
00855 {
00856 m_numTilesLoaded++;
00857 }
00858
00859
00860 inline void
00861 SoLDMResourceParameters::decreaseNumTilesLoaded()
00862 {
00863 m_numTilesLoaded--;
00864 }
00865
00866
00867 inline void
00868 SoLDMResourceParameters::resetNumTilesLoaded()
00869 {
00870 m_numTilesLoaded = 0;
00871 }
00872
00873
00874 inline void
00875 SoLDMResourceParameters::setResourceManager(SoLDMResourceManager* resourceManager)
00876 {
00877 m_resourceMgr = resourceManager;
00878 }
00879
00880
00881 inline SoLDMResourceParameters&
00882 SoLDMResourceParameters::operator=(const SoLDMResourceParameters& )
00883 {
00884 assert(0);
00885 return *this;
00886 }
00887
00888
00889 inline void
00890 SoLDMResourceParameters::forceFixedResolution(bool flag)
00891 {
00892 m_forceFixedResolution = flag;
00893 }
00894
00895
00896 inline bool
00897 SoLDMResourceParameters::isFixedResolutionForced() const
00898 {
00899 return m_forceFixedResolution || s_artForceFixed;
00900 }
00901
00902
00903 extern std::ostream& operator << (std::ostream& os, const SoLDMResourceParameters& p);
00904
00905 #ifdef _MSC_VER
00906 #pragma warning( pop )
00907 #endif
00908
00909 #endif
00910
00911
00912