We were using QwtPlot3D recently to plot a point cloud. This 3rd-party Qt library is an extension to the popular Qwt library for 3D plotting. It uses OpenGL to create nice 3D plots with user interaction (e.g. rotation and zoom). It also colors the data based on the z-axis values and can automatically fit a mesh to your data. But we ran into a couple of issues with the library that did not work well for us (not including poor documentation). We made slight modifications to the library that greatly improve its speed and made our own colormap class because the default one doesn’t look good.
One issue with QwtPlot3D is that it is very slow to load new data sets. When plotting hundreds of thousands of points, it can take on the order of half a minute to load. What we realized is that all the time is spent resizing the internal data arrays. The reason is that every time new data is loaded to a plot using the loadFromData method, the internal GridData object is deallocated and reallocated regardless if the data dimensions change or not. Furthermore deallocation and reallocation both go through every single data point and deallocate or allocate a glDouble for that data point (see GridData::clear and GridData::setSize in qwt3d_types.cpp). Multiple calls to delete and new for small deallocations and allocations, respectively, are very inefficient so we changed this to make one big delete and one big new. Now GridData::setSize allocates a big array of size column*row*3*2 (3 for x, y, z and 2 is one for points and one for normals) and then assigns subsections of the array (specifically, counts of 3) to the data pointers. Likewise, GridData::clear just deallocates the single array. The other enhancement is that loadFromData method was modified to check whether the dimensions of the plot have changed. If not, but only the data is changing, then the clear and setSize methods are not called. You can download the revised files here.
The other issue with the library is the bad default colormap for color spreading provided by the StandardColor class. The StandardColor class spreads colors between red and blue. If you want something a little more colorful and easy to see (like Matlab’s Jet colormap) then you have to create your own Color object. We created an almost identical class to StandardColor, but rewrote the reset method to be:
void PlotColor::reset(unsigned size)
colors_ = Qwt3D::ColorVector(size);
double dsize = size;
for (unsigned int i=0; i!=size; ++i)
elem.r = red(i/dsize);
elem.g = green(i/dsize);
elem.b = blue(i/dsize);
elem.a = 1.0;
colors_[i] = elem;
The methods red, green and blue are provided by the code from here. This updated code is not provided in our binaries but can easily be created by inheriting from the Color class or even simpler from the StandardColor class.
Another setting you might be interested in for an improved look is the plot style. You can choose from among 5 different plot styles to set using the setPlotStyle method. Or you can even roll out your own. FILLED seems to be useful for a dense point cloud because otherwise there are far too many mesh lines.
You can download revised binaries (sorry, these are 64-bit Windows only but at least we have both debug and release versions) of version 0.2.7 of the library from here.