Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
SoLDMMediator.h
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2024 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : VSG (MMM YYYY)
22**=======================================================================*/
23#ifndef _SO_MEDIATOR_
24#define _SO_MEDIATOR_
25
26#ifdef _MSC_VER
27#pragma warning( push )
28#pragma warning(disable:4251)
29#endif
30
31#include <Inventor/STL/vector>
32#include <Inventor/SbBox.h>
33#include <LDM/SoLDMTileID.h>
34#include <LDM/SoLDMResourceManager.h>
35#include <LDM/nodes/SoLDMResourceParameters.h>
36
37#include <LDM/SoLDMDataAccess.h>
38
39#include <LDM/elements/SoDataSetElement.h>
40
41
42// LDM
43class SoLDMTileVisitor;
44class SoLDMProximityVisitor;
45class SoLDMMultiIOTileManager;
46class SoLDMNodeFrontManager;
47class SoLDMTextureManager;
48class SoLDMGeometry;
51class LDMDefaultSliceAccessor;
53class SoDataSet;
54class SoState;
55class SoLdmParameterNode;
56class SoBufferObject;
58class SoDataSetId;
59class SoLdmValuationAction;
60class SoLDMTileInfo;
61class SoLDMTileManager;
62class LDMSliceAccessor;
63
64
82{
83public:
85 SoLDMMediator();
86
88 virtual ~SoLDMMediator();
89
90private:
91
92 void registerNode(const SoLDM::DataSetIdPair& dsIdPair, bool sync);
93 void unregisterNode(const SoLDM::DataSetIdPair& dsIdPair, SoLDMMediator *newMediator = NULL);
94
95 void readTile(int dataSetId, SoLDMTileID tileID, unsigned char* buffer, bool transform) ;
96
97 void readTile(const int dataSetId, const SoLDMTileID tileID, SoBufferObject* buffer, const bool transform) ;
98
99 size_t readTile(SoLDMTileInfo* tileInfo, const int dataSetId, bool transform);
100
101 uint64_t getTileSize(int dataSetId, const SoLDMTileID* tileId = NULL)const ;
102 SbVec3i32 getTileDimension()const ;
103
104 const SbVec3i32& getDimension()const ;
105 const SbBox3f& getExtent()const ;
106 int getOverlapping() const
107 {
108 return 0;
109 }
110
111 void renderNotify()const;
112
116 const std::vector<int>& getNumData() const ;
117
118 SbBool getBbox(SoLDMTileID tileID, SbBox3f& box)const;
119 bool getCenter(SoLDMTileID tileID, SbVec3f& center)const;
120
121 //stuff I dont know what to do with yet
122 SbBool getListChange(){return m_listChange;};
123
125 int getDataEntry(unsigned short id)const ;
126 int getDataEntry(SoDataSet*)const ;
127
129 bool hasMultiDataError() const
130 {
131 return m_multiDataError;
132 }
133
135private:
136
138 void registerWithIds(SoDataSet* ds, std::vector<int> ids, bool sync);
139
141 void unregisterAllIds(SoDataSet* ds, SoLDMMediator* newMediator = NULL);
142
144 void unregisterAll();
145
146 SoLDMTileManager* getTileManager() { return m_tileManager; }
147 SoLDMTextureManager* getTextureManager() { return m_textureManager; }
148 SoLDMGeometry* getVVizGeometry() { return m_vvizGeometry; }
149 SoLDMNodeFrontManager* getNodeFrontManager() { return m_nodeFrontManager; }
150
151 LDMSliceAccessor* getSliceAccessor(const SoLDM::DataSetIdPair& p)const;
152 void startRenderTraversal(SoLdmValuationAction*, SoDataSet*);
153
154 void updateRegions(const SbBox3i32* region, int numRegions);
155 /*
156 * This function will only be called if in multiple data mode.
157 * Called to check if the list of SoDataSet currently stored in the state are also in the list
158 * of data set registered to this tile manager (subsequent calls to registerVolumeData).
159 * Allows to detect scene graph change ( e.g. a switch node was turned off, the SoDataSet under
160 * the switch node is still registered in the tile manager but is not part of the state anymore ).
161 * The data compositor present in the state (if any) is also passed to check if it corresponds to the one
162 * used by the tile manager (getVolumeData()->getDataCompositor()).
163 * If any change occured, tile manager's state must be set accordingly.
164 */
165 void checkList(SoAction* action, SoDataCompositor* dc);
166
167 //Return the biggest buffer id in the m_volumeDataList. When a dataset is no more in the
168 //state but is still registered(because of a switch change or a delayed delete in ScaleViz)
169 //this number is different from m_volumeDataList.size()-1. So this is this value which must
170 //be used for SoLDMTileInfo::extendNumBuffer(int).
171 //Ex: bufferIDs(0, 1, 2) -> bufferIDs(0, 2) and m_volumeDataList.size(3) -> m_volumeDataList.size(2)
172 int getBiggestBufferEntry() const;
173
174 //Do a start/endNumDataNotify without sync in order to be sure that SoLDMMultiIOTileManager::loadingThreadRoutine
175 //is running (if there is at least one dataset registered)
176 void restartLoadingThread();
177
178 // SoDataSet ids vectors
179 void updateDataIds() ;
180
181 SoDataSet* getVolumeOfId(unsigned short dataSetId)const;
182 void getVolumeElements(SoLDM::DataSetIdPairList& dsIdPairList) const;
183
185 void getDataSetList(SoLDM::DsVector& dsList) const;
186
188 void getDataSetIds(const SoDataSet* ds, std::vector<int>& ids) const;
189
193 SoDataSet* getFirstDataSet() const
194 {
195 if (m_volumeDataList.empty())
196 return NULL;
197
198 return m_volumeDataList[0].dsIdPair.first;
199 }
200
204 const SoLDM::DataSetIdPair& getFirstDataSetIdPair() const;
205
209 const SoLDM::DataSetIdPairList& getDsIds() const
210 {
211 return m_dataDsIds;
212 }
213
214 //After this call, data handled by this mediator will be loaded by LDM's threads
215 void addToLDM();
216
217 SoDataCompositor* getDataCompositor()const { return m_dc; }
218 void setDataCompositor(SoDataCompositor *dc);
219
221 struct DataSetInfo
222 {
223 SoLDM::DataSetIdPair dsIdPair;
224 int bufferId;
225 };
226 typedef std::vector<DataSetInfo> DataSetInfoList;
227
228 DataSetInfoList & getVolumeDataList();
229
236 bool isAlreadyInFixResMode() const
237 {
238 return m_isTileVisitorFixedRes;
239 }
240
241#if 1 SoDEPRECATED
248 void useFixedTileVisitor(bool flag)
249 {
250 m_isTileVisitorFixedRes = flag;
251 }
252#endif
265 void setTileVisitor( SoLDMTileVisitor* visitor, bool ownedByUser = true );
266
274 void setTileManager( SoLDMTileManager* tilemgr, SbBool ownedByUser = TRUE );
275
279 SoLDMTileVisitor* getTileVisitor()
280 {
281 return m_tileVisitor;
282 }
283
287 bool isTileVisitorOwnedByUser() const { return m_userVisitor; }
288
289private:
290 SoLDMTextureManager* m_textureManager;
291 SoLDMGeometry* m_vvizGeometry;
292 SoDataCompositor* m_dc;
293 SoLDMTileVisitor* m_tileVisitor;
294 SoLDMNodeFrontManager* m_nodeFrontManager;
295 SoLDMTileManager* m_tileManager;
296
297 //for user defined LDM component
298 bool m_userVisitor;
299 SoLDMProximityVisitor* m_internalVisitor;
300 bool m_userTileManager;
301 SoLDMMultiIOTileManager* m_internalTileManager;
302
303 const DataSetInfo& getDataInfo(const SoLDM::DataSetIdPair& dsIdPair) const;
304
305 bool isUsedByLDM() { return m_isUsedByLDM; }
306 void setUsedByLDM(bool flag) { m_isUsedByLDM = flag; }
307 bool m_isUsedByLDM;
308
310 std::vector<int> m_dataIds ;
311 SoLDM::DataSetIdPairList m_dataDsIds;
312
313 std::vector<DataSetInfo> m_volumeDataList;
314 bool isInList(const SoLDM::DataSetIdPair& dsIdPair)const;
315
316 // Available buffer entries (ie id) for data
317 std::vector<int> m_availBufferEntry;
318
319 void addToList(const SoLDM::DataSetIdPair& dsIdPair);
320 void removeFromList(const SoLDM::DataSetIdPair& dsIdPair);
321 void setListChange(bool val){m_listChange = val;};
322 bool m_listChange;
324
325 void createLDMCore();
326 void deleteLDMCore();
327
328 void setMinResolutionThreshold();
329
334 bool isMultiDataPossible();
335
337 bool m_multiDataError;
338
340 static int s_debugMediator;
341
342private:
343 SoLDMDataAccess& getDataAccess ( int id = -1 );
344 SoLDMDataAccess& getDataAccess ( SoDataSet* ds );
345
348 SoLDMResourceManager* getResourceManager(int id);
349
350 SoLDMResourceParameters* getResourceParameter( int dataEntry );
351 SoLDMResourceParameters* getFirstResourceParameter();
352
353private:
354
355 bool m_isTileVisitorFixedRes;
356
357 // We use a map of LDMDataAccess to be able to
358 // support multi thread. One Data Access per thread id
359 typedef std::map<SbThreadId_t, SoLDMDataAccess*> t_dataAccessList;
360
361 t_dataAccessList m_ldmDataAccessList;
362 SbThreadMutex* m_semDataAccessList;
363
364};
365
366#ifdef _MSC_VER
367#pragma warning( pop )
368#endif
369
370#endif
371
372
3D box class.
Definition SbBox.h:649
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> 3D box class.
Definition SbBox.h:96
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Portable mutex c...
Semaphore management.
3D vector class.
Definition SbVec.h:932
3D vector class.
Definition SbVec.h:1517
Abstract base class for all actions.
Definition SoAction.h:132
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Abstract base cl...
<a href="IconLegend.html"><img src="extLDM.gif" alt="Large Data Management" border="0"></a> Data set...
<a href="IconLegend.html"><img src="extLDM.gif" alt="Large Data Management" border="0"></a> Data set...
Definition SoDataSet.h:139
<a href="IconLegend.html"><img src="extLDM.gif" alt="Large Data Management" border="0"></a> Property...
Renders a scene graph using Open Inventor's Render Engine.
<a href="IconLegend.html"><img src="extLDM.gif" alt="Large Data Management" border="0"></a> Volume d...
<a href="IconLegend.html"><img src="extLDM.gif" alt="Large Data Management" border="0"></a> Resource...
<a href="IconLegend.html"><img src="extLDM.gif" alt="Large Data Management" border="0"></a> Defines ...
<a href="IconLegend.html"><img src="extLDM.gif" alt="Large Data Management" border="0"></a> Tile ID
Definition SoLDMTileID.h:63
Traversal state.
Definition SoState.h:74
int SbBool
Boolean type.
Definition SbBase.h:87
std::pair< SoDataSet *, int > DataSetIdPair
Pair containing an SoDataset and its dataSetId.
Definition SoLDM.h:71
std::vector< DataSetIdPair > DataSetIdPairList
List of DataSetIdPair.
Definition SoLDM.h:76
std::vector< SoDataSet * > DsVector
Vector of SoDataSet.
Definition SoLDM.h:56