<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2873" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><FONT face=Arial size=2><SPAN 
class=631251903-19042006>Hi,</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN 
class=631251903-19042006></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>We are working mesh generation from image data. We 
would like to save the meshes in meta format. However, when we use the 
SpatialObjectWriter a segmentation fault is generated when writing on the cell 
traits. All of the point location and connectivity information is written 
properly to the file. We have code that is able to write the meshes 
appropriately in other another format, but would like to include this is an 
option for loading the meshes into VTK and paraview. Here is an example of the 
code generating the problem:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>typedef itk::DefaultStaticMeshTraits&lt; unsigned 
long , 3, 3, double, double, double &gt; MeshTraitType; </FONT></DIV>
<DIV><FONT face=Arial size=2>typedef itk::Mesh&lt; unsigned long, 3, 
MeshTraitType &gt; MeshType; .<BR>.<BR>.<BR>finalMesh = 
MeshFilter-&gt;GetOutput();</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>typedef itk::MeshSpatialObject&lt; MeshType &gt; 
MeshSpatialObjectType; <BR>&nbsp;<BR>MeshSpatialObjectType::Pointer 
meshSpatialObject = 
MeshSpatialObjectType::New();<BR>meshSpatialObject-&gt;SetMesh( finalMesh ); 
</FONT></DIV>
<DIV><FONT face=Arial 
size=2>meshSpatialObject-&gt;ComputeLocalBoundingBox();</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>typedef itk::SpatialObjectWriter&lt;3, unsigned 
long, MeshTraitType&gt; WriterType; </FONT></DIV>
<DIV><FONT face=Arial size=2>WriterType::Pointer writer = 
WriterType::New();<BR>writer-&gt;SetInput( meshSpatialObject 
);<BR>writer-&gt;SetFileName( "myMesh.meta" );<BR>try<BR>{<BR>&nbsp;&nbsp; 
writer-&gt;Update( );<BR>}<BR>&nbsp;<BR>catch (itk::ExceptionObject 
&amp;ex)<BR>{<BR>&nbsp;&nbsp; std::cout &lt;&lt; ex &lt;&lt; 
std::endl;<BR>}<BR></FONT></DIV>
<DIV><FONT face=Arial size=2><FONT color=#0000ff></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><FONT color=#0000ff></FONT></FONT>&nbsp;</DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN 
class=433574717-19042006>&nbsp;The following is a test program that i have 
written to test out this functionality</SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN 
class=433574717-19042006></SPAN></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN 
class=433574717-19042006>&nbsp;<BR>#if defined(_MSC_VER)<BR>#pragma warning ( 
disable : 4786 )<BR>#endif</SPAN></FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT>&nbsp;</DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN 
class=433574717-19042006>#include "itkMesh.h"<BR>#include 
"itkDefaultStaticMeshTraits.h"<BR>#include 
"itkAutomaticTopologyMeshSource.h"<BR>#include 
&lt;itkMeshSpatialObject.h&gt;<BR>#include 
&lt;itkSpatialObjectWriter.h&gt;<BR>#include 
&lt;itkSpatialObjectReader.h&gt;</SPAN></FONT></SPAN></DIV>
<DIV>&nbsp;</DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN 
class=433574717-19042006>int main(int, char *[])<BR>&nbsp; 
{</SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN 
class=433574717-19042006>&nbsp;&nbsp;&nbsp; const unsigned int PointDimension = 
3;<BR>&nbsp;&nbsp;&nbsp; const unsigned int MaxTopologicalDimension = 
3;</SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN 
class=433574717-19042006>&nbsp;&nbsp;&nbsp; typedef unsigned 
long&nbsp;&nbsp;&nbsp; PixelType;<BR>&nbsp;&nbsp;&nbsp; typedef 
double&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
CellDataType;</SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN 
class=433574717-19042006>&nbsp;&nbsp;&nbsp; typedef 
double&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
CoordinateType;<BR>&nbsp;&nbsp;&nbsp; typedef 
double&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
InterpolationWeightType;</SPAN></FONT></SPAN></DIV>
<DIV>&nbsp;</DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN 
class=433574717-19042006>&nbsp;&nbsp;&nbsp; typedef 
itk::DefaultStaticMeshTraits&lt; PixelType, PointDimension, 
MaxTopologicalDimension,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
CoordinateType, InterpolationWeightType, CellDataType &gt; 
MeshTraitType;</SPAN></FONT></SPAN></DIV>
<DIV>&nbsp;</DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN 
class=433574717-19042006>&nbsp;&nbsp;&nbsp; typedef itk::Mesh&lt; PixelType, 
PointDimension, MeshTraitType &gt; MeshType; </SPAN></FONT></SPAN></DIV>
<DIV>&nbsp;</DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN 
class=433574717-19042006>&nbsp;&nbsp;&nbsp; typedef 
itk::AutomaticTopologyMeshSource&lt; MeshType &gt;&nbsp;&nbsp; 
MeshSourceType;<BR>&nbsp;&nbsp;&nbsp; MeshSourceType::Pointer&nbsp; 
meshSource;</SPAN></FONT></SPAN></DIV>
<DIV>&nbsp;</DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN 
class=433574717-19042006>&nbsp;&nbsp;&nbsp; meshSource = MeshSourceType::New( 
);<BR>&nbsp;&nbsp;&nbsp; 
meshSource-&gt;AddHexahedron(<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
meshSource-&gt;AddPoint( 13.5, -20.5, 10.5 ),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
meshSource-&gt;AddPoint( 13.5, -17.5, 10.5 ),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
meshSource-&gt;AddPoint( 16.5, -17.5, 10.5 ),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
meshSource-&gt;AddPoint( 16.5, -20.5, 10.5 ),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
meshSource-&gt;AddPoint( 13.5, -20.5, 7.5 ),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
meshSource-&gt;AddPoint( 13.5, -17.5, 7.5 ),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
meshSource-&gt;AddPoint( 16.5, -17.5, 7.5 ),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
meshSource-&gt;AddPoint( 16.5, -20.5, 7.5 ));</SPAN></FONT></SPAN></DIV>
<DIV>&nbsp;</DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN 
class=433574717-19042006>&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; " Points = " 
&lt;&lt; meshSource-&gt;GetOutput()-&gt;GetNumberOfPoints() &lt;&lt; 
std::endl;<BR>&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; " Cells&nbsp; = " &lt;&lt; 
meshSource-&gt;GetOutput()-&gt;GetNumberOfCells()&nbsp; &lt;&lt; 
std::endl;</SPAN></FONT></SPAN></DIV>
<DIV>&nbsp;</DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN 
class=433574717-19042006>&nbsp;&nbsp;&nbsp; CellDataType value = 
3000.50;<BR>&nbsp;&nbsp;&nbsp; meshSource-&gt;GetOutput()-&gt;SetCellData( 1, 
value );</SPAN></FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT>&nbsp;</DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN 
class=433574717-19042006>&nbsp;&nbsp;&nbsp; CellDataType 
cellData;<BR>&nbsp;&nbsp;&nbsp; meshSource-&gt;GetOutput()-&gt;GetCellData( 1, 
&amp;cellData );</SPAN></FONT></SPAN></DIV>
<DIV>&nbsp;</DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN 
class=433574717-19042006>&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; " cell data from 
GetCellData() method = " &lt;&lt; cellData &lt;&lt; 
std::endl;</SPAN></FONT></SPAN></DIV>
<DIV>&nbsp;</DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN 
class=433574717-19042006>&nbsp;&nbsp;&nbsp; typedef itk::MeshSpatialObject&lt; 
MeshType &gt; MeshSpatialObjectType;&nbsp; </SPAN></FONT></SPAN></DIV>
<DIV>&nbsp;</DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN 
class=433574717-19042006>&nbsp;&nbsp;&nbsp; MeshSpatialObjectType::Pointer 
meshSpatialObject = MeshSpatialObjectType::New();<BR>&nbsp;&nbsp;&nbsp; 
meshSpatialObject-&gt;SetMesh( meshSource-&gt;GetOutput() 
);<BR>&nbsp;&nbsp;&nbsp; 
meshSpatialObject-&gt;ComputeLocalBoundingBox();</SPAN></FONT></SPAN></DIV>
<DIV>&nbsp;</DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN 
class=433574717-19042006>&nbsp;&nbsp;&nbsp; typedef 
itk::SpatialObjectWriter&lt;3, unsigned long, MeshTraitType&gt; 
WriterType;<BR>&nbsp;&nbsp;&nbsp; WriterType::Pointer writer = 
WriterType::New();<BR>&nbsp;&nbsp;&nbsp; writer-&gt;SetInput( meshSpatialObject 
);<BR>&nbsp;&nbsp;&nbsp; writer-&gt;SetFileName( "myMesh.meta" 
);<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; 
try<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; 
writer-&gt;Update( );<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;}</SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN 
class=433574717-19042006>&nbsp;&nbsp;&nbsp; catch (itk::ExceptionObject 
&amp;ex)<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;std::cout &lt;&lt; ex 
&lt;&lt; std::endl;<BR>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;}<BR>&nbsp; &nbsp; return 
0;<BR>}</SPAN></FONT></SPAN><FONT size=+0></DIV></FONT></BODY></HTML>