00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef _SO_DATA_SET_
00028 #define _SO_DATA_SET_
00029
00030 #ifdef _MSC_VER
00031 #pragma warning( push )
00032 #pragma warning(disable:4251)
00033 #endif
00034
00035
00036 #include <Inventor/SbBox.h>
00037 #include <Inventor/SbLinear.h>
00038 #include <Inventor/fields/SoSFBool.h>
00039 #include <Inventor/fields/SoSFBox3f.h>
00040 #include <Inventor/fields/SoSFEnum.h>
00041 #include <Inventor/fields/SoSFFieldContainer.h>
00042 #include <Inventor/fields/SoSFFilePathString.h>
00043 #include <Inventor/fields/SoSFFloat.h>
00044 #include <Inventor/SbDataType.h>
00045 #include <Inventor/fields/SoSFInt32.h>
00046 #include <Inventor/fields/SoSFNode.h>
00047 #include <Inventor/fields/SoSFString.h>
00048 #include <Inventor/fields/SoSFUShort.h>
00049 #include <Inventor/misc/SoMemoryObject.h>
00050 #include <Inventor/misc/SoRef.h>
00051 #include <Inventor/nodes/SoNode.h>
00052 #include <LDM/SoLDM.h>
00053 #include <LDM/SoLDMMediator.h>
00054 #include <LDM/SoLDMTileID.h>
00055 #include <LDM/fields/SoSFLDMResourceParameters.h>
00056 #include <LDM/fields/SoSFLDMDataTransform.h>
00057 #include <LDM/nodes/SoLDMResourceParameters.h>
00058 #include <LDM/nodes/SoTransferFunction.h>
00059 #include <LDM/tiles/SoCpuBufferUniform.h>
00060 #include <Inventor/sys/SoGLType.h>
00061
00062
00063 #include <Inventor/devices/SoCpuBufferObject.h>
00064
00065 class SoGLRenderAction;
00066 class SoCallbackAction;
00067 class SoWriteAction;
00068 class SoState;
00069 class SoLDMGeomElement;
00070 class SoLDMGeometry;
00071 class SoLDMReader;
00072 class SoTransferFunction;
00073 class SoMultiDataSeparator;
00074 class SoVolumeHistogram;
00075 class SoVolumeReader;
00076 class SoPerfCounterManager;
00077 class SoPerfCounter;
00078 class SoBufferObject;
00079 class SoCpuBufferUniform;
00080 class SoGLTexture;
00081 class SoCache;
00082
00083 class SoDataExtract;
00084 class SoConversion;
00085 class SoAlgorithms;
00086 class SoLDMAlgorithms;
00087 class SoLdmValuationAction;
00088 class SoDataRange;
00089
00090 class SoVolumeWriter;
00091
00092 SO_PIMPL_PUBLIC_DECLARATION(SoDataSet)
00093
00094
00095
00135 class SoDataSet : public SoNode
00136 {
00137 SO_NODE_ABSTRACT_HEADER( SoDataSet );
00138
00139 SO_PIMPL_PUBLIC_HEADER( SoDataSet );
00140
00141 public:
00142
00158 SoSFInt32 dataSetId;
00159
00184 SoSFFilePathString fileName;
00185
00193 SoSFBool useCompressedTexture;
00194
00219 SoSFUShort texturePrecision;
00220
00230 SoSFBox3f extent;
00231
00252 SoSFLDMDataTransform dataTransform;
00253
00261 SoSFBool allocateResourceOnRender;
00262
00266 const SbVec3i32& getDimension();
00267
00271 SbVec3i32 getTileDimension();
00272
00276 unsigned int getDatumSize();
00277
00285 virtual size_t readTile( SoBufferObject*& bufferObject, SoLDMTileID tileID, bool transform );
00286
00292 virtual void readTile(SoLDMTileID tileID, SoBufferObject* buffer, bool transform);
00293
00302 virtual void writeTile( SoLDMTileID tileID, SoBufferObject* buffer, SoVolumeWriter* writer );
00303
00308 bool isInMemory( SoLDMTileID tileID ) const;
00309
00319 bool isDataInMemory( const SoLDMTileID& tileID ) const;
00320
00325 void getTileIDInMemory( std::vector<LDM_TILE_ID_TYPE>& tilesInMemory ) const;
00326
00331 SoSFLDMResourceParameters ldmResourceParameters;
00332
00337 SoLDMDataAccess & getLdmDataAccess();
00338
00346 virtual SbBool startEditing( int& transactionId );
00347
00356 virtual SbBool finishEditing( int transactionId );
00357
00366 virtual int editTile( const SoLDMTileID& tileId, SoBufferObject* userData );
00367
00377 virtual int editSubVolume( const SbBox3i32& subVolume, SoBufferObject* userData );
00378
00383 virtual int editTile( const SoLDMTileID& tileId, const double& value );
00384
00390 virtual int editSubVolume( const SbBox3i32& subVolume, const double& value );
00391
00404 virtual int editSurfaceShape( const SoNode* surfaceShape, const float& thickness, const double& value );
00405
00425 virtual int editSolidShape( const SoNode* solidShape, const double& value );
00426
00434 virtual int editBoxes(
00435 const std::vector<SbVec3i32>& boxCenters,
00436 const int& boxSize,
00437 const double& newValue
00438 );
00439
00451 virtual SbBool undoEditing( int transactionId );
00452
00464 virtual SbBool redoEditing( int transactionId );
00465
00466
00482 typedef SbBool SaveEditingCB( SoDataSet* dataSet,
00483 SoVolumeWriter* writer,
00484 int tilesRemaining,
00485 int totalTiles );
00525 virtual SbBool saveEditing( bool recomputeLowerResolution = TRUE,
00526 const std::vector<char*> conversionParameters = std::vector<char*>(), SaveEditingCB* callback = NULL );
00527
00531 virtual bool hasEditedTile();
00532
00539 SoLDMReader* getLDMReader();
00540
00547 void setLDMReader(SoLDMReader* reader);
00548
00556 inline SoVolumeReader* getReader()
00557 {return (SoVolumeReader*)m_reader.ptr();};
00558
00559
00567 inline SoVolumeReader* getReader() const
00568 { return (SoVolumeReader*)m_reader.ptr(); };
00569
00573 enum DataType {
00575 UNSIGNED_BYTE = SbDataType::UNSIGNED_BYTE,
00577 UNSIGNED_SHORT = SbDataType::UNSIGNED_SHORT,
00579 UNSIGNED_INT32 = SbDataType::UNSIGNED_INT32,
00581 SIGNED_BYTE = SbDataType::SIGNED_BYTE,
00583 SIGNED_SHORT = SbDataType::SIGNED_SHORT,
00585 SIGNED_INT32 = SbDataType::SIGNED_INT32,
00587 FLOAT = SbDataType::FLOAT,
00589 DOUBLE = SbDataType::DOUBLE
00590 };
00591
00592
00596 static int dataSize( DataType dataType );
00597
00601 static SbBool isDataSigned( DataType dataType );
00602
00606 static SbBool isDataFloat( DataType dataType );
00607
00611 int numSigBits() const;
00612
00625 virtual SbBool getMinMax( int64_t &min, int64_t &max);
00626
00640 virtual SbBool getMinMax( double &min, double &max);
00641
00645 DataType getDataType();
00646
00650 int getDataSize();
00651
00671 void setReader( SoVolumeReader &reader, SbBool takeOwnership = FALSE );
00672
00677 static int getMaxNumDataSets() ;
00678
00679 #if 1 SoDEPRECATED
00682 virtual void readTile(SoLDMTileID tileID, unsigned char* buffer, bool transform);
00683
00711 typedef void SoLDMDataTransformFunction(SoDataSet* ds,
00712 const SbVec3i32& bufferDimension,
00713 void* bufferToTransform,
00714 const SbBox3i32& dataBox,
00715 int resolutionLevel,
00716 void* userData);
00717 SoDEPRECATED
00727 void setLDMDataTransformFunction(SoLDMDataTransformFunction* func, void* userData = NULL);
00728
00729 #endif
00731 #if 1 SoDEPRECATED
00738 int getOverlapping();
00739
00740 #endif
00742 SoEXTENDER_Documented public:
00743
00757 void resetReader();
00758
00763 const SoLDMTopoOctree* getLDMTopoOctree() const;
00764
00765 private:
00766
00768 virtual void callback( SoCallbackAction *action );
00770 virtual void GLRender( SoGLRenderAction *action );
00772 virtual void getBoundingBox(SoGetBoundingBoxAction *action);
00774 virtual void pick(SoPickAction *action) ;
00776 virtual void write(SoWriteAction *action);
00778 virtual void doAction( SoAction *action );
00779
00783 inline virtual void useFakeData(SoLDMTileID , SoBufferObject* ) {};
00784
00785 private:
00786
00787
00788
00789
00790 typedef std::map<SoLDMTileID, uint64_t> tileSigInCacheMap;
00791
00792 static void initClass();
00793 static void exitClass();
00794
00796 static bool isReallyOfType(SoDataSet* ds, const SoType& type, bool derived);
00797
00803 bool isGPUDataRange( SoState* state );
00804
00810 SoBufferObject* getEditedTile( SoBufferObject* tileBuffer, const SoLDMTileID& tileId );
00811
00816 virtual SoBufferObject *getTransformedTile(const SoLDMTileID& tile,
00817 const SoLDM::DataSetIdPair& p,
00818 SoState * state=NULL,
00819 const bool useExtendedData = false);
00820
00821
00822
00823 static int getNumInstance();
00824
00826 SB_THREAD_TLS_HEADER();
00827
00829 SoLDM::DataSetIdPair getDataSetIdPair(SoState* state) const;
00830
00831 SoMultiDataSeparator *getMultiDataSeparator() { return m_MultiDataSeparator; }
00832 void setMultiDataSeparator(SoMultiDataSeparator *mds);
00833
00837 virtual void notify(SoNotList *list);
00838
00842 void sendParametersToLDM(SoLdmValuationAction* action);
00843
00844
00845 void ignoredByMultiDataSeparator(bool state);
00846 bool isIgnoredByMultiDataSeparator();
00847
00848
00849 virtual bool getDataCharRead() { return m_dataCharRead;};
00850
00851
00852 int getIndTexPrec() const;
00853 bool loadInMemory(SoState* s = NULL);
00854 void setListChange(bool val);
00855 bool getListChange();
00856
00857
00858
00859
00860
00861
00862
00863 unsigned short getResourcesState() const;
00864
00865
00866
00867
00868
00869 void setResourcesState( const SoLDMResourceManager::State flag, bool value );
00870
00871
00872 SbVec3i32 getEyeDataCoord(SoState* state);
00873
00880 int getZaxis(SoState *state, const SbBox3f& volBbox) const;
00881
00885 SbVec3f getVolCenterToEyeVector(SoState *state, const SbBox3f& volBbox) const;
00886
00888 SbVec3f getObjectSpaceEyeAxis(SoState *state) const;
00889
00890
00891 bool isAccumulated();
00892
00893 SbBool getCurrentMatrixDifference(SoState*, SbMatrix&);
00894
00895
00896 void lookForSceneGraphChange(SoAction* action);
00897
00898
00899 virtual SoBufferObject* getDataOneSlice( const SbVec3i32& tileSize, SoBufferObject* tileData, int Zaxis, int slice);
00900 virtual void releaseDataOneSlice(SoBufferObject *sliceDataBuffer);
00901
00902
00903
00904 virtual LDMSliceAccessor* getAppropriateSliceAccessor(const SoLDM::DataSetIdPair& p);
00905 virtual SoLDMReader* getAppropriateLDMReader( const SbString& )
00906 { return NULL; };
00907
00908
00909 bool getCenter(SoLDMTileID tileID, SbVec3f& center)const;
00910
00911 SoLDMMediator* getMediator(){return m_mediator;};
00912 void setMediator(SoLDMMediator* m);
00913
00914 virtual bool createTex(int Zaxis, SoState *state, const SbVec3i32 &tileSize, SoBufferObject *tileDataBuffer, SoTransferFunction *transferFunction,
00915 SoBufferObject*& textureBufferObject, int alphaUse = 0);
00916
00917
00919 void* getTexData(const void* tileBuffer,
00920 int numElem,
00921 SoTransferFunction* transferFunction,
00922 int alphaUse,
00923 int texPrec,
00924 void *textureBuffer,
00925 SoDataRange* datarange,
00926 SoDataCompositor* dataCompositor);
00927
00928
00929
00930
00931
00932 SoBufferObject* getTexData(SoBufferObject* tileBufferObject,
00933 SoTransferFunction* transferFunction,
00934 int alphaUse,
00935 int texPrec,
00936 SoBufferObject* textureBufferObject,
00937 SoDataRange* dataRange,
00938 SoDataCompositor* dataCompositor);
00939
00940 int getRGBAInternalFormat() const;
00941
00942 virtual void updateColorTable(SoState *, SoTransferFunction *);
00943
00944 SoLDMResourceManager& getResourceManager() { return *m_resourceManager; }
00945
00950 virtual int getTexPrec(SoState*);
00951
00957 void getTextureFormat(SoTransferFunction::GLColorMapType colorMapType,
00958 GLenum& format,
00959 GLenum& dataType,
00960 GLint& internalFormat) const;
00961
00962
00963 virtual void drawTilesInMainMemory( SoGLRenderAction* action );
00964
00965
00966
00967 void copyLDMParameters(SoLDMMediator *mediator);
00968
00974 virtual bool isMultidataEnabled() const { return m_multidataEnabled; }
00975
00976
00977 enum BoxColor {
00978 GREY,
00979 RED,
00980 BLUE,
00981 GREEN,
00982 FULL_RES_GREY,
00983 FULL_RES_GREEN
00984 };
00985
00990 unsigned short getId() const
00991 { return m_id; }
00992
00996 bool hasReadError();
00997
01001 inline bool isEmpty()
01002 {
01003 const SbVec3i32& dim = getDimension();
01004 return ( dim[0] == 0 || dim[1] == 0 || dim[2] == 0 );
01005 };
01006
01011 struct DatumElement{
01012 SoDataSet::DataType type;
01013 int num;
01014 };
01015
01022 float convertToNormalizedTextureSpace(SoState *state, const float data);
01023
01027 void setFirstTraversalDone(bool flag);
01028
01032 bool isFirstTraversalDone() const;
01033
01034 virtual bool isPalettedTexture(SoState*);
01035
01036
01037
01038
01039 virtual uint64_t getTileSignature(const SoLDMTileID& tileId);
01040
01046 inline void setOwnedReader( SoVolumeReader &reader )
01047 { setReader( reader, TRUE ); };
01048
01049
01050
01051
01052
01053
01054 void refVolRender( int contextId );
01055 void unrefVolRender( int contextId );
01056
01063 int getBestEqualResolution() const;
01064
01069 void computeBestEqualResolution();
01070
01071 private:
01072
01074 SoDataSet();
01075
01077 virtual ~SoDataSet();
01078
01079 inline virtual void computeLighting( const SbVec3i32& , SoBufferObject* ) {};
01080
01084 virtual void setElement(SoState* state);
01085
01089 bool isUsingUserExtent();
01090
01091
01092
01093
01094
01095
01096
01097
01098 virtual bool enableMultidata(SoState* state);
01099
01100
01101 virtual SoVolumeReader* getAppropriateReader();
01102
01104 bool m_forcePow2TileDim;
01105
01106
01107 SoRef<SoFieldContainer> m_reader;
01108
01109 bool load(SoState*);
01110 virtual void unload();
01111 virtual void releaseMemory();
01112
01113
01114 bool m_multidataEnabled;
01115
01116 SbVec3i32 m_dimension;
01117 bool m_initialized;
01118
01119 SbDataType m_type;
01120 int m_numBits;
01121
01122
01123 bool m_dataCharRead;
01124
01125 SbString m_filename;
01126 virtual void updateFilename();
01127
01128
01129 unsigned short m_id;
01130
01131
01135 virtual void readerChanged();
01136
01137 void initReader();
01138
01139 virtual SoLDMMediator *createMediator();
01140 SoLDMMediator* m_mediator;
01141
01142 SoMultiDataSeparator *m_MultiDataSeparator;
01143
01144 SoLDMResourceManager* m_resourceManager;
01145
01146 void getTransferFunction(SoTransferFunction *transferFunction, int alphaUse,
01147 int &shift, int &offset, int &nrgba, unsigned int * &rgba);
01148
01149
01150
01151
01152 virtual void buildTile(SoLDMTileID tileID, SoBufferObject* buffer);
01153
01154 SoVolumeHistogram *m_histogram;
01155
01157 virtual void ldmAction(SoLdmValuationAction* action);
01158
01162 virtual SbBool isRGBAData();
01163
01164 SoINTERNAL private:
01165
01170 virtual SoLDMGeomElement* getAppropriateElement( SoLDMGeometry* SO_UNUSED_PARAM(v) )
01171 {
01172 return NULL;
01173 }
01174
01175 SoSFFieldContainer customReader;
01176 SoSFBool customReaderOwnerShip;
01177
01182 SoSFLDMDataTransform editingStack;
01183
01184 private:
01185
01187 void commonConstructor();
01188
01192 struct MTstruct {
01193 SoBufferObject *tmpTexture;
01194 SoCpuBufferUniform *tmpTextureUniform;
01195 SoBufferObject *tmpColormap;
01196 SoBufferObject *tmpTexturePermute;
01197 };
01198
01199 #ifndef HIDDEN_FROM_DOC
01200 friend class SoLDMMediator;
01201 friend class SoCpuBufferFromVolumeReader;
01202 #endif
01203 friend class SoLdmValuationAction;
01204 friend class SoLDMGeometry;
01205 };
01206
01207 #ifdef _MSC_VER
01208 #pragma warning( pop )
01209 #endif
01210
01211 #endif // _SO_DATA_SET_
01212
01213
01214