void cloneAttachments( OSG::AttachmentContainer const *src, OSG::AttachmentContainer *dst, const std::vector<OSG::UInt16> &cloneGroupIds, const std::vector<OSG::UInt16> &ignoreGroupIds) { std::vector<const ReflexiveContainerType *> cloneTypes; std::vector<const ReflexiveContainerType *> ignoreTypes; cloneAttachments(src, dst, cloneTypes, ignoreTypes, cloneGroupIds, ignoreGroupIds); }
void cloneAttachments( OSG::AttachmentContainer const *src, OSG::AttachmentContainer *dst, const std::string &cloneTypesString, const std::string &ignoreTypesString) { std::vector<const ReflexiveContainerType *> cloneTypes; std::vector<const ReflexiveContainerType *> ignoreTypes; std::vector<UInt16> cloneGroupIds; std::vector<UInt16> ignoreGroupIds; appendTypesString(cloneTypesString, cloneTypes); appendTypesString(ignoreTypesString, ignoreTypes); cloneAttachments(src, dst, cloneTypes, ignoreTypes, cloneGroupIds, ignoreGroupIds); }
NodeTransitPtr cloneTree( const OSG::Node *rootNode, const std::vector<const OSG::ReflexiveContainerType *> &cloneTypes, const std::vector<const OSG::ReflexiveContainerType *> &ignoreTypes, const std::vector<OSG::UInt16> &cloneGroupIds, const std::vector<OSG::UInt16> &ignoreGroupIds) { NodeUnrecPtr rootClone(NULL); if(rootNode != NULL) { NodeUnrecPtr childClone; NodeCore *core = rootNode->getCore(); rootClone = Node::create(); rootClone->setTravMask(rootNode->getTravMask()); cloneAttachments(rootNode, rootClone, cloneTypes, ignoreTypes, cloneGroupIds, ignoreGroupIds); if(core != NULL) { NodeCoreUnrecPtr coreClone = NULL; const FieldContainerType &coreType = core->getType(); // test if core type should NOT be ignored if(!TypePredicates::typeInGroupIds( ignoreGroupIds.begin(), ignoreGroupIds.end(), coreType) && !TypePredicates::typeDerivedFrom( ignoreTypes.begin(), ignoreTypes.end(), coreType) ) { // test if core should cloned if(TypePredicates::typeInGroupIds ( cloneGroupIds.begin(), cloneGroupIds.end(), coreType) || TypePredicates::typeDerivedFrom( cloneTypes.begin(), cloneTypes.end(), coreType) ) { // clone core coreClone = dynamic_pointer_cast<NodeCore>( deepClone(core, cloneTypes, ignoreTypes, cloneGroupIds, ignoreGroupIds)); } else { // share core coreClone = core; } } rootClone->setCore(coreClone); } for(UInt32 i = 0; i < rootNode->getNChildren(); ++i) { childClone = cloneTree(rootNode->getChild(i), cloneTypes, ignoreTypes, cloneGroupIds, ignoreGroupIds); rootClone->addChild(childClone); } } return NodeTransitPtr(rootClone); }