[Insight-users] MeshToMeshFilter

Luis Ibanez luis.ibanez at kitware.com
Thu, 19 Feb 2004 00:34:55 -0500


Hi Thomas,

It seems that we hit a design decision here.

The itk::TransformMeshFilter was written under
the assumption that a user would take a mesh,
apply a transform to its points and then simply
carry over all the additional mesh information.

In other words it was intended for a sort of
Mesh deformation operation.


The PointData is intended to hold data associated
to each point. Since this data doesn't change as
a result of deforming the mesh, the filter is
passing the pointdata container from the input
to the output. Since it is a template argument,
you can select what to store at each point. The
itk mesh It is the equivalent of the VTK unstructured grid.


However, You could use the PointData it for something
like  storing vectors normal to a surface for example.
which in the case of a deformation, will have to be
recomputed, but because the filter doesn't have a way
to know what you are storing as PointData, it doesn't
know what to do to update this part of the mesh.

It seems that the solution is to add a filter of
type:

       itkPointSetToPointSetFilter

that will apply the transformation to the points.
In this situation you will pass the set of points
from the mesh to this filter and then take the
resulting point for creating a new mesh.

Another option is to use the notion of "inPlace" filters
that recently has spread over the ImageToImage filters.
In that context, the mesh is updated without creating
a new one. Simply modifying the values of the point
coordinates in the same point container.  Note that for
this to work the inptu and output mesh types must be
the same......which doesn't help at all for your original
purpose...

We could take the risk of using the reinterpret_casting
but this is like using high profile antibiotics... it
may bring more problems than solutions...


Please let us know if you find any of those to be a
reasonable solution or you envisage some other option.



Thanks,


    Luis



----------------------
Thomas Boettger wrote:

> Hello everybody,
> 
> I tried to define the MeshToMeshFilter subclasses with different 
> MeshTypes for input and output meshes. The only difference between the 
> meshtraits is the pixel type, which i want to change from input to 
> output. I need this because I have different PixelTypes defined to store 
> data in the new classes I am writing.
> 
> The following code example does not compile:
> 
> #include "itkMesh.h"
> #include "itkIdentityTransform.h"
> #include "itkTransformMeshFilter.h"
> #include "itkDefaultStaticMeshTraits.h"
> 
> int itkDifferentMeshTypesTest(int, char* [] )
> {
>   typedef itk::DefaultStaticMeshTraits<float, 3, 3, float, float, float> 
> FloatTraits;
>   typedef itk::DefaultStaticMeshTraits<double, 3, 3, float,float,float> 
> DoubleTraits;
> 
>   typedef itk::Mesh<float, 3, FloatTraits> FloatMeshType;
>   typedef itk::Mesh<double, 3, DoubleTraits> DoubleMeshType;
>   typedef itk::IdentityTransform<float,3>  TransformType;
>   typedef itk::TransformMeshFilter<FloatMeshType, DoubleMeshType, 
> TransformType> MeshFilterType;
>   MeshFilterType::Pointer meshTransformer = MeshFilterType::New();
>   return 0;
> }
> 
> 
> It is not clear what the pixel type is really used for. There should be 
> no influence because it is described as the PointData type in the 
> documetation.
> 
> I attached the code and Visual Studio error output. Where is the mistake?
> 
> 
> Regards,
> 
> Thomas
> 
> 
> ------------------------------------------------------------------------
> 
> f:\itk-1.4.0\Code\BasicFilters\itkTransformMeshFilter.txx(105) : error C2664: 'void itk::PointSet<TPixelType,VDimension,TMeshTraits>::SetPointData(itk::PointSet<TPixelType,VDimension,TMeshTraits>::PointDataContainer *)' : cannot convert parameter 1 from 'itk::PointSet<TPixelType,VDimension,TMeshTraits>::PointDataContainer *' to 'itk::PointSet<TPixelType,VDimension,TMeshTraits>::PointDataContainer *'
>         with
>         [
>             TPixelType=float,
>             VDimension=3,
>             TMeshTraits=DoubleTraits
>         ]
>         and
>         [
>             TPixelType=float,
>             VDimension=3,
>             TMeshTraits=itk::DefaultStaticMeshTraits<float,3,3,float,float,float>
>         ]
>         and
>         [
>             TPixelType=float,
>             VDimension=3,
>             TMeshTraits=DoubleTraits
>         ]
>         Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
>         C:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xtree(261) : while compiling class-template member function 'void itk::TransformMeshFilter<TInputMesh,TOutputMesh,TTransform>::GenerateData(void)'
>         with
>         [
>             TInputMesh=FloatMeshType,
>             TOutputMesh=DoubleMeshType,
>             TTransform=TransformType
>         ]
>         itkRegularSphereMeshSourceTest.cpp(65) : see reference to class template instantiation 'itk::TransformMeshFilter<TInputMesh,TOutputMesh,TTransform>' being compiled
>         with
>         [
>             TInputMesh=FloatMeshType,
>             TOutputMesh=DoubleMeshType,
>             TTransform=TransformType
>         ]
> f:\itk-1.4.0\Code\BasicFilters\itkTransformMeshFilter.txx(118) : error C2664: 'itk::Mesh<float,3,class itk::DefaultStaticMeshTraits<double,3,3,float,float,float> >::SetBoundaryAssignments' : cannot convert parameter 2 from 'itk::Mesh<TPixelType,VDimension,TMeshTraits>::BoundaryAssignmentsContainerPointer' to 'itk::Mesh<TPixelType,VDimension,TMeshTraits>::BoundaryAssignmentsContainer *'
>         with
>         [
>             TPixelType=float,
>             VDimension=3,
>             TMeshTraits=itk::DefaultStaticMeshTraits<float,3,3,float,float,float>
>         ]
>         and
>         [
>             TPixelType=float,
>             VDimension=3,
>             TMeshTraits=DoubleTraits
>         ]
>         No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
> 
> 
> ------------------------------------------------------------------------
> 
> 
> #include "itkMesh.h"
> #include "itkIdentityTransform.h"
> #include "itkTransformMeshFilter.h"
> #include "itkDefaultStaticMeshTraits.h"
> 
> int itkDifferentMeshTypesTest(int, char* [] )
> {
>   typedef itk::DefaultStaticMeshTraits<float, 3, 3, float, float, float> FloatTraits;
>   typedef itk::DefaultStaticMeshTraits<double, 3, 3, float, float, float> DoubleTraits;
> 
>   typedef itk::Mesh<float, 3, FloatTraits> FloatMeshType;
>   typedef itk::Mesh<double, 3, DoubleTraits> DoubleMeshType;
>   typedef itk::IdentityTransform<float,3>  TransformType;
>   typedef itk::TransformMeshFilter<FloatMeshType, DoubleMeshType, TransformType> MeshFilterType;
>   MeshFilterType::Pointer meshTransformer = MeshFilterType::New();
>   return 0;
> }