Index: lib/Alembic/AbcCoreHDF5/SimplePrImpl.h |
=================================================================== |
--- a/lib/Alembic/AbcCoreHDF5/SimplePrImpl.h |
+++ b/lib/Alembic/AbcCoreHDF5/SimplePrImpl.h |
@@ -109,6 +109,9 @@ |
virtual bool getKey( index_t iSampleIndex, AbcA::ArraySampleKey & oKey ); |
protected: |
+ |
+ index_t verifySampleIndex( index_t iSampleIndex ); |
+ |
// Parent compound property writer. It must exist. |
AbcA::CompoundPropertyReaderPtr m_parent; |
@@ -198,12 +201,12 @@ |
// Validate the first and last changed index |
ABCA_ASSERT( m_firstChangedIndex <= m_numSamples && |
- m_lastChangedIndex <= m_numSamples && |
- m_firstChangedIndex <= m_lastChangedIndex, |
- "Corrupt sampling information for property: " << myName |
- << " first change index: " << m_firstChangedIndex |
- << " last change index: " << m_lastChangedIndex |
- << " total number of samples: " << m_numSamples ); |
+ m_lastChangedIndex <= m_numSamples && |
+ m_firstChangedIndex <= m_lastChangedIndex, |
+ "Corrupt sampling information for property: " << myName |
+ << " first change index: " << m_firstChangedIndex |
+ << " last change index: " << m_lastChangedIndex |
+ << " total number of samples: " << m_numSamples ); |
} |
//-***************************************************************************** |
@@ -255,6 +258,30 @@ |
//-***************************************************************************** |
template <class ABSTRACT, class IMPL, class SAMPLE> |
+index_t SimplePrImpl<ABSTRACT,IMPL,SAMPLE>::verifySampleIndex( index_t iIndex ) |
+{ |
+ // Verify sample index |
+ ABCA_ASSERT( iIndex >= 0 && |
+ iIndex < m_numSamples, |
+ "Invalid sample index: " << iIndex |
+ << ", should be between 0 and " << m_numSamples-1 ); |
+ |
+ // greater than the last index that had a change? read it from there |
+ if ( iIndex > m_lastChangedIndex ) |
+ { |
+ iIndex = m_lastChangedIndex; |
+ } |
+ // less than the first change? map to 0 |
+ else if ( iIndex < m_firstChangedIndex ) |
+ { |
+ iIndex = 0; |
+ } |
+ |
+ return iIndex; |
+} |
+ |
+//-***************************************************************************** |
+template <class ABSTRACT, class IMPL, class SAMPLE> |
std::pair<index_t, chrono_t> |
SimplePrImpl<ABSTRACT,IMPL,SAMPLE>::getFloorIndex( chrono_t iTime ) |
{ |
@@ -283,22 +310,8 @@ |
SimplePrImpl<ABSTRACT,IMPL,SAMPLE>::getSample( index_t iSampleIndex, |
SAMPLE oSample ) |
{ |
- // Verify sample index |
- ABCA_ASSERT( iSampleIndex >= 0 && |
- iSampleIndex < m_numSamples, |
- "Invalid sample index: " << iSampleIndex |
- << ", should be between 0 and " << m_numSamples-1 ); |
- // greater than the last index that had a change? read it from there |
- if ( iSampleIndex > m_lastChangedIndex ) |
- { |
- iSampleIndex = m_lastChangedIndex; |
- } |
- // less than the first change? map to 0 |
- else if ( iSampleIndex < m_firstChangedIndex ) |
- { |
- iSampleIndex = 0; |
- } |
+ iSampleIndex = verifySampleIndex( iSampleIndex ); |
// Get our name. |
const std::string &myName = m_header->getName(); |
@@ -359,25 +372,9 @@ |
template <class ABSTRACT, class IMPL, class SAMPLE> |
bool |
SimplePrImpl<ABSTRACT,IMPL,SAMPLE>::getKey( index_t iSampleIndex, |
- AbcA::ArraySampleKey & oKey ) |
+ AbcA::ArraySampleKey & oKey ) |
{ |
- // Verify sample index |
- ABCA_ASSERT( iSampleIndex >= 0 && |
- iSampleIndex < m_numSamples, |
- "Invalid sample index: " << iSampleIndex |
- << ", should be between 0 and " << m_numSamples-1 ); |
- |
- // greater than the last index that had a change? read it from there |
- if ( iSampleIndex > m_lastChangedIndex ) |
- { |
- iSampleIndex = m_lastChangedIndex; |
- } |
- // less than the first change? map to 0 |
- else if ( iSampleIndex < m_firstChangedIndex ) |
- { |
- iSampleIndex = 0; |
- } |
- |
+ iSampleIndex = verifySampleIndex( iSampleIndex ); |
// Get our name. |
const std::string &myName = m_header->getName(); |
@@ -402,8 +399,8 @@ |
} |
return static_cast<IMPL *>( this )->readKey( m_parentGroup, |
- sample0Name, |
- oKey ); |
+ sample0Name, |
+ oKey ); |
} |
else |
{ |
@@ -427,8 +424,8 @@ |
// Read the sample. |
std::string sampleName = getSampleName( myName, iSampleIndex ); |
return static_cast<IMPL *>( this )->readKey( m_samplesIGroup, |
- sampleName, |
- oKey ); |
+ sampleName, |
+ oKey ); |
} |
} |