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