[Liblas-commits] hg: 2 new changesets
liblas-commits at liblas.org
liblas-commits at liblas.org
Wed Jul 14 11:50:52 EDT 2010
changeset 5046a89520c7 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=5046a89520c7
summary: don't copy transform points onto the heap. no reason for that
changeset 1c965145fba9 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=1c965145fba9
summary: replace reprojection transform with boost::shared_ptr instead of naked pointer
diffstat:
include/liblas/laswriter.hpp | 9 +++++++--
src/laswriter.cpp | 41 +++++++++++++++++++++++------------------
2 files changed, 30 insertions(+), 20 deletions(-)
diffs (134 lines):
diff -r e07b656ef222 -r 1c965145fba9 include/liblas/laswriter.hpp
--- a/include/liblas/laswriter.hpp Wed Jul 14 10:34:40 2010 -0500
+++ b/include/liblas/laswriter.hpp Wed Jul 14 10:49:25 2010 -0500
@@ -56,10 +56,14 @@
#include <memory>
#include <cstdlib> // std::size_t
+#include <boost/shared_ptr.hpp>
+
namespace liblas
{
+typedef boost::shared_ptr< liblas::TransformI > TransformPtr;
+
/// Defines public interface to LAS writer implementation.
/// This class
@@ -125,8 +129,9 @@
std::vector<liblas::FilterI*>* m_filters;
std::vector<liblas::TransformI*>* m_transforms;
-
- liblas::TransformI* m_reprojection_transform;
+
+ TransformPtr m_reprojection_transform;
+ // liblas::TransformI* m_reprojection_transform;
SpatialReference m_out_srs;
SpatialReference m_in_srs;
diff -r e07b656ef222 -r 1c965145fba9 src/laswriter.cpp
--- a/src/laswriter.cpp Wed Jul 14 10:34:40 2010 -0500
+++ b/src/laswriter.cpp Wed Jul 14 10:49:25 2010 -0500
@@ -57,7 +57,7 @@
m_pimpl(detail::WriterFactory::Create(ofs)), m_header(header),
m_filters(0),
m_transforms(0),
- m_reprojection_transform(0)
+ m_reprojection_transform(TransformPtr())
{
m_pimpl->WriteHeader(m_header);
@@ -123,23 +123,22 @@
if (bHaveTransforms) {
if (m_transforms->size() != 0) {
+
// Apply the transforms to each point
- Point* pt = new Point(point);
+ Point p(point);
for (ti = m_transforms->begin(); ti != m_transforms->end(); ++ti) {
liblas::TransformI* transform = *ti;
- transform->transform(*pt);
+ transform->transform(p);
}
// We have to write a copy of our point, because we're applying
// transformations that change the point.
- m_pimpl->WritePoint(*pt, m_header);
- delete pt;
+ m_pimpl->WritePoint(p, m_header);
return true;
}
}
-
// if we haven't returned because of the filter and we don't have any
// transforms, just write the point
@@ -150,7 +149,6 @@
std::ostream& Writer::GetStream() const
{
return m_pimpl->GetStream();
- // return m_ofs;
}
void Writer::WriteHeader(Header& header)
@@ -176,7 +174,13 @@
{
m_out_srs = srs;
-
+ // Check the very first transform and see if it is
+ // the reprojection transform. If it is, we're going to
+ // nuke it and replace it with a new one
+
+ // If there was nothing there, we're going to make a new reprojection
+ // transform and put in on the transforms list (or make a new transforms
+ // list if *that* isn't there).
TransformI* possible_reprojection_transform = 0;
if (m_transforms != 0) {
@@ -185,29 +189,30 @@
}
}
- if (m_reprojection_transform == possible_reprojection_transform && m_reprojection_transform != 0) {
+ if (m_reprojection_transform.get() == possible_reprojection_transform && m_reprojection_transform.get() != 0) {
// remove it from the transforms list
std::vector<TransformI*>::iterator i = m_transforms->begin();
m_transforms->erase(i);
}
- if (m_reprojection_transform != 0)
- {
- delete m_reprojection_transform;
- }
-
- m_reprojection_transform = new ReprojectionTransform(m_in_srs, m_out_srs);
+ // overwrite our reprojection transform
+ m_reprojection_transform = TransformPtr(new ReprojectionTransform(m_in_srs, m_out_srs));
if (m_transforms != 0) {
if (m_transforms->size() > 0) {
- m_transforms->insert(m_transforms->begin(), m_reprojection_transform);
+ // Insert the new reprojection transform to the beginning of the
+ // vector there are already transforms there.
+ m_transforms->insert(m_transforms->begin(), m_reprojection_transform.get());
} else {
- m_transforms->push_back(m_reprojection_transform);
+ // List exists, but its size is 0
+ m_transforms->push_back(m_reprojection_transform.get());
}
} else {
+ // transforms don't exist yet, make a new one and put our
+ // reprojection transform on it.
m_transforms = new std::vector<liblas::TransformI*>;
- m_transforms->push_back(m_reprojection_transform);
+ m_transforms->push_back(m_reprojection_transform.get());
}
More information about the Liblas-commits
mailing list