[vtkusers] Plotting flat surface using vtkChartXYZ and vtkPlotSurface
Aleksandar Atanasov
redbaronqueen at gmail.com
Wed Aug 10 05:47:53 EDT 2016
Hi all,
I'm having a really though time plotting a flat surface (as in every point
from that surface has the same *z value*). I'm using the QVTKWidget in my
Qt 5.7 application. My idea is to show one or multiple signals which
represent how near one or multiple (up to 10) fingers come to the surface
of a device. So initially the surface plot is flat (since no fingers are
touching it). Whenever a finger comes near the surface, the device emits
the position of that finger (*x,y values*) along with a signal strength at
that position (*z value*). I'm really new to the whole chart and surface
plotting in VTK (I have used it with PCL) so I have no idea where to look
at (it took me quite some time to even build and integrate the VTK and the
surface plot in my Qt application...). Basically if I set all my points to
have the same *z value* the surface plot simply doesn't show. I think this
has something to do with the scaling of the chart and the fact that it
expects a range of values. Even if it's binary (that is only two values are
possible for each *z value*) the min and max have to be different. Setting
the min and max to a very small values (min: 0, max: 0.00001) doesn't help
at all since the chart scales to these values and I get a very noisy
surface plot. Currently my plot is static (though I intend to bind it to
near real time values if it works out) and I'm setting up the data as
follows:
void Q3DTouchPadSignalsFingersPlot::setupPlot() {
int numPoints = 100;
double inc = 9.424778 / (numPoints - 1);
for (int i = 0; i < (int)numPoints; ++i) {
vtkNew<vtkFloatArray> arr;
this->surfaceData->AddColumn(arr.GetPointer());
}
this->surfaceData->SetNumberOfRows(numPoints);
for (int i = 0; i < (int)numPoints; ++i) {
double x = i*inc;
// double x = i;
for (int j = 0; j < (int)numPoints; ++j) {
double y = j*inc;
// double y = j;
this->surfaceData->SetValue(i, j,
sin(sqrt(x*x + y*y))/sqrt(x*x + y*y));
// sin(sqrt(x*x + y*y)) |
sin(sqrt(x*x + y*y))/sqrt(x*x + y*y)
}
}
this->plot->SetXRange(0, 9.424778);
this->plot->SetYRange(0, 9.424778);
this->plot->SetInputData(this->surfaceData.GetPointer());
}
This produces a quater of the function sin(sqrt(x*x + y*y))/sqrt(x*x + y*y)):
[image: Inline images 2]
If I change the setting of the data at the given location in the
surface to this->surfaceData->SetValue(i, j, 1) (that is I use a
constant)
the plot disappears:
[image: Inline images 1]
Any ideas how to fix this?
Kind regards,
Aleksandar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160810/36610b6f/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 95148 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160810/36610b6f/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 24174 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160810/36610b6f/attachment-0003.png>
More information about the vtkusers
mailing list