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/fields/SoSFEnum.h>
00030 #include <Inventor/fields/SoMFFloat.h>
00031 #include <Inventor/fields/SoSFInt32.h>
00032 #include <Inventor/fields/SoSFFloat.h>
00033 #include <Inventor/algorithms/SoConversion.h>
00034 #include <Inventor/SbVec.h>
00035
00036 #include <Inventor/SbPImpl.h>
00037
00038 #ifdef _WIN32
00039 #pragma warning( push )
00040 #pragma warning(disable:4251)
00041 #endif
00042
00043 class SoGLTexture;
00044
00045 SO_PIMPL_BASE_PUBLIC_DECLARATION(SoTransferFunction)
00046
00047
00427 class SoTransferFunction : public SoNode {
00428
00429 SO_NODE_HEADER( SoTransferFunction );
00430
00431 SO_PIMPL_BASE_PUBLIC_HEADER(SoTransferFunction);
00432
00433 public:
00479 SoSFInt32 transferFunctionId;
00480
00489 SoSFInt32 shift;
00490
00495 SoSFInt32 offset;
00496
00509 SoSFInt32 minValue;
00510
00518 SoSFInt32 maxValue;
00519
00530 SoSFFloat fauxShadingLength;
00531
00543 SoSFFloat fauxShadingStrength;
00544
00555 SoSFFloat fauxShadingDarkenThreshold;
00556
00560 enum PredefColorMap {
00562 NONE,
00565 GREY,
00567 GRAY = GREY,
00569 TEMPERATURE,
00571 PHYSICS,
00573 STANDARD,
00575 GLOW,
00577 BLUE_RED,
00579 SEISMIC,
00581 BLUE_WHITE_RED,
00585 INTENSITY,
00587 LABEL_256,
00589 VOLREN_RED,
00591 VOLREN_GREEN,
00596 AIRWAY,
00601 AIRWAY_SURFACES,
00605 INTENSITY_REVERSED
00606 };
00607
00636 SoSFEnum predefColorMap;
00637
00639 enum ColorMapType {
00641 ALPHA,
00643 LUM_ALPHA,
00645 RGBA
00646 };
00647
00663 SoSFEnum colorMapType;
00664
00691 SoMFFloat colorMap;
00692
00702 SoMFFloat actualColorMap;
00703
00707 SoTransferFunction();
00708
00713 SbBool hasTransparency() const;
00714
00729 virtual SbBool loadColormap(const SbString& filename);
00730
00731 #if 1 SoDEPRECATED
00734 void reMap(int min, int max);
00735
00736 #endif
00738 //------------------------------------------------------------------------------
00739
00740 private:
00741 virtual void doAction( SoAction *action );
00742 virtual void callback( SoCallbackAction *action );
00743 virtual void GLRender( SoGLRenderAction *action );
00744 virtual void pick(SoPickAction *action) ;
00745 virtual void write(SoWriteAction *action);
00746
00747
00748 private:
00749
00753 enum MappingMethod
00754 {
00762 MAP_TO_CENTER = SoConversion::MAP_TO_CENTER,
00763
00771 MAP_TO_BORDER = SoConversion::MAP_TO_BORDER
00772 };
00773
00780 SoSFEnum mappingMethod;
00781
00782 typedef float OpacityCorrectionFunction(float alpha, void* userData);
00783
00787 virtual void notify(SoNotList *list);
00788
00793 virtual bool affectsPath() const;
00794
00795 static void initClass();
00796 static void exitClass();
00797
00798 int getPackedColorMap(unsigned int * &, int);
00799 static unsigned int getDefaultPackedColor(unsigned int);
00800 enum GLColorMapType {
00801 NO_COLORMAP = 0,
00802 TEX_FRAGMENT_PROGRAM = 2
00803 };
00804
00805 GLColorMapType installColorMap(SoState*, int alphaUse);
00806
00810 GLColorMapType installColorMap(SoState*, int, OpacityCorrectionFunction* f, void* userData);
00811 int m_colorMapMin;
00812 int m_colorMapMax;
00813
00817 void applyOpacityCorrection(unsigned int* allRgba, size_t numRgba,
00818 OpacityCorrectionFunction* f, void* userData);
00819
00823 SbBool isFullyTransparent(int64_t min, int64_t max, int alphaUse = 0);
00824
00825
00826 enum Cmd{
00827 REMAP = 0
00828 };
00829
00830 void getCMBuffer( int alphaUse, int nrgba, unsigned int *rgba );
00831
00836 bool isTransparent(const float min, const float max, const float materialTransparency) const;
00837
00841 SoGLTexture* getTexture() const;
00842
00846 SbVec2i32 getTextureSize() const;
00847
00852 unsigned int getNumColors() const;
00853
00857 bool isBinary() const;
00858
00862 static SoGLTexture* createPreIntegratedTexture(SoState *state);
00863
00867 static int getTextureHeight(int minTfId, int maxTfId);
00868
00872 size_t getNumComponents() const;
00873
00878 int getTransferFunctionPosInTexture(int maxTfId);
00879
00880 private :
00881
00882
00883 void construct();
00884 };
00885
00886 #if defined(_WIN32)
00887 #pragma warning( pop )
00888 #endif
00889
00890 #endif // _SO_TRANSFER_FUNCTION_
00891
00892
00893