00001 /*======================================================================= 00002 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00003 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00004 *** *** 00005 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00006 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00007 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00008 *** *** 00009 *** RESTRICTED RIGHTS LEGEND *** 00010 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00011 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00012 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00013 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00014 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00015 *** *** 00016 *** COPYRIGHT (C) 1996-2017 BY FEI S.A.S, *** 00017 *** BORDEAUX, FRANCE *** 00018 *** ALL RIGHTS RESERVED *** 00019 **=======================================================================*/ 00020 /*======================================================================= 00021 ** Author : VSG (MMM YYYY) 00022 **=======================================================================*/ 00023 00024 00025 #ifndef SO_DATA_COMPRESSOR_H 00026 #define SO_DATA_COMPRESSOR_H 00027 00028 #ifdef _MSC_VER 00029 #pragma warning( push ) 00030 #pragma warning(disable:4251) 00031 #endif 00032 00033 #include <Inventor/SoSubTypedClass.h> 00034 #include <Inventor/sys/port.h> 00035 #include <Inventor/SbString.h> 00036 #include <Inventor/lists/SbStringList.h> 00037 #include <Inventor/SbLinear.h> 00038 #include <Inventor/SbDataType.h> 00039 #include <Inventor/STL/vector> 00040 00041 #include <LDM/nodes/SoDataSet.h> 00042 00065 class SoDataCompressor : public SoTypedObject 00066 { 00067 SO_TYPED_CLASS_ABSTRACT_HEADER() 00068 00069 public: 00070 00075 struct TileInfo 00076 { 00077 TileInfo(); 00078 TileInfo( const SbVec3i32 &dims, const SbDataType& dataType ); 00079 TileInfo( const SbVec3i32 &dims, const SbDataType& dataType, const SbVec2d &range ); 00080 00084 SbVec3i32 dims; 00085 00089 SoDataSet::DataType dataType; 00090 00094 SbVec2d range; 00095 00099 bool isRGBA; 00100 }; 00101 00110 static SoDataCompressor* getAppropriateCompressor( const SbString& name ); 00111 00115 static SbStringList getAvailableCompressors(); 00116 00120 SoDataCompressor() : m_level(0){} 00124 virtual ~SoDataCompressor() {} 00125 00134 virtual size_t compress(void *src, size_t srcLen, const TileInfo &tileInfo) = 0; 00135 00144 virtual size_t uncompress(void *dest, size_t destLen, const TileInfo &tileInfo) = 0; 00145 00152 virtual SbString getCompressionFormatName() const = 0; 00153 00165 virtual bool isLossless() = 0; 00166 00172 virtual void setCompressionLevel(size_t level) { m_level = level; } 00173 00179 virtual void *allocateCompressedBuffer(size_t size) 00180 { 00181 m_size = size; 00182 m_compressedBuffer.resize(size); 00183 if ( size>0) 00184 return &m_compressedBuffer[0]; 00185 else 00186 return NULL; 00187 } 00188 00194 virtual void *getCompressedBuffer() { return &m_compressedBuffer[0]; } 00195 00203 static size_t crc32(const void *buf, size_t len); 00204 00209 virtual size_t getCompressionLevel() { return m_level; }; 00210 00211 private: 00212 00213 size_t getSize() { return m_size;}; 00214 size_t m_size; 00215 00216 private: 00217 SbString m_compressionName; 00218 00219 std::vector<unsigned char> m_compressedBuffer; 00220 00221 size_t m_level; 00222 }; 00223 00224 #ifdef _MSC_VER 00225 #pragma warning( pop ) 00226 #endif 00227 00228 #endif 00229