<div dir="ltr">Hello David,<br><br>Thank you. That code works when modified for what I'm trying to do. And you cleared up my confusion on the ExodusIIReader.<br><br>Mark<br></div><div class="gmail_extra"><br clear="all">
<div><br>Mark Messner<br>Ph.D. Candidate<br>Department of Civil and Environmental Engineering<br>University of Illinois at Urbana-Champaign</div>
<br><br><div class="gmail_quote">On Mon, Mar 4, 2013 at 8:40 PM, David Thompson <span dir="ltr"><<a href="mailto:david.thompson@kitware.com" target="_blank">david.thompson@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Mark,<br>
<br>
> I'm trying to use a programmable filter to apply colors to an ExodusII data set. ... From that what I assume I have to do is create a vtkUnsignedCharArray with length equal to the number of cells in the model, assign my colors, and then display.<br>
<br>
Yes, you are correct.<br>
<div class="im"><br>
> 1) I understand the ExodusIIReader is, well, a reader -- it will generate the data blocks, it's not actually representing the data.<br>
<br>
</div>I'm not sure what you mean by "not actually representing the data." It *does* represent the data, segregated into a series of blocks (which is how it is stored on disk). The blocks are arranged into a 2-level hierarchy. The first level determines what the blocks represent (elements, faces, edges, or subsets thereof). The second level contains the actual data.<br>
<div class="im"><br>
> But I don't get how to access at the generated data. Say I have a single block of elements called 'hexes' with cell data 'stresses', how do I access that cell data in the programmable filter?<br>
<br>
</div>I've put a script below that colors the first element block in the can.ex2 dataset (available from the ParaViewData git repo: <a href="http://www.paraview.org/gitweb?p=ParaViewData.git;a=blob;f=Data/can.ex2;hb=HEAD" target="_blank">http://www.paraview.org/gitweb?p=ParaViewData.git;a=blob;f=Data/can.ex2;hb=HEAD</a> ). It shows how you can add a color array to one block (in the example below, ids.GetBlock(0).GetBlock(0) is the first "leaf" node of the tree containing the Exodus data). In reality, you probably want to loop over all leaf nodes in the dataset. You can use GetNumberOfBlocks() to set up a loop that calls GetBlock with each valid index.<br>
<br>
David<br>
<br>
ids = self.GetInput()<br>
ods = self.GetOutput()<br>
<br>
ods.ShallowCopy(ids)<br>
<br>
cellData = ids.GetBlock(0).GetBlock(0).GetCellData()<br>
eqps = cellData.GetArray('EQPS')<br>
nt = eqps.GetNumberOfTuples()<br>
<br>
color = vtk.vtkUnsignedCharArray()<br>
color.SetName('Color')<br>
color.SetNumberOfComponents(3)<br>
color.SetNumberOfTuples(nt)<br>
for i in range(nt):<br>
ival = eqps.GetTuple1(i)<br>
red = 255.0 * ival<br>
green = 255.0 * (1 - ival)<br>
blue= 255.0<br>
color.SetTuple3(i, red, green, blue)<br>
<br>
cellData.SetScalars(color)</blockquote></div><br></div>