Hello,<br><br>I figured it out. I wrote the mesh to a .vtk file using VTK coding and viewed the mesh in Paraview.<br><br>The following links helped me considerably in achieving this:<br><a href="http://www.itk.org/pipermail/insight-users/2002-September/001154.html">http://www.itk.org/pipermail/insight-users/2002-September/001154.html</a><br>
<a href="http://www.na-mic.org/svn/Slicer3-lib-mirrors/trunk/Insight/Testing/Code/Common/itkMeshSourceGraftOutputTest.cxx">http://www.na-mic.org/svn/Slicer3-lib-mirrors/trunk/Insight/Testing/Code/Common/itkMeshSourceGraftOutputTest.cxx</a><br>
<br>thanks,<br><br>John<br><br><div class="gmail_quote">On Mon, Jun 28, 2010 at 8:15 PM, John Drozd <span dir="ltr">&lt;<a href="mailto:john.drozd@gmail.com">john.drozd@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>Hello,</div>
<div> </div>
<div>How can I view a metamesh.txt mesh file that I created with an itk::SpatialObjectWriter.</div>
<div> </div>
<div>I modified itk&#39;s example DeformableModel1.cxx to create the &quot;metamesh.txt&quot; file using a binary image that I segmented using the FuzzyConnectedness segmentation example in itk.<br></div>
<div> </div>
<div>I suspect I can use paraview to view a metamesh.txt file but I don&#39;t know the steps.</div>
<div> </div>
<div>Can anyone help?<br><br>To illustrate my case, below are snippets of the contents of my metamesh.txt file:<br><br>ObjectType = Scene<br>NDims = 3<br>NObjects = 1<br>ObjectType = Mesh<br>NDims = 3<br>BinaryData = False<br>

TransformMatrix = 1 0 0 0 1 0 0 0 1<br>Offset = 0 0 0<br>CenterOfRotation = 0 0 0<br>ElementSpacing = 1 1 1<br>PointType = MET_FLOAT<br>PointDataType = MET_SHORT<br>CellDataType = MET_SHORT<br>NCellTypes = 1<br>PointDim = ID x y ...<br>

NPoints = 22863<br>Points = <br>0 321.712 160.777 68.8275 <br>1 322.185 160.305 68.8275 <br>2 322.185 160.777 68.2237 <br>3 322.658 160.777 68.8275 <br>4 321.712 161.723 68.8275 <br>5 322.185 161.723 68.2237 <br>6 322.658 161.723 68.8275 <br>

7 321.712 162.669 68.8275 <br>8 322.185 162.669 68.2237 <br><br>.............................<br><br>22855 319.821 164.088 132.221 <br>22856 320.294 164.561 132.221 <br>22857 319.348 165.506 132.221 <br>22858 319.821 165.033 132.221 <br>

22859 320.294 165.506 132.221 <br>22860 320.294 166.452 132.221 <br>22861 319.821 165.979 132.221 <br>22862 320.294 167.398 132.221 <br>CellType = TRI<br>NCells = 45574<br>Cells = <br>0 0 2 1 <br>1 3 1 2 <br>2 4 5 0 <br>
3 2 0 5 <br>
4 6 3 5 <br>5 2 5 3 <br>6 7 8 4 <br>7 5 4 8 <br>8 9 6 8 <br>9 5 8 6 <br>10 10 11 7 <br>11 8 7 11 <br>12 12 9 11 <br><br>.........................................<br><br>45567 22859 22793 22860 <br>45568 22801 22797 22862 <br>

45569 22860 22862 22797 <br>45570 22804 22862 22799 <br>45571 22860 22799 22862 <br>45572 22801 22862 22806 <br>45573 22804 22806 22862 <br>NCellData = 45574<br>CellDataSize = 273444<br>CellData = <br><br></div>

<div>(binary data)<br><br><br>And Here is the code that generates my metamesh.txt file:<br><br>#include &lt;iostream&gt;<br><br><br>//  Software Guide : BeginLatex<br>//<br>//  We start by including the headers of the main classes required for this<br>

//  example. The BinaryMask3DMeshSource is used to produce an initial<br>//  approximation of the shape to be segmented. This filter takes a binary<br>//  image as input and produces a Mesh as output using the marching cube<br>

//  isocontouring algorithm.<br>//<br>//  \index{itk::BinaryMask3DMeshSource!Header}<br>//<br>//  Software Guide : EndLatex <br><br>// Software Guide : BeginCodeSnippet<br>#include &quot;itkBinaryMask3DMeshSource.h&quot;<br>

// Software Guide : EndCodeSnippet<br><br><br>//  Software Guide : BeginLatex<br>//  <br>//  Then we include the header of the DeformableMesh3DFilter that<br>//  implements the deformable model algorithm.<br>//<br>//  \index{itk::DeformableMesh3DFilter!Header}<br>

//<br>//  Software Guide : EndLatex <br><br>//  Software Guide : BeginCodeSnippet<br>#include &quot;itkDeformableMesh3DFilter.h&quot;<br>//  Software Guide : EndCodeSnippet <br><br><br>//  Software Guide : BeginLatex<br>
//  <br>
//  We also need the headers of the gradient filters that will be used for<br>//  computing the vector field. In our case they are the<br>//  GradientMagnitudeRecursiveGaussianImageFilter and<br>//  GradientRecursiveGaussianImageFilter.<br>

//<br>//  Software Guide : EndLatex <br><br>//  Software Guide : BeginCodeSnippet<br>#include &quot;itkGradientRecursiveGaussianImageFilter.h&quot;<br>#include &quot;itkGradientMagnitudeRecursiveGaussianImageFilter.h&quot;<br>

//  Software Guide : EndCodeSnippet <br><br><br>//  Software Guide : BeginLatex<br>//  <br>//  The main data structures required in this example are the Image<br>//  and the Mesh classes. The deformable model \emph{per se} is<br>

//  represented as a Mesh.<br>//<br>//  Software Guide : EndLatex <br><br>//  Software Guide : BeginCodeSnippet<br>#include &quot;itkImage.h&quot;<br>#include &quot;itkMesh.h&quot;<br>//  Software Guide : EndCodeSnippet <br>

<br><br>//  Software Guide : BeginLatex<br>//  <br>//  The \code{PixelType} of the image derivatives is represented with a<br>//  \doxygen{CovariantVector}. We include its header in the following line.<br>//<br>//  Software Guide : EndLatex <br>

<br>//  Software Guide : BeginCodeSnippet<br>#include &quot;itkCovariantVector.h&quot;<br>//  Software Guide : EndCodeSnippet <br><br>//  Software Guide : BeginLatex<br>//  <br>//  The deformed mesh is converted into a binary image using the<br>

//  \doxygen{PointSetToImageFilter}.<br>//<br>//  Software Guide : EndLatex <br><br>//  Software Guide : BeginCodeSnippet<br>#include &quot;itkPointSetToImageFilter.h&quot;<br>//  Software Guide : EndCodeSnippet <br><br>
//  Software Guide : BeginLatex<br>
//  <br>//  In order to read both the input image and the mask image, we need the<br>//  \doxygen{ImageFileReader} class. We also need the \doxygen{ImageFileWriter}<br>//  to save the resulting deformed mask image.<br>//<br>

//  Software Guide : EndLatex <br><br>//  Software Guide : BeginCodeSnippet<br>#include &quot;itkImageFileReader.h&quot;<br>#include &quot;itkImageFileWriter.h&quot;<br>//  Software Guide : EndCodeSnippet <br><br>//added by jd<br>

//<a href="http://www.slideshare.net/kitware/itk-tutorial-presentation-slides948" target="_blank">http://www.slideshare.net/kitware/itk-tutorial-presentation-slides948</a><br>#include &quot;itkSpatialObjectWriter.h&quot;<br>
#include &quot;itkMeshSpatialObject.h&quot;<br>
#include &quot;itkDefaultDynamicMeshTraits.h&quot;<br>//end of added code<br><br>int main( int argc, char *argv[] )<br>{<br><br>  if( argc &lt; 4 )<br>    {<br>    std::cerr &lt;&lt; &quot;Missing Parameters &quot; &lt;&lt; std::endl;<br>

    std::cerr &lt;&lt; &quot;Usage: &quot; &lt;&lt; argv[0];<br>    std::cerr &lt;&lt; &quot; InputImage  BinaryImage DeformedMaskImage&quot; &lt;&lt; std::endl;<br>    return 1;<br>    }<br> <br><br>  //  Software Guide : BeginLatex<br>

  //<br>  //  Here we declare the type of the image to be processed. This implies a<br>  //  decision about the \code{PixelType} and the dimension. The<br>  //  DeformableMesh3DFilter is specialized for $3D$, so the choice<br>

  //  is clear in our case.<br>  //<br>  //  Software Guide : EndLatex <br><br>  // Software Guide : BeginCodeSnippet<br>  <br>  const     unsigned int    Dimension = 3;<br>  <br>  typedef   signed short                         PixelType;<br>

<br>  typedef itk::Image&lt;PixelType, Dimension&gt; ImageType;<br>  // Software Guide : EndCodeSnippet<br><br><br>  //  Software Guide : BeginLatex<br>  //  <br>  //  The input to BinaryMask3DMeshSource is a binary mask that we<br>

  //  will read from a file. This mask could be the result of a rough<br>  //  segmentation algorithm applied previously to the same anatomical<br>  //  structure. We declare below the type of the binary mask image.<br>  //<br>

  //  Software Guide : EndLatex <br><br>  // Software Guide : BeginCodeSnippet<br><br>  typedef itk::Image&lt; signed short, Dimension &gt;   BinaryImageType;<br>  <br>  // Software Guide : EndCodeSnippet<br><br><br>  //  Software Guide : BeginLatex<br>

  //  <br>  //  Then we define the type of the deformable mesh. We represent the<br>  //  deformable model using the Mesh class. The \code{signed short} type used as<br>  //  template parameter here is to be used to assign values to every point<br>

  //  of the Mesh.<br>  //<br>  //  Software Guide : EndLatex <br><br>  // Software Guide : BeginCodeSnippet<br>  <br>  typedef  itk::Mesh&lt;signed short&gt;     MeshType;<br><br>  // Software Guide : EndCodeSnippet<br>
<br>
<br>  //  Software Guide : BeginLatex<br>  //  <br>  //  The filter implementing the isocontouring algorithm is the<br>  //  BinaryMask3DMeshSource filter.<br>  // <br>  //  \index{itk::BinaryMask3DMeshSource!Instantiation} <br>

  //<br>  //  Software Guide : EndLatex <br><br>  //  Software Guide : BeginCodeSnippet<br>  typedef itk::BinaryMask3DMeshSource&lt; BinaryImageType, MeshType &gt;  MeshSourceType;<br> <br><br>  //  Software Guide : BeginLatex<br>

  //<br>  //  Let&#39;s declare two readers. The first will read the image to be<br>  //  segmented. The second will read the binary mask containing a first<br>  //  approximation of the segmentation that will be used to initialize a<br>

  //  mesh for the deformable model.<br>  //<br>  //  Software Guide : EndLatex <br><br>  // Software Guide : BeginCodeSnippet<br>  typedef itk::ImageFileReader&lt; ImageType       &gt;  ReaderType;<br>  typedef itk::ImageFileReader&lt; BinaryImageType &gt;  BinaryReaderType;<br>

  ReaderType::Pointer       imageReader   =  ReaderType::New();<br>  BinaryReaderType::Pointer maskReader    =  BinaryReaderType::New();<br>  // Software Guide : EndCodeSnippet<br><br><br>  //  Software Guide : BeginLatex<br>

  //  <br>  //  In this example we take the filenames of the input image and the binary<br>  //  mask from the command line arguments.<br>  //<br>  //  Software Guide : EndLatex <br><br>  //  Software Guide : BeginCodeSnippet<br>

  imageReader-&gt;SetFileName( argv[1] );<br>  maskReader-&gt;SetFileName(  argv[2] );<br>  //  Software Guide : EndCodeSnippet <br><br><br><br><br>  //  Software Guide : BeginLatex<br>  //  <br>  //  Now we can construct the mesh source filter that implements the<br>

  //  isocontouring algorithm.<br>  //<br>  //  \index{BinaryMask3DMeshSource!New()}<br>  //  \index{BinaryMask3DMeshSource!Pointer}<br>  //<br>  //  Software Guide : EndLatex <br><br>  // Software Guide : BeginCodeSnippet<br>

  MeshSourceType::Pointer meshSource = MeshSourceType::New();<br>  <br>  BinaryImageType::Pointer mask = maskReader-&gt;GetOutput();<br>  meshSource-&gt;SetInput( mask );<br><br>  meshSource-&gt;SetObjectValue( 1 );<br><br>

  std::cout &lt;&lt; &quot;Creating mesh...&quot; &lt;&lt; std::endl;<br>  try <br>    {<br>    meshSource-&gt;Update();<br>    }<br>  catch( itk::ExceptionObject &amp; excep )<br>    {<br>    std::cerr &lt;&lt; &quot;Exception Caught !&quot; &lt;&lt; std::endl;<br>

    std::cerr &lt;&lt; excep &lt;&lt; std::endl;<br>    }<br><br>  meshSource-&gt;GetOutput()-&gt;Print(std::cout);<br><br>  //from slideshare website<br><br>  typedef itk::MeshSpatialObject&lt;MeshType&gt;MeshSpatialObjectType;<br>

<br>  MeshSpatialObjectType::Pointer meshSO = MeshSpatialObjectType::New();<br>  meshSO-&gt;SetMesh(meshSource-&gt;GetOutput());<br><br>  typedef MeshSourceType::OutputMeshType OutputMeshType;<br><br>  typedef itk::SpatialObjectWriter&lt;3,signed short,OutputMeshType::MeshTraits&gt;WriterType;<br>

  WriterType::Pointer writer=WriterType::New();<br>  writer-&gt;SetInput(meshSO);<br>  writer-&gt;SetFileName(&quot;metamesh.txt&quot;);<br>  writer-&gt;Update();<br>  //end of added code<br><br>  std::cout &lt;&lt; &quot;Deformable mesh created using Marching Cube!&quot; &lt;&lt; std::endl;<br>

<br>return EXIT_SUCCESS;<br>}<br><br></div>
<div> </div>
<div>Any help in giving me suggestions to view this mesh would be appreciated. <br></div>
<div> </div>

<div> <br></div>
<div>Thank you,</div>
<div>John</div>
</blockquote></div><br>