Coin Logo http://www.sim.no
http://www.coin3d.org

SoVolumeData.h

00001 #ifndef SIMVOLEON_SOVOLUMEDATA_H
00002 #define SIMVOLEON_SOVOLUMEDATA_H
00003 
00004 /**************************************************************************\
00005  *
00006  *  This file is part of the SIM Voleon visualization library.
00007  *  Copyright (C) 2003-2004 by Systems in Motion.  All rights reserved.
00008  *
00009  *  This library is free software; you can redistribute it and/or
00010  *  modify it under the terms of the GNU General Public License
00011  *  ("GPL") version 2 as published by the Free Software Foundation.
00012  *  See the file LICENSE.GPL at the root directory of this source
00013  *  distribution for additional information about the GNU GPL.
00014  *
00015  *  For using SIM Voleon with software that can not be combined with
00016  *  the GNU GPL, and for taking advantage of the additional benefits
00017  *  of our support services, please contact Systems in Motion about
00018  *  acquiring a SIM Voleon Professional Edition License.
00019  *
00020  *  See <URL:http://www.coin3d.org/> for more information.
00021  *
00022  *  Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY.
00023  *  <URL:http://www.sim.no/>.
00024  *
00025 \**************************************************************************/
00026 
00027 #include <Inventor/fields/SoSFString.h>
00028 #include <Inventor/fields/SoSFEnum.h>
00029 #include <Inventor/fields/SoSFBool.h>
00030 #include <Inventor/fields/SoSFVec3f.h>
00031 #include <Inventor/SbVec3f.h>
00032 #include <Inventor/SbVec3s.h>
00033 #include <Inventor/SbBox3f.h>
00034 #include <Inventor/SbBox3s.h>
00035 #include <Inventor/SbBox2s.h>
00036 #include <Inventor/SbBox2f.h>
00037 #include <VolumeViz/nodes/SoVolumeRendering.h>
00038 #include <Inventor/nodes/SoSubNode.h>
00039 
00040 class SoVolumeReader;
00041 class SoState;
00042 class SoTransferFunction;
00043 
00044 
00045 class SIMVOLEON_DLL_API SoVolumeData : public SoVolumeRendering {
00046   typedef SoVolumeRendering inherited;
00047 
00048   SO_NODE_HEADER(SoVolumeData);
00049 
00050 public:
00051   static void initClass(void);
00052   SoVolumeData(void);
00053 
00054   enum StorageHint {
00055     AUTO,
00056     TEX2D_MULTI,
00057     TEX2D = TEX2D_MULTI,
00058     TEX3D,
00059     MEMORY,
00060     VOLUMEPRO,
00061     TEX2D_SINGLE
00062   };
00063 
00064   enum SubMethod { NEAREST, MAX, AVERAGE };
00065   enum OverMethod { NONE, CONSTANT, LINEAR, CUBIC };
00066 
00067   enum DataType { UNSIGNED_BYTE, UNSIGNED_SHORT };
00068 
00069   SoSFString fileName;
00070   SoSFEnum storageHint;
00071   SoSFBool usePalettedTexture;
00072   SoSFBool useSharedPalettedTexture;
00073   SoSFBool useCompressedTexture;
00074 
00075   void setVolumeData(const SbVec3s & dimension, void * data,
00076                      SoVolumeData::DataType type = SoVolumeData::UNSIGNED_BYTE,
00077                      int significantbits = 0);
00078   SbBool getVolumeData(SbVec3s & dimension, void *& data,
00079                        SoVolumeData::DataType & type,
00080                        int * significantbits = NULL) const;
00081 
00082   uint32_t getVoxelValue(const SbVec3s & voxelpos) const;
00083 
00084   void setVolumeSize(const SbBox3f & size);
00085   SbBox3f getVolumeSize(void) const;
00086 
00087   void setPageSize(int size);
00088   void setPageSize(const SbVec3s & size);
00089   const SbVec3s & getPageSize(void) const;
00090 
00091   void setReader(SoVolumeReader & reader);
00092   SoVolumeReader * getReader(void) const;
00093 
00094   void setTexMemorySize(int megatexels);
00095   int getTexMemorySize(void) const;
00096 
00097   SbBool getMinMax(int & minval, int & maxval);
00098   SbBool getHistogram(int & length, int *& histogram);
00099 
00100   SoVolumeData * subSetting(const SbBox3s & region);
00101   void updateRegions(const SbBox3s * region, int num);
00102   void loadRegions(const SbBox3s * region, int num, SoState * state, SoTransferFunction * node);
00103 
00104   SoVolumeData * reSampling(const SbVec3s & dimension,
00105                             SoVolumeData::SubMethod subMethod,
00106                             SoVolumeData::OverMethod = NONE);
00107 
00108   void enableSubSampling(SbBool enable);
00109   SbBool isSubSamplingEnabled(void) const;
00110 
00111   void enableAutoSubSampling(SbBool enable);
00112   SbBool isAutoSubSamplingEnabled(void) const;
00113 
00114   void enableAutoUnSampling(SbBool enable);
00115   SbBool isAutoUnSamplingEnabled(void) const;
00116 
00117   void unSample(void);
00118 
00119   void setSubSamplingMethod(SubMethod method);
00120   SubMethod getSubSamplingMethod(void) const;
00121 
00122   void setSubSamplingLevel(const SbVec3s & roi, const SbVec3s & secondary);
00123   void getSubSamplingLevel(SbVec3s & roi, SbVec3s & secondary) const;
00124 
00125 
00126 protected:
00127   ~SoVolumeData();
00128 
00129   virtual void doAction(SoAction * action);
00130   virtual void GLRender(SoGLRenderAction * action);
00131   virtual void callback(SoCallbackAction * action);
00132   virtual void getBoundingBox(SoGetBoundingBoxAction * action);
00133   virtual void pick(SoPickAction * action);
00134 
00135 private:
00136   friend class SoVolumeDataP;
00137   class SoVolumeDataP * pimpl;
00138 
00139   // These were added to make it possible to control the world-space
00140   // volume size from an iv-file. They basically provide the same
00141   // functionality as the setVolumeSize()/getVolumeSize() functions.
00142   SoSFVec3f volumeboxmin;
00143   SoSFVec3f volumeboxmax;
00144 };
00145 
00146 #endif // !SIMVOLEON_SOVOLUMEDATA_H

Copyright © 1998-2004 by Systems in Motion AS. All rights reserved.

Generated on Wed Feb 21 02:26:21 2007 for SIMVoleon by Doxygen. 1.4.6