[Liblas-commits] hg-main-tree: lots of pipeline stage builder and shared ptr work

liblas-commits at liblas.org liblas-commits at liblas.org
Tue Jul 19 15:18:12 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/1234ab109b94
changeset: 869:1234ab109b94
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Mon Jul 18 13:07:43 2011 -0700
description:
lots of pipeline stage builder and shared ptr work
Subject: hg-main-tree: botched merge

details:   http://hg.libpc.orghg-main-tree/rev/dd56dea47855
changeset: 870:dd56dea47855
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Mon Jul 18 13:14:33 2011 -0700
description:
botched merge
Subject: hg-main-tree: checkpoint -- pipeline manager work

details:   http://hg.libpc.orghg-main-tree/rev/8908e10de487
changeset: 871:8908e10de487
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Mon Jul 18 16:37:12 2011 -0700
description:
checkpoint -- pipeline manager work
Subject: hg-main-tree: converted xml-based pipeline manager to ptree

details:   http://hg.libpc.orghg-main-tree/rev/d744b9f3bf62
changeset: 872:d744b9f3bf62
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Mon Jul 18 17:40:02 2011 -0700
description:
converted xml-based pipeline manager to ptree
Subject: hg-main-tree: checkpoint -- trying to debug Options::empty linking issue

details:   http://hg.libpc.orghg-main-tree/rev/081f0e1ea0a6
changeset: 873:081f0e1ea0a6
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Mon Jul 18 21:46:18 2011 -0700
description:
checkpoint -- trying to debug Options::empty linking issue
Subject: hg-main-tree: checkpoint -- pipeline as ptree now working

details:   http://hg.libpc.orghg-main-tree/rev/a62ff2bd7999
changeset: 874:a62ff2bd7999
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Mon Jul 18 23:16:10 2011 -0700
description:
checkpoint -- pipeline as ptree now working
Subject: hg-main-tree: LiblasWriter now uses options block for filename

details:   http://hg.libpc.orghg-main-tree/rev/7cc3349eb9a1
changeset: 875:7cc3349eb9a1
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Mon Jul 18 23:24:42 2011 -0700
description:
LiblasWriter now uses options block for filename
Subject: hg-main-tree: make the Iterators be shared ptrs now

details:   http://hg.libpc.orghg-main-tree/rev/2ad5b59719ea
changeset: 876:2ad5b59719ea
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Tue Jul 19 11:02:17 2011 -0700
description:
make the Iterators be shared ptrs now

diffstat:

 apps/pc2pc.cpp                                  |  102 ++++---
 apps/pcinfo.cpp                                 |    2 +-
 apps/pcview/main.cpp                            |   27 +-
 apps/qfit2las.cpp                               |   19 +-
 include/pdal/Filter.hpp                         |   10 +-
 include/pdal/FilterIterator.hpp                 |   20 +-
 include/pdal/MultiFilter.hpp                    |    9 +-
 include/pdal/MultiFilterIterator.hpp            |   12 +-
 include/pdal/Options.hpp                        |  182 +++++++------
 include/pdal/PipelineManager.hpp                |   38 +-
 include/pdal/Reader.hpp                         |    4 +-
 include/pdal/ReaderIterator.hpp                 |    2 +-
 include/pdal/Stage.hpp                          |   52 ++-
 include/pdal/StageFactory.hpp                   |   39 +-
 include/pdal/StageIterator.hpp                  |   14 +-
 include/pdal/Writer.hpp                         |   10 +-
 include/pdal/drivers/faux/Reader.hpp            |    7 +-
 include/pdal/drivers/faux/Writer.hpp            |    6 +-
 include/pdal/drivers/las/Reader.hpp             |    4 +-
 include/pdal/drivers/las/Writer.hpp             |    4 +-
 include/pdal/drivers/liblas/Reader.hpp          |    7 +-
 include/pdal/drivers/liblas/Writer.hpp          |    7 +-
 include/pdal/drivers/oci/Reader.hpp             |    2 +-
 include/pdal/drivers/oci/Writer.hpp             |    6 +-
 include/pdal/drivers/qfit/Reader.hpp            |    4 +-
 include/pdal/drivers/terrasolid/Reader.hpp      |    4 +-
 include/pdal/filters/ByteSwapFilter.hpp         |    8 +-
 include/pdal/filters/ByteSwapFilterIterator.hpp |    2 +-
 include/pdal/filters/CacheFilter.hpp            |   10 +-
 include/pdal/filters/CacheFilterIterator.hpp    |    3 +-
 include/pdal/filters/Chipper.hpp                |   25 +-
 include/pdal/filters/ColorFilter.hpp            |    8 +-
 include/pdal/filters/CropFilter.hpp             |    9 +-
 include/pdal/filters/DecimationFilter.hpp       |    8 +-
 include/pdal/filters/MosaicFilter.hpp           |    7 +-
 include/pdal/filters/ReprojectionFilter.hpp     |    9 +-
 include/pdal/filters/ScalingFilter.hpp          |   12 +-
 include/pdal/pdal.hpp                           |    5 +
 src/Filter.cpp                                  |   13 +-
 src/FilterIterator.cpp                          |   39 +-
 src/MultiFilter.cpp                             |   36 +--
 src/MultiFilterIterator.cpp                     |   15 +-
 src/Options.cpp                                 |   85 ++---
 src/PipelineManager.cpp                         |  303 +++++++++++++++++++++--
 src/Reader.cpp                                  |    2 +-
 src/Stage.cpp                                   |  121 ++++++--
 src/StageFactory.cpp                            |  128 +++++----
 src/StageIterator.cpp                           |   10 +-
 src/Writer.cpp                                  |   19 +-
 src/drivers/faux/Reader.cpp                     |   42 ++-
 src/drivers/faux/Writer.cpp                     |    8 +-
 src/drivers/las/Reader.cpp                      |   10 +-
 src/drivers/las/Writer.cpp                      |   10 +-
 src/drivers/liblas/Reader.cpp                   |   18 +-
 src/drivers/liblas/Writer.cpp                   |   24 +-
 src/drivers/oci/Reader.cpp                      |    6 +-
 src/drivers/oci/Writer.cpp                      |   12 +-
 src/drivers/qfit/Reader.cpp                     |   10 +-
 src/drivers/terrasolid/Reader.cpp               |   10 +-
 src/filters/ByteSwapFilter.cpp                  |   16 +-
 src/filters/ByteSwapFilterIterator.cpp          |   12 +-
 src/filters/CacheFilter.cpp                     |   27 +-
 src/filters/CacheFilterIterator.cpp             |   14 +-
 src/filters/Chipper.cpp                         |   36 +-
 src/filters/ChipperIterator.cpp                 |    4 +-
 src/filters/ColorFilter.cpp                     |   13 +-
 src/filters/ColorFilterIterator.cpp             |    6 +-
 src/filters/CropFilter.cpp                      |    8 +-
 src/filters/CropFilterIterator.cpp              |    6 +-
 src/filters/DecimationFilter.cpp                |   17 +-
 src/filters/DecimationFilterIterator.cpp        |   10 +-
 src/filters/MosaicFilter.cpp                    |   42 +--
 src/filters/MosaicFilterIterator.cpp            |    4 +-
 src/filters/ReprojectionFilter.cpp              |   10 +-
 src/filters/ReprojectionFilterIterator.cpp      |    6 +-
 src/filters/ScalingFilter.cpp                   |   14 +-
 src/filters/ScalingFilterIterator.cpp           |    8 +-
 test/data/pipeline1.xml                         |   25 +
 test/unit/ByteSwapFilterTest.cpp                |   29 +-
 test/unit/CacheFilterTest.cpp                   |   40 +-
 test/unit/ChipperTest.cpp                       |   22 +-
 test/unit/ColorFilterTest.cpp                   |    2 +-
 test/unit/CropFilterTest.cpp                    |   15 +-
 test/unit/DecimationFilterTest.cpp              |   18 +-
 test/unit/DimensionLayoutTest.cpp               |    2 +-
 test/unit/FauxReaderTest.cpp                    |   62 +++-
 test/unit/FauxWriterTest.cpp                    |   58 ++-
 test/unit/LasReaderTest.cpp                     |   87 +++---
 test/unit/LasWriterTest.cpp                     |   67 ++--
 test/unit/LiblasReaderTest.cpp                  |   94 +++---
 test/unit/LiblasWriterTest.cpp                  |   95 +++---
 test/unit/MosaicFilterTest.cpp                  |   38 +-
 test/unit/OptionsTest.cpp                       |   69 ++++-
 test/unit/PipelineManagerTest.cpp               |   28 +-
 test/unit/PointBufferCacheTest.cpp              |    2 +-
 test/unit/QFITReaderTest.cpp                    |    8 +-
 test/unit/ReprojectionFilterTest.cpp            |   53 ++--
 test/unit/SpatialReferenceTest.cpp              |   35 +-
 test/unit/StageFactoryTest.cpp                  |  121 ++++++++-
 test/unit/TerraSolidTest.cpp                    |    4 +-
 100 files changed, 1669 insertions(+), 1178 deletions(-)

diffs (truncated from 6118 to 300 lines):

diff -r cc83cbdc225c -r 2ad5b59719ea apps/pc2pc.cpp
--- a/apps/pc2pc.cpp	Thu Jul 14 13:11:40 2011 -0700
+++ b/apps/pc2pc.cpp	Tue Jul 19 11:02:17 2011 -0700
@@ -118,31 +118,34 @@
         return 1;
     }
 
-    Options optsW("filename", m_outputFile, "file to write to");
+    Options writerOptions;
+    writerOptions.add("filename", m_outputFile);
 
     if (hasOption("native"))
     {
-        Options optsR("filename", m_inputFile, "file to read from");
-        pdal::drivers::las::LasReader reader(optsR);
+        Options readerOptions;
+        readerOptions.add("filename", m_inputFile);
+        DataStagePtr reader(new pdal::drivers::las::LasReader(readerOptions));
     
-        const boost::uint64_t numPoints = reader.getNumPoints();
+        const boost::uint64_t numPoints = reader->getNumPoints();
 
-        pdal::drivers::las::LasWriter writer(reader, optsW);
+        WriterPtr writer(new pdal::drivers::las::LasWriter(reader, writerOptions));
 
         //BUG: handle laz writer.setCompressed(false);
 
         //writer.setPointFormat( reader.getPointFormatNumber() );
 
-        writer.write(numPoints);
+        writer->write(numPoints);
     }
 
     else if (hasOption("oracle-writer"))
     {
 #ifdef PDAL_HAVE_ORACLE
-        Options optsR("filename", m_inputFile, "file to read from");
-        pdal::drivers::las::LasReader reader(optsR);
+        Options readerOptions;
+        readerOptions.add("filename", m_inputFile);
+        DataStagePtr reader(new pdal::drivers::las::LasReader(readerOptions));
     
-        const boost::uint64_t numPoints = reader.getNumPoints();
+        const boost::uint64_t numPoints = reader->getNumPoints();
 
         boost::property_tree::ptree load_tree;
         
@@ -164,15 +167,20 @@
         
         boost::uint32_t capacity = tree.get<boost::uint32_t>("capacity");
         
-        
-        pdal::filters::CacheFilter cache(reader, 1, capacity);
-        pdal::filters::Chipper chipper(cache, capacity);
-        pdal::filters::ByteSwapFilter swapper(chipper);
+        pdal::Options cacheOptions;
+        cacheOptions.add("max_cache_blocks", 1);
+        cacheOptions.add("cache_block_size", capacity);
+        DataStagePtr cache(new pdal::filters::CacheFilter(reader, cacheOptions));
 
-     
-        pdal::filters::ScalingFilter scalingFilter(swapper, false);
+        pdal::Options chipperOptions;
+        cacheOptions.add("max_partition_size", capacity);
+        DataStagePtr chipper(new pdal::filters::Chipper(cache, chipperOptions));
 
-        pdal::filters::ReprojectionFilter reprojectionFilter(scalingFilter, in_ref, out_ref);
+        DataStagePtr swapper(new pdal::filters::ByteSwapFilter(chipper, Options::empty()));
+
+        DataStagePtr scalingFilter(new pdal::filters::ScalingFilter(swapper, false));
+
+        DataStagePtr reprojectionFilter(new pdal::filters::ReprojectionFilter(scalingFilter, in_ref, out_ref));
 
         // convert to ints, using custom scale factor
         
@@ -184,19 +192,19 @@
         double offsety = oracle_options.get<double>("offset.y");
         double offsetz = oracle_options.get<double>("offset.z");
 
-        pdal::filters::ScalingFilter descalingFilter(   reprojectionFilter, 
+        DataStagePtr descalingFilter(new pdal::filters::ScalingFilter (   reprojectionFilter, 
                                                         scalex, offsetx,
                                                         scaley, offsety, 
                                                         scalez, offsetz, 
-                                                        true);
+                                                        true));
         
-        pdal::drivers::oci::Writer writer(descalingFilter, options);
+        WriterPtr writer(new pdal::drivers::oci::Writer(descalingFilter, options));
 
         // pdal::filters::CacheFilter cache(reader, 1, capacity);
         // pdal::filters::Chipper chipper(cache, capacity);
         // pdal::drivers::oci::Writer writer(chipper, options);
 
-        writer.write(numPoints);
+        writer->write(numPoints);
         boost::property_tree::ptree output_tree;
         // output_tree.put_child(writer.getName(), options.GetPTree());
         // boost::property_tree::write_xml(m_xml, output_tree);
@@ -227,14 +235,14 @@
         {
             pdal::SpatialReference out_ref(out_wkt);
 
-            pdal::drivers::oci::Reader reader(options);
-            pdal::SpatialReference in_ref(reader.getSpatialReference());
+            DataStagePtr reader(new pdal::drivers::oci::Reader(options));
+            pdal::SpatialReference in_ref(reader->getSpatialReference());
 
-            pdal::filters::ByteSwapFilter swapper(reader);
+            DataStagePtr swapper(new pdal::filters::ByteSwapFilter(reader, Options::empty()));
 
-            pdal::filters::ScalingFilter scalingFilter(swapper, false);
+            DataStagePtr scalingFilter(new pdal::filters::ScalingFilter(swapper, false));
 
-            pdal::filters::ReprojectionFilter reprojectionFilter(scalingFilter, in_ref, out_ref);
+            DataStagePtr reprojectionFilter(new pdal::filters::ReprojectionFilter(scalingFilter, in_ref, out_ref));
 
             // convert to ints, using custom scale factor
             
@@ -246,34 +254,34 @@
             double offsety = las_options.get<double>("offset.y");
             double offsetz = las_options.get<double>("offset.z");
 
-            pdal::filters::ScalingFilter descalingFilter(   reprojectionFilter, 
-                                                            scalex, offsetx,
-                                                            scaley, offsety, 
-                                                            scalez, offsetz, 
-                                                            true);
+            DataStagePtr descalingFilter(new pdal::filters::ScalingFilter(reprojectionFilter, 
+                                                                          scalex, offsetx,
+                                                                          scaley, offsety, 
+                                                                          scalez, offsetz, 
+                                                                          true));
 
-            pdal::drivers::las::LasWriter writer(descalingFilter, optsW);
+            pdal::drivers::las::LasWriterPtr writer(new pdal::drivers::las::LasWriter(descalingFilter, writerOptions));
 
 
             if (compress)
-                writer.setCompressed(true);
-            writer.setChunkSize(oracle_options.get<boost::uint32_t>("capacity"));            
-            writer.write(0);
+                writer->setCompressed(true);
+            writer->setChunkSize(oracle_options.get<boost::uint32_t>("capacity"));            
+            writer->write(0);
         } else 
         {
             pdal::SpatialReference out_ref(out_wkt);
 
-            pdal::drivers::oci::Reader reader(options);
-            pdal::SpatialReference in_ref(reader.getSpatialReference());
-            pdal::filters::ByteSwapFilter swapper(reader);
+            DataStagePtr reader(new pdal::drivers::oci::Reader(options));
+            pdal::SpatialReference in_ref(reader->getSpatialReference());
+            DataStagePtr swapper(new pdal::filters::ByteSwapFilter(reader, Options::empty()));
             
 
-            pdal::drivers::las::LasWriter writer(swapper, optsW);
+            pdal::drivers::las::LasWriterPtr writer(new pdal::drivers::las::LasWriter(swapper, writerOptions));
             if (compress)
-                writer.setCompressed(true);
+                writer->setCompressed(true);
         
-            writer.setChunkSize(oracle_options.get<boost::uint32_t>("capacity"));            
-            writer.write(0);
+            writer->setChunkSize(oracle_options.get<boost::uint32_t>("capacity"));            
+            writer->write(0);
         }
 
 
@@ -294,17 +302,19 @@
 
     else
     {
-        pdal::drivers::liblas::LiblasReader reader(m_inputFile);
+        pdal::Options readerOptions;
+        readerOptions.add("filename", m_inputFile);
+        pdal::drivers::liblas::LiblasReaderPtr reader(new pdal::drivers::liblas::LiblasReader(readerOptions));
     
-        const boost::uint64_t numPoints = reader.getNumPoints();
+        const boost::uint64_t numPoints = reader->getNumPoints();
 
-        pdal::drivers::liblas::LiblasWriter writer(reader, optsW);
+        pdal::drivers::liblas::LiblasWriterPtr writer(new pdal::drivers::liblas::LiblasWriter(reader, writerOptions));
 
         //BUG: handle laz writer.setCompressed(false);
 
-        writer.setPointFormat( reader.getPointFormat() );
+        writer->setPointFormat( reader->getPointFormat() );
 
-        writer.write(numPoints);
+        writer->write(numPoints);
     }
 
     return 0;
diff -r cc83cbdc225c -r 2ad5b59719ea apps/pcinfo.cpp
--- a/apps/pcinfo.cpp	Thu Jul 14 13:11:40 2011 -0700
+++ b/apps/pcinfo.cpp	Tue Jul 19 11:02:17 2011 -0700
@@ -82,7 +82,7 @@
         return 1;
     }
 
-    pdal::Stage* reader = NULL;
+    pdal::DataStage* reader = NULL;
     size_t ext = m_inputFile.find_last_of('.');
     if (ext != std::string::npos)
     {
diff -r cc83cbdc225c -r 2ad5b59719ea apps/pcview/main.cpp
--- a/apps/pcview/main.cpp	Thu Jul 14 13:11:40 2011 -0700
+++ b/apps/pcview/main.cpp	Tue Jul 19 11:02:17 2011 -0700
@@ -132,7 +132,7 @@
 class ThreadArgs
 {
 public:
-    ThreadArgs(Controller& controller, pdal::Stage& stage, boost::uint32_t startPoint, boost::uint32_t numPoints)
+    ThreadArgs(Controller& controller, pdal::DataStage& stage, boost::uint32_t startPoint, boost::uint32_t numPoints)
         : m_controller(controller)
         , m_stage(stage)
         , m_startPoint(startPoint)
@@ -141,7 +141,7 @@
     { }
 
     Controller& m_controller;
-    pdal::Stage& m_stage;
+    pdal::DataStage& m_stage;
     boost::uint32_t m_startPoint;
     boost::uint32_t m_numPoints;
     boost::uint32_t m_numRead;
@@ -157,14 +157,14 @@
 static void givePointsToEngine(ThreadArgs* threadArgs)
 {
     Controller& controller = threadArgs->m_controller;
-    pdal::Stage& stage = threadArgs->m_stage;
+    pdal::DataStage& stage = threadArgs->m_stage;
     boost::uint32_t startPoint = threadArgs->m_startPoint;
     boost::uint32_t numPoints = threadArgs->m_numPoints;
 
     const pdal::Schema& schema = stage.getSchema();
     const pdal::SchemaLayout schemaLayout(schema);
 
-    pdal::StageSequentialIterator* iter = stage.createSequentialIterator();
+    pdal::StageSequentialIteratorPtr iter = stage.createSequentialIterator();
     pdal::PointBuffer buffer(schemaLayout, numPoints);
     iter->skip(startPoint);
     const boost::uint32_t numRead = iter->read(buffer);
@@ -220,8 +220,6 @@
     controller.addPoints(points, colors, numRead);
     mutex.unlock();
 
-    delete iter;
-
     threadArgs->m_numRead = numRead;
 
     return;
@@ -232,12 +230,15 @@
 {
     boost::timer timer;
 
-    pdal::Options optsR("filename", file, "file to read from");
-    pdal::Stage* reader = new pdal::drivers::las::LasReader(optsR);
-    
-    pdal::Stage* decimator = new pdal::filters::DecimationFilter(*reader, factor);
+    pdal::Options readerOptions;
+    readerOptions.add("filename", file);
+    pdal::DataStagePtr reader(new pdal::drivers::las::LasReader(readerOptions));
 
-    pdal::Stage* colorizer = new pdal::filters::ColorFilter(*decimator);
+    pdal::Options decimatorOptions;
+    decimatorOptions.add("step", factor);
+    pdal::DataStagePtr decimator(new pdal::filters::DecimationFilter(reader, decimatorOptions));
+
+    pdal::DataStagePtr colorizer(new pdal::filters::ColorFilter(decimator, pdal::Options::empty()));
 
     const boost::uint32_t numPoints = (boost::uint32_t)colorizer->getNumPoints();
 
@@ -269,10 +270,6 @@
     controller.setBounds((float)bounds.getMinimum(0), (float)bounds.getMinimum(1), (float)bounds.getMinimum(2), 
                          (float)bounds.getMaximum(0), (float)bounds.getMaximum(1), (float)bounds.getMaximum(2));
 
-    delete colorizer;
-    delete decimator;
-    delete reader;
-
     return;
 }
 
diff -r cc83cbdc225c -r 2ad5b59719ea apps/qfit2las.cpp
--- a/apps/qfit2las.cpp	Thu Jul 14 13:11:40 2011 -0700
+++ b/apps/qfit2las.cpp	Tue Jul 19 11:02:17 2011 -0700
@@ -84,20 +84,19 @@
         return 1;
     }
 
-    pdal::Options options;
+    pdal::Options readerOptions;
+    readerOptions.add("input", m_inputFile, "Input filename for reader to use" );
+    DataStagePtr reader(new pdal::drivers::qfit::Reader(readerOptions));
+    
+    const boost::uint64_t numPoints = reader->getNumPoints();
 


More information about the Liblas-commits mailing list