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

Method doOperation

src/IECoreScene/ParticleReader.cpp:160–202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158}
159
160ObjectPtr ParticleReader::doOperation( const CompoundObject * operands )
161{
162 vector<string> attributes;
163 particleAttributes( attributes );
164 PointsPrimitivePtr result = new PointsPrimitive( numParticles() );
165 // because of percentage filtering we don't really know the number of points until we've loaded an attribute.
166 // we start off with numParticles() in case there aren't any varying attributes in the cache at all, but replace it
167 // below as soon as we have a revised (percentage filtered) value.
168 bool haveNumPoints = false;
169 for( vector<string>::const_iterator it = attributes.begin(); it!=attributes.end(); it++ )
170 {
171 DataPtr d = readAttribute( *it );
172
173 if ( testTypedData<TypeTraits::IsVectorTypedData>( d.get() ) )
174 {
175 size_t s = despatchTypedData< TypedDataSize, TypeTraits::IsVectorTypedData >( d.get() );
176 if( !haveNumPoints )
177 {
178 result->setNumPoints( s );
179 haveNumPoints = true;
180 }
181 if( s==result->getNumPoints() )
182 {
183 string primVarName = *it;
184 if( convertPrimVarNames() && primVarName == positionPrimVarName() )
185 {
186 // Current attribute is the position. Use "P" instead.
187 primVarName = "P";
188 }
189 result->variables.insert( PrimitiveVariableMap::value_type( primVarName, PrimitiveVariable( PrimitiveVariable::Vertex, d ) ) );
190 }
191 else
192 {
193 msg( Msg::Warning, "ParticleReader::doOperation", format( "Ignoring attribute \"%s\" due to insufficient elements (expected %d but found %d)." ) % *it % result->getNumPoints() % s );
194 }
195 }
196 else if ( testTypedData<TypeTraits::IsSimpleTypedData>( d.get() ) )
197 {
198 result->variables.insert( PrimitiveVariableMap::value_type( *it, PrimitiveVariable( PrimitiveVariable::Constant, d ) ) );
199 }
200 }
201 return result;
202}
203
204float ParticleReader::particlePercentage() const
205{

Callers

nothing calls this directly

Calls 8

readAttributeFunction · 0.85
PrimitiveVariableFunction · 0.85
setNumPointsMethod · 0.80
getNumPointsMethod · 0.80
insertMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected