<div dir="ltr"><div><div><div><div>Hi.<br><br>I've been reading the visualization toolkit book and user's guide, googling a fair bit, and digging through the vtk websites.<br><br></div>I'm not sure how things are meant to connect.  I'm working in python.  I'm trying to build and use a reader.  Many examples seem to assume there's only a single field that can be made active.  But in my case, the reader is where I keep all information, and there is no sense (at least in my mind) of an "active" field, because several may be used at ones (scalar for surface coloring, one vector field for one set of cone glyphs, and another vector field for a different set of cone glyphs, all to be displayed at the same time).<br>
<br></div><div>I create the each field this way (where my_voltages is just a python list that I parsed from a file):<br><br></div><div>  voltage = vtkDoubleArray()<br></div><div>  voltage.SetName('voltage')<br></div>
<div>  voltage.SetNumberOfComponents(1)<br></div><div>  for v in my_voltages:<br></div><div>      voltage.InsertNextValue(v)<br><br></div><div>And I did the same thing for the 3D fields, except using 3 for the number of components.<br>
</div><div></div>Then, I add these fields to my reader (derived from vtkProgrammableSource) this way:<br><br></div><div>  # 1D fields:<br></div>  self.GetPolyDataOutput().GetCellData().AddArray(voltage)<br>  self.GetPolyDataOutput().GetCellData().AddArray(charge)<br>
<br></div>  # 3D fields:<br><div>  self.GetPolyDataOutput().GetCellData().AddArray(current_density_real)<br>  self.GetPolyDataOutput().GetCellData().AddArray(current_density_imag)<br><br></div><div>I'm able to iterate through those and print out the correct values and some of my early scalar visualization with colormaps and such seem to be working.<br>
<br></div><div>So, first question is: does what I have done so far seem reasonable or is there a more vtk-ish way of doing this?<br><br></div><div>Second question is how to connect to the reader.  I'm trying to use it this way:<br>
<br></div><div>    cone = vtkConeSource()<br>    cone.SetRadius(0.1)<br>    cone.SetHeight(0.5)<br>    cone.SetResolution(8)<br><br>    glyph = vtkGlyph3D()<br>    glyph.SetInputConnection( WHAT GOES HERE??? )<br><br>    glyph.SetSourceConnection(self.cone.GetOutputPort())<br>
    glyph.SetScaleModeToDataScalingOff() <br>    glyph.SetScaleFactor(1.0e-3)<br>    glyph.SetVectorModeToUseVector()<br>    glyph.OrientOn()<br><br></div><div>So the "what goes here" is this question.  Because I used a named array, I'd hope for something like:<br>
<br></div><div>   glyph.SetInputConnection(reader.GetOutputPort('current_density_real'))<br><br></div><div>But that doesn't work, and I've seen nothing to suggest that it would.  When I try this as the argument,<br>
</div><div>        <br>    reader.GetPolyDataOutput().GetCellData().GetArray('current_density_real')<br><br></div><div>I get:<br>    TypeError: argument 1: method requires a vtkAlgorithmOutput, a vtkDoubleArray was provided.<br>
<br></div><div>Switching from SetInputConnection() to just SetInput() gives this error instead<br>    TypeError: argument 1: method requires a vtkDataObject, a vtkDoubleArray was provided.<br></div><div><br></div><div>Is this a matter of converting an array to an algorithm output?   It seems (probably quite wrongly) to me that algorithms can produce many different kinds of output, and that a vtkArray would reasonably be one of them.  Or, when using the SetInput(), why wouldn't a vtkArray be a  vtkDataObject?  Of course, the easy answer is "that's not how the inheritance diagrams are drawn", but that doesn't really get me closer to groking the intended grand scheme of things.   I'm not complaining; I'm just confused.<br>
<br></div><div>How to I get the glyph to use the vector data (in the vtkArray) as its input?  (or if that's the wrong way to think about this, then what's the right way?)<br></div><div><br>Many thanks in advance for any help/enlightenment.<br>
<br></div><div>Greg<br></div><div><br></div><div><br></div><div><br></div></div>