#811, #812 WIP, Formation names coloring of cells. First shot. Works but needs refinment.

This commit is contained in:
Jacob Støren
2016-09-06 10:27:30 +02:00
parent ca6e650a72
commit c903e87dfd
28 changed files with 373 additions and 50 deletions

View File

@@ -28,6 +28,7 @@
#include "RigStatisticsDataCache.h"
#include "RigFemPartResults.h"
#include "RigFemPartCollection.h"
#include "RigFormationNames.h"
#include "cafProgressInfo.h"
#include "cvfBoundingBox.h"
@@ -38,6 +39,7 @@
#include "RigFemNativeStatCalc.h"
#include "cafTensor3.h"
#include "cafProgressInfo.h"
#include "RigFemPartGrid.h"
//--------------------------------------------------------------------------------------------------
@@ -66,6 +68,21 @@ RigFemPartResultsCollection::~RigFemPartResultsCollection()
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFemPartResultsCollection::setActiveFormationNames(RigFormationNames* activeFormationNames)
{
m_activeFormationNamesData = activeFormationNames;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFormationNames* RigFemPartResultsCollection::activeFormationNames()
{
return m_activeFormationNamesData.p();
}
//--------------------------------------------------------------------------------------------------
/// Will always return a valid object, but it can be empty
@@ -151,6 +168,11 @@ std::map<std::string, std::vector<std::string> > RigFemPartResultsCollection::sc
{
std::map<std::string, std::vector<std::string> > fieldCompNames;
if (resPos == RIG_FORMATION_NAMES)
{
if (activeFormationNames()) fieldCompNames["Active Formation Names"];
}
if (m_readerInterface.notNull())
{
if (resPos == RIG_NODAL)
@@ -619,6 +641,38 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDerivedResult(in
return m_femPartResults[partIndex]->createScalarResult(resVarAddr);
}
if (resVarAddr.resultPosType == RIG_FORMATION_NAMES)
{
RigFemScalarResultFrames* resFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr);
const RigFemPart * femPart = m_femParts->part(partIndex);
std::vector<float>& dstFrameData = resFrames->frameData(0);
size_t valCount = femPart->elementNodeResultCount();
float inf = std::numeric_limits<float>::infinity();
dstFrameData.resize(valCount, inf);
RigFormationNames* activeFormNames = m_activeFormationNamesData.p();
int elementCount = femPart->elementCount();
for(int elmIdx = 0; elmIdx < elementCount; ++elmIdx)
{
RigElementType elmType = femPart->elementType(elmIdx);
int elmNodeCount = RigFemTypes::elmentNodeCount(elmType);
size_t i, j, k;
femPart->structGrid()->ijkFromCellIndex(elmIdx, &i, &j, &k);
int formNameIdx = activeFormNames->formationIndexFromKLayerIdx(k);
for(int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx)
{
size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx);
dstFrameData[elmNodResIdx] = formNameIdx;
}
}
return resFrames;
}
return NULL;
}

View File

@@ -32,6 +32,7 @@ class RigFemPartResultsCollection;
class RigFemPartResults;
class RigStatisticsDataCache;
class RigFemPartCollection;
class RigFormationNames;
class RigFemPartResultsCollection: public cvf::Object
{
@@ -39,6 +40,9 @@ public:
RigFemPartResultsCollection(RifGeoMechReaderInterface* readerInterface, const RigFemPartCollection * femPartCollection);
~RigFemPartResultsCollection();
void setActiveFormationNames(RigFormationNames* activeFormationNames);
RigFormationNames* activeFormationNames();
std::map<std::string, std::vector<std::string> > scalarFieldAndComponentNames(RigFemResultPosEnum resPos);
std::vector<std::string> stepNames();
bool assertResultsLoaded(const RigFemResultAddress& resVarAddr);
@@ -72,6 +76,7 @@ private:
cvf::Collection<RigFemPartResults> m_femPartResults;
cvf::ref<RifGeoMechReaderInterface> m_readerInterface;
cvf::cref<RigFemPartCollection> m_femParts;
cvf::ref<RigFormationNames> m_activeFormationNamesData;
RigStatisticsDataCache* statistics(const RigFemResultAddress& resVarAddr);
std::vector< RigFemResultAddress> getResAddrToComponentsToRead(const RigFemResultAddress& resVarAddr);

View File

@@ -43,7 +43,8 @@ RigFemResultAddress(RigFemResultPosEnum resPosType,
{
bool isTypeValid = resultPosType == RIG_NODAL
|| resultPosType == RIG_ELEMENT_NODAL
|| resultPosType == RIG_INTEGRATION_POINT;
|| resultPosType == RIG_INTEGRATION_POINT
|| resultPosType == RIG_FORMATION_NAMES;
bool isFieldValid = fieldName != "";
return isTypeValid && isFieldValid;
}

View File

@@ -3,5 +3,6 @@
enum RigFemResultPosEnum {
RIG_NODAL,
RIG_ELEMENT_NODAL,
RIG_INTEGRATION_POINT
RIG_INTEGRATION_POINT,
RIG_FORMATION_NAMES
};