<div dir="ltr"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 19, 2016 at 5:02 PM, Grant Mc Auley <span dir="ltr"><<a href="mailto:gamcauley@gmail.com" target="_blank">gamcauley@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"><div><br></div>I have a vti file that contains several PointData arrays containing 3-tuples.  Many of the 3-tuples contain all zeros and, after reading in the file I remove them, essentially like:<div><br></div><div><div><span style="white-space:pre-wrap">             </span>xmlreader = vtk.vtkXMLImageDataReader()</div><div><span style="white-space:pre-wrap">          </span>xmlreader.SetFileName(self.__<wbr>filename)</div><div><span style="white-space:pre-wrap">                </span>xmlreader.Update()</div><div>                <span style="white-space:pre-wrap">image_data = xmlreader.GetOutput()</span></div><div><span style="white-space:pre-wrap">             image_point_data = image_data.GetPointData()</span><br></div><div>                ...</div><div>                if math.sqrt(x_ ** 2 + y_ ** 2 + z_ ** 2) == 0.0:               </div><div>                    image_point_data.RemoveArray(<wbr>index)</div><div><br></div><div>Now, I want to write out a new file with the cleaned-up arrays using:</div><div><div><br></div><div><span style="white-space:pre-wrap">             </span>xml_image_writer = vtk.vtkXMLImageDataWriter()</div><div><span style="white-space:pre-wrap">           </span>xml_image_writer.SetFileName(<wbr>filename)</div><div><span style="white-space:pre-wrap">                </span>xml_image_writer.<wbr>SetDataModeToBinary()</div><div><br></div><div><span style="white-space:pre-wrap">               </span># self.__image_data.<wbr>SetDimensions(51905, 1, 1)</div><div><span style="white-space:pre-wrap">                </span>xml_image_writer.SetInputData(<wbr>self.__image_data)</div><div><span style="white-space:pre-wrap">              </span>xml_image_writer.Write()</div><div><br></div></div><div><br></div><div>However, there are at least two issue I am not sure how to handle:</div><div>[program output]</div><div><div>Number of points: 266688</div><div>ERROR: In /build/buildd/vtk6-6.1.0+dfsg/<wbr>Common/DataModel/vtkDataSet.<wbr>cxx, line 414</div><div>vtkImageData (0x1632f50): Point array array_1 with 3 components, only has 51905 tuples but there are 266688 points</div></div><div>[/program output]<br></div><div><br></div><div>1) The number of 3-tuples no longer matches the number of points in the image data structure, and ...</div></div><div><br></div><div>2) Even if I try to remedy this by putting the correct number in getDimensions() above, it will still not be correct for the other arrays since in the number of 'zero tuples' removed from each is in general different</div><div><br></div><div>Finally, I will need to combine the contents of point arrays of the same name in multiple files by appending the data from each file into one.  Something like:</div><div><br></div><div><VTKFile type="ImageData">></div><div>   <ImageData WholeExtent="0 ? 0 0 0 0" Origin="0 0 0" Spacing="1 1 1"></div><div>      <Piece Extent="0 ? 0 0 0 0"></div><div>         <PointData></div><div>            <DataArray type="Float64" Name="array1" NumberOfComponents="3"          RangeMin="0.1" RangeMax="100"><br></div><div>1 2 3 4 5 6 7 8 9 10 11 12</div><div>            </DataArray></div><div><div>            <DataArray type="Float64" Name="array2" NumberOfComponents="3"          RangeMin="0.1" RangeMax="100"><br></div><div>50 100 150 200</div><div>            </DataArray></div></div><div>                 ...</div><div>AND</div><div><br></div><div><div><VTKFile type="ImageData">></div><div>   <ImageData WholeExtent="0 ? 0 0 0 0" Origin="0 0 0" Spacing="1 1 1"></div><div>      <Piece Extent="0 ? 0 0 0 0"></div><div>         <PointData></div><div>            <DataArray type="Float64" Name="array1" NumberOfComponents="3"          RangeMin="0.1" RangeMax="100"><br></div><div>13 14 15 16 17 18 19 20 21</div><div>            </DataArray></div><div><div><div>            <DataArray type="Float64" Name="array2" NumberOfComponents="3"          RangeMin="0.1" RangeMax="100"><br></div><div>250 300 350</div><div>            </DataArray></div></div><div>                 ...</div></div><div>                 ...</div></div><div><br></div><div>COMBINED INTO:</div><div><br></div><div><div><VTKFile type="ImageData">></div><div>   <ImageData WholeExtent="0 ? 0 0 0 0" Origin="0 0 0" Spacing="1 1 1"></div><div>      <Piece Extent="0 ? 0 0 0 0"></div><div>         <PointData></div><div>            <DataArray type="Float64" Name="array1" NumberOfComponents="3"          RangeMin="0.1" RangeMax="100"><br></div><div>1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21</div><div>            </DataArray></div><div><div>            <DataArray type="Float64" Name="array2" NumberOfComponents="3"          RangeMin="0.1" RangeMax="100"><br></div><div>50 100 150 200 250 300 350</div><div>            </DataArray></div></div><div>                 ...</div></div><div><br></div><div>Any guidance/suggestions/info/<wbr>corrections would be much appreciated.</div><div><br></div></div>
</blockquote></div><br></div><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr">Grant McAuley, PhD<div>Assistant Professor</div><div>Radiation Medicine</div><div>Loma Linda University</div><div>(909) 558-8082 Ext 88082</div><div><a href="mailto:gmcauley@llu.edu" target="_blank">gmcauley@llu.edu</a></div></div></div></div></div>