00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _SO_VOLUME_DATA_
00024 #define _SO_VOLUME_DATA_
00025
00026 #ifdef _MSC_VER
00027 #pragma warning( push )
00028 #pragma warning(disable:4251)
00029 #endif
00030
00031 #include <Inventor/STL/map>
00032 #include <Inventor/STL/vector>
00033
00034 #include <Inventor/SbBox.h>
00035 #include <Inventor/SbPList.h>
00036 #include <Inventor/fields/SoSFBool.h>
00037 #include <Inventor/fields/SoSFEnum.h>
00038 #include <Inventor/fields/SoSFMemObj.h>
00039 #include <Inventor/fields/SoSFString.h>
00040 #include <Inventor/fields/SoSFUShort.h>
00041 #include <Inventor/fields/SoSFInt32.h>
00042 #include <Inventor/fields/SoSFArray3D.h>
00043
00044 #include <LDM/SoLDMDataAccess.h>
00045 #include <LDM/SoLDMMediator.h>
00046 #include <LDM/SoLDMTileID.h>
00047 #include <LDM/nodes/SoDataSet.h>
00048 #include <LDM/nodes/SoTransferFunction.h>
00049 #include <LDM/readers/SoVolumeReader.h>
00050
00051 #include <VolumeViz/nodes/SoVolumeRendering.h>
00052
00053 class SoGLRenderAction;
00054 class SoCallbackAction;
00055 class SoWriteAction;
00056 class SoVolumeReader;
00057 class SoCache;
00058 class SoState;
00059 class SoGLVolCacheList;
00060 class SoVolumeHistogram;
00061 class SoDataCompositor;
00062 class SoVolumeShader;
00063 class SoVolumeState;
00064
00065
00066 class SoLDMTileManager;
00067 class SoLDMTileVisitor;
00068 class SoLDMNodeFrontManager;
00069 class SoLDMTextureManager;
00070 class SoLDMGeometry;
00071 class SoLDMResourceManager;
00072
00073
00074 class SoDataExtract;
00075 class LDMDefaultSliceAccessor;
00076 class SoVolumeData;
00077
00078 SO_PIMPL_PUBLIC_DECLARATION(SoVolumeData)
00079
00080
00726 class SoVolumeData : public SoDataSet, public SoVolumeRendering
00727 {
00728 SO_NODE_HEADER( SoVolumeData );
00729
00730 SO_PIMPL_PUBLIC_HEADER( SoVolumeData );
00731
00732 public:
00733 using SoDataSet::getTexData;
00734
00735
00736 typedef SoLDMDataAccess LDMDataAccess;
00737 typedef ::SoLDMResourceParameters SoLDMResourceParameters;
00738
00742 SoVolumeData();
00743
00769 SoSFBool usePalettedTexture;
00770
00771
00781 SoSFBool useSharedPalettedTexture;
00782
00791 SoSFBool useExtendedData;
00792
00816 SoSFArray3D data;
00817
00834 SoSFBool dataRGBA;
00835
00837 virtual SbBool getMinMax( int64_t &min, int64_t &max);
00838
00840 virtual SbBool getMinMax( double &min, double &max);
00841
00883 SbBool getHistogram( int &length, int64_t* &histogram);
00884
00893 void updateRegions(const SbBox3i32 *region, int num_regions);
00894
00902 void updateTilesInTextureMemory(SoLDMTileID* tiles, int numTiles);
00903
00909 void setRGBAData(const bool flag);
00910
00914 enum CoordinateType {
00918 COORDINATES_UNIFORM = SoVolumeReader::COORDINATES_UNIFORM,
00922 COORDINATES_RECTILINEAR = SoVolumeReader::COORDINATES_RECTILINEAR
00923 };
00924
00925 CoordinateType getCoordinateType() const;
00926
00932 enum Axis {
00933 X,
00934 Y,
00935 Z
00936 };
00937
00943 const std::vector<float>& getRectilinearCoordinates(Axis axis) const;
00944
00946 virtual SbBool startEditing(int &transactionId );
00947
00949 virtual int editTile( const SoLDMTileID& tileId, SoBufferObject* userData );
00950
00952 virtual int editSubVolume( const SbBox3i32& subVolume, SoBufferObject* userData );
00953
00955 virtual int editTile( const SoLDMTileID& tileId, const double& value );
00956
00958 virtual int editSubVolume( const SbBox3i32& subVolume, const double& value );
00959
00961 virtual int editSurfaceShape( const SoNode* surfaceShape, const float& thickness, const double& newValue );
00962
00964 virtual int editSolidShape( const SoNode* solidShape, const double& value );
00965
00967 virtual int editBoxes(
00968 const std::vector<SbVec3i32>& boxCenters,
00969 const int& boxSize,
00970 const double& newValue
00971 );
00972
00974 virtual SbBool finishEditing(int transactionId);
00975
00977 virtual SbBool undoEditing( int transactionId );
00978
00980 virtual SbBool redoEditing( int transactionId );
00981
00983 virtual SbBool saveEditing(bool recomputeLowerResolution = TRUE, const std::vector<char*> convertionParameters = std::vector<char*>(), SaveEditingCB* callback = NULL );
00984
00985 #if 1 SoDEPRECATED enum
00993 StorageHint {
00995 AUTO,
00997 TEX2D_MULTI,
00999 TEX2D = TEX2D_MULTI,
01001 TEX3D,
01003 MEMORY,
01004 #ifndef HIDDEN_FROM_DOC
01005
01006 VOLUMEPRO,
01008 TEX2D_SINGLE
01009 #endif // HIDDEN_FROM_DOC
01010 };
01011
01012 #endif
01015 #if 1 SoDEPRECATED enum
01021 SubMethod {
01023 NEAREST,
01025 MAX,
01027 AVERAGE
01028 };
01029 SoDEPRECATED enum
01034 OverMethod {
01036 NONE,
01038 CONSTANT,
01040 LINEAR,
01042 CUBIC
01043 };
01044 SoDEPRECATED
01057 SoVolumeData *reSampling( const SbVec3i32 &dimension, SoVolumeData::SubMethod subMethod, SoVolumeData::OverMethod = NONE);
01058 SoDEPRECATED
01064 SoVolumeData *subSetting( const SbBox3i32 ®ion );
01065 SoDEPRECATED
01070 void setTexMemorySize(int size);
01071 SoDEPRECATED
01076 int getTexMemorySize();
01077
01078 #endif
01080 private:
01081
01082 virtual void doAction( SoAction *action );
01083 virtual void GLRender( SoGLRenderAction *action );
01084 virtual void useFakeData(SoLDMTileID tileID, SoBufferObject* bufferObject);
01085
01086
01087
01088 virtual int32_t getRenderUnitID() const;
01089
01090 private:
01091
01093 SbVec3d getVoxelSize() const;
01094
01095 virtual void updateTile( const SbBox3i32 ®ion, const SoLDMTileID& tileId );
01096 virtual void drawTilesInMainMemory(SoGLRenderAction* action, const SoLDM::DataSetIdPair& idPair);
01097
01098 enum Cmd{
01099 CREATE_NODE,
01100 UPDATE_REGIONS,
01101 SET_LDM,
01102 SET_PAGING
01103 };
01104
01108 virtual void notify(SoNotList *list);
01109
01110 int64_t getValue (SbVec3i32 &pos, SbBool real = FALSE);
01111 double getValueD(const SbVec3i32 &pos, SbBool real = FALSE);
01112 int64_t loadDataValue(void* value, const SbVec3i32 &pos, void*& data, SoBufferObject *dataBufferObject, SbBool real);
01113
01114 static void initClass();
01115 static void exitClass();
01116
01117 virtual void updateColorTable(SoState *, SoTransferFunction *);
01118 void loadData(SoAction* action, SbBool& texLoadedOrReloaded);
01119
01120 SoTransferFunction::GLColorMapType getColorMapType(SoState*);
01121 SbVec3i32& getDimensionPowerOf2();
01122 SbVec3f& getTexRatio();
01123
01124
01125 void setLighting(SoState* state, SbBool);
01126 void setLightDirection(SoState* state,const SbVec3f&);
01127 void setLightIntensity(SoState* state,float);
01128
01129 virtual bool isPalettedTexture(SoState* state);
01130 int isSharedPalettedTexture();
01131
01133 void getVolumeTexGen(SbVec4d texGen[3]) const;
01134
01136 SbMatrix getVolumeTexGen() const;
01137
01139 SbVec3f getVolumeTextureRatio() const;
01140
01142 SbBox3f toTextureSpace(const SbBox3f& bbox) const;
01143
01144 void drawOctree(SoGLRenderAction* pGLRA);
01145
01146
01147 virtual int getTexPrec(SoState*state);
01148
01149 virtual void getDataOneObliqueSlice( const SbVec3i32& tileSize, SoBufferObject* tileData, int Zaxis, const SbPlane& plane, SoBufferObject* slicedata, int interp );
01150 virtual SoBufferObject* getDataOneSlice( const SbVec3i32& tileSize, SoBufferObject* tileData, int Zaxis, int slice);
01151
01152 SbBox3f getLDMOutliningBox();
01153
01158 virtual SoBufferObject *getTransformedTile(const SoLDMTileID& tile,
01159 const SoLDM::DataSetIdPair& p,
01160 SoState * state=NULL,
01161 const bool useExtendedData = false);
01162
01163
01166 SbBool saveEditing( SoVolumeWriter* writer, SaveEditingCB* callback = NULL );
01167
01171 const std::vector<float>& getInvertedRectilinearCoordinates(Axis axis) const;
01172
01176 virtual void drawXYZBox( SoGLRenderAction* action, BoxColor color, const SbBox3f& box );
01177
01181 virtual void drawIJKBox( SoGLRenderAction* action, BoxColor color, const SbBox3f& box, const SoLDMTileID& tile, bool subTile = false );
01182 virtual void drawIJKBox( SoGLRenderAction* action, BoxColor color, const SbBox3f& box, bool fullRes, bool subTile = false );
01183 virtual void drawIJKBox( SoGLRenderAction* action, BoxColor color, const SbBox3f& box, bool subTile = false );
01184
01185 void setupRectilinearCoordinates(const SbVec3i32&);
01186 bool isRectilinearCoordinatesUpdated(const SoVolumeShader* s);
01187 void resetRectilinearCoordinatesUpdated(const SoVolumeShader* s);
01188
01189 SbVec3f computeRectilinearCoordinate(const SbVec3f& vertex);
01190 SbBox3f computeRectilinearCoordinate(const SbBox3f& box);
01191
01192 SbVec3f computeInvertedRectilinearCoordinate(const SbVec3f& vertex) const;
01193 SbBox3f computeInvertedRectilinearCoordinate(const SbBox3f& box);
01194
01195 void setDefaultValue( const double defValue );
01196 double getDefaultValue() const;
01197
01201 SbBox3f getXYZCoordinates(const SbBox3i32& box, const SbBox3i32& cropped);
01202
01207 SbBox3f getSubtileXYZCoordinates(const SbBox3i32& fullTileBox,
01208 const SbBox3i32& subTileBox,
01209 const SbBox3i32& cropped);
01210
01211 virtual LDMSliceAccessor* getAppropriateSliceAccessor( const SoLDM::DataSetIdPair& p );
01212
01213 virtual SoLDMReader* getAppropriateLDMReader( const SbString& pathname);
01214
01215 private:
01216
01221 virtual void readerChanged();
01222
01226 virtual void setElement(SoState* state);
01227
01228 virtual SoVolumeReader *getAppropriateReader();
01229
01230
01231 virtual ~SoVolumeData();
01232 void releaseMemory();
01233
01234 virtual bool enableMultidata(SoState* state);
01235
01239 virtual void unload();
01240
01244 virtual void updateFilename();
01245
01249 virtual SbBool isRGBAData();
01250
01252 virtual void buildTile(SoLDMTileID tileID, SoBufferObject* buffer);
01253
01255 virtual void computeLighting( const SbVec3i32 & tileSize, SoBufferObject* rgbaBuffer );
01256
01257 SoINTERNAL private:
01258
01260 virtual SoLDMGeomElement* getAppropriateElement( SoLDMGeometry* v );
01261
01262 private:
01263
01265 void commonConstructor();
01266
01267 #if 1 SoDEPRECATED
01269 void updateColorTable( SoState *, SoVolumeData::StorageHint textype, SoTransferFunction * );
01270 #endif SoDEPRECATED
01273 SoSFEnum storageHint;
01274
01275
01277 SoSFInt32 volumeDataId;
01278
01279 friend class ::SoVolumeState;
01280 };
01281
01282 #ifdef _MSC_VER
01283 #pragma warning( pop )
01284 #endif
01285
01286 #endif // _SO_VOLUME_DATA_
01287
01288
01289