[Insight-users] CellInterface & PolygonCell & Region

Luis Ibanez luis.ibanez@kitware.com
Tue, 26 Nov 2002 16:10:42 -0500


Hi Ofri,

-----------------------------
1)

The AddPointId() only makes sense in a polygonal cell.
That's the reason it is not defined at the level of
the CellInterface. For memory efficiency reasons, every
cell using a static array for storing point identifiers.

The polygonal cell is the only cell with an arbitrary
number of points henceforth it requires to manage dynamic
memory.

The easy way around this is to downcast the cell pointer.
Cells return their type in the GetType() method. This method
returns an enum with a geometry type. It is defined as:

VERTEX_CELL=0,
LINE_CELL,
TRIANGLE_CELL,
QUADRILATERAL_CELL,
POLYGON_CELL,
TETRAHEDRON_CELL,
HEXAHEDRON_CELL,
QUADRATIC_EDGE_CELL,
QUADRATIC_TRIANGLE_CELL,


You can then do the following:
Since you are constructing here, you can do

PolygonType  *  pcell = new PolygonType;
pcell->AdPointId( pp );  // many times...
_polygonCellPtr.TakeOwnership( pcell );
_mesh->SetCell(0, cellptr);


If you were visiting the cells and you don't
know if all of them are polygonal cell you
could also do:


CellAutoPointer cellptr;
while(.. some condition...)
{
   mesh->GetCell( i, cellptr );
   if( cellptr->GetType() == POLYGON_CELL )
   {
   PolygonType * pcell =
      dynamic_cast< PolygonCell * >( cellptr.GetPointer() );
    pcell->AddPointId( pid ); // many times...
   }
}


You may want to look at the Mesh examples on

    Insigh/Examples/DataRepresentation/Mesh


The example on MeshCellVisitor is work in progress...


-----------------------------

2) There are plans to extend the functionality of the Mesh.

Please note that the Mesh has been less excercised than
the ITK image. It will still require some work to take it
to the same level of maturity.

All suggestions on how to improve this class are welcome.



========================================================


Thanks


   Luis


=================================

Ofri Sadowsky wrote:
> Hi,
> 
> 
>  1
> ---
> I look at the documentation for itk::CellInterface and itk::PolygonCell.
> 
> My hypothesis was, that these should have compatible interfaces, as
> PolygonCell is a case of CellInterface. But they seem to be
> incompatible: PolygonCell declares the method AddPointId() and
> CellInterface does not.
> 
> If I want to insert a PolygonCell into a Mesh, I do the following:
> 
>  typedef itk::Mesh<PixelType, VDimension> MeshType;
>  typedef MeshType::CellType CellType;
>  typedef CellType::CellAutoPointer CellAutoPointer;
>  typedef itk::PolygonCell<CellType> PolygonType;
> 
>  MeshType::Pointer _mesh;
>  CellAutoPointer _polygonCellPtr;
> 
> _mesh = MeshType::New();
>  _polygonCellPtr.TakeOwnership(new PolygonType); /* (1) */
>  _mesh->SetCell(0, cellptr);
> 
> 
> But I could not use AddPointId() on my _polygonCellPtr, because it only
> allows access to the methods of CellInterface.
> I tried to make my CellAutoPointer a itk::AutoPointer<PolygonCell>, but
> then I fell into type incompatibility in (1).
> 
> How do I get out of this?
> 
> 
> 
>  2
> ---
> the classes ImageRegion and ImageIORegion declare a public method
> IsInside() but MeshRegion does not seem to have one. I would question
> the usability of a Region object without a function of this sort.
> Furthermore, MeshRegion hardly declares any public methods. Are there
> plans to extend MeshRegion, or should I avoid using it?
> 
> 
> 
> Thanks,
> 
>    Ofri.
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-users
> 
>