Point Cloud Library (PCL) 1.13.0
Loading...
Searching...
No Matches
opennurbs_zlib.h
1/* $NoKeywords: $ */
2/*
3//
4// Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
5// OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
6// McNeel & Associates.
7//
8// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
9// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
10// MERCHANTABILITY ARE HEREBY DISCLAIMED.
11//
12// For complete openNURBS copyright information see <http://www.opennurbs.org>.
13//
14////////////////////////////////////////////////////////////////
15*/
16
17#if !defined(OPENNURBS_ZLIB_INC_)
18#define OPENNURBS_ZLIB_INC_
19
20// If you are using opennurbs as a statically linked library, then
21// you may make calls to the same zlib that opennurbs uses. This
22// zlib is compiled with z_ symbol projectection. All the necessary
23// header files are included by opennurbs.h.
24//
25// If you are using opennurbs as a DLL or writing a Rhino plug-in
26// and you want to use the same zlib that opennurbs uses, then
27// compile opennurbs_zlib_memory.cpp into your application
28// and statically link with the zlib library. All the necessary
29// header files are included by opennurbs.h.
30
31
32#if !defined(Z_PREFIX)
33/* decorates zlib functions with a "z_" prefix to prevent symbol collision. */
34#define Z_PREFIX
35#endif
36
37#if !defined(MY_ZCALLOC)
38/* have zlib use oncalloc() and onfree() for memory managment*/
39#define MY_ZCALLOC
40#endif
41
42#include "zlib.h"
43
44ON_BEGIN_EXTERNC
45voidpf zcalloc (voidpf, unsigned, unsigned);
46void zcfree (voidpf, voidpf);
47ON_END_EXTERNC
48
49class ON_CLASS ON_CompressedBuffer
50{
51public:
56
57 /*
58 Description:
59 Compress inbuffer.
60 Parameters:
61 sizeof__inbuffer - [in]
62 Number of bytes in inbuffer.
63 inbuffer - [in]
64 Uncompressed information.
65 sizeof_element - [out]
66 This parameter only matters if the buffer will be compressed,
67 and decompressed on CPUs with different endianness. If this
68 is the case, then the types in the buffer need to have the
69 same size (2,4, or 8).
70 Returns:
71 True if inbuffer is successfully compressed.
72 */
74 std::size_t sizeof__inbuffer, // sizeof uncompressed input data
75 const void* inbuffer, // uncompressed input data
76 int sizeof_element
77 );
78
79 /*
80 Returns:
81 Number of bytes in the uncompressed information.
82 */
83 std::size_t SizeOfUncompressedBuffer() const;
84
85 /*
86 Description:
87 Uncompress the contents of this ON_CompressedBuffer.
88 Parameters:
89 outbuffer - [in/out]
90 This buffer must have at least SizeOfUncompressedBuffer() bytes.
91 If the function returns true, then the uncopressed information
92 is stored in this buffer.
93 bFailedCRC - [out]
94 If not null, then this boolean is set to true if the CRC
95 of the uncompressed information has changed.
96 Returns:
97 True if uncompressed information is returned in outbuffer.
98 */
99 bool Uncompress( // read and uncompress
100 void* outbuffer, // uncompressed output data returned here
101 int* bFailedCRC
102 ) const;
103
104 /*
105 Description:
106 Destroy the current informtion in the ON_CompressedBuffer
107 so the class can be reused.
108 */
109 void Destroy();
110
111 bool Write( ON_BinaryArchive& binary_archive ) const;
112 bool Read( ON_BinaryArchive& binary_archive );
113
114 /////////////////////////////////////////////////
115 //
116 // Implementation
117 //
118 bool CompressionInit( struct ON_CompressedBufferHelper* ) const;
119 bool CompressionEnd( struct ON_CompressedBufferHelper* ) const;
120 std::size_t DeflateHelper( // returns number of bytes written
121 struct ON_CompressedBufferHelper*,
122 std::size_t sizeof___inbuffer, // sizeof uncompressed input data ( > 0 )
123 const void* in___buffer // uncompressed input data ( != NULL )
124 );
126 struct ON_CompressedBufferHelper*,
127 std::size_t sizeof___outbuffer, // sizeof uncompressed data
128 void* out___buffer // buffer for uncompressed data
129 ) const;
131 std::size_t count,
132 const void* buffer
133 );
134
139 int m_method; // 0 = copied, 1 = compressed
143};
144
145#endif
ON__UINT32 m_crc_uncompressed
ON_CompressedBuffer(const ON_CompressedBuffer &src)
std::size_t DeflateHelper(struct ON_CompressedBufferHelper *, std::size_t sizeof___inbuffer, const void *in___buffer)
std::size_t SizeOfUncompressedBuffer() const
bool CompressionInit(struct ON_CompressedBufferHelper *) const
bool Compress(std::size_t sizeof__inbuffer, const void *inbuffer, int sizeof_element)
ON_CompressedBuffer & operator=(const ON_CompressedBuffer &src)
ON__UINT32 m_crc_compressed
bool Uncompress(void *outbuffer, int *bFailedCRC) const
std::size_t m_sizeof_compressed
bool Write(ON_BinaryArchive &binary_archive) const
std::size_t m_buffer_compressed_capacity
bool CompressionEnd(struct ON_CompressedBufferHelper *) const
bool InflateHelper(struct ON_CompressedBufferHelper *, std::size_t sizeof___outbuffer, void *out___buffer) const
bool WriteChar(std::size_t count, const void *buffer)
bool Read(ON_BinaryArchive &binary_archive)
std::size_t m_sizeof_uncompressed