[Insight-users] VectorContainer, removing element

Luis Ibanez luis.ibanez at kitware.com
Thu, 05 Feb 2004 16:58:26 -0500


Hi Laurent,

With:

     NodeContainer::Pointer seeds[128];

You are declaring an array of 128
SmartPointers to:

   "VectorContainer< unsigned int, NodeType >".

When you say that you want to delete some
elements from "seeds", do you mean that you
want to destroy one of the 128 entries in
this array of smart pointers ?

or, do you mean that from one of those
128 Containers you want to delete some
of its NodeType entries ?


Please let us know,


Thanks


    Luis




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

Laurent Mundeleer wrote:

> in fact I think I didn't gave you enough information, here's some code :
> ...
> 
>    typedef itk::FastMarchingImageFilter<Image2DType, Image2DType> 
> fastMarchingType;
>    typedef fastMarchingType::NodeContainer NodeContainer;
>    typedef fastMarchingType::NodeType NodeType;
> 
> ...
>    NodeContainer::Pointer seeds[128];
> ...
> void levelSetITK::addSeed(float *pos, float ratio)
> {      typedef NodeType::IndexType IndexType;
>    IndexType point;
> 
>    float ratio0 = ratio*0.969;
>    float ratio1 = ratio*0.98;
> 
>    point[0] = static_cast<IndexType::IndexValueType>( pos[0]*ratio0 );
>    point[1] = static_cast<IndexType::IndexValueType>( pos[1]*ratio1 );
>      NodeType node;
> 
>    node.SetValue( -25.0 );
>    node.SetIndex( point );
> 
>    int p = (int) pos[2];
>    seeds[p]->InsertElement( nbreSeed[p], node );
>    nbreSeed[p]++;
> }
> 
> and I'd like to remove some element from seeds.
> 
> Thanks
> 
> Laurent
> 
> Brad King wrote:
> 
>> Laurent Mundeleer wrote:
>>
>>> Hi all,
>>>
>>> I can't figure how to remove an element anywhere in a VectorContainer 
>>> (like erase(pos) in stl) ??
>>
>>
>>
>> The class derives from std::vector, so the same methods should be 
>> available.  However, you should know that itk::VectorContainer is used 
>> by itk::Image to manage memory for pixel buffers.  It is not intended 
>> to be used as a general-purpose container by user code.
>>
>> -Brad
>>
>>
>