[Liblas-commits] laszip: remove calls to fprintf, exit
liblas-commits at liblas.org
liblas-commits at liblas.org
Mon Dec 27 14:44:51 EST 2010
details: http://hg.liblas.orglaszip/rev/7af78ceb3bfa
changeset: 90:7af78ceb3bfa
user: Michael P. Gerlek <mpg at flaxen.com>
date: Mon Dec 27 12:14:06 2010 -0700
description:
remove calls to fprintf, exit
Subject: laszip: remove fprintf calls
details: http://hg.liblas.orglaszip/rev/ba16595e644c
changeset: 91:ba16595e644c
user: Michael P. Gerlek <mpg at flaxen.com>
date: Mon Dec 27 12:15:58 2010 -0700
description:
remove fprintf calls
Subject: laszip: fix err checks on open()
details: http://hg.liblas.orglaszip/rev/ce1bdb2a9e26
changeset: 92:ce1bdb2a9e26
user: Michael P. Gerlek <mpg at flaxen.com>
date: Mon Dec 27 12:17:59 2010 -0700
description:
fix err checks on open()
Subject: laszip: use an enum for the compression type, for type safety
details: http://hg.liblas.orglaszip/rev/276b21e82629
changeset: 93:276b21e82629
user: Michael P. Gerlek <mpg at flaxen.com>
date: Mon Dec 27 12:35:32 2010 -0700
description:
use an enum for the compression type, for type safety
Subject: laszip: explicit default param no longer needed
details: http://hg.liblas.orglaszip/rev/16cbedc7335f
changeset: 94:16cbedc7335f
user: Michael P. Gerlek <mpg at flaxen.com>
date: Mon Dec 27 12:44:10 2010 -0700
description:
explicit default param no longer needed
diffstat:
include/laszip/lasunzipper.hpp | 4 ++--
include/laszip/laszip.hpp | 13 +++++++++----
include/laszip/laszipper.hpp | 4 ++--
src/bytestreamin_file.hpp | 2 +-
src/bytestreamin_istream.hpp | 2 +-
src/lasreadpoint.cpp | 10 +++++-----
src/lasreadpoint.hpp | 2 +-
src/lasunzipper.cpp | 8 ++++----
src/laswritepoint.cpp | 10 +++++-----
src/laswritepoint.hpp | 2 +-
src/laszipper.cpp | 8 ++++----
src/rangemodel.cpp | 7 +++++--
tools/laszippertest.cpp | 24 ++++++++++++------------
13 files changed, 52 insertions(+), 44 deletions(-)
diffs (truncated from 368 to 300 lines):
diff -r e815143ce051 -r 16cbedc7335f include/laszip/lasunzipper.hpp
--- a/include/laszip/lasunzipper.hpp Thu Dec 23 17:24:25 2010 -0800
+++ b/include/laszip/lasunzipper.hpp Mon Dec 27 12:44:10 2010 -0700
@@ -64,8 +64,8 @@
class LASunzipper
{
public:
- unsigned int open(FILE* file, unsigned int num_items, const LASitem items[], unsigned int compression=0);
- unsigned int open(istream& stream, unsigned int num_items, const LASitem items[], unsigned int compression=0);
+ unsigned int open(FILE* file, unsigned int num_items, const LASitem items[], LASzip::CompressionType compression_type);
+ unsigned int open(istream& stream, unsigned int num_items, const LASitem items[], LASzip::CompressionType compression_type);
bool read(unsigned char * const * point);
unsigned int close();
diff -r e815143ce051 -r 16cbedc7335f include/laszip/laszip.hpp
--- a/include/laszip/laszip.hpp Thu Dec 23 17:24:25 2010 -0800
+++ b/include/laszip/laszip.hpp Mon Dec 27 12:44:10 2010 -0700
@@ -58,11 +58,7 @@
#define LASZIP_VERSION_MINOR 0
#define LASZIP_VERSION_REVISION 0
-#define LASZIP_COMPRESSION_NONE 0
-#define LASZIP_COMPRESSION_ARITHMETIC 1
-#define LASZIP_COMPRESSION_RANGE 2
-#define LASZIP_COMPRESSION_DEFAULT 1
class LASitem
{
@@ -86,6 +82,15 @@
class LASzip
{
public:
+ enum CompressionType
+ {
+ COMPRESSION_NONE = 0,
+ COMPRESSION_ARITHMETIC = 1,
+ COMPRESSION_RANGE = 2,
+ COMPRESSION_DEFAULT = COMPRESSION_ARITHMETIC
+ };
+
+public:
LASzip();
~LASzip();
diff -r e815143ce051 -r 16cbedc7335f include/laszip/laszipper.hpp
--- a/include/laszip/laszipper.hpp Thu Dec 23 17:24:25 2010 -0800
+++ b/include/laszip/laszipper.hpp Mon Dec 27 12:44:10 2010 -0700
@@ -64,8 +64,8 @@
class LASzipper
{
public:
- unsigned int open(FILE* outfile, unsigned int num_items, LASitem items[], unsigned int compression=0);
- unsigned int open(ostream& outstream, unsigned int num_items, LASitem items[], unsigned int compression=0);
+ unsigned int open(FILE* outfile, unsigned int num_items, LASitem items[], LASzip::CompressionType compression_type);
+ unsigned int open(ostream& outstream, unsigned int num_items, LASitem items[], LASzip::CompressionType compression_type);
bool write(const unsigned char* const * point);
unsigned int close();
diff -r e815143ce051 -r 16cbedc7335f src/bytestreamin_file.hpp
--- a/src/bytestreamin_file.hpp Thu Dec 23 17:24:25 2010 -0800
+++ b/src/bytestreamin_file.hpp Mon Dec 27 12:44:10 2010 -0700
@@ -109,7 +109,7 @@
int byte = getc(file);
if (byte == EOF)
{
- fprintf(stderr, "reading EOF\n");
+ //fprintf(stderr, "reading EOF\n");
byte = 0;
}
return (unsigned int)byte;
diff -r e815143ce051 -r 16cbedc7335f src/bytestreamin_istream.hpp
--- a/src/bytestreamin_istream.hpp Thu Dec 23 17:24:25 2010 -0800
+++ b/src/bytestreamin_istream.hpp Mon Dec 27 12:44:10 2010 -0700
@@ -111,7 +111,7 @@
int byte = stream.get();
if (stream.eof())
{
- fprintf(stderr, "reading EOF\n");
+ //fprintf(stderr, "reading EOF\n");
byte = 0;
}
return (unsigned int)byte;
diff -r e815143ce051 -r 16cbedc7335f src/lasreadpoint.cpp
--- a/src/lasreadpoint.cpp Thu Dec 23 17:24:25 2010 -0800
+++ b/src/lasreadpoint.cpp Mon Dec 27 12:44:10 2010 -0700
@@ -63,7 +63,7 @@
dec = 0;
}
-BOOL LASreadPoint::setup(U32 num_items, const LASitem* items, U32 compression)
+BOOL LASreadPoint::setup(U32 num_items, const LASitem* items, LASzip::CompressionType compression_type)
{
U32 i;
@@ -74,15 +74,15 @@
}
// create entropy decoder (if requested)
- switch (compression)
+ switch (compression_type)
{
- case LASZIP_COMPRESSION_NONE:
+ case LASzip::COMPRESSION_NONE:
dec = 0;
break;
- case LASZIP_COMPRESSION_RANGE:
+ case LASzip::COMPRESSION_RANGE:
dec = new RangeDecoder();
break;
- case LASZIP_COMPRESSION_ARITHMETIC:
+ case LASzip::COMPRESSION_ARITHMETIC:
dec = new ArithmeticDecoder();
break;
default:
diff -r e815143ce051 -r 16cbedc7335f src/lasreadpoint.hpp
--- a/src/lasreadpoint.hpp Thu Dec 23 17:24:25 2010 -0800
+++ b/src/lasreadpoint.hpp Mon Dec 27 12:44:10 2010 -0700
@@ -63,7 +63,7 @@
~LASreadPoint();
// should only be called *once*
- BOOL setup(U32 num_items, const LASitem* items, U32 compression=0);
+ BOOL setup(U32 num_items, const LASitem* items, LASzip::CompressionType compression_type);
BOOL init(ByteStreamIn* instream);
BOOL read(U8* const * point);
diff -r e815143ce051 -r 16cbedc7335f src/lasunzipper.cpp
--- a/src/lasunzipper.cpp Thu Dec 23 17:24:25 2010 -0800
+++ b/src/lasunzipper.cpp Mon Dec 27 12:44:10 2010 -0700
@@ -49,26 +49,26 @@
#include "bytestreamin_istream.hpp"
#include "lasreadpoint.hpp"
-unsigned int LASunzipper::open(FILE* infile, unsigned int num_items, const LASitem items[], unsigned int compression)
+unsigned int LASunzipper::open(FILE* infile, unsigned int num_items, const LASitem items[], LASzip::CompressionType compression_type)
{
count = 0;
stream = new ByteStreamInFile(infile);
if (!stream) return 1;
reader = new LASreadPoint();
if (!reader) return 1;
- if (!reader->setup(num_items, items, compression)) return 1;
+ if (!reader->setup(num_items, items, compression_type)) return 1;
if (!reader->init(stream)) return 1;
return 0;
}
-unsigned int LASunzipper::open(istream& instream, unsigned int num_items, const LASitem items[], unsigned int compression)
+unsigned int LASunzipper::open(istream& instream, unsigned int num_items, const LASitem items[], LASzip::CompressionType compression_type)
{
count = 0;
stream = new ByteStreamInIstream(instream);
if (!stream) return 1;
reader = new LASreadPoint();
if (!reader) return 1;
- if (!reader->setup(num_items, items, compression)) return 1;
+ if (!reader->setup(num_items, items, compression_type)) return 1;
if (!reader->init(stream)) return 1;
return 0;
}
diff -r e815143ce051 -r 16cbedc7335f src/laswritepoint.cpp
--- a/src/laswritepoint.cpp Thu Dec 23 17:24:25 2010 -0800
+++ b/src/laswritepoint.cpp Mon Dec 27 12:44:10 2010 -0700
@@ -63,7 +63,7 @@
enc = 0;
}
-BOOL LASwritePoint::setup(U32 num_items, LASitem* items, U32 compression)
+BOOL LASwritePoint::setup(U32 num_items, LASitem* items, LASzip::CompressionType compression_type)
{
U32 i;
@@ -74,15 +74,15 @@
}
// create entropy encoder (if requested)
- switch (compression)
+ switch (compression_type)
{
- case LASZIP_COMPRESSION_NONE:
+ case LASzip::COMPRESSION_NONE:
enc = 0;
break;
- case LASZIP_COMPRESSION_RANGE:
+ case LASzip::COMPRESSION_RANGE:
enc = new RangeEncoder();
break;
- case LASZIP_COMPRESSION_ARITHMETIC:
+ case LASzip::COMPRESSION_ARITHMETIC:
enc = new ArithmeticEncoder();
break;
default:
diff -r e815143ce051 -r 16cbedc7335f src/laswritepoint.hpp
--- a/src/laswritepoint.hpp Thu Dec 23 17:24:25 2010 -0800
+++ b/src/laswritepoint.hpp Mon Dec 27 12:44:10 2010 -0700
@@ -63,7 +63,7 @@
~LASwritePoint();
// should only be called *once*
- BOOL setup(U32 num_items, LASitem* items, U32 compression=0);
+ BOOL setup(U32 num_items, LASitem* items, LASzip::CompressionType compression_type);
BOOL init(ByteStreamOut* outstream);
BOOL write(const U8 * const * point);
diff -r e815143ce051 -r 16cbedc7335f src/laszipper.cpp
--- a/src/laszipper.cpp Thu Dec 23 17:24:25 2010 -0800
+++ b/src/laszipper.cpp Mon Dec 27 12:44:10 2010 -0700
@@ -49,26 +49,26 @@
#include "bytestreamout_ostream.hpp"
#include "laswritepoint.hpp"
-unsigned int LASzipper::open(FILE* outfile, unsigned int num_items, LASitem items[], unsigned int compression)
+unsigned int LASzipper::open(FILE* outfile, unsigned int num_items, LASitem items[], LASzip::CompressionType compression_type)
{
count = 0;
stream = new ByteStreamOutFile(outfile);
if (!stream) return 1;
writer = new LASwritePoint();
if (!writer) return 1;
- if (!writer->setup(num_items, items, compression)) return 1;
+ if (!writer->setup(num_items, items, compression_type)) return 1;
if (!writer->init(stream)) return 1;
return 0;
}
-unsigned int LASzipper::open(ostream& outstream, unsigned int num_items, LASitem items[], unsigned int compression)
+unsigned int LASzipper::open(ostream& outstream, unsigned int num_items, LASitem items[], LASzip::CompressionType compression_type)
{
count = 0;
stream = new ByteStreamOutOstream(outstream);
if (!stream) return 1;
writer = new LASwritePoint();
if (!writer) return 1;
- if (!writer->setup(num_items, items, compression)) return 1;
+ if (!writer->setup(num_items, items, compression_type)) return 1;
if (!writer->init(stream)) return 1;
return 0;
}
diff -r e815143ce051 -r 16cbedc7335f src/rangemodel.cpp
--- a/src/rangemodel.cpp Thu Dec 23 17:24:25 2010 -0800
+++ b/src/rangemodel.cpp Mon Dec 27 12:44:10 2010 -0700
@@ -48,6 +48,8 @@
#include <stdio.h>
#include <stdlib.h>
+#include <stdexcept>
+
/* initialisation of model */
/* n number of symbols in that model */
/* compress set to 1 on compression, 0 on decompression */
@@ -120,8 +122,9 @@
}
if (c!=newf[0])
{
- fprintf(stderr,"BUG: rescaling left %d total frequency\n",c);
- exit(1);
+ //fprintf(stderr,"BUG: rescaling left %d total frequency\n",c);
+ //exit(1);
+ throw std::runtime_error("laszip internal error: RangeModel::dorescale()");
}
newf[0] = newf[0]>>1 | 1;
missing -= newf[0];
diff -r e815143ce051 -r 16cbedc7335f tools/laszippertest.cpp
--- a/tools/laszippertest.cpp Thu Dec 23 17:24:25 2010 -0800
+++ b/tools/laszippertest.cpp Mon Dec 27 12:44:10 2010 -0700
@@ -154,7 +154,7 @@
ostream1 = new ofstream();
ostream1->open("test1.lax", std::ios::out | std::ios::binary );
#endif
- if (laszipper1->open(*ostream1, num_items, items, LASZIP_COMPRESSION_NONE) != 0)
+ if (laszipper1->open(*ostream1, num_items, items, LASzip::COMPRESSION_NONE) != 0)
{
fprintf(stderr, "ERROR: could not open laszipper1\n");
return 0;
@@ -168,7 +168,7 @@
ostream2 = new ofstream();
ostream2->open("test2.lax", std::ios::out | std::ios::binary );
#endif
- if (laszipper2->open(*ostream2, num_items, items, LASZIP_COMPRESSION_ARITHMETIC) != 0)
+ if (laszipper2->open(*ostream2, num_items, items, LASzip::COMPRESSION_ARITHMETIC) != 0)
{
fprintf(stderr, "ERROR: could not open laszipper2\n");
return 0;
@@ -182,7 +182,7 @@
ostream3 = new ofstream();
ostream3->open("test3.lax", std::ios::out | std::ios::binary );
#endif
- if (laszipper3->open(*ostream3, num_items, items, LASZIP_COMPRESSION_RANGE) != 0)
+ if (laszipper3->open(*ostream3, num_items, items, LASzip::COMPRESSION_RANGE) != 0)
{
fprintf(stderr, "ERROR: could not open laszipper3\n");
return 0;
@@ -191,21 +191,21 @@
else
{
ofile1 = fopen("test1.lax", "wb");
- if (!laszipper1->open(ofile1, num_items, items, LASZIP_COMPRESSION_NONE))
+ if (laszipper1->open(ofile1, num_items, items, LASzip::COMPRESSION_NONE) != 0)
{
More information about the Liblas-commits
mailing list