[Liblas-commits] hg-main-tree: Make the chipper support a
SequentialIterator and ...
liblas-commits at liblas.org
liblas-commits at liblas.org
Mon Mar 28 12:13:44 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/70a0560cdc38
changeset: 476:70a0560cdc38
user: Howard Butler <hobu.inc at gmail.com>
date: Mon Mar 28 11:13:35 2011 -0500
description:
Make the chipper support a SequentialIterator and implement writeBuffer to use it
diffstat:
apps/pc2pc.cpp | 13 +--
include/libpc/drivers/oci/Writer.hpp | 10 +--
include/libpc/filters/Chipper.hpp | 18 +++--
include/libpc/filters/ChipperIterator.hpp | 17 +++-
src/Writer.cpp | 5 +-
src/drivers/oci/Writer.cpp | 100 +++++++++++------------------
src/filters/Chipper.cpp | 93 ++++++++++++++++++---------
src/filters/ChipperIterator.cpp | 55 +++++++++++++++-
src/filters/ColorFilter.cpp | 2 +-
test/unit/ChipperTest.cpp | 6 +-
10 files changed, 189 insertions(+), 130 deletions(-)
diffs (truncated from 640 to 300 lines):
diff -r 173c8e4494c7 -r 70a0560cdc38 apps/pc2pc.cpp
--- a/apps/pc2pc.cpp Fri Mar 25 16:46:41 2011 -0700
+++ b/apps/pc2pc.cpp Mon Mar 28 11:13:35 2011 -0500
@@ -18,7 +18,7 @@
//#include <libpc/Color.hpp>
//#include <libpc/Dimension.hpp>
//#include <libpc/Schema.hpp>
-//#include <libpc/CropFilter.hpp>
+#include <libpc/filters/Chipper.hpp>
//#include <libpc/ColorFilter.hpp>
//#include <libpc/MosaicFilter.hpp>
//#include <libpc/FauxReader.hpp>
@@ -129,19 +129,14 @@
libpc::driver::oci::Options options;
boost::property_tree::ptree& tree = options.GetPTree();
- tree.put("capacity", 15);
+ tree.put("capacity", 12);
tree.put("connection", "lidar/lidar at oracle.hobu.biz/crrel");
tree.put("debug", true);
tree.put("verbose", true);
libpc::filters::CacheFilter cache(reader, 1, 1024);
-
- libpc::driver::oci::Writer writer(cache, options);
-
-
- //BUG: handle laz writer.setCompressed(false);
-
- //writer.setPointFormat( reader.getPointFormatNumber() );
+ libpc::filters::Chipper chipper(cache, 12);
+ libpc::driver::oci::Writer writer(chipper, options);
writer.write(numPoints);
#else
diff -r 173c8e4494c7 -r 70a0560cdc38 include/libpc/drivers/oci/Writer.hpp
--- a/include/libpc/drivers/oci/Writer.hpp Fri Mar 25 16:46:41 2011 -0700
+++ b/include/libpc/drivers/oci/Writer.hpp Mon Mar 28 11:13:35 2011 -0500
@@ -92,13 +92,9 @@
std::string LoadSQLData(std::string const& filename);
bool FillOraclePointBuffer(PointBuffer const& buffer,
- std::vector<boost::uint8_t>& point_data,
- filters::chipper::Block const& block,
- boost::uint32_t block_id);
+ std::vector<boost::uint8_t>& point_data);
bool WriteBlock(PointBuffer const& buffer,
- std::vector<boost::uint8_t>& point_data,
- filters::chipper::Block const& block,
- boost::uint32_t block_id);
+ std::vector<boost::uint8_t>& point_data);
void SetOrdinates(Statement statement,
OCIArray* ordinates,
@@ -106,7 +102,7 @@
void SetElements(Statement statement,
OCIArray* elem_info);
Stage& m_stage;
- filters::Chipper m_chipper;
+ // filters::Chipper m_chipper;
Options& m_options;
libpc::Bounds<double> m_bounds; // Bounds of the entire point cloud
diff -r 173c8e4494c7 -r 70a0560cdc38 include/libpc/filters/Chipper.hpp
--- a/include/libpc/filters/Chipper.hpp Fri Mar 25 16:46:41 2011 -0700
+++ b/include/libpc/filters/Chipper.hpp Mon Mar 28 11:13:35 2011 -0500
@@ -136,7 +136,7 @@
std::vector<boost::uint32_t> GetIDs() const;
libpc::Bounds<double> const& GetBounds() const {return m_bounds;}
void SetBounds(libpc::Bounds<double> const& bounds) {m_bounds = bounds;}
- PointBuffer GetBuffer( Stage& stage) const;
+ void GetBuffer( Stage const& stage, PointBuffer& buffer, boost::uint32_t block_id) const;
// double GetXmin() const
// { return m_xmin; }
// double GetYmin() const
@@ -153,21 +153,23 @@
{
public:
Chipper(Stage& prevStage, boost::uint32_t max_partition_size) :
- libpc::Filter(prevStage), m_stage(prevStage), m_threshold(max_partition_size),
+ libpc::Filter(prevStage), m_threshold(max_partition_size),
m_xvec(chipper::DIR_X), m_yvec(chipper::DIR_Y), m_spare(chipper::DIR_NONE)
- {}
+ {
+ checkImpedance();
+ }
void Chip();
- std::vector<chipper::Block>::size_type GetBlockCount()
+ std::vector<chipper::Block>::size_type GetBlockCount() const
{ return m_blocks.size(); }
- const chipper::Block& GetBlock(std::vector<chipper::Block>::size_type i)
+ const chipper::Block& GetBlock(std::vector<chipper::Block>::size_type i) const
{ return m_blocks[i]; }
const std::string& getName() const ;
bool supportsIterator (StageIteratorType t)
{
- if (t == StageIterator_Block ) return true;
+ if (t == StageIterator_Sequential ) return true;
return false;
}
@@ -188,9 +190,9 @@
boost::uint32_t pleft, boost::uint32_t pcenter);
void Emit(chipper::RefList& wide, boost::uint32_t widemin, boost::uint32_t widemax,
chipper::RefList& narrow, boost::uint32_t narrowmin, boost::uint32_t narrowmax );
-
- Stage& m_stage;
+ void checkImpedance();
+
boost::uint32_t m_threshold;
std::vector<chipper::Block> m_blocks;
std::vector<boost::uint32_t> m_partitions;
diff -r 173c8e4494c7 -r 70a0560cdc38 include/libpc/filters/ChipperIterator.hpp
--- a/include/libpc/filters/ChipperIterator.hpp Fri Mar 25 16:46:41 2011 -0700
+++ b/include/libpc/filters/ChipperIterator.hpp Mon Mar 28 11:13:35 2011 -0500
@@ -39,6 +39,8 @@
#include <libpc/FilterIterator.hpp>
#include <libpc/filters/Chipper.hpp>
+#include <libpc/exceptions.hpp>
+
namespace libpc {
@@ -46,17 +48,20 @@
-class ChipperBlockIterator : public libpc::FilterBlockIterator
+class ChipperSequentialIterator : public libpc::FilterSequentialIterator
{
public:
- ChipperBlockIterator(const Chipper& filter);
+ ChipperSequentialIterator(Chipper const& filter);
private:
- // boost::uint64_t skipImpl(boost::uint64_t);
- // boost::uint32_t readImpl(PointBuffer&);
- // bool atEndImpl() const;
+ boost::uint64_t skipImpl(boost::uint64_t);
+ boost::uint32_t readImpl(PointBuffer&);
+ bool atEndImpl() const;
- const Chipper& m_chipper;
+ Chipper const& m_chipper;
+ std::size_t m_currentBlockId;
+ boost::uint64_t m_currentPointCount;
+
};
diff -r 173c8e4494c7 -r 70a0560cdc38 src/Writer.cpp
--- a/src/Writer.cpp Fri Mar 25 16:46:41 2011 -0700
+++ b/src/Writer.cpp Mon Mar 28 11:13:35 2011 -0500
@@ -32,13 +32,14 @@
* OF SUCH DAMAGE.
****************************************************************************/
-#include <libpc/Writer.hpp>
//
#include <boost/scoped_ptr.hpp>
+#include <libpc/Writer.hpp>
#include <libpc/Iterator.hpp>
#include <libpc/Stage.hpp>
#include <libpc/PointBuffer.hpp>
+#include <libpc/exceptions.hpp>
namespace libpc
{
@@ -80,6 +81,8 @@
m_actualNumPointsWritten = 0;
boost::scoped_ptr<SequentialIterator> iter(m_prevStage.createSequentialIterator());
+
+ if (!iter) throw libpc_error("Unable to obtain iterator from previous stage!");
writeBegin();
diff -r 173c8e4494c7 -r 70a0560cdc38 src/drivers/oci/Writer.cpp
--- a/src/drivers/oci/Writer.cpp Fri Mar 25 16:46:41 2011 -0700
+++ b/src/drivers/oci/Writer.cpp Mon Mar 28 11:13:35 2011 -0500
@@ -48,7 +48,7 @@
Writer::Writer(Stage& prevStage, Options& options)
: libpc::Writer(prevStage)
, m_stage(prevStage)
- , m_chipper(m_stage, options.GetPTree().get<boost::uint32_t>("capacity") )
+ // , m_chipper(m_stage, options.GetPTree().get<boost::uint32_t>("capacity") )
, m_options(options)
, m_verbose(false)
{
@@ -591,17 +591,17 @@
void Writer::writeBegin()
{
- m_chipper.Chip();
-
- // cumulate a global bounds for the dataset
- for ( boost::uint32_t i = 0; i < m_chipper.GetBlockCount(); ++i )
- {
- const filters::chipper::Block& b = m_chipper.GetBlock(i);
-
- // FIXME: This only gets called once!
- if (m_bounds.empty()) // If the user already set the bounds for this writer, we're using that
- m_bounds.grow(b.GetBounds());
- }
+ // m_chipper.Chip();
+ //
+ // // cumulate a global bounds for the dataset
+ // for ( boost::uint32_t i = 0; i < m_chipper.GetBlockCount(); ++i )
+ // {
+ // const filters::chipper::Block& b = m_chipper.GetBlock(i);
+ //
+ // // FIXME: This only gets called once!
+ // if (m_bounds.empty()) // If the user already set the bounds for this writer, we're using that
+ // m_bounds.grow(b.GetBounds());
+ // }
// Set up debugging info
Debug();
@@ -612,7 +612,6 @@
if (!BlockTableExists())
CreateBlockTable();
- // m_stage.seekToPoint(0);
return;
}
@@ -624,14 +623,13 @@
}
bool Writer::FillOraclePointBuffer(PointBuffer const& buffer,
- std::vector<boost::uint8_t>& point_data,
- filters::chipper::Block const& block,
- boost::uint32_t block_id)
+ std::vector<boost::uint8_t>& point_data
+)
{
libpc::Schema const& schema = buffer.getSchema();
- std::vector<boost::uint32_t> ids = block.GetIDs();
+ // std::vector<boost::uint32_t> ids = block.GetIDs();
bool hasTimeData = schema.hasDimension(Dimension::Field_Time, Dimension::Uint64);
@@ -649,6 +647,10 @@
const int indexClassification = schema.getDimensionIndex(Dimension::Field_Classification, Dimension::Uint8);
const int indexTime = schema.getDimensionIndex(Dimension::Field_Time, Dimension::Double);
+ // "Global" ids from the chipper are also available here.
+ // const int indexId = schema.getDimensionIndex(Dimension::Field_User1, Dimension::Int32);
+ const int indexBlockId = schema.getDimensionIndex(Dimension::Field_User2, Dimension::Int32);
+
Dimension const& dimX = schema.getDimension(indexX);
Dimension const& dimY = schema.getDimension(indexY);
Dimension const& dimZ = schema.getDimension(indexZ);
@@ -662,8 +664,8 @@
double zoffset = dimZ.getNumericOffset();
boost::uint32_t counter = 0;
- std::cout.setf(std::ios_base::fixed, std::ios_base::floatfield);
- std::cout.precision(6);
+ // std::cout.setf(std::ios_base::fixed, std::ios_base::floatfield);
+ // std::cout.precision(6);
while (counter < count)
{
@@ -673,8 +675,10 @@
double z = (buffer.getField<boost::int32_t>(counter, indexZ) * zscale) + zoffset;
boost::uint8_t classification = buffer.getField<boost::uint8_t>(counter, indexClassification);
double c = static_cast<double>(classification);
- boost::uint32_t id = ids[counter];
- std::cout << x <<" "<< y <<" "<< z << " "<< id << " " << c <<std::endl;
+ // boost::uint32_t id = buffer.getField<boost::uint32_t>(counter, indexId);
+ boost::uint32_t block_id = buffer.getField<boost::uint32_t>(counter, indexBlockId);
+ // boost::uint32_t id = ids[counter];
+ // std::cout << x <<" "<< y <<" "<< z << " "<< id << " " << block_id <<" " << c <<std::endl;
double t = 0.0;
if (hasTimeData)
@@ -711,8 +715,8 @@
point_data.push_back(c_b[i]);
}
- boost::uint8_t* id_b = reinterpret_cast<boost::uint8_t*>(&id);
- boost::uint8_t* block_b = reinterpret_cast<boost::uint8_t*>(&block_id);
+ boost::uint8_t* id_b = reinterpret_cast<boost::uint8_t*>(&counter);
+ boost::uint8_t* block_b = reinterpret_cast<boost::uint8_t*>(&block_id);
// 4-byte big-endian integer for the BLK_ID value
for (int i = sizeof(boost::uint32_t) - 1; i >= 0; i--) {
@@ -770,9 +774,7 @@
}
bool Writer::WriteBlock(PointBuffer const& buffer,
More information about the Liblas-commits
mailing list