[Liblas-commits] hg-main-tree: add impedance checking to colorizer
filter
liblas-commits at liblas.org
liblas-commits at liblas.org
Thu Mar 17 09:39:28 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/6bc2e32f9db3
changeset: 309:6bc2e32f9db3
user: Michael P. Gerlek <mpg at flaxen.com>
date: Thu Mar 17 09:38:58 2011 -0400
description:
add impedance checking to colorizer filter
Subject: hg-main-tree: merge
details: http://hg.libpc.orghg-main-tree/rev/16927985169c
changeset: 310:16927985169c
user: Michael P. Gerlek <mpg at flaxen.com>
date: Thu Mar 17 09:39:21 2011 -0400
description:
merge
diffstat:
.hgignore | 1 +
CMakeLists.txt | 19 ++-
csharp/CMakeLists.txt | 2 +-
csharp/libpc_swig_cs/Properties/AssemblyInfo.cs | 36 -----
include/libpc/PointData.hpp | 10 +-
include/libpc/Schema.hpp | 16 ++-
include/libpc/exceptions.hpp | 11 +-
include/libpc/filters/ColorFilter.hpp | 2 +-
python/CMakeLists.txt | 9 +
python/libpc.i | 145 ++++++++++++++++++++++++
src/PointData.cpp | 4 +
src/drivers/faux/Reader.cpp | 12 +-
src/filters/CacheFilter.cpp | 2 +-
src/filters/ColorFilter.cpp | 36 +++++-
test/unit/CMakeLists.txt | 1 +
test/unit/ColorFilterTest.cpp | 53 ++++++++
test/unit/SchemaTest.cpp | 8 +
17 files changed, 308 insertions(+), 59 deletions(-)
diffs (truncated from 569 to 300 lines):
diff -r bc9106554d70 -r 16927985169c .hgignore
--- a/.hgignore Wed Mar 16 16:21:48 2011 -0400
+++ b/.hgignore Thu Mar 17 09:39:21 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 bc9106554d70 -r 16927985169c CMakeLists.txt
--- a/CMakeLists.txt Wed Mar 16 16:21:48 2011 -0400
+++ b/CMakeLists.txt Thu Mar 17 09:39:21 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 bc9106554d70 -r 16927985169c csharp/CMakeLists.txt
--- a/csharp/CMakeLists.txt Wed Mar 16 16:21:48 2011 -0400
+++ b/csharp/CMakeLists.txt Thu Mar 17 09:39:21 2011 -0400
@@ -1,1 +1,1 @@
-
+add_subdirectory(libpc_swig_cpp)
\ No newline at end of file
diff -r bc9106554d70 -r 16927985169c csharp/libpc_swig_cs/Properties/AssemblyInfo.cs
--- a/csharp/libpc_swig_cs/Properties/AssemblyInfo.cs Wed Mar 16 16:21:48 2011 -0400
+++ /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 bc9106554d70 -r 16927985169c include/libpc/PointData.hpp
--- a/include/libpc/PointData.hpp Wed Mar 16 16:21:48 2011 -0400
+++ b/include/libpc/PointData.hpp Thu Mar 17 09:39:21 2011 -0400
@@ -69,11 +69,13 @@
// number of points in this buffer
boost::uint32_t getNumPoints() const;
- inline void setNumPoints(boost::uint32_t v) { m_numPoints = v; }
+ inline void setNumPoints(boost::uint32_t v) { assert(v <= m_capacity);m_numPoints = v; }
+ inline boost::uint32_t& getNumPointsRef() {assert(m_numPoints <= m_capacity);return m_numPoints; }
+
// number of points in this buffer that have legit data; initially will be zero,
// and after a read() call it will be in the range 0 to getNumPoints()-1
- boost::uint32_t getCapacity();
+ inline boost::uint32_t getCapacity() { return m_capacity; }
// schema (number and kinds of fields) for a point in this buffer
const SchemaLayout& getSchemaLayout() const
@@ -119,7 +121,7 @@
inline void PointData::setField(std::size_t pointIndex, std::size_t fieldIndex, T value)
{
std::size_t offset = (pointIndex * m_pointSize) + m_schemaLayout.getDimensionLayout(fieldIndex).getByteOffset();
- assert(offset + sizeof(T) <= m_pointSize * m_numPoints);
+ assert(offset + sizeof(T) <= m_pointSize * m_capacity);
boost::uint8_t* p = m_data + offset;
*(T*)p = value;
@@ -130,7 +132,7 @@
inline T PointData::getField(std::size_t pointIndex, std::size_t fieldIndex) const
{
std::size_t offset = (pointIndex * m_pointSize) + m_schemaLayout.getDimensionLayout(fieldIndex).getByteOffset();
- assert(offset + sizeof(T) <= m_pointSize * m_numPoints);
+ assert(offset + sizeof(T) <= m_pointSize * m_capacity);
boost::uint8_t* p = m_data + offset;
return *(T*)p;
diff -r bc9106554d70 -r 16927985169c include/libpc/Schema.hpp
--- a/include/libpc/Schema.hpp Wed Mar 16 16:21:48 2011 -0400
+++ b/include/libpc/Schema.hpp Thu Mar 17 09:39:21 2011 -0400
@@ -97,7 +97,21 @@
return index != -1;
}
- // returns -1 if the index not found
+ bool hasDimension(Dimension::Field field, Dimension::DataType datatype) const
+ {
+ int index = m_indexTable[field];
+ if (index == -1) return false;
+ const Dimension& dim = m_dimensions[index];
+ if (dim.getDataType() != datatype) return false;
+ return true;
+ }
+
+ bool hasDimension(const Dimension& dim) const
+ {
+ return hasDimension(dim.getField(), dim.getDataType());
+ }
+
+ // assumes the index does, in fact, exist
int getDimensionIndex(Dimension::Field field) const
{
int index = m_indexTable[field];
diff -r bc9106554d70 -r 16927985169c include/libpc/exceptions.hpp
--- a/include/libpc/exceptions.hpp Wed Mar 16 16:21:48 2011 -0400
+++ b/include/libpc/exceptions.hpp Thu Mar 17 09:39:21 2011 -0400
@@ -73,7 +73,7 @@
/// Flags are composed with composed with Point::DataMemberFlag.
/// Testing flags example: bool timeValid = e.who() & Point::eTime;
unsigned int who() const
- {
+ {
return m_who;
}
@@ -101,6 +101,15 @@
{}
};
+// for when a stage doesn't get the schema it expects
+class impedance_invalid : public libpc_error
+{
+public:
+
+ impedance_invalid(std::string const& msg)
+ : libpc_error(msg)
+ {}
+};
// use this for attempts to use a feature not compiled in, e.g. laszip or gdal
class configuration_error : public libpc_error
diff -r bc9106554d70 -r 16927985169c include/libpc/filters/ColorFilter.hpp
--- a/include/libpc/filters/ColorFilter.hpp Wed Mar 16 16:21:48 2011 -0400
+++ b/include/libpc/filters/ColorFilter.hpp Thu Mar 17 09:39:21 2011 -0400
@@ -53,7 +53,7 @@
private:
boost::uint32_t readBuffer(PointData&);
-
+ void checkImpedance();
void getColor(float value, boost::uint8_t& red, boost::uint8_t& green, boost::uint8_t& blue);
ColorFilter& operator=(const ColorFilter&); // not implemented
diff -r bc9106554d70 -r 16927985169c python/CMakeLists.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/python/CMakeLists.txt Thu Mar 17 09:39:21 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 bc9106554d70 -r 16927985169c python/libpc.i
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/python/libpc.i Thu Mar 17 09:39:21 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);
More information about the Liblas-commits
mailing list