Hello again,

I think that the method deepClone implemented in OSGFieldContainer.cpp does not 
what I'm expecting it to do.


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)      )
                {
                    dstField->shareValues(srcField);
                }
                else
                {
                    dstField->cloneValues(srcField,
                                          shareTypes,
                                          ignoreTypes,
                                          shareGroupIds,
                                          ignoreGroupIds);
                }


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.


Is this intentionally or is deepClone not correctly implemented and should use


/*! Tests if \a type is a base type 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 a base type any of the types in
        [\a begin, \a end), false otherwise.
 */
template <class InIteratorTypeT> inline
bool TypePredicates::typeBaseOf(      InIteratorTypeT  begin,
                                      InIteratorTypeT  end,
                                const OSG::TypeBase   &type  )


instead?


Any help is appreciated.

All the best,
Johannes

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

Reply via email to