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