<!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> </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> </DIV>
<DIV><FONT face=Arial size=2>typedef itk::DefaultStaticMeshTraits< unsigned
long , 3, 3, double, double, double > MeshTraitType; </FONT></DIV>
<DIV><FONT face=Arial size=2>typedef itk::Mesh< unsigned long, 3,
MeshTraitType > MeshType; .<BR>.<BR>.<BR>finalMesh =
MeshFilter->GetOutput();</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>typedef itk::MeshSpatialObject< MeshType >
MeshSpatialObjectType; <BR> <BR>MeshSpatialObjectType::Pointer
meshSpatialObject =
MeshSpatialObjectType::New();<BR>meshSpatialObject->SetMesh( finalMesh );
</FONT></DIV>
<DIV><FONT face=Arial
size=2>meshSpatialObject->ComputeLocalBoundingBox();</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>typedef itk::SpatialObjectWriter<3, unsigned
long, MeshTraitType> WriterType; </FONT></DIV>
<DIV><FONT face=Arial size=2>WriterType::Pointer writer =
WriterType::New();<BR>writer->SetInput( meshSpatialObject
);<BR>writer->SetFileName( "myMesh.meta" );<BR>try<BR>{<BR>
writer->Update( );<BR>}<BR> <BR>catch (itk::ExceptionObject
&ex)<BR>{<BR> std::cout << ex <<
std::endl;<BR>}<BR></FONT></DIV>
<DIV><FONT face=Arial size=2><FONT color=#0000ff></FONT></FONT> </DIV>
<DIV><FONT face=Arial size=2><FONT color=#0000ff></FONT></FONT> </DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN
class=433574717-19042006> 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> </DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN
class=433574717-19042006> <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> </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
<itkMeshSpatialObject.h><BR>#include
<itkSpatialObjectWriter.h><BR>#include
<itkSpatialObjectReader.h></SPAN></FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN
class=433574717-19042006>int main(int, char *[])<BR>
{</SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN
class=433574717-19042006> const unsigned int PointDimension =
3;<BR> const unsigned int MaxTopologicalDimension =
3;</SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN
class=433574717-19042006> typedef unsigned
long PixelType;<BR> typedef
double
CellDataType;</SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN
class=433574717-19042006> typedef
double
CoordinateType;<BR> typedef
double
InterpolationWeightType;</SPAN></FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN
class=433574717-19042006> typedef
itk::DefaultStaticMeshTraits< PixelType, PointDimension,
MaxTopologicalDimension,<BR>
CoordinateType, InterpolationWeightType, CellDataType >
MeshTraitType;</SPAN></FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN
class=433574717-19042006> typedef itk::Mesh< PixelType,
PointDimension, MeshTraitType > MeshType; </SPAN></FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN
class=433574717-19042006> typedef
itk::AutomaticTopologyMeshSource< MeshType >
MeshSourceType;<BR> MeshSourceType::Pointer
meshSource;</SPAN></FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN
class=433574717-19042006> meshSource = MeshSourceType::New(
);<BR>
meshSource->AddHexahedron(<BR>
meshSource->AddPoint( 13.5, -20.5, 10.5 ),<BR>
meshSource->AddPoint( 13.5, -17.5, 10.5 ),<BR>
meshSource->AddPoint( 16.5, -17.5, 10.5 ),<BR>
meshSource->AddPoint( 16.5, -20.5, 10.5 ),<BR>
meshSource->AddPoint( 13.5, -20.5, 7.5 ),<BR>
meshSource->AddPoint( 13.5, -17.5, 7.5 ),<BR>
meshSource->AddPoint( 16.5, -17.5, 7.5 ),<BR>
meshSource->AddPoint( 16.5, -20.5, 7.5 ));</SPAN></FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN
class=433574717-19042006> std::cout << " Points = "
<< meshSource->GetOutput()->GetNumberOfPoints() <<
std::endl;<BR> std::cout << " Cells = " <<
meshSource->GetOutput()->GetNumberOfCells() <<
std::endl;</SPAN></FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN
class=433574717-19042006> CellDataType value =
3000.50;<BR> meshSource->GetOutput()->SetCellData( 1,
value );</SPAN></FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN
class=433574717-19042006> CellDataType
cellData;<BR> meshSource->GetOutput()->GetCellData( 1,
&cellData );</SPAN></FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN
class=433574717-19042006> std::cout << " cell data from
GetCellData() method = " << cellData <<
std::endl;</SPAN></FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN
class=433574717-19042006> typedef itk::MeshSpatialObject<
MeshType > MeshSpatialObjectType; </SPAN></FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN
class=433574717-19042006> MeshSpatialObjectType::Pointer
meshSpatialObject = MeshSpatialObjectType::New();<BR>
meshSpatialObject->SetMesh( meshSource->GetOutput()
);<BR>
meshSpatialObject->ComputeLocalBoundingBox();</SPAN></FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN
class=433574717-19042006> typedef
itk::SpatialObjectWriter<3, unsigned long, MeshTraitType>
WriterType;<BR> WriterType::Pointer writer =
WriterType::New();<BR> writer->SetInput( meshSpatialObject
);<BR> writer->SetFileName( "myMesh.meta"
);<BR> <BR>
try<BR> {<BR>
writer->Update( );<BR>
}</SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=697043917-19042006><FONT face=Arial size=2><SPAN
class=433574717-19042006> catch (itk::ExceptionObject
&ex)<BR>
{<BR> std::cout << ex
<< std::endl;<BR> }<BR> return
0;<BR>}</SPAN></FONT></SPAN><FONT size=+0></DIV></FONT></BODY></HTML>