Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://coin3d.github.io
https://www.kongsberg.com/en/kogt/
SoVolumeData.h
1 #ifndef SIMVOLEON_SOVOLUMEDATA_H
2 #define SIMVOLEON_SOVOLUMEDATA_H
3 
4 /**************************************************************************\
5  * Copyright (c) Kongsberg Oil & Gas Technologies AS
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are
10  * met:
11  *
12  * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  *
19  * Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from
21  * this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 \**************************************************************************/
35 
36 #include <Inventor/fields/SoSFString.h>
37 #include <Inventor/fields/SoSFEnum.h>
38 #include <Inventor/fields/SoSFBool.h>
39 #include <Inventor/fields/SoSFVec3f.h>
40 #include <Inventor/SbVec3f.h>
41 #include <Inventor/SbVec3s.h>
42 #include <Inventor/SbBox3f.h>
43 #include <Inventor/SbBox3s.h>
44 #include <Inventor/SbBox2s.h>
45 #include <Inventor/SbBox2f.h>
46 #include <VolumeViz/nodes/SoVolumeRendering.h>
47 #include <Inventor/nodes/SoSubNode.h>
48 
49 class SoVolumeReader;
50 class SoState;
51 class SoTransferFunction;
52 
53 
54 class SIMVOLEON_DLL_API SoVolumeData : public SoVolumeRendering {
56 
58 
59 public:
60  static void initClass(void);
61  SoVolumeData(void);
62 
63  enum StorageHint {
64  AUTO,
65  TEX2D_MULTI,
66  TEX2D = TEX2D_MULTI,
67  TEX3D,
68  MEMORY,
69  VOLUMEPRO,
70  TEX2D_SINGLE
71  };
72 
73  enum SubMethod { NEAREST, MAX, AVERAGE };
74  enum OverMethod { NONE, CONSTANT, LINEAR, CUBIC };
75 
76  enum DataType { UNSIGNED_BYTE, UNSIGNED_SHORT };
77 
78  SoSFString fileName;
79  SoSFEnum storageHint;
83 
84  void setVolumeData(const SbVec3s & dimension, void * data,
85  SoVolumeData::DataType type = SoVolumeData::UNSIGNED_BYTE,
86  int significantbits = 0);
87  SbBool getVolumeData(SbVec3s & dimension, void *& data,
88  SoVolumeData::DataType & type,
89  int * significantbits = NULL) const;
90 
91  uint32_t getVoxelValue(const SbVec3s & voxelpos) const;
92 
93  void setVolumeSize(const SbBox3f & size);
94  SbBox3f getVolumeSize(void) const;
95 
96  void setPageSize(int size);
97  void setPageSize(const SbVec3s & size);
98  const SbVec3s & getPageSize(void) const;
99 
100  void setReader(SoVolumeReader & reader);
101  SoVolumeReader * getReader(void) const;
102 
103  void setTexMemorySize(int megatexels);
104  int getTexMemorySize(void) const;
105 
106  SbBool getMinMax(int & minval, int & maxval);
107  SbBool getHistogram(int & length, int *& histogram);
108 
109  SoVolumeData * subSetting(const SbBox3s & region);
110  void updateRegions(const SbBox3s * region, int num);
111  void loadRegions(const SbBox3s * region, int num, SoState * state, SoTransferFunction * node);
112 
113  SoVolumeData * reSampling(const SbVec3s & dimension,
114  SoVolumeData::SubMethod subMethod,
115  SoVolumeData::OverMethod = NONE);
116 
117  void enableSubSampling(SbBool enable);
118  SbBool isSubSamplingEnabled(void) const;
119 
120  void enableAutoSubSampling(SbBool enable);
121  SbBool isAutoSubSamplingEnabled(void) const;
122 
123  void enableAutoUnSampling(SbBool enable);
124  SbBool isAutoUnSamplingEnabled(void) const;
125 
126  void unSample(void);
127 
128  void setSubSamplingMethod(SubMethod method);
129  SubMethod getSubSamplingMethod(void) const;
130 
131  void setSubSamplingLevel(const SbVec3s & roi, const SbVec3s & secondary);
132  void getSubSamplingLevel(SbVec3s & roi, SbVec3s & secondary) const;
133 
134 
135 protected:
136  ~SoVolumeData();
137 
138  virtual void doAction(SoAction * action);
139  virtual void GLRender(SoGLRenderAction * action);
140  virtual void callback(SoCallbackAction * action);
141  virtual void getBoundingBox(SoGetBoundingBoxAction * action);
142  virtual void pick(SoPickAction * action);
143 
144 private:
145  friend class SoVolumeDataP;
146  class SoVolumeDataP * pimpl;
147 
148  // These were added to make it possible to control the world-space
149  // volume size from an iv-file. They basically provide the same
150  // functionality as the setVolumeSize()/getVolumeSize() functions.
151  SoSFVec3f volumeboxmin;
152  SoSFVec3f volumeboxmax;
153 };
154 
155 #endif // !SIMVOLEON_SOVOLUMEDATA_H
SoSFBool usePalettedTexture
Definition: SoVolumeData.h:80
#define SO_NODE_HEADER(classname)
SoSFBool useCompressedTexture
Definition: SoVolumeData.h:82
SoSFBool useSharedPalettedTexture
Definition: SoVolumeData.h:81
The main interface for setting up volume data sets.
Definition: SoVolumeData.h:54
static void initClass(void)
Definition: VolumeRendering.cpp:373
Abstract base class for all nodes related to volume rendering.
Definition: SoVolumeRendering.h:41
virtual void pick(SoPickAction *action)
virtual void doAction(SoAction *action)
Contains the transfer function definition.
Definition: SoTransferFunction.h:44
Abstract superclass for all volume data reader classes.
Definition: SoVolumeReader.h:43
virtual void getBoundingBox(SoGetBoundingBoxAction *action)
virtual void GLRender(SoGLRenderAction *action)
virtual void callback(SoCallbackAction *action)