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

Method readAttribute

src/IECoreScene/PDCParticleReader.cpp:249–371  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

247}
248
249DataPtr PDCParticleReader::readAttribute( const std::string &name )
250{
251 if( !open() )
252 {
253 return nullptr;
254 }
255
256 map<string, Record>::const_iterator it = m_header.attributes.find( name );
257 if( it==m_header.attributes.end() )
258 {
259 return nullptr;
260 }
261
262 const Data *idAttr = idAttribute();
263 if ( !idAttr && particlePercentage() < 100.0f )
264 {
265 msg( Msg::Warning, "PDCParticleReader::filterAttr", format( "Percentage filtering requested but file \"%s\" contains no particle Id attribute." ) % fileName() );
266 }
267
268 DataPtr result = nullptr;
269 switch( it->second.type )
270 {
271 case Integer :
272 {
273 IntDataPtr d( new IntData );
274 readElements( &d->writable(), it->second.position, 1 );
275 result = d;
276 }
277 break;
278 case IntegerArray :
279 {
280 IntVectorDataPtr d( new IntVectorData );
281 d->writable().resize( numParticles() );
282 readElements( &d->writable()[0], it->second.position, numParticles() );
283 result = filterAttr<IntVectorData, IntVectorData>( d.get(), particlePercentage(), idAttr );
284 }
285 break;
286 case Double :
287 {
288 DoubleDataPtr d( new DoubleData );
289 readElements( &d->writable(), it->second.position, 1 );
290 switch( realType() )
291 {
292 case PDCParticleReader::RealType::Native :
293 case PDCParticleReader::RealType::Double :
294 result = d;
295 break;
296 case PDCParticleReader::RealType::Float :
297 result = new FloatData( d->readable() );
298 break;
299 }
300 }
301 break;
302 case DoubleArray :
303 {
304 DoubleVectorDataPtr d( new DoubleVectorData );
305 d->writable().resize( numParticles() );
306 readElements( &d->writable()[0], it->second.position, numParticles() );

Callers

nothing calls this directly

Calls 6

readableMethod · 0.80
findMethod · 0.45
endMethod · 0.45
writableMethod · 0.45
resizeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected