[Rtk-users] rtkThreeDCircularProjectionGeometry cannot be cloned

Simon Rit simon.rit at creatis.insa-lyon.fr
Thu Oct 26 16:11:10 EDT 2017


Hi,
I have pushed a fix to a new branch:
https://github.com/SimonRit/RTK/commit/f5249c900a8776dfb3a8a6243a41a2396eb5c134
I'll merge it to master tomorrow if all test pass.
Best regards,
Simon

On Thu, Oct 26, 2017 at 11:14 AM, Fredrik Hellman <fredrik.hellman at gmail.com
> wrote:

> Dear Simon,
>
> No, I can't say I have used the Clone function before. I am writing a
> geometry converter class that takes ThreeDCircularProjectionGeometry
> through a setter-function. The converter is supposed to give detector
> positions etc. on demand in a different coordinate system.
>
> I need to determine what behavior I want of this converter:
>
> 1. Either the converter tracks the ThreeDCircularProjectionGeometry
> object with a smart pointer. All changes in the geometry by the caller so
> the setter is reflected in the converter.
> 2. Or the object is cloned and the converter will reflect the object as it
> was when it was set, regardless of any changes done to it by the caller.
>
> Actually, I think I can do with behavior 1. However, as it is now, I don't
> think I have possibility to implement behavior 2 at all.
>
> Best regards,
> Fredrik
>
> 2017-10-25 18:03 GMT+02:00 Simon Rit <simon.rit at creatis.insa-lyon.fr>:
>
>> Dear Fredrik,
>> Thanks for the report. I actually never use this function. I checked and
>> I have a similar behavior with itk::Image:
>>
>> #include "itkImage.h"
>>
>> int main(int argc, char *argv[])
>> {
>>   typedef float PixelType;
>>   const unsigned int Dimension = 3;
>>   typedef itk::Image< PixelType, Dimension > ImageType;
>>
>>   ImageType::Pointer img = ImageType::New();
>>   ImageType::RegionType reg;
>>   reg.SetSize(0,128);
>>   reg.SetSize(1,128);
>>   reg.SetSize(2,128);
>>   img->SetRegions(reg);
>>   img->Allocate();
>>   img->Print(std::cout);
>>   ImageType::Pointer imgClone = img->Clone();
>>   imgClone->Print(std::cout);
>>   return 0;
>> }
>>
>> The standard output shows that the two images are of the same type but
>> don't contain the same members, e.g., not the same region. It seems that
>> copying an image is done using the Copy function in ImageAlgorithms.
>> If we want to change the behavior for the geometry object, we need to
>> re-implement InternalClone()
>> <https://itk.org/Doxygen/html/classitk_1_1LightObject.html#a2d043fc03a87de736ebdec6214f7e817>.
>> Are you used to use the Clone function in ITK?
>> BTW, I wonder why would one want to do a clone of a geometry but we can
>> probably implement it if it is useful for you.
>> Best regards,
>> Simon
>>
>> On Wed, Oct 25, 2017 at 2:15 PM, Fredrik Hellman <
>> fredrik.hellman at gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I would like to clone a geometry object, but it does not seem to be
>>> possible. Is this the expected behaviour or a bug?
>>>
>>> The code below prints
>>>
>>> 1
>>> 0
>>>
>>> i.e. the two geometry objects (seemingly clones) have different number
>>> of projections.
>>>
>>> Code:
>>>
>>> #include <rtkThreeDCircularProjectionGeometry.h>
>>> #include <iostream>
>>>
>>> int main(int argc, char *argv[])
>>> {
>>>   rtk::ThreeDCircularProjectionGeometry::Pointer geometry =
>>> rtk::ThreeDCircularProjectionGeometry::New();
>>>
>>>   double sourceToIsocenterDistance = 1;
>>>   double sourceToDetectorDistance = 1;
>>>   double gantryAngleInDegrees = 0;
>>>   geometry->AddProjection(sourceToIsocenterDistance,
>>>                           sourceToDetectorDistance,
>>>                           gantryAngleInDegrees);
>>>
>>>   rtk::ThreeDCircularProjectionGeometry::Pointer geometryClone =
>>> geometry->Clone();
>>>
>>>   std::cout << geometry->GetGantryAngles().size() << std::endl;
>>>   std::cout << geometryClone->GetGantryAngles().size() << std::endl;
>>>
>>>   return 0;
>>> }
>>>
>>> Best regards,
>>> Fredrik
>>>
>>> _______________________________________________
>>> Rtk-users mailing list
>>> Rtk-users at public.kitware.com
>>> http://public.kitware.com/mailman/listinfo/rtk-users
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/rtk-users/attachments/20171026/f5de5847/attachment.html>


More information about the Rtk-users mailing list