| 158 | } |
| 159 | |
| 160 | ObjectPtr 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 | |
| 204 | float ParticleReader::particlePercentage() const |
| 205 | { |
nothing calls this directly
no test coverage detected