[Insight-developers] CreateInstance<TransformType> broken again?

Williams, Norman K norman-k-williams at uiowa.edu
Wed Nov 2 10:36:00 EDT 2011


Back in March I ran into a problem with ObjectFactories.  I'll append my
original description of the problem, because it has cropped up again.  In
our BRAINSResample program -- a module that's incorporated in Slicer, some
of our tests started failing after the recent re-organization of the
Transform modules.

The symptom crops up in trying to read Matlab transforms created by ITK3.
As you can see, it's complaining about not being able to create an
instance of AffineTransform_double_3_3 even though directly below it
claims that exactly that transform type has been registered with the
factory:

45: itk::ExceptionObject (0x10240abb0)
45: Location: "void
itk::TransformIOBase::CreateTransform(itk::SmartPointer<itk::TransformBase>
&, const std::string&)"
45: File:
/scratch/kent/BRAINSStandalone/build/ITKv4/Modules/IO/TransformBase/src/itk
TransformIOBase.cxx
45: Line: 58
45: Description: itk::ERROR: MatlabTransformIO(0x102400f90): Could not
create an instance of AffineTransform_double_3_3
45: The usual cause of this error is not registering the transform with
TransformFactory
45: Currently registered Transforms:
45:     "AffineTransform_double_2_2"
45:     "AffineTransform_double_3_3"
45:     "AffineTransform_double_4_4"
45:     "AffineTransform_double_5_5"
45:     "AffineTransform_double_6_6"
45:     "AffineTransform_double_7_7"
45:     "AffineTransform_double_8_8"
45:     "AffineTransform_double_9_9"
45:     "AffineTransform_float_2_2"
45:     "AffineTransform_float_3_3"
45:     "AffineTransform_float_4_4"
45:     "AffineTransform_float_5_5"
45:     "AffineTransform_float_6_6"
45:     "AffineTransform_float_7_7"
45:     "AffineTransform_float_8_8"
45:     "AffineTransform_float_9_9"
45:     "BSplineDeformableTransform_double_2_2"
45:     "BSplineDeformableTransform_double_3_3"
45:     "BSplineDeformableTransform_float_2_2"
45:     "BSplineDeformableTransform_float_3_3"
45:     "BSplineTransform_double_2_2"
45:     "BSplineTransform_double_3_3"
45:     "BSplineTransform_float_2_2"
45:     "BSplineTransform_float_3_3"
45:     "CenteredAffineTransform_double_2_2"
45:     "CenteredAffineTransform_double_3_3"
45:     "CenteredAffineTransform_float_2_2"
45:     "CenteredAffineTransform_float_3_3"
45:     "CenteredEuler3DTransform_double_3_3"
45:     "CenteredEuler3DTransform_float_3_3"
45:     "CenteredRigid2DTransform_double_2_2"
45:     "CenteredRigid2DTransform_float_2_2"
45:     "CenteredSimilarity2DTransform_double_2_2"
45:     "CenteredSimilarity2DTransform_float_2_2"
45:     "CompositeTransform_double_2_2"
45:     "CompositeTransform_double_3_3"
45:     "CompositeTransform_double_4_4"
45:     "CompositeTransform_double_5_5"
45:     "CompositeTransform_double_6_6"
45:     "CompositeTransform_double_7_7"
45:     "CompositeTransform_double_8_8"
45:     "CompositeTransform_double_9_9"
45:     "CompositeTransform_float_2_2"
45:     "CompositeTransform_float_3_3"
45:     "CompositeTransform_float_4_4"
45:     "CompositeTransform_float_5_5"
45:     "CompositeTransform_float_6_6"
45:     "CompositeTransform_float_7_7"
45:     "CompositeTransform_float_8_8"
45:     "CompositeTransform_float_9_9"
45:     "Euler2DTransform_double_2_2"
45:     "Euler2DTransform_float_2_2"
45:     "Euler3DTransform_double_3_3"
45:     "Euler3DTransform_float_3_3"
45:     "FixedCenterOfRotationAffineTransform_double_3_3"
45:     "FixedCenterOfRotationAffineTransform_float_3_3"
45:     "IdentityTransform_double_2_2"
45:     "IdentityTransform_double_3_3"
45:     "IdentityTransform_double_4_4"
45:     "IdentityTransform_double_5_5"
45:     "IdentityTransform_double_6_6"
45:     "IdentityTransform_double_7_7"
45:     "IdentityTransform_double_8_8"
45:     "IdentityTransform_double_9_9"
45:     "IdentityTransform_float_2_2"
45:     "IdentityTransform_float_3_3"
45:     "IdentityTransform_float_4_4"
45:     "IdentityTransform_float_5_5"
45:     "IdentityTransform_float_6_6"
45:     "IdentityTransform_float_7_7"
45:     "IdentityTransform_float_8_8"
45:     "IdentityTransform_float_9_9"
45:     "QuaternionRigidTransform_double_3_3"
45:     "QuaternionRigidTransform_float_3_3"
45:     "Rigid2DTransform_double_2_2"
45:     "Rigid2DTransform_float_2_2"
45:     "Rigid3DPerspectiveTransform_double_3_2"
45:     "Rigid3DPerspectiveTransform_float_3_2"
45:     "Rigid3DTransform_double_3_3"
45:     "Rigid3DTransform_float_3_3"
45:     "ScalableAffineTransform_double_3_3"
45:     "ScalableAffineTransform_float_3_3"
45:     "ScaleLogarithmicTransform_double_3_3"
45:     "ScaleLogarithmicTransform_float_3_3"
45:     "ScaleSkewVersor3DTransform_double_3_3"
45:     "ScaleSkewVersor3DTransform_float_3_3"
45:     "ScaleTransform_double_2_2"
45:     "ScaleTransform_double_3_3"
45:     "ScaleTransform_double_4_4"
45:     "ScaleTransform_float_2_2"
45:     "ScaleTransform_float_3_3"
45:     "ScaleTransform_float_4_4"
45:     "ScaleVersor3DTransform_double_3_3"
45:     "ScaleVersor3DTransform_float_3_3"
45:     "Similarity2DTransform_double_2_2"
45:     "Similarity2DTransform_float_2_2"
45:     "TranslationTransform_double_3_3"
45:     "TranslationTransform_float_3_3"
45:     "VersorRigid3DTransform_double_3_3"
45:     "VersorRigid3DTransform_float_3_3"
45:     "VersorTransform_double_3_3"
45:     "VersorTransform_float_3_3"
45:

My original description of the problem with ObjectFactories:
OK. So I changed ObjectFactoryBase::InitializeFactoryList() thusly:


void
ObjectFactoryBase
::InitializeFactoryList()
{
  CleanUpObjectFactoryGlobal.Use();
  /**
   * Don't do anything if we are already initialized
   */
  if ( ObjectFactoryBase::m_RegisteredFactories == 0)
    {
    ObjectFactoryBase::m_RegisteredFactories =
      new std::list< ObjectFactoryBase * >;
    }
  std::cerr << "&m_RegisteredFactories = " << &m_RegisteredFactories
            << " m_RegisteredFactories = " << m_RegisteredFactories
            << " m_RegisteredFactories.size() = " <<
m_RegisteredFactories->size()
            << std::endl;
}

So it is printing out the address and size of the One True
m_RegisteredFactories every time
ObjectFactoryBase::InitializeFactoryList() gets called.

The output is below. Let me summarize: First, the ImageIO factories get
added. Then the TransformIO factories get added and the address changes,
and the count goes back to zero!

Now I'm perhaps alone in running with ITK_BUILD_SHARED, but it appears
that you get a different instance of
ObjectFactoryBase::m_RegisteredFactories depending on which shared library
you're in.  In other words the ObjectFactory implementation in ITK is 100%
broken with respect to shared libraries.


&m_RegisteredFactories = 0x101fb7c30 m_RegisteredFactories = 0x1061d6330
m_RegisteredFactories.size() =0
&m_RegisteredFactories = 0x101fb7c30 m_RegisteredFactories = 0x1061d6330
m_RegisteredFactories.size() =1
&m_RegisteredFactories = 0x101fb7c30 m_RegisteredFactories = 0x1061d6330
m_RegisteredFactories.size() =2
&m_RegisteredFactories = 0x101fb7c30 m_RegisteredFactories = 0x1061d6330
m_RegisteredFactories.size() =3
&m_RegisteredFactories = 0x101fb7c30 m_RegisteredFactories = 0x1061d6330
m_RegisteredFactories.size() =4
&m_RegisteredFactories = 0x101fb7c30 m_RegisteredFactories = 0x1061d6330
m_RegisteredFactories.size() =5
&m_RegisteredFactories = 0x101fb7c30 m_RegisteredFactories = 0x1061d6330
m_RegisteredFactories.size() =6
&m_RegisteredFactories = 0x101fb7c30 m_RegisteredFactories = 0x1061d6330
m_RegisteredFactories.size() =7
&m_RegisteredFactories = 0x101fb7c30 m_RegisteredFactories = 0x1061d6330
m_RegisteredFactories.size() =8
&m_RegisteredFactories = 0x101fb7c30 m_RegisteredFactories = 0x1061d6330
m_RegisteredFactories.size() =9
&m_RegisteredFactories = 0x101fb7c30 m_RegisteredFactories = 0x1061d6330
m_RegisteredFactories.size() =10
&m_RegisteredFactories = 0x101fb7c30 m_RegisteredFactories = 0x1061d6330
m_RegisteredFactories.size() =11
&m_RegisteredFactories = 0x101fb7c30 m_RegisteredFactories = 0x1061d6330
m_RegisteredFactories.size() =12
&m_RegisteredFactories = 0x101fb7c30 m_RegisteredFactories = 0x1061d6330
m_RegisteredFactories.size() =13
&m_RegisteredFactories = 0x104d7d5e0 m_RegisteredFactories = 0x1061e0a70
m_RegisteredFactories.size() =0




On 3/22/11 3:53 PM, "Kent WIlliams" <norman-k-williams at uiowa.edu> wrote:

>Yes I'd be available.
>
>
>Since at this point the TransformFactory only works by accident, any
>improvement would be welcome.
>
>On 3/22/11 3:35 PM, "Luis Ibanez" <luis.ibanez at kitware.com> wrote:
>
>>Hi Kent,
>>
>>Coincidentally we have a great tcon yesterday with Vince
>>looking at the status of factories in ITK.
>>
>>We identified a set of improvements that can be applied
>>to the Transform Factories.
>>
>>Could you be available for a phone or Skype tcon at
>>some time tomorrow Wednesday ?
>>
>>We can go over the details there.
>>
>>
>>    Please let me know,
>>
>>
>>        Thanks
>>
>>
>>            Luis
>>



________________________________
Notice: This UI Health Care e-mail (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and may be legally privileged.  If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited.  Please reply to the sender that you have received the message in error, then delete it.  Thank you.
________________________________


More information about the Insight-developers mailing list