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
00429 class SoTransferFunction : public SoNode {
00430
00431 SO_NODE_HEADER( SoTransferFunction );
00432
00433 SO_PIMPL_BASE_PUBLIC_HEADER(SoTransferFunction);
00434
00435 public:
00481 SoSFInt32 transferFunctionId;
00482
00491 SoSFInt32 shift;
00492
00497 SoSFInt32 offset;
00498
00511 SoSFInt32 minValue;
00512
00520 SoSFInt32 maxValue;
00521
00532 SoSFFloat fauxShadingLength;
00533
00545 SoSFFloat fauxShadingStrength;
00546
00557 SoSFFloat fauxShadingDarkenThreshold;
00558
00562 enum PredefColorMap {
00564 NONE,
00567 GREY,
00569 GRAY = GREY,
00571 TEMPERATURE,
00573 PHYSICS,
00575 STANDARD,
00577 GLOW,
00579 BLUE_RED,
00581 SEISMIC,
00583 BLUE_WHITE_RED,
00587 INTENSITY,
00589 LABEL_256,
00591 VOLREN_RED,
00593 VOLREN_GREEN,
00598 AIRWAY,
00603 AIRWAY_SURFACES,
00607 INTENSITY_REVERSED
00608 };
00609
00638 SoSFEnum predefColorMap;
00639
00641 enum ColorMapType {
00643 ALPHA,
00645 LUM_ALPHA,
00647 RGBA
00648 };
00649
00665 SoSFEnum colorMapType;
00666
00693 SoMFFloat colorMap;
00694
00704 SoMFFloat actualColorMap;
00705
00709 SoTransferFunction();
00710
00715 SbBool hasTransparency() const;
00716
00731 virtual SbBool loadColormap(const SbString& filename);
00732
00733 private:
00734 virtual void doAction( SoAction *action );
00735 virtual void callback( SoCallbackAction *action );
00736 virtual void GLRender( SoGLRenderAction *action );
00737 virtual void pick(SoPickAction *action) ;
00738 virtual void write(SoWriteAction *action);
00739
00740
00741 private:
00742
00746 enum MappingMethod
00747 {
00755 MAP_TO_CENTER = SoConversion::MAP_TO_CENTER,
00756
00764 MAP_TO_BORDER = SoConversion::MAP_TO_BORDER
00765 };
00766
00773 SoSFEnum mappingMethod;
00774
00775 typedef float OpacityCorrectionFunction(float alpha, void* userData);
00776
00780 virtual void notify(SoNotList *list);
00781
00786 virtual bool affectsPath() const;
00787
00788 static void initClass();
00789 static void exitClass();
00790
00791 int getPackedColorMap(unsigned int * &, int);
00792 static unsigned int getDefaultPackedColor(unsigned int);
00793 enum GLColorMapType {
00794 NO_COLORMAP = 0,
00795 TEX_FRAGMENT_PROGRAM = 2
00796 };
00797
00798 GLColorMapType installColorMap(SoState*, int alphaUse);
00799
00803 GLColorMapType installColorMap(SoState*, int, OpacityCorrectionFunction* f, void* userData);
00804 int m_colorMapMin;
00805 int m_colorMapMax;
00806
00810 void applyOpacityCorrection(unsigned int* allRgba, size_t numRgba,
00811 OpacityCorrectionFunction* f, void* userData);
00812
00816 SbBool isFullyTransparent(int64_t min, int64_t max, int alphaUse = 0);
00817
00818
00819 enum Cmd{
00820 REMAP = 0
00821 };
00822
00823 void getCMBuffer( int alphaUse, int nrgba, unsigned int *rgba );
00824
00829 bool isTransparent(const float min, const float max, const float materialTransparency) const;
00830
00834 SoRef<SoTexture> getTexture() const;
00835
00839 SbVec2i32 getTextureSize() const;
00840
00845 unsigned int getNumColors() const;
00846
00850 bool isBinary() const;
00851
00855 static SoRef<SoTexture> createPreIntegratedTexture(SoState *state);
00856
00860 size_t getNumComponents() const;
00861
00866 int getTransferFunctionPosInTexture(int maxTfId);
00867
00868 private :
00869
00870
00871 void construct();
00872
00873 friend class SoVolumeState;
00874 };
00875
00876 #if defined(_WIN32)
00877 #pragma warning( pop )
00878 #endif
00879
00880 #endif // _SO_TRANSFER_FUNCTION_
00881
00882
00883