//--------------------------------------------------------------------------------------------------
/// Returns whether any of the active property filters are based on a dynamic result
//--------------------------------------------------------------------------------------------------
bool RimEclipsePropertyFilterCollection::hasActiveDynamicFilters() const
{
    if (!active) return false;

    for (size_t i = 0; i < propertyFilters.size(); i++)
    {
        RimEclipsePropertyFilter* propertyFilter = propertyFilters[i];
        if (propertyFilter->isActive() && propertyFilter->resultDefinition->hasDynamicResult()) return true;
    }

    return false;
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
bool RimEclipsePropertyFilterCollection::isUsingFormationNames() const
{
    if ( !isActive ) return false;

    for ( size_t i = 0; i < propertyFilters.size(); i++ )
    {
        RimEclipsePropertyFilter* propertyFilter = propertyFilters[i];
        if (   propertyFilter->isActive() 
            && propertyFilter->resultDefinition->resultType() == RimDefines::FORMATION_NAMES 
            && propertyFilter->resultDefinition->resultVariable() != RimDefines::undefinedResultName()) return true;
    }

    return false;
}
예제 #3
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RivReservoirViewPartMgr::computePropertyVisibility(cvf::UByteArray* cellVisibility, const RigGridBase* grid, size_t timeStepIndex, 
    const cvf::UByteArray* rangeFilterVisibility, RimEclipsePropertyFilterCollection* propFilterColl)
{
    CVF_ASSERT(cellVisibility != nullptr);
    CVF_ASSERT(rangeFilterVisibility != nullptr);
    CVF_ASSERT(propFilterColl != nullptr);

    CVF_ASSERT(grid->cellCount() > 0);
    CVF_ASSERT(rangeFilterVisibility->size() == grid->cellCount());

    // Copy if not equal
    if (cellVisibility != rangeFilterVisibility ) (*cellVisibility) = *rangeFilterVisibility;

    if (propFilterColl->hasActiveFilters())
    {
        for (size_t i = 0; i < propFilterColl->propertyFilters().size(); i++)
        {
            RimEclipsePropertyFilter* propertyFilter = propFilterColl->propertyFilters()[i];

            if (propertyFilter->isActive() && propertyFilter->resultDefinition->hasResult())
            {
                const RimCellFilter::FilterModeType filterType = propertyFilter->filterMode();

                RigEclipseCaseData* eclipseCase = propFilterColl->reservoirView()->eclipseCase()->eclipseCaseData();

                cvf::ref<RigResultAccessor> resultAccessor = RigResultAccessorFactory::createFromResultDefinition(eclipseCase, grid->gridIndex(),  timeStepIndex, propertyFilter->resultDefinition);

                CVF_ASSERT(resultAccessor.notNull());

                if (propertyFilter->isCategorySelectionActive())
                {
                    std::vector<int> integerVector = propertyFilter->selectedCategoryValues();
                    std::set<int> integerSet;
                    for (auto val : integerVector)
                    {
                        integerSet.insert(val);
                    }

                    for (int cellIndex = 0; cellIndex < static_cast<int>(grid->cellCount()); cellIndex++)
                    {
                        if ((*cellVisibility)[cellIndex])
                        {
                            size_t resultValueIndex = cellIndex;

                            double scalarValue = resultAccessor->cellScalar(resultValueIndex);
                            if (integerSet.find(scalarValue) != integerSet.end())
                            {
                                if (filterType == RimCellFilter::EXCLUDE)
                                {
                                    (*cellVisibility)[cellIndex] = false;
                                }
                            }
                            else
                            {
                                if (filterType == RimCellFilter::INCLUDE)
                                {
                                    (*cellVisibility)[cellIndex] = false;
                                }
                            }
                        }
                    }
                }
                else
                {
                    double lowerBound = 0.0;
                    double upperBound = 0.0;
                    propertyFilter->rangeValues(&lowerBound, &upperBound);

                    for (int cellIndex = 0; cellIndex < static_cast<int>(grid->cellCount()); cellIndex++)
                    {
                        if ((*cellVisibility)[cellIndex])
                        {
                            size_t resultValueIndex = cellIndex;

                            double scalarValue = resultAccessor->cellScalar(resultValueIndex);
                            if (lowerBound <= scalarValue && scalarValue <= upperBound)
                            {
                                if (filterType == RimCellFilter::EXCLUDE)
                                {
                                    (*cellVisibility)[cellIndex] = false;
                                }
                            }
                            else
                            {
                                if (filterType == RimCellFilter::INCLUDE)
                                {
                                    (*cellVisibility)[cellIndex] = false;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}