[vtkusers] vtkImageData::SetOrigin didn't take effect
Mathieu Malaterre
mathieu.malaterre at gmail.com
Tue Mar 2 12:08:41 EST 2010
On Tue, Mar 2, 2010 at 5:53 PM, David Doria <daviddoria+vtk at gmail.com> wrote:
> On Tue, Mar 2, 2010 at 7:11 AM, michiel mentink
> <michael.mentink at st-hughs.ox.ac.uk> wrote:
>>
>> try using imgdata->GetOrigin()
>>
>> cheers, Michael
>>
>> On Tue, Mar 2, 2010 at 10:03 AM, 王君臣 <wangjunchen at gmail.com> wrote:
>>>
>>> hi, all
>>>
>>> I just encountered a strange thing that when I set the origin of
>>> vtkImageData, and read it out after the assignment, it turned out that the
>>> value hasn't changed (hold the value before the assignment).
>>>
>>> =====code seg =======
>>>
>>> vtkImageData * imgdata = vNode->GetImageData();
>>> double o[3];
>>> imgdata->GetOrigin(o); // o is [100, 100, 100]
>>> imgdata->SetOrigin(0, 0, 0); // assign origin to [0 0 0]
>>> imgdata->GetOrigin(o);// still [100 100 100]
>>> ====================
>>>
>>> something I have to say is that the mehtod SetOrigin will trigger the
>>> vtkcommand::modifiedevent of the imgdata and in the handler I re-rendered
>>> the widget which contains the actor of the imgdata. imgdata is not connected
>>> to the filter, thus there is no possibility that the filter updated the
>>> imgdata.
>>>
>>> I need for your help, thanks.
>>> --
>>> Best Regards,
>>> WANG Junchen
>
> This seems to behave as expected:
>
> vtkSmartPointer<vtkImageData> imgdata =
> vtkSmartPointer<vtkImageData>::New();
> double o[3];
> imgdata->GetOrigin(o);
> cout << o[0] << " " << o[1] << " " << o[2] << endl;
>
> double newO[3] = {100, 100, 100};
> imgdata->SetOrigin(newO);
>
> double modifiedO[3];
> imgdata->GetOrigin(modifiedO);
> cout << modifiedO[0] << " " << modifiedO[1] << " " << modifiedO[2] <<
> endl;
No. This is just pure luck.
The OP refer to an issue occuring during a pipeline (re)update (AFAIK).
In this case one should use the appropriate class for that:
http://www.vtk.org/doc/nightly/html/classvtkImageChangeInformation.html
HTH
--
Mathieu
More information about the vtkusers
mailing list