Point Cloud Library (PCL) 1.14.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// PCL can use an external zlib.
32
33#include <pcl/pcl_config.h>
34
35#if defined(HAVE_ZLIB)
36
37#define z_deflate deflate
38#define z_inflate inflate
39#define z_Bytef Bytef
40
41#define zcalloc pcl_zcalloc
42#define zcfree pcl_zcfree
43
44#include <zlib.h>
45
46#else
47
48#if !defined(Z_PREFIX)
49/* decorates zlib functions with a "z_" prefix to prevent symbol collision. */
50#define Z_PREFIX
51#endif
52
53#if !defined(MY_ZCALLOC)
54/* have zlib use oncalloc() and onfree() for memory managment*/
55#define MY_ZCALLOC
56#endif
57
58#include "zlib.h"
59
60#endif // HAVE_ZLIB
61
62ON_BEGIN_EXTERNC
63voidpf zcalloc (voidpf, unsigned, unsigned);
64void zcfree (voidpf, voidpf);
65ON_END_EXTERNC
66
67class ON_CLASS ON_CompressedBuffer
68{
69public:
74
75 /*
76 Description:
77 Compress inbuffer.
78 Parameters:
79 sizeof__inbuffer - [in]
80 Number of bytes in inbuffer.
81 inbuffer - [in]
82 Uncompressed information.
83 sizeof_element - [out]
84 This parameter only matters if the buffer will be compressed,
85 and decompressed on CPUs with different endianness. If this
86 is the case, then the types in the buffer need to have the
87 same size (2,4, or 8).
88 Returns:
89 True if inbuffer is successfully compressed.
90 */
92 std::size_t sizeof__inbuffer, // sizeof uncompressed input data
93 const void* inbuffer, // uncompressed input data
94 int sizeof_element
95 );
96
97 /*
98 Returns:
99 Number of bytes in the uncompressed information.
100 */
101 std::size_t SizeOfUncompressedBuffer() const;
102
103 /*
104 Description:
105 Uncompress the contents of this ON_CompressedBuffer.
106 Parameters:
107 outbuffer - [in/out]
108 This buffer must have at least SizeOfUncompressedBuffer() bytes.
109 If the function returns true, then the uncopressed information
110 is stored in this buffer.
111 bFailedCRC - [out]
112 If not null, then this boolean is set to true if the CRC
113 of the uncompressed information has changed.
114 Returns:
115 True if uncompressed information is returned in outbuffer.
116 */
117 bool Uncompress( // read and uncompress
118 void* outbuffer, // uncompressed output data returned here
119 int* bFailedCRC
120 ) const;
121
122 /*
123 Description:
124 Destroy the current informtion in the ON_CompressedBuffer
125 so the class can be reused.
126 */
127 void Destroy();
128
129 bool Write( ON_BinaryArchive& binary_archive ) const;
130 bool Read( ON_BinaryArchive& binary_archive );
131
132 /////////////////////////////////////////////////
133 //
134 // Implementation
135 //
136 bool CompressionInit( struct ON_CompressedBufferHelper* ) const;
137 bool CompressionEnd( struct ON_CompressedBufferHelper* ) const;
138 std::size_t DeflateHelper( // returns number of bytes written
139 struct ON_CompressedBufferHelper*,
140 std::size_t sizeof___inbuffer, // sizeof uncompressed input data ( > 0 )
141 const void* in___buffer // uncompressed input data ( != NULL )
142 );
144 struct ON_CompressedBufferHelper*,
145 std::size_t sizeof___outbuffer, // sizeof uncompressed data
146 void* out___buffer // buffer for uncompressed data
147 ) const;
149 std::size_t count,
150 const void* buffer
151 );
152
157 int m_method; // 0 = copied, 1 = compressed
161};
162
163#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