2013-12-03 13:30:32 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2014-09-24 00:14:52 -05:00
|
|
|
// Copyright (C) Statoil ASA
|
|
|
|
// Copyright (C) Ceetron Solutions AS
|
2018-09-21 04:43:03 -05:00
|
|
|
//
|
2013-12-03 13:30:32 -06:00
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
2018-09-21 04:43:03 -05:00
|
|
|
//
|
2013-12-03 13:30:32 -06:00
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
2018-09-21 04:43:03 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2013-12-03 13:30:32 -06:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RivFaultPartMgr.h"
|
|
|
|
|
2013-12-10 00:56:58 -06:00
|
|
|
#include "RiaApplication.h"
|
|
|
|
#include "RiaPreferences.h"
|
2013-12-03 13:30:32 -06:00
|
|
|
|
2014-08-11 07:28:32 -05:00
|
|
|
#include "RigCaseCellResultsData.h"
|
2017-01-09 12:04:45 -06:00
|
|
|
#include "RigMainGrid.h"
|
2014-08-08 09:44:21 -05:00
|
|
|
#include "RigResultAccessor.h"
|
|
|
|
|
2015-05-15 02:16:33 -05:00
|
|
|
#include "RimEclipseCase.h"
|
2015-06-25 06:32:00 -05:00
|
|
|
#include "RimEclipseCellColors.h"
|
2016-08-01 15:27:03 -05:00
|
|
|
#include "RimEclipseView.h"
|
2017-10-13 08:01:52 -05:00
|
|
|
#include "RimFaultInView.h"
|
2017-10-15 14:20:03 -05:00
|
|
|
#include "RimFaultInViewCollection.h"
|
2018-04-18 03:10:39 -05:00
|
|
|
#include "RimRegularLegendConfig.h"
|
2014-08-11 07:28:32 -05:00
|
|
|
#include "RimTernaryLegendConfig.h"
|
2013-12-10 00:56:58 -06:00
|
|
|
|
2017-02-24 06:34:25 -06:00
|
|
|
#include "RivFaultGeometryGenerator.h"
|
2019-01-15 03:53:54 -06:00
|
|
|
#include "RivMeshLinesSourceInfo.h"
|
2017-02-24 06:34:25 -06:00
|
|
|
#include "RivNNCGeometryGenerator.h"
|
2017-02-17 07:52:56 -06:00
|
|
|
#include "RivPartPriority.h"
|
2014-08-08 09:44:21 -05:00
|
|
|
#include "RivResultToTextureMapper.h"
|
2014-08-11 07:28:32 -05:00
|
|
|
#include "RivScalarMapperUtils.h"
|
|
|
|
#include "RivSourceInfo.h"
|
|
|
|
#include "RivTernaryScalarMapper.h"
|
|
|
|
#include "RivTernaryTextureCoordsCreator.h"
|
2019-01-15 03:53:54 -06:00
|
|
|
#include "RivTextLabelSourceInfo.h"
|
2014-08-11 07:28:32 -05:00
|
|
|
#include "RivTextureCoordsCreator.h"
|
2013-12-03 13:30:32 -06:00
|
|
|
|
2014-08-11 07:28:32 -05:00
|
|
|
#include "cvfDrawableGeo.h"
|
|
|
|
#include "cvfDrawableText.h"
|
|
|
|
#include "cvfModelBasicList.h"
|
|
|
|
#include "cvfPart.h"
|
|
|
|
#include "cvfPrimitiveSetDirect.h"
|
|
|
|
#include "cvfqtUtils.h"
|
2013-12-03 13:30:32 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-09-21 04:43:03 -05:00
|
|
|
///
|
2013-12-03 13:30:32 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-09-21 04:43:03 -05:00
|
|
|
RivFaultPartMgr::RivFaultPartMgr(const RigGridBase* grid,
|
|
|
|
const RimFaultInViewCollection* rimFaultCollection,
|
|
|
|
RimFaultInView* rimFault)
|
|
|
|
: m_grid(grid)
|
|
|
|
, m_rimFaultCollection(rimFaultCollection)
|
|
|
|
, m_rimFault(rimFault)
|
|
|
|
, m_opacityLevel(1.0f)
|
|
|
|
, m_defaultColor(cvf::Color3::WHITE)
|
2013-12-03 13:30:32 -06:00
|
|
|
{
|
2018-09-21 04:43:03 -05:00
|
|
|
cvf::ref<cvf::Array<size_t>> connIdxes = new cvf::Array<size_t>;
|
2013-12-14 02:45:25 -06:00
|
|
|
connIdxes->assign(rimFault->faultGeometry()->connectionIndices());
|
|
|
|
|
2018-09-21 04:43:03 -05:00
|
|
|
m_nativeFaultGenerator = new RivFaultGeometryGenerator(grid, rimFault->faultGeometry(), true);
|
|
|
|
m_oppositeFaultGenerator = new RivFaultGeometryGenerator(grid, rimFault->faultGeometry(), false);
|
2013-12-16 04:31:06 -06:00
|
|
|
|
2018-09-21 04:43:03 -05:00
|
|
|
m_NNCGenerator =
|
|
|
|
new RivNNCGeometryGenerator(grid->mainGrid()->nncData(), grid->mainGrid()->displayModelOffset(), connIdxes.p());
|
2013-12-14 02:45:25 -06:00
|
|
|
|
2018-09-21 04:43:03 -05:00
|
|
|
m_nativeFaultFacesTextureCoords = new cvf::Vec2fArray;
|
2013-12-10 00:56:58 -06:00
|
|
|
m_oppositeFaultFacesTextureCoords = new cvf::Vec2fArray;
|
2018-09-21 04:43:03 -05:00
|
|
|
m_NNCTextureCoords = new cvf::Vec2fArray;
|
2013-12-03 13:30:32 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-09-21 04:43:03 -05:00
|
|
|
///
|
2013-12-03 13:30:32 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-12-10 00:56:58 -06:00
|
|
|
void RivFaultPartMgr::setCellVisibility(cvf::UByteArray* cellVisibilities)
|
2013-12-03 13:30:32 -06:00
|
|
|
{
|
2013-12-16 04:31:06 -06:00
|
|
|
m_nativeFaultGenerator->setCellVisibility(cellVisibilities);
|
|
|
|
m_oppositeFaultGenerator->setCellVisibility(cellVisibilities);
|
2013-12-18 03:15:35 -06:00
|
|
|
m_NNCGenerator->setCellVisibility(cellVisibilities, m_grid.p());
|
2013-12-10 00:56:58 -06:00
|
|
|
|
|
|
|
generatePartGeometry();
|
2013-12-03 13:30:32 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-09-21 04:43:03 -05:00
|
|
|
///
|
2013-12-03 13:30:32 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-12-10 00:56:58 -06:00
|
|
|
void RivFaultPartMgr::applySingleColorEffect()
|
2013-12-03 13:30:32 -06:00
|
|
|
{
|
2013-12-10 00:56:58 -06:00
|
|
|
m_defaultColor = m_rimFault->faultColor();
|
2013-12-16 04:31:06 -06:00
|
|
|
this->updatePartEffect();
|
2013-12-03 13:30:32 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-09-21 04:43:03 -05:00
|
|
|
///
|
2013-12-03 13:30:32 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-06-25 07:34:20 -05:00
|
|
|
void RivFaultPartMgr::updateCellResultColor(size_t timeStepIndex, RimEclipseCellColors* cellResultColors)
|
2013-12-03 13:30:32 -06:00
|
|
|
{
|
2015-06-25 07:34:20 -05:00
|
|
|
CVF_ASSERT(cellResultColors);
|
2013-12-10 00:56:58 -06:00
|
|
|
|
2017-06-26 03:25:08 -05:00
|
|
|
updateNNCColors(timeStepIndex, cellResultColors);
|
2013-12-19 02:08:08 -06:00
|
|
|
|
2015-06-25 07:34:20 -05:00
|
|
|
RimEclipseView* eclipseView = cellResultColors->reservoirView();
|
2013-12-10 00:56:58 -06:00
|
|
|
|
|
|
|
// Faults
|
|
|
|
if (m_nativeFaultFaces.notNull())
|
2013-12-03 13:30:32 -06:00
|
|
|
{
|
2015-06-25 07:34:20 -05:00
|
|
|
if (cellResultColors->isTernarySaturationSelected())
|
2014-04-29 03:13:19 -05:00
|
|
|
{
|
2018-09-21 04:43:03 -05:00
|
|
|
RivTernaryTextureCoordsCreator texturer(cellResultColors,
|
|
|
|
cellResultColors->ternaryLegendConfig(),
|
|
|
|
timeStepIndex,
|
|
|
|
m_grid->gridIndex(),
|
|
|
|
m_nativeFaultGenerator->quadToCellFaceMapper());
|
2014-04-29 03:13:19 -05:00
|
|
|
|
2015-10-23 08:46:25 -05:00
|
|
|
texturer.createTextureCoords(m_nativeFaultFacesTextureCoords.p());
|
2014-08-11 07:28:32 -05:00
|
|
|
|
2015-10-23 08:46:25 -05:00
|
|
|
const RivTernaryScalarMapper* mapper = cellResultColors->ternaryLegendConfig()->scalarMapper();
|
2018-09-21 04:43:03 -05:00
|
|
|
RivScalarMapperUtils::applyTernaryTextureResultsToPart(m_nativeFaultFaces.p(),
|
|
|
|
m_nativeFaultFacesTextureCoords.p(),
|
|
|
|
mapper,
|
|
|
|
m_opacityLevel,
|
|
|
|
this->faceCullingMode(),
|
|
|
|
eclipseView->isLightingDisabled());
|
2015-10-23 08:46:25 -05:00
|
|
|
}
|
2013-12-17 01:07:14 -06:00
|
|
|
else
|
|
|
|
{
|
2018-09-21 04:43:03 -05:00
|
|
|
RivTextureCoordsCreator texturer(
|
|
|
|
cellResultColors, timeStepIndex, m_grid->gridIndex(), m_nativeFaultGenerator->quadToCellFaceMapper());
|
2013-12-10 00:56:58 -06:00
|
|
|
|
2015-10-23 08:46:25 -05:00
|
|
|
if (!texturer.isValid())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-08-11 04:02:16 -05:00
|
|
|
|
2014-08-08 09:44:21 -05:00
|
|
|
texturer.createTextureCoords(m_nativeFaultFacesTextureCoords.p());
|
2013-12-10 00:56:58 -06:00
|
|
|
|
2015-10-23 08:46:25 -05:00
|
|
|
const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper();
|
2018-09-21 04:43:03 -05:00
|
|
|
RivScalarMapperUtils::applyTextureResultsToPart(m_nativeFaultFaces.p(),
|
|
|
|
m_nativeFaultFacesTextureCoords.p(),
|
|
|
|
mapper,
|
|
|
|
m_opacityLevel,
|
|
|
|
this->faceCullingMode(),
|
|
|
|
eclipseView->isLightingDisabled());
|
2014-04-29 03:13:19 -05:00
|
|
|
}
|
2013-12-03 13:30:32 -06:00
|
|
|
}
|
2013-12-10 00:56:58 -06:00
|
|
|
|
|
|
|
if (m_oppositeFaultFaces.notNull())
|
|
|
|
{
|
2015-10-23 08:46:25 -05:00
|
|
|
if (cellResultColors->isTernarySaturationSelected())
|
|
|
|
{
|
2018-09-21 04:43:03 -05:00
|
|
|
RivTernaryTextureCoordsCreator texturer(cellResultColors,
|
|
|
|
cellResultColors->ternaryLegendConfig(),
|
|
|
|
timeStepIndex,
|
|
|
|
m_grid->gridIndex(),
|
|
|
|
m_oppositeFaultGenerator->quadToCellFaceMapper());
|
2015-10-23 08:46:25 -05:00
|
|
|
|
|
|
|
texturer.createTextureCoords(m_oppositeFaultFacesTextureCoords.p());
|
|
|
|
|
|
|
|
const RivTernaryScalarMapper* mapper = cellResultColors->ternaryLegendConfig()->scalarMapper();
|
2018-09-21 04:43:03 -05:00
|
|
|
RivScalarMapperUtils::applyTernaryTextureResultsToPart(m_oppositeFaultFaces.p(),
|
|
|
|
m_oppositeFaultFacesTextureCoords.p(),
|
|
|
|
mapper,
|
|
|
|
m_opacityLevel,
|
|
|
|
this->faceCullingMode(),
|
|
|
|
eclipseView->isLightingDisabled());
|
2015-10-23 08:46:25 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-09-21 04:43:03 -05:00
|
|
|
RivTextureCoordsCreator texturer(
|
|
|
|
cellResultColors, timeStepIndex, m_grid->gridIndex(), m_oppositeFaultGenerator->quadToCellFaceMapper());
|
2015-10-23 08:46:25 -05:00
|
|
|
|
|
|
|
if (!texturer.isValid())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
texturer.createTextureCoords(m_oppositeFaultFacesTextureCoords.p());
|
|
|
|
|
|
|
|
const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper();
|
2018-09-21 04:43:03 -05:00
|
|
|
RivScalarMapperUtils::applyTextureResultsToPart(m_oppositeFaultFaces.p(),
|
|
|
|
m_oppositeFaultFacesTextureCoords.p(),
|
|
|
|
mapper,
|
|
|
|
m_opacityLevel,
|
|
|
|
this->faceCullingMode(),
|
|
|
|
eclipseView->isLightingDisabled());
|
2015-10-23 08:46:25 -05:00
|
|
|
}
|
|
|
|
}
|
2013-12-03 13:30:32 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-09-21 04:43:03 -05:00
|
|
|
///
|
2013-12-03 13:30:32 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-09-21 04:43:03 -05:00
|
|
|
void RivFaultPartMgr::updateCellEdgeResultColor(size_t timeStepIndex,
|
|
|
|
RimEclipseCellColors* cellResultColors,
|
|
|
|
RimCellEdgeColors* cellEdgeResultColors)
|
2013-12-03 13:30:32 -06:00
|
|
|
{
|
2017-06-26 03:25:08 -05:00
|
|
|
updateNNCColors(timeStepIndex, cellResultColors);
|
2014-09-04 01:35:59 -05:00
|
|
|
|
2015-10-23 08:46:25 -05:00
|
|
|
if (m_nativeFaultFaces.notNull())
|
|
|
|
{
|
|
|
|
cvf::DrawableGeo* dg = dynamic_cast<cvf::DrawableGeo*>(m_nativeFaultFaces->drawable());
|
|
|
|
if (dg)
|
|
|
|
{
|
2018-09-21 04:43:03 -05:00
|
|
|
cvf::ref<cvf::Effect> eff =
|
|
|
|
RivScalarMapperUtils::createCellEdgeEffect(dg,
|
|
|
|
m_nativeFaultGenerator->quadToCellFaceMapper(),
|
|
|
|
m_grid->gridIndex(),
|
|
|
|
timeStepIndex,
|
|
|
|
cellResultColors,
|
|
|
|
cellEdgeResultColors,
|
|
|
|
m_opacityLevel,
|
|
|
|
m_defaultColor,
|
|
|
|
this->faceCullingMode(),
|
|
|
|
cellResultColors->reservoirView()->isLightingDisabled());
|
2014-08-13 03:45:09 -05:00
|
|
|
|
2015-10-23 08:46:25 -05:00
|
|
|
m_nativeFaultFaces->setEffect(eff.p());
|
|
|
|
}
|
|
|
|
}
|
2013-12-06 05:02:04 -06:00
|
|
|
|
2015-10-23 08:46:25 -05:00
|
|
|
if (m_oppositeFaultFaces.notNull())
|
|
|
|
{
|
|
|
|
cvf::DrawableGeo* dg = dynamic_cast<cvf::DrawableGeo*>(m_oppositeFaultFaces->drawable());
|
|
|
|
if (dg)
|
|
|
|
{
|
2018-09-21 04:43:03 -05:00
|
|
|
cvf::ref<cvf::Effect> eff =
|
|
|
|
RivScalarMapperUtils::createCellEdgeEffect(dg,
|
|
|
|
m_oppositeFaultGenerator->quadToCellFaceMapper(),
|
|
|
|
m_grid->gridIndex(),
|
|
|
|
timeStepIndex,
|
|
|
|
cellResultColors,
|
|
|
|
cellEdgeResultColors,
|
|
|
|
m_opacityLevel,
|
|
|
|
m_defaultColor,
|
|
|
|
this->faceCullingMode(),
|
|
|
|
cellResultColors->reservoirView()->isLightingDisabled());
|
2014-08-13 03:45:09 -05:00
|
|
|
|
2015-10-23 08:46:25 -05:00
|
|
|
m_oppositeFaultFaces->setEffect(eff.p());
|
|
|
|
}
|
|
|
|
}
|
2013-12-10 00:56:58 -06:00
|
|
|
}
|
2013-12-03 13:30:32 -06:00
|
|
|
|
2013-12-10 00:56:58 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-09-21 04:43:03 -05:00
|
|
|
///
|
2013-12-10 00:56:58 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RivFaultPartMgr::generatePartGeometry()
|
|
|
|
{
|
|
|
|
bool useBufferObjects = true;
|
|
|
|
// Surface geometry
|
2013-12-03 13:30:32 -06:00
|
|
|
{
|
2013-12-16 04:31:06 -06:00
|
|
|
cvf::ref<cvf::DrawableGeo> geo = m_nativeFaultGenerator->generateSurface();
|
2013-12-10 00:56:58 -06:00
|
|
|
if (geo.notNull())
|
2013-12-06 05:02:04 -06:00
|
|
|
{
|
2013-12-10 00:56:58 -06:00
|
|
|
geo->computeNormals();
|
2013-12-09 14:13:02 -06:00
|
|
|
|
2013-12-10 00:56:58 -06:00
|
|
|
if (useBufferObjects)
|
2013-12-09 14:13:02 -06:00
|
|
|
{
|
2013-12-10 00:56:58 -06:00
|
|
|
geo->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT);
|
2013-12-09 14:13:02 -06:00
|
|
|
}
|
|
|
|
|
2013-12-10 00:56:58 -06:00
|
|
|
cvf::ref<cvf::Part> part = new cvf::Part;
|
|
|
|
part->setName("Grid " + cvf::String(static_cast<int>(m_grid->gridIndex())));
|
|
|
|
part->setDrawable(geo.p());
|
|
|
|
|
|
|
|
// Set mapping from triangle face index to cell index
|
2018-09-21 04:43:03 -05:00
|
|
|
cvf::ref<RivSourceInfo> si = new RivSourceInfo(m_rimFault, m_grid->gridIndex());
|
2014-08-11 07:38:36 -05:00
|
|
|
si->m_cellFaceFromTriangleMapper = m_nativeFaultGenerator->triangleToCellFaceMapper();
|
2013-12-20 03:57:53 -06:00
|
|
|
part->setSourceInfo(si.p());
|
2013-12-10 00:56:58 -06:00
|
|
|
|
|
|
|
part->updateBoundingBox();
|
|
|
|
part->setEnableMask(faultBit);
|
2017-02-17 07:52:56 -06:00
|
|
|
part->setPriority(RivPartPriority::PartType::Fault);
|
2013-12-10 00:56:58 -06:00
|
|
|
|
|
|
|
m_nativeFaultFaces = part;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mesh geometry
|
|
|
|
{
|
2013-12-16 04:31:06 -06:00
|
|
|
cvf::ref<cvf::DrawableGeo> geoMesh = m_nativeFaultGenerator->createMeshDrawable();
|
2013-12-10 00:56:58 -06:00
|
|
|
if (geoMesh.notNull())
|
|
|
|
{
|
|
|
|
if (useBufferObjects)
|
2013-12-09 14:13:02 -06:00
|
|
|
{
|
2013-12-10 00:56:58 -06:00
|
|
|
geoMesh->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT);
|
2013-12-09 14:13:02 -06:00
|
|
|
}
|
|
|
|
|
2013-12-10 00:56:58 -06:00
|
|
|
cvf::ref<cvf::Part> part = new cvf::Part;
|
|
|
|
part->setName("Grid mesh" + cvf::String(static_cast<int>(m_grid->gridIndex())));
|
|
|
|
part->setDrawable(geoMesh.p());
|
|
|
|
|
|
|
|
part->updateBoundingBox();
|
|
|
|
part->setEnableMask(meshFaultBit);
|
2017-03-08 07:27:02 -06:00
|
|
|
part->setPriority(RivPartPriority::PartType::FaultMeshLines);
|
2013-12-10 00:56:58 -06:00
|
|
|
|
2018-09-21 04:36:32 -05:00
|
|
|
part->setSourceInfo(new RivMeshLinesSourceInfo(m_rimFault));
|
|
|
|
|
2013-12-10 00:56:58 -06:00
|
|
|
m_nativeFaultGridLines = part;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Surface geometry
|
|
|
|
{
|
2013-12-16 04:31:06 -06:00
|
|
|
cvf::ref<cvf::DrawableGeo> geo = m_oppositeFaultGenerator->generateSurface();
|
2013-12-10 00:56:58 -06:00
|
|
|
if (geo.notNull())
|
|
|
|
{
|
|
|
|
geo->computeNormals();
|
|
|
|
|
|
|
|
if (useBufferObjects)
|
2013-12-09 14:13:02 -06:00
|
|
|
{
|
2013-12-10 00:56:58 -06:00
|
|
|
geo->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT);
|
2013-12-09 14:13:02 -06:00
|
|
|
}
|
|
|
|
|
2013-12-10 00:56:58 -06:00
|
|
|
cvf::ref<cvf::Part> part = new cvf::Part;
|
|
|
|
part->setName("Grid " + cvf::String(static_cast<int>(m_grid->gridIndex())));
|
|
|
|
part->setDrawable(geo.p());
|
|
|
|
|
|
|
|
// Set mapping from triangle face index to cell index
|
2018-09-21 04:43:03 -05:00
|
|
|
cvf::ref<RivSourceInfo> si = new RivSourceInfo(m_rimFault, m_grid->gridIndex());
|
2014-08-11 07:38:36 -05:00
|
|
|
si->m_cellFaceFromTriangleMapper = m_oppositeFaultGenerator->triangleToCellFaceMapper();
|
2013-12-20 03:57:53 -06:00
|
|
|
part->setSourceInfo(si.p());
|
2013-12-10 00:56:58 -06:00
|
|
|
|
|
|
|
part->updateBoundingBox();
|
|
|
|
part->setEnableMask(faultBit);
|
2017-02-17 07:52:56 -06:00
|
|
|
part->setPriority(RivPartPriority::PartType::Fault);
|
2013-12-10 00:56:58 -06:00
|
|
|
|
|
|
|
m_oppositeFaultFaces = part;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mesh geometry
|
|
|
|
{
|
2013-12-16 04:31:06 -06:00
|
|
|
cvf::ref<cvf::DrawableGeo> geoMesh = m_oppositeFaultGenerator->createMeshDrawable();
|
2013-12-10 00:56:58 -06:00
|
|
|
if (geoMesh.notNull())
|
|
|
|
{
|
|
|
|
if (useBufferObjects)
|
|
|
|
{
|
|
|
|
geoMesh->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT);
|
|
|
|
}
|
|
|
|
|
|
|
|
cvf::ref<cvf::Part> part = new cvf::Part;
|
|
|
|
part->setName("Grid mesh" + cvf::String(static_cast<int>(m_grid->gridIndex())));
|
|
|
|
part->setDrawable(geoMesh.p());
|
|
|
|
|
|
|
|
part->updateBoundingBox();
|
|
|
|
part->setEnableMask(meshFaultBit);
|
2017-03-08 07:27:02 -06:00
|
|
|
part->setPriority(RivPartPriority::PartType::FaultMeshLines);
|
2013-12-10 00:56:58 -06:00
|
|
|
|
2018-09-21 04:36:32 -05:00
|
|
|
part->setSourceInfo(new RivMeshLinesSourceInfo(m_rimFault));
|
|
|
|
|
2013-12-10 00:56:58 -06:00
|
|
|
m_oppositeFaultGridLines = part;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-14 02:45:25 -06:00
|
|
|
{
|
|
|
|
cvf::ref<cvf::DrawableGeo> geo = m_NNCGenerator->generateSurface();
|
|
|
|
if (geo.notNull())
|
|
|
|
{
|
|
|
|
geo->computeNormals();
|
|
|
|
|
|
|
|
if (useBufferObjects)
|
|
|
|
{
|
|
|
|
geo->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT);
|
|
|
|
}
|
|
|
|
|
|
|
|
cvf::ref<cvf::Part> part = new cvf::Part;
|
|
|
|
part->setName("NNC in Fault. Grid " + cvf::String(static_cast<int>(m_grid->gridIndex())));
|
|
|
|
part->setDrawable(geo.p());
|
|
|
|
|
|
|
|
// Set mapping from triangle face index to cell index
|
2018-09-21 04:36:32 -05:00
|
|
|
cvf::ref<RivSourceInfo> si = new RivSourceInfo(m_rimFault, m_grid->gridIndex());
|
2018-09-21 04:43:03 -05:00
|
|
|
si->m_NNCIndices = m_NNCGenerator->triangleToNNCIndex().p();
|
2013-12-20 03:57:53 -06:00
|
|
|
part->setSourceInfo(si.p());
|
2013-12-14 02:45:25 -06:00
|
|
|
|
|
|
|
part->updateBoundingBox();
|
|
|
|
part->setEnableMask(faultBit);
|
2017-02-17 07:52:56 -06:00
|
|
|
part->setPriority(RivPartPriority::PartType::Nnc);
|
2013-12-14 02:45:25 -06:00
|
|
|
|
|
|
|
m_NNCFaces = part;
|
|
|
|
}
|
|
|
|
}
|
2018-09-21 04:43:03 -05:00
|
|
|
|
2013-12-18 05:16:03 -06:00
|
|
|
createLabelWithAnchorLine(m_nativeFaultFaces.p());
|
2013-12-10 00:56:58 -06:00
|
|
|
|
|
|
|
updatePartEffect();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-09-21 04:43:03 -05:00
|
|
|
///
|
2013-12-10 00:56:58 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RivFaultPartMgr::updatePartEffect()
|
|
|
|
{
|
|
|
|
// Set default effect
|
2013-12-19 02:08:08 -06:00
|
|
|
caf::SurfaceEffectGenerator geometryEffgen(m_defaultColor, caf::PO_1);
|
2013-12-19 01:48:36 -06:00
|
|
|
geometryEffgen.setCullBackfaces(faceCullingMode());
|
2018-09-21 04:43:03 -05:00
|
|
|
|
2015-08-13 07:35:30 -05:00
|
|
|
cvf::ref<cvf::Effect> geometryOnlyEffect = geometryEffgen.generateCachedEffect();
|
2013-12-10 00:56:58 -06:00
|
|
|
|
|
|
|
if (m_nativeFaultFaces.notNull())
|
|
|
|
{
|
|
|
|
m_nativeFaultFaces->setEffect(geometryOnlyEffect.p());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_oppositeFaultFaces.notNull())
|
|
|
|
{
|
|
|
|
m_oppositeFaultFaces->setEffect(geometryOnlyEffect.p());
|
|
|
|
}
|
|
|
|
|
2018-02-18 11:56:43 -06:00
|
|
|
updateNNCColors(0, nullptr);
|
2013-12-10 00:56:58 -06:00
|
|
|
|
|
|
|
// Update mesh colors as well, in case of change
|
|
|
|
RiaPreferences* prefs = RiaApplication::instance()->preferences();
|
|
|
|
|
2018-09-21 04:43:03 -05:00
|
|
|
cvf::ref<cvf::Effect> eff;
|
2013-12-10 00:56:58 -06:00
|
|
|
caf::MeshEffectGenerator faultEffGen(prefs->defaultFaultGridLineColors());
|
2015-08-13 07:35:30 -05:00
|
|
|
eff = faultEffGen.generateCachedEffect();
|
2013-12-10 00:56:58 -06:00
|
|
|
|
|
|
|
if (m_nativeFaultGridLines.notNull())
|
|
|
|
{
|
|
|
|
m_nativeFaultGridLines->setEffect(eff.p());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_oppositeFaultGridLines.notNull())
|
|
|
|
{
|
|
|
|
m_oppositeFaultGridLines->setEffect(eff.p());
|
|
|
|
}
|
2013-12-16 04:31:06 -06:00
|
|
|
|
|
|
|
if (m_opacityLevel < 1.0f)
|
|
|
|
{
|
|
|
|
// Set priority to make sure this transparent geometry are rendered last
|
2017-02-17 07:52:56 -06:00
|
|
|
if (m_nativeFaultFaces.notNull()) m_nativeFaultFaces->setPriority(RivPartPriority::PartType::TransparentFault);
|
|
|
|
if (m_oppositeFaultFaces.notNull()) m_oppositeFaultFaces->setPriority(RivPartPriority::PartType::TransparentFault);
|
2018-09-21 04:43:03 -05:00
|
|
|
if (m_NNCFaces.notNull()) m_NNCFaces->setPriority(RivPartPriority::PartType::TransparentNnc);
|
2014-07-01 07:28:06 -05:00
|
|
|
|
|
|
|
if (m_nativeFaultGridLines.notNull())
|
|
|
|
{
|
2017-03-08 07:27:02 -06:00
|
|
|
m_nativeFaultGridLines->setPriority(RivPartPriority::PartType::FaultMeshLines);
|
2014-07-01 07:28:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (m_oppositeFaultGridLines.notNull())
|
|
|
|
{
|
2017-03-08 07:27:02 -06:00
|
|
|
m_oppositeFaultGridLines->setPriority(RivPartPriority::PartType::FaultMeshLines);
|
2014-07-01 07:28:06 -05:00
|
|
|
}
|
2013-12-16 04:31:06 -06:00
|
|
|
}
|
2013-12-10 00:56:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-09-21 04:43:03 -05:00
|
|
|
///
|
2013-12-10 00:56:58 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RivFaultPartMgr::createLabelWithAnchorLine(const cvf::Part* part)
|
|
|
|
{
|
2018-09-21 04:43:03 -05:00
|
|
|
m_faultLabelPart = nullptr;
|
2018-02-18 11:56:43 -06:00
|
|
|
m_faultLabelLinePart = nullptr;
|
2013-12-18 05:16:03 -06:00
|
|
|
|
|
|
|
if (!part) return;
|
2013-12-10 00:56:58 -06:00
|
|
|
|
|
|
|
cvf::BoundingBox bb = part->boundingBox();
|
|
|
|
|
|
|
|
cvf::Vec3d bbTopCenter = bb.center();
|
2018-09-21 04:43:03 -05:00
|
|
|
bbTopCenter.z() = bb.max().z();
|
2013-12-10 00:56:58 -06:00
|
|
|
|
|
|
|
const cvf::DrawableGeo* geo = dynamic_cast<const cvf::DrawableGeo*>(part->drawable());
|
|
|
|
|
|
|
|
// Find closest vertex to top of bounding box.
|
|
|
|
// Will be recomputed when filter changes, to make sure the label is always visible
|
|
|
|
// for any filter combination
|
|
|
|
cvf::Vec3f faultVertexToAttachLabel = findClosestVertex(cvf::Vec3f(bbTopCenter), geo->vertexArray());
|
|
|
|
|
|
|
|
cvf::Vec3f labelPosition = faultVertexToAttachLabel;
|
|
|
|
labelPosition.z() += bb.extent().z() / 2;
|
|
|
|
|
|
|
|
// Fault label
|
2015-07-02 09:20:29 -05:00
|
|
|
if (!m_rimFault->name().isEmpty())
|
2013-12-10 00:56:58 -06:00
|
|
|
{
|
2016-08-09 06:09:08 -05:00
|
|
|
cvf::Font* font = RiaApplication::instance()->customFont();
|
2013-12-10 00:56:58 -06:00
|
|
|
|
|
|
|
cvf::ref<cvf::DrawableText> drawableText = new cvf::DrawableText;
|
2016-08-09 06:09:08 -05:00
|
|
|
drawableText->setFont(font);
|
2013-12-10 00:56:58 -06:00
|
|
|
drawableText->setCheckPosVisible(false);
|
|
|
|
drawableText->setDrawBorder(false);
|
|
|
|
drawableText->setDrawBackground(false);
|
|
|
|
drawableText->setVerticalAlignment(cvf::TextDrawer::CENTER);
|
2018-09-21 04:43:03 -05:00
|
|
|
|
2013-12-10 00:56:58 -06:00
|
|
|
cvf::Color3f defWellLabelColor = RiaApplication::instance()->preferences()->defaultWellLabelColor();
|
|
|
|
{
|
2013-12-09 14:13:02 -06:00
|
|
|
{
|
2017-10-15 14:20:03 -05:00
|
|
|
RimFaultInViewCollection* parentObject;
|
2018-09-21 04:36:32 -05:00
|
|
|
m_rimFault->firstAncestorOrThisOfType(parentObject);
|
2015-07-31 11:58:23 -05:00
|
|
|
if (parentObject)
|
|
|
|
{
|
2018-09-21 04:43:03 -05:00
|
|
|
defWellLabelColor = parentObject->faultLabelColor();
|
2015-07-31 11:58:23 -05:00
|
|
|
}
|
2013-12-09 14:13:02 -06:00
|
|
|
}
|
2013-12-06 05:02:04 -06:00
|
|
|
}
|
2013-12-10 00:56:58 -06:00
|
|
|
|
|
|
|
drawableText->setTextColor(defWellLabelColor);
|
|
|
|
|
|
|
|
cvf::String cvfString = cvfqt::Utils::toString(m_rimFault->name());
|
|
|
|
|
|
|
|
cvf::Vec3f textCoord(labelPosition);
|
2018-09-21 04:43:03 -05:00
|
|
|
double characteristicCellSize = bb.extent().z() / 20;
|
2013-12-10 00:56:58 -06:00
|
|
|
textCoord.z() += characteristicCellSize;
|
|
|
|
|
|
|
|
drawableText->addText(cvfString, textCoord);
|
|
|
|
|
2018-09-24 14:20:35 -05:00
|
|
|
cvf::ref<cvf::Part> labelPart = new cvf::Part;
|
|
|
|
labelPart->setName("RivFaultPart : text " + cvfString);
|
|
|
|
labelPart->setDrawable(drawableText.p());
|
2013-12-10 00:56:58 -06:00
|
|
|
|
|
|
|
cvf::ref<cvf::Effect> eff = new cvf::Effect;
|
|
|
|
|
2018-09-24 14:20:35 -05:00
|
|
|
labelPart->setEffect(eff.p());
|
|
|
|
labelPart->setPriority(RivPartPriority::PartType::Text);
|
2013-12-10 00:56:58 -06:00
|
|
|
|
2019-01-15 03:53:54 -06:00
|
|
|
labelPart->setSourceInfo(new RivTextLabelSourceInfo(m_rimFault, cvfString, textCoord));
|
|
|
|
|
2018-09-24 14:20:35 -05:00
|
|
|
m_faultLabelPart = labelPart;
|
2013-12-03 13:30:32 -06:00
|
|
|
}
|
|
|
|
|
2013-12-10 00:56:58 -06:00
|
|
|
// Line from fault geometry to label
|
2013-12-03 13:30:32 -06:00
|
|
|
{
|
2013-12-10 00:56:58 -06:00
|
|
|
cvf::ref<cvf::Vec3fArray> vertices = new cvf::Vec3fArray;
|
|
|
|
vertices->reserve(2);
|
|
|
|
vertices->add(faultVertexToAttachLabel);
|
|
|
|
vertices->add(labelPosition);
|
|
|
|
|
2018-09-27 13:17:56 -05:00
|
|
|
cvf::ref<cvf::DrawableGeo> lineGeo = new cvf::DrawableGeo;
|
|
|
|
lineGeo->setVertexArray(vertices.p());
|
2013-12-10 00:56:58 -06:00
|
|
|
|
|
|
|
cvf::ref<cvf::PrimitiveSetDirect> primSet = new cvf::PrimitiveSetDirect(cvf::PT_LINES);
|
|
|
|
primSet->setStartIndex(0);
|
|
|
|
primSet->setIndexCount(vertices->size());
|
2018-09-27 13:17:56 -05:00
|
|
|
lineGeo->addPrimitiveSet(primSet.p());
|
2013-12-10 00:56:58 -06:00
|
|
|
|
|
|
|
m_faultLabelLinePart = new cvf::Part;
|
|
|
|
m_faultLabelLinePart->setName("Anchor line for label" + cvf::String(static_cast<int>(m_grid->gridIndex())));
|
2018-09-27 13:17:56 -05:00
|
|
|
m_faultLabelLinePart->setDrawable(lineGeo.p());
|
2013-12-10 00:56:58 -06:00
|
|
|
|
|
|
|
m_faultLabelLinePart->updateBoundingBox();
|
|
|
|
|
|
|
|
caf::MeshEffectGenerator gen(m_rimFault->faultColor());
|
2018-09-21 04:43:03 -05:00
|
|
|
cvf::ref<cvf::Effect> eff = gen.generateCachedEffect();
|
|
|
|
|
2013-12-10 00:56:58 -06:00
|
|
|
m_faultLabelLinePart->setEffect(eff.p());
|
2013-12-03 13:30:32 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-09-21 04:43:03 -05:00
|
|
|
///
|
2013-12-03 13:30:32 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-12-10 00:56:58 -06:00
|
|
|
cvf::Vec3f RivFaultPartMgr::findClosestVertex(const cvf::Vec3f& point, const cvf::Vec3fArray* vertices)
|
2013-12-03 13:30:32 -06:00
|
|
|
{
|
2013-12-10 00:56:58 -06:00
|
|
|
CVF_ASSERT(vertices);
|
2018-09-21 04:43:03 -05:00
|
|
|
|
2013-12-10 00:56:58 -06:00
|
|
|
if (!vertices) return cvf::Vec3f::UNDEFINED;
|
|
|
|
|
|
|
|
float closestDiff(HUGE_VAL);
|
2013-12-09 14:13:02 -06:00
|
|
|
|
2013-12-10 00:56:58 -06:00
|
|
|
size_t closestIndex = cvf::UNDEFINED_SIZE_T;
|
2013-12-09 14:13:02 -06:00
|
|
|
|
2013-12-10 00:56:58 -06:00
|
|
|
for (size_t i = 0; i < vertices->size(); i++)
|
2013-12-03 13:30:32 -06:00
|
|
|
{
|
2013-12-10 00:56:58 -06:00
|
|
|
float diff = point.pointDistance(vertices->get(i));
|
|
|
|
|
|
|
|
if (diff < closestDiff)
|
|
|
|
{
|
2018-09-21 04:43:03 -05:00
|
|
|
closestDiff = diff;
|
2013-12-10 00:56:58 -06:00
|
|
|
closestIndex = i;
|
|
|
|
}
|
2013-12-03 13:30:32 -06:00
|
|
|
}
|
|
|
|
|
2013-12-10 00:56:58 -06:00
|
|
|
if (closestIndex != cvf::UNDEFINED_SIZE_T)
|
|
|
|
{
|
|
|
|
return vertices->get(closestIndex);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return cvf::Vec3f::UNDEFINED;
|
|
|
|
}
|
2013-12-03 13:30:32 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-09-21 04:43:03 -05:00
|
|
|
///
|
2013-12-03 13:30:32 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-12-10 00:56:58 -06:00
|
|
|
void RivFaultPartMgr::appendNativeFaultFacesToModel(cvf::ModelBasicList* model)
|
2013-12-03 13:30:32 -06:00
|
|
|
{
|
2013-12-10 00:56:58 -06:00
|
|
|
if (m_nativeFaultFaces.notNull())
|
2013-12-03 13:30:32 -06:00
|
|
|
{
|
2013-12-10 00:56:58 -06:00
|
|
|
model->addPart(m_nativeFaultFaces.p());
|
2013-12-03 13:30:32 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-09-21 04:43:03 -05:00
|
|
|
///
|
2013-12-03 13:30:32 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-12-10 00:56:58 -06:00
|
|
|
void RivFaultPartMgr::appendOppositeFaultFacesToModel(cvf::ModelBasicList* model)
|
2013-12-03 13:30:32 -06:00
|
|
|
{
|
2013-12-10 00:56:58 -06:00
|
|
|
if (m_oppositeFaultFaces.notNull())
|
2013-12-03 13:30:32 -06:00
|
|
|
{
|
2013-12-10 00:56:58 -06:00
|
|
|
model->addPart(m_oppositeFaultFaces.p());
|
2013-12-03 13:30:32 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-10 00:56:58 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-09-21 04:43:03 -05:00
|
|
|
///
|
2013-12-10 00:56:58 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RivFaultPartMgr::appendLabelPartsToModel(cvf::ModelBasicList* model)
|
|
|
|
{
|
2018-09-21 04:43:03 -05:00
|
|
|
if (m_faultLabelPart.notNull()) model->addPart(m_faultLabelPart.p());
|
|
|
|
if (m_faultLabelLinePart.notNull()) model->addPart(m_faultLabelLinePart.p());
|
2013-12-10 00:56:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-09-21 04:43:03 -05:00
|
|
|
///
|
2013-12-10 00:56:58 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RivFaultPartMgr::appendMeshLinePartsToModel(cvf::ModelBasicList* model)
|
|
|
|
{
|
2018-09-21 04:43:03 -05:00
|
|
|
if (m_nativeFaultGridLines.notNull()) model->addPart(m_nativeFaultGridLines.p());
|
2013-12-10 00:56:58 -06:00
|
|
|
if (m_oppositeFaultGridLines.notNull()) model->addPart(m_oppositeFaultGridLines.p());
|
|
|
|
}
|
|
|
|
|
2013-12-14 02:45:25 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-09-21 04:43:03 -05:00
|
|
|
///
|
2013-12-14 02:45:25 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RivFaultPartMgr::appendNNCFacesToModel(cvf::ModelBasicList* model)
|
|
|
|
{
|
2018-09-21 04:43:03 -05:00
|
|
|
if (m_NNCFaces.notNull()) model->addPart(m_NNCFaces.p());
|
2013-12-14 02:45:25 -06:00
|
|
|
}
|
|
|
|
|
2013-12-18 06:21:03 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-09-21 04:43:03 -05:00
|
|
|
///
|
2013-12-18 06:21:03 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2013-12-19 01:48:36 -06:00
|
|
|
caf::FaceCulling RivFaultPartMgr::faceCullingMode() const
|
|
|
|
{
|
2013-12-18 06:35:44 -06:00
|
|
|
bool isShowingGrid = m_rimFaultCollection->isGridVisualizationMode();
|
2018-09-21 04:43:03 -05:00
|
|
|
if (!isShowingGrid)
|
2013-12-18 02:21:35 -06:00
|
|
|
{
|
2017-10-15 14:20:03 -05:00
|
|
|
if (m_rimFaultCollection->faultResult() == RimFaultInViewCollection::FAULT_BACK_FACE_CULLING)
|
2013-12-18 06:35:44 -06:00
|
|
|
{
|
2014-09-23 05:24:48 -05:00
|
|
|
if (m_grid->mainGrid()->isFaceNormalsOutwards())
|
2013-12-19 01:48:36 -06:00
|
|
|
{
|
|
|
|
return caf::FC_BACK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return caf::FC_FRONT;
|
|
|
|
}
|
2013-12-18 06:35:44 -06:00
|
|
|
}
|
2017-10-15 14:20:03 -05:00
|
|
|
else if (m_rimFaultCollection->faultResult() == RimFaultInViewCollection::FAULT_FRONT_FACE_CULLING)
|
2013-12-18 06:35:44 -06:00
|
|
|
{
|
2014-09-23 05:24:48 -05:00
|
|
|
if (m_grid->mainGrid()->isFaceNormalsOutwards())
|
2013-12-19 01:48:36 -06:00
|
|
|
{
|
|
|
|
return caf::FC_FRONT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return caf::FC_BACK;
|
|
|
|
}
|
2013-12-18 06:35:44 -06:00
|
|
|
}
|
2014-01-03 01:38:09 -06:00
|
|
|
else
|
|
|
|
{
|
2018-09-21 04:43:03 -05:00
|
|
|
return caf::FC_NONE;
|
2014-01-03 01:38:09 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-08 03:47:41 -06:00
|
|
|
// Do not perform face culling in grid mode to make sure the displayed grid is watertight
|
|
|
|
return caf::FC_NONE;
|
2013-12-18 02:21:35 -06:00
|
|
|
}
|
2013-12-18 06:21:03 -06:00
|
|
|
}
|
2013-12-19 02:08:08 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-09-21 04:43:03 -05:00
|
|
|
///
|
2013-12-19 02:08:08 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-06-26 03:25:08 -05:00
|
|
|
void RivFaultPartMgr::updateNNCColors(size_t timeStepIndex, RimEclipseCellColors* cellResultColors)
|
2013-12-19 02:08:08 -06:00
|
|
|
{
|
|
|
|
if (m_NNCFaces.isNull()) return;
|
|
|
|
|
2014-09-04 02:30:00 -05:00
|
|
|
bool showNncsWithScalarMappedColor = false;
|
|
|
|
|
2017-08-04 09:30:21 -05:00
|
|
|
RimEclipseView* eclipseView = nullptr;
|
|
|
|
|
2015-06-25 07:34:20 -05:00
|
|
|
if (cellResultColors)
|
2014-09-04 02:30:00 -05:00
|
|
|
{
|
2019-01-23 09:08:25 -06:00
|
|
|
RigEclipseResultAddress eclResAddr = cellResultColors->eclipseResultAddress();
|
2014-09-04 02:30:00 -05:00
|
|
|
|
2019-01-23 09:08:25 -06:00
|
|
|
if (m_grid->mainGrid()->nncData()->hasScalarValues(eclResAddr))
|
2014-09-04 02:30:00 -05:00
|
|
|
{
|
|
|
|
showNncsWithScalarMappedColor = true;
|
|
|
|
}
|
2017-08-04 09:30:21 -05:00
|
|
|
eclipseView = cellResultColors->reservoirView();
|
2014-09-04 02:30:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (showNncsWithScalarMappedColor)
|
2013-12-19 02:08:08 -06:00
|
|
|
{
|
2019-01-23 09:08:25 -06:00
|
|
|
RigEclipseResultAddress eclResAddr = cellResultColors->eclipseResultAddress();
|
|
|
|
RiaDefines::ResultCatType resultType = cellResultColors->resultType();
|
2014-08-26 05:07:08 -05:00
|
|
|
|
2015-06-25 07:34:20 -05:00
|
|
|
const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper();
|
2018-09-21 04:43:03 -05:00
|
|
|
|
2017-10-19 02:57:10 -05:00
|
|
|
if (eclipseView)
|
|
|
|
{
|
|
|
|
RimEclipseCase* eclipseCase = eclipseView->eclipseCase();
|
|
|
|
if (eclipseCase)
|
|
|
|
{
|
|
|
|
size_t nativeTimeStepIndex = eclipseCase->uiToNativeTimeStepIndex(timeStepIndex);
|
2018-09-21 04:43:03 -05:00
|
|
|
m_NNCGenerator->textureCoordinates(
|
2019-01-23 09:08:25 -06:00
|
|
|
m_NNCTextureCoords.p(), mapper, resultType, eclResAddr, nativeTimeStepIndex);
|
2017-10-19 02:57:10 -05:00
|
|
|
}
|
|
|
|
}
|
2013-12-19 02:08:08 -06:00
|
|
|
|
|
|
|
cvf::ref<cvf::Effect> nncEffect;
|
|
|
|
|
|
|
|
if (m_rimFaultCollection->showFaultFaces || m_rimFaultCollection->showOppositeFaultFaces)
|
|
|
|
{
|
2014-01-22 06:17:05 -06:00
|
|
|
// Move NNC closer to camera to avoid z-fighting with grid surface
|
2013-12-19 02:08:08 -06:00
|
|
|
caf::ScalarMapperEffectGenerator nncEffgen(mapper, caf::PO_NEG_LARGE);
|
2017-08-04 09:30:21 -05:00
|
|
|
if (eclipseView) nncEffgen.disableLighting(eclipseView->isLightingDisabled());
|
2015-08-13 07:35:30 -05:00
|
|
|
nncEffect = nncEffgen.generateCachedEffect();
|
2013-12-19 02:08:08 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-22 06:17:05 -06:00
|
|
|
// If no grid is present, use same offset as grid geometry to be able to see mesh lines
|
|
|
|
caf::ScalarMapperEffectGenerator nncEffgen(mapper, caf::PO_1);
|
2017-08-04 09:30:21 -05:00
|
|
|
if (eclipseView) nncEffgen.disableLighting(eclipseView->isLightingDisabled());
|
2015-08-13 07:35:30 -05:00
|
|
|
nncEffect = nncEffgen.generateCachedEffect();
|
2013-12-19 02:08:08 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
cvf::DrawableGeo* dg = dynamic_cast<cvf::DrawableGeo*>(m_NNCFaces->drawable());
|
|
|
|
if (dg) dg->setTextureCoordArray(m_NNCTextureCoords.p());
|
|
|
|
|
|
|
|
m_NNCFaces->setEffect(nncEffect.p());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// NNC faces a bit lighter than the fault for now
|
|
|
|
cvf::Color3f nncColor = m_defaultColor;
|
2018-09-21 04:43:03 -05:00
|
|
|
nncColor.r() += (1.0 - nncColor.r()) * 0.2;
|
|
|
|
nncColor.g() += (1.0 - nncColor.g()) * 0.2;
|
|
|
|
nncColor.b() += (1.0 - nncColor.b()) * 0.2;
|
2013-12-19 02:08:08 -06:00
|
|
|
|
2018-03-24 08:42:30 -05:00
|
|
|
CVF_ASSERT(nncColor.isValid());
|
2013-12-19 02:08:08 -06:00
|
|
|
cvf::ref<cvf::Effect> nncEffect;
|
|
|
|
|
|
|
|
if (m_rimFaultCollection->showFaultFaces || m_rimFaultCollection->showOppositeFaultFaces)
|
|
|
|
{
|
2014-01-22 06:17:05 -06:00
|
|
|
// Move NNC closer to camera to avoid z-fighting with grid surface
|
2013-12-19 02:08:08 -06:00
|
|
|
caf::SurfaceEffectGenerator nncEffgen(nncColor, caf::PO_NEG_LARGE);
|
2015-08-13 07:35:30 -05:00
|
|
|
nncEffect = nncEffgen.generateCachedEffect();
|
2013-12-19 02:08:08 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-22 06:17:05 -06:00
|
|
|
// If no grid is present, use same offset as grid geometry to be able to see mesh lines
|
2013-12-19 02:08:08 -06:00
|
|
|
caf::SurfaceEffectGenerator nncEffgen(nncColor, caf::PO_1);
|
2015-08-13 07:35:30 -05:00
|
|
|
nncEffect = nncEffgen.generateCachedEffect();
|
2013-12-19 02:08:08 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
m_NNCFaces->setEffect(nncEffect.p());
|
|
|
|
}
|
|
|
|
}
|