[vtkusers] Get/Set values Vector Data

Chiranjib Sur sur.chiranjib at gmail.com
Wed Mar 18 07:55:51 EDT 2015


HI Allen,
Thanks for the pointer. I am having some issues with this. before
explaining the issues let me state the problem I am trying to solve in bit
more dtails.

I have a poly data which corresponds to to different set, i.e. the combined
poly data I am dealing with correspond to two different section of the
geometrical object. And I know the offset of the data set which
differentiates object A from Object B from the polydata.

Now when I am trying to set value like velocity with 3 component, I am
facing the issues. Although I do the following, the properties are getting
assigned randomly. Here is the snippet of my code :


vtkSmartPointer<vtkDoubleArray> velocity =
vtkSmartPointer<vtkDoubleArray>::New();
velocity->SetName ("Velocity");
velocity->SetNumberOfComponents(3);

velocity->SetNumberOfTuples( polydata->GetNumberOfPoints());

polydata->GetPointData()->AddArray( velocity );

   for (long long i = offset; i < polydata->GetNumberOfPoints(); ++i)
 // offset determines the position of the polydata I want to start with
instead of starting at == 0)
   {
   velocity->SetTuple3( i,  _Vx, _Vy, _Vz );            //_Vx,_Vy,_Vz are
double and declared elsewhere
   //      velocity->InsertNextTuple3(  _Vx, _Vy, _Vz );       // Instead
of using SetTuple3, I can use InsertNextTuple3 or InsertTuple3 too.
   }


Am I doing anything wrong here ?

Thanks much,
Chiranjib

On Tue, Mar 17, 2015 at 6:55 PM, Allen Sanderson <allen at sci.utah.edu> wrote:

> Here is some sample code:
>
> vtkDoubleArray *velocityArray = vtkDoubleArray::New();
> velocityArray->SetName(var.c_str());
> // NOTE: you want to set the number of components BEFORE setting the
> number of Tuples so memory is correctly allocated.
>
> velocityArray->SetNumberOfComponents(3);
> velocityArray->SetNumberOfTuples(nTuples);
>
> polydata->GetPointData()->AddArray(velocityArray);
>
> double dx, dy, dz;
>
> Loop: velocityArray->SetTuple3(index, dx, dy, dz);
> Where : 0<= index < nTuples
>
> velocityArray->Delete();
>
>
> The get would be:
>
> double *velocity = velocityArray->GetTuple3(l);
>
>
> Cheers,
>
>
> Allen
>
>
>
> Allen Sanderson
>
> SCI Institute
>
> University of Utah
>
> www.sci.utah.edu
>
>
>
> On Mar 17, 2015, at 1:03 PM, Chiranjib Sur <sur.chiranjib at gmail.com>
> wrote:
>
> Hi All,
> I want to assign values (3 component vector) to all in a polydata set.
> I found the email thread where the solution for a one component scalar
> data is explained (
> http://vtk.1045678.n5.nabble.com/Get-Set-values-in-scalar-data-td3259506.html
> )
>
> Anybody can help explaining how to do this for a 3-component vector data
> type.
>
> Thanks in advance.
>
> Chiranjib Sur
> _______________________________________________
> 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 VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150318/a2ce0b86/attachment.html>


More information about the vtkusers mailing list