[Insight-users] Re: Insight-users Digest, Vol 37, Issue 49

Andriy Fedorov fedorov at bwh.harvard.edu
Fri May 18 12:10:44 EDT 2007


Catherine,

Below is a code snippet, which saves a mesh in RAW format (very
simple), given ITK surface mesh. Hope this helps you.

Andriy Fedorov



template<class TInputMesh> void
TriangularSurfaceMeshWriter<TInputMesh>::WriteRawMesh(){
      std::ofstream raw_mesh(m_FileName.c_str());
      raw_mesh << m_InputMesh->GetPoints()->Size() << " "
        << m_InputMesh->GetCells()->Size() << std::endl;

      typename InputMeshType::PointsContainer::ConstIterator inPointsI;
      typename InputMeshType::CellsContainer::ConstIterator inCellsI;
      inPointsI = m_InputMesh->GetPoints()->Begin();
      while(inPointsI != m_InputMesh->GetPoints()->End()){
        typename InputMeshType::PointType curPoint;
        curPoint = inPointsI.Value();
        raw_mesh << curPoint[0] << " " << curPoint[1] << " " <<
curPoint[2] << std::endl;
        inPointsI++;
      }

      inCellsI = m_InputMesh->GetCells()->Begin();
      typedef itk::TriangleCell<typename InputMeshType::CellType> TriangleType;
      while(inCellsI != m_InputMesh->GetCells()->End()){
        TriangleType *curTri;
        typename TriangleType::PointIdIterator ptI;
        if(inCellsI.Value()->GetType() !=
InputMeshType::CellType::TRIANGLE_CELL)
          itkExceptionMacro(<<"Input surface mesh is not triangular");
        curTri = dynamic_cast<TriangleType*>(inCellsI.Value());
        ptI = curTri->PointIdsBegin();
        raw_mesh << *ptI++ << " " << *ptI++ << " " << *ptI++ << std::endl;
        inCellsI++;
      }
      raw_mesh.close();
}


> Message: 5
> Date: Fri, 18 May 2007 10:48:03 -0500
> From: "Catherine Peloquin" <cepeloquin at gmail.com>
> Subject: [Insight-users] Retrieving coordinates from
>         BinaryMask3DMeshSource  mesh
> To: insight-users at itk.org
> Message-ID:
>         <3a72f1140705180848h35f387f2h6e418e3aa2a62ba3 at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> I am using the BinaryMask3DMeshSource filter example in
> Insight/Examples/Filters/SurfaceExtraction.cxx to create an isosurface of a
> series of DICOM images.  I need to retrieve the coordinates of the output
> mesh's nodes (or the vertices of the triangles formed by the mesh) so I can
> then draw the surface in Coin3D.  I realize that I can also draw the surface
> in VTK, but I need to integrate the program into an application that uses
> Coin.
>
> In a previous post (located at
> http://public.kitware.com/pipermail/insight-users/2007-May/022211.html) , I
> attempted to follow the methods of retrieving coordinates in the PointSet
> example in Insight/Examples/DataRepresentation/Mesh/PointSet2.cxx, but could
> not find a way to get the mesh points for the points container.
>
> How is it possible to get the x, y, and z coordinates of a mesh generated by
> the BinaryMask3DMeshSource filter?
>
> Thank you,
> Catherine Peloquin
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://public.kitware.com/pipermail/insight-users/attachments/20070518/4bc94481/attachment-0001.htm
>


More information about the Insight-users mailing list