00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _SO_MEDIATOR_
00024 #define _SO_MEDIATOR_
00025
00026 #ifdef _MSC_VER
00027 #pragma warning( push )
00028 #pragma warning(disable:4251)
00029 #endif
00030
00031 #include <Inventor/STL/vector>
00032 #include <Inventor/SbBox.h>
00033 #include <LDM/SoLDMTileID.h>
00034 #include <LDM/SoLDMTileManager.h>
00035 #include <LDM/SoLDMResourceManager.h>
00036 #include <LDM/nodes/SoLDMResourceParameters.h>
00037
00038 #include <LDM/SoLDMDataAccess.h>
00039
00040 #include <LDM/elements/SoDataSetElement.h>
00041
00042
00043
00044 class SoLDMTileVisitor;
00045 class SoLDMProximityVisitor;
00046 class SoLDMMultiIOTileManager;
00047 class SoLDMNodeFrontManager;
00048 class SoLDMTextureManager;
00049 class SoLDMGeometry;
00050 class SoLDMResourceManager;
00051 class SoDataCompositor;
00052 class LDMDefaultSliceAccessor;
00053 class SoGLRenderAction;
00054 class SoDataSet;
00055 class SoState;
00056 class SoLdmParameterNode;
00057 class SoBufferObject;
00058 class SbThreadSemaphore;
00059 class SoDataSetId;
00060 class SoLdmValuationAction;
00061 class SoLDMTileInfo;
00062
00079 SoEXTENDER_Documented class SoLDMMediator
00080 {
00081 public:
00083 SoLDMMediator();
00084
00086 virtual ~SoLDMMediator();
00087
00088 private:
00089
00090 void registerNode(const SoLDM::DataSetIdPair& dsIdPair, bool sync);
00091 void unregisterNode(const SoLDM::DataSetIdPair& dsIdPair, SoLDMMediator *newMediator = NULL);
00092
00093 void readTile(int dataSetId, SoLDMTileID tileID, unsigned char* buffer, bool transform) ;
00094
00095 void readTile(const int dataSetId, const SoLDMTileID tileID, SoBufferObject* buffer, const bool transform) ;
00096
00097 size_t readTile(SoLDMTileInfo* tileInfo, const int dataSetId, bool transform);
00098
00099 uint64_t getTileSize(int dataSetId, const SoLDMTileID* tileId = NULL)const ;
00100 SbVec3i32 getTileDimension()const ;
00101
00102 const SbVec3i32& getDimension()const ;
00103 const SbBox3f& getExtent()const ;
00104 inline int getOverlapping() const
00105 { return 0; }
00106
00107 void renderNotify()const;
00108
00112 const std::vector<int>& getNumData() const ;
00113
00114 SbBool getBbox(SoLDMTileID tileID, SbBox3f& box)const;
00115 bool getCenter(SoLDMTileID tileID, SbVec3f& center)const;
00116
00117
00118 SbBool getListChange(){return m_listChange;};
00119
00121 int getDataEntry(unsigned short id)const ;
00122 int getDataEntry(SoDataSet*)const ;
00123
00125 inline bool hasMultiDataError() const;
00126
00128 private:
00129
00131 void registerWithIds(SoDataSet* ds, std::vector<int> ids, bool sync);
00132
00134 void unregisterAllIds(SoDataSet* ds, SoLDMMediator* newMediator = NULL);
00135
00137 void unregisterAll();
00138
00139
00140 bool m_userVisitor;
00141 SoLDMProximityVisitor* m_internalVisitor;
00142 bool m_userTileManager;
00143 SoLDMMultiIOTileManager* m_internalTileManager;
00144 SoLDMTileManager* getTileManager() { return m_tileManager; }
00145 SoLDMTextureManager* getTextureManager() { return m_textureManager; }
00146 SoLDMGeometry* getVVizGeometry() { return m_vvizGeometry; }
00147
00148 SoLDMTileManager::LDMSliceAccessor* getSliceAccessor(const SoLDM::DataSetIdPair& p)const;
00149 void startRenderTraversal(SoLdmValuationAction*, SoDataSet*);
00150
00151 void updateRegions(const SbBox3i32* region, int numRegions);
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162 void checkList(SoAction* action, SoDataCompositor* dc);
00163
00164
00165
00166
00167
00168
00169 int getBiggestBufferEntry() const;
00170
00171
00172
00173 void restartLoadingThread();
00174
00175
00176 void updateDataIds() ;
00177
00178 SoDataSet* getVolumeOfId(unsigned short dataSetId)const;
00179 void getVolumeElements(SoLDM::DataSetIdPairList& dsIdPairList) const;
00180
00182 void getDataSetList(SoLDM::DsVector& dsList) const;
00183
00185 void getDataSetIds(const SoDataSet* ds, std::vector<int>& ids) const;
00186
00190 inline SoDataSet* getFirstDataSet() const;
00191
00195 inline const SoLDM::DataSetIdPairList& getDsIds() const { return m_dataDsIds; }
00196
00197
00198
00199 void addToLDM();
00200
00201 SoDataCompositor* getDataCompositor()const { return m_dc; }
00202 void setDataCompositor(SoDataCompositor *dc);
00203
00205 struct DataSetInfo
00206 {
00207 SoLDM::DataSetIdPair dsIdPair;
00208 int bufferId;
00209 };
00210 typedef std::vector<DataSetInfo> DataSetInfoList;
00211
00212 DataSetInfoList & getVolumeDataList();
00213
00220 bool isAlreadyInFixResMode() const;
00221
00222 #if 1 SoDEPRECATED
00229 void useFixedTileVisitor(bool flag);
00230 #endif
00231
00232 private:
00233 SoLDMTileManager *m_tileManager;
00234 SoLDMTileVisitor *m_tileVisitor;
00235 SoLDMNodeFrontManager *m_nodeFrontManager;
00236
00237 private:
00238 SoLDMTextureManager *m_textureManager;
00239 SoLDMGeometry *m_vvizGeometry;
00240 SoDataCompositor *m_dc;
00241
00242 private:
00243 const DataSetInfo& getDataInfo(const SoLDM::DataSetIdPair& dsIdPair) const;
00244
00245 bool isUsedByLDM() { return m_isUsedByLDM; }
00246 void setUsedByLDM(bool flag) { m_isUsedByLDM = flag; }
00247 bool m_isUsedByLDM;
00248
00250 std::vector<int> m_dataIds ;
00251 SoLDM::DataSetIdPairList m_dataDsIds;
00252
00253 std::vector<DataSetInfo> m_volumeDataList;
00254 bool isInList(const SoLDM::DataSetIdPair& dsIdPair)const;
00255
00256
00257 std::vector<int> m_availBufferEntry;
00258
00259 void addToList(const SoLDM::DataSetIdPair& dsIdPair);
00260 void removeFromList(const SoLDM::DataSetIdPair& dsIdPair);
00261 void setListChange(bool val){m_listChange = val;};
00262 bool m_listChange;
00264
00265 void createLDMCore();
00266 void deleteLDMCore();
00267
00268 void setMinResolutionThreshold();
00269
00274 bool isMultiDataPossible();
00275
00277 bool m_multiDataError;
00278
00280 static int s_debugMediator;
00281
00284 SoEXTENDER_Documented public:
00285
00298 SoEXTENDER_Documented class LDMManagerAccess {
00299
00300 public:
00302 LDMManagerAccess(){};
00303
00307 void setMediator(SoLDMMediator* mediator)
00308 { m_mediator = mediator; };
00309
00313 void setNodeFrontManager( SoLDMNodeFrontManager* );
00314
00318 inline SoLDMNodeFrontManager* getNodeFrontManager() { return m_mediator->m_nodeFrontManager; }
00319
00320 #if 1 SoDEPRECATED
00333 void setTileVisitor(SoLDMTileVisitor*, SbBool ownedByUser = TRUE);
00334 SoDEPRECATED
00339 SoLDMTileVisitor* getTileVisitor();
00340 SoDEPRECATED
00345 bool isTileVisitorOwnedByUser() const;
00346 SoDEPRECATED
00351 SoLDMGeometry* getVVizGeometry() { return m_mediator->getVVizGeometry(); }
00352 #endif
00353
00361 void setTileManager(SoLDMTileManager* tilemgr, SbBool ownedByUser = TRUE);
00362
00366 SoLDMTileManager* getTileManager() { return m_mediator->getTileManager(); }
00367
00371 SoLDMTextureManager* getTextureManager() { return m_mediator->getTextureManager(); }
00372
00376 SoLDMResourceManager* getResourceManager(int id = -1);
00377
00378 private:
00379 SoLDMMediator* m_mediator;
00380 };
00381
00382 private:
00383 LDMManagerAccess ldmManagerAccess;
00384 SoLDMDataAccess& getDataAccess ( int id = -1 );
00385 SoLDMDataAccess& getDataAccess ( SoDataSet* ds );
00386
00387
00388 LDMResourceParameter* getResourceParameter(int dataEntry);
00389 private:
00390
00391
00392 typedef std::map<SbThreadId_t, SoLDMDataAccess*> t_dataAccessList;
00393
00394 t_dataAccessList ldmDataAccessList;
00395 SbThreadMutex* m_semDataAccessList;
00396
00397 private:
00398 bool m_isTileVisitorFixedRes;
00399
00400 };
00401
00402
00403 SoDataSet*
00404 SoLDMMediator::getFirstDataSet() const
00405 {
00406 if ( m_volumeDataList.empty() )
00407 return NULL;
00408
00409 return m_volumeDataList[0].dsIdPair.first;
00410 }
00411
00412
00413 bool
00414 SoLDMMediator::hasMultiDataError() const
00415 {
00416 return m_multiDataError;
00417 }
00418
00419 inline bool
00420 SoLDMMediator::isAlreadyInFixResMode() const
00421 {
00422 return m_isTileVisitorFixedRes;
00423 }
00424
00425 inline void
00426 SoLDMMediator::useFixedTileVisitor(bool flag)
00427 {
00428 m_isTileVisitorFixedRes = flag;
00429 }
00430
00431 #ifdef _MSC_VER
00432 #pragma warning( pop )
00433 #endif
00434
00435 #endif
00436
00437
00438