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
00414 SoSFVec3i32 subTileDimension;
00415
00433 SoSFInt32 loadNotificationRate;
00434
00444 SoSFFloat tileHalfLife;
00445
00456 SoSFBool fixedResolution;
00457
00467 SoSFInt32 resolution;
00468
00474 SoSFInt32 numPrefetchThread;
00475
00476 #if 1 SoDEPRECATED
00491 SoSFInt32 maxNumTriangles;
00492 #endif
00503 void setMovingTimeOut(float timeout);
00504
00511 float getMovingTimeOut();
00512
00516 int getDataSize();
00517
00522 void enableFixedResolutionMode(int resolution, FixedResolutionCB* func);
00523
00537 void setGeometryPriority(SoType geometryType, float priority);
00538
00543 SbBool getGeometryPriority(SoType geometryType, float& priority);
00544
00545 #if 1 SoDEPRECATED
00548 void setMaxMainMemory( int maxMainMemory );
00549 SoDEPRECATED
00551 int getMaxMainMemory();
00552 SoDEPRECATED
00558 void setMaxTilesInMainMem( int numTiles );
00559 SoDEPRECATED
00565 int getMaxTilesInMainMem();
00566 SoDEPRECATED
00568 void setLoadPolicy( LoadPolicy policy );
00569 SoDEPRECATED
00571 LoadPolicy getLoadPolicy();
00572 SoDEPRECATED
00574 void setLoadNotificationRate(int rate);
00575 SoDEPRECATED
00577 int getLoadNotificationRate();
00578 SoDEPRECATED
00580 void setMaxTexMemory( int maxTexMemory );
00581 SoDEPRECATED
00583 int getMaxTexMemory();
00584 SoDEPRECATED
00586 void setMaxTilesInTexMem( int numTiles );
00587 SoDEPRECATED
00589 int getMaxTilesInTexMem();
00590 SoDEPRECATED
00592 void setTex3LoadRate( int loadRate );
00593 SoDEPRECATED
00595 int getTex3LoadRate();
00596 SoDEPRECATED
00598 void setMax2DTextures( int numTextures );
00599 SoDEPRECATED
00601 int getMax2DTextures();
00602 SoDEPRECATED
00604 void setTex2LoadRate( int loadRate );
00605 SoDEPRECATED
00607 int getTex2LoadRate();
00608 SoDEPRECATED
00610 void setMinResolutionThreshold( int threshold );
00611 SoDEPRECATED
00613 int getMinResolutionThreshold();
00614 SoDEPRECATED
00616 void setMaxResolutionThreshold( int threshold );
00617 SoDEPRECATED
00619 int getMaxResolutionThreshold();
00620 SoDEPRECATED
00622 void setTileSize( int tileDim );
00623 SoDEPRECATED
00625 int getTileSize();
00626 SoDEPRECATED
00628 void fixParams( SbBool flag);
00629 SoDEPRECATED
00631 SbBool isParamsFixed();
00632 SoDEPRECATED
00634 void setOverlapping( int );
00635 SoDEPRECATED
00637 int getOverlapping();
00638 SoDEPRECATED
00640 void setTileHalfLife(float timeInSec);
00641 SoDEPRECATED
00643 float getTileHalfLife();
00644 SoDEPRECATED
00646 void disableFixedResolutionMode();
00647 SoDEPRECATED
00649 SbBool isFixedResolutionMode();
00650 SoDEPRECATED
00652 int getFixedResolution();
00653
00654 #endif
00656 #if 1 SoDEPRECATED
00663 SoSFInt32 overlapping;
00664
00665 #endif
00667 #if 1 SoDEPRECATED
00679 SoSFInt32 maxTilesInMainMem;
00680 SoDEPRECATED
00691 SoSFInt32 maxTilesInTexMem;
00692 SoDEPRECATED
00706 SoSFBool fixedParams;
00707
00708 #endif
00710 private:
00711 typedef struct GeomPriority
00712 {
00713 float m_weight;
00714 SoType m_geomId;
00715 } GeomPriority;
00716
00720 void setDataSet(SoDataSet *ds);
00721
00725 void copyParameters(SoLDMMediator *mediator);
00726
00730 void fprintfResourceManager(FILE *f);
00731
00732
00733
00734
00735 void invalidateData();
00736
00737
00738
00739
00740
00741
00742
00743 void setNumTiles(int numTiles);
00744
00748 int getNumTiles();
00749
00754 SbBox3i32 XYZToVoxel(const SbBox3f &dataBox);
00755
00756
00760 bool isReportDisabled();
00761 void setReportDisabled(bool flag);
00762 FixedResolutionCB* getFixedResCB();
00763 int getNumTilesLoaded();
00764 bool toReport();
00765 void setToReport(bool flag);
00766 void increaseNumTilesLoaded();
00767 void decreaseNumTilesLoaded();
00768 void resetNumTilesLoaded();
00769 void resetFixedResVar();
00770
00771 void sendToLdm(SoDataSet* ds);
00772
00773 void enableParamsNotify(SbBool state);
00774
00775 virtual void notify(SoNotList*);
00776
00777 inline void setResourceManager(SoLDMResourceManager* resourceManager);
00778
00784 inline void forceFixedResolution(bool flag);
00785
00790 inline bool isFixedResolutionForced() const;
00791
00797 enum Resolution {
00802 BEST = -1,
00806 FULL = 0
00807 };
00808
00809 private:
00810 bool m_forceFixedResolution;
00811
00815 SoLDMResourceParameters& operator=(const SoLDMResourceParameters& ldmrp);
00816 SoLDMResourceParameters(const SoLDMResourceParameters& );
00817
00818
00819 void updateTileHalfLife(float timeInSec);
00820 void updateTileSize( const SbVec3i32 &tileDim );
00821 void updateMaxResolutionThreshold( int threshold );
00822 void updateMinResolutionThreshold( int threshold );
00823 void updateLoadPolicy( SoLDMResourceManager::LoadPolicy loadPolicy );
00824 void updateEnableFixedResolutionMode(int resolution, FixedResolutionCB* func);
00825 void updateDisableFixedResolutionMode();
00826
00827 SoDataSet* m_ds;
00828 SoLDMResourceManager* m_resourceMgr;
00829
00830 FixedResolutionCB* m_fixedResCB;
00831 int m_numTilesLoaded;
00832 int m_numTilesNeeded;
00833 bool m_toReport;
00834 bool m_reportDisable;
00835 bool m_isFixedRes;
00836 bool m_bLdmParamDebug;
00837
00839 int m_previousMinThreshold;
00840
00841
00842 LoadPolicy m_policyUsed;
00843 int m_resolution;
00844 bool m_viewCulling;
00845 bool m_viewRefinement;
00846 SoLDMTileVisitor* m_fixedResVisitor;
00847 SoLDMTileVisitor* m_beforeFixedResVisitor;
00848 bool m_beforeFixedResVisitorFlag;
00849
00850 std::vector<GeomPriority> m_geomPriority;
00851 int getGeometryIndex(SoType geometryType);
00852
00853 static bool s_artForceFixed;
00854 };
00855
00856
00857 inline bool
00858 SoLDMResourceParameters::isReportDisabled()
00859 {
00860 return m_reportDisable;
00861 }
00862
00863
00864 inline void
00865 SoLDMResourceParameters::setReportDisabled(bool flag)
00866 {
00867 m_reportDisable = flag;
00868 }
00869
00870
00871 inline SoLDMResourceParameters::FixedResolutionCB*
00872 SoLDMResourceParameters::getFixedResCB()
00873 {
00874 return m_fixedResCB;
00875 }
00876
00877
00878 inline int
00879 SoLDMResourceParameters::getNumTilesLoaded()
00880 {
00881 return m_numTilesLoaded;
00882 }
00883
00884
00885 inline bool
00886 SoLDMResourceParameters::toReport()
00887 {
00888 return m_toReport;
00889 }
00890
00891
00892 inline void
00893 SoLDMResourceParameters::setToReport(bool flag)
00894 {
00895 m_toReport = flag;
00896 }
00897
00898
00899 inline void
00900 SoLDMResourceParameters::increaseNumTilesLoaded()
00901 {
00902 m_numTilesLoaded++;
00903 }
00904
00905
00906 inline void
00907 SoLDMResourceParameters::decreaseNumTilesLoaded()
00908 {
00909 m_numTilesLoaded--;
00910 }
00911
00912
00913 inline void
00914 SoLDMResourceParameters::resetNumTilesLoaded()
00915 {
00916 m_numTilesLoaded = 0;
00917 }
00918
00919
00920 inline void
00921 SoLDMResourceParameters::setResourceManager(SoLDMResourceManager* resourceManager)
00922 {
00923 m_resourceMgr = resourceManager;
00924 }
00925
00926
00927 inline SoLDMResourceParameters&
00928 SoLDMResourceParameters::operator=(const SoLDMResourceParameters& )
00929 {
00930 assert(0);
00931 return *this;
00932 }
00933
00934
00935 inline void
00936 SoLDMResourceParameters::forceFixedResolution(bool flag)
00937 {
00938 m_forceFixedResolution = flag;
00939 }
00940
00941
00942 inline bool
00943 SoLDMResourceParameters::isFixedResolutionForced() const
00944 {
00945 return m_forceFixedResolution || s_artForceFixed;
00946 }
00947
00948
00949 extern std::ostream& operator << (std::ostream& os, const SoLDMResourceParameters& p);
00950
00951
00952 #define LDMResourceParameter SoLDMResourceParameters
00953
00954 #ifdef _MSC_VER
00955 #pragma warning( pop )
00956 #endif
00957
00958 #endif
00959
00960
00961