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

Method particleAttributes

src/IECoreScene/ParticleWriter.cpp:81–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79}
80
81void ParticleWriter::particleAttributes( std::vector<std::string> &names )
82{
83 // find all attributes of the particle object with appropriate amounts of data
84 size_t numParticles = particleCount();
85 vector<string> allNames;
86 ConstPointsPrimitivePtr cd = particleObject();
87 for( PrimitiveVariableMap::const_iterator it=cd->variables.begin(); it!=cd->variables.end(); it++ )
88 {
89 if ( testTypedData<TypeTraits::IsVectorTypedData>( it->second.data.get() ) )
90 {
91 size_t s = despatchTypedData< TypedDataSize, TypeTraits::IsVectorTypedData >( it->second.data.get() );
92 if( s==numParticles )
93 {
94 allNames.push_back( it->first );
95 }
96 else
97 {
98 msg( Msg::Warning, "ParticleWriter::particleAttributes", format( "Ignoring attribute \"%s\" due to insufficient elements (expected %d but found %d)." ) % it->first % numParticles % s );
99 }
100 }
101 else if ( testTypedData<TypeTraits::IsSimpleTypedData>( it->second.data.get() ) )
102 {
103 // it's not data of a vector type but it could be of a simple type
104 // in which case it's suitable for saving as a constant particle attribute
105
106 despatchTypedData< TypedDataAddress, TypeTraits::IsSimpleTypedData >( it->second.data.get() );
107 allNames.push_back( it->first );
108 }
109 }
110
111 const StringVectorData *d = static_cast<const StringVectorData *>( parameters()->parameter<StringVectorParameter>( "attributes" )->getValue() );
112 if( !d->readable().size() )
113 {
114 names = allNames;
115 return;
116 }
117
118 names.clear();
119 for( vector<string>::const_iterator it = d->readable().begin(); it!=d->readable().end(); it++ )
120 {
121 if( find( allNames.begin(), allNames.end(), *it )!=allNames.end() )
122 {
123 names.push_back( *it );
124 }
125 else
126 {
127 msg( Msg::Warning, "ParticleWriter::particleAttributes", format( "Attribute \"%s\" requested via parameters but is not available." ) % *it );
128 }
129 }
130}

Callers

nothing calls this directly

Calls 8

findFunction · 0.85
readableMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
getMethod · 0.45
getValueMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected