[vtkusers] Get/Set values Vector Data
Chiranjib Sur
sur.chiranjib at gmail.com
Thu Mar 19 07:54:28 EDT 2015
Hi Allen,
I restructured the point data part of my algorithm and thins are working as
expected. Thanks for your suggestions.
Thanks,
Chiranjib
On Wed, Mar 18, 2015 at 11:07 PM, Chiranjib Sur <sur.chiranjib at gmail.com>
wrote:
> Hi Allen,
> Thanks for your reply. I now understand the philosophy behind the insert
> tuple thing.
> One the other hand, to reply your questions (if I understood it
> correctly), I can do the get/set operation with scalars (single component)
> easily and correctly, which means my polydata points are created properly.
> What exactly you mean by "down stream".
>
> I am new to this field and may be I am missing the terminologies. To
> reiterate, my problem is to assign same vector properties to my poly points
> but with different values (separated by offset).
>
> Thanks again in advance for your help.
>
> Chiranjib
>
> On Wed, Mar 18, 2015 at 9:49 PM, Allen Sanderson <allen at sci.utah.edu>
> wrote:
>
>> You do not need to do an insert next tuple as memory has already been
>> allocated with the call to SetNumberOfTuples.
>>
>> Right off I do see anything wrong with your approach. I would check the
>> obvious does your polydata have points?? What happens to it down stream??
>>
>>
>> Cheers,
>>
>> Allen
>>
>>
>>
>>
>> On Mar 18, 2015, at 12:55 PM, Chiranjib Sur <sur.chiranjib at gmail.com>
>> wrote:
>>
>> 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
>>>
>>>
>>>
>> _______________________________________________
>> 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/20150319/317d4057/attachment.html>
More information about the vtkusers
mailing list