Felipe,
The Calculator filter has no support for field data currently, see e.g.
http://www.paraview.org/Bug/view.php?id=5626. Neither it is the only
filter that does not pass field data, see e.g.
http://www.paraview.org/Bug/view.php?id=10787.
For operations involving field data, like plotting field data over time
or some trivial calculations, I resort to the Programmable Filter.
Here's an example pipeline that first adds a source, then adds some
vector point data to operate on and a single scalar value as field data
to eventually scale an input (point data) data array (stored in the
first non-multi-block leaf of a multi-block dataset) by (the first
component of) the first tuple of a given name data array stored as field
data and add the result as a new data array.
Sources - Wavelet - Apply
Filters - Programmable Filter -
Script: see add.scalarValue.as.fieldData.py - Apply
Filters - Random Vectors - Apply
Filters - Programmable Filter -
Script: see scale.pointData.by.fieldDataValue.py - Apply
It should get you started. Changing the script to work on cell data or
with a different input data array/field data tuple is straightforward.
Sven
Felipe Bordeu wrote, On 07.10.2011 19:15:
> Hello everybody,
>
> I have a custom reader, and I generate cells and points data correctly.
> Now I am trying to put global data (like material propeties) in a
> vtkFieldData using
>
> ouput->SetFieldData(my_vtkfielddata);
>
> This work properly and I can see the information in the information tab
> (variable Y).
>
>
> But the problem is I am unable to access this information in paraview, I
> cant use the variable in the calculator, and if apply the calculator
> filter the global fields are not passed to the output.
>
> How can I access this kind of information in the calculator??
>
> I am using the 3.12.0-RC2 from git in linux, and a custom reader in c++.
>
>
> --
>
> Felipe Bordeu Weldt
> Ingénieur de Recherche
> -------------------------------------
> Tél. : 33 (0)2 40 37 16 57
> Fax. : 33 (0)2 40 74 74 06
> [email protected]
> Institut GeM - UMR CNRS 6183
> École Centrale Nantes
> 1 Rue de La Noë, 44321 Nantes, FRANCE
> -------------------------------------
inp = self.GetInput();
out = self.GetOutput();
out.ShallowCopy(inp);
scalarFieldDataValue = 0.1
scalarFieldDataName = "foo"
ref = out
if not ref is None:
value = vtk.vtkFloatArray();
value.SetName(scalarFieldDataName);
value.SetNumberOfComponents(1);
value.InsertNextValue(scalarFieldDataValue);
ref.GetFieldData().AddArray(value);
inp = self.GetInput();
out = self.GetOutput();
out.ShallowCopy(inp);
pdArrayToScale = "BrownianVectors";
fieldData = "foo";
scaledPDArrayName = "scaled";
ref = out
while not ref is None and ref.GetClassName() == 'vtkMultiBlockDataSet':
if not ref.GetBlock(0) is None:
ref = ref.GetBlock(0);
if not ref is None:
if not ref.GetPointData() is None and not ref.GetFieldData() is None:
inpArray = ref.GetPointData().GetArray(pdArrayToScale)
factor = ref.GetFieldData().GetArray(fieldData)
if not inpArray is None and not factor is None:
newPD = vtk.vtkFloatArray();
newPD.SetName(scaledPDArrayName);
newPD.SetNumberOfComponents(inpArray.GetNumberOfComponents());
for i in xrange(0, ref.GetNumberOfPoints() *
inpArray.GetNumberOfComponents()):
value = inpArray.GetValue(i) * factor.GetValue(0);
newPD.InsertNextValue(value);
ref.GetPointData().AddArray(newPD);
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the ParaView Wiki at:
http://paraview.org/Wiki/ParaView
Follow this link to subscribe/unsubscribe:
http://www.paraview.org/mailman/listinfo/paraview