Some small refactoring. Preparing for Derived results

This commit is contained in:
Jacob Støren 2015-06-12 11:34:03 +02:00
parent c22119e6a3
commit bd67047f57
4 changed files with 17 additions and 15 deletions

View File

@ -53,7 +53,7 @@ RigFemScalarResultFrames* RigFemPartResults::createScalarResult(const RigFemResu
{
CVF_ASSERT(m_stepNames.size());
RigFemScalarResultFrames * resFrames = new RigFemScalarResultFrames(m_stepNames);
RigFemScalarResultFrames * resFrames = new RigFemScalarResultFrames(static_cast<int>(m_stepNames.size()));
resultSets[resVarAddr] = resFrames;
return resFrames;
}

View File

@ -98,13 +98,20 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::findOrLoadScalarResult(in
CVF_ASSERT(m_readerInterface.notNull());
CVF_ASSERT(resVarAddr.isValid());
// If we have it in the cache, return it
RigFemScalarResultFrames* frames = m_femPartResults[partIndex]->findScalarResult(resVarAddr);
if (frames) return frames;
std::vector<std::string> stepNames = m_readerInterface->stepNames();
frames = m_femPartResults[partIndex]->createScalarResult(resVarAddr);
// Check whether a derived result is requested
for (int stepIndex = 0; stepIndex < static_cast<int>(stepNames.size()); ++stepIndex)
// We need to read the data as bulk fields, and populate the correct scalar caches
frames = m_femPartResults[partIndex]->createScalarResult(resVarAddr);
int frameCount = this->frameCount();
for (int stepIndex = 0; stepIndex < frameCount; ++stepIndex)
{
std::vector<double > frameTimes = m_readerInterface->frameTimes(stepIndex);

View File

@ -25,10 +25,9 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemScalarResultFrames::RigFemScalarResultFrames(const std::vector<std::string>& frameNames)
: m_frameNames(frameNames)
RigFemScalarResultFrames::RigFemScalarResultFrames(int frameCount)
{
m_dataForEachFrame.resize(m_frameNames.size());
m_dataForEachFrame.resize(frameCount);
}
//--------------------------------------------------------------------------------------------------
@ -42,9 +41,9 @@ RigFemScalarResultFrames::~RigFemScalarResultFrames()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigFemScalarResultFrames::frameCount()
int RigFemScalarResultFrames::frameCount()
{
return m_frameNames.size();
return static_cast<int>(m_dataForEachFrame.size());
}

View File

@ -30,16 +30,12 @@ class RigStatisticsDataCache;
class RigFemScalarResultFrames: public cvf::Object
{
public:
RigFemScalarResultFrames(const std::vector<std::string>& frameNames);
RigFemScalarResultFrames(int frameCount);
virtual ~RigFemScalarResultFrames();
std::vector<float>& frameData(size_t frameIndex);
size_t frameCount();
int frameCount();
private:
std::vector< std::vector<float> > m_dataForEachFrame;
std::vector<std::string> m_frameNames;
};