[Liblas-commits] libpc: mosaicker basically working

liblas-commits at liblas.org liblas-commits at liblas.org
Tue Feb 8 14:03:32 EST 2011


details:   http://hg.liblas.orglibpc/rev/bfdaef209a3a
changeset: 11:bfdaef209a3a
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Tue Feb 08 11:03:16 2011 -0800
description:
mosaicker basically working

diffstat:

 include/libpc/Bounds.hpp         |    3 +
 include/libpc/CropFilter.hpp     |    1 +
 include/libpc/DemosaicFilter.hpp |   58 ++++++++++++++++++
 include/libpc/FauxReader.hpp     |    4 +-
 include/libpc/FauxWriter.hpp     |    2 +-
 include/libpc/Field.hpp          |    1 +
 include/libpc/MosaicFilter.hpp   |   60 ++++++++++++++++++
 include/libpc/PointData.hpp      |   24 ++++---
 include/libpc/PointLayout.hpp    |    8 +-
 src/Bounds.cpp                   |   20 ++++++
 src/CropFilter.cpp               |   16 +++-
 src/DemosaicFilter.cpp           |   75 +++++++++++++++++++++++
 src/FauxReader.cpp               |   26 ++++---
 src/FauxWriter.cpp               |   35 ++++-----
 src/Field.cpp                    |   15 ++++-
 src/Header.cpp                   |   10 +++
 src/MosaicFilter.cpp             |  125 +++++++++++++++++++++++++++++++++++++++
 src/PointData.cpp                |   40 +++++++++---
 src/PointLayout.cpp              |   32 ++++++++-
 src/main.cpp                     |   49 ++++++++++++++-
 src/prototype.vcxproj            |    4 +
 21 files changed, 538 insertions(+), 70 deletions(-)

diffs (truncated from 933 to 300 lines):

diff -r d541e1299674 -r bfdaef209a3a include/libpc/Bounds.hpp
--- a/include/libpc/Bounds.hpp	Tue Feb 08 09:11:46 2011 -0800
+++ b/include/libpc/Bounds.hpp	Tue Feb 08 11:03:16 2011 -0800
@@ -89,6 +89,9 @@
     return (x >= m_minX && x <= m_maxX && y >= m_minY && y <= m_maxY && z >= m_minZ && z <= m_maxZ);
   }
 
+  // enlarge the bbox of 'this' to include the points of 'other'
+  void grow(const Bounds& other);
+
   void dump() const;
 
   double m_minX;
diff -r d541e1299674 -r bfdaef209a3a include/libpc/CropFilter.hpp
--- a/include/libpc/CropFilter.hpp	Tue Feb 08 09:11:46 2011 -0800
+++ b/include/libpc/CropFilter.hpp	Tue Feb 08 11:03:16 2011 -0800
@@ -40,6 +40,7 @@
 
 
 // removes any points outside of the given range
+// updates the header accordingly
 class CropFilter : public Filter
 {
 public:
diff -r d541e1299674 -r bfdaef209a3a include/libpc/DemosaicFilter.hpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/libpc/DemosaicFilter.hpp	Tue Feb 08 11:03:16 2011 -0800
@@ -0,0 +1,58 @@
+/******************************************************************************
+* Copyright (c) 2011, Michael P. Gerlek (mpg at flaxen.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 Hobu, Inc. or Flaxen Geo Consulting 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.
+****************************************************************************/
+
+#ifndef INCLUDED_DEMOSAICFILTER_HPP
+#define INCLUDED_DEMOSAICFILTER_HPP
+
+#include "libpc/Filter.hpp"
+#include "libpc/Bounds.hpp"
+
+
+// removes any points outside of the given range
+class DemosaicFilter : public Filter
+{
+public:
+  DemosaicFilter(Stage& prevStage);
+  void initialize();
+
+  void updateLayout();
+
+  void readNextPoints(PointData&);
+
+private:
+  DemosaicFilter& operator=(const DemosaicFilter&); // not implemented
+  DemosaicFilter(const DemosaicFilter&); // not implemented
+};
+
+#endif
diff -r d541e1299674 -r bfdaef209a3a include/libpc/FauxReader.hpp
--- a/include/libpc/FauxReader.hpp	Tue Feb 08 09:11:46 2011 -0800
+++ b/include/libpc/FauxReader.hpp	Tue Feb 08 11:03:16 2011 -0800
@@ -40,7 +40,9 @@
 class FauxReader : public Reader
 {
 public:
-  FauxReader(std::string file);
+  // generates N points randomly within the bounds
+  FauxReader(const Bounds&, int numPoints);
+
   void initialize();
 
   void updateLayout();
diff -r d541e1299674 -r bfdaef209a3a include/libpc/FauxWriter.hpp
--- a/include/libpc/FauxWriter.hpp	Tue Feb 08 09:11:46 2011 -0800
+++ b/include/libpc/FauxWriter.hpp	Tue Feb 08 11:03:16 2011 -0800
@@ -42,7 +42,7 @@
 class FauxWriter : public Writer
 {
 public:
-  FauxWriter(std::string filename, Stage& prevStage);
+  FauxWriter(Stage& prevStage);
   void initialize();
 
   void updateLayout();
diff -r d541e1299674 -r bfdaef209a3a include/libpc/Field.hpp
--- a/include/libpc/Field.hpp	Tue Feb 08 09:11:46 2011 -0800
+++ b/include/libpc/Field.hpp	Tue Feb 08 11:03:16 2011 -0800
@@ -77,6 +77,7 @@
   Field(const Field&);
 
   Field& operator=(const Field&);
+  bool operator==(const Field& other) const;
 
   DataItem getItem() const { return m_item; }
   DataType getType() const { return m_type; }
diff -r d541e1299674 -r bfdaef209a3a include/libpc/MosaicFilter.hpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/libpc/MosaicFilter.hpp	Tue Feb 08 11:03:16 2011 -0800
@@ -0,0 +1,60 @@
+/******************************************************************************
+* Copyright (c) 2011, Michael P. Gerlek (mpg at flaxen.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 Hobu, Inc. or Flaxen Geo Consulting 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.
+****************************************************************************/
+
+#ifndef INCLUDED_MOSAICFILTER_HPP
+#define INCLUDED_MOSAICFILTER_HPP
+
+#include "libpc/Filter.hpp"
+#include "libpc/Bounds.hpp"
+
+
+// removes any points outside of the given range
+class MosaicFilter : public Filter
+{
+public:
+  MosaicFilter(Stage& prevStage, Stage& prevStage2);
+  void initialize();
+
+  void updateLayout();
+
+  void readNextPoints(PointData&);
+
+private:
+  Stage& m_prevStage2;
+
+  MosaicFilter& operator=(const MosaicFilter&); // not implemented
+  MosaicFilter(const MosaicFilter&); // not implemented
+};
+
+#endif
diff -r d541e1299674 -r bfdaef209a3a include/libpc/PointData.hpp
--- a/include/libpc/PointData.hpp	Tue Feb 08 09:11:46 2011 -0800
+++ b/include/libpc/PointData.hpp	Tue Feb 08 11:03:16 2011 -0800
@@ -53,13 +53,12 @@
 public:
   PointData(const PointLayout&, int numPoints);
 
-  byte* getData(int index) const;
+  byte* getData(int pointIndex) const;
   int getNumPoints() const;
   const PointLayout& getLayout() const;
 
-  bool isValid(int index) const;
-  void setValid(int index);
-  void setInvalid(int index);
+  bool isValid(int pointIndex) const;
+  void setValid(int pointIndex, bool value=true);
 
   byte getField_U8(int pointIndex, int fieldIndex) const;
   float getField_F32(int pointIndex, int fieldIndex) const;
@@ -70,12 +69,17 @@
   void setField_F64(int pointIndex, int fieldIndex, double value);
 
   // some well-known fields
-  float getX(int index) const;
-  float getY(int index) const;
-  float getZ(int index) const;
-  void setX(int index, float value);
-  void setY(int index, float value);
-  void setZ(int index, float value);
+  float getX(int pointIndex) const;
+  float getY(int pointIndex) const;
+  float getZ(int pointIndex) const;
+  void setX(int pointIndex, float value);
+  void setY(int pointIndex, float value);
+  void setZ(int pointIndex, float value);
+
+  // bulk copy all the fields from the given point into this object
+  // NOTE: this is only legal if the src and dest layouts are exactly the same
+  // (later, this will be implemented properly, to handle the general cases slowly and the best case quickly)
+  void copyFieldsFast(int destPointIndex, int srcPointIndex, const PointData& srcPointData);
 
   void dump(std::string indent="") const;
   void dump(int index, std::string indent="") const;
diff -r d541e1299674 -r bfdaef209a3a include/libpc/PointLayout.hpp
--- a/include/libpc/PointLayout.hpp	Tue Feb 08 09:11:46 2011 -0800
+++ b/include/libpc/PointLayout.hpp	Tue Feb 08 11:03:16 2011 -0800
@@ -46,13 +46,17 @@
   PointLayout(const PointLayout&);
   PointLayout& operator=(const PointLayout & other);
 
+  bool operator==(const PointLayout & other) const;
+  bool same(const PointLayout & other, bool ignoreActive=false) const;
+
   void addField(const Field& field);
   void addFields(const std::vector<Field>& fields);
 
   const Field& getField(int fieldIndex) const { return m_fields[fieldIndex]; }
   bool isActive(int fieldIndex) const { return m_isActive[fieldIndex]; }
-  void setActive(int fieldIndex) { m_isActive[fieldIndex] = true; }
-  void setInactive(int fieldIndex) { m_isActive[fieldIndex] = false; }
+  void setActive(int fieldIndex, bool value=true) { m_isActive[fieldIndex] = value; }
+  void copyActiveVector(const std::vector<bool>& other) { m_isActive = other; }
+  const std::vector<bool>& getActiveVector() const { return m_isActive; }
 
   int getSizeInBytes() const;
   int getNumFields() const;
diff -r d541e1299674 -r bfdaef209a3a src/Bounds.cpp
--- a/src/Bounds.cpp	Tue Feb 08 09:11:46 2011 -0800
+++ b/src/Bounds.cpp	Tue Feb 08 11:03:16 2011 -0800
@@ -39,6 +39,26 @@
 using std::cout;
 
 
+#define mymin(a,b) ((a)<(b)?(a):(b))
+#define mymax(a,b) ((a)>=(b)?(a):(b))
+
+void Bounds::grow(const Bounds& b)
+{
+  Bounds& a = *this;
+
+  a.m_minX = mymin(a.m_minX, b.m_minX);
+  a.m_maxX = mymax(a.m_maxX, b.m_maxX);
+
+  a.m_minY = mymin(a.m_minY, b.m_minY);
+  a.m_maxY = mymax(a.m_maxY, b.m_maxY);
+
+  a.m_minZ = mymin(a.m_minZ, b.m_minZ);
+  a.m_maxZ = mymax(a.m_maxZ, b.m_maxZ);
+
+  return;
+}
+
+
 void Bounds::dump(void) const
 {
   cout << "x(" << m_minX << "," << m_maxX << ")";
diff -r d541e1299674 -r bfdaef209a3a src/CropFilter.cpp
--- a/src/CropFilter.cpp	Tue Feb 08 09:11:46 2011 -0800
+++ b/src/CropFilter.cpp	Tue Feb 08 11:03:16 2011 -0800
@@ -38,6 +38,10 @@
   : Filter(prevStage),
   m_bounds(bounds)
 {
+  Header& header = getHeader();
+
+  header.setBounds(bounds);
+
   return;
 }
 
@@ -66,17 +70,17 @@
 {


More information about the Liblas-commits mailing list