[Insight-users] itk::MeshToMeshFilter creation

Leonardo Florez leonardo.Florez at creatis.insa-lyon.fr
Thu Mar 24 14:53:08 EST 2005


   Dear ITK users,

We are trying to write our own MeshToMeshFilter (by derivation) and idealy
we would like to do such things as:

   typedef itk::Mesh< float, 2 >   InputMeshType;    // NOTICE the 2 !
   typedef itk::Mesh< float, 3 >   OutputMeshType;   // NOTICE the 3 !
   typedef OurMeshToMeshFilter< InputMeshType, OutputMeshType > FilterType;
   ...
   InputMeshType::Pointer  mesh = InputMeshType::New();
   ...
   FilterType::Pointer filter = FilterType::New( );
   filter->SetInput( mesh );
   filter->Update( );
   ...
where OurMeshToMeshFilter<...> inherits from itk::MeshToMeshFilter<...>.

At first, we thought this would be a reasonable usage of InputMeshType,
OutputMeshType and a specialization/extension of itk::MeshToMeshFilter
(and we could provide many nice examples where such usage would be powerfull).

But soon enough we encountered some difficulties. For example the
  filter->Update( );
invocation triggers the following calls:
  itk::ProcessObject::Update ()
  ---> itk::DataObject::Update ()
  ---> itk::PointSet< ... >::UpdateOutputInformation ()
  ---> itk::ProcessObject::UpdateOutputInformation ()
  ---> itk::ProcessObject::GenerateOutputInformation ()
  ---> itk::PointSet< ... >::CopyInformation ()
where the code goes
{
  const PointSet *mesh;
  mesh = dynamic_cast<const PointSet*>(data);
  if (mesh)
    m_MaximumNumberOfRegions = mesh->GetMaximumNumberOfRegions();
  else
    itkExceptionMacro(<< "itk::PointSet::CopyInformation() cannot cast " )...;
}

The difficulty (for what we are trying to do at least) lies in the line
  mesh = dynamic_cast<const PointSet*>(data);
that always fails, since somehow this line assumes that the incoming
mesh (InputMeshType) inherited PointSet can be casted to the outcoming
mesh (OutputMeshType) inherited PointSet. And for our special (or general?)
case this assumption will not hold since both PointSets are of different
type... (VDimension is different).

Maybe we are missunderstanding the usage of the template parameters of
itk::MeshToMeshFilter or maybe we got off the road somewhere ?

For the time being we use the following kludge: we define OurMesh< ... >
by deriving from itk::Mesh<...> in which we overloaded the
CopyInformation() method to simply do nothing.
This is not only dirty, it also will break things when the
MaximumNumberOfRegions needs to be properly updated (which in turn we can
fix in OurMeshToMeshFilter< ... > constructor...).

Could anyone be kind enough to tell us if we goofed up or if this is
a design limitation of itk::Mesh + itk::MeshToMeshFilter. If this happens
to be the case, what is the clean way to get things working ?

	Yours,
        Leonardo Florez, Alexandre Gouaillard , Eric Boix.



-- 
Leonardo Florez Valencia
Doctorant Images et Systemes
CREATIS, INSA de Lyon
Bat. Blaise Pascal
7, Rue Capelle
F-69621 Villeurbanne cedex, FRANCE
Phone : +33 (0) 4 72 43 63 06
Fax   : +33 (0) 4 72 43 85 26
WWW   : http://www.creatis.insa-lyon.fr/~lflorez


More information about the Insight-users mailing list