[Liblas-commits] hg-main-tree: build fix for win32

liblas-commits at liblas.org liblas-commits at liblas.org
Wed Mar 16 15:38:40 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/8fbec3925ab6
changeset: 299:8fbec3925ab6
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Wed Mar 16 15:38:27 2011 -0400
description:
build fix for win32
Subject: hg-main-tree: merge

details:   http://hg.libpc.orghg-main-tree/rev/9ee4dd85b70d
changeset: 300:9ee4dd85b70d
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Wed Mar 16 15:38:38 2011 -0400
description:
merge

diffstat:

 apps/pc2pc.cpp               |   2 +-
 include/libpc/PointData.hpp  |  17 +++--------
 src/PointData.cpp            |  65 +++++++------------------------------------
 src/drivers/faux/Reader.cpp  |   2 -
 src/drivers/faux/Writer.cpp  |  31 ++++++++------------
 src/drivers/las/Reader.cpp   |   2 -
 src/drivers/las/Writer.cpp   |   1 -
 src/filters/ColorFilter.cpp  |  22 +++++---------
 src/filters/CropFilter.cpp   |  45 +++++++++++++----------------
 src/filters/MosaicFilter.cpp |  10 +------
 test/unit/CropFilterTest.cpp |   2 +-
 test/unit/main.cpp           |   4 +-
 12 files changed, 62 insertions(+), 141 deletions(-)

diffs (truncated from 410 to 300 lines):

diff -r f4d00899cec4 -r 9ee4dd85b70d apps/pc2pc.cpp
--- a/apps/pc2pc.cpp	Wed Mar 16 14:32:54 2011 -0500
+++ b/apps/pc2pc.cpp	Wed Mar 16 15:38:38 2011 -0400
@@ -127,7 +127,7 @@
     else if (hasOption("oracle"))
     {
 #ifdef HAVE_ORACLE
-        LiblasReader reader(*ifs);
+        libpc::drivers::liblas::LiblasReader reader(*ifs);
     
         const boost::uint64_t numPoints = reader.getHeader().getNumPoints();
         
diff -r f4d00899cec4 -r 9ee4dd85b70d include/libpc/PointData.hpp
--- a/include/libpc/PointData.hpp	Wed Mar 16 14:32:54 2011 -0500
+++ b/include/libpc/PointData.hpp	Wed Mar 16 15:38:38 2011 -0400
@@ -58,21 +58,22 @@
 {
     
 public:
-    typedef std::vector<boost::uint8_t> valid_mask_type;
     
     // note that when we make a PointData object all the fields are initialized to inactive,
     // regardless of what the passed-in schema says -- this is because the field object
     // represents the state within the owning object, which in this case is a completely
     // empty buffer (similarly, all the points in the buffer are marked "invalid")
-    PointData(const SchemaLayout&, boost::uint32_t numPoints);
+    PointData(const SchemaLayout&, boost::uint32_t capacity);
     ~PointData();
 
     // number of points in this buffer
     boost::uint32_t getNumPoints() const;
+    
+    inline void setNumPoints(boost::uint32_t v) { m_numPoints = v; } 
 
     // number of points in this buffer that have legit data; initially will be zero,
     // and after a read() call it will be in the range 0 to getNumPoints()-1
-    boost::uint32_t getNumValidPoints();
+    boost::uint32_t getCapacity();
 
     // schema (number and kinds of fields) for a point in this buffer
     const SchemaLayout& getSchemaLayout() const
@@ -86,13 +87,6 @@
         return m_schemaLayout.getSchema();
     }
 
-    // "valid" means the data for the point can be used; if invalid, the point should
-    // be ignored or skipped.  (This is done for efficiency; we don't want to have to
-    // modify the buffer's size just to "delete" a point.)
-    bool isValid(valid_mask_type::size_type pointIndex) const;
-    bool allValid() const;
-    void setValid(valid_mask_type::size_type  pointIndex, bool value=true);
-    
 
     // accessors to a particular field of a particular point in this buffer
     template<class T> T getField(std::size_t pointIndex, std::size_t fieldIndex) const;
@@ -114,8 +108,7 @@
     boost::uint8_t* m_data;
     std::size_t m_pointSize;
     boost::uint32_t m_numPoints;
-    
-    valid_mask_type m_isValid; // one byte for each point
+    boost::uint32_t m_capacity;    
 
     PointData(const PointData&); // not implemented
     PointData& operator=(const PointData&); // not implemented
diff -r f4d00899cec4 -r 9ee4dd85b70d src/PointData.cpp
--- a/src/PointData.cpp	Wed Mar 16 14:32:54 2011 -0500
+++ b/src/PointData.cpp	Wed Mar 16 15:38:38 2011 -0400
@@ -44,17 +44,14 @@
 {
 
 
-PointData::PointData(const SchemaLayout& schemaLayout, boost::uint32_t numPoints) :
+PointData::PointData(const SchemaLayout& schemaLayout, boost::uint32_t capacity) :
     m_schemaLayout(schemaLayout),
     m_data(NULL),
     m_pointSize(m_schemaLayout.getByteSize()),
-    m_numPoints(numPoints),
-    m_isValid(numPoints)
+    m_numPoints(0),
+    m_capacity(capacity)
 {
-    m_data = new boost::uint8_t[m_pointSize * m_numPoints];
-    
-    // the points will all be set to invalid here
-    m_isValid.assign(m_isValid.size(), 0);
+    m_data = new boost::uint8_t[m_pointSize * m_capacity];
 
     return;
 }
@@ -67,31 +64,6 @@
 }
 
 
-bool
-PointData::isValid(std::size_t index) const
-{
-    return (m_isValid[index] != 0);
-}
-
-bool PointData::allValid() const
-{
-    valid_mask_type::size_type i = 0;
-    while(i < m_isValid.size())
-    {
-        if (m_isValid[i] != 1) return false;
-        i++;
-    }
-    return true;
-    
-}
-
-void
-PointData::setValid(std::size_t index, bool value)
-{
-    m_isValid[index] = static_cast<bool>(value);
-}
-
-
 boost::uint8_t* PointData::getData(std::size_t index) const
 {
     return m_data + m_pointSize * index;
@@ -113,9 +85,7 @@
     std::size_t len = getSchemaLayout().getByteSize();
 
     memcpy(dest, src, len);
-
-        
-    setValid(destPointIndex, srcPointData.isValid(srcPointIndex));
+    m_numPoints++;
 
     return;
 }
@@ -130,21 +100,8 @@
     std::size_t len = getSchemaLayout().getByteSize();
 
     memcpy(dest, src, len * numPoints);
-
-    if (srcPointData.allValid())
-    {
-        m_isValid.assign(m_isValid.size(), 1);
-    }
-    else 
-    {
-        for (valid_mask_type::size_type i=0; i<numPoints; i++)
-        {
-          setValid(destPointIndex+i, srcPointData.isValid(srcPointIndex+i));
-        }
-        
-    }
-
-
+    
+    m_numPoints = m_numPoints + numPoints;
     return;
 }
 
@@ -160,14 +117,14 @@
     int cnt = 0;
     for (boost::uint32_t pointIndex=0; pointIndex<numPoints; pointIndex++)
     {
-        if (pointData.isValid(pointIndex))
-            ++cnt;
+
+        ++cnt;
     }
-    ostr << "Contains " << cnt << " valid points (" << pointData.getNumPoints() << " total)" << endl;
+    ostr << "Contains " << cnt << "  points (" << pointData.getNumPoints() << " total)" << endl;
 
     for (boost::uint32_t pointIndex=0; pointIndex<numPoints; pointIndex++)
     {
-        if (!pointData.isValid(pointIndex)) continue;
+
         
         ostr << "Point: " << pointIndex << endl;
 
diff -r f4d00899cec4 -r 9ee4dd85b70d src/drivers/faux/Reader.cpp
--- a/src/drivers/faux/Reader.cpp	Wed Mar 16 14:32:54 2011 -0500
+++ b/src/drivers/faux/Reader.cpp	Wed Mar 16 15:38:38 2011 -0400
@@ -142,8 +142,6 @@
             z = (double)minZ;
         }
 
-        data.setValid(pointIndex);
-
         data.setField<double>(pointIndex, offsetX, x);
         data.setField<double>(pointIndex, offsetY, y);
         data.setField<double>(pointIndex, offsetZ, z);
diff -r f4d00899cec4 -r 9ee4dd85b70d src/drivers/faux/Writer.cpp
--- a/src/drivers/faux/Writer.cpp	Wed Mar 16 14:32:54 2011 -0500
+++ b/src/drivers/faux/Writer.cpp	Wed Mar 16 15:38:38 2011 -0400
@@ -97,31 +97,26 @@
     const int fieldIndexY = schema.getDimensionIndex(Dimension::Field_Y);
     const int fieldIndexZ = schema.getDimensionIndex(Dimension::Field_Z);
 
-    boost::uint32_t numValidPoints = 0;
     for (boost::uint32_t pointIndex=0; pointIndex<numPoints; pointIndex++)
     {
-        if (pointData.isValid(pointIndex))
-        {
-            ++numValidPoints;
 
-            double x = pointData.getField<double>(pointIndex, fieldIndexX);
-            double y = pointData.getField<double>(pointIndex, fieldIndexY);
-            double z = pointData.getField<double>(pointIndex, fieldIndexZ);
+        double x = pointData.getField<double>(pointIndex, fieldIndexX);
+        double y = pointData.getField<double>(pointIndex, fieldIndexY);
+        double z = pointData.getField<double>(pointIndex, fieldIndexZ);
 
-            m_minimumX = std::min(m_minimumX, x);
-            m_minimumY = std::min(m_minimumY, y);
-            m_minimumZ = std::min(m_minimumZ, z);
-            m_maximumX = std::max(m_maximumX, x);
-            m_maximumY = std::max(m_maximumY, y);
-            m_maximumZ = std::max(m_maximumZ, z);
+        m_minimumX = std::min(m_minimumX, x);
+        m_minimumY = std::min(m_minimumY, y);
+        m_minimumZ = std::min(m_minimumZ, z);
+        m_maximumX = std::max(m_maximumX, x);
+        m_maximumY = std::max(m_maximumY, y);
+        m_maximumZ = std::max(m_maximumZ, z);
 
-            m_averageX += x;
-            m_averageY += y;
-            m_averageZ += z;
-        }
+        m_averageX += x;
+        m_averageY += y;
+        m_averageZ += z;
     }
 
-    return numValidPoints;
+    return numPoints;
 }
 
 
diff -r f4d00899cec4 -r 9ee4dd85b70d src/drivers/las/Reader.cpp
--- a/src/drivers/las/Reader.cpp	Wed Mar 16 14:32:54 2011 -0500
+++ b/src/drivers/las/Reader.cpp	Wed Mar 16 15:38:38 2011 -0400
@@ -185,7 +185,6 @@
             pointData.setField<boost::uint8_t>(pointIndex, fieldIndexUserData, user);
             pointData.setField<boost::uint16_t>(pointIndex, fieldIndexPointSource, pointSourceId);
 
-            pointData.setValid(pointIndex);
         }
         else if (pointFormat == LasHeader::ePointFormat1)
         {
@@ -239,7 +238,6 @@
             pointData.setField<boost::uint16_t>(pointIndex, fieldIndexGreen, green);
             pointData.setField<boost::uint16_t>(pointIndex, fieldIndexBlue, blue);
 
-            pointData.setValid(pointIndex);
         }
         else
         {
diff -r f4d00899cec4 -r 9ee4dd85b70d src/drivers/las/Writer.cpp
--- a/src/drivers/las/Writer.cpp	Wed Mar 16 14:32:54 2011 -0500
+++ b/src/drivers/las/Writer.cpp	Wed Mar 16 15:38:38 2011 -0400
@@ -142,7 +142,6 @@
 
     for (boost::uint32_t pointIndex=0; pointIndex<pointData.getNumPoints(); pointIndex++)
     {
-        if (pointData.isValid(pointIndex) == false) continue;
 
         if (pointFormat == LasHeader::ePointFormat0)
         {
diff -r f4d00899cec4 -r 9ee4dd85b70d src/filters/ColorFilter.cpp
--- a/src/filters/ColorFilter.cpp	Wed Mar 16 14:32:54 2011 -0500
+++ b/src/filters/ColorFilter.cpp	Wed Mar 16 15:38:38 2011 -0400
@@ -73,26 +73,20 @@
     int fieldIndexB = schema.getDimensionIndex(Dimension::Field_Blue);
     int offsetZ = schema.getDimensionIndex(Dimension::Field_Z);
 
-    boost::uint32_t numValidPoints = 0;
-
     for (boost::uint32_t pointIndex=0; pointIndex<numPoints; pointIndex++)
     {
-        if (data.isValid(pointIndex))
-        {
-            float z = data.getField<float>(pointIndex, offsetZ);
-            boost::uint8_t red, green, blue;
-            getColor(z, red, green, blue);
+        float z = data.getField<float>(pointIndex, offsetZ);
+        boost::uint8_t red, green, blue;
+        getColor(z, red, green, blue);
 
-            // now we store the 3 u8's in the point data...
-            data.setField<boost::uint8_t>(pointIndex, fieldIndexR, red);
-            data.setField<boost::uint8_t>(pointIndex, fieldIndexG, green);
-            data.setField<boost::uint8_t>(pointIndex, fieldIndexB, blue);
+        // now we store the 3 u8's in the point data...
+        data.setField<boost::uint8_t>(pointIndex, fieldIndexR, red);
+        data.setField<boost::uint8_t>(pointIndex, fieldIndexG, green);
+        data.setField<boost::uint8_t>(pointIndex, fieldIndexB, blue);
 
-            ++numValidPoints;
-        }
     }
 
-    return numValidPoints;


More information about the Liblas-commits mailing list