[Liblas-commits] libpc: checkpoint (still need to set isActive)

liblas-commits at liblas.org liblas-commits at liblas.org
Mon Feb 7 21:39:11 EST 2011


details:   http://hg.liblas.orglibpc/rev/7ac0fe222e37
changeset: 9:7ac0fe222e37
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Mon Feb 07 18:39:05 2011 -0800
description:
checkpoint (still need to set isActive)

diffstat:

 include/libpc/ColorFilter.hpp |    2 +
 include/libpc/CropFilter.hpp  |   10 +++-
 include/libpc/FauxReader.hpp  |    2 +
 include/libpc/FauxWriter.hpp  |    2 +
 include/libpc/Field.hpp       |   22 ++++++-
 include/libpc/Filter.hpp      |    3 +-
 include/libpc/Header.hpp      |    1 +
 include/libpc/PointData.hpp   |   16 +++---
 include/libpc/PointLayout.hpp |   26 ++++++---
 include/libpc/Reader.hpp      |    3 +-
 include/libpc/Stage.hpp       |    6 +-
 include/libpc/Writer.hpp      |    2 +
 src/ColorFilter.cpp           |   55 +++++++++-----------
 src/CropFilter.cpp            |   28 +++++++++-
 src/FauxReader.cpp            |   30 +++++++----
 src/FauxWriter.cpp            |   16 ++++-
 src/Field.cpp                 |   41 ++++++++++-----
 src/Header.cpp                |    6 ++
 src/PointData.cpp             |   90 +++++++++++++++++++--------------
 src/PointLayout.cpp           |  111 +++++++++++++++++++++++++----------------
 src/main.cpp                  |    4 +-
 21 files changed, 302 insertions(+), 174 deletions(-)

diffs (truncated from 1011 to 300 lines):

diff -r d1e630d22d83 -r 7ac0fe222e37 include/libpc/ColorFilter.hpp
--- a/include/libpc/ColorFilter.hpp	Mon Feb 07 13:53:54 2011 -0800
+++ b/include/libpc/ColorFilter.hpp	Mon Feb 07 18:39:05 2011 -0800
@@ -46,6 +46,8 @@
   ColorFilter(Stage& prevStage);
   void initialize();
 
+  void updateLayout();
+
   void readNextPoints(PointData&);
 
 private:
diff -r d1e630d22d83 -r 7ac0fe222e37 include/libpc/CropFilter.hpp
--- a/include/libpc/CropFilter.hpp	Mon Feb 07 13:53:54 2011 -0800
+++ b/include/libpc/CropFilter.hpp	Mon Feb 07 18:39:05 2011 -0800
@@ -38,16 +38,22 @@
 #include "libpc/Filter.hpp"
 
 
-// removes any points outside of the given Z range
+// removes any points outside of the given range
 class CropFilter : public Filter
 {
 public:
-  CropFilter(Stage& prevStage, float minZ, float maxZ);
+  CropFilter(Stage& prevStage, float minX, float maxX, float minY, float maxY, float minZ, float maxZ);
   void initialize();
 
+  void updateLayout();
+
   void readNextPoints(PointData&);
 
 private:
+  float m_minX;
+  float m_maxX;
+  float m_minY;
+  float m_maxY;
   float m_minZ;
   float m_maxZ;
 
diff -r d1e630d22d83 -r 7ac0fe222e37 include/libpc/FauxReader.hpp
--- a/include/libpc/FauxReader.hpp	Mon Feb 07 13:53:54 2011 -0800
+++ b/include/libpc/FauxReader.hpp	Mon Feb 07 18:39:05 2011 -0800
@@ -43,6 +43,8 @@
   FauxReader(std::string file);
   void initialize();
 
+  void updateLayout();
+
   void readNextPoints(PointData& data);
 
 private:
diff -r d1e630d22d83 -r 7ac0fe222e37 include/libpc/FauxWriter.hpp
--- a/include/libpc/FauxWriter.hpp	Mon Feb 07 13:53:54 2011 -0800
+++ b/include/libpc/FauxWriter.hpp	Mon Feb 07 18:39:05 2011 -0800
@@ -45,6 +45,8 @@
   FauxWriter(std::string filename, Stage& prevStage);
   void initialize();
 
+  void updateLayout();
+
 private:
   int m_numPointsWritten;
 
diff -r d1e630d22d83 -r 7ac0fe222e37 include/libpc/Field.hpp
--- a/include/libpc/Field.hpp	Mon Feb 07 13:53:54 2011 -0800
+++ b/include/libpc/Field.hpp	Mon Feb 07 18:39:05 2011 -0800
@@ -48,6 +48,9 @@
     YPos,
     ZPos,
     Time,
+    Zred,
+    Zgreen,
+    Zblue
   };
   static std::string getName(DataItem);
 
@@ -70,14 +73,21 @@
 
 public:
   Field();
-  Field(DataItem item, int offset, DataType type);
+  Field(DataItem item, DataType type);
   Field(const Field&);
 
   Field& operator=(const Field&);
 
-  DataItem item() const { return m_item; }
-  int offset() const { return m_offset; }
-  DataType type() const { return m_type; }
+  DataItem getItem() const { return m_item; }
+  DataType getType() const { return m_type; }
+
+  int getOffset() const { return m_offset; }
+  void setOffset(int offset) { m_offset = offset; }
+
+  int getIndex() const { return m_index; }
+  void setIndex(int index) { m_index = index; }
+
+  int getNumBytes() const;
 
   static const std::vector<Field>& standardFields();
 
@@ -85,9 +95,11 @@
 
 private:
   DataItem m_item;
-  int m_offset;
   DataType m_type;
 
+  int m_offset;// byte offset within a point buffer
+  int m_index; // 0..n-1, where n is number of fields in layout
+
   static std::vector<Field>* s_standardFields;
 };
 
diff -r d1e630d22d83 -r 7ac0fe222e37 include/libpc/Filter.hpp
--- a/include/libpc/Filter.hpp	Mon Feb 07 13:53:54 2011 -0800
+++ b/include/libpc/Filter.hpp	Mon Feb 07 18:39:05 2011 -0800
@@ -44,7 +44,8 @@
   Filter(Stage& prevStage);
   virtual void initialize() = 0;
 
-  // from Stage
+  virtual void updateLayout() = 0;
+
   virtual void readNextPoints(PointData&) = 0;
 
 protected:
diff -r d1e630d22d83 -r 7ac0fe222e37 include/libpc/Header.hpp
--- a/include/libpc/Header.hpp	Mon Feb 07 13:53:54 2011 -0800
+++ b/include/libpc/Header.hpp	Mon Feb 07 18:39:05 2011 -0800
@@ -53,6 +53,7 @@
 
   const PointLayout& getConstPointLayout() const;
   PointLayout& getPointLayout();
+  void setLayout(const PointLayout&);
 
   int getNumPoints() const;
   void setNumPoints(int);
diff -r d1e630d22d83 -r 7ac0fe222e37 include/libpc/PointData.hpp
--- a/include/libpc/PointData.hpp	Mon Feb 07 13:53:54 2011 -0800
+++ b/include/libpc/PointData.hpp	Mon Feb 07 18:39:05 2011 -0800
@@ -61,13 +61,13 @@
   void setValid(int index);
   void setInvalid(int index);
 
-  byte getField_U8(int index, int itemOffset) const;
-  float getField_F32(int index, int itemOffset) const;
-  double getField_F64(int index, int itemOffset) const;
+  byte getField_U8(int pointIndex, int fieldIndex) const;
+  float getField_F32(int pointIndex, int fieldIndex) const;
+  double getField_F64(int pointIndex, int fieldIndex) const;
 
-  void setField_U8(int index, int itemOffset, byte value);
-  void setField_F32(int index, int itemOffset, float value);
-  void setField_F64(int index, int itemOffset, double value);
+  void setField_U8(int pointIndex, int fieldIndex, byte value);
+  void setField_F32(int pointIndex, int fieldIndex, float value);
+  void setField_F64(int pointIndex, int fieldIndex, double value);
 
   // some well-known fields
   float getX(int index) const;
@@ -77,8 +77,8 @@
   void setY(int index, float value);
   void setZ(int index, float value);
 
-  void dump() const;
-  void dump(int index) const;
+  void dump(std::string indent="") const;
+  void dump(int index, std::string indent="") const;
 
 private:
   template<class T> T getField(int index, int itemOffset) const;
diff -r d1e630d22d83 -r 7ac0fe222e37 include/libpc/PointLayout.hpp
--- a/include/libpc/PointLayout.hpp	Mon Feb 07 13:53:54 2011 -0800
+++ b/include/libpc/PointLayout.hpp	Mon Feb 07 18:39:05 2011 -0800
@@ -49,26 +49,36 @@
   void addField(const Field& field);
   void addFields(const std::vector<Field>& fields);
 
-  const Field& getField(int) const;
+  const Field& getField(int index) const { return m_fields[index]; }
+  bool isActive(int index) const { return m_isActive[index]; }
+  void setActive(int index) { m_isActive[index] = true; }
+  void setInactive(int index) { m_isActive[index] = false; }
 
   int getSizeInBytes() const;
   int getNumFields() const;
 
   void dump() const;
 
-  bool findField(Field::DataItem item, Field& ret) const;
+  // returns -1 if not found
+  int findFieldIndex(Field::DataItem item) const;
+  bool hasField(Field::DataItem item) const;
   int findFieldOffset(Field::DataItem item) const;
 
   // some well-known field types are always available
-  int getFieldOffset_X() const { return m_offsetX; }
-  int getFieldOffset_Z() const { return m_offsetY; }
-  int getFieldOffset_Y() const { return m_offsetZ; }
+  // is this worth it?
+  int getFieldIndex_X() const { return m_fieldIndex_X; }
+  int getFieldIndex_Y() const { return m_fieldIndex_Y; }
+  int getFieldIndex_Z() const { return m_fieldIndex_Z; }
 
 private:
   std::vector<Field> m_fields;
-  int m_offsetX;
-  int m_offsetY;
-  int m_offsetZ;
+  std::vector<bool> m_isActive;
+
+  int m_numBytes;
+
+  int m_fieldIndex_X;
+  int m_fieldIndex_Y;
+  int m_fieldIndex_Z;
 };
 
 #endif
diff -r d1e630d22d83 -r 7ac0fe222e37 include/libpc/Reader.hpp
--- a/include/libpc/Reader.hpp	Mon Feb 07 13:53:54 2011 -0800
+++ b/include/libpc/Reader.hpp	Mon Feb 07 18:39:05 2011 -0800
@@ -46,7 +46,8 @@
   // opens the file (or whatever) and sets m_layout
   virtual void initialize();
 
-  // from Stage
+  virtual void updateLayout() = 0;
+
   virtual void readNextPoints(PointData&) = 0;
 
 protected:
diff -r d1e630d22d83 -r 7ac0fe222e37 include/libpc/Stage.hpp
--- a/include/libpc/Stage.hpp	Mon Feb 07 13:53:54 2011 -0800
+++ b/include/libpc/Stage.hpp	Mon Feb 07 18:39:05 2011 -0800
@@ -46,8 +46,10 @@
   Stage();
   virtual void initialize();
   bool isInitialized() const;
-
-  virtual void readNextPoints(PointData&) = 0;
+  
+  virtual void updateLayout() = 0;
+  
+    virtual void readNextPoints(PointData&) = 0;
 
   const Header& getConstHeader() const;
 
diff -r d1e630d22d83 -r 7ac0fe222e37 include/libpc/Writer.hpp
--- a/include/libpc/Writer.hpp	Mon Feb 07 13:53:54 2011 -0800
+++ b/include/libpc/Writer.hpp	Mon Feb 07 18:39:05 2011 -0800
@@ -45,6 +45,8 @@
   Writer(Stage& prevStage);
   virtual void initialize();
 
+  virtual void updateLayout() = 0;
+
   void write();
 
 protected:
diff -r d1e630d22d83 -r 7ac0fe222e37 src/ColorFilter.cpp
--- a/src/ColorFilter.cpp	Mon Feb 07 13:53:54 2011 -0800
+++ b/src/ColorFilter.cpp	Mon Feb 07 18:39:05 2011 -0800
@@ -48,44 +48,37 @@
 }
 
 
-void ColorFilter::readNextPoints(PointData& currData)
+void ColorFilter::updateLayout()
 {
-  // This filter changes the layout: it adds three u8 fields
-  // Therefore, we get the data from the prev stage using the prev stage's layout,
-  // and then copy the contents into the layout for this stage (which was
-  // passed in to us).
-
-  const int chunk = currData.getNumPoints();
-  int cnt = currData.getNumPoints();
-
-  //const PointLayout& currLayout = getConstHeader().getConstPointLayout();
+  m_prevStage.updateLayout();
   const PointLayout& prevLayout = m_prevStage.getConstHeader().getConstPointLayout();
 
-  PointData prevData(prevLayout, chunk);
-  m_prevStage.readNextPoints(prevData);
+  PointLayout myLayout(prevLayout);
+
+  // add the three u8 fields
+  myLayout.addField(Field(Field::Zred, Field::U8));
+  myLayout.addField(Field(Field::Zgreen, Field::U8));
+  myLayout.addField(Field(Field::Zgreen, Field::U8));
+
+  getHeader().setLayout(myLayout);
+}
+
+
+void ColorFilter::readNextPoints(PointData& data)
+{


More information about the Liblas-commits mailing list