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

Method loadPrimitiveVariables

src/IECoreScene/Primitive.cpp:403–457  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

401}
402
403PrimitiveVariableMap Primitive::loadPrimitiveVariables( const IndexedIO *ioInterface, const IndexedIO::EntryID &name, const IndexedIO::EntryIDList &primVarNames, const Canceller *canceller )
404{
405 IECore::Object::LoadContextPtr context = new Object::LoadContext( ioInterface->subdirectory( name )->subdirectory( g_dataEntry ), canceller );
406
407 unsigned int v = m_ioVersion;
408 ConstIndexedIOPtr container = context->container( Primitive::staticTypeName(), v );
409 if ( !container )
410 {
411 throw Exception( "Could not find Primitive entry in the file!" );
412 }
413 ConstIndexedIOPtr ioVariables = container->subdirectory( g_variablesEntry );
414
415 IndexedIO::EntryIDList names( primVarNames );
416 if( v < 2 )
417 {
418 // we changed naming convention for UVs in version 2
419 // so we must remap to the names that actually exist
420 // in the file, assuming the user request is using
421 // the new naming convention.
422 IndexedIO::EntryIDList existingNames;
423 ioVariables->entryIds( existingNames, IndexedIO::Directory );
424 remapToLegacyVariableNames( primVarNames, existingNames, names );
425 }
426
427 PrimitiveVariableMap variables;
428 for( const auto &primVarName : names )
429 {
430 ConstIndexedIOPtr ioPrimVar = ioVariables->subdirectory( primVarName, IndexedIO::NullIfMissing );
431 if ( !ioPrimVar )
432 {
433 continue;
434 }
435 int i;
436 ioPrimVar->read( g_interpolationEntry, i );
437
438 Canceller::check( canceller );
439 IntVectorDataPtr indices = nullptr;
440 if( ioPrimVar->hasEntry( g_indicesEntry ) )
441 {
442 indices = context->load<IntVectorData>( ioPrimVar.get(), g_indicesEntry );
443 }
444
445 Canceller::check( canceller );
446 variables.insert(
447 PrimitiveVariableMap::value_type( primVarName, PrimitiveVariable( (PrimitiveVariable::Interpolation)i, context->load<Data>( ioPrimVar.get(), g_dataEntry ), indices ) )
448 );
449 }
450
451 if( v < 2 )
452 {
453 ::convertLegacyVariables( variables );
454 }
455
456 return variables;
457}
458
459bool Primitive::isEqualTo( const Object *other ) const
460{

Callers

nothing calls this directly

Calls 10

PrimitiveVariableFunction · 0.85
convertLegacyVariablesFunction · 0.85
subdirectoryMethod · 0.80
containerMethod · 0.80
hasEntryMethod · 0.80
insertMethod · 0.80
entryIdsMethod · 0.45
readMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected