Hello Johannes,

On Wed, Mar 10, 2021 at 1:08 PM Johannes Brunen <jbru...@datasolid.de>
wrote:
> Say I have a container with a material field (MaterialGroup) in it and I
want that my special material (MyMaterial) must not to be deep cloned but
shared. So I provide myMaterial to the shareTypes parameter of the
deepClone method.
>
>
> deepClone checks for each of the fields of the given 'src' container the
following in order to decide if the field is to be cloned or shared:
>
>
>                 // check if type should by shared
>
>                 if(TypePredicates::typeInGroupIds(
>                         shareGroupIds.begin(),
>                         shareGroupIds.end  (), *rcType) ||
>                    TypePredicates::typeDerivedFrom(
>                         shareTypes.begin(),
>                         shareTypes.end  (), *rcType)      )

the way I'm reading this, it means if the field we are looking at is
derived from any of the types in shareTypes it gets shared, which sounds
correct to me.

> Now the function TypePredicates::typeDerivedFrom states
>
>
> /*! Tests if \a type is derived from any of the types in the sequence
>     specified by [\a begin, \a end). The sequence must consist of pointers
>     to TypeBase objects (or a derived class), e.g.
>     std::vector\<const FieldContainerType *\>.
>
>     \param[in] begin Start of sequence.
>     \param[in] end End of sequence.
>     \param[in] type Type that is tested.
>     \return true, if \a type is derived from any of the types in
>         [\a begin, \a end), false otherwise.
>  */
> template <class InIteratorTypeT> inline
> bool TypePredicates::typeDerivedFrom(      InIteratorTypeT  begin,
>                                            InIteratorTypeT  end,
>                                      const OSG::TypeBase   &type  )
>
>
> In my case MyMaterial is derived from Material but the test gives only
true if Material would be derived from MyMaterial what is not the case.

I'm not following this reasoning; I think I'm overlooking something, sorry.
If you put MyMaterial's type into the list, other Materials should not be
shared, but MyMaterials (and types derived from MyMaterial) should be
shared; at least I believe that was the idea modulo bugs.

Cheers,
Carsten
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to