<HTML>
<HEAD>
<TITLE>Re: [vtkusers] Arithmetic on point data arrays</TITLE>
</HEAD>
<BODY>
<FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>Hi Adam,<BR>
The way you are trying to use the arraycalculator is incorrect. One example of how to use it would be to create a new array in a single dataset from adding to existing arrays from the same data set.<BR>
Take a look at the example here:<BR>
<a href="http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/Examples/DataManipulation/Python/FinancialField.py?root=VTK&content-type=text/plain">http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/Examples/DataManipulation/Python/FinancialField.py?root=VTK&content-type=text/plain</a><BR>
<BR>
If I understand what you are trying to do you could create one structured grid and then just add the arrays from each of the files as a different scalar/point data array(pt_view_01,pt_view_02...etc).<BR>
Then you could contour based on the selected array.<BR>
If you did want to use the array calculator you could then take this single dataset and sum the arrays as you described.<BR>
<BR>
<BR>
HTH<BR>
Gerrick<BR>
<BR>
<BR>
On 6/17/09 7:51 AM, "Adam Davis" <<a href="addavis@FosterandPartners.com">addavis@FosterandPartners.com</a>> wrote:<BR>
<BR>
</SPAN></FONT><BLOCKQUOTE><SPAN STYLE='font-size:11pt'><FONT FACE="Arial">I have a number of data sets obtained from structured points files, all of which are equal in dimension. I would like to create a single data set for isosurface visualization that represents the sum of these individual sets, with the ability to weight each individual set by a certain factor in the resultant output. I wish to do this within vtk because I would like to interactively change the weighting (using sliders) and see the results.<BR>
</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"><BR>
</FONT><FONT FACE="Arial">Am I correct that I should be using vtkArrayCalculator to do the summing?</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
<BR>
</FONT><FONT FACE="Arial">If this is correct, would I call SetInput and AddScalarArrayName iteratively for each of my source data sets?</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
<BR>
</FONT><FONT FACE="Arial">To be more specific about what I am currently trying to do:</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
<BR>
</FONT><FONT FACE="Arial">Here's a sample header from one of my stuctured points files:</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
<BR>
</FONT><FONT FACE="Arial"># vtk DataFile Version 2.0</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
</FONT><FONT FACE="Arial">Point Data for Analysis</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
</FONT><FONT FACE="Arial">ASCII</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
</FONT><FONT FACE="Arial">DATASET STRUCTURED_POINTS</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
</FONT><FONT FACE="Arial">DIMENSIONS 31 35 65</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
</FONT><FONT FACE="Arial">ORIGIN 0 0 0</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
</FONT><FONT FACE="Arial">SPACING 6 6 4</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
</FONT><FONT FACE="Arial">POINT_DATA 70525</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
</FONT><FONT FACE="Arial">SCALARS pt_view short 1</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
</FONT><FONT FACE="Arial">LOOKUP_TABLE Default</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
<BR>
</FONT><FONT FACE="Arial">In a tcl file, I am trying to get the data into the array calculator as follows:</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
<BR>
</FONT><FONT FACE="Arial">-----</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
</FONT><FONT FACE="Courier, Courier New">vtkStructuredPointsReader reader1</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
</FONT><FONT FACE="Courier, Courier New">reader1 SetFileName "c:\\sp.vtk"</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
</FONT><FONT FACE="Courier, Courier New">reader1 Update</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
<BR>
</FONT><FONT FACE="Courier, Courier New">set pt [[[reader1 GetOutput] GetPointData] GetArray "pt_view"]</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
<BR>
</FONT><FONT FACE="Courier, Courier New">vtkArrayCalculator calc</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
</FONT><FONT FACE="Courier, Courier New">calc SetAttributeModeToUsePointData</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
</FONT><FONT FACE="Courier, Courier New">calc SetInput [reader1 GetOutput]</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
</FONT><FONT FACE="Courier, Courier New">calc AddScalarArrayName $pt 0</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
</FONT><FONT FACE="Arial">-----</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
<BR>
</FONT><FONT FACE="Arial">vtkArrayCalculator throws an error:</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
</FONT><FONT FACE="Arial">Invalid array name: vtkTemp2</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
<BR>
</FONT><FONT FACE="Arial">Can someone please advise:</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
<BR>
</FONT><FONT FACE="Arial">1. Whether vtkArrayCalculator is the proper way to do the summing?</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
</FONT><FONT FACE="Arial">2. If so, why the above isn't working?</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
<BR>
</FONT><FONT FACE="Arial">Thank you.</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
<BR>
</FONT><FONT FACE="Arial">-Adam Davis</FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"> <BR>
<BR>
<HR ALIGN=CENTER SIZE="3" WIDTH="95%"></FONT></SPAN><FONT SIZE="2"><FONT FACE="Consolas, Courier New, Courier"><SPAN STYLE='font-size:10pt'>_______________________________________________<BR>
Powered by www.kitware.com<BR>
<BR>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><BR>
<BR>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a><BR>
<BR>
Follow this link to subscribe/unsubscribe:<BR>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><BR>
</SPAN></FONT></FONT></BLOCKQUOTE>
</BODY>
</HTML>