Skip to content

Commit

Permalink
go back to caching Dimensions for now, with the caveat listed in the …
Browse files Browse the repository at this point in the history
…comment
  • Loading branch information
hobu committed Jul 8, 2013
1 parent d55cba3 commit c4b7d05
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 8 deletions.
3 changes: 3 additions & 0 deletions include/pdal/drivers/las/Reader.hpp
Expand Up @@ -141,6 +141,9 @@ class Base
void initialize();

protected:

Schema const* m_describedSchema;
PointDimensions* m_pointDimensions;
const pdal::drivers::las::Reader& m_reader;
std::istream& m_istream;

Expand Down
64 changes: 56 additions & 8 deletions src/drivers/las/Reader.cpp
Expand Up @@ -679,7 +679,9 @@ namespace iterators


Base::Base(pdal::drivers::las::Reader const& reader)
: m_reader(reader)
: m_describedSchema(0)
, m_pointDimensions(0)
, m_reader(reader)
, m_istream(m_reader.getStreamFactory().allocate())
, m_zipPoint(NULL)
, m_unzipper(NULL)
Expand All @@ -705,7 +707,9 @@ Base::~Base()
m_zipPoint.reset();
m_unzipper.reset();
#endif


if (m_pointDimensions)
delete m_pointDimensions;
m_reader.getStreamFactory().deallocate(m_istream);
}

Expand Down Expand Up @@ -806,22 +810,44 @@ bool Reader::atEndImpl() const

boost::uint32_t Reader::readBufferImpl(PointBuffer& data)
{
PointDimensions cachedDimensions(data.getSchema(), m_reader.getName());
// There's still a scenario where this fails...
// If the PointBuffer's schema changed inbetween successive
// readBufferImpl calls in such a way that altered the order,
// we're still screwed.

Schema const* schema = &data.getSchema();
if (!m_pointDimensions)
{
m_pointDimensions = new PointDimensions(*schema, m_reader.getName());
}

if (!m_describedSchema)
{
m_describedSchema = schema;
} else
{
if (m_describedSchema != schema)
{
delete m_pointDimensions;
m_pointDimensions = new PointDimensions(*schema, m_reader.getName());
}
}

#ifdef PDAL_HAVE_LASZIP
return m_reader.processBuffer(data,
m_istream,
getStage().getNumPoints()-this->getIndex(),
m_unzipper.get(),
m_zipPoint.get(),
&cachedDimensions,
m_pointDimensions,
m_read_buffer);
#else
return m_reader.processBuffer(data,
m_istream,
getStage().getNumPoints()-this->getIndex(),
NULL,
NULL,
&cachedDimensions,
m_pointDimensions,
m_read_buffer);

#endif
Expand Down Expand Up @@ -880,22 +906,44 @@ boost::uint64_t Reader::seekImpl(boost::uint64_t count)

boost::uint32_t Reader::readBufferImpl(PointBuffer& data)
{
PointDimensions cachedDimensions(data.getSchema(), m_reader.getName());
// There's still a scenario where this fails...
// If the PointBuffer's schema changed inbetween successive
// readBufferImpl calls in such a way that altered the order,
// we're still screwed.

Schema const* schema = &data.getSchema();
if (!m_pointDimensions)
{
m_pointDimensions = new PointDimensions(*schema, m_reader.getName());
}

if (!m_describedSchema)
{
m_describedSchema = schema;
} else
{
if (m_describedSchema != schema)
{
delete m_pointDimensions;
m_pointDimensions = new PointDimensions(*schema, m_reader.getName());
}
}

#ifdef PDAL_HAVE_LASZIP
return m_reader.processBuffer(data,
m_istream,
getStage().getNumPoints()-this->getIndex(),
m_unzipper.get(),
m_zipPoint.get(),
&cachedDimensions,
m_pointDimensions,
m_read_buffer);
#else
return m_reader.processBuffer(data,
m_istream,
getStage().getNumPoints()-this->getIndex(),
NULL,
NULL,
&cachedDimensions,
m_pointDimensions,
m_read_buffer);

#endif
Expand Down

0 comments on commit c4b7d05

Please sign in to comment.