Renamed to RivFaultPartMgr

This commit is contained in:
Magne Sjaastad
2013-12-10 07:56:58 +01:00
parent 07cac1367c
commit 48d63495e5
9 changed files with 759 additions and 760 deletions

View File

@@ -7,13 +7,13 @@ endif()
set (SOURCE_GROUP_HEADER_FILES
${CEE_CURRENT_LIST_DIR}RivCellEdgeEffectGenerator.h
${CEE_CURRENT_LIST_DIR}RivColorTableArray.h
${CEE_CURRENT_LIST_DIR}RivFaultPart.h
${CEE_CURRENT_LIST_DIR}RivFaultPartMgr.h
${CEE_CURRENT_LIST_DIR}RivFaultGeometryGenerator.h
${CEE_CURRENT_LIST_DIR}RivGridPartMgr.h
${CEE_CURRENT_LIST_DIR}RivReservoirPartMgr.h
${CEE_CURRENT_LIST_DIR}RivReservoirViewPartMgr.h
${CEE_CURRENT_LIST_DIR}RivPipeGeometryGenerator.h
${CEE_CURRENT_LIST_DIR}RivReservoirFaultsPartMgr.h
${CEE_CURRENT_LIST_DIR}RivReservoirPipesPartMgr.h
${CEE_CURRENT_LIST_DIR}RivWellPathPartMgr.h
${CEE_CURRENT_LIST_DIR}RivWellPathCollectionPartMgr.h
@@ -24,10 +24,10 @@ ${CEE_CURRENT_LIST_DIR}RivWellHeadPartMgr.h
set (SOURCE_GROUP_SOURCE_FILES
${CEE_CURRENT_LIST_DIR}RivCellEdgeEffectGenerator.cpp
${CEE_CURRENT_LIST_DIR}RivColorTableArray.cpp
${CEE_CURRENT_LIST_DIR}RivFaultPart.cpp
${CEE_CURRENT_LIST_DIR}RivFaultPartMgr.cpp
${CEE_CURRENT_LIST_DIR}RivFaultGeometryGenerator.cpp
${CEE_CURRENT_LIST_DIR}RivGridPartMgr.cpp
${CEE_CURRENT_LIST_DIR}RivReservoirFaultsPartMgr.cpp
${CEE_CURRENT_LIST_DIR}RivReservoirPartMgr.cpp
${CEE_CURRENT_LIST_DIR}RivReservoirViewPartMgr.cpp
${CEE_CURRENT_LIST_DIR}RivPipeGeometryGenerator.cpp

View File

@@ -1,548 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Statoil ASA, Ceetron Solutions AS
//
// 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.
//
// 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.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RivFaultPart.h"
#include "cvfPart.h"
#include "cafEffectGenerator.h"
#include "cvfStructGrid.h"
#include "cvfDrawableGeo.h"
#include "cvfModelBasicList.h"
#include "RivCellEdgeEffectGenerator.h"
#include "RimReservoirView.h"
#include "RimResultSlot.h"
#include "RimCellEdgeResultSlot.h"
#include "RigCaseCellResultsData.h"
#include "RigCaseData.h"
#include "RiaApplication.h"
#include "RiaPreferences.h"
#include "RimCase.h"
#include "RimWellCollection.h"
#include "cafPdmFieldCvfMat4d.h"
#include "cafPdmFieldCvfColor.h"
#include "RimCellRangeFilterCollection.h"
#include "RimCellPropertyFilterCollection.h"
#include "Rim3dOverlayInfoConfig.h"
#include "RimReservoirCellResultsCacher.h"
#include "cvfDrawableText.h"
#include "cvfqtUtils.h"
#include "cvfPrimitiveSetIndexedUInt.h"
#include "cvfPrimitiveSetDirect.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivFaultPartMgr::RivFaultPartMgr(const RigGridBase* grid, const RimFault* rimFault)
: m_grid(grid),
m_rimFault(rimFault),
m_opacityLevel(1.0f),
m_defaultColor(cvf::Color3::WHITE),
m_nativeFaultGenerator(grid, rimFault->faultGeometry(), true),
m_oppositeFaultGenerator(grid, rimFault->faultGeometry(), false)
{
m_nativeFaultFacesTextureCoords = new cvf::Vec2fArray;
m_oppositeFaultFacesTextureCoords = new cvf::Vec2fArray;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::setCellVisibility(cvf::UByteArray* cellVisibilities)
{
m_nativeFaultGenerator.setCellVisibility(cellVisibilities);
m_oppositeFaultGenerator.setCellVisibility(cellVisibilities);
generatePartGeometry();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::applySingleColorEffect()
{
m_defaultColor = m_rimFault->faultColor();
// Set default effect
caf::SurfaceEffectGenerator geometryEffgen(m_defaultColor, true);
cvf::ref<cvf::Effect> geometryOnlyEffect = geometryEffgen.generateEffect();
if (m_nativeFaultFaces.notNull()) m_nativeFaultFaces->setEffect(geometryOnlyEffect.p());
if (m_oppositeFaultFaces.notNull()) m_oppositeFaultFaces->setEffect(geometryOnlyEffect.p());
if (m_opacityLevel < 1.0f)
{
// Set priority to make sure this transparent geometry are rendered last
if (m_nativeFaultFaces.notNull()) m_nativeFaultFaces->setPriority(100);
if (m_oppositeFaultFaces.notNull()) m_oppositeFaultFaces->setPriority(100);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot)
{
CVF_ASSERT(cellResultSlot);
size_t scalarSetIndex = cellResultSlot->gridScalarIndex();
const cvf::ScalarMapper* mapper = cellResultSlot->legendConfig()->scalarMapper();
// If the result is static, only read that.
size_t resTimeStepIdx = timeStepIndex;
if (cellResultSlot->hasStaticResult()) resTimeStepIdx = 0;
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel());
RigCaseData* eclipseCase = cellResultSlot->reservoirView()->eclipseCase()->reservoirData();
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObject = eclipseCase->dataAccessObject(m_grid.p(), porosityModel, resTimeStepIdx, scalarSetIndex);
if (dataAccessObject.isNull()) return;
// Faults
if (m_nativeFaultFaces.notNull())
{
m_nativeFaultGenerator.textureCoordinates(m_nativeFaultFacesTextureCoords.p(), dataAccessObject.p(), mapper);
if (m_opacityLevel < 1.0f )
{
const std::vector<cvf::ubyte>& isWellPipeVisible = cellResultSlot->reservoirView()->wellCollection()->isWellPipesVisible(timeStepIndex);
cvf::ref<cvf::UIntArray> gridCellToWellindexMap = eclipseCase->gridCellToWellIndex(m_grid->gridIndex());
const std::vector<size_t>& quadsToGridCells = m_nativeFaultGenerator.quadToGridCellIndices();
for(size_t i = 0; i < m_nativeFaultFacesTextureCoords->size(); ++i)
{
if ((*m_nativeFaultFacesTextureCoords)[i].y() == 1.0f) continue; // Do not touch undefined values
size_t quadIdx = i/4;
size_t cellIndex = quadsToGridCells[quadIdx];
cvf::uint wellIndex = gridCellToWellindexMap->get(cellIndex);
if (wellIndex != cvf::UNDEFINED_UINT)
{
if ( !isWellPipeVisible[wellIndex])
{
(*m_nativeFaultFacesTextureCoords)[i].y() = 0; // Set the Y texture coordinate to the opaque line in the texture
}
}
}
}
cvf::DrawableGeo* dg = dynamic_cast<cvf::DrawableGeo*>(m_nativeFaultFaces->drawable());
if (dg) dg->setTextureCoordArray(m_nativeFaultFacesTextureCoords.p());
bool usePolygonOffset = true;
caf::ScalarMapperEffectGenerator scalarEffgen(mapper, usePolygonOffset);
scalarEffgen.setOpacityLevel(m_opacityLevel);
cvf::ref<cvf::Effect> scalarEffect = scalarEffgen.generateEffect();
m_nativeFaultFaces->setEffect(scalarEffect.p());
}
if (m_oppositeFaultFaces.notNull())
{
m_oppositeFaultGenerator.textureCoordinates(m_oppositeFaultFacesTextureCoords.p(), dataAccessObject.p(), mapper);
if (m_opacityLevel < 1.0f )
{
const std::vector<cvf::ubyte>& isWellPipeVisible = cellResultSlot->reservoirView()->wellCollection()->isWellPipesVisible(timeStepIndex);
cvf::ref<cvf::UIntArray> gridCellToWellindexMap = eclipseCase->gridCellToWellIndex(m_grid->gridIndex());
const std::vector<size_t>& quadsToGridCells = m_oppositeFaultGenerator.quadToGridCellIndices();
for(size_t i = 0; i < m_oppositeFaultFacesTextureCoords->size(); ++i)
{
if ((*m_oppositeFaultFacesTextureCoords)[i].y() == 1.0f) continue; // Do not touch undefined values
size_t quadIdx = i/4;
size_t cellIndex = quadsToGridCells[quadIdx];
cvf::uint wellIndex = gridCellToWellindexMap->get(cellIndex);
if (wellIndex != cvf::UNDEFINED_UINT)
{
if ( !isWellPipeVisible[wellIndex])
{
(*m_oppositeFaultFacesTextureCoords)[i].y() = 0; // Set the Y texture coordinate to the opaque line in the texture
}
}
}
}
cvf::DrawableGeo* dg = dynamic_cast<cvf::DrawableGeo*>(m_oppositeFaultFaces->drawable());
if (dg) dg->setTextureCoordArray(m_oppositeFaultFacesTextureCoords.p());
bool usePolygonOffset = true;
caf::ScalarMapperEffectGenerator scalarEffgen(mapper, usePolygonOffset);
scalarEffgen.setOpacityLevel(m_opacityLevel);
cvf::ref<cvf::Effect> scalarEffect = scalarEffgen.generateEffect();
m_oppositeFaultFaces->setEffect(scalarEffect.p());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::updateCellEdgeResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot, RimCellEdgeResultSlot* cellEdgeResultSlot)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::generatePartGeometry()
{
bool useBufferObjects = true;
// Surface geometry
{
cvf::ref<cvf::DrawableGeo> geo = m_nativeFaultGenerator.generateSurface();
if (geo.notNull())
{
geo->computeNormals();
if (useBufferObjects)
{
geo->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT);
}
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName("Grid " + cvf::String(static_cast<int>(m_grid->gridIndex())));
part->setId(m_grid->gridIndex()); // !! For now, use grid index as part ID (needed for pick info)
part->setDrawable(geo.p());
// Set mapping from triangle face index to cell index
part->setSourceInfo(m_nativeFaultGenerator.triangleToSourceGridCellMap().p());
part->updateBoundingBox();
part->setEnableMask(faultBit);
m_nativeFaultFaces = part;
}
}
// Mesh geometry
{
cvf::ref<cvf::DrawableGeo> geoMesh = m_nativeFaultGenerator.createMeshDrawable();
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);
m_nativeFaultGridLines = part;
}
}
// Surface geometry
{
cvf::ref<cvf::DrawableGeo> geo = m_oppositeFaultGenerator.generateSurface();
if (geo.notNull())
{
geo->computeNormals();
if (useBufferObjects)
{
geo->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT);
}
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName("Grid " + cvf::String(static_cast<int>(m_grid->gridIndex())));
part->setId(m_grid->gridIndex()); // !! For now, use grid index as part ID (needed for pick info)
part->setDrawable(geo.p());
// Set mapping from triangle face index to cell index
part->setSourceInfo(m_oppositeFaultGenerator.triangleToSourceGridCellMap().p());
part->updateBoundingBox();
part->setEnableMask(faultBit);
m_oppositeFaultFaces = part;
}
}
// Mesh geometry
{
cvf::ref<cvf::DrawableGeo> geoMesh = m_oppositeFaultGenerator.createMeshDrawable();
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);
m_oppositeFaultGridLines = part;
}
}
m_faultLabelPart = NULL;
{
cvf::ref<cvf::Part> partToAttachLabelTo;
if (m_nativeFaultFaces.notNull())
{
partToAttachLabelTo = m_nativeFaultFaces;
}
else if(m_oppositeFaultFaces.notNull())
{
partToAttachLabelTo = m_oppositeFaultFaces;
}
if (partToAttachLabelTo.notNull())
{
createLabelWithAnchorLine(partToAttachLabelTo.p());
}
}
updatePartEffect();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::updatePartEffect()
{
cvf::Color3f partColor = m_defaultColor;
// Set default effect
caf::SurfaceEffectGenerator geometryEffgen(partColor, true);
cvf::ref<cvf::Effect> geometryOnlyEffect = geometryEffgen.generateEffect();
if (m_nativeFaultFaces.notNull())
{
m_nativeFaultFaces->setEffect(geometryOnlyEffect.p());
}
if (m_oppositeFaultFaces.notNull())
{
m_oppositeFaultFaces->setEffect(geometryOnlyEffect.p());
}
// Update mesh colors as well, in case of change
RiaPreferences* prefs = RiaApplication::instance()->preferences();
cvf::ref<cvf::Effect> eff;
caf::MeshEffectGenerator faultEffGen(prefs->defaultFaultGridLineColors());
eff = faultEffGen.generateEffect();
if (m_nativeFaultGridLines.notNull())
{
m_nativeFaultGridLines->setEffect(eff.p());
}
if (m_oppositeFaultGridLines.notNull())
{
m_oppositeFaultGridLines->setEffect(eff.p());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::createLabelWithAnchorLine(const cvf::Part* part)
{
CVF_ASSERT(part);
cvf::BoundingBox bb = part->boundingBox();
cvf::Vec3d bbTopCenter = bb.center();
bbTopCenter.z() = bb.max().z();
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
{
cvf::Font* standardFont = RiaApplication::instance()->standardFont();
cvf::ref<cvf::DrawableText> drawableText = new cvf::DrawableText;
drawableText->setFont(standardFont);
drawableText->setCheckPosVisible(false);
drawableText->setDrawBorder(false);
drawableText->setDrawBackground(false);
drawableText->setVerticalAlignment(cvf::TextDrawer::CENTER);
cvf::Color3f defWellLabelColor = RiaApplication::instance()->preferences()->defaultWellLabelColor();
{
std::vector<RimFaultCollection*> parentObjects;
m_rimFault->parentObjectsOfType(parentObjects);
if (parentObjects.size() > 0)
{
defWellLabelColor = parentObjects[0]->faultLabelColor();;
}
}
drawableText->setTextColor(defWellLabelColor);
cvf::String cvfString = cvfqt::Utils::toString(m_rimFault->name());
cvf::Vec3f textCoord(labelPosition);
double characteristicCellSize = bb.extent().z() / 20;
textCoord.z() += characteristicCellSize;
drawableText->addText(cvfString, textCoord);
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName("RivFaultPart : text " + cvfString);
part->setDrawable(drawableText.p());
cvf::ref<cvf::Effect> eff = new cvf::Effect;
part->setEffect(eff.p());
part->setPriority(1000);
m_faultLabelPart = part;
}
// Line from fault geometry to label
{
cvf::ref<cvf::Vec3fArray> vertices = new cvf::Vec3fArray;
vertices->reserve(2);
vertices->add(faultVertexToAttachLabel);
vertices->add(labelPosition);
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
geo->setVertexArray(vertices.p());
cvf::ref<cvf::PrimitiveSetDirect> primSet = new cvf::PrimitiveSetDirect(cvf::PT_LINES);
primSet->setStartIndex(0);
primSet->setIndexCount(vertices->size());
geo->addPrimitiveSet(primSet.p());
m_faultLabelLinePart = new cvf::Part;
m_faultLabelLinePart->setName("Anchor line for label" + cvf::String(static_cast<int>(m_grid->gridIndex())));
m_faultLabelLinePart->setDrawable(geo.p());
m_faultLabelLinePart->updateBoundingBox();
caf::MeshEffectGenerator gen(m_rimFault->faultColor());
cvf::ref<cvf::Effect> eff = gen.generateEffect();
m_faultLabelLinePart->setEffect(eff.p());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3f RivFaultPartMgr::findClosestVertex(const cvf::Vec3f& point, const cvf::Vec3fArray* vertices)
{
CVF_ASSERT(vertices);
if (!vertices) return cvf::Vec3f::UNDEFINED;
float closestDiff(HUGE_VAL);
size_t closestIndex = cvf::UNDEFINED_SIZE_T;
for (size_t i = 0; i < vertices->size(); i++)
{
float diff = point.pointDistance(vertices->get(i));
if (diff < closestDiff)
{
closestDiff = diff;
closestIndex = i;
}
}
if (closestIndex != cvf::UNDEFINED_SIZE_T)
{
return vertices->get(closestIndex);
}
else
{
return cvf::Vec3f::UNDEFINED;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::appendNativeFaultFacesToModel(cvf::ModelBasicList* model)
{
if (m_nativeFaultFaces.notNull())
{
model->addPart(m_nativeFaultFaces.p());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::appendOppositeFaultFacesToModel(cvf::ModelBasicList* model)
{
if (m_oppositeFaultFaces.notNull())
{
model->addPart(m_oppositeFaultFaces.p());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::appendLabelPartsToModel(cvf::ModelBasicList* model)
{
if (m_faultLabelPart.notNull()) model->addPart(m_faultLabelPart.p());
if (m_faultLabelLinePart.notNull()) model->addPart(m_faultLabelLinePart.p());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::appendMeshLinePartsToModel(cvf::ModelBasicList* model)
{
if (m_nativeFaultGridLines.notNull()) model->addPart(m_nativeFaultGridLines.p());
if (m_oppositeFaultGridLines.notNull()) model->addPart(m_oppositeFaultGridLines.p());
}

View File

@@ -1,94 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Statoil ASA, Ceetron Solutions AS
//
// 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.
//
// 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.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "RigGridBase.h"
#include "RimFault.h"
#include "RivFaultGeometryGenerator.h"
#include "cvfColor4.h"
namespace cvf
{
class StructGridInterface;
class ModelBasicList;
class Transform;
class Part;
}
class RimResultSlot;
class RimCellEdgeResultSlot;
class RimFaultCollection;
//==================================================================================================
///
///
//==================================================================================================
class RivFaultPartMgr : public cvf::Object
{
public:
RivFaultPartMgr(const RigGridBase* grid, const RimFault* rimFault);
void setCellVisibility(cvf::UByteArray* cellVisibilities);
void applySingleColorEffect();
void updateCellResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot);
void updateCellEdgeResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot, RimCellEdgeResultSlot* cellEdgeResultSlot);
void appendNativeFaultFacesToModel(cvf::ModelBasicList* model);
void appendOppositeFaultFacesToModel(cvf::ModelBasicList* model);
void appendLabelPartsToModel(cvf::ModelBasicList* model);
void appendMeshLinePartsToModel(cvf::ModelBasicList* model);
private:
void generatePartGeometry();
void updatePartEffect();
void createLabelWithAnchorLine(const cvf::Part* part);
static cvf::Vec3f findClosestVertex(const cvf::Vec3f& point, const cvf::Vec3fArray* vertices);
private:
cvf::cref<RigGridBase> m_grid;
const RimFault* m_rimFault;
float m_opacityLevel;
cvf::Color3f m_defaultColor;
bool m_showNativeFaces;
bool m_showOppositeFaces;
bool m_showLabel;
cvf::ref<cvf::UByteArray> m_cellVisibility;
RivFaultGeometryGenerator m_nativeFaultGenerator;
cvf::ref<cvf::Part> m_nativeFaultFaces;
cvf::ref<cvf::Part> m_nativeFaultGridLines;
cvf::ref<cvf::Vec2fArray> m_nativeFaultFacesTextureCoords;
RivFaultGeometryGenerator m_oppositeFaultGenerator;
cvf::ref<cvf::Part> m_oppositeFaultFaces;
cvf::ref<cvf::Part> m_oppositeFaultGridLines;
cvf::ref<cvf::Vec2fArray> m_oppositeFaultFacesTextureCoords;
cvf::ref<cvf::Part> m_faultLabelPart;
cvf::ref<cvf::Part> m_faultLabelLinePart;
};

View File

@@ -19,157 +19,530 @@
#include "RivFaultPartMgr.h"
#include "cvfPart.h"
#include "cafEffectGenerator.h"
#include "cvfStructGrid.h"
#include "cvfDrawableGeo.h"
#include "cvfModelBasicList.h"
#include "cvfColor3.h"
#include "cvfTransform.h"
#include "RivCellEdgeEffectGenerator.h"
#include "RimReservoirView.h"
#include "RimResultSlot.h"
#include "RimCellEdgeResultSlot.h"
#include "RigCaseCellResultsData.h"
#include "RigCaseData.h"
#include "RiaApplication.h"
#include "RiaPreferences.h"
#include "RimCase.h"
#include "RimWellCollection.h"
#include "cafPdmFieldCvfMat4d.h"
#include "cafPdmFieldCvfColor.h"
#include "RimCellRangeFilterCollection.h"
#include "RimCellPropertyFilterCollection.h"
#include "Rim3dOverlayInfoConfig.h"
#include "RimReservoirCellResultsCacher.h"
#include "cvfDrawableText.h"
#include "cvfqtUtils.h"
#include "cvfPrimitiveSetIndexedUInt.h"
#include "cvfPrimitiveSetDirect.h"
#include "RimFaultCollection.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivReservoirFaultsPartMgr::RivReservoirFaultsPartMgr(const RigGridBase* grid, size_t gridIdx, const RimFaultCollection* faultCollection)
: m_gridIdx(gridIdx),
m_grid(grid),
m_faultCollection(faultCollection)
RivFaultPartMgr::RivFaultPartMgr(const RigGridBase* grid, const RimFault* rimFault)
: m_grid(grid),
m_rimFault(rimFault),
m_opacityLevel(1.0f),
m_defaultColor(cvf::Color3::WHITE),
m_nativeFaultGenerator(grid, rimFault->faultGeometry(), true),
m_oppositeFaultGenerator(grid, rimFault->faultGeometry(), false)
{
CVF_ASSERT(grid);
m_nativeFaultFacesTextureCoords = new cvf::Vec2fArray;
m_oppositeFaultFacesTextureCoords = new cvf::Vec2fArray;
}
if (faultCollection)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::setCellVisibility(cvf::UByteArray* cellVisibilities)
{
m_nativeFaultGenerator.setCellVisibility(cellVisibilities);
m_oppositeFaultGenerator.setCellVisibility(cellVisibilities);
generatePartGeometry();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::applySingleColorEffect()
{
m_defaultColor = m_rimFault->faultColor();
// Set default effect
caf::SurfaceEffectGenerator geometryEffgen(m_defaultColor, true);
cvf::ref<cvf::Effect> geometryOnlyEffect = geometryEffgen.generateEffect();
if (m_nativeFaultFaces.notNull()) m_nativeFaultFaces->setEffect(geometryOnlyEffect.p());
if (m_oppositeFaultFaces.notNull()) m_oppositeFaultFaces->setEffect(geometryOnlyEffect.p());
if (m_opacityLevel < 1.0f)
{
for (size_t i = 0; i < faultCollection->faults.size(); i++)
// Set priority to make sure this transparent geometry are rendered last
if (m_nativeFaultFaces.notNull()) m_nativeFaultFaces->setPriority(100);
if (m_oppositeFaultFaces.notNull()) m_oppositeFaultFaces->setPriority(100);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot)
{
CVF_ASSERT(cellResultSlot);
size_t scalarSetIndex = cellResultSlot->gridScalarIndex();
const cvf::ScalarMapper* mapper = cellResultSlot->legendConfig()->scalarMapper();
// If the result is static, only read that.
size_t resTimeStepIdx = timeStepIndex;
if (cellResultSlot->hasStaticResult()) resTimeStepIdx = 0;
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel());
RigCaseData* eclipseCase = cellResultSlot->reservoirView()->eclipseCase()->reservoirData();
cvf::ref<cvf::StructGridScalarDataAccess> dataAccessObject = eclipseCase->dataAccessObject(m_grid.p(), porosityModel, resTimeStepIdx, scalarSetIndex);
if (dataAccessObject.isNull()) return;
// Faults
if (m_nativeFaultFaces.notNull())
{
m_nativeFaultGenerator.textureCoordinates(m_nativeFaultFacesTextureCoords.p(), dataAccessObject.p(), mapper);
if (m_opacityLevel < 1.0f )
{
m_faultParts.push_back(new RivFaultPartMgr(grid, faultCollection->faults[i]));
const std::vector<cvf::ubyte>& isWellPipeVisible = cellResultSlot->reservoirView()->wellCollection()->isWellPipesVisible(timeStepIndex);
cvf::ref<cvf::UIntArray> gridCellToWellindexMap = eclipseCase->gridCellToWellIndex(m_grid->gridIndex());
const std::vector<size_t>& quadsToGridCells = m_nativeFaultGenerator.quadToGridCellIndices();
for(size_t i = 0; i < m_nativeFaultFacesTextureCoords->size(); ++i)
{
if ((*m_nativeFaultFacesTextureCoords)[i].y() == 1.0f) continue; // Do not touch undefined values
size_t quadIdx = i/4;
size_t cellIndex = quadsToGridCells[quadIdx];
cvf::uint wellIndex = gridCellToWellindexMap->get(cellIndex);
if (wellIndex != cvf::UNDEFINED_UINT)
{
if ( !isWellPipeVisible[wellIndex])
{
(*m_nativeFaultFacesTextureCoords)[i].y() = 0; // Set the Y texture coordinate to the opaque line in the texture
}
}
}
}
cvf::DrawableGeo* dg = dynamic_cast<cvf::DrawableGeo*>(m_nativeFaultFaces->drawable());
if (dg) dg->setTextureCoordArray(m_nativeFaultFacesTextureCoords.p());
bool usePolygonOffset = true;
caf::ScalarMapperEffectGenerator scalarEffgen(mapper, usePolygonOffset);
scalarEffgen.setOpacityLevel(m_opacityLevel);
cvf::ref<cvf::Effect> scalarEffect = scalarEffgen.generateEffect();
m_nativeFaultFaces->setEffect(scalarEffect.p());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivReservoirFaultsPartMgr::~RivReservoirFaultsPartMgr()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivReservoirFaultsPartMgr::setTransform(cvf::Transform* scaleTransform)
{
m_scaleTransform = scaleTransform;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivReservoirFaultsPartMgr::setCellVisibility(cvf::UByteArray* cellVisibilities)
{
CVF_ASSERT(cellVisibilities);
for (size_t i = 0; i < m_faultParts.size(); i++)
if (m_oppositeFaultFaces.notNull())
{
m_faultParts.at(i)->setCellVisibility(cellVisibilities);
}
}
m_oppositeFaultGenerator.textureCoordinates(m_oppositeFaultFacesTextureCoords.p(), dataAccessObject.p(), mapper);
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivReservoirFaultsPartMgr::appendPartsToModel(cvf::ModelBasicList* model)
{
CVF_ASSERT(model != NULL);
if (!m_faultCollection) return;
// Faults are only present for main grid
if (!m_grid->isMainGrid()) return;
if (!m_faultCollection->showFaultCollection()) return;
// Check match between model fault count and fault parts
CVF_ASSERT(m_faultCollection->faults.size() == m_faultParts.size());
cvf::ModelBasicList parts;
for (size_t i = 0; i < m_faultCollection->faults.size(); i++)
{
const RimFault* rimFault = m_faultCollection->faults[i];
if (rimFault->showFault())
if (m_opacityLevel < 1.0f )
{
cvf::ref<RivFaultPartMgr> rivFaultPart = m_faultParts[i];
CVF_ASSERT(rivFaultPart.notNull());
const std::vector<cvf::ubyte>& isWellPipeVisible = cellResultSlot->reservoirView()->wellCollection()->isWellPipesVisible(timeStepIndex);
cvf::ref<cvf::UIntArray> gridCellToWellindexMap = eclipseCase->gridCellToWellIndex(m_grid->gridIndex());
const std::vector<size_t>& quadsToGridCells = m_oppositeFaultGenerator.quadToGridCellIndices();
if (m_faultCollection->showFaultFaces())
for(size_t i = 0; i < m_oppositeFaultFacesTextureCoords->size(); ++i)
{
rivFaultPart->appendNativeFaultFacesToModel(&parts);
if ((*m_oppositeFaultFacesTextureCoords)[i].y() == 1.0f) continue; // Do not touch undefined values
size_t quadIdx = i/4;
size_t cellIndex = quadsToGridCells[quadIdx];
cvf::uint wellIndex = gridCellToWellindexMap->get(cellIndex);
if (wellIndex != cvf::UNDEFINED_UINT)
{
if ( !isWellPipeVisible[wellIndex])
{
(*m_oppositeFaultFacesTextureCoords)[i].y() = 0; // Set the Y texture coordinate to the opaque line in the texture
}
}
}
}
cvf::DrawableGeo* dg = dynamic_cast<cvf::DrawableGeo*>(m_oppositeFaultFaces->drawable());
if (dg) dg->setTextureCoordArray(m_oppositeFaultFacesTextureCoords.p());
bool usePolygonOffset = true;
caf::ScalarMapperEffectGenerator scalarEffgen(mapper, usePolygonOffset);
scalarEffgen.setOpacityLevel(m_opacityLevel);
cvf::ref<cvf::Effect> scalarEffect = scalarEffgen.generateEffect();
m_oppositeFaultFaces->setEffect(scalarEffect.p());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::updateCellEdgeResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot, RimCellEdgeResultSlot* cellEdgeResultSlot)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::generatePartGeometry()
{
bool useBufferObjects = true;
// Surface geometry
{
cvf::ref<cvf::DrawableGeo> geo = m_nativeFaultGenerator.generateSurface();
if (geo.notNull())
{
geo->computeNormals();
if (useBufferObjects)
{
geo->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT);
}
if (m_faultCollection->showOppositeFaultFaces())
{
rivFaultPart->appendOppositeFaultFacesToModel(&parts);
}
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName("Grid " + cvf::String(static_cast<int>(m_grid->gridIndex())));
part->setId(m_grid->gridIndex()); // !! For now, use grid index as part ID (needed for pick info)
part->setDrawable(geo.p());
if (m_faultCollection->showFaultLabel())
{
rivFaultPart->appendLabelPartsToModel(&parts);
}
// Set mapping from triangle face index to cell index
part->setSourceInfo(m_nativeFaultGenerator.triangleToSourceGridCellMap().p());
if (m_faultCollection->showFaultFaces() || m_faultCollection->showOppositeFaultFaces())
{
rivFaultPart->appendMeshLinePartsToModel(&parts);
}
part->updateBoundingBox();
part->setEnableMask(faultBit);
m_nativeFaultFaces = part;
}
}
for (size_t i = 0; i < parts.partCount(); i++)
// Mesh geometry
{
cvf::Part* part = parts.part(i);
part->setTransform(m_scaleTransform.p());
cvf::ref<cvf::DrawableGeo> geoMesh = m_nativeFaultGenerator.createMeshDrawable();
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);
m_nativeFaultGridLines = part;
}
}
// Surface geometry
{
cvf::ref<cvf::DrawableGeo> geo = m_oppositeFaultGenerator.generateSurface();
if (geo.notNull())
{
geo->computeNormals();
if (useBufferObjects)
{
geo->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT);
}
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName("Grid " + cvf::String(static_cast<int>(m_grid->gridIndex())));
part->setId(m_grid->gridIndex()); // !! For now, use grid index as part ID (needed for pick info)
part->setDrawable(geo.p());
// Set mapping from triangle face index to cell index
part->setSourceInfo(m_oppositeFaultGenerator.triangleToSourceGridCellMap().p());
part->updateBoundingBox();
part->setEnableMask(faultBit);
m_oppositeFaultFaces = part;
}
}
// Mesh geometry
{
cvf::ref<cvf::DrawableGeo> geoMesh = m_oppositeFaultGenerator.createMeshDrawable();
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);
m_oppositeFaultGridLines = part;
}
}
m_faultLabelPart = NULL;
{
cvf::ref<cvf::Part> partToAttachLabelTo;
if (m_nativeFaultFaces.notNull())
{
partToAttachLabelTo = m_nativeFaultFaces;
}
else if(m_oppositeFaultFaces.notNull())
{
partToAttachLabelTo = m_oppositeFaultFaces;
}
if (partToAttachLabelTo.notNull())
{
createLabelWithAnchorLine(partToAttachLabelTo.p());
}
}
updatePartEffect();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::updatePartEffect()
{
cvf::Color3f partColor = m_defaultColor;
// Set default effect
caf::SurfaceEffectGenerator geometryEffgen(partColor, true);
cvf::ref<cvf::Effect> geometryOnlyEffect = geometryEffgen.generateEffect();
if (m_nativeFaultFaces.notNull())
{
m_nativeFaultFaces->setEffect(geometryOnlyEffect.p());
}
if (m_oppositeFaultFaces.notNull())
{
m_oppositeFaultFaces->setEffect(geometryOnlyEffect.p());
}
// Update mesh colors as well, in case of change
RiaPreferences* prefs = RiaApplication::instance()->preferences();
cvf::ref<cvf::Effect> eff;
caf::MeshEffectGenerator faultEffGen(prefs->defaultFaultGridLineColors());
eff = faultEffGen.generateEffect();
if (m_nativeFaultGridLines.notNull())
{
m_nativeFaultGridLines->setEffect(eff.p());
}
if (m_oppositeFaultGridLines.notNull())
{
m_oppositeFaultGridLines->setEffect(eff.p());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::createLabelWithAnchorLine(const cvf::Part* part)
{
CVF_ASSERT(part);
cvf::BoundingBox bb = part->boundingBox();
cvf::Vec3d bbTopCenter = bb.center();
bbTopCenter.z() = bb.max().z();
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
{
cvf::Font* standardFont = RiaApplication::instance()->standardFont();
cvf::ref<cvf::DrawableText> drawableText = new cvf::DrawableText;
drawableText->setFont(standardFont);
drawableText->setCheckPosVisible(false);
drawableText->setDrawBorder(false);
drawableText->setDrawBackground(false);
drawableText->setVerticalAlignment(cvf::TextDrawer::CENTER);
model->addPart(part);
cvf::Color3f defWellLabelColor = RiaApplication::instance()->preferences()->defaultWellLabelColor();
{
std::vector<RimFaultCollection*> parentObjects;
m_rimFault->parentObjectsOfType(parentObjects);
if (parentObjects.size() > 0)
{
defWellLabelColor = parentObjects[0]->faultLabelColor();;
}
}
drawableText->setTextColor(defWellLabelColor);
cvf::String cvfString = cvfqt::Utils::toString(m_rimFault->name());
cvf::Vec3f textCoord(labelPosition);
double characteristicCellSize = bb.extent().z() / 20;
textCoord.z() += characteristicCellSize;
drawableText->addText(cvfString, textCoord);
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName("RivFaultPart : text " + cvfString);
part->setDrawable(drawableText.p());
cvf::ref<cvf::Effect> eff = new cvf::Effect;
part->setEffect(eff.p());
part->setPriority(1000);
m_faultLabelPart = part;
}
// Line from fault geometry to label
{
cvf::ref<cvf::Vec3fArray> vertices = new cvf::Vec3fArray;
vertices->reserve(2);
vertices->add(faultVertexToAttachLabel);
vertices->add(labelPosition);
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
geo->setVertexArray(vertices.p());
cvf::ref<cvf::PrimitiveSetDirect> primSet = new cvf::PrimitiveSetDirect(cvf::PT_LINES);
primSet->setStartIndex(0);
primSet->setIndexCount(vertices->size());
geo->addPrimitiveSet(primSet.p());
m_faultLabelLinePart = new cvf::Part;
m_faultLabelLinePart->setName("Anchor line for label" + cvf::String(static_cast<int>(m_grid->gridIndex())));
m_faultLabelLinePart->setDrawable(geo.p());
m_faultLabelLinePart->updateBoundingBox();
caf::MeshEffectGenerator gen(m_rimFault->faultColor());
cvf::ref<cvf::Effect> eff = gen.generateEffect();
m_faultLabelLinePart->setEffect(eff.p());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivReservoirFaultsPartMgr::updateCellColor(cvf::Color4f color)
cvf::Vec3f RivFaultPartMgr::findClosestVertex(const cvf::Vec3f& point, const cvf::Vec3fArray* vertices)
{
CVF_UNUSED(color);
CVF_ASSERT(vertices);
if (!vertices) return cvf::Vec3f::UNDEFINED;
// NB color is not used, as the color is defined per fault
float closestDiff(HUGE_VAL);
for (size_t i = 0; i < m_faultParts.size(); i++)
size_t closestIndex = cvf::UNDEFINED_SIZE_T;
for (size_t i = 0; i < vertices->size(); i++)
{
m_faultParts[i]->applySingleColorEffect();
float diff = point.pointDistance(vertices->get(i));
if (diff < closestDiff)
{
closestDiff = diff;
closestIndex = i;
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivReservoirFaultsPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot)
{
for (size_t i = 0; i < m_faultParts.size(); i++)
if (closestIndex != cvf::UNDEFINED_SIZE_T)
{
m_faultParts[i]->updateCellResultColor(timeStepIndex, cellResultSlot);
return vertices->get(closestIndex);
}
else
{
return cvf::Vec3f::UNDEFINED;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivReservoirFaultsPartMgr::updateCellEdgeResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot, RimCellEdgeResultSlot* cellEdgeResultSlot)
void RivFaultPartMgr::appendNativeFaultFacesToModel(cvf::ModelBasicList* model)
{
for (size_t i = 0; i < m_faultParts.size(); i++)
if (m_nativeFaultFaces.notNull())
{
m_faultParts[i]->updateCellEdgeResultColor(timeStepIndex, cellResultSlot, cellEdgeResultSlot);
model->addPart(m_nativeFaultFaces.p());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::appendOppositeFaultFacesToModel(cvf::ModelBasicList* model)
{
if (m_oppositeFaultFaces.notNull())
{
model->addPart(m_oppositeFaultFaces.p());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::appendLabelPartsToModel(cvf::ModelBasicList* model)
{
if (m_faultLabelPart.notNull()) model->addPart(m_faultLabelPart.p());
if (m_faultLabelLinePart.notNull()) model->addPart(m_faultLabelLinePart.p());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::appendMeshLinePartsToModel(cvf::ModelBasicList* model)
{
if (m_nativeFaultGridLines.notNull()) model->addPart(m_nativeFaultGridLines.p());
if (m_oppositeFaultGridLines.notNull()) model->addPart(m_oppositeFaultGridLines.p());
}

View File

@@ -17,16 +17,20 @@
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "RigGridBase.h"
#include "RivFaultPart.h"
#include "RimFault.h"
#include "RivFaultGeometryGenerator.h"
#include "cvfColor4.h"
namespace cvf
{
class StructGridInterface;
class ModelBasicList;
class Transform;
class Part;
}
class RimResultSlot;
@@ -35,28 +39,56 @@ class RimFaultCollection;
//==================================================================================================
///
///
//==================================================================================================
class RivReservoirFaultsPartMgr : public cvf::Object
class RivFaultPartMgr : public cvf::Object
{
public:
RivReservoirFaultsPartMgr(const RigGridBase* grid, size_t gridIdx, const RimFaultCollection* faultCollection);
~RivReservoirFaultsPartMgr();
RivFaultPartMgr(const RigGridBase* grid, const RimFault* rimFault);
void setTransform(cvf::Transform* scaleTransform);
void setCellVisibility(cvf::UByteArray* cellVisibilities);
void updateCellColor(cvf::Color4f color);
void applySingleColorEffect();
void updateCellResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot);
void updateCellEdgeResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot,
RimCellEdgeResultSlot* cellEdgeResultSlot);
void appendPartsToModel(cvf::ModelBasicList* model);
void updateCellEdgeResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot, RimCellEdgeResultSlot* cellEdgeResultSlot);
void appendNativeFaultFacesToModel(cvf::ModelBasicList* model);
void appendOppositeFaultFacesToModel(cvf::ModelBasicList* model);
void appendLabelPartsToModel(cvf::ModelBasicList* model);
void appendMeshLinePartsToModel(cvf::ModelBasicList* model);
private:
size_t m_gridIdx;
cvf::cref<RigGridBase> m_grid;
cvf::ref<cvf::Transform> m_scaleTransform;
const RimFaultCollection* m_faultCollection;
cvf::Collection<RivFaultPartMgr> m_faultParts;
void generatePartGeometry();
void updatePartEffect();
void createLabelWithAnchorLine(const cvf::Part* part);
static cvf::Vec3f findClosestVertex(const cvf::Vec3f& point, const cvf::Vec3fArray* vertices);
private:
cvf::cref<RigGridBase> m_grid;
const RimFault* m_rimFault;
float m_opacityLevel;
cvf::Color3f m_defaultColor;
bool m_showNativeFaces;
bool m_showOppositeFaces;
bool m_showLabel;
cvf::ref<cvf::UByteArray> m_cellVisibility;
RivFaultGeometryGenerator m_nativeFaultGenerator;
cvf::ref<cvf::Part> m_nativeFaultFaces;
cvf::ref<cvf::Part> m_nativeFaultGridLines;
cvf::ref<cvf::Vec2fArray> m_nativeFaultFacesTextureCoords;
RivFaultGeometryGenerator m_oppositeFaultGenerator;
cvf::ref<cvf::Part> m_oppositeFaultFaces;
cvf::ref<cvf::Part> m_oppositeFaultGridLines;
cvf::ref<cvf::Vec2fArray> m_oppositeFaultFacesTextureCoords;
cvf::ref<cvf::Part> m_faultLabelPart;
cvf::ref<cvf::Part> m_faultLabelLinePart;
};

View File

@@ -0,0 +1,175 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Statoil ASA, Ceetron Solutions AS
//
// 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.
//
// 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.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RivReservoirFaultsPartMgr.h"
#include "cvfPart.h"
#include "cvfModelBasicList.h"
#include "cvfColor3.h"
#include "cvfTransform.h"
#include "cafPdmFieldCvfColor.h"
#include "RimFaultCollection.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivReservoirFaultsPartMgr::RivReservoirFaultsPartMgr(const RigGridBase* grid, size_t gridIdx, const RimFaultCollection* faultCollection)
: m_gridIdx(gridIdx),
m_grid(grid),
m_faultCollection(faultCollection)
{
CVF_ASSERT(grid);
if (faultCollection)
{
for (size_t i = 0; i < faultCollection->faults.size(); i++)
{
m_faultParts.push_back(new RivFaultPartMgr(grid, faultCollection->faults[i]));
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivReservoirFaultsPartMgr::~RivReservoirFaultsPartMgr()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivReservoirFaultsPartMgr::setTransform(cvf::Transform* scaleTransform)
{
m_scaleTransform = scaleTransform;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivReservoirFaultsPartMgr::setCellVisibility(cvf::UByteArray* cellVisibilities)
{
CVF_ASSERT(cellVisibilities);
for (size_t i = 0; i < m_faultParts.size(); i++)
{
m_faultParts.at(i)->setCellVisibility(cellVisibilities);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivReservoirFaultsPartMgr::appendPartsToModel(cvf::ModelBasicList* model)
{
CVF_ASSERT(model != NULL);
if (!m_faultCollection) return;
// Faults are only present for main grid
if (!m_grid->isMainGrid()) return;
if (!m_faultCollection->showFaultCollection()) return;
// Check match between model fault count and fault parts
CVF_ASSERT(m_faultCollection->faults.size() == m_faultParts.size());
cvf::ModelBasicList parts;
for (size_t i = 0; i < m_faultCollection->faults.size(); i++)
{
const RimFault* rimFault = m_faultCollection->faults[i];
if (rimFault->showFault())
{
cvf::ref<RivFaultPartMgr> rivFaultPart = m_faultParts[i];
CVF_ASSERT(rivFaultPart.notNull());
if (m_faultCollection->showFaultFaces())
{
rivFaultPart->appendNativeFaultFacesToModel(&parts);
}
if (m_faultCollection->showOppositeFaultFaces())
{
rivFaultPart->appendOppositeFaultFacesToModel(&parts);
}
if (m_faultCollection->showFaultLabel())
{
rivFaultPart->appendLabelPartsToModel(&parts);
}
if (m_faultCollection->showFaultFaces() || m_faultCollection->showOppositeFaultFaces())
{
rivFaultPart->appendMeshLinePartsToModel(&parts);
}
}
}
for (size_t i = 0; i < parts.partCount(); i++)
{
cvf::Part* part = parts.part(i);
part->setTransform(m_scaleTransform.p());
model->addPart(part);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivReservoirFaultsPartMgr::updateCellColor(cvf::Color4f color)
{
CVF_UNUSED(color);
// NB color is not used, as the color is defined per fault
for (size_t i = 0; i < m_faultParts.size(); i++)
{
m_faultParts[i]->applySingleColorEffect();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivReservoirFaultsPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot)
{
for (size_t i = 0; i < m_faultParts.size(); i++)
{
m_faultParts[i]->updateCellResultColor(timeStepIndex, cellResultSlot);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivReservoirFaultsPartMgr::updateCellEdgeResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot, RimCellEdgeResultSlot* cellEdgeResultSlot)
{
for (size_t i = 0; i < m_faultParts.size(); i++)
{
m_faultParts[i]->updateCellEdgeResultColor(timeStepIndex, cellResultSlot, cellEdgeResultSlot);
}
}

View File

@@ -0,0 +1,62 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Statoil ASA, Ceetron Solutions AS
//
// 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.
//
// 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.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "RigGridBase.h"
#include "RivFaultPartMgr.h"
namespace cvf
{
class Transform;
}
class RimResultSlot;
class RimCellEdgeResultSlot;
class RimFaultCollection;
//==================================================================================================
///
//==================================================================================================
class RivReservoirFaultsPartMgr : public cvf::Object
{
public:
RivReservoirFaultsPartMgr(const RigGridBase* grid, size_t gridIdx, const RimFaultCollection* faultCollection);
~RivReservoirFaultsPartMgr();
void setTransform(cvf::Transform* scaleTransform);
void setCellVisibility(cvf::UByteArray* cellVisibilities);
void updateCellColor(cvf::Color4f color);
void updateCellResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot);
void updateCellEdgeResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot,
RimCellEdgeResultSlot* cellEdgeResultSlot);
void appendPartsToModel(cvf::ModelBasicList* model);
private:
size_t m_gridIdx;
cvf::cref<RigGridBase> m_grid;
cvf::ref<cvf::Transform> m_scaleTransform;
const RimFaultCollection* m_faultCollection;
cvf::Collection<RivFaultPartMgr> m_faultParts;
};

View File

@@ -24,7 +24,6 @@
#include "RigCaseData.h"
#include "RivGridPartMgr.h"
#include "RivFaultPartMgr.h"
//--------------------------------------------------------------------------------------------------
///

View File

@@ -21,7 +21,7 @@
#include "cvfArray.h"
#include "cvfCollection.h"
#include "RivFaultPartMgr.h"
#include "RivReservoirFaultsPartMgr.h"
namespace cvf
{