[Insight-users] input mesh to TriangleMeshToBinaryImageFilter

Luis Ibanez luis.ibanez at kitware.com
Thu Sep 14 09:40:06 EDT 2006


Hi "Advanced Math"

   You may want to share with the list the source code that
   you used to add points and triangle cells int your Mesh.


   It is very likely that this is where the error is coming
   from.

   Did you tried with a minimal Mesh ?

   For example a mesh with single Tetrahedron ?
   (4 points and 4 triangles) ?


   Please let us know


    Thanks


       Luis


--------------------
advanced math wrote:
> Dear All,
> 
>   I got some problems when using the TriangleMeshToBinaryImageFilter class,
> 
>   The following test code can run smoothly,
> 
>   typedef itk::DefaultDynamicMeshTraits<double, 3, 3,double,double> 
> TriangleMeshTraits;
>   typedef itk::Mesh<double,3, TriangleMeshTraits> TriangleMeshType;
>   typedef 
> itk::RegularSphereMeshSource<TriangleMeshType>  SphereMeshSourceType;
>   typedef SphereMeshSourceType::PointType PointType;
>   typedef itk::Image<unsigned char, 3>      MeshPixelType;
>   typedef itk::TriangleMeshToBinaryImageFilter<TriangleMeshType, 
> MeshPixelType> TriangleMeshToBinaryImageFilterType;
> 
>   TriangleMeshToBinaryImageFilterType::Pointer m_TriangleMeshToImage = 
> TriangleMeshToBinaryImageFilterType::New();
> 
> PointType center;
> center[0]=200;
> center[1]=200;
> center[2]=200;
> 
> SphereMeshSourceType::Pointer mySphere = SphereMeshSourceType::New();
> mySphere->SetCenter(center);
> mySphere->SetScale( 10 );
> mySphere->SetResolution(5);
> 
> m_TriangleMeshToImage->SetInput(mySphere->GetOutput());
> 
> MeshPixelType::SizeType size;
> 
> size[0] = 90;
> size[1] = 90;
> size[2] = 90;
> m_TriangleMeshToImage->SetSize(size);
> 
> float orgn[3];
> orgn[0] = 120;
> orgn[1] = 120;
> orgn[2] = 120;
> m_TriangleMeshToImage->SetOrigin(orgn);
> 
> // spacing remains (1,1,1) until we make a change to deformable model class
> float spacing[3];
> spacing[0] = 1;
> spacing[1] = 1;
> spacing[2] = 1;
> 
> m_TriangleMeshToImage->SetSpacing(spacing);
> 
> m_TriangleMeshToImage->Update();
> 
> However, when I change the input mesh to itk::mesh as the following 
> code, runtime exception occurred in the itkprocessobject.
> 
>   typedef itk::DefaultDynamicMeshTraits<double, 3, 3,double,double> 
> TriangleMeshTraits;
>   typedef itk::Mesh<double,3, TriangleMeshTraits> TriangleMeshType;
>   typedef itk::Image<unsigned char, 3>      MeshPixelType;
>   typedef itk::TriangleMeshToBinaryImageFilter<TriangleMeshType, 
> MeshPixelType> TriangleMeshToBinaryImageFilterType;
> 
>   TriangleMeshToBinaryImageFilterType::Pointer m_TriangleMeshToImage = 
> TriangleMeshToBinaryImageFilterType::New();
>   TriangleMeshType::Pointer m_TriangleMesh = TriangleMeshType::New(); 
> //Mesh in triangle
>   ..................................
>   .................................
>  (The code to add point and triangle cell into the mesh)
>  .................................
>  ...................................
> m_TriangleMeshToImage->SetInput(m_TriangleMesh);
> 
>   MeshPixelType::SizeType size;
> 
> size[0] = 90;
> size[1] = 90;
> size[2] = 90;
> m_TriangleMeshToImage->SetSize(size);
> 
> float orgn[3];
> orgn[0] = 120;
> orgn[1] = 120;
> orgn[2] = 120;
> m_TriangleMeshToImage->SetOrigin(orgn);
> 
> // spacing remains (1,1,1) until we make a change to deformable model class
> float spacing[3];
> spacing[0] = 1;
> spacing[1] = 1;
> spacing[2] = 1;
> 
> m_TriangleMeshToImage->SetSpacing(spacing);
> 
> m_TriangleMeshToImage->Update();
> 
> In case there is error in creating the mesh, I have output the mesh in 
> meta file, and checked. No problems found.
> Any ideas? Thanks.
> 
> Tim,
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users




More information about the Insight-users mailing list