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-2020 BY FEI S.A.S, *** 00017 *** BORDEAUX, FRANCE *** 00018 *** ALL RIGHTS RESERVED *** 00019 **=======================================================================*/ 00020 /*======================================================================= 00021 ** Author : David BEILLOIN (MMM yyyy) 00022 **=======================================================================*/ 00023 00024 00025 #ifndef SO_MEMORY_BUFFER_COMPRESSION_H 00026 #define SO_MEMORY_BUFFER_COMPRESSION_H 00027 00028 #include <ScaleViz/SoScaleViz.h> 00029 00030 class SoMemoryBuffer; 00031 00032 SoMemoryBufferCompression 00033 { 00034 00035 public: 00036 // define the type of compression available 00037 typedef enum { 00038 /* No compression */ 00039 NONE, 00040 /* Zip through zlib compression */ 00041 ZLIB, 00042 /* bzip compression */ 00043 BZIP2, 00044 /* per component bzip compression */ 00045 PBZIP2 00046 } CompressionMode; 00047 00048 public: 00049 // Constructor 00050 SoMemoryBufferCompression(); 00051 00052 //Destructor 00053 virtual ~SoMemoryBufferCompression(); 00054 00055 // setup the source buffer of the compression with the possibility 00056 // to limit the compression to a subset of the buffer with offset and size parameter 00057 // if size is set to 0 then the buffer size will be taken minus the offset 00058 virtual void setSource(SoMemoryBuffer *src,const unsigned long offset=0,const unsigned long size=0); 00059 00060 // setup the destination buffer of the compression with the possibilty to 00061 // set a destination offset, allowing the user to add specific infoon the header 00062 virtual void setDestination(SoMemoryBuffer *dst,const unsigned long offset=0); 00063 00064 // apply a compression function on the defined source offset/size 00065 // and put the results in destination at offset 00066 // return the size of the compressed results 00067 // or -1 if error 00068 int compress(const CompressionMode mode); 00069 00070 // apply uncompress function on the defined source offset/size 00071 // and put the results in destination at offset 00072 // return the size of the compressed results 00073 // or -1 if error 00074 int uncompress(const CompressionMode mode); 00075 00076 private: 00077 SoMemoryBuffer* m_srcBuf; 00078 unsigned long m_srcOffset, m_srcSize; 00079 00080 SoMemoryBuffer* m_dstBuf; 00081 unsigned long m_dstOffset, m_dstSize; 00082 00083 }; 00084 00085 #endif // SO_MEMORY_BUFFER_COMPRESSION_H 00086 00087 00088 00089 00090