[Liblas-commits] libpc: don't expose liblas headers\!

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Mar 3 20:40:11 EST 2011


details:   http://hg.liblas.orglibpc/rev/acd792209405
changeset: 169:acd792209405
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Mar 03 17:03:54 2011 -0800
description:
don't expose liblas headers\!
Subject: libpc: swig work

details:   http://hg.liblas.orglibpc/rev/b90ead329da0
changeset: 170:b90ead329da0
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Thu Mar 03 17:39:35 2011 -0800
description:
swig work

diffstat:

 .hgignore                                     |   1 +
 csharp/libpc_swig_cpp/libpc.i                 |  66 +++++++++++++++++++++++++++
 csharp/libpc_swig_cs/libpc_swig_cs.csproj     |   8 +++
 csharp/libpc_swig_test/Program.cs             |   2 +
 csharp/libpc_swig_test/TestLiblasReader.cs    |  26 ++++++++++
 csharp/libpc_swig_test/libpc_swig_test.csproj |   1 +
 src/drivers/liblas/reader.cpp                 |  22 ++++----
 src/drivers/liblas/reader.hpp                 |   5 +-
 8 files changed, 116 insertions(+), 15 deletions(-)

diffs (260 lines):

diff -r 9ccbaa4f4705 -r b90ead329da0 .hgignore
--- a/.hgignore	Thu Mar 03 16:46:50 2011 -0800
+++ b/.hgignore	Thu Mar 03 17:39:35 2011 -0800
@@ -31,3 +31,4 @@
 
 # generated swig files
 csharp/libpc_swig_cs/*.cs
+csharp/libpc_swig_cpp/libpc_wrap.cpp
diff -r 9ccbaa4f4705 -r b90ead329da0 csharp/libpc_swig_cpp/libpc.i
--- a/csharp/libpc_swig_cpp/libpc.i	Thu Mar 03 16:46:50 2011 -0800
+++ b/csharp/libpc_swig_cpp/libpc.i	Thu Mar 03 17:39:35 2011 -0800
@@ -43,6 +43,11 @@
 %{
 #include "libpc/libpc_config.hpp"
 #include "libpc/Dimension.hpp"
+#include "libpc/Header.hpp"
+#include "libpc/Schema.hpp"
+#include "libpc/Reader.hpp"
+#include "libpc/../../src/drivers/liblas/reader.hpp"
+#include "libpc/../../src/drivers/liblas/header.hpp"
 %}
 
 %include "typemaps.i"
@@ -72,6 +77,8 @@
     typedef signed short int16_t;
     typedef unsigned int uint32_t;
     typedef signed int int32_t;
+    typedef unsigned long long uint64_t;
+    typedef signed long long int64_t;
 };
 
 // BUG: how do I do a rename such that "SWIGTYPE_p_std__istream" can
@@ -147,4 +154,63 @@
 
 
 
+class LiblasReader
+{
+public:
+    LiblasReader(std::istream&);
+    const libpc::LiblasHeader& getLiblasHeader() const;
+    boost::int8_t getPointFormatNumber() const;
+};
+
+
+class Stage
+{
+public:
+    Stage();
+    virtual const std::string& getName() const = 0;
+    boost::uint32_t read(PointData&);
+    virtual void readBegin(boost::uint32_t numPointsToRead) = 0;
+    virtual boost::uint32_t readBuffer(PointData&) = 0;
+    virtual void readEnd(boost::uint32_t numPointsRead) = 0;
+    virtual void seekToPoint(boost::uint64_t pointNum) = 0;
+    virtual boost::uint64_t getCurrentPointIndex() const = 0;
+    boost::uint64_t getNumPoints() const;
+    bool atEnd() const;
+    const Header& getHeader() const;
+};
+
+
+class Reader : public Stage
+{
+public:
+    Reader();
+
+    virtual void readBegin(boost::uint32_t numPointsToRead);
+
+    virtual void readEnd(boost::uint32_t numPointsRead);
+
+    virtual void seekToPoint(boost::uint64_t pointNum);
+
+    virtual boost::uint64_t getCurrentPointIndex() const;
+};
+
+
+class LiblasHeader : public Reader
+{
+public:
+    LiblasHeader();
+};
+
+
+
+class Utils
+{
+public:
+    static std::istream* openFile(std::string const& filename, bool asBinary=true);
+    static void closeFile(std::istream* ifs);
+};
+
+
+
+
 }; // namespace
diff -r 9ccbaa4f4705 -r b90ead329da0 csharp/libpc_swig_cs/libpc_swig_cs.csproj
--- a/csharp/libpc_swig_cs/libpc_swig_cs.csproj	Thu Mar 03 16:46:50 2011 -0800
+++ b/csharp/libpc_swig_cs/libpc_swig_cs.csproj	Thu Mar 03 17:39:35 2011 -0800
@@ -88,9 +88,17 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Dimension.cs" />
+    <Compile Include="LiblasHeader.cs" />
+    <Compile Include="LiblasReader.cs" />
     <Compile Include="libpc_swig_cpp.cs" />
     <Compile Include="libpc_swig_cppPINVOKE.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Reader.cs" />
+    <Compile Include="Stage.cs" />
+    <Compile Include="SWIGTYPE_p_Header.cs" />
+    <Compile Include="SWIGTYPE_p_PointData.cs" />
+    <Compile Include="SWIGTYPE_p_std__istream.cs" />
+    <Compile Include="Utils.cs" />
     <Compile Include="VectorU32.cs" />
     <Compile Include="VectorU8.cs" />
   </ItemGroup>
diff -r 9ccbaa4f4705 -r b90ead329da0 csharp/libpc_swig_test/Program.cs
--- a/csharp/libpc_swig_test/Program.cs	Thu Mar 03 16:46:50 2011 -0800
+++ b/csharp/libpc_swig_test/Program.cs	Thu Mar 03 17:39:35 2011 -0800
@@ -48,6 +48,8 @@
       static int Main(string[] args)
       {
          TestDimension a = new TestDimension();
+         
+         TestLiblasReader r = new TestLiblasReader();
 
          return 0;
       }
diff -r 9ccbaa4f4705 -r b90ead329da0 csharp/libpc_swig_test/TestLiblasReader.cs
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/csharp/libpc_swig_test/TestLiblasReader.cs	Thu Mar 03 17:39:35 2011 -0800
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+using Libpc;
+using System.Diagnostics;
+
+namespace libpc_swig_test
+{
+    internal class TestLiblasReader : TestBase
+   {
+      public TestLiblasReader()
+      {
+         Test1();
+      }
+
+      private void Test1()
+      {
+          SWIGTYPE_p_std__istream str = Utils.openFile("../../test/data/simple.las");
+          LiblasReader r = new LiblasReader(str);
+          
+         return;
+      }
+   }
+}
diff -r 9ccbaa4f4705 -r b90ead329da0 csharp/libpc_swig_test/libpc_swig_test.csproj
--- a/csharp/libpc_swig_test/libpc_swig_test.csproj	Thu Mar 03 16:46:50 2011 -0800
+++ b/csharp/libpc_swig_test/libpc_swig_test.csproj	Thu Mar 03 17:39:35 2011 -0800
@@ -78,6 +78,7 @@
     <Compile Include="Program.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="TestDimension.cs" />
+    <Compile Include="TestLiblasReader.cs" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\libpc_swig_cs\libpc_swig_cs.csproj">
diff -r 9ccbaa4f4705 -r b90ead329da0 src/drivers/liblas/reader.cpp
--- a/src/drivers/liblas/reader.cpp	Thu Mar 03 16:46:50 2011 -0800
+++ b/src/drivers/liblas/reader.cpp	Thu Mar 03 17:39:35 2011 -0800
@@ -56,7 +56,7 @@
     , m_offsetY(0.0)
     , m_offsetZ(0.0)
     , m_isCompressed(false)
-    , m_pointFormat(liblas::ePointFormatUnknown)
+    , m_pointFormatNumber(-1)
     , m_hasTimeData(false)
     , m_hasColorData(false)
     , m_hasWaveData(false)
@@ -92,7 +92,7 @@
 
 boost::int8_t LiblasReader::getPointFormatNumber() const
 {
-    return (boost::uint8_t)m_pointFormat;
+    return m_pointFormatNumber;
 }
 
 void LiblasReader::processExternalHeader()
@@ -118,33 +118,33 @@
 
     m_isCompressed = externalHeader.Compressed();
 
-    m_pointFormat = externalHeader.GetDataFormatId();
+    m_pointFormatNumber = (boost::int8_t)externalHeader.GetDataFormatId();
 
     m_hasTimeData = m_hasColorData = m_hasWaveData = false;
-    switch (m_pointFormat)
+    switch (m_pointFormatNumber)
     {
-    case liblas::ePointFormat0:
+    case 0:
         break;
-    case liblas::ePointFormat1:
+    case 1:
         m_hasTimeData = true;
         break;
-    case liblas::ePointFormat2:
+    case 2:
         m_hasColorData = true;
         break;
-    case liblas::ePointFormat3:
+    case 3:
         m_hasTimeData = true;
         m_hasColorData = true;
         break;
-    case liblas::ePointFormat4:
+    case 4:
         m_hasTimeData = true;
         m_hasWaveData = true;
         break;
-    case liblas::ePointFormat5:
+    case 5:
         m_hasColorData = true;
         m_hasTimeData = true;
         m_hasWaveData = true;
         break;
-    case liblas::ePointFormatUnknown:
+    default:
         throw not_yet_implemented("Unknown point format encountered");
     }
 
diff -r 9ccbaa4f4705 -r b90ead329da0 src/drivers/liblas/reader.hpp
--- a/src/drivers/liblas/reader.hpp	Thu Mar 03 16:46:50 2011 -0800
+++ b/src/drivers/liblas/reader.hpp	Thu Mar 03 17:39:35 2011 -0800
@@ -41,13 +41,10 @@
 
 #include "header.hpp"
 
-#include <liblas/version.hpp>
-
 // fwd decls
 namespace liblas
 {
     class Reader;
-    // enum PointFormatName;
 }
 
 
@@ -93,7 +90,7 @@
     double m_offsetZ;
     bool m_isCompressed;
     
-    liblas::PointFormatName m_pointFormat;
+    boost::int8_t m_pointFormatNumber; // should be an enum
     bool m_hasTimeData;
     bool m_hasColorData;
     bool m_hasWaveData;


More information about the Liblas-commits mailing list