| 371 | } |
| 372 | |
| 373 | const Data * PDCParticleReader::idAttribute() |
| 374 | { |
| 375 | if( !open() ) |
| 376 | { |
| 377 | return nullptr; |
| 378 | } |
| 379 | if( !m_idAttribute ) |
| 380 | { |
| 381 | map<string, Record>::const_iterator it = m_header.attributes.find( "particleId" ); |
| 382 | if( it == m_header.attributes.end() ) |
| 383 | { |
| 384 | it = m_header.attributes.find( "id" ); |
| 385 | } |
| 386 | |
| 387 | if( it!=m_header.attributes.end() ) |
| 388 | { |
| 389 | if( it->second.type==DoubleArray ) |
| 390 | { |
| 391 | DoubleVectorDataPtr doubleVec = new DoubleVectorData; |
| 392 | doubleVec->writable().resize( numParticles() ); |
| 393 | readElements( &doubleVec->writable()[0], it->second.position, numParticles() ); |
| 394 | m_idAttribute = doubleVec; |
| 395 | } |
| 396 | if( it->second.type==IntegerArray ) |
| 397 | { |
| 398 | IntVectorDataPtr intVec = new IntVectorData; |
| 399 | intVec->writable().resize( numParticles() ); |
| 400 | readElements( &intVec->writable()[0], it->second.position, numParticles() ); |
| 401 | m_idAttribute = intVec; |
| 402 | } |
| 403 | } |
| 404 | } |
| 405 | return m_idAttribute.get(); |
| 406 | } |
| 407 | |
| 408 | std::string PDCParticleReader::positionPrimVarName() |
| 409 | { |