[Liblas-commits] hg-main-tree: support skipping

liblas-commits at liblas.org liblas-commits at liblas.org
Tue Apr 19 00:22:16 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/b1d2ca59701c
changeset: 594:b1d2ca59701c
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Mon Apr 18 21:20:50 2011 -0700
description:
support skipping
Subject: hg-main-tree: handle read-past-end nicely

details:   http://hg.libpc.orghg-main-tree/rev/6e2ac55da7cc
changeset: 595:6e2ac55da7cc
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Mon Apr 18 21:21:07 2011 -0700
description:
handle read-past-end nicely
Subject: hg-main-tree: move to do parallel reads (oooh\!)

details:   http://hg.libpc.orghg-main-tree/rev/1b8de28f673d
changeset: 596:1b8de28f673d
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Mon Apr 18 21:22:04 2011 -0700
description:
move to do parallel reads (oooh\!)

diffstat:

 apps/pcview/Controller.cpp               |   29 +---
 apps/pcview/Controller.hpp               |   17 +-
 apps/pcview/Engine.cpp                   |  109 +++++++++------
 apps/pcview/main.cpp                     |  201 ++++++++++++++++++++----------
 include/libpc/drivers/las/Reader.hpp     |    2 +-
 src/drivers/las/Iterator.cpp             |    4 +-
 src/drivers/las/Reader.cpp               |    6 +-
 src/filters/DecimationFilterIterator.cpp |    7 +-
 8 files changed, 229 insertions(+), 146 deletions(-)

diffs (truncated from 600 to 300 lines):

diff -r 023ee2d9fa27 -r 1b8de28f673d apps/pcview/Controller.cpp
--- a/apps/pcview/Controller.cpp	Mon Apr 18 14:27:50 2011 -0700
+++ b/apps/pcview/Controller.cpp	Mon Apr 18 21:22:04 2011 -0700
@@ -48,9 +48,6 @@
     , m_cameraX(m_defaultCameraX)
     , m_cameraY(m_defaultCameraY)
     , m_cameraZ(m_defaultCameraZ)
-    , m_numPoints(0)
-    , m_points(NULL)
-    , m_colors(NULL)
     , m_minx(0.0f)
     , m_miny(0.0f)
     , m_minz(0.0f)
@@ -176,29 +173,19 @@
 }
 
 
-int Controller::getNumPoints() const
+std::vector<Controller::Data> Controller::getDataVector() const
 {
-    return m_numPoints;
-}
- 
-
-const float* Controller::getPoints() const
-{
-    return m_points;
-}
- 
-
-const boost::uint16_t* Controller::getColors() const
-{
-    return m_colors;
+    return m_dataVector;
 }
 
 
-void Controller::setPoints(const float* points, const boost::uint16_t* colors, int numPoints)
+void Controller::addPoints(float* points, boost::uint16_t* colors, int numPoints)
 {
-    m_numPoints = numPoints;
-    m_points = points;
-    m_colors = colors;
+    Data data;
+    data.points = points;
+    data.colors = colors;
+    data.numPoints = numPoints;
+    m_dataVector.push_back(data);
 }
 
 
diff -r 023ee2d9fa27 -r 1b8de28f673d apps/pcview/Controller.hpp
--- a/apps/pcview/Controller.hpp	Mon Apr 18 14:27:50 2011 -0700
+++ b/apps/pcview/Controller.hpp	Mon Apr 18 21:22:04 2011 -0700
@@ -36,6 +36,7 @@
 #define INCLUDED_PCVIEW_CONTROLLER_H
 
 #include <deque>
+#include <vector>
 
 #include <boost/cstdint.hpp>
 
@@ -65,10 +66,14 @@
     double getCameraZ() const;
     void setCamera(double x, double y, double z);
 
-    int getNumPoints() const;
-    const float* getPoints() const;
-    const boost::uint16_t* getColors() const;
-    void setPoints(const float* points, const boost::uint16_t* colors, int numPoints);
+    typedef struct
+    {
+        int numPoints;
+        float* points;
+        boost::uint16_t* colors;
+    } Data;
+    std::vector<Data> getDataVector() const;
+    void addPoints(float* points, boost::uint16_t* colors, int numPoints);
 
     void setBounds(float minx, float miny, float minz, float maxx, float maxy, float maxz);
     void getBounds(float& minx, float& miny, float& minz, float& maxx, float& maxy, float& maxz, float& delx, float& dely, float& delz);
@@ -94,9 +99,7 @@
     double m_cameraY;
     double m_cameraZ;
 
-    int m_numPoints;
-    const float* m_points;
-    const boost::uint16_t* m_colors;
+    std::vector<Data> m_dataVector;
 
     float m_minx, m_miny, m_minz, m_maxx, m_maxy, m_maxz;
 
diff -r 023ee2d9fa27 -r 1b8de28f673d apps/pcview/Engine.cpp
--- a/apps/pcview/Engine.cpp	Mon Apr 18 14:27:50 2011 -0700
+++ b/apps/pcview/Engine.cpp	Mon Apr 18 21:22:04 2011 -0700
@@ -345,6 +345,8 @@
     // handle arc rotation
     glMultMatrixf(m_arcBall->getTransform());
 
+    float zAdjust = 1.0f;
+
     // scale and translate scale from model coords to view coords
     float minx, miny, minz, maxx, maxy, maxz, delx, dely, delz;
     controller.getBounds(minx, miny, minz, maxx, maxy, maxz, delx, dely, delz);
@@ -352,52 +354,11 @@
     float rangeMax = delx;
     if (dely > rangeMax) rangeMax = dely;
     if (delz > rangeMax) rangeMax = delz;
-    glScaled(1.0/rangeMax, 1.0/rangeMax, 1.0/rangeMax);
+    glScaled(1.0/rangeMax, 1.0/rangeMax, zAdjust * 1.0/rangeMax);
 
-    glTranslated(-minx-delx/2.0,-miny-dely/2.0,-minz-delx/2.0);
+    glTranslated(-minx-delx/2.0,-miny-dely/2.0,(-minz-delx/2.0)/zAdjust);
 
-    const float* points = controller.getPoints();
-    const boost::uint16_t* colors = controller.getColors();
-    const int numPoints = controller.getNumPoints();
-    
-#if 0
-    // draw points
-    glBegin(GL_POINTS);
-    glColor3f(1,1,1);
-    for (int i=0; i<numPoints*3; i+=3)
-    {
-        float x = points[i];
-        float y = points[i+1];
-        float z = points[i+2];
-
-        if (colors != NULL)
-        {
-            boost::uint16_t r = colors[i];
-            boost::uint16_t g = colors[i+1];
-            boost::uint16_t b = colors[i+2];
-
-            glColor3us(r, g, b);
-        }
-
-        glVertex3f(x, y, z);
-    }
-    glEnd();
-#else
-    glEnableClientState(GL_COLOR_ARRAY);
-    glEnableClientState(GL_VERTEX_ARRAY);
-    glColorPointer(3, GL_UNSIGNED_SHORT, 0, colors);
-    glVertexPointer(3, GL_FLOAT, 0, points);
-    
-    glBegin(GL_POINTS);
-    for (int i=0; i<numPoints; i++)
-    {
-        glArrayElement(i);
-    }
-    glEnd();
-    //glDrawElements(GL_POINTS, numPoints, GL_FLOAT, points);
-#endif
-
-    if (0)
+    if (1)
     {
     // draw cube
     glBegin(GL_LINES);
@@ -440,7 +401,6 @@
     glVertex3f(maxx,maxy,maxz);
 
     glEnd();
-    }
 
 #if 0
     // put indicator at orgin
@@ -452,6 +412,65 @@
     glVertex3f(minx+0.2f*delx, miny, minz);
     glEnd();
 #endif
+    }
+
+    for (size_t v=0; v<controller.getDataVector().size(); v++)
+    {
+        const float* points = controller.getDataVector()[v].points;
+        const boost::uint16_t* colors = controller.getDataVector()[v].colors;
+        const int numPoints = controller.getDataVector()[v].numPoints;
+        
+#if 0
+        // draw points
+        glBegin(GL_POINTS);
+        glColor3f(1,1,1);
+        for (int i=0; i<numPoints*3; i+=3)
+        {
+            float x = points[i];
+            float y = points[i+1];
+            float z = points[i+2];
+
+            if (colors != NULL)
+            {
+                boost::uint16_t r = colors[i];
+                boost::uint16_t g = colors[i+1];
+                boost::uint16_t b = colors[i+2];
+
+                glColor3us(r, g, b);
+            }
+
+            glVertex3f(x, y, z);
+        }
+        glEnd();
+#else
+        glEnableClientState(GL_VERTEX_ARRAY);
+        glVertexPointer(3, GL_FLOAT, 0, points);
+
+        if (colors)
+        {
+            glEnableClientState(GL_COLOR_ARRAY);
+            glColorPointer(3, GL_UNSIGNED_SHORT, 0, colors);
+        }
+        else
+        {
+            glColor3f(1,1,1);
+        }
+
+        glBegin(GL_POINTS);
+        {
+            if (!colors)
+            {
+                glColor3f(1,1,1);
+            }
+            for (int i=0; i<numPoints; i++)
+            {
+                glArrayElement(i);
+            }
+        }
+        glEnd();
+        //glDrawElements(GL_POINTS, numPoints, GL_FLOAT, points);
+#endif
+    }
 
     glFlush();
 
diff -r 023ee2d9fa27 -r 1b8de28f673d apps/pcview/main.cpp
--- a/apps/pcview/main.cpp	Mon Apr 18 14:27:50 2011 -0700
+++ b/apps/pcview/main.cpp	Mon Apr 18 21:22:04 2011 -0700
@@ -35,6 +35,7 @@
 #include <stdlib.h>
 
 #include <boost/timer.hpp>
+#include <boost/thread.hpp>
 
 #include "Engine.hpp"
 #include "Controller.hpp"
@@ -54,9 +55,6 @@
 
 using namespace std;
 
-static float* g_points = NULL;
-static boost::uint16_t* g_colors = NULL;
-
 
 static float myrand_gaussian() // returns [0..1]
 {
@@ -83,8 +81,8 @@
 static void readFakeFile(Controller& controller)
 {
     const int numPoints = 10000;
-    g_points = new float[numPoints * 3];
-    g_colors = new boost::uint16_t[numPoints * 3];
+    float* points = new float[numPoints * 3];
+    boost::uint16_t* colors = new boost::uint16_t[numPoints * 3];
 
     const float minx = 100.0;
     const float maxx = 200.0;
@@ -102,9 +100,9 @@
         float y = miny + dely*myrand_normal();
         float z = minz + delz*myrand_gaussian();
 
-        g_points[i] = (float)x;
-        g_points[i+1] = (float)y;
-        g_points[i+2] = (float)z;
+        points[i] = (float)x;
+        points[i+1] = (float)y;
+        points[i+2] = (float)z;
 
         double red,green,blue;
         libpc::Color::interpolateColor(z,minz,maxz,red,green,blue);
@@ -114,59 +112,70 @@
         boost::uint16_t g16 = (boost::uint16_t)(green * vmax);
         boost::uint16_t b16 = (boost::uint16_t)(blue * vmax);
 
-        g_colors[i] = r16;
-        g_colors[i+1] = g16;
-        g_colors[i+2] = b16;
+        colors[i] = r16;
+        colors[i+1] = g16;
+        colors[i+2] = b16;
     }
 
-    controller.setPoints(g_points, g_colors, numPoints);
+    controller.addPoints(points, colors, numPoints);
     controller.setBounds(minx, miny, minz, maxx, maxy, maxz);
 
     return;
 }
 
+    
+boost::uint32_t maxPoints = 1000 * 1000;


More information about the Liblas-commits mailing list