Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(571)

Unified Diff: lib/Alembic/AbcCoreHDF5/SimplePrImpl.h

Issue 4662068: Alembic 1.0rc1, changes since 0.9.3
Patch Set: Created 12 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/Alembic/AbcCoreHDF5/ReadWrite.h ('k') | lib/Alembic/AbcCoreHDF5/Tests/ArrayPropertyTests.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 );
}
}
« no previous file with comments | « lib/Alembic/AbcCoreHDF5/ReadWrite.h ('k') | lib/Alembic/AbcCoreHDF5/Tests/ArrayPropertyTests.cpp » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b