[Fwd: Re: [Insight-developers] mesh data structure problem.]

Luis Ibanez ibanez@cs.unc.edu
Wed, 28 Feb 2001 02:12:56 -0500


Hi Ting,

Have you allocated memory for the expected number of points ?

The Mesh class has a point container (that by default is an
itkVectorContainer), it expects you to reserve space
for a number of points, before you can insert them.

Maybe trying something like:

const unsigned int myNumberOfPoints = 1000;  // any value
GetPoints()->Reserve(  myNumberOfPoints );

Then you can insert Points using  SetPoint()
and read them using GetPoint().

If you are expecting to go through all the points in a
serial way, it could be more efficient to use the iterator
or the vector container. like:

PointsContainerPointer      myPoints = GetPoints();
PointsContainer::Iterator   point    = myPoints->Begin();
PointType p;
p = 0,0,0;
while(  point != myPoints->End() )
{
    point.Value( p );
    ++point;
}



Luis


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

Ting Chen wrote:

> I write the following code in my itkDeformableMesh class:
>
> ....
>   float ds[3], d[3]={0, 0, 0};
>   SetPoint(1, (PointType)d);
>   GetPoint(1, (PointType*)ds);
> ....
>
> but I found out that ds={-1.074e+008, 0, 0} after the operation.
>
> if I do
> ....
>   float ds[3], d[3]={0, 0, 0};
>   SetPoint(0, (PointType)d);
>   GetPoint(0, (PointType*)ds);
> ....
>
> ds = {-1.074e+008, -1.074e+008, -1.074e+008}
>
> it seems the first element in the container has problems here. what is the
> problem here?
> thanks
> ting
>
> _______________________________________________
> Insight-developers mailing list
> Insight-developers@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-developers

--
______________________________________________________________________

Luis Ibanez
Research Assistant Professor - Division of Neurosurgery
University of North Carolina at Chapel Hill
CB# 7060, Chapel Hill, NC 27599
email : ibanez@cs.unc.edu       home  : http://www.cs.unc.edu/~ibanez
phone : (919)-843-9961          fax   : (919)-966-6627
______________________________________________________________________