Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dmitri Naumov
ogs
Commits
7384ffe7
Commit
7384ffe7
authored
12 years ago
by
Karsten Rink
Browse files
Options
Downloads
Patches
Plain Diff
added compress + uncompress methods for bytestreams using zlib
parent
66d7e7e5
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CMakeLists.txt
+1
-0
1 addition, 0 deletions
CMakeLists.txt
FileIO/RapidXmlIO/zLibDataCompressor.cpp
+64
-0
64 additions, 0 deletions
FileIO/RapidXmlIO/zLibDataCompressor.cpp
FileIO/RapidXmlIO/zLibDataCompressor.h
+39
-0
39 additions, 0 deletions
FileIO/RapidXmlIO/zLibDataCompressor.h
with
104 additions
and
0 deletions
CMakeLists.txt
+
1
−
0
View file @
7384ffe7
...
@@ -90,6 +90,7 @@ ENDIF() #OGS_PACKAGING
...
@@ -90,6 +90,7 @@ ENDIF() #OGS_PACKAGING
ADD_SUBDIRECTORY
(
ThirdParty
)
ADD_SUBDIRECTORY
(
ThirdParty
)
INCLUDE_DIRECTORIES
(
${
CMAKE_SOURCE_DIR
}
/ThirdParty
)
INCLUDE_DIRECTORIES
(
${
CMAKE_SOURCE_DIR
}
/ThirdParty
)
INCLUDE_DIRECTORIES
(
${
CMAKE_SOURCE_DIR
}
/ThirdParty/quickcheck
)
INCLUDE_DIRECTORIES
(
${
CMAKE_SOURCE_DIR
}
/ThirdParty/quickcheck
)
INCLUDE_DIRECTORIES
(
${
CMAKE_BINARY_DIR
}
/ThirdParty/zlib
)
ADD_SUBDIRECTORY
(
BaseLib
)
ADD_SUBDIRECTORY
(
BaseLib
)
ADD_SUBDIRECTORY
(
FemLib
)
ADD_SUBDIRECTORY
(
FemLib
)
...
...
This diff is collapsed.
Click to expand it.
FileIO/RapidXmlIO/zLibDataCompressor.cpp
0 → 100644
+
64
−
0
View file @
7384ffe7
/**
* Copyright (c) 2012, OpenGeoSys Community (http://www.opengeosys.net)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.net/LICENSE.txt
*
* \file zLibDataCompressor.cpp
*
* Created on 2012-11-26 by Karsten Rink
* Based on the vtkZLibDataCompressor-class in VTK 5.6
*/
#include
"zLibDataCompressor.h"
#include
<cstddef>
#include
<iostream>
#include
"zlib/zlib.h"
unsigned
long
zLibDataCompressor
::
CompressBuffer
(
const
unsigned
char
*
uncompressedData
,
unsigned
long
uncompressedSize
,
unsigned
char
*
compressedData
,
unsigned
long
compressionSpace
)
{
int
CompressionLevel
=
Z_DEFAULT_COMPRESSION
;
unsigned
long
compressedSize
=
compressionSpace
;
Bytef
*
cd
=
reinterpret_cast
<
Bytef
*>
(
compressedData
);
const
Bytef
*
ud
=
reinterpret_cast
<
const
Bytef
*>
(
uncompressedData
);
// Call zlib's compress function.
if
(
compress2
(
cd
,
&
compressedSize
,
ud
,
uncompressedSize
,
CompressionLevel
)
!=
Z_OK
)
{
std
::
cout
<<
"Zlib error while compressing data."
<<
std
::
endl
;
return
0
;
}
return
compressedSize
;
}
unsigned
long
zLibDataCompressor
::
UncompressBuffer
(
const
unsigned
char
*
compressedData
,
unsigned
long
compressedSize
,
unsigned
char
*
uncompressedData
,
unsigned
long
uncompressedSize
)
{
unsigned
long
decSize
=
uncompressedSize
;
Bytef
*
ud
=
reinterpret_cast
<
Bytef
*>
(
uncompressedData
);
const
Bytef
*
cd
=
reinterpret_cast
<
const
Bytef
*>
(
compressedData
);
// Call zlib's uncompress function.
if
(
uncompress
(
ud
,
&
decSize
,
cd
,
compressedSize
)
!=
Z_OK
)
{
std
::
cout
<<
"Zlib error while uncompressing data."
<<
std
::
endl
;
return
0
;
}
// Make sure the output size matched that expected.
if
(
decSize
!=
uncompressedSize
)
{
std
::
cout
<<
"Decompression produced incorrect size. Expected "
<<
uncompressedSize
<<
" and got "
<<
decSize
<<
std
::
endl
;
return
0
;
}
return
decSize
;
}
This diff is collapsed.
Click to expand it.
FileIO/RapidXmlIO/zLibDataCompressor.h
0 → 100644
+
39
−
0
View file @
7384ffe7
/**
* Copyright (c) 2012, OpenGeoSys Community (http://www.opengeosys.net)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.net/LICENSE.txt
*
* \file zLibDataCompressor.h
*
* Created on 2012-11-26 by Karsten Rink
* Based on the vtkZLibDataCompressor-class in VTK 5.6
*/
#ifndef ZLIBDATACOMPRESSOR_H
#define ZLIBDATACOMPRESSOR_H
class
zLibDataCompressor
{
public:
unsigned
long
GetMaximumCompressionSpace
(
unsigned
long
size
);
// Compression method required by vtkDataCompressor.
static
unsigned
long
CompressBuffer
(
const
unsigned
char
*
uncompressedData
,
unsigned
long
uncompressedSize
,
unsigned
char
*
compressedData
,
unsigned
long
compressionSpace
);
// Decompression method required by vtkDataCompressor.
static
unsigned
long
UncompressBuffer
(
const
unsigned
char
*
compressedData
,
unsigned
long
compressedSize
,
unsigned
char
*
uncompressedData
,
unsigned
long
uncompressedSize
);
private:
};
#endif //ZLIBDATACOMPRESSOR_H
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment