[vtkusers] vtkStringArray and /or vtkIntArray as outputVector

David Gobbi david.gobbi at gmail.com
Tue Nov 25 08:54:52 EST 2014


Hi Orlando,

An array cannot, by itself, be an output.
Instead, the array must be attached to a vtkDataObject.

vtkDataObject *output = outInfo->Get(vtkDataObject::DATA_OBJECT());
vtkSmartPointer<vtkStringArray>  strArr = vtkStringArray::New();
strArray->SetName("Strings"); // set name to whatever you want
output->GetFieldData()->AddArray(strArray);

The "FieldData" of a vtkDataObject is a collection of arrays, you
can add an unlimited number of arrays to it, and then retrieve them
later:

vtkStringArray *a = vtkStringArray::SafeDownCast(
  output->GetFieldData()->GetAbstractArray("Strings"));

You don't need to add any new outputs to the algorithm.  You can just
add the arrays to the FieldData of an output that already exists.

 - David



On Tue, Nov 25, 2014 at 2:23 AM, RIVERA, Orlando <Orlando.RIVERA at mtu.de>
wrote:

>    Dear  Community
>
>
>
> I have been trying for a while  and   I checked some  examples as well
>
>
>
> I just want in a reader by   RequestData    to add two extra output ports
> one for vtkStringArray and one to vtkIntArray  ,
>
>
>
> Something lilke:
>
>
>
> void RequestData(vtkInformation*, vtkInformationVector**,
> vtkInformationVector* outputVector){
>
>   {
>
> ......
>
>          vtkSmartPointer<vtkInformation>   outinfo1=
> outputVector->GetInformationObject(1);
>
>                vtkSmartPointer<vtkStringArray>  strArr=
> vtkStringArray::SafeDownCast(outInfo1->Get(vtkDataObject::DATA_OBJECT()));
>
>               strArr->SetNumberOfValues() ;
>
> ...
>
> }
>
>
>
> I think I need to tell outputVector  somewhere that its second element is
> a vtkStringArray?  I saw all plugins  send vtkPoint, Grids etc   but
> nothing like string-int arrays  .Sorry for my naivety !
>
>
>
> Cheers
>
>
>
> Orlando
>
>
>   --
> *MTU Aero Engines AG*
> Vorstand/Board of Management: Reiner Winkler, Vorsitzender/CEO; Dr. Rainer
> Martens, Michael Schreyögg, Dr. Stefan Weingartner
> Vorsitzender des Aufsichtsrats/Chairman of the Supervisory Board: Klaus
> Eberhardt
> Sitz der Gesellschaft/Registered Office: Muenchen
> Handelsregister/Commercial Register: Muenchen HRB 157206
>
> Diese E-Mail sowie ihre Anhaenge enthalten MTU-eigene vertrauliche oder
> rechtlich geschuetzte Informationen.
> Wenn Sie nicht der beabsichtigte Empfaenger sind, informieren Sie bitte
> den Absender und loeschen Sie diese
> E-Mail sowie die Anhaenge. Das unbefugte Speichern, Kopieren oder
> Weiterleiten ist nicht gestattet.
>
> This e-mail and any attached documents are proprietary to MTU,
> confidential or protected by law.
> If you are not the intended recipient, please advise the sender and delete
> this message and its attachments.
> Any unauthorised storing, copying or distribution is prohibited.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20141125/1bdc84fa/attachment.html>


More information about the vtkusers mailing list