[Liblas-commits] hg-main-tree: enable Options-based ctors

liblas-commits at liblas.org liblas-commits at liblas.org
Fri Jul 29 15:20:40 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/b10964c028e3
changeset: 966:b10964c028e3
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Fri Jul 29 12:13:41 2011 -0700
description:
enable Options-based ctors
Subject: hg-main-tree: lint

details:   http://hg.libpc.orghg-main-tree/rev/0f814f803ba2
changeset: 967:0f814f803ba2
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Fri Jul 29 12:14:00 2011 -0700
description:
lint
Subject: hg-main-tree: enable Options-based ctors

details:   http://hg.libpc.orghg-main-tree/rev/0f158c29d276
changeset: 968:0f158c29d276
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Fri Jul 29 12:20:31 2011 -0700
description:
enable Options-based ctors

diffstat:

 include/pdal/drivers/faux/Reader.hpp      |   8 ++-
 include/pdal/filters/ByteSwapFilter.hpp   |   2 +-
 include/pdal/filters/CacheFilter.hpp      |   2 +
 include/pdal/filters/DecimationFilter.hpp |   2 +
 src/drivers/faux/Reader.cpp               |  86 +++++++++++++++++++++---------
 src/filters/ByteSwapFilter.cpp            |  22 +++++--
 src/filters/CacheFilter.cpp               |  17 +++++-
 src/filters/DecimationFilter.cpp          |  15 ++++-
 test/unit/CacheFilterTest.cpp             |  54 +++++++++++++++++++
 test/unit/DecimationFilterTest.cpp        |  39 +++++++++++++-
 test/unit/FauxReaderTest.cpp              |  48 +++++++++++++++++
 11 files changed, 255 insertions(+), 40 deletions(-)

diffs (truncated from 471 to 300 lines):

diff -r e013fe10c140 -r 0f158c29d276 include/pdal/drivers/faux/Reader.hpp
--- a/include/pdal/drivers/faux/Reader.hpp	Fri Jul 29 11:44:22 2011 -0700
+++ b/include/pdal/drivers/faux/Reader.hpp	Fri Jul 29 12:20:31 2011 -0700
@@ -77,8 +77,8 @@
 
 public:
     Reader(const Options& options);
-    Reader(const Bounds<double>&, int numPoints, Mode mode);
-    Reader(const Bounds<double>&, int numPoints, Mode mode, const std::vector<Dimension>& dimensions);
+    Reader(const Bounds<double>&, boost::uint64_t numPoints, Mode mode);
+    Reader(const Bounds<double>&, boost::uint64_t numPoints, Mode mode, const std::vector<Dimension>& dimensions);
     
     Mode getMode() const;
     
@@ -97,7 +97,11 @@
     boost::uint32_t processBuffer(PointBuffer& data, boost::uint64_t index) const;
 
 private:
+    void initialize();
+    void initialize(const std::vector<Dimension>& dimensions);
 
+    Bounds<double> m_bounds;
+    boost::uint64_t m_numPoints;
     Mode m_mode;
 
     Reader& operator=(const Reader&); // not implemented
diff -r e013fe10c140 -r 0f158c29d276 include/pdal/filters/ByteSwapFilter.hpp
--- a/include/pdal/filters/ByteSwapFilter.hpp	Fri Jul 29 11:44:22 2011 -0700
+++ b/include/pdal/filters/ByteSwapFilter.hpp	Fri Jul 29 12:20:31 2011 -0700
@@ -76,7 +76,7 @@
 
 
 private:
-
+    void initialize();
 
     ByteSwapFilter& operator=(const ByteSwapFilter&); // not implemented
     ByteSwapFilter(const ByteSwapFilter&); // not implemented
diff -r e013fe10c140 -r 0f158c29d276 include/pdal/filters/CacheFilter.hpp
--- a/include/pdal/filters/CacheFilter.hpp	Fri Jul 29 11:44:22 2011 -0700
+++ b/include/pdal/filters/CacheFilter.hpp	Fri Jul 29 12:20:31 2011 -0700
@@ -102,6 +102,8 @@
     pdal::StageRandomIterator* createRandomIterator() const;
 
 private:
+    void initialize();
+
     // these are mutable to allow const-ness for updating stats
     // BUG: need to make thread-safe
     mutable boost::uint64_t m_numPointsRequested;
diff -r e013fe10c140 -r 0f158c29d276 include/pdal/filters/DecimationFilter.hpp
--- a/include/pdal/filters/DecimationFilter.hpp	Fri Jul 29 11:44:22 2011 -0700
+++ b/include/pdal/filters/DecimationFilter.hpp	Fri Jul 29 12:20:31 2011 -0700
@@ -75,6 +75,8 @@
 private:
     boost::uint32_t m_step;
 
+    void initialize();
+
     DecimationFilter& operator=(const DecimationFilter&); // not implemented
     DecimationFilter(const DecimationFilter&); // not implemented
 };
diff -r e013fe10c140 -r 0f158c29d276 src/drivers/faux/Reader.cpp
--- a/src/drivers/faux/Reader.cpp	Fri Jul 29 11:44:22 2011 -0700
+++ b/src/drivers/faux/Reader.cpp	Fri Jul 29 12:20:31 2011 -0700
@@ -45,48 +45,84 @@
 
 IMPLEMENT_STATICS(Reader, "drivers.faux.reader", "Faux Reader")
 
+static Reader::Mode string2mode(const std::string& str)
+{
+    if (compare_no_case(str.c_str(), "constant")==0) return Reader::Constant;
+    if (compare_no_case(str.c_str(), "random")==0) return Reader::Random;
+    if (compare_no_case(str.c_str(), "ramp")==0) return Reader::Ramp;
+    throw pdal_error("invalid Mode option: " + str);
+}
+
 
 Reader::Reader(const Options& options)
     : pdal::Reader(options)
+    , m_bounds(options.getValueOrThrow<Bounds<double> >("bounds"))
+    , m_numPoints(options.getValueOrThrow<boost::uint64_t>("num_points"))
+    , m_mode(string2mode(options.getValueOrThrow<std::string>("mode")))
 {
-    throw not_yet_implemented("options ctor"); 
-}
-
-
-Reader::Reader(const Bounds<double>& bounds, int numPoints, Mode mode)
-    : pdal::Reader(Options::none())
-    , m_mode(mode)
-{
-    Schema& schema = getSchemaRef();
-
-    schema.addDimension(Dimension(Dimension::Field_X, Dimension::Double));
-    schema.addDimension(Dimension(Dimension::Field_Y, Dimension::Double));
-    schema.addDimension(Dimension(Dimension::Field_Z, Dimension::Double));
-    schema.addDimension(Dimension(Dimension::Field_Time, Dimension::Uint64));
-
-    setNumPoints(numPoints);
-    setPointCountType(PointCount_Fixed);
-
-    setBounds(bounds);
+    initialize();
 
     return;
 }
 
-Reader::Reader(const Bounds<double>& bounds, int numPoints, Mode mode, const std::vector<Dimension>& dimensions)
-    : pdal::Reader( Options::none())
+
+Reader::Reader(const Bounds<double>& bounds, boost::uint64_t numPoints, Mode mode)
+    : pdal::Reader(Options::none())
+    , m_bounds(bounds)
+    , m_numPoints(numPoints)
     , m_mode(mode)
 {
-    Schema& schema = getSchemaRef();
+    initialize();
+
+    return;
+}
+
+Reader::Reader(const Bounds<double>& bounds, boost::uint64_t numPoints, Mode mode, const std::vector<Dimension>& dimensions)
+    : pdal::Reader( Options::none())
+    , m_bounds(bounds)
+    , m_numPoints(numPoints)
+    , m_mode(mode)
+{
     if (dimensions.size() == 0)
     {
         throw; // BUG
     }
+
+    initialize(dimensions);
+
+    return;
+}
+
+
+void Reader::initialize()
+{
+    std::vector<Dimension> dimensions;
+
+    Dimension dimx(Dimension::Field_X, Dimension::Double);
+    Dimension dimy(Dimension::Field_Y, Dimension::Double);
+    Dimension dimz(Dimension::Field_Z, Dimension::Double);
+    Dimension dimt(Dimension::Field_Time, Dimension::Uint64);
+
+    dimensions.push_back(dimx);
+    dimensions.push_back(dimy);
+    dimensions.push_back(dimz);
+    dimensions.push_back(dimt);
+    
+    initialize(dimensions);
+
+    return;
+}
+
+
+void Reader::initialize(const std::vector<Dimension>& dimensions)
+{
+    Schema& schema = getSchemaRef();
     schema.addDimensions(dimensions);
 
-    setNumPoints(numPoints);
-    setBounds(bounds);
+    setNumPoints(m_numPoints);
+    setPointCountType(PointCount_Fixed);
 
-    return;
+    setBounds(m_bounds);
 }
 
 
diff -r e013fe10c140 -r 0f158c29d276 src/filters/ByteSwapFilter.cpp
--- a/src/filters/ByteSwapFilter.cpp	Fri Jul 29 11:44:22 2011 -0700
+++ b/src/filters/ByteSwapFilter.cpp	Fri Jul 29 12:20:31 2011 -0700
@@ -53,18 +53,26 @@
 ByteSwapFilter::ByteSwapFilter(const Stage& prevStage, const Options& options)
     : pdal::Filter(prevStage, options)
 {
-    throw not_yet_implemented("options ctor"); 
+    initialize();
+    return;
 }
 
 
 ByteSwapFilter::ByteSwapFilter(const Stage& prevStage)
     : Filter(prevStage, Options::none())
 {
+    initialize();
+    return;
+}
 
-    this->setNumPoints(prevStage.getNumPoints());
-    this->setPointCountType(prevStage.getPointCountType());
 
-    Schema& schema = this->getSchemaRef();
+void ByteSwapFilter::initialize()
+{
+    const Stage& stage = getPrevStage();
+    this->setNumPoints(stage.getNumPoints());
+    this->setPointCountType(stage.getPointCountType());
+
+    //Schema& schema = this->getSchemaRef();
 
     // FIXME:  this doesn't work anymore
     // std::vector<Dimension>& dimensions = schema.getDimensions();
@@ -80,9 +88,9 @@
     //     } else {
     //         throw pdal_error("ByteSwapFilter can only swap big/little endian dimensions");
     //     }
-    // }    
-        
-    return;
+    // }
+
+    return;        
 }
 
 
diff -r e013fe10c140 -r 0f158c29d276 src/filters/CacheFilter.cpp
--- a/src/filters/CacheFilter.cpp	Fri Jul 29 11:44:22 2011 -0700
+++ b/src/filters/CacheFilter.cpp	Fri Jul 29 12:20:31 2011 -0700
@@ -45,8 +45,14 @@
 
 CacheFilter::CacheFilter(const Stage& prevStage, const Options& options)
     : pdal::Filter(prevStage, options)
+    , m_numPointsRequested(0)
+    , m_numPointsRead(0)
+    , m_cache(NULL)
+    , m_maxCacheBlocks(options.getValueOrThrow<boost::uint32_t>("max_cache_blocks"))
+    , m_cacheBlockSize(options.getValueOrThrow<boost::uint32_t>("cache_block_size"))
 {
-    throw not_yet_implemented("options ctor"); 
+    initialize();
+    return;
 }
 
 
@@ -59,7 +65,7 @@
     , m_maxCacheBlocks(maxCacheBlocks)
     , m_cacheBlockSize(cacheBlockSize)
 {
-    resetCache();
+    initialize();
     return;
 }
 
@@ -70,6 +76,13 @@
 }
 
 
+void CacheFilter::initialize()
+{
+    resetCache();
+    return;
+}
+
+
 const Options& CacheFilter::s_getDefaultOptions()
 {
     static Options options;
diff -r e013fe10c140 -r 0f158c29d276 src/filters/DecimationFilter.cpp
--- a/src/filters/DecimationFilter.cpp	Fri Jul 29 11:44:22 2011 -0700
+++ b/src/filters/DecimationFilter.cpp	Fri Jul 29 12:20:31 2011 -0700
@@ -45,8 +45,11 @@
 
 DecimationFilter::DecimationFilter(const Stage& prevStage, const Options& options)
     : pdal::Filter(prevStage, options)
+    , m_step(options.getValueOrThrow<boost::uint32_t>("step"))
 {
-    throw not_yet_implemented("options ctor"); 
+    initialize();
+
+    return;
 }
 
 
@@ -54,7 +57,15 @@
     : Filter(prevStage, Options::none())
     , m_step(step)
 {
-    this->setNumPoints( this->getNumPoints() / step );
+    initialize();
+
+    return;
+}
+
+
+void DecimationFilter::initialize()
+{
+    this->setNumPoints( this->getNumPoints() / m_step );
 
     return;
 }
diff -r e013fe10c140 -r 0f158c29d276 test/unit/CacheFilterTest.cpp
--- a/test/unit/CacheFilterTest.cpp	Fri Jul 29 11:44:22 2011 -0700
+++ b/test/unit/CacheFilterTest.cpp	Fri Jul 29 12:20:31 2011 -0700


More information about the Liblas-commits mailing list