Files
ResInsight/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgrCache.cpp
T

100 lines
3.3 KiB
C++
Raw Normal View History

2015-05-22 17:01:59 +02:00
#include "RivGeoMechPartMgrCache.h"
#include "RivGeoMechPartMgr.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivGeoMechPartMgrCache::RivGeoMechPartMgrCache()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivGeoMechPartMgrCache::~RivGeoMechPartMgrCache()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-06-22 08:16:46 +02:00
bool RivGeoMechPartMgrCache::isNeedingRegeneration(const Key& key) const
2015-05-22 17:01:59 +02:00
{
2015-06-22 08:16:46 +02:00
std::map<Key, CacheEntry >::const_iterator ceIt = m_partMgrs.find(key);
if (ceIt != m_partMgrs.end())
{
return ceIt->second.needsRegen;
}
else
{
return true;
}
2015-05-22 17:01:59 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGeoMechPartMgrCache::scheduleRegeneration(const Key& key)
{
2015-06-22 08:16:46 +02:00
std::map<Key, CacheEntry >::iterator ceIt = m_partMgrs.find(key);
if (ceIt != m_partMgrs.end())
{
ceIt->second.needsRegen = true;
}
2015-05-22 17:01:59 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-06-22 08:16:46 +02:00
void RivGeoMechPartMgrCache::setGenerationFinished(const Key& key)
2015-05-22 17:01:59 +02:00
{
m_partMgrs[key].needsRegen = false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivGeoMechPartMgr* RivGeoMechPartMgrCache::partMgr(const Key& key)
{
CacheEntry& ce = m_partMgrs[key];
if (ce.partMgr.isNull())
{
ce.partMgr = new RivGeoMechPartMgr;
}
return ce.partMgr.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGeoMechPartMgrCache::Key::set(RivCellSetEnum aGeometryType, int aFrameIndex)
{
m_frameIndex = aFrameIndex;
m_geometryType = aGeometryType;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RivGeoMechPartMgrCache::Key::operator<(const Key& other) const
{
if (m_frameIndex != other.m_frameIndex)
{
return (m_frameIndex < other.m_frameIndex);
}
return (m_geometryType < other.m_geometryType);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivGeoMechPartMgrCache::Key::Key(RivCellSetEnum aGeometryType, int aFrameIndex)
: m_geometryType(aGeometryType), m_frameIndex(aFrameIndex)
{
}