Exemplo n.º 1
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RigReservoirBuilderMock::addFaults(RigEclipseCaseData* eclipseCase)
{
    if (!eclipseCase) return;

    RigMainGrid* grid = eclipseCase->mainGrid();
    if (!grid) return;

    cvf::Collection<RigFault> faults;

    {
        cvf::ref<RigFault> fault = new RigFault;
        fault->setName("Fault A");
        
        cvf::Vec3st min = cvf::Vec3st::ZERO;
        cvf::Vec3st max(0, 0, cellDimension().z() - 2);
        
        if (cellDimension().x() > 5)
        {
            min.x() = cellDimension().x() / 2;
            max.x() = min.x() + 2;
        }
        
        if (cellDimension().y() > 5)
        {
            min.y() = cellDimension().y() / 2;
            max.y() = cellDimension().y() / 2;
        }

        cvf::CellRange cellRange(min, max);

        fault->addCellRangeForFace(cvf::StructGridInterface::POS_I, cellRange);
        faults.push_back(fault.p());
    }

    grid->setFaults(faults);

    // NNCs
    std::vector<RigConnection>& nncConnections = grid->nncData()->connections();
    {
        size_t i1 = 2;
        size_t j1 = 2;
        size_t k1 = 3;
        
        size_t i2 = 2;
        size_t j2 = 3;
        size_t k2 = 4;

        addNnc(grid, i1, j1, k1, i2, j2, k2, nncConnections);
    }

    {
        size_t i1 = 2;
        size_t j1 = 2;
        size_t k1 = 3;

        size_t i2 = 2;
        size_t j2 = 1;
        size_t k2 = 4;

        addNnc(grid, i1, j1, k1, i2, j2, k2, nncConnections);
    }

    std::vector<double>& tranVals = grid->nncData()->makeStaticConnectionScalarResult(RigNNCData::propertyNameCombTrans());
    for (size_t cIdx = 0; cIdx < tranVals.size(); ++cIdx)
    {
        tranVals[cIdx] = 0.2;
    }

}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RivReservoirFaultsPartMgr::appendPartsToModel(cvf::ModelBasicList* model)
{
    CVF_ASSERT(model != NULL);

    RimFaultCollection* faultCollection = m_reservoirView->faultCollection();
    if (!faultCollection) return;

 
    bool isShowingGrid = faultCollection->isGridVisualizationMode();
    if (!faultCollection->showFaultCollection() && !isShowingGrid) return;
    
    // Check match between model fault count and fault parts
    CVF_ASSERT(faultCollection->faults.size() == m_faultParts.size());

    cvf::ModelBasicList parts;

    for (size_t i = 0; i < faultCollection->faults.size(); i++)
    {
        const RimFault* rimFault = faultCollection->faults[i];

        cvf::ref<RivFaultPartMgr> rivFaultPart = m_faultParts[i];
        CVF_ASSERT(rivFaultPart.notNull());

        // Parts that is overridden by the grid settings
        bool forceDisplayOfFault = false;
        if (!faultCollection->showFaultsOutsideFilters())
        {
            forceDisplayOfFault = isShowingGrid;
        }

        if (m_forceVisibility && isShowingGrid)
        {
            forceDisplayOfFault = true;
        }

        if ( (faultCollection->showFaultCollection() && rimFault->showFault()) || forceDisplayOfFault)
        {
            if (faultCollection->showFaultFaces() || forceDisplayOfFault)
            {
                rivFaultPart->appendNativeFaultFacesToModel(&parts);
            }

            if (faultCollection->showOppositeFaultFaces() || forceDisplayOfFault)
            {
                rivFaultPart->appendOppositeFaultFacesToModel(&parts);
            }

            if (faultCollection->showFaultFaces() || faultCollection->showOppositeFaultFaces() || faultCollection->showNNCs() || forceDisplayOfFault)
            {
                rivFaultPart->appendMeshLinePartsToModel(&parts);
            }
        }

        // Parts that is not overridden by the grid settings
        RimEclipseFaultColors* faultResultColors = m_reservoirView->faultResultSettings();
        RimEclipseCellColors* cellResultColors = m_reservoirView->cellResult();

        if (rimFault->showFault() && faultCollection->showFaultCollection())
        {
            if (faultCollection->showNNCs())
            {
                bool showNncs = true;
                if (faultCollection->hideNncsWhenNoResultIsAvailable())
                {
                    size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T;
                    if (faultResultColors->showCustomFaultResult())
                    {
                        scalarResultIndex = faultResultColors->customFaultResult()->scalarResultIndex();
                    }
                    else
                    {
                        scalarResultIndex = cellResultColors->scalarResultIndex();
                    }

                    RigMainGrid* mainGrid = m_reservoirView->eclipseCase()->reservoirData()->mainGrid();
                    if (!(mainGrid && mainGrid->nncData()->hasScalarValues(scalarResultIndex)))
                    {
                        showNncs = false;
                    }
                }

                if (showNncs)
                {
                    rivFaultPart->appendNNCFacesToModel(&parts);
                }
            }
        }
    }

    for (size_t i = 0; i < parts.partCount(); i++)
    {
        cvf::Part* part = parts.part(i);
        part->setTransform(m_scaleTransform.p());
        
        model->addPart(part);
    }
}