[vtk-developers] Ongoing changes to AttributeData etc
Berk Geveci
berk.geveci at kitware.com
Tue Sep 18 17:02:59 EDT 2001
>The reason behind this was because I was doing this...
>MyFilter::Execute(...)
> FloatArray *f = floatarray::New()....
> ...
> output->GetPointData()->AddArray(f);
> output->GetPointData()->SetScalars(f);
>
>This appears to be wrong and I'm now doing
> output->GetPointData()->AddArray(f);
> output->GetPointData()->SetActiveScalars("FieldStrengthdBuv/m");
>though it'd be much tidier to say this, (shall I add it?)
> output->GetPointData()->SetActiveScalars(f);
There are a few ways of doing this. Here are the most common ones:
pd = output->GetPointData();
1. pd->SetScalars(f); // This adds the array AND makes it the
scalars, note that this method is overloaded
2. int idx =pd->AddArray(f); // This just adds the array and returns
the index in the field data
pd->SetActiveAttribute(idx, vtkDataSetAttributes::SCALARS); //
make that array the scalars
3. pd->AddArray(f); //This just adds the array
pd->SetActiveScalars(f->GetName()); // Use the array name and
make it scalars
As a rule, SetXXX() adds an arrays and flags it as some attribute,
SetActiveXXX() does not add anything,
it just flags.
There are actually other ways of doing this but I made the necessary
methods protected to avoid even more
confusion :-)
>Now I'm wondering, if I fix all my code to use the above instead of
>the SetScalars(f) (which appears to be the wrong thing to do, [but I
>didn't know because nobody told us about the SetActiveScalars
>function!] - is the fix in Appendpolydata to copy the array names
>still required. I have a sneaking suspicion that I put in a fix that
>was only needed to solve a problem that occurred when you set the
>scalars to one of the field arrays, but did it wrong.
As for vtkAppendPolyDataFilter, this is how it should work:
- If an attribute (i.e. an array which represents an attribute)
exists on all inputs, it will be appended,
The name is not used because the arrays might have different names.
- If an array with the same name exists on all inputs, it will be
appended. The new array should have the same name.
If it behaves in any other way, it should be fixed. Please let me know.
-Berk
--
More information about the vtk-developers
mailing list