[Insight-users] Data Representation Objects
Luis Ibanez
luis.ibanez@kitware.com
Thu, 21 Nov 2002 17:08:09 -0500
Hi Ofri,
Ofri Sadowsky wrote:
>>From looking at the code, it seems that you can update the PointSet of a Mesh in any
> way, regardless of cells etc. See PointSet::SetPoint() and PointSet::SetPoints(). All
> that happens there is PointSet calling Modified().
You are right here. The actual risk of breaking consistency
on the Mesh is the same when the SetPoints() is invoked with
a new container. So, it probably doesn't make sense to restrict
the use of the std::vector. It will be the user's responsibility
to take care of maintain consistency when points or cells are
accessed through an STL adaptor.
>
> The first adapter calls Modified() when it's destroyed, and thus guarantees that
> afterwards all the necessary notifications were sent. Still, you can modify the
> non-const vector that you obtained from the Adapter and try to access the cells without
> the PointSet::Modified().
> That is not so wise, bu it's possible. However, as long as you separate vector
> modification from accessing the cells by at least a {block},
> Modified() wil be called automatically.
>
I like the invokation of Modified() in the adaptor destructor.
It seems to be a reasonable thing to do.
>
> As for the const reference, it's possible to follow your direction. I added the
> STLConstVectorAdapter for consistency with the STLVectorAdapter. But it's possible, and
> maybe simpler, to do without.
>
Const is good !
I think it is important to have the const version of the adaptor.
How about making the Adaptor a class in itself as opposed
to a class inside the Container ?
It could be templated over the container type and just get
the trait: STLContainerType. In this way the same adapter
could be used for itk::VectorContainer and itk::MapContainer.
That will facilitate a lot the maintenance of the classes.
How about "STLContainerAdaptor":
template <typename TContainer>
class STLContainerAdaptor {
typedef typename TContainer::STLContainerType STLContainerType;
....
// . your code
}
Thanks
Luis