mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Preparing for property filter. #314
Prototype code for property filter visibility Refactoring the VizLogic class to make the responsibilities clearer
This commit is contained in:
@@ -71,3 +71,95 @@ void RivFemElmVisibilityCalculator::computeRangeVisibility(cvf::UByteArray* elmV
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFemElmVisibilityCalculator::computePropertyVisibility(cvf::UByteArray* cellVisibility,
|
||||
const RigFemPart* grid,
|
||||
int timeStepIndex,
|
||||
const cvf::UByteArray* rangeFilterVisibility,
|
||||
RimGeoMechPropertyFilterCollection* propFilterColl)
|
||||
{
|
||||
#if 0
|
||||
CVF_ASSERT(cellVisibility != NULL);
|
||||
CVF_ASSERT(rangeFilterVisibility != NULL);
|
||||
CVF_ASSERT(propFilterColl != NULL);
|
||||
|
||||
CVF_ASSERT(grid->elementCount() > 0);
|
||||
CVF_ASSERT(rangeFilterVisibility->size() == grid->elementCount());
|
||||
|
||||
// Copy if not equal
|
||||
if (cellVisibility != rangeFilterVisibility ) (*cellVisibility) = *rangeFilterVisibility;
|
||||
const int elementCount = grid->elementCount();
|
||||
|
||||
if (propFilterColl->hasActiveFilters())
|
||||
{
|
||||
for (size_t i = 0; i < propFilterColl->propertyFilters().size(); i++)
|
||||
{
|
||||
RimCellPropertyFilter* propertyFilter = propFilterColl->propertyFilters()[i];
|
||||
|
||||
if (propertyFilter->isActive() && propertyFilter->resultDefinition->hasResult())
|
||||
{
|
||||
const double lowerBound = propertyFilter->lowerBound();
|
||||
const double upperBound = propertyFilter->upperBound();
|
||||
|
||||
RigFemResultAddress resVarAddress = propertyFilter->resultDefinition->resulAddress();
|
||||
|
||||
size_t adjustedTimeStepIndex = timeStepIndex;
|
||||
|
||||
// Set time step to zero for static results
|
||||
if (propertyFilter->resultDefinition()->hasStaticResult())
|
||||
{
|
||||
adjustedTimeStepIndex = 0;
|
||||
}
|
||||
|
||||
const RimCellFilter::FilterModeType filterType = propertyFilter->filterMode();
|
||||
|
||||
RigGeoMechCaseData* caseData = propFilterColl->reservoirView()->geoMechCase()->geoMechCaseData();
|
||||
|
||||
const std::vector<float>& resVals = caseData->femPartResults()->resultValues(resVarAddress, grid->elementPartId(), timeStepIndex);
|
||||
//#pragma omp parallel for schedule(dynamic)
|
||||
for (int cellIndex = 0; cellIndex < elementCount; cellIndex++)
|
||||
{
|
||||
if ( (*cellVisibility)[cellIndex] )
|
||||
{
|
||||
RigElementType eType = grid->elementType(cellIndex);
|
||||
int elmNodeCount = RigFemTypes::elmentNodeCount(eType);
|
||||
|
||||
const int* elmNodeIndices = grid->connectivities(cellIndex);
|
||||
for(int enIdx = 0; enIdx < elmNodeCount; ++enIdx)
|
||||
{
|
||||
size_t resultValueIndex = cvf::UNDEFINED_SIZE_T;
|
||||
if (resVarAddress.resultPosType == RIG_NODAL)
|
||||
{
|
||||
resultValueIndex = elmNodeIndices[enIdx];
|
||||
}
|
||||
else
|
||||
{
|
||||
resultValueIndex = grid->elementNodeResultIdx(cellIndex, enIdx);
|
||||
}
|
||||
|
||||
double scalarValue = resVals[resultValueIndex];
|
||||
if (lowerBound <= scalarValue && scalarValue <= upperBound)
|
||||
{
|
||||
if (filterType == RimCellFilter::EXCLUDE)
|
||||
{
|
||||
(*cellVisibility)[cellIndex] = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (filterType == RimCellFilter::INCLUDE)
|
||||
{
|
||||
(*cellVisibility)[cellIndex] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -27,14 +27,20 @@ namespace cvf
|
||||
}
|
||||
|
||||
class RigFemPart;
|
||||
|
||||
class RimGeoMechPropertyFilterCollection;
|
||||
|
||||
class RivFemElmVisibilityCalculator
|
||||
{
|
||||
public:
|
||||
static void computeAllVisible(cvf::UByteArray* elmVisibilities, const RigFemPart* femPart );
|
||||
static void computeRangeVisibility(cvf::UByteArray* elmVisibilities, RigFemPart* femPart, const cvf::CellRangeFilter& rangeFilter);
|
||||
static void computeRangeVisibility(cvf::UByteArray* elmVisibilities, RigFemPart* femPart,
|
||||
const cvf::CellRangeFilter& rangeFilter);
|
||||
|
||||
static void computePropertyVisibility(cvf::UByteArray* cellVisibility,
|
||||
const RigFemPart* grid,
|
||||
int timeStepIndex,
|
||||
const cvf::UByteArray* rangeFilterVisibility,
|
||||
RimGeoMechPropertyFilterCollection* propFilterColl);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user