Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
SoConversion.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-2023 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : VSG (MMM YYYY)
22**=======================================================================*/
23#if !defined SOCONVERSION_H
24#define SOCONVERSION_H
25
26#include <Inventor/SbString.h>
27#include <Inventor/SbDataType.h>
28
29#include <Inventor/STL/vector>
30
31#include <Inventor/algorithms/SoAlgorithmsDefs.h>
32
33#if defined(__i386__) || defined(__amd64__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_AMD64)
34# define HAS_SSE
35#endif
36
37#if ( __GNUC__ == 3 && __GNUC_MINOR__ == 2 )
38#undef HAS_SSE
39#endif
40
41#ifdef HAS_SSE
42# include <mmintrin.h>
43# include <xmmintrin.h>
44# include <emmintrin.h>
45#endif
46
47class SoBufferObject;
49
66{
67private:
69 virtual ~SoConversion();
70
71
73 static void initClass();
74
75
77 static void exitClass();
78
79public:
82
101 virtual int convert(
102 SoBufferObject* sourceBufferObject, const SbDataType src_type,
103 SoBufferObject* targetBufferObject, const SbDataType dst_type, const size_t size );
104
105
112 SoCpuBufferObject* sourceBufferObject, const SbDataType src_type,
113 SoCpuBufferObject* targetBufferObject, const SbDataType dst_type, const size_t size );
114
132 SoBufferObject* sourceBufferObject,
133 SoBufferObject* targetBufferObject,
134 const size_t size, const float dataMin, const float dataMax );
135
136
143 SoCpuBufferObject* sourceBufferObject,
144 SoCpuBufferObject* targetBufferObject,
145 const size_t size, const float dataMin, const float dataMax );
146
147private:
162 int convertToFloat(
163 SoBufferObject* sourceBufferObject, const SbDataType src_type,
164 SoBufferObject* targetBufferObject, const size_t size );
165
166
178 int convertToUChar(
179 SoBufferObject* sourceBufferObject, SbDataType src_type,
180 SoBufferObject* targetBufferObject, const size_t size );
181
182
183private:
184
186 enum MappingMethod {
195 MAP_TO_CENTER,
196
205 MAP_TO_BORDER
206 };
207
211 virtual void mapDataRangeToIndex(
212 SoBufferObject *sourceBufferObject, const SbDataType src_type,
213 SoBufferObject *targetBufferObject, const SbDataType dst_type,
214 const double dataRangeMin, const double dataRangeMax, const bool dataRangeMap,
215 const double undefinedValue = std::numeric_limits<double>::quiet_NaN() );
216
217
221 virtual void mapDataToIndex(
222 SoBufferObject *sourceBufferObject, const SbDataType src_type,
223 SoBufferObject *targetBufferObject, const SbDataType dst_type,
224 const int numSigBits );
225
226
230 virtual void mapDataRangeToRgba(
231 SoBufferObject *sourceBufferObject, const SbDataType src_type,
232 SoBufferObject *targetBufferObject, const SbDataType dst_type,
233 const double dataRangeMin, const double dataRangeMax, const bool dataRangeMap,
234 SoBufferObject *rgbaBufferObject, const int numRgba, MappingMethod rgbaMapping );
235
236
240 virtual void mapDataToRgba(
241 SoBufferObject *sourceBufferObject, const SbDataType src_type,
242 SoBufferObject *targetBufferObject, const SbDataType dst_type,
243 const int numSigBits,
244 SoBufferObject *rgbaBufferObject, const int numRgba, MappingMethod mapping );
245
253 static void convertByteToBitSet(SoBufferObject* sourceBufferObject, SoBufferObject* targetBufferObject);
254
261 static void convertBitSetToByte(SoBufferObject* sourceBufferObject, SoBufferObject* targetBufferObject);
262
267 template <typename DataClassIn>
268 static void cpuMapDataRangeToIndex(const void *srcData, void *dstData,
269 const size_t bufferSize, const SbDataType::DataType dataTypeDst,
270 const double dataRangeMin, const double dataRangeMax, const bool dataRangeMap,
271 const double undefinedValue = std::numeric_limits<double>::quiet_NaN()
272 );
273
278 template <typename DataClassIn, typename DataClassOut>
279 static void cpuMapDataRangeToIndexTempl(
280 const void *src, void *dst, const size_t bufferSize,
281 const double dataRangeMin, const double dataRangeMax, const bool dataRangeMap,
282 const double undefinedValue = std::numeric_limits<double>::quiet_NaN()
283 );
284
289 template <typename DataClassIn, typename DataClassOut>
290 static void cpuMapDataRangeToIndexTemplSSE(
291 const void *src, void *dst, const size_t bufferSize,
292 const double dataRangeMin, const double dataRangeMax, const bool dataRangeMap
293 );
294
299 template <typename DataClassIn>
300 static void cpuMapDataRangeToRgba(
301 const void *src, void *dst, const size_t bufferSize,
302 const double dataRangeMin, const double dataRangeMax, const bool dataRangeMap,
303 const unsigned int *rgba, const int numRgba, MappingMethod mapping
304 );
305
310 template <typename DataClassIn>
311 static void cpuMapDataToIndex(const void *srcData, void *dstData,
312 const size_t bufferSize, const SbDataType::DataType dataTypeDst,
313 const int numSigBits
314 );
315
320 template <typename DataClassIn, typename DataClassOut>
321 static void cpuMapDataToIndexTempl(
322 const void *src, void *dst, const size_t bufferSize,
323 const int numSigBits
324 );
325
330 template <typename DataClassIn>
331 static void cpuMapDataToRgba(
332 const void *src, void *dst, const size_t bufferSize,
333 const int numSigBits,
334 const unsigned int *rgba, const int numRgba, MappingMethod mapping
335 );
336
337private:
338
339 // IN template CPU dataRangeToIndex version
340 template <typename DataClassIn>
341 static void cpuMapDataRangeToIndex(const void *srcData, void *dstData,
342 const size_t bufferSize, const SbDataType::DataType dataTypeDst,
343 const double dataRangeMin, const double dataRangeMax, const bool dataRangeMap,
344 const int shift, const int offset
345 );
346
347
348 // IN/OUT template CPU version
349 template <typename DataClassIn, typename DataClassOut>
350 static void cpuMapDataRangeToIndexTempl(
351 const void *src, void *dst, const size_t bufferSize,
352 const double dataRangeMin, const double dataRangeMax, const bool dataRangeMap,
353 const int shift, const int offset
354 );
355
356#ifdef HAS_SSE
357 // IN/OUT template CPU SSE2 version
358 template <typename DataClassIn, typename DataClassOut>
359 static void cpuMapDataRangeToIndexTemplSSE(
360 const void *src, void *dst, const size_t bufferSize,
361 const double dataRangeMin, const double dataRangeMax, const bool dataRangeMap,
362 const int shift, const int offset
363 );
364
365 template <typename DataClassIn>
366 static void SSE_loadRegister( DataClassIn*& ptr, __m128& reg );
367
368 template <typename DataClassOut>
369 static void SSE_unloadRegister( __m128& regA, __m128& regB, DataClassOut*& ptr );
370#endif
371
372 // IN template CPU dataRangeToRgba version
373 template <typename DataClassIn>
374 static void cpuMapDataRangeToRgba(
375 const void *src, void *dst, const size_t bufferSize,
376 const double dataRangeMin, const double dataRangeMax, const bool dataRangeMap,
377 const int shift, const int offset,
378 const unsigned int *rgba, const int numRgba, MappingMethod mapping
379 );
380
381
382 // IN template CPU dataToIndex version
383 template <typename DataClassIn>
384 static void cpuMapDataToIndex(const void *srcData, void *dstData,
385 const size_t bufferSize, const SbDataType::DataType dataTypeDst,
386 const int numSigBits, const int shift, const int offset
387 );
388
389
390 // IN/OUT template CPU version
391 template <typename DataClassIn, typename DataClassOut>
392 static void cpuMapDataToIndexTempl(
393 const void *src, void *dst, const size_t bufferSize,
394 const int numSigBits, const int shift, const int offset
395 );
396
397
398 // IN template CPU dataToRgba version
399 template <typename DataClassIn>
400 static void cpuMapDataToRgba(
401 const void *src, void *dst, const size_t bufferSize,
402 const int numSigBits, const int shift, const int offset,
403 const unsigned int *rgba, const int numRgba, MappingMethod mapping
404 );
405
406private:
407#if defined(HAS_SSE)
408 static void convertBitSetToByteSSE(unsigned char* packedTile, unsigned char* unpackedTile, uint64_t size);
409#endif
410 static void convertBitSetToByteStd(unsigned char* packedTile, unsigned char* unpackedTile, uint64_t size);
411
412
413 static bool s_useSSE;
414
415};
416
417#endif //SOCONVERSION_H
418
Class encoding a data type.
Definition SbDataType.h:58
DataType
Supported Data type.
Definition SbDataType.h:64
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Abstract base cl...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Type conversion ...
int convertFloatToRGBA(SoCpuBufferObject *sourceBufferObject, SoCpuBufferObject *targetBufferObject, const size_t size, const float dataMin, const float dataMax)
Convert FLOAT data stored in a buffer to RGBA data.
virtual int convertFloatToRGBA(SoBufferObject *sourceBufferObject, SoBufferObject *targetBufferObject, const size_t size, const float dataMin, const float dataMax)
Convert FLOAT data stored in a buffer to (grayscale) RGBA data.
SoConversion()
SoConversion constructor.
virtual int convert(SoBufferObject *sourceBufferObject, const SbDataType src_type, SoBufferObject *targetBufferObject, const SbDataType dst_type, const size_t size)
Convert the data in a buffer object from one data type to another one.
int convert(SoCpuBufferObject *sourceBufferObject, const SbDataType src_type, SoCpuBufferObject *targetBufferObject, const SbDataType dst_type, const size_t size)
Convert the data in a buffer object from one data type to another one.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> CPU buffer objec...