[vtkusers] Using String

John Biddiscombe jbiddiscombe at skippingmouse.co.uk
Fri May 10 08:37:06 EDT 2002


I quite often give each datasets a name in a field using chararry...you can
modify this...

(Note that this is years old and may not be as efficient as it could be...)

//--------------------------------------------------------------------------
-
void SetDatasetFieldString(vtkDataSet *dataset, char *StringName, char
*StringData) {
    vtkFieldData *fd = dataset->GetFieldData();
    if (!fd) {
        fd = vtkFieldData::New();
        dataset->SetFieldData(fd);
        fd->Delete();
    }
    //
    vtkCharArray *array = vtkCharArray::New();
    array->Allocate(strlen(StringData)+1);
    strcpy(array->GetPointer(0),StringData);
    //
    array->SetName(StringName);
    fd->AddArray(array);
    //
    array->Delete();
}
//--------------------------------------------------------------------------
-

JB


----- Original Message -----
From: "Giancarlo Amati" <amati at ira.cnr.it>
To: <vtkusers at public.kitware.com>
Sent: Friday, May 10, 2002 11:34 AM
Subject: [vtkusers] Using String


> Hi everybody,
>
> can I attach to every point of my dataset a String of chars? I tryed with
> VtkCharArray but with bad results, i mean that I can associate only a char
> but not a string of chars.
>
> thank you all
> giancarlo
>
> --
> ----------------------------------------
> dott. Giancarlo Amati                  |
> (amati at ira.cnr.it)                     |
>                                        |
> National Research Council              |
> RadioAstronomical Institute            |
> office phone n. +39 051 6399405        |
> via Gobetti 101 - Bologna (Italy)      |
> ----------------------------------------
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
<http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers




More information about the vtkusers mailing list