[Liblas-commits] laszip: move header functions into .cpp file

liblas-commits at liblas.org liblas-commits at liblas.org
Wed Dec 22 16:09:58 EST 2010


changeset b939bfb7bdf7 in /Volumes/Data/www/liblas.org/laszip
details: http://hg.liblas.orglaszip?cmd=changeset;node=b939bfb7bdf7
summary: move header functions into .cpp file

diffstat:

 include/laszip/laszip.hpp |  193 +++------------------------------------
 src/CMakeLists.txt        |    1 +
 src/Makefile.am           |    1 +
 src/lasunzipper.cpp       |    1 -
 src/laszip.cpp            |  225 ++++++++++++++++++++++++++++++++++++++++++++++
 src/laszipper.cpp         |    1 -
 6 files changed, 242 insertions(+), 180 deletions(-)

diffs (truncated from 491 to 300 lines):

diff -r e8f5528c3d30 -r b939bfb7bdf7 include/laszip/laszip.hpp
--- a/include/laszip/laszip.hpp	Wed Dec 22 11:25:03 2010 -0800
+++ b/include/laszip/laszip.hpp	Wed Dec 22 13:09:56 2010 -0800
@@ -67,173 +67,29 @@
 class LASitem
 {
 public:
+  enum Type { BYTE = 0, SHORT, INT, LONG, FLOAT, DOUBLE, POINT10, GPSTIME11, RGB12, WAVEPACKET13 } type;
 
-  enum Type { BYTE = 0, SHORT, INT, LONG, FLOAT, DOUBLE, POINT10, GPSTIME11, RGB12, WAVEPACKET13 } type;
+  // number parameter only used when setting to BYTE
+  void set(LASitem::Type t, unsigned short number=1);
+
+  bool is_type(LASitem::Type t) const;
+  bool supported_type() const;
+  bool supported_size() const;
+  bool supported_version() const;
+  bool supported() const;
+
+public:
   unsigned short size;
   unsigned short version;
-
-  void set(LASitem::Type t, unsigned int number=1)
-  {
-    switch (t)
-    {
-    case LASitem::POINT10:
-        type = LASitem::POINT10;
-        size = 20;
-        version = 0;
-        break;
-    case LASitem::GPSTIME11:
-        type = LASitem::GPSTIME11;
-        size = 8;
-        version = 0;
-        break;
-    case LASitem::RGB12:
-        type = LASitem::RGB12;
-        size = 6;
-        version = 0;
-        break;
-    case LASitem::WAVEPACKET13:
-        type = LASitem::WAVEPACKET13;
-        size = 29;
-        version = 0;
-        break;
-    case LASitem::BYTE:
-        type = LASitem::BYTE;
-        size = number;
-        version = 0;
-        break;
-    default:
-        throw 0; // BUG
-    }
-    return;
-  }
-
-  bool is_type(LASitem::Type t) const
-  {
-    if (t != type) return false;
-    switch (t)
-    {
-    case POINT10:
-      if (size != 20) return false;
-      break;
-    case GPSTIME11:
-      if (size != 8) return false;
-      break;
-    case RGB12:
-      if (size != 6) return false;
-      break;
-    case WAVEPACKET13:
-      if (size != 29) return false;
-      break;
-    case BYTE:
-      if (size < 1) return false;
-      break;
-    default:
-      return false;
-    }
-    return true;
-  }
-
-  bool supported_type() const
-  {
-    switch (type)
-    {
-    case POINT10:
-    case GPSTIME11:
-    case RGB12:
-    case WAVEPACKET13:
-    case BYTE:
-      return true;
-      break;
-    default:
-      return false;
-    }
-    return false;
-  }
-
-  bool supported_size() const
-  {
-    switch (type)
-    {
-    case POINT10:
-      if (size != 20) return false;
-      break;
-    case GPSTIME11:
-      if (size != 8) return false;
-      break;
-    case RGB12:
-      if (size != 6) return false;
-      break;
-    case WAVEPACKET13:
-      if (size != 29) return false;
-      break;
-    case BYTE:
-      if (size < 1) return false;
-      break;
-    default:
-      return false;
-    }
-    return true;
-  }
-
-  bool supported_version() const
-  {
-    switch (type)
-    {
-    case POINT10:
-      if (version > 1) return false;
-      break;
-    case GPSTIME11:
-      if (version > 1) return false;
-      break;
-    case RGB12:
-      if (version > 1) return false;
-      break;
-    case WAVEPACKET13:
-      if (version > 1) return false;
-      break;
-    case BYTE:
-      if (version > 1) return false;
-      break;
-    default:
-      return false;
-    }
-    return true;
-  }
-
-  bool supported() const
-  {
-    switch (type)
-    {
-    case POINT10:
-      if (size != 20) return false;
-      if (version > 1) return false;
-      break;
-    case GPSTIME11:
-      if (size != 8) return false;
-      if (version > 1) return false;
-      break;
-    case RGB12:
-      if (size != 6) return false;
-      if (version > 1) return false;
-      break;
-    case WAVEPACKET13:
-      if (size != 29) return false;
-      if (version > 1) return false;
-      break;
-    case BYTE:
-      if (size < 1) return false;
-      if (version > 1) return false;
-      break;
-    default:
-      return false;
-    }
-    return true;
-  }
 };
 
 class LASzip
 {
 public:
+    LASzip();
+    ~LASzip();
+
+public:
   unsigned int compression;
   unsigned char version_major;
   unsigned char version_minor;
@@ -244,25 +100,6 @@
   SIGNED_INT64 num_points;  /* not mandatory ... -1 if unknown */
   SIGNED_INT64 num_bytes;   /* not mandatory ... -1 if unknown */
   LASitem* items;
-
-  LASzip()
-  {
-    compression = 0;
-    version_major = 1;
-    version_minor = 0;
-    version_revision = 0;
-    options = 0;
-    num_items = 0;
-    num_chunks = 1;
-    num_points = -1;
-    num_bytes = -1;
-    items = 0;
-  }
-
-  ~LASzip()
-  {
-    if (items) delete [] items;
-  }
 };
 
 /*
diff -r e8f5528c3d30 -r b939bfb7bdf7 src/CMakeLists.txt
--- a/src/CMakeLists.txt	Wed Dec 22 11:25:03 2010 -0800
+++ b/src/CMakeLists.txt	Wed Dec 22 13:09:56 2010 -0800
@@ -44,6 +44,7 @@
     lasunzipper.cpp
     laswriteitemcompressed_v1.cpp
     laswritepoint.cpp
+    laszip.cpp
     laszipper.cpp
     rangeencoder.cpp
     rangedecoder.cpp
diff -r e8f5528c3d30 -r b939bfb7bdf7 src/Makefile.am
--- a/src/Makefile.am	Wed Dec 22 11:25:03 2010 -0800
+++ b/src/Makefile.am	Wed Dec 22 13:09:56 2010 -0800
@@ -11,6 +11,7 @@
 						lasreaditemcompressed_v1.cpp \
 						laswritepoint.cpp \
 						lasreadpoint.cpp \
+						laszip.cpp \
 						laszipper.cpp \
 						lasunzipper.cpp \
 						rangeencoder.cpp \
diff -r e8f5528c3d30 -r b939bfb7bdf7 src/lasunzipper.cpp
--- a/src/lasunzipper.cpp	Wed Dec 22 11:25:03 2010 -0800
+++ b/src/lasunzipper.cpp	Wed Dec 22 13:09:56 2010 -0800
@@ -86,7 +86,6 @@
   if (reader) delete reader;
   reader = 0;
   unsigned int byteCount = stream->byteCount();
-  if (stream) delete stream;
   stream = 0;
   return byteCount;
 }
diff -r e8f5528c3d30 -r b939bfb7bdf7 src/laszip.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/laszip.cpp	Wed Dec 22 13:09:56 2010 -0800
@@ -0,0 +1,225 @@
+/******************************************************************************
+ *
+ * Project:  integrating laszip into liblas - http://liblas.org -
+ * Purpose:
+ * Author:   Martin Isenburg
+ *           isenburg at cs.unc.edu
+ *
+ ******************************************************************************
+ * Copyright (c) 2010, Martin Isenburg
+ *
+ * This is free software; you can redistribute and/or modify it under
+ * the terms of the GNU Lesser General Licence as published
+ * by the Free Software Foundation.
+ *
+ * See the COPYING file for more information.
+ *
+ ****************************************************************************/
+
+/*
+===============================================================================
+
+  FILE:  laszip.cpp
+  
+  CONTENTS:
+  
+    see corresponding header file
+  
+  PROGRAMMERS:
+  
+    martin isenburg at cs.unc.edu
+  
+  COPYRIGHT:
+  
+    copyright (C) 2010  martin isenburg at cs.unc.edu
+    
+    This software is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  
+  CHANGE HISTORY:
+  
+    see corresponding header file
+  
+===============================================================================
+*/


More information about the Liblas-commits mailing list