Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
SoVRRasterStackReader.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 : C. Ognier (Jul 2005)
22**=======================================================================*/
23#ifndef _SO_VR_RASTER_STACK_READER_
24#define _SO_VR_RASTER_STACK_READER_
25
26#ifdef _WIN32
27#pragma warning( push )
28#pragma warning(disable:4251)
29#endif
30
31#include <LDM/readers/SoVolumeReader.h>
32#include <Inventor/helpers/SbFileHelper.h>
33#include <Inventor/image/SoRasterImageFile.h>
34#include <Inventor/image/SoRasterReaderSet.h>
35#include <Inventor/image/SoRasterImageRW.h>
36#include <Inventor/image/SbRasterImage.h>
37#include <Inventor/STL/vector>
38#include <Inventor/STL/string>
39#include <VolumeViz/nodes/SoVolumeData.h>
40
115 {
116 SO_FIELDCONTAINER_HEADER(SoVRRasterStackReader);
117
118 public:
119
125 MAX_CHANNEL = 0, // Maximum of all channels
129 LUMINANCE = 1, // Luminance
133 RED_CHANNEL = 2, // Red channel
137 GREEN_CHANNEL = 3, // Green channel
141 BLUE_CHANNEL = 4, // Blue channel
145 ALPHA_CHANNEL = 5, // Alpha channel
149 ALL_CHANNELS = 11 // All channels combined
150 };
151
154
159 virtual int setFilename(const SbString& filename);
160
168 SbBool setFilenameList(const SbStringList& filenameList);
169
186 SbBool setDirectory(const SbString& directory);
187
191 virtual ReadError getDataChar(SbBox3f& size, SoDataSet::DataType& type, SbVec3i32& dim) override;
192
196 virtual void getSubSlice(const SbBox2i32& subSlice, int sliceNumber, void* data);
197
201 void setSize(SbBox3f& size) {m_size = size;};
202
206 void setChannelSelection(ChannelSelection cs) {m_channelSelection = cs;};
207
212
216 virtual SbBool isRGBA() const;
217
221 virtual SbBool isThreadSafe() const;
222
223private:
224
225 int extractFileList(const SbString& headFile);
226 SbBool extractParameters(const char* lineStr);
227
228 SoDataSet::DataType findOutDestType(const SbRasterImage::Components nc, const unsigned int numComponent);
229
230 void RGBA2HLS(SbVec3f& hls, float* rgba);
231
232 float convertFloat(float value);
233 short convertShort(short value);
234 int32_t convertInt32(int32_t value);
235 unsigned short convertUShort(unsigned short value);
236 uint32_t convertUInt32(uint32_t value);
237 SbBool needEndianConversion();
238
239 int getChannelId(const char* channel);
240
241 template <typename T>
242 void getSubSliceInternal(const SbBox2i32 &subSlice, int sliceNumber, void* data);
243
244 template <typename TSRC, typename T>
245 void convertSubSliceInternal(TSRC* srcData, const SbVec2i32 srcSize, const unsigned int srcNumComponent, std::vector<T>& dstVector);
246
254 SbBool readImage(int numImage, SbRasterImage& rasterImage, const SbBox2i32& region, SbBool infoOnly);
255
256 template <typename T>
257 void getSingleChannelData(std::vector<T> srcVector, SbVec2i32& size2s,
258 unsigned int xMin, unsigned int xMax,
259 unsigned int yMin, unsigned int yMax,
260 void* data);
261
262 template <typename T>
263 T endianConverter(const T value);
264
265 SbString m_listDirectory;
266 SbBox3f m_size;
267 SbVec3i32 m_dim;
268 SbBool m_isRawData;
269 unsigned int m_nc;
270 SoDataSet::DataType m_srcType;
271 SoDataSet::DataType m_destType;
272 ChannelSelection m_channelSelection;
273 std::vector< SbString > m_fileList;
274 unsigned int m_rawHeaderSize;
275 SbBool m_rawIsBigEndian;
276 SbBool m_rawIsBinary;
277
278private:
279
280 bool m_isInitialized;
281
282 /*
283 * Internal function to read a region of a raw file into a SbRasterImage
284 * @return success
285 */
286 template <typename T>
287 SbBool readRawBuffer(FILE* fp, SbRasterImage& rasterImage, const SbBox2i32& region);
288};
289
290#ifdef _WIN32
291#pragma warning( pop )
292#endif
293
294#endif /* _SO_VR_RASTER_STACK_READER_ */
295
2D box class.
Definition SbBox.h:2383
3D box class.
Definition SbBox.h:649
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Class encapsulat...
Components
Components type.
Class for smart character strings.
Definition SbString.h:202
Maintains a list of pointers to SbString instances.
2D vector class.
Definition SbVec.h:517
3D vector class.
Definition SbVec.h:932
3D vector class.
Definition SbVec.h:1517
DataType
Supported data type.
Definition SoDataSet.h:664
<a href="IconLegend.html"><img src="extVR.gif" alt="VolumeViz" border="0"></a> Raster stack reader.
virtual ReadError getDataChar(SbBox3f &size, SoDataSet::DataType &type, SbVec3i32 &dim) override
Gets the characteristics (file header) of the data volume.
SbBool setDirectory(const SbString &directory)
Specify a directory containing image files to load (jpg, png, tif,...).
SbBool setFilenameList(const SbStringList &filenameList)
Specify a list of files to load.
virtual SbBool isRGBA() const
Returns TRUE if the data set contains RGBA color values.
virtual SoVolumeReader::ReaderType getReaderType()
Returns the reader type.
SoVRRasterStackReader()
Constructor.
void setSize(SbBox3f &size)
Defines the bounding box size in physical units of the data set.
void setChannelSelection(ChannelSelection cs)
Selects channels to be used for data rendering.
virtual SbBool isThreadSafe() const
Return true as this reader is thread safe.
virtual int setFilename(const SbString &filename)
Specifies the path of the descriptive (.lst) file.
ChannelSelection
Channel selection.
@ MAX_CHANNEL
Maximum of all channels.
@ ALL_CHANNELS
All channels combined.
virtual void getSubSlice(const SbBox2i32 &subSlice, int sliceNumber, void *data)
Must copy the rectangular part defined by subSlice of the XY slice sliceNumber to the memory refe...
<a href="IconLegend.html"><img src="extLDM.gif" alt="Large Data Management" border="0"></a> Abstract...
ReaderType
Available reader type.
@ RASTERSTACK
Raster Stack.
ReadError
Read error.
int SbBool
Boolean type.
Definition SbBase.h:87