[Paraview] vtkDoubleArray with >3 components

Berk Geveci berk.geveci at kitware.com
Wed Jul 22 09:44:33 EDT 2015


Actually, don't call SetNumberOfTuples() at all if you are using
SetArray(). It will unnecessarily allocate memory if you call it before
SetArray().

-berk

On Wed, Jul 22, 2015 at 9:40 AM, Shawn Waldon <shawn.waldon at kitware.com>
wrote:

> Hi Bruce,
>
> SetNumberOfTuples reallocates the internal datastructure of the data array
> to be the new required size based on the new number of components and
> number of tuples.  This (combined with trying to clean up the old data from
> SetArray) may be causing the heap corruption you are seeing.  Try setting
> the number of components and number of tuples before adding the data to the
> array.
>
> HTH,
> Shawn
>
> On Tue, Jul 21, 2015 at 1:37 PM, Bruce Jones <bruce.david.jones at gmail.com>
> wrote:
>
>> Hi Cory,
>>
>> Sorry for the delayed response, I've hit another more serious bug which
>> has been diverting my attention from this.
>>
>> Thanks for the state file, I haven't got it to work as I don't have numpy
>> set up, but I have also got this working with 9 component arrays in
>> paraview using a python script. However, I am now trying to port my python
>> plugin to c++ which is where I am seeing the error.
>>
>> In my plugin I want to output a vtkarray for each vtkarray in the input
>> dataset. The values in the output vtkarrays are interpolated from those in
>> the input vtkarrays. Rather than working directly on vtkarray objects, I am
>> allocating c++ arrays for each vtkarray, performing the interpolation, then
>> creating vtkDoubleArrays and using SetArray to pass a pointer to my
>> allocated c++ arrays to the output vtkarrays. The code for setting up the
>> output vtkarrays is roughly as follows
>>
>>                 vtkPointData *pointData = input->GetPointData();
>>                 vtkDataArray *dArray = pointData->GetArray(i);
>> vtkDoubleArray *vtkDArrayAve = vtkDoubleArray::New();
>> vtkDArrayAve->SetName(dArray->GetName());
>> vtkDArrayAve->SetArray(dArraysAve[i],hgrid->GetTotalCells(),0);
>> vtkDArrayAve->SetNumberOfComponents(numComponents[i]);
>> vtkDArrayAve->SetNumberOfTuples(hgrid->GetTotalCells());
>> output->GetPointData()->AddArray(vtkDArrayAve);
>>
>> dArraysAve is an array of pointers pointing to my c++ arrays
>> hgrid->GetTotalCells() returns the number of data points for my output
>>
>> I also have another mode of operation for this plugin, where I perform
>> the interpolation differently, in that function, if I make the call to
>> SetNumberOfComponents() some heap corruption occurs and I get a segfault
>> when I try to subsequently free my c++ arrays. Commenting out the call to
>> SetNumberOfComponents avoids the segfault, but then I am limited to single
>> component arrays. This is the more serious bug I mentioned, initially I
>> figured they were unrelated, but I can't deny the number of components
>> coincidence.
>>
>> Cheers,
>> Bruce
>>
>> On Thu, 16 Jul 2015 at 14:41 Cory Quammen <cory.quammen at kitware.com>
>> wrote:
>>
>>> Hi Bruce,
>>>
>>> I have attached a ParaView state file with a Programmable Source that
>>> produces a vtkPolyData with 100 random points and a point data array with 9
>>> components. It seems to display the various component ranges just fine.
>>>
>>> Best,
>>> Cory
>>>
>>> On Thu, Jul 16, 2015 at 11:14 AM, Cory Quammen <cory.quammen at kitware.com
>>> > wrote:
>>>
>>>> Hi Bruce,
>>>>
>>>> I haven't seen this, but ParaView may be interpreting this array as a
>>>> tensor field. Do you have a smallish test data file that you can share that
>>>> shows the problem?
>>>>
>>>> Thanks,
>>>> Cory
>>>>
>>>> On Sat, Jul 11, 2015 at 11:14 AM, Bruce Jones <
>>>> bruce.david.jones at gmail.com> wrote:
>>>>
>>>>> I am creating vtkDoubleArrays based on averaging some input data to a
>>>>> reduced set of points. The input data includes various vtk arrays which
>>>>> have 1, 3 and 9 components.
>>>>>
>>>>> After averaging, I am writing the data to c++ arrays, and creating a
>>>>> new vtkDoubleArray using the SetArray() function to pass the c++ arrays.
>>>>> This works fine for 1 and 3 component arrays, however for the 9 component
>>>>> arrays paraview shows that every element is set to 0.
>>>>>
>>>>> If I hardcode it so that 9 component arrays become 3 component arrays
>>>>> (reading only the first 3 components from the input array), then I get the
>>>>> correct data for the first 3 components, though I obviously need the other
>>>>> 6 components in the end.
>>>>>
>>>>> Has anyone encountered this before?
>>>>>
>>>>> Cheers,
>>>>> Bruce
>>>>>
>>>>> _______________________________________________
>>>>> 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 ParaView Wiki at:
>>>>> http://paraview.org/Wiki/ParaView
>>>>>
>>>>> Search the list archives at: http://markmail.org/search/?q=ParaView
>>>>>
>>>>> Follow this link to subscribe/unsubscribe:
>>>>> http://public.kitware.com/mailman/listinfo/paraview
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Cory Quammen
>>>> R&D Engineer
>>>> Kitware, Inc.
>>>>
>>>
>>>
>>>
>>> --
>>> Cory Quammen
>>> R&D Engineer
>>> Kitware, Inc.
>>>
>>
>> _______________________________________________
>> 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 ParaView Wiki at:
>> http://paraview.org/Wiki/ParaView
>>
>> Search the list archives at: http://markmail.org/search/?q=ParaView
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/paraview
>>
>>
>
> _______________________________________________
> 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 ParaView Wiki at:
> http://paraview.org/Wiki/ParaView
>
> Search the list archives at: http://markmail.org/search/?q=ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/paraview
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20150722/b12385b7/attachment.html>


More information about the ParaView mailing list