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

Method readAttribute

src/IECoreScene/NParticleReader.cpp:289–410  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

287}
288
289DataPtr NParticleReader::readAttribute( const std::string &name )
290{
291 if( !open() )
292 {
293 return nullptr;
294 }
295
296 int frameIndex = m_frameParameter->getNumericValue();
297 int frame = m_frames->readable()[frameIndex];
298 std::map<int, IFFFile::Chunk::ChunkIterator>::const_iterator frameIt = frameToRootChildren.find( frame );
299 if( frameIt == frameToRootChildren.end() )
300 {
301 msg( Msg::Warning, "NParticleReader::readAttribute()", boost::format( "Frame '%d' (index '%d') does not exist in '%s'." ) % frame % frameIndex % m_iffFileName );
302 return nullptr;
303 }
304
305 bool foundAttr = false;
306 std::string channelName;
307 IFFFile::Chunk::ChunkIterator attrIt;
308 IFFFile::Chunk::ChunkIterator cache = frameIt->second;
309 IFFFile::Chunk::ChunkIterator it = cache->childrenBegin();
310
311 for ( ; it != cache->childrenEnd(); it++ )
312 {
313 if ( it->type().id() == kCHNM )
314 {
315 it->read( channelName );
316
317 if ( name.compare( channelName ) == 0 )
318 {
319 attrIt = it;
320 foundAttr = true;
321 break;
322 }
323 }
324 }
325
326 if ( !foundAttr )
327 {
328 return nullptr;
329 }
330
331 for ( it++; it < attrIt+2 && it != cache->childrenEnd(); it++ )
332 {
333 int id = it->type().id();
334 if ( id != kSIZE && id != kDBLA && id != kDVCA && id != kFVCA )
335 {
336 msg( Msg::Warning, "NParticleReader::readAttribute()", boost::format( "CHNM '%s' found, but was followed by invalid Tag '%s'." ) % name % it->type().name() );
337 return nullptr;
338 }
339 }
340
341 DataPtr result = nullptr;
342
343 int numParticles = 0;
344 (attrIt+1)->read( numParticles );
345
346 switch( (attrIt+2)->type().id() )

Callers

nothing calls this directly

Calls 13

getNumericValueMethod · 0.80
readableMethod · 0.80
childrenBeginMethod · 0.80
childrenEndMethod · 0.80
idMethod · 0.80
findMethod · 0.45
endMethod · 0.45
typeMethod · 0.45
readMethod · 0.45
nameMethod · 0.45
resizeMethod · 0.45
writableMethod · 0.45

Tested by

no test coverage detected