[Insight-users] Ordering of cells in itkMesh and mesh data
Luis Ibanez
luis.ibanez at kitware.com
Wed Jul 11 12:25:19 EDT 2007
Hi Andriy,
You probably shouldn't count on this,..
but... just for you to know:
When you use the itkDefaultStaticMeshTraits.h
the cell container is a class deriving from the std::vector,
so the cell ID and will match with the position of the cells
in the array, and when you iterate through the cells, their
Id "should" be ordered.
When you use the itkDefaultDynamicMeshTraits.h
the cell container is a class deriving from the std::map.
in that case *there is no* guarantee that the cells will
be ordered by Cell ID when they are visited by the iterator.
----
For a plausible solution to your quest:
Note that the Iterators, have an "Index()" method, that will
return the Identifier of the Cell.
You could use this Index() method in order to find the
appropriate cell data entry.
in pseudo code:
while( cellIterator != cellContainer->End() )
{
IdentifierType id = cellIterator.Index();
cellDataContainer->SetElement( id, celldata );
cellDataContainer->InsertElement( id, celldata );
}
SetElement() assumes that the entry *already exists* and
that you are only changing its value
InsertElement() will create the entry if it does not
exist already.
Regards,
Luis
----------------------
Andriy Fedorov wrote:
> Hi,
>
> This may be a simple question, but I am not able to find the answer in
> the Guide quickly.
>
> Is there a guarantee that cells in itkMesh are ordered by their IDs
> while iterating using CellIterator? If not, is there a way to get cell
> ID given cell pointer? I need to know this because I need to assign
> cell data to each cell while iterating through the mesh.
>
> Thank you
>
> Andriy Fedorov
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>
More information about the Insight-users
mailing list