opennurbs_zlib.h
Go to the documentation of this file.
00001 /* $NoKeywords: $ */
00002 /*
00003 //
00004 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
00005 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
00006 // McNeel & Associates.
00007 //
00008 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
00009 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
00010 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
00011 //                              
00012 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
00013 //
00015 */
00016 
00017 #if !defined(OPENNURBS_ZLIB_INC_)
00018 #define OPENNURBS_ZLIB_INC_
00019 
00020 // If you are using opennurbs as a statically linked library, then
00021 // you may make calls to the same zlib that opennurbs uses.  This
00022 // zlib is compiled with z_ symbol projectection.  All the necessary
00023 // header files are included by opennurbs.h.
00024 // 
00025 // If you are using opennurbs as a DLL or writing a Rhino plug-in
00026 // and you want to use the same zlib that opennurbs uses, then
00027 // compile opennurbs_zlib_memory.cpp into your application
00028 // and statically link with the zlib library. All the necessary
00029 // header files are included by opennurbs.h.
00030 
00031 
00032 #if !defined(Z_PREFIX)
00033 /* decorates zlib functions with a "z_" prefix to prevent symbol collision. */
00034 #define Z_PREFIX
00035 #endif
00036 
00037 #if !defined(MY_ZCALLOC)
00038 /* have zlib use oncalloc() and onfree() for memory managment*/
00039 #define MY_ZCALLOC
00040 #endif
00041 
00042 #include "zlib.h"
00043 
00044 ON_BEGIN_EXTERNC
00045 voidpf zcalloc (voidpf, unsigned, unsigned);
00046 void  zcfree (voidpf, voidpf);
00047 ON_END_EXTERNC
00048 
00049 class ON_CLASS ON_CompressedBuffer
00050 {
00051 public:
00052   ON_CompressedBuffer();
00053   ~ON_CompressedBuffer();
00054   ON_CompressedBuffer(const ON_CompressedBuffer& src);
00055   ON_CompressedBuffer& operator=(const ON_CompressedBuffer& src);
00056 
00057   /*
00058   Description:
00059     Compress inbuffer.
00060   Parameters:
00061     sizeof__inbuffer - [in]
00062        Number of bytes in inbuffer.
00063     inbuffer - [in]
00064        Uncompressed information.
00065     sizeof_element - [out]
00066        This parameter only matters if the buffer will be compressed,
00067        and decompressed on CPUs with different endianness.  If this
00068        is the case, then the types in the buffer need to have the
00069        same size (2,4, or 8).  
00070   Returns:
00071     True if inbuffer is successfully compressed.
00072   */
00073   bool Compress(
00074           size_t sizeof__inbuffer,  // sizeof uncompressed input data
00075           const void* inbuffer,     // uncompressed input data
00076           int sizeof_element
00077           );
00078 
00079   /*
00080   Returns:
00081     Number of bytes in the uncompressed information.
00082   */
00083   size_t SizeOfUncompressedBuffer() const;
00084 
00085   /*
00086   Description:
00087     Uncompress the contents of this ON_CompressedBuffer.
00088   Parameters:
00089     outbuffer - [in/out]
00090        This buffer must have at least SizeOfUncompressedBuffer() bytes.
00091        If the function returns true, then the uncopressed information
00092        is stored in this buffer.
00093     bFailedCRC - [out]
00094        If not null, then this boolean is set to true if the CRC 
00095        of the uncompressed information has changed.
00096   Returns:
00097     True if uncompressed information is returned in outbuffer.
00098   */
00099   bool Uncompress( // read and uncompress
00100           void* outbuffer,           // uncompressed output data returned here
00101           int* bFailedCRC
00102           ) const;
00103 
00104   /*
00105   Description:
00106     Destroy the current informtion in the ON_CompressedBuffer 
00107     so the class can be reused.
00108   */
00109   void Destroy();
00110 
00111   bool Write( ON_BinaryArchive& binary_archive ) const;
00112   bool Read( ON_BinaryArchive& binary_archive );
00113 
00115   //
00116   // Implementation
00117   //
00118   bool CompressionInit( struct ON_CompressedBufferHelper* ) const;
00119   bool CompressionEnd( struct ON_CompressedBufferHelper* ) const;
00120   size_t DeflateHelper( // returns number of bytes written
00121         struct ON_CompressedBufferHelper*,
00122         size_t sizeof___inbuffer,  // sizeof uncompressed input data ( > 0 )
00123         const void* in___buffer     // uncompressed input data ( != NULL )
00124         );
00125   bool InflateHelper(
00126         struct ON_CompressedBufferHelper*,
00127         size_t sizeof___outbuffer,  // sizeof uncompressed data
00128         void* out___buffer          // buffer for uncompressed data
00129         ) const;
00130   bool WriteChar( 
00131         size_t count, 
00132         const void* buffer 
00133         );
00134 
00135   size_t     m_sizeof_uncompressed;
00136   size_t     m_sizeof_compressed;
00137   ON__UINT32 m_crc_uncompressed;
00138   ON__UINT32 m_crc_compressed;
00139   int        m_method; // 0 = copied, 1 = compressed
00140   int        m_sizeof_element;
00141   size_t     m_buffer_compressed_capacity;
00142   void*      m_buffer_compressed;
00143 };
00144 
00145 #endif


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:27:03