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 
00152   typedef void FixedResolutionCB(FixedResolutionReport&, void*);
00153 
00157   enum LoadPolicy {
00161     NO_USER_INTERACTION,
00163     ALWAYS,
00165     NEVER
00166   };
00167 
00178   enum TileCachePolicy {
00195     NONE,
00196 
00212     LOWRES_ONLY,
00213 
00230     ALL
00231   };
00232 
00233 
00237   SoLDMResourceParameters();
00238 
00242   virtual ~SoLDMResourceParameters();
00243 
00258   SoSFInt32 maxMainMemory;
00259  
00274   SoSFInt32 maxTexMemory;
00275 
00286   SoSFEnum loadPolicy;
00287 
00298   SoSFEnum tileCachePolicy;
00299 
00324   SoSFInt32 tex3LoadRate;
00325 
00348   SoSFInt32 max2DTexMemory;
00349 
00372   SoSFInt32 tex2LoadRate;
00373 
00389   SoSFInt32 minResolutionThreshold;
00390 
00398   SoSFInt32 maxResolutionThreshold;
00399 
00450   SoSFVec3i32 tileDimension;
00451 
00463   SoSFVec3i32 subTileDimension;
00464 
00482   SoSFInt32 loadNotificationRate;
00483 
00493   SoSFFloat tileHalfLife;
00494 
00503   SoSFBool fixedResolution;
00504 
00526   SoSFInt32 resolution;
00527 
00533   SoSFInt32 numPrefetchThread;
00534 
00563   SoSFBool tileBorders;
00564 
00586   SoSFInt32 minTilesToLoad;
00587 
00593   enum ViewpointRefinementPolicy
00594   {
00596     VIEWPOINT_REFINEMENT_OFF,
00597 
00604     VIEWPOINT_REFINEMENT_ON,
00605 
00610     VIEWPOINT_REFINEMENT_INHERITED_FROM_GLOBAL,
00611   };
00612 
00621   SoSFEnum viewpointRefinementPolicy;
00622 
00628   enum ScreenResolutionCullingPolicy
00629   {
00631     SCREEN_RESOLUTION_CULLING_OFF,
00632 
00642     SCREEN_RESOLUTION_CULLING_ON,
00643 
00648     SCREEN_RESOLUTION_CULLING_INHERITED_FROM_GLOBAL,
00649   };
00650 
00659   SoSFEnum screenResolutionCullingPolicy;
00660 
00670   void setMovingTimeOut(float timeout);
00671 
00678   float getMovingTimeOut();
00679 
00683   int getDataSize();
00684 
00697   void enableFixedResolutionMode(int resolution, FixedResolutionCB* func);
00698 
00712   void setGeometryPriority(SoType geometryType, float priority);
00713 
00718   SbBool getGeometryPriority(SoType geometryType, float& priority);
00719 
00720 private:
00721   typedef struct GeomPriority
00722   {
00723     float   m_weight;
00724     SoType  m_geomId;
00725   } GeomPriority;
00726 
00730   void setDataSet(SoDataSet *ds);
00731 
00735   void copyParameters(SoLDMMediator *mediator);
00736 
00740   void fprintfResourceManager(FILE *f);
00741 
00742   
00743 
00744 
00745   void invalidateData();
00746 
00747   
00748 
00749 
00750 
00751 
00752 
00753   void setNumTiles(int numTiles);
00754 
00758   int getNumTiles();
00759 
00764   SbBox3i32 XYZToVoxel(const SbBox3f &dataBox);
00765 
00766 
00770   bool isReportDisabled();
00771   void setReportDisabled(bool flag);
00772   FixedResolutionCB* getFixedResCB();
00773   int getNumTilesLoaded();
00774   bool toReport();
00775   void setToReport(bool flag);
00776   void increaseNumTilesLoaded();
00777   void decreaseNumTilesLoaded();
00778   void resetNumTilesLoaded();
00779   void resetFixedResVar();
00780 
00781   void sendToLdm(SoDataSet* ds);
00782 
00783   void enableParamsNotify(SbBool state);
00784 
00785   virtual void notify(SoNotList*);
00786 
00787   inline void setResourceManager(SoLDMResourceManager* resourceManager);
00788 
00794   inline void forceFixedResolution(bool flag);
00795 
00800   inline bool isFixedResolutionForced() const;
00801 
00807   enum Resolution {
00812     BEST = -1,
00816     FULL = 0
00817   };
00818 
00819 private:
00820 
00821 #if 1             SoDEPRECATED
00828   SoSFInt32 overlapping;
00829 
00830 #endif 
00832 #if 1             SoDEPRECATED
00844   SoSFInt32 maxTilesInMainMem;
00845 SoDEPRECATED
00856   SoSFInt32 maxTilesInTexMem;
00857 SoDEPRECATED
00871   SoSFBool fixedParams;
00872 
00873 #endif 
00875 #if 1             SoDEPRECATED
00896   SoSFInt32 max2DTextures;
00897 
00898   
00899   friend class SoLDMResourceManager;
00900 #endif 
00902   // Deprecated in 9700 and removed (hidden) in 10000.
00903   
00904   
00905   SoSFInt32 maxNumTriangles;
00906 
00907   bool m_forceFixedResolution;
00908 
00912   SoLDMResourceParameters& operator=(const SoLDMResourceParameters& ldmrp);
00913   SoLDMResourceParameters(const SoLDMResourceParameters& );
00914 
00915   
00916   void updateTileHalfLife(float timeInSec);
00917   void updateTileSize();
00918   void updateMaxResolutionThreshold( int threshold );
00919   void updateMinResolutionThreshold( int threshold );
00920   void updateLoadPolicy( LoadPolicy loadPolicy );
00921   void updateEnableFixedResolutionMode(int resolution, FixedResolutionCB* func);
00922   void updateDisableFixedResolutionMode();
00923 
00924   SoDataSet* m_ds;
00925   SoLDMResourceManager* m_resourceMgr;
00926 
00927   FixedResolutionCB* m_fixedResCB;
00928   int  m_numTilesLoaded;
00929   int  m_numTilesNeeded;
00930   bool m_toReport;
00931   bool m_reportDisable;
00932   bool m_isFixedRes;
00933   bool m_bLdmParamDebug;
00934 
00936   int m_previousMinThreshold;
00937 
00938   
00939   LoadPolicy         m_policyUsed;
00940   int                m_resolution;
00941   SoLDMTileVisitor*  m_fixedResVisitor;
00942   SoLDMTileVisitor*  m_beforeFixedResVisitor;
00943   bool m_beforeFixedResVisitorFlag;
00944 
00945   float m_movingTimeOut; 
00946 
00947   std::vector<GeomPriority> m_geomPriority;
00948   int getGeometryIndex(SoType geometryType);
00949 
00950   static bool s_artForceFixed;
00951 };
00952 
00953 
00954 inline bool
00955 SoLDMResourceParameters::isReportDisabled()
00956 {
00957   return m_reportDisable;
00958 }
00959 
00960 
00961 inline void
00962 SoLDMResourceParameters::setReportDisabled(bool flag)
00963 {
00964   m_reportDisable = flag;
00965 }
00966 
00967 
00968 inline SoLDMResourceParameters::FixedResolutionCB*
00969 SoLDMResourceParameters::getFixedResCB()
00970 {
00971   return m_fixedResCB;
00972 }
00973 
00974 
00975 inline int
00976 SoLDMResourceParameters::getNumTilesLoaded()
00977 {
00978   return m_numTilesLoaded;
00979 }
00980 
00981 
00982 inline bool
00983 SoLDMResourceParameters::toReport()
00984 {
00985   return m_toReport;
00986 }
00987 
00988 
00989 inline void
00990 SoLDMResourceParameters::setToReport(bool flag)
00991 {
00992   m_toReport = flag;
00993 }
00994 
00995 
00996 inline void
00997 SoLDMResourceParameters::increaseNumTilesLoaded()
00998 {
00999   m_numTilesLoaded++;
01000 }
01001 
01002 
01003 inline void
01004 SoLDMResourceParameters::decreaseNumTilesLoaded()
01005 {
01006   m_numTilesLoaded--;
01007 }
01008 
01009 
01010 inline void
01011 SoLDMResourceParameters::resetNumTilesLoaded()
01012 {
01013   m_numTilesLoaded = 0;
01014 }
01015 
01016 
01017 inline void
01018 SoLDMResourceParameters::setResourceManager(SoLDMResourceManager* resourceManager)
01019 {
01020   m_resourceMgr = resourceManager;
01021 }
01022 
01023 
01024 inline SoLDMResourceParameters&
01025 SoLDMResourceParameters::operator=(const SoLDMResourceParameters& )
01026 {
01027   assert(0);
01028   return *this;
01029 }
01030 
01031 
01032 inline void
01033 SoLDMResourceParameters::forceFixedResolution(bool flag)
01034 {
01035   m_forceFixedResolution = flag;
01036 }
01037 
01038 
01039 inline bool
01040 SoLDMResourceParameters::isFixedResolutionForced() const
01041 {
01042   return m_forceFixedResolution || s_artForceFixed;
01043 }
01044 
01045 
01046 extern  std::ostream& operator << (std::ostream& os, const SoLDMResourceParameters& p);
01047 
01048 #ifdef _MSC_VER
01049 #pragma warning( pop )
01050 #endif
01051 
01052 #endif
01053 
01054 
01055