[Insight-users] VectorContainer, removing element

Laurent Mundeleer lmundele at ulb.ac.be
Thu, 05 Feb 2004 23:43:14 +0100


Hi Luis,

in fact I'd like to do both. The 128 elements are representing the z
coordonate of my image volume.
Brad allready send me elements of answer :
>The VectorContainer provides a DeleteIndex method to remove an element 
from one entry in seeds.  If you want to remove an entire container from
>seeds[x], then that is up to you because it is just a standard array.
>I suggest you convert seeds to look like this:
>
> std::vector< NodeContainer::Pointer > seeds;
>
>or
>
> std::set< NodeContainer::Pointer > seeds;
>
>Then there is no limit to the number of seeds and you get the STL 
container features to manage the structure.
>
>-Brad

But I'm not quite familiar with STL so I'm still looking how I'll do to
delete all a range of seeds, or a particular seed (found by a
approximation of the x,y coordinates).
For the moment it will be all the nodes for a z value, it will be easier.

Thanks for the help

Laurent

Luis Ibanez wrote:

>
>
> 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
>>>
>>>
>>
>
>
>
>


-- 
********************************************
Laurent Mundeleer
Université Libre de Bruxelles (ULB)
Service des Systèmes Logiques et Numériques (SLN) CP165/57
50, Av. F.Roosevelt
1050 Bruxelles
Belgium
tel : ++32.2.650.22.97
fax : ++32.2.650.22.98
e-mail : lmundele at ulb.ac.be
********************************************