[Insight-users] Writing mesh to Metafile

Tobias Heimann t.heimann at dkfz-heidelberg.de
Thu Dec 8 12:28:22 EST 2005


Hi Dominique,

The IndexedTriangleMesh is not part of ITK yet, as I'm still waiting for 
some legal information before submitting it to the InsightJournal, and 
only then it will be considered for inclusion.
For now, I'm the only one who can answer questions about this class, so 
you can send future emails directly to me.

On the general question of writing meshes with ITK, you can convert the 
mesh data to VTK (there are examples for that in the InsightApplication 
directory I think) and use VTK writers to output the data.
This method also works for an IndexedTriangleMesh.

An easier way (outside of the current ITK) is to use the 
itk::MeshSTLWriter class that you should have as well  if you have the 
IndexedTriangleMesh. If that's not the case, just send me another mail...

Best wishes,
Tobias


Dominique Zosso wrote:

>Hello,
>
>I'm trying to save an itkIndexedTriangleMesh (author : Tobias Heimann.
>Division Medical and Biological Informatics,  German Cancer Research Center,
>Heidelberg, Germany ) in some meta-file.
>
>itkIndexedTriangleMesh is a class derived from itkMesh offering additional
>CellLink-functionalities.
>
>According to the SoftwareGuide, I put the mesh into a MeshSpatialObject and
>try to write this latter into a meta-file. The source code doing this is
>given below.
>
>The evolveMesh-Output is already calculated when it is assigned to the
>meshSpatialObject. No need to update. (see Meta-Output)
>
>The program crashes as soon as I try to update the SpatialObjectWriter, with
>a segmentation fault. There is not even an itkException being catched by the
>block. Does anybody have an idea what could be wrong? Or is there another
>way to save a mesh?
>
>Thank you for every piece of advice!!
>
>For your information, I'm using ITK 2.2.0, and c++ (GCC) 4.0.2 20050808
>(prerelease)  on Ubuntu 4.0.1-4ubuntu9.
>
>
>Thanks a lot, Dominique
>
>
>Piece of code producing the crash:
>**************************
>
>  MeshSpatialObjectType::Pointer meshSpatialObject =
>MeshSpatialObjectType::New();
>  meshSpatialObject->SetMesh( evolveMesh->GetOutput() );
>
>  MeshWriterType::Pointer meshWriter = MeshWriterType::New();
>  meshWriter->SetInput( meshSpatialObject );
>  meshWriter->SetFileName( "mesh.meta" );
>
>  std::cout << std::endl << " meshSpatialObject : " << std::endl <<
>meshSpatialObject << std::endl;
>  std::cout << std::endl << " meshWriter : " << std::endl << meshWriter <<
>std::endl;
>
>  try
>  {
>    meshWriter->Update();
>  }
>  catch ( itk::ExceptionObject & err )
>  {
>    std::cerr << " Could not write mesh meta file. Going down *tilt* " <<
>std::endl;
>    std::cerr << err << std::endl;
>    return EXIT_FAILURE;
>  }
>
>
>
>And the console output produced before crashing:
>**************************************
>
>meshSpatialObject :
>MeshSpatialObject (0x82e0a60)
>  RTTI typeinfo:   itk::MeshSpatialObject<itk::IndexedTriangleMesh<short,
>unsigned int, double> >
>  Reference Count: 3
>  Modified Time: 26050
>  Debug: Off
>  Observers:
>    none
>  Source: (none)
>  Source output index:  0
>  Release Data: Off
>  Data Released: False
>  Global Release Data: Off
>  PipelineMTime: 0
>  UpdateMTime: 0
>Bounding Box:
>  Object (0x82e08f0)
>  RTTI typeinfo:   itk::BoundingBox<unsigned long, 3, double,
>itk::VectorContainer<unsigned long, itk::Point<double, 3u> > >
>  Reference Count: 2
>  Modified Time: 26004
>  Debug: Off
>  Observers:
>    none
>  Bounding Box: ( 60.3259,140.075 60.3259,140.072 60.2,140.6  )
>
>Geometric properties:
>  Object to World Transform: ScalableAffineTransform (0x8412150)
>  RTTI typeinfo:   itk::ScalableAffineTransform<double, 3u>
>  Reference Count: 2
>  Modified Time: 26009
>  Debug: Off
>  Observers:
>    none
>  Matrix:
>    1 0 0
>    0 1 0
>    0 0 1
>  Offset: [0, 0, 0]
>  Center: [0, 0, 0]
>  Translation: [0, 0, 0]
>  Inverse:
>    1 0 0
>    0 1 0
>    0 0 1
>  Singular: 0
>  Scale : 1 1 1
>  MatrixScale : 1 1 1
>
>  Index to World Transform: ScalableAffineTransform (0x83e6930)
>  RTTI typeinfo:   itk::ScalableAffineTransform<double, 3u>
>  Reference Count: 3
>  Modified Time: 26017
>  Debug: Off
>  Observers:
>    none
>  Matrix:
>    1 0 0
>    0 1 0
>    0 0 1
>  Offset: [0, 0, 0]
>  Center: [0, 0, 0]
>  Translation: [0, 0, 0]
>  Inverse:
>    1 0 0
>    0 1 0
>    0 0 1
>  Singular: 0
>  Scale : 1 1 1
>  MatrixScale : 1 1 1
>
>
>
>  Bounding Box Children Depth: 9999999
>  Bounding Box Children Name:
>Object properties:
>SpatialObjectProperty (0x82e0960)
>  RTTI typeinfo:   itk::SpatialObjectProperty<float>
>  Reference Count: 2
>  Name:
>  RGBA: 1 1 1
>
>Mesh:
>m_IsInsidePrecision: 1
>  IndexedTriangleMesh (0x82e0b80)
>  RTTI typeinfo:   itk::IndexedTriangleMesh<short, unsigned int, double>
>  Reference Count: 3
>  Modified Time: 26050
>  Debug: Off
>  Observers:
>    none
>  Source: (0x83151e0)
>  Source output index: 0
>  Release Data: Off
>  Data Released: False
>  Global Release Data: Off
>  PipelineMTime: 22445
>  UpdateMTime: 25842
>  Number Of Points: 402
>  Requested Number Of Regions: 1
>  Requested Region: 0
>  Buffered Region: 0
>  Maximum Number Of Regions: 1
>  Number Of Points: 402
>  Number Of Cell Links: 402
>  Number Of Cells: 800
>  Size of Cell Data Container: 800
>  Number of explicit cell boundary assignments: 2
>  CellsAllocationMethod: 3
>  Number Of Edges: 1200
>  Number Of Faces: 800
>
>
>
> meshWriter :
>SpatialObjectWriter (0x8432e38)
>  RTTI typeinfo:   itk::SpatialObjectWriter<3u, short,
>itk::DefaultStaticMeshTraits<short, 3u, 2u, double, double, short> >
>  Reference Count: 2
>  Modified Time: 26056
>  Debug: Off
>  Observers:
>    none
>
>Erreur de segmentation
>
>
>---
>Dominique Zosso
>cand. ing. el. EPFL
>
>
>_______________________________________________
>Insight-users mailing list
>Insight-users at itk.org
>http://www.itk.org/mailman/listinfo/insight-users
>
>  
>

-- 
Dipl.-Inform. Med. Tobias Heimann
Deutsches Krebsforschungszentrum         (German Cancer Research Center)
Div. Medical and Biological Informatics B010      Tel: (+49) 6221-423548
Im Neuenheimer Feld 280                           Fax: (+49) 6221-422345
D-69120 Heidelberg                              email: T.Heimann at dkfz.de
Germany                       http://www.dkfz.de/mbi/people/tobiash.html



More information about the Insight-users mailing list