MCPcopy Create free account
hub / github.com/ImageEngine/cortex / writeAttribute

Method writeAttribute

src/IECoreScene/LinkedScene.cpp:665–795  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

663}
664
665void LinkedScene::writeAttribute( const Name &name, const Object *attribute, double time )
666{
667 if ( m_readOnly )
668 {
669 throw Exception( "No write access to scene file!" );
670 }
671
672 if ( name == linkAttribute )
673 {
674 bool firstTime = !m_mainScene->hasAttribute( fileNameLinkAttribute );
675
676 if ( firstTime )
677 {
678 // if it's the first time, we better check if this level already has objects, tags or children
679 // and raise exceptions to prevent weird configurations...
680 if ( m_mainScene->hasObject() )
681 {
682 throw Exception( "Links to external scenes cannot be created on locations where there's already an object saved!" );
683 }
684 }
685
686 // we are creating a link!
687 const CompoundData *d = runTimeCast< const CompoundData >(attribute);
688 if ( !d )
689 {
690 throw Exception( "SceneInterface:link attribute must be of type CompoundData!" );
691 }
692
693 // open the linked scene
694 int linkDepth;
695 ConstDoubleDataPtr timeData = d->member< const DoubleData >( g_time );
696 const StringData *fileName = d->member< const StringData >( g_fileName );
697 const InternedStringVectorData *sceneRoot = d->member< const InternedStringVectorData >( g_root );
698 m_linkedScene = expandLink( fileName, sceneRoot, linkDepth );
699 if ( !m_linkedScene )
700 {
701 throw Exception( "Trying to store a broken link!" );
702 }
703 m_rootLinkDepth = linkDepth;
704
705 // check for child name clashes:
706 NameList mainSceneChildren;
707 NameList linkedSceneChildren;
708
709 m_mainScene->childNames( mainSceneChildren );
710 m_linkedScene->childNames( linkedSceneChildren );
711 std::sort( mainSceneChildren.begin(), mainSceneChildren.end() );
712 std::sort( linkedSceneChildren.begin(), linkedSceneChildren.end() );
713
714 std::set<Name> intersection;
715 std::set_intersection(mainSceneChildren.begin(),mainSceneChildren.end(),linkedSceneChildren.begin(),linkedSceneChildren.end(), std::inserter(intersection,intersection.begin()) );
716
717 if( intersection.size() )
718 {
719 std::string intersectionString;
720 for( std::set<Name>::iterator it = intersection.begin(); it != intersection.end(); ++it )
721 {
722 intersectionString += " " + it->string();

Callers 1

~LinkedSceneMethod · 0.45

Calls 15

pathToStringFunction · 0.85
pathFunction · 0.85
readableMethod · 0.80
addPathMethod · 0.80
hasAttributeMethod · 0.45
hasObjectMethod · 0.45
childNamesMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
getMethod · 0.45
numBoundSamplesMethod · 0.45

Tested by

no test coverage detected