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

Method scene

src/IECoreScene/LinkedScene.cpp:1327–1399  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1325}
1326
1327SceneInterfacePtr LinkedScene::scene( const Path &path, MissingBehaviour missingBehaviour )
1328{
1329 if ( missingBehaviour == SceneInterface::CreateIfMissing )
1330 {
1331 throw Exception( "createIfMissing is not supported!" );
1332 }
1333
1334 SceneInterfacePtr s = m_mainScene->scene( SceneInterface::rootPath );
1335
1336 Path::const_iterator pIt;
1337 /// first try to get as close as possible using the m_mainScene...
1338 for ( pIt = path.begin(); pIt != path.end(); pIt++ )
1339 {
1340 SceneInterfacePtr n = s->child( *pIt, SceneInterface::NullIfMissing );
1341 if ( !n )
1342 {
1343 break;
1344 }
1345 s = n;
1346 }
1347 ConstSceneInterfacePtr l = nullptr;
1348 int linkDepth = 0;
1349 bool atLink = false;
1350 bool timeRemapped = false;
1351
1352 if ( s->hasAttribute( fileNameLinkAttribute ) && s->hasAttribute( rootLinkAttribute ) )
1353 {
1354 atLink = true;
1355 timeRemapped = s->hasAttribute( timeLinkAttribute );
1356 ConstStringDataPtr fileName = runTimeCast< const StringData >( s->readAttribute( fileNameLinkAttribute, 0 ) );
1357 ConstInternedStringVectorDataPtr root = runTimeCast< const InternedStringVectorData >( s->readAttribute( rootLinkAttribute, 0 ) );
1358
1359 l = expandLink( fileName.get(), root.get(), linkDepth );
1360 if (!l)
1361 {
1362 atLink = false;
1363 timeRemapped = false;
1364 }
1365 }
1366 else if( s->hasAttribute( linkAttribute ) )
1367 {
1368 atLink = true;
1369 ConstCompoundDataPtr d = runTimeCast< const CompoundData >( s->readAttribute( linkAttribute, 0 ) );
1370 l = expandLink( d->member< const StringData >( g_fileName ), d->member< const InternedStringVectorData >( g_root ), linkDepth );
1371 if ( !l )
1372 {
1373 atLink = false;
1374 }
1375 }
1376
1377 if ( pIt != path.end() )
1378 {
1379 if ( !atLink )
1380 {
1381 if ( missingBehaviour == SceneInterface::NullIfMissing )
1382 {
1383 return nullptr;
1384 }

Callers 4

testWritingMethod · 0.95
readSavedScenesMethod · 0.95
expandLinkMethod · 0.45

Calls 7

beginMethod · 0.45
endMethod · 0.45
childMethod · 0.45
hasAttributeMethod · 0.45
readAttributeMethod · 0.45
getMethod · 0.45
valueMethod · 0.45

Tested by 3

testWritingMethod · 0.76
readSavedScenesMethod · 0.76