<div dir="ltr">Thanks Berk,<div><br></div><div>I have tried with both zero and 1 as the save argument and am getting the same behavior. As before, if I comment the SetNumberOfComponents call (or set number of components to 1) everything works, except I only have single component arrays in the output.</div><div><br></div><div>I'm going to put together a minimum working example with the issue this afternoon so that I can show you guys in more detail.</div><div><br></div><div>Cheers,</div><div>Bruce</div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, 22 Jul 2015 at 11:09 Berk Geveci <<a href="mailto:berk.geveci@kitware.com">berk.geveci@kitware.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">The solution is in the documentation:<div><br></div><div><div> // This method lets the user specify data to be held by the array. The</div><div> // array argument is a pointer to the data. size is the size of the</div><div> // array supplied by the user. Set save to 1 to keep the class from</div><div> // deleting the array when it cleans up or reallocates memory. The class</div><div> // uses the actual array provided; it does not copy the data from the</div><div> // suppled array. If specified, the delete method determines how the data</div><div> // array will be deallocated. If the delete method is</div><div> // VTK_DATA_ARRAY_FREE, free() will be used. If the delete method is</div><div> // DELETE, delete[] will be used. The default is FREE.</div></div><div><br></div><div>You are passing 0 for the "save" argument, which means that VTK will delete the array when the VTK array object is deleted, which would cause a double delete/free. Use 1 as the second argument of SetArray() if you are managing the memory. Also, make sure that the VTK array is not used after you free your array.</div><div><br></div><div>Best,</div><div>-berk</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 22, 2015 at 9:56 AM, Bruce Jones <span dir="ltr"><<a href="mailto:bruce.david.jones@gmail.com" target="_blank">bruce.david.jones@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Guys,<div><br></div><div>I have just tried it as you suggested, doing SetNumberOfComponents then SetArray, without doing SetNumberOfTuples. Unfortunately I am still getting the same behaviour.</div><div><br></div><div>Cheers,</div><div>Bruce</div></div><div><div><br><div class="gmail_quote"><div dir="ltr">On Wed, 22 Jul 2015 at 09:44 Berk Geveci <<a href="mailto:berk.geveci@kitware.com" target="_blank">berk.geveci@kitware.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Actually, don't call SetNumberOfTuples() at all if you are using SetArray(). It will unnecessarily allocate memory if you call it before SetArray().</div><div dir="ltr"><div><br></div><div>-berk</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 22, 2015 at 9:40 AM, Shawn Waldon <span dir="ltr"><<a href="mailto:shawn.waldon@kitware.com" target="_blank">shawn.waldon@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>Hi Bruce,<br><br></div>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.<br><br></div>HTH,<br></div>Shawn<br></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 21, 2015 at 1:37 PM, Bruce Jones <span dir="ltr"><<a href="mailto:bruce.david.jones@gmail.com" target="_blank">bruce.david.jones@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Cory,<div><br></div><div>Sorry for the delayed response, I've hit another more serious bug which has been diverting my attention from this.</div><div><br></div><div>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.</div><div><br></div><div>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</div><div> </div><div> vtkPointData *pointData = input->GetPointData();</div><div> vtkDataArray *dArray = pointData->GetArray(i);<br></div><div><div><span style="white-space:pre-wrap"> </span>vtkDoubleArray *vtkDArrayAve = vtkDoubleArray::New();</div><div><span style="white-space:pre-wrap"> </span>vtkDArrayAve->SetName(dArray->GetName());</div><div><span style="white-space:pre-wrap"> </span>vtkDArrayAve->SetArray(dArraysAve[i],hgrid->GetTotalCells(),0);</div><div><span style="white-space:pre-wrap"> </span>vtkDArrayAve->SetNumberOfComponents(numComponents[i]);</div><div><span style="white-space:pre-wrap"> </span>vtkDArrayAve->SetNumberOfTuples(hgrid->GetTotalCells());</div><div><span style="white-space:pre-wrap"> </span>output->GetPointData()->AddArray(vtkDArrayAve);</div></div><div><br></div><div>dArraysAve is an array of pointers pointing to my c++ arrays</div><div>hgrid->GetTotalCells() returns the number of data points for my output</div><div><br></div><div>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.</div><div><br></div><div>Cheers,</div><div>Bruce</div></div><div><div><br><div class="gmail_quote"><div dir="ltr">On Thu, 16 Jul 2015 at 14:41 Cory Quammen <<a href="mailto:cory.quammen@kitware.com" target="_blank">cory.quammen@kitware.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Bruce,<div><br></div><div>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.</div><div><br></div><div>Best,</div><div>Cory</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jul 16, 2015 at 11:14 AM, Cory Quammen <span dir="ltr"><<a href="mailto:cory.quammen@kitware.com" target="_blank">cory.quammen@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Bruce,<div><br></div><div>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?</div><div><br></div><div>Thanks,</div><div>Cory</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Sat, Jul 11, 2015 at 11:14 AM, Bruce Jones <span dir="ltr"><<a href="mailto:bruce.david.jones@gmail.com" target="_blank">bruce.david.jones@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr">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.<div><br></div><div>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.</div><div><br></div><div>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.</div><div><br></div><div>Has anyone encountered this before?</div><div><br></div><div>Cheers,</div><div>Bruce</div></div>
<br></div></div>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the ParaView Wiki at: <a href="http://paraview.org/Wiki/ParaView" rel="noreferrer" target="_blank">http://paraview.org/Wiki/ParaView</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=ParaView" rel="noreferrer" target="_blank">http://markmail.org/search/?q=ParaView</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/paraview" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/paraview</a><br>
<br></blockquote></div><span><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div>Cory Quammen<br>R&D Engineer<br>Kitware, Inc.</div>
</font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Cory Quammen<br>R&D Engineer<br>Kitware, Inc.</div>
</div>
</blockquote></div>
</div></div><br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the ParaView Wiki at: <a href="http://paraview.org/Wiki/ParaView" rel="noreferrer" target="_blank">http://paraview.org/Wiki/ParaView</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=ParaView" rel="noreferrer" target="_blank">http://markmail.org/search/?q=ParaView</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/paraview" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/paraview</a><br>
<br></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the ParaView Wiki at: <a href="http://paraview.org/Wiki/ParaView" rel="noreferrer" target="_blank">http://paraview.org/Wiki/ParaView</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=ParaView" rel="noreferrer" target="_blank">http://markmail.org/search/?q=ParaView</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/paraview" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/paraview</a><br>
<br></blockquote></div><br></div>
</blockquote></div>
</div></div></blockquote></div><br></div>
</blockquote></div>