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
00172 SoLDMResourceParameters();
00173
00177 virtual ~SoLDMResourceParameters();
00178
00193 SoSFInt32 maxMainMemory;
00194
00209 SoSFInt32 maxTexMemory;
00210
00221 SoSFEnum loadPolicy;
00222
00247 SoSFInt32 tex3LoadRate;
00248
00271 SoSFInt32 max2DTexMemory;
00272
00273 #if 1 SoDEPRECATED
00294 SoSFInt32 max2DTextures;
00295
00296 #endif
00320 SoSFInt32 tex2LoadRate;
00321
00341 SoSFInt32 minResolutionThreshold;
00342
00350 SoSFInt32 maxResolutionThreshold;
00351
00399 SoSFVec3i32 tileDimension;
00400
00412 SoSFVec3i32 subTileDimension;
00413
00431 SoSFInt32 loadNotificationRate;
00432
00442 SoSFFloat tileHalfLife;
00443
00454 SoSFBool fixedResolution;
00455
00465 SoSFInt32 resolution;
00466
00472 SoSFInt32 numPrefetchThread;
00473
00474 #if 1 SoDEPRECATED
00489 SoSFInt32 maxNumTriangles;
00490 #endif
00501 void setMovingTimeOut(float timeout);
00502
00509 float getMovingTimeOut();
00510
00514 int getDataSize();
00515
00520 void enableFixedResolutionMode(int resolution, FixedResolutionCB* func);
00521
00535 void setGeometryPriority(SoType geometryType, float priority);
00536
00541 SbBool getGeometryPriority(SoType geometryType, float& priority);
00542
00543 #if 1 SoDEPRECATED
00546 void setMaxMainMemory( int maxMainMemory );
00547 SoDEPRECATED
00549 int getMaxMainMemory();
00550 SoDEPRECATED
00556 void setMaxTilesInMainMem( int numTiles );
00557 SoDEPRECATED
00563 int getMaxTilesInMainMem();
00564 SoDEPRECATED
00566 void setLoadPolicy( LoadPolicy policy );
00567 SoDEPRECATED
00569 LoadPolicy getLoadPolicy();
00570 SoDEPRECATED
00572 void setLoadNotificationRate(int rate);
00573 SoDEPRECATED
00575 int getLoadNotificationRate();
00576 SoDEPRECATED
00578 void setMaxTexMemory( int maxTexMemory );
00579 SoDEPRECATED
00581 int getMaxTexMemory();
00582 SoDEPRECATED
00584 void setMaxTilesInTexMem( int numTiles );
00585 SoDEPRECATED
00587 int getMaxTilesInTexMem();
00588 SoDEPRECATED
00590 void setTex3LoadRate( int loadRate );
00591 SoDEPRECATED
00593 int getTex3LoadRate();
00594 SoDEPRECATED
00596 void setMax2DTextures( int numTextures );
00597 SoDEPRECATED
00599 int getMax2DTextures();
00600 SoDEPRECATED
00602 void setTex2LoadRate( int loadRate );
00603 SoDEPRECATED
00605 int getTex2LoadRate();
00606 SoDEPRECATED
00608 void setMinResolutionThreshold( int threshold );
00609 SoDEPRECATED
00611 int getMinResolutionThreshold();
00612 SoDEPRECATED
00614 void setMaxResolutionThreshold( int threshold );
00615 SoDEPRECATED
00617 int getMaxResolutionThreshold();
00618 SoDEPRECATED
00620 void setTileSize( int tileDim );
00621 SoDEPRECATED
00623 int getTileSize();
00624 SoDEPRECATED
00626 void fixParams( SbBool flag);
00627 SoDEPRECATED
00629 SbBool isParamsFixed();
00630 SoDEPRECATED
00632 void setOverlapping( int );
00633 SoDEPRECATED
00635 int getOverlapping();
00636 SoDEPRECATED
00638 void setTileHalfLife(float timeInSec);
00639 SoDEPRECATED
00641 float getTileHalfLife();
00642 SoDEPRECATED
00644 void disableFixedResolutionMode();
00645 SoDEPRECATED
00647 SbBool isFixedResolutionMode();
00648 SoDEPRECATED
00650 int getFixedResolution();
00651
00652 #endif
00654 #if 1 SoDEPRECATED
00661 SoSFInt32 overlapping;
00662
00663 #endif
00665 #if 1 SoDEPRECATED
00677 SoSFInt32 maxTilesInMainMem;
00678 SoDEPRECATED
00689 SoSFInt32 maxTilesInTexMem;
00690 SoDEPRECATED
00704 SoSFBool fixedParams;
00705
00706 #endif
00708 private:
00709 typedef struct GeomPriority
00710 {
00711 float m_weight;
00712 SoType m_geomId;
00713 } GeomPriority;
00714
00718 void setDataSet(SoDataSet *ds);
00719
00723 void copyParameters(SoLDMMediator *mediator);
00724
00728 void fprintfResourceManager(FILE *f);
00729
00730
00731
00732
00733 void invalidateData();
00734
00735
00736
00737
00738
00739
00740
00741 void setNumTiles(int numTiles);
00742
00746 int getNumTiles();
00747
00752 SbBox3i32 XYZToVoxel(const SbBox3f &dataBox);
00753
00754
00758 bool isReportDisabled();
00759 void setReportDisabled(bool flag);
00760 FixedResolutionCB* getFixedResCB();
00761 int getNumTilesLoaded();
00762 bool toReport();
00763 void setToReport(bool flag);
00764 void increaseNumTilesLoaded();
00765 void decreaseNumTilesLoaded();
00766 void resetNumTilesLoaded();
00767 void resetFixedResVar();
00768
00769 void sendToLdm(SoDataSet* ds);
00770
00771 void enableParamsNotify(SbBool state);
00772
00773 virtual void notify(SoNotList*);
00774
00775 inline void setResourceManager(SoLDMResourceManager* resourceManager);
00776
00782 inline void forceFixedResolution(bool flag);
00783
00788 inline bool isFixedResolutionForced() const;
00789
00795 enum Resolution {
00800 BEST = -1,
00804 FULL = 0
00805 };
00806
00807 private:
00808 bool m_forceFixedResolution;
00809
00813 SoLDMResourceParameters& operator=(const SoLDMResourceParameters& ldmrp);
00814 SoLDMResourceParameters(const SoLDMResourceParameters& );
00815
00816
00817 void updateTileHalfLife(float timeInSec);
00818 void updateTileSize( const SbVec3i32 &tileDim );
00819 void updateMaxResolutionThreshold( int threshold );
00820 void updateMinResolutionThreshold( int threshold );
00821 void updateLoadPolicy( SoLDMResourceManager::LoadPolicy loadPolicy );
00822 void updateEnableFixedResolutionMode(int resolution, FixedResolutionCB* func);
00823 void updateDisableFixedResolutionMode();
00824
00825 SoDataSet* m_ds;
00826 SoLDMResourceManager* m_resourceMgr;
00827
00828 FixedResolutionCB* m_fixedResCB;
00829 int m_numTilesLoaded;
00830 int m_numTilesNeeded;
00831 bool m_toReport;
00832 bool m_reportDisable;
00833 bool m_isFixedRes;
00834 bool m_bLdmParamDebug;
00835
00837 int m_previousMinThreshold;
00838
00839
00840 LoadPolicy m_policyUsed;
00841 int m_resolution;
00842 bool m_viewCulling;
00843 bool m_viewRefinement;
00844 SoLDMTileVisitor* m_fixedResVisitor;
00845 SoLDMTileVisitor* m_beforeFixedResVisitor;
00846 bool m_beforeFixedResVisitorFlag;
00847
00848 std::vector<GeomPriority> m_geomPriority;
00849 int getGeometryIndex(SoType geometryType);
00850
00851 static bool s_artForceFixed;
00852 };
00853
00854
00855 inline bool
00856 SoLDMResourceParameters::isReportDisabled()
00857 {
00858 return m_reportDisable;
00859 }
00860
00861
00862 inline void
00863 SoLDMResourceParameters::setReportDisabled(bool flag)
00864 {
00865 m_reportDisable = flag;
00866 }
00867
00868
00869 inline SoLDMResourceParameters::FixedResolutionCB*
00870 SoLDMResourceParameters::getFixedResCB()
00871 {
00872 return m_fixedResCB;
00873 }
00874
00875
00876 inline int
00877 SoLDMResourceParameters::getNumTilesLoaded()
00878 {
00879 return m_numTilesLoaded;
00880 }
00881
00882
00883 inline bool
00884 SoLDMResourceParameters::toReport()
00885 {
00886 return m_toReport;
00887 }
00888
00889
00890 inline void
00891 SoLDMResourceParameters::setToReport(bool flag)
00892 {
00893 m_toReport = flag;
00894 }
00895
00896
00897 inline void
00898 SoLDMResourceParameters::increaseNumTilesLoaded()
00899 {
00900 m_numTilesLoaded++;
00901 }
00902
00903
00904 inline void
00905 SoLDMResourceParameters::decreaseNumTilesLoaded()
00906 {
00907 m_numTilesLoaded--;
00908 }
00909
00910
00911 inline void
00912 SoLDMResourceParameters::resetNumTilesLoaded()
00913 {
00914 m_numTilesLoaded = 0;
00915 }
00916
00917
00918 inline void
00919 SoLDMResourceParameters::setResourceManager(SoLDMResourceManager* resourceManager)
00920 {
00921 m_resourceMgr = resourceManager;
00922 }
00923
00924
00925 inline SoLDMResourceParameters&
00926 SoLDMResourceParameters::operator=(const SoLDMResourceParameters& )
00927 {
00928 assert(0);
00929 return *this;
00930 }
00931
00932
00933 inline void
00934 SoLDMResourceParameters::forceFixedResolution(bool flag)
00935 {
00936 m_forceFixedResolution = flag;
00937 }
00938
00939
00940 inline bool
00941 SoLDMResourceParameters::isFixedResolutionForced() const
00942 {
00943 return m_forceFixedResolution || s_artForceFixed;
00944 }
00945
00946
00947 extern std::ostream& operator << (std::ostream& os, const SoLDMResourceParameters& p);
00948
00949
00950 #define LDMResourceParameter SoLDMResourceParameters
00951
00952 #ifdef _MSC_VER
00953 #pragma warning( pop )
00954 #endif
00955
00956 #endif
00957
00958
00959