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_TRANSFER_FUNCTION_
00024 #define _SO_TRANSFER_FUNCTION_
00025
00026 #include <LDM/SoLDM.h>
00027
00028 #include <Inventor/nodes/SoNode.h>
00029 #include <Inventor/nodes/SoTexture2.h>
00030 #include <Inventor/fields/SoSFEnum.h>
00031 #include <Inventor/fields/SoMFFloat.h>
00032 #include <Inventor/fields/SoSFInt32.h>
00033 #include <Inventor/fields/SoSFFloat.h>
00034 #include <Inventor/algorithms/SoConversion.h>
00035 #include <Inventor/SbVec.h>
00036
00037 #include <Inventor/SbPImpl.h>
00038
00039 #ifdef _WIN32
00040 #pragma warning( push )
00041 #pragma warning(disable:4251)
00042 #endif
00043
00044 class SoGLTexture;
00045 class SoVolumeState;
00046
00047 SO_PIMPL_BASE_PUBLIC_DECLARATION(SoTransferFunction)
00048
00049
00443 class SoTransferFunction : public SoNode {
00444
00445 SO_NODE_HEADER( SoTransferFunction );
00446
00447 SO_PIMPL_BASE_PUBLIC_HEADER(SoTransferFunction);
00448
00449 public:
00495 SoSFInt32 transferFunctionId;
00496
00505 SoSFInt32 shift;
00506
00511 SoSFInt32 offset;
00512
00525 SoSFInt32 minValue;
00526
00534 SoSFInt32 maxValue;
00535
00546 SoSFFloat fauxShadingLength;
00547
00559 SoSFFloat fauxShadingStrength;
00560
00571 SoSFFloat fauxShadingDarkenThreshold;
00572
00576 enum PredefColorMap {
00578 NONE,
00581 GREY,
00583 GRAY = GREY,
00585 TEMPERATURE,
00587 PHYSICS,
00589 STANDARD,
00591 GLOW,
00593 BLUE_RED,
00595 SEISMIC,
00597 BLUE_WHITE_RED,
00601 INTENSITY,
00603 LABEL_256,
00605 VOLREN_RED,
00607 VOLREN_GREEN,
00612 AIRWAY,
00617 AIRWAY_SURFACES,
00621 INTENSITY_REVERSED
00622 };
00623
00652 SoSFEnum predefColorMap;
00653
00655 enum ColorMapType {
00657 ALPHA,
00659 LUM_ALPHA,
00661 RGBA
00662 };
00663
00679 SoSFEnum colorMapType;
00680
00707 SoMFFloat colorMap;
00708
00718 SoMFFloat actualColorMap;
00719
00723 SoTransferFunction();
00724
00729 SbBool hasTransparency() const;
00730
00745 virtual SbBool loadColormap(const SbString& filename);
00746
00747 private:
00748 virtual void doAction( SoAction *action );
00749 virtual void callback( SoCallbackAction *action );
00750 virtual void GLRender( SoGLRenderAction *action );
00751 virtual void pick(SoPickAction *action) ;
00752 virtual void write(SoWriteAction *action);
00753
00754
00755 private:
00756
00760 enum MappingMethod
00761 {
00769 MAP_TO_CENTER = SoConversion::MAP_TO_CENTER,
00770
00778 MAP_TO_BORDER = SoConversion::MAP_TO_BORDER
00779 };
00780
00787 SoSFEnum mappingMethod;
00788
00789 typedef float OpacityCorrectionFunction(float alpha, void* userData);
00790
00794 virtual void notify(SoNotList *list);
00795
00800 virtual bool affectsPath() const;
00801
00802 static void initClass();
00803 static void exitClass();
00804
00805 int getPackedColorMap(unsigned int * &, int);
00806 static unsigned int getDefaultPackedColor(unsigned int);
00807 enum GLColorMapType {
00808 NO_COLORMAP = 0,
00809 TEX_FRAGMENT_PROGRAM = 2
00810 };
00811
00812 GLColorMapType installColorMap(SoState*, int alphaUse);
00813
00817 GLColorMapType installColorMap(SoState*, int, OpacityCorrectionFunction* f, void* userData);
00818 int m_colorMapMin;
00819 int m_colorMapMax;
00820
00824 void applyOpacityCorrection(unsigned int* allRgba, size_t numRgba,
00825 OpacityCorrectionFunction* f, void* userData);
00826
00830 SbBool isFullyTransparent(int64_t min, int64_t max, int alphaUse = 0);
00831
00832
00833 enum Cmd{
00834 REMAP = 0
00835 };
00836
00837 void getCMBuffer( int alphaUse, int nrgba, unsigned int *rgba );
00838
00843 bool isTransparent(const float min, const float max, const float materialTransparency) const;
00844
00848 SoRef<SoTexture> getTexture() const;
00849
00853 SbVec2i32 getTextureSize() const;
00854
00859 unsigned int getNumColors() const;
00860
00864 bool isBinary() const;
00865
00869 static void createPreIntegratedTexture(SoState* state, SoGroup* placeHolder);
00870
00874 size_t getNumComponents() const;
00875
00880 int getTransferFunctionPosInTexture(int maxTfId);
00881
00882 private :
00883
00884
00885 void construct();
00886
00887 friend class SoVolumeState;
00888 };
00889
00890 #if defined(_WIN32)
00891 #pragma warning( pop )
00892 #endif
00893
00894 #endif // _SO_TRANSFER_FUNCTION_
00895
00896
00897