[Insight-users] request fo rexample of itkMesh->SetCellLinks()

Bitter, Ingmar (NIH/CC/DRD) IBitter at cc.nih.gov
Fri May 28 12:40:18 EDT 2004


Hi,

The following code is a trimmed down version of the
AutomaticTopologyMeshSource example in the manual. Unfortunately it does not
compute the CellLinks. 
(At least the output contains: Number Of Cell Links: 0)

Is there a standard way to compute the cell links?

If not and I have to write one, is itk::AutomaticTopologyMeshSource the best
place to do so, as it already contains the hashtables for the cells?  I.e.
should there be a function
itk::AutomaticTopologyMeshSource::ComputeCellLinks() that can be called
after all elements are added and that would traverse all cells ones,
building the Cell Link container on the way by looking up in the hash table
which container entry to add the current cell to.

-Ingmar

#include "itkMesh.h"
#include "itkVertexCell.h"
#include "itkLineCell.h"
#include "itkTriangleCell.h"
#include "itkTetrahedronCell.h"
#include "itkAutomaticTopologyMeshSource.h"

int main()
{
    typedef float                             PixelType;
    typedef itk::Mesh< PixelType, 3 >         MeshType;
    typedef MeshType::PointType               PointType;
    typedef MeshType::CellType                CellType;

    typedef itk::AutomaticTopologyMeshSource< MeshType > MeshSourceType;
    typedef MeshSourceType::IdentifierType               IdentifierType;
    typedef MeshSourceType::IdentifierArrayType     IdentifierArrayType;

    MeshSourceType::Pointer meshSource;
    meshSource = MeshSourceType::New();

    meshSource->AddTriangle(meshSource->AddPoint( 0, 0, 0),
                            meshSource->AddPoint( 0, 1, 0),
                            meshSource->AddPoint( 1, 0, 0)
                           );
    meshSource->AddTriangle(meshSource->AddPoint( 1, 1, 0),
                            meshSource->AddPoint( 0, 1, 0),
                            meshSource->AddPoint( 1, 0, 0)
                           );

    MeshType::Pointer mesh = meshSource->GetOutput();
    std::cout << mesh << std::endl;
    return 0;
}



More information about the Insight-users mailing list