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/SoLDMResourceManager.h>
00035 #include <LDM/nodes/SoLDMResourceParameters.h>
00036
00037 #include <LDM/SoLDMDataAccess.h>
00038
00039 #include <LDM/elements/SoDataSetElement.h>
00040
00041
00042
00043 class SoLDMTileVisitor;
00044 class SoLDMProximityVisitor;
00045 class SoLDMMultiIOTileManager;
00046 class SoLDMNodeFrontManager;
00047 class SoLDMTextureManager;
00048 class SoLDMGeometry;
00049 class SoLDMResourceManager;
00050 class SoDataCompositor;
00051 class LDMDefaultSliceAccessor;
00052 class SoGLRenderAction;
00053 class SoDataSet;
00054 class SoState;
00055 class SoLdmParameterNode;
00056 class SoBufferObject;
00057 class SbThreadSemaphore;
00058 class SoDataSetId;
00059 class SoLdmValuationAction;
00060 class SoLDMTileInfo;
00061 class SoLDMTileManager;
00062 class LDMSliceAccessor;
00063
00064
00081 SoEXTENDER_Documented class SoLDMMediator
00082 {
00083 public:
00085 SoLDMMediator();
00086
00088 virtual ~SoLDMMediator();
00089
00090 private:
00091
00092 void registerNode(const SoLDM::DataSetIdPair& dsIdPair, bool sync);
00093 void unregisterNode(const SoLDM::DataSetIdPair& dsIdPair, SoLDMMediator *newMediator = NULL);
00094
00095 void readTile(int dataSetId, SoLDMTileID tileID, unsigned char* buffer, bool transform) ;
00096
00097 void readTile(const int dataSetId, const SoLDMTileID tileID, SoBufferObject* buffer, const bool transform) ;
00098
00099 size_t readTile(SoLDMTileInfo* tileInfo, const int dataSetId, bool transform);
00100
00101 uint64_t getTileSize(int dataSetId, const SoLDMTileID* tileId = NULL)const ;
00102 SbVec3i32 getTileDimension()const ;
00103
00104 const SbVec3i32& getDimension()const ;
00105 const SbBox3f& getExtent()const ;
00106 inline int getOverlapping() const
00107 { return 0; }
00108
00109 void renderNotify()const;
00110
00114 const std::vector<int>& getNumData() const ;
00115
00116 SbBool getBbox(SoLDMTileID tileID, SbBox3f& box)const;
00117 bool getCenter(SoLDMTileID tileID, SbVec3f& center)const;
00118
00119
00120 SbBool getListChange(){return m_listChange;};
00121
00123 int getDataEntry(unsigned short id)const ;
00124 int getDataEntry(SoDataSet*)const ;
00125
00127 inline bool hasMultiDataError() const;
00128
00130 private:
00131
00133 void registerWithIds(SoDataSet* ds, std::vector<int> ids, bool sync);
00134
00136 void unregisterAllIds(SoDataSet* ds, SoLDMMediator* newMediator = NULL);
00137
00139 void unregisterAll();
00140
00141 SoLDMTileManager* getTileManager() { return m_tileManager; }
00142 SoLDMTextureManager* getTextureManager() { return m_textureManager; }
00143 SoLDMGeometry* getVVizGeometry() { return m_vvizGeometry; }
00144 SoLDMNodeFrontManager* getNodeFrontManager() { return m_nodeFrontManager; }
00145
00146 LDMSliceAccessor* getSliceAccessor(const SoLDM::DataSetIdPair& p)const;
00147 void startRenderTraversal(SoLdmValuationAction*, SoDataSet*);
00148
00149 void updateRegions(const SbBox3i32* region, int numRegions);
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160 void checkList(SoAction* action, SoDataCompositor* dc);
00161
00162
00163
00164
00165
00166
00167 int getBiggestBufferEntry() const;
00168
00169
00170
00171 void restartLoadingThread();
00172
00173
00174 void updateDataIds() ;
00175
00176 SoDataSet* getVolumeOfId(unsigned short dataSetId)const;
00177 void getVolumeElements(SoLDM::DataSetIdPairList& dsIdPairList) const;
00178
00180 void getDataSetList(SoLDM::DsVector& dsList) const;
00181
00183 void getDataSetIds(const SoDataSet* ds, std::vector<int>& ids) const;
00184
00188 inline SoDataSet* getFirstDataSet() const;
00189
00193 inline const SoLDM::DataSetIdPairList& getDsIds() const { return m_dataDsIds; }
00194
00195
00196
00197 void addToLDM();
00198
00199 SoDataCompositor* getDataCompositor()const { return m_dc; }
00200 void setDataCompositor(SoDataCompositor *dc);
00201
00203 struct DataSetInfo
00204 {
00205 SoLDM::DataSetIdPair dsIdPair;
00206 int bufferId;
00207 };
00208 typedef std::vector<DataSetInfo> DataSetInfoList;
00209
00210 DataSetInfoList & getVolumeDataList();
00211
00218 bool isAlreadyInFixResMode() const;
00219
00220 #if 1 SoDEPRECATED
00227 void useFixedTileVisitor(bool flag);
00228 #endif
00229
00241 void setTileVisitor( SoLDMTileVisitor* visitor, bool ownedByUser = true );
00242
00250 void setTileManager( SoLDMTileManager* tilemgr, SbBool ownedByUser = TRUE );
00251
00255 inline SoLDMTileVisitor* getTileVisitor() { return m_tileVisitor; }
00256
00260 bool isTileVisitorOwnedByUser() const { return m_userVisitor; }
00261
00262 private:
00263 SoLDMTextureManager* m_textureManager;
00264 SoLDMGeometry* m_vvizGeometry;
00265 SoDataCompositor* m_dc;
00266 SoLDMTileVisitor* m_tileVisitor;
00267 SoLDMNodeFrontManager* m_nodeFrontManager;
00268 SoLDMTileManager* m_tileManager;
00269
00270
00271 bool m_userVisitor;
00272 SoLDMProximityVisitor* m_internalVisitor;
00273 bool m_userTileManager;
00274 SoLDMMultiIOTileManager* m_internalTileManager;
00275
00276 const DataSetInfo& getDataInfo(const SoLDM::DataSetIdPair& dsIdPair) const;
00277
00278 bool isUsedByLDM() { return m_isUsedByLDM; }
00279 void setUsedByLDM(bool flag) { m_isUsedByLDM = flag; }
00280 bool m_isUsedByLDM;
00281
00283 std::vector<int> m_dataIds ;
00284 SoLDM::DataSetIdPairList m_dataDsIds;
00285
00286 std::vector<DataSetInfo> m_volumeDataList;
00287 bool isInList(const SoLDM::DataSetIdPair& dsIdPair)const;
00288
00289
00290 std::vector<int> m_availBufferEntry;
00291
00292 void addToList(const SoLDM::DataSetIdPair& dsIdPair);
00293 void removeFromList(const SoLDM::DataSetIdPair& dsIdPair);
00294 void setListChange(bool val){m_listChange = val;};
00295 bool m_listChange;
00297
00298 void createLDMCore();
00299 void deleteLDMCore();
00300
00301 void setMinResolutionThreshold();
00302
00307 bool isMultiDataPossible();
00308
00310 bool m_multiDataError;
00311
00313 static int s_debugMediator;
00314
00315 private:
00316 SoLDMDataAccess& getDataAccess ( int id = -1 );
00317 SoLDMDataAccess& getDataAccess ( SoDataSet* ds );
00318
00321 SoLDMResourceManager* getResourceManager(int id);
00322
00323 SoLDMResourceParameters* getResourceParameter( int dataEntry );
00324 SoLDMResourceParameters* getFirstResourceParameter();
00325
00326 private:
00327
00328 bool m_isTileVisitorFixedRes;
00329
00330
00331
00332 typedef std::map<SbThreadId_t, SoLDMDataAccess*> t_dataAccessList;
00333
00334 t_dataAccessList m_ldmDataAccessList;
00335 SbThreadMutex* m_semDataAccessList;
00336
00337 };
00338
00339
00340 SoDataSet*
00341 SoLDMMediator::getFirstDataSet() const
00342 {
00343 if ( m_volumeDataList.empty() )
00344 return NULL;
00345
00346 return m_volumeDataList[0].dsIdPair.first;
00347 }
00348
00349
00350 bool
00351 SoLDMMediator::hasMultiDataError() const
00352 {
00353 return m_multiDataError;
00354 }
00355
00356 inline bool
00357 SoLDMMediator::isAlreadyInFixResMode() const
00358 {
00359 return m_isTileVisitorFixedRes;
00360 }
00361
00362 inline void
00363 SoLDMMediator::useFixedTileVisitor(bool flag)
00364 {
00365 m_isTileVisitorFixedRes = flag;
00366 }
00367
00368 #ifdef _MSC_VER
00369 #pragma warning( pop )
00370 #endif
00371
00372 #endif
00373
00374
00375