[vtkusers] Fwd: Problems with vtkDoubleArray
Ronald Römer
rroemer at gmail.com
Mon Jan 13 08:27:24 EST 2014
Hello Susanne,
the problem is simple. Don't use InsertNextTupleValue in conjunction with
SetNumberOfTuples (or SetNumberOfValues). The following code will work:
vtkDoubleArray *measurements = vtkDoubleArray::New();
//measurements->SetNumberOfComponents(1);
measurements->SetNumberOfValues(numberOfGridpoints);
measurements->SetName(name);
for (int i = 0; i < numberOfGridpoints; i++) {
double temp = static_cast<double>(measurementArray[i][t]);
cout << "temp: " << temp << endl;
measurements->SetValue(i, temp);
double check = measurements->GetValue(i);
cout << "check: " << check << endl;
}
meshPolyData->GetPointData()->AddArray(measurements);
Best regards (from Germany).
On Mon, Jan 13, 2014 at 11:26 AM, Susanne Schmalkalt <
Susanne.Schmalkalt at gmx.de> wrote:
> Hallo everybody,
>
> I have a question regarding vtkDoubleArray.
>
> I want to save doubles in an array which I then add to a PolyDataObject.
> But when I add the variable and then call it again, the correct value
> dissapears.
> Does someone have an idea why? what am I doing wrong?
>
>
> Instantiate(measurements,vtkDoubleArray);
> measurements->SetNumberOfComponents(1);
> measurements->SetNumberOfTuples(numberOfGridpoints);
> measurements->SetName(name);
> for(int i = 0; i < numberOfGridpoints; i++){
> double temp[1];
> temp[0] = static_cast<double>(measurementArray[i][t]);
> cout << " temp: " << temp[0];
> measurements->InsertNextTupleValue(temp);
> vtkIdType id = (vtkIdType)i;
> double check[1];
> measurements->GetTupleValue(id,check);
> cout << " check: " << check[0];
> }
> meshPolyData->GetPointData()->AddArray(measurements);
>
> Thank you for your help!
> Susi
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140113/f812ecbd/attachment.html>
More information about the vtkusers
mailing list