[Liblas-commits] hg-main-tree: Added rudimentary cmake-swig support for csharp an...

liblas-commits at liblas.org liblas-commits at liblas.org
Wed Mar 16 16:55:51 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/c12273525164
changeset: 308:c12273525164
user:      Pete Gadomski <pete.gadomski at gmail.com>
date:      Wed Mar 16 16:55:46 2011 -0400
description:
Added rudimentary cmake-swig support for csharp and python

diffstat:

 .hgignore                                       |    1 +
 CMakeLists.txt                                  |   19 ++-
 csharp/CMakeLists.txt                           |    2 +-
 csharp/libpc_swig_cs/Properties/AssemblyInfo.cs |   36 -----
 python/CMakeLists.txt                           |    9 +
 python/libpc.i                                  |  145 ++++++++++++++++++++++++
 6 files changed, 169 insertions(+), 43 deletions(-)

diffs (252 lines):

diff -r e0a263e48f83 -r c12273525164 .hgignore
--- a/.hgignore	Wed Mar 16 15:52:29 2011 -0500
+++ b/.hgignore	Wed Mar 16 16:55:46 2011 -0400
@@ -32,6 +32,7 @@
 # generated swig files
 csharp/libpc_swig_cs/*.cs
 csharp/libpc_swig_cpp/libpc_wrap.cpp
+*.pyc
 
 Makefile
 doc/build
diff -r e0a263e48f83 -r c12273525164 CMakeLists.txt
--- a/CMakeLists.txt	Wed Mar 16 15:52:29 2011 -0500
+++ b/CMakeLists.txt	Wed Mar 16 16:55:46 2011 -0400
@@ -252,14 +252,21 @@
   set(WITH_SWIG_CSHARP FALSE CACHE BOOL "Choose if you want to make C# bindings via Swig")
 endif()
 
-if(WITH_SWIG_CSHARP)
-    find_package(swig 2.0.1)
-    if(SWIG_FOUND)
+set(WITH_SWIG_PYTHON FALSE CACHE BOOL "Choose if you want to make Python bindings via Swig")
+
+if(WITH_SWIG_CSHARP OR WITH_SWIG_PYTHON)
+    find_package(swig 2.0.1 REQUIRED)
+    include(${SWIG_USE_FILE})
+    message(STATUS "Found Swig version ${SWIG_VERSION}")
+    if(WITH_SWIG_CSHARP)
         add_subdirectory(csharp)
         set(LIBPC_HAVE_SWIG_CSHARP 1)
-		message(STATUS "Found Swig version ${SWIG_VERSION}")
-	else()
-		message(FATAL_ERROR "Swig not found (required for C# bindings)")
+        message(STATUS "Enabling swig for csharp")
+    endif()
+    if(WITH_SWIG_PYTHON)
+        add_subdirectory(python)
+        set(LIBPC_HAVE_SWIG_PYTHON 1)
+        message(STATUS "Enabling swig for python")
     endif()
 endif()
 
diff -r e0a263e48f83 -r c12273525164 csharp/CMakeLists.txt
--- a/csharp/CMakeLists.txt	Wed Mar 16 15:52:29 2011 -0500
+++ b/csharp/CMakeLists.txt	Wed Mar 16 16:55:46 2011 -0400
@@ -1,1 +1,1 @@
-
+add_subdirectory(libpc_swig_cpp)
\ No newline at end of file
diff -r e0a263e48f83 -r c12273525164 csharp/libpc_swig_cs/Properties/AssemblyInfo.cs
--- a/csharp/libpc_swig_cs/Properties/AssemblyInfo.cs	Wed Mar 16 15:52:29 2011 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following 
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("generated_cs")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Microsoft")]
-[assembly: AssemblyProduct("generated_cs")]
-[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible 
-// to COM components.  If you need to access a type in this assembly from 
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("892a9c92-8c75-4b89-a46f-bda78a6f5bf3")]
-
-// Version information for an assembly consists of the following four values:
-//
-//      Major Version
-//      Minor Version 
-//      Build Number
-//      Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers 
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff -r e0a263e48f83 -r c12273525164 python/CMakeLists.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/python/CMakeLists.txt	Wed Mar 16 16:55:46 2011 -0400
@@ -0,0 +1,9 @@
+find_package(PythonLibs)
+include_directories(${PYTHON_INCLUDE_PATH})
+set_source_files_properties(libpc.i PROPERTIES CPLUSPLUS ON)
+swig_add_module(libpc_py python libpc.i)
+swig_link_libraries(libpc_py ${PYTHON_LIBRARIES})
+set_source_files_properties(${swig_generated_file_fullname} PROPERTIES COMPILE_FLAGS "-I../include")
+set_target_properties(${SWIG_MODULE_libpc_py_REAL_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ".")
+set_target_properties(${SWIG_MODULE_libpc_py_REAL_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ".")
+set_target_properties(${SWIG_MODULE_libpc_py_REAL_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ".")
\ No newline at end of file
diff -r e0a263e48f83 -r c12273525164 python/libpc.i
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/python/libpc.i	Wed Mar 16 16:55:46 2011 -0400
@@ -0,0 +1,145 @@
+/******************************************************************************
+ *
+ * Project:  libPC - http://libpc.org - A BSD library for point clouds
+ * Purpose:  swig/python bindings for libpc
+ * Author:   Pete J. Gadomski (pete.gadomski at gmail.com)
+ *
+ ******************************************************************************
+ * Copyright (c) 2011, Pete J. Gadomski (pete.gadomski at gmail.com)
+ *
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following 
+ * conditions are met:
+ * 
+ *     * Redistributions of source code must retain the above copyright 
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright 
+ *       notice, this list of conditions and the following disclaimer in 
+ *       the documentation and/or other materials provided 
+ *       with the distribution.
+ *     * Neither the name of the Martin Isenburg or Iowa Department 
+ *       of Natural Resources nor the names of its contributors may be 
+ *       used to endorse or promote products derived from this software 
+ *       without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
+ * OF SUCH DAMAGE.
+ ****************************************************************************/
+ 
+%module libpc
+
+%{
+#include <iostream>
+
+#include "libpc/libpc_config.hpp"
+
+#include "libpc/Bounds.hpp"
+
+%}
+
+namespace libpc
+{
+
+template <typename T>
+class Range
+{
+public:
+    typedef T value_type;
+
+    Range();
+    Range(T minimum, T maximum);
+    T getMinimum() const;
+    void setMinimum(T value);
+    T getMaximum() const;
+    void setMaximum(T value);
+    bool equal(Range const& other) const;
+    bool overlaps(Range const& r) const;
+    bool contains(Range const& r) const;
+    bool contains(T v) const;
+    bool empty(void) const;
+    void clip(Range const& r);
+    void grow(T v);
+    void grow(Range const& r);
+    void grow(T lo, T hi);
+    T length() const;
+};
+
+%rename(Range_double) Range<double>;
+%template(Range_double) Range<double>;
+
+template <typename T>
+class Vector
+{
+public:
+    Vector();
+    Vector(T v0);
+    Vector(T v0, T v1);
+    Vector(T v0, T v1, T v2);
+    Vector(std::vector<T> v);
+    Vector(Vector<T> const& rhs);
+    bool operator==(Vector<T> const& rhs) const;
+    bool operator!=(Vector const& rhs) const;
+    T get(std::size_t index);
+    void set(std::size_t index, T v);
+    void set(std::vector<T> v);
+    bool equal(Vector const& other) const;
+    void shift(T v);
+    void scale(T v);
+    std::size_t size() const;
+};
+
+%rename(Vector_double) Vector<double>;
+%template(Vector_double) Vector<double>;
+
+template <typename T>
+class Bounds
+{
+public:
+    typedef typename std::vector< Range<T> > RangeVector;
+    Bounds();
+    Bounds(Bounds const& other);
+    Bounds(RangeVector const& ranges);
+    Bounds(T minx, T miny, T minz, T maxx, T maxy, T maxz);
+    Bounds(T minx, T miny, T maxx, T maxy);
+    Bounds(const Vector<T>& minimum, const Vector<T>& maximum);
+    T getMinimum(std::size_t const& index) const;
+    void setMinimum(std::size_t const& index, T v);
+    T getMaximum(std::size_t const& index) const;
+    void setMaximum(std::size_t const& index, T v);
+    Vector<T> getMinimum();
+    Vector<T> getMaximum();
+    inline bool operator==(Bounds<T> const& rhs) const;
+    inline bool operator!=(Bounds<T> const& rhs) const;
+    RangeVector const& dimensions() const;
+    std::size_t size() const;
+    bool equal(Bounds<T> const& other) const;
+    bool overlaps(Bounds const& other) const;
+    bool contains(Vector<T> point) const;
+    bool contains(Bounds<T> const& other) const;
+    void shift(std::vector<T> deltas);
+    void scale(std::vector<T> deltas);
+    void clip(Bounds const& r);
+    void grow(Bounds const& r);
+    void grow(Vector<T> const& point);
+    T volume() const;
+    bool empty() const;
+    bool verify();
+    
+};
+
+%rename(Bounds_double) Bounds<double>;
+%template(Bounds_double) Bounds<double>;
+
+}; // namespace


More information about the Liblas-commits mailing list