Whitespace

This commit is contained in:
Magne Sjaastad
2018-09-21 11:43:03 +02:00
parent 32237b6c7c
commit 163193dc6c
6 changed files with 501 additions and 503 deletions

View File

@@ -2,17 +2,17 @@
// //
// Copyright (C) 2015- Statoil ASA // Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS // Copyright (C) 2015- Ceetron Solutions AS
// //
// ResInsight is free software: you can redistribute it and/or modify // ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or // WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. // FITNESS FOR A PARTICULAR PURPOSE.
// //
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> // See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details. // for more details.
// //
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
@@ -49,9 +49,9 @@
#include "cvfMath.h" #include "cvfMath.h"
#include "cvfModelBasicList.h" #include "cvfModelBasicList.h"
#include "cvfPart.h" #include "cvfPart.h"
#include "cvfRenderState_FF.h"
#include "cvfRenderStateBlending.h" #include "cvfRenderStateBlending.h"
#include "cvfRenderStatePolygonOffset.h" #include "cvfRenderStatePolygonOffset.h"
#include "cvfRenderState_FF.h"
#include "cvfShaderProgram.h" #include "cvfShaderProgram.h"
#include "cvfShaderProgramGenerator.h" #include "cvfShaderProgramGenerator.h"
#include "cvfShaderSourceProvider.h" #include "cvfShaderSourceProvider.h"
@@ -60,25 +60,23 @@
#include "cvfTransform.h" #include "cvfTransform.h"
#include "cvfUniform.h" #include "cvfUniform.h"
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RivFemPartPartMgr::RivFemPartPartMgr(const RigFemPart* grid) RivFemPartPartMgr::RivFemPartPartMgr(const RigFemPart* grid)
: m_surfaceGenerator(grid), : m_surfaceGenerator(grid)
m_grid(grid), , m_grid(grid)
m_opacityLevel(1.0f), , m_opacityLevel(1.0f)
m_defaultColor(cvf::Color3::WHITE) , m_defaultColor(cvf::Color3::WHITE)
{ {
CVF_ASSERT(grid); CVF_ASSERT(grid);
m_gridIdx = grid->elementPartId(); m_gridIdx = grid->elementPartId();
m_cellVisibility = new cvf::UByteArray; m_cellVisibility = new cvf::UByteArray;
m_surfaceFacesTextureCoords = new cvf::Vec2fArray; m_surfaceFacesTextureCoords = new cvf::Vec2fArray;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivFemPartPartMgr::setTransform(cvf::Transform* scaleTransform) void RivFemPartPartMgr::setTransform(cvf::Transform* scaleTransform)
{ {
@@ -86,7 +84,7 @@ void RivFemPartPartMgr::setTransform(cvf::Transform* scaleTransform)
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivFemPartPartMgr::setCellVisibility(cvf::UByteArray* cellVisibilities) void RivFemPartPartMgr::setCellVisibility(cvf::UByteArray* cellVisibilities)
{ {
@@ -101,13 +99,13 @@ void RivFemPartPartMgr::setCellVisibility(cvf::UByteArray* cellVisibilities)
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivFemPartPartMgr::generatePartGeometry(RivFemPartGeometryGenerator& geoBuilder) void RivFemPartPartMgr::generatePartGeometry(RivFemPartGeometryGenerator& geoBuilder)
{ {
bool useBufferObjects = true; bool useBufferObjects = true;
// Surface geometry // Surface geometry
{ {
m_surfaceFaces = nullptr; // To possibly free memory before adding the new stuff m_surfaceFaces = nullptr; // To possibly free memory before adding the new stuff
cvf::ref<cvf::DrawableGeo> geo = geoBuilder.generateSurface(); cvf::ref<cvf::DrawableGeo> geo = geoBuilder.generateSurface();
@@ -122,7 +120,7 @@ void RivFemPartPartMgr::generatePartGeometry(RivFemPartGeometryGenerator& geoBui
cvf::ref<cvf::Part> part = new cvf::Part; cvf::ref<cvf::Part> part = new cvf::Part;
part->setName("FemPart " + cvf::String(m_gridIdx)); part->setName("FemPart " + cvf::String(m_gridIdx));
part->setId(m_gridIdx); // Use grid index as part ID part->setId(m_gridIdx); // Use grid index as part ID
part->setDrawable(geo.p()); part->setDrawable(geo.p());
part->setTransform(m_scaleTransform.p()); part->setTransform(m_scaleTransform.p());
@@ -131,10 +129,10 @@ void RivFemPartPartMgr::generatePartGeometry(RivFemPartGeometryGenerator& geoBui
part->setSourceInfo(si.p()); part->setSourceInfo(si.p());
part->updateBoundingBox(); part->updateBoundingBox();
// Set default effect // Set default effect
caf::SurfaceEffectGenerator geometryEffgen(cvf::Color4f(cvf::Color3f::WHITE), caf::PO_1); caf::SurfaceEffectGenerator geometryEffgen(cvf::Color4f(cvf::Color3f::WHITE), caf::PO_1);
cvf::ref<cvf::Effect> geometryOnlyEffect = geometryEffgen.generateCachedEffect(); cvf::ref<cvf::Effect> geometryOnlyEffect = geometryEffgen.generateCachedEffect();
part->setEffect(geometryOnlyEffect.p()); part->setEffect(geometryOnlyEffect.p());
part->setEnableMask(surfaceBit); part->setEnableMask(surfaceBit);
m_surfaceFaces = part; m_surfaceFaces = part;
@@ -162,7 +160,7 @@ void RivFemPartPartMgr::generatePartGeometry(RivFemPartGeometryGenerator& geoBui
RiaPreferences* prefs = RiaApplication::instance()->preferences(); RiaPreferences* prefs = RiaApplication::instance()->preferences();
cvf::ref<cvf::Effect> eff; cvf::ref<cvf::Effect> eff;
caf::MeshEffectGenerator effGen(prefs->defaultGridLineColors()); caf::MeshEffectGenerator effGen(prefs->defaultGridLineColors());
eff = effGen.generateCachedEffect(); eff = effGen.generateCachedEffect();
@@ -179,18 +177,18 @@ void RivFemPartPartMgr::generatePartGeometry(RivFemPartGeometryGenerator& geoBui
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivFemPartPartMgr::appendPartsToModel(cvf::ModelBasicList* model) void RivFemPartPartMgr::appendPartsToModel(cvf::ModelBasicList* model)
{ {
CVF_ASSERT(model != nullptr); CVF_ASSERT(model != nullptr);
if(m_surfaceFaces.notNull() ) model->addPart(m_surfaceFaces.p() ); if (m_surfaceFaces.notNull()) model->addPart(m_surfaceFaces.p());
if(m_surfaceGridLines.notNull()) model->addPart(m_surfaceGridLines.p()); if (m_surfaceGridLines.notNull()) model->addPart(m_surfaceGridLines.p());
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
const RivFemPartGeometryGenerator* RivFemPartPartMgr::surfaceGenerator() const const RivFemPartGeometryGenerator* RivFemPartPartMgr::surfaceGenerator() const
{ {
@@ -198,7 +196,7 @@ const RivFemPartGeometryGenerator* RivFemPartPartMgr::surfaceGenerator() const
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivFemPartPartMgr::updateCellColor(cvf::Color4f color) void RivFemPartPartMgr::updateCellColor(cvf::Color4f color)
{ {
@@ -206,7 +204,7 @@ void RivFemPartPartMgr::updateCellColor(cvf::Color4f color)
// Set default effect // Set default effect
caf::SurfaceEffectGenerator geometryEffgen(color, caf::PO_1); caf::SurfaceEffectGenerator geometryEffgen(color, caf::PO_1);
cvf::ref<cvf::Effect> geometryOnlyEffect = geometryEffgen.generateCachedEffect(); cvf::ref<cvf::Effect> geometryOnlyEffect = geometryEffgen.generateCachedEffect();
if (m_surfaceFaces.notNull()) m_surfaceFaces->setEffect(geometryOnlyEffect.p()); if (m_surfaceFaces.notNull()) m_surfaceFaces->setEffect(geometryOnlyEffect.p());
@@ -232,7 +230,7 @@ void RivFemPartPartMgr::updateCellColor(cvf::Color4f color)
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivFemPartPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechCellColors* cellResultColors) void RivFemPartPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechCellColors* cellResultColors)
{ {
@@ -243,34 +241,36 @@ void RivFemPartPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechCe
// Outer surface // Outer surface
if (m_surfaceFaces.notNull()) if (m_surfaceFaces.notNull())
{ {
const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper(); const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper();
RigGeoMechCaseData* caseData = cellResultColors->ownerCaseData(); RigGeoMechCaseData* caseData = cellResultColors->ownerCaseData();
if (!caseData) return; if (!caseData) return;
RigFemResultAddress resVarAddress = cellResultColors->resultAddress(); RigFemResultAddress resVarAddress = cellResultColors->resultAddress();
// Do a "Hack" to show elm nodal and not nodal POR results // Do a "Hack" to show elm nodal and not nodal POR results
if (resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar") resVarAddress.resultPosType = RIG_ELEMENT_NODAL; if (resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar")
{
resVarAddress.resultPosType = RIG_ELEMENT_NODAL;
}
const std::vector<float>& resultValues = caseData->femPartResults()->resultValues(resVarAddress, m_gridIdx, (int)timeStepIndex); const std::vector<float>& resultValues =
caseData->femPartResults()->resultValues(resVarAddress, m_gridIdx, (int)timeStepIndex);
const std::vector<size_t>* vxToResultMapping = nullptr; const std::vector<size_t>* vxToResultMapping = nullptr;
int vxCount = 0; int vxCount = 0;
if (resVarAddress.resultPosType == RIG_NODAL) if (resVarAddress.resultPosType == RIG_NODAL)
{ {
vxToResultMapping = &(m_surfaceGenerator.quadVerticesToNodeIdxMapping()); vxToResultMapping = &(m_surfaceGenerator.quadVerticesToNodeIdxMapping());
} }
else if ( resVarAddress.resultPosType == RIG_ELEMENT_NODAL else if (resVarAddress.resultPosType == RIG_ELEMENT_NODAL || resVarAddress.resultPosType == RIG_INTEGRATION_POINT ||
|| resVarAddress.resultPosType == RIG_INTEGRATION_POINT resVarAddress.resultPosType == RIG_FORMATION_NAMES)
|| resVarAddress.resultPosType == RIG_FORMATION_NAMES)
{ {
vxToResultMapping = &(m_surfaceGenerator.quadVerticesToGlobalElmNodeIdx()); vxToResultMapping = &(m_surfaceGenerator.quadVerticesToGlobalElmNodeIdx());
} }
else if(resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE) else if (resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE)
{ {
vxToResultMapping = &(m_surfaceGenerator.quadVerticesToGlobalElmFaceNodeIdx()); vxToResultMapping = &(m_surfaceGenerator.quadVerticesToGlobalElmFaceNodeIdx());
} }
@@ -278,9 +278,9 @@ void RivFemPartPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechCe
{ {
vxToResultMapping = &(m_surfaceGenerator.quadVerticesToGlobalElmIdx()); vxToResultMapping = &(m_surfaceGenerator.quadVerticesToGlobalElmIdx());
} }
if (!vxToResultMapping) return; if (!vxToResultMapping) return;
vxCount = static_cast<int>(vxToResultMapping->size()); vxCount = static_cast<int>(vxToResultMapping->size());
m_surfaceFacesTextureCoords->resize(vxCount); m_surfaceFacesTextureCoords->resize(vxCount);
@@ -292,7 +292,7 @@ void RivFemPartPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechCe
{ {
cvf::Vec2f* rawPtr = m_surfaceFacesTextureCoords->ptr(); cvf::Vec2f* rawPtr = m_surfaceFacesTextureCoords->ptr();
#pragma omp parallel for schedule(dynamic) #pragma omp parallel for schedule(dynamic)
for (int quadStartIdx = 0; quadStartIdx < vxCount; quadStartIdx += 4) for (int quadStartIdx = 0; quadStartIdx < vxCount; quadStartIdx += 4)
{ {
float resultValue1 = resultValues[(*vxToResultMapping)[quadStartIdx + 0]]; float resultValue1 = resultValues[(*vxToResultMapping)[quadStartIdx + 0]];
@@ -300,22 +300,21 @@ void RivFemPartPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechCe
float resultValue3 = resultValues[(*vxToResultMapping)[quadStartIdx + 2]]; float resultValue3 = resultValues[(*vxToResultMapping)[quadStartIdx + 2]];
float resultValue4 = resultValues[(*vxToResultMapping)[quadStartIdx + 3]]; float resultValue4 = resultValues[(*vxToResultMapping)[quadStartIdx + 3]];
if ( resultValue1 == HUGE_VAL || resultValue1 != resultValue1 // a != a is true for NAN's if (resultValue1 == HUGE_VAL || resultValue1 != resultValue1 // a != a is true for NAN's
|| resultValue2 == HUGE_VAL || resultValue2 != resultValue2 || resultValue2 == HUGE_VAL || resultValue2 != resultValue2 || resultValue3 == HUGE_VAL ||
|| resultValue3 == HUGE_VAL || resultValue3 != resultValue3 resultValue3 != resultValue3 || resultValue4 == HUGE_VAL || resultValue4 != resultValue4)
|| resultValue4 == HUGE_VAL || resultValue4 != resultValue4)
{ {
rawPtr[quadStartIdx][1] = 1.0f; rawPtr[quadStartIdx][1] = 1.0f;
rawPtr[quadStartIdx + 1][1] = 1.0f; rawPtr[quadStartIdx + 1][1] = 1.0f;
rawPtr[quadStartIdx + 2][1] = 1.0f; rawPtr[quadStartIdx + 2][1] = 1.0f;
rawPtr[quadStartIdx + 3][1] = 1.0f; rawPtr[quadStartIdx + 3][1] = 1.0f;
} }
else else
{ {
rawPtr[quadStartIdx] = mapper->mapToTextureCoord(resultValue1); rawPtr[quadStartIdx] = mapper->mapToTextureCoord(resultValue1);
rawPtr[quadStartIdx + 1] = mapper->mapToTextureCoord(resultValue2); rawPtr[quadStartIdx + 1] = mapper->mapToTextureCoord(resultValue2);
rawPtr[quadStartIdx + 2] = mapper->mapToTextureCoord(resultValue3); rawPtr[quadStartIdx + 2] = mapper->mapToTextureCoord(resultValue3);
rawPtr[quadStartIdx + 3] = mapper->mapToTextureCoord(resultValue4); rawPtr[quadStartIdx + 3] = mapper->mapToTextureCoord(resultValue4);
} }
} }
} }
@@ -324,22 +323,16 @@ void RivFemPartPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechCe
cellResultColors->firstAncestorOrThisOfType(view); cellResultColors->firstAncestorOrThisOfType(view);
CVF_ASSERT(view); CVF_ASSERT(view);
RivScalarMapperUtils::applyTextureResultsToPart(m_surfaceFaces.p(), RivScalarMapperUtils::applyTextureResultsToPart(m_surfaceFaces.p(),
m_surfaceFacesTextureCoords.p(), m_surfaceFacesTextureCoords.p(),
mapper, mapper,
m_opacityLevel, m_opacityLevel,
caf::FC_NONE, caf::FC_NONE,
view->isLightingDisabled()); view->isLightingDisabled());
} }
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RivFemPartPartMgr::~RivFemPartPartMgr() RivFemPartPartMgr::~RivFemPartPartMgr() {}
{
}

View File

@@ -1,17 +1,17 @@
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) Statoil ASA // Copyright (C) Statoil ASA
// //
// ResInsight is free software: you can redistribute it and/or modify // ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or // WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. // FITNESS FOR A PARTICULAR PURPOSE.
// //
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> // See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details. // for more details.
// //
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
@@ -48,19 +48,17 @@
#include "cvfModelBasicList.h" #include "cvfModelBasicList.h"
#include "cvfPart.h" #include "cvfPart.h"
#include "cvfPrimitiveSetDirect.h" #include "cvfPrimitiveSetDirect.h"
#include "cvfRenderState_FF.h"
#include "cvfRenderStateDepth.h" #include "cvfRenderStateDepth.h"
#include "cvfRenderStatePoint.h" #include "cvfRenderStatePoint.h"
#include "cvfRenderState_FF.h"
#include "cvfStructGridGeometryGenerator.h" #include "cvfStructGridGeometryGenerator.h"
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RivIntersectionBoxPartMgr::RivIntersectionBoxPartMgr(RimIntersectionBox* intersectionBox) RivIntersectionBoxPartMgr::RivIntersectionBoxPartMgr(RimIntersectionBox* intersectionBox)
: m_rimIntersectionBox(intersectionBox), : m_rimIntersectionBox(intersectionBox)
m_defaultColor(cvf::Color3::WHITE) , m_defaultColor(cvf::Color3::WHITE)
{ {
CVF_ASSERT(m_rimIntersectionBox); CVF_ASSERT(m_rimIntersectionBox);
@@ -71,20 +69,19 @@ RivIntersectionBoxPartMgr::RivIntersectionBoxPartMgr(RimIntersectionBox* interse
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivIntersectionBoxPartMgr::applySingleColorEffect() void RivIntersectionBoxPartMgr::applySingleColorEffect()
{ {
m_defaultColor = cvf::Color3f::OLIVE;//m_rimCrossSection->CrossSectionColor(); m_defaultColor = cvf::Color3f::OLIVE; // m_rimCrossSection->CrossSectionColor();
this->updatePartEffect(); this->updatePartEffect();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivIntersectionBoxPartMgr::updateCellResultColor(size_t timeStepIndex) void RivIntersectionBoxPartMgr::updateCellResultColor(size_t timeStepIndex)
{ {
if (!m_intersectionBoxGenerator->isAnyGeometryPresent()) return; if (!m_intersectionBoxGenerator->isAnyGeometryPresent()) return;
RimEclipseView* eclipseView; RimEclipseView* eclipseView;
@@ -100,11 +97,11 @@ void RivIntersectionBoxPartMgr::updateCellResultColor(size_t timeStepIndex)
{ {
if (cellResultColors->isTernarySaturationSelected()) if (cellResultColors->isTernarySaturationSelected())
{ {
RivTernaryTextureCoordsCreator texturer(cellResultColors, RivTernaryTextureCoordsCreator texturer(
cellResultColors->ternaryLegendConfig()->scalarMapper(), cellResultColors, cellResultColors->ternaryLegendConfig()->scalarMapper(), timeStepIndex);
timeStepIndex);
texturer.createTextureCoords(m_intersectionBoxFacesTextureCoords.p(),
texturer.createTextureCoords(m_intersectionBoxFacesTextureCoords.p(), m_intersectionBoxGenerator->triangleToCellIndex()); m_intersectionBoxGenerator->triangleToCellIndex());
const RivTernaryScalarMapper* mapper = cellResultColors->ternaryLegendConfig()->scalarMapper(); const RivTernaryScalarMapper* mapper = cellResultColors->ternaryLegendConfig()->scalarMapper();
RivScalarMapperUtils::applyTernaryTextureResultsToPart(m_intersectionBoxFaces.p(), RivScalarMapperUtils::applyTernaryTextureResultsToPart(m_intersectionBoxFaces.p(),
@@ -118,7 +115,7 @@ void RivIntersectionBoxPartMgr::updateCellResultColor(size_t timeStepIndex)
{ {
CVF_ASSERT(m_intersectionBoxGenerator.notNull()); CVF_ASSERT(m_intersectionBoxGenerator.notNull());
const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper(); const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper();
cvf::ref<RigResultAccessor> resultAccessor; cvf::ref<RigResultAccessor> resultAccessor;
if (RiaDefines::isPerCellFaceResult(cellResultColors->resultVariable())) if (RiaDefines::isPerCellFaceResult(cellResultColors->resultVariable()))
@@ -127,17 +124,14 @@ void RivIntersectionBoxPartMgr::updateCellResultColor(size_t timeStepIndex)
} }
else else
{ {
resultAccessor = RigResultAccessorFactory::createFromResultDefinition(cellResultColors->reservoirView()->eclipseCase()->eclipseCaseData(), resultAccessor = RigResultAccessorFactory::createFromResultDefinition(
0, cellResultColors->reservoirView()->eclipseCase()->eclipseCaseData(), 0, timeStepIndex, cellResultColors);
timeStepIndex,
cellResultColors);
} }
RivIntersectionPartMgr::calculateEclipseTextureCoordinates(m_intersectionBoxFacesTextureCoords.p(), RivIntersectionPartMgr::calculateEclipseTextureCoordinates(m_intersectionBoxFacesTextureCoords.p(),
m_intersectionBoxGenerator->triangleToCellIndex(), m_intersectionBoxGenerator->triangleToCellIndex(),
resultAccessor.p(), resultAccessor.p(),
mapper); mapper);
RivScalarMapperUtils::applyTextureResultsToPart(m_intersectionBoxFaces.p(), RivScalarMapperUtils::applyTextureResultsToPart(m_intersectionBoxFaces.p(),
m_intersectionBoxFacesTextureCoords.p(), m_intersectionBoxFacesTextureCoords.p(),
@@ -145,7 +139,7 @@ void RivIntersectionBoxPartMgr::updateCellResultColor(size_t timeStepIndex)
1.0, 1.0,
caf::FC_NONE, caf::FC_NONE,
eclipseView->isLightingDisabled()); eclipseView->isLightingDisabled());
} }
} }
} }
@@ -155,23 +149,22 @@ void RivIntersectionBoxPartMgr::updateCellResultColor(size_t timeStepIndex)
if (geoView) if (geoView)
{ {
RimGeoMechCellColors* cellResultColors = geoView->cellResult(); RimGeoMechCellColors* cellResultColors = geoView->cellResult();
RigGeoMechCaseData* caseData = cellResultColors->ownerCaseData(); RigGeoMechCaseData* caseData = cellResultColors->ownerCaseData();
if (!caseData) return; if (!caseData) return;
RigFemResultAddress resVarAddress = cellResultColors->resultAddress(); RigFemResultAddress resVarAddress = cellResultColors->resultAddress();
const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper();
const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper();
if (resVarAddress.resultPosType == RIG_ELEMENT) if (resVarAddress.resultPosType == RIG_ELEMENT)
{ {
const std::vector<float>& resultValues = caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex); const std::vector<float>& resultValues =
const std::vector<size_t>& triangleToCellIdx = m_intersectionBoxGenerator->triangleToCellIndex(); caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex);
const std::vector<size_t>& triangleToCellIdx = m_intersectionBoxGenerator->triangleToCellIndex();
RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords(m_intersectionBoxFacesTextureCoords.p(), RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords(
resultValues, m_intersectionBoxFacesTextureCoords.p(), resultValues, triangleToCellIdx, mapper);
triangleToCellIdx,
mapper);
} }
else if (resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE) else if (resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE)
{ {
@@ -180,15 +173,14 @@ void RivIntersectionBoxPartMgr::updateCellResultColor(size_t timeStepIndex)
if (resVarAddress.componentName == "Pazi" || resVarAddress.componentName == "Pinc") if (resVarAddress.componentName == "Pazi" || resVarAddress.componentName == "Pinc")
{ {
RivIntersectionPartMgr::calculatePlaneAngleTextureCoords(m_intersectionBoxFacesTextureCoords.p(), RivIntersectionPartMgr::calculatePlaneAngleTextureCoords(
triangelVxes, m_intersectionBoxFacesTextureCoords.p(), triangelVxes, resVarAddress, mapper);
resVarAddress,
mapper);
} }
else else
{ {
const std::vector<RivIntersectionVertexWeights> &vertexWeights = m_intersectionBoxGenerator->triangleVxToCellCornerInterpolationWeights(); const std::vector<RivIntersectionVertexWeights>& vertexWeights =
m_intersectionBoxGenerator->triangleVxToCellCornerInterpolationWeights();
RivIntersectionPartMgr::calculateGeoMechTensorXfTextureCoords(m_intersectionBoxFacesTextureCoords.p(), RivIntersectionPartMgr::calculateGeoMechTensorXfTextureCoords(m_intersectionBoxFacesTextureCoords.p(),
triangelVxes, triangelVxes,
vertexWeights, vertexWeights,
@@ -201,37 +193,34 @@ void RivIntersectionBoxPartMgr::updateCellResultColor(size_t timeStepIndex)
else else
{ {
// Do a "Hack" to show elm nodal and not nodal POR results // Do a "Hack" to show elm nodal and not nodal POR results
if (resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar") resVarAddress.resultPosType = RIG_ELEMENT_NODAL; if (resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar")
resVarAddress.resultPosType = RIG_ELEMENT_NODAL;
const std::vector<float>& resultValues = caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex); const std::vector<float>& resultValues =
RigFemPart* femPart = caseData->femParts()->part(0); caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex);
bool isElementNodalResult = !(resVarAddress.resultPosType == RIG_NODAL); RigFemPart* femPart = caseData->femParts()->part(0);
const std::vector<RivIntersectionVertexWeights> &vertexWeights = m_intersectionBoxGenerator->triangleVxToCellCornerInterpolationWeights(); bool isElementNodalResult = !(resVarAddress.resultPosType == RIG_NODAL);
const std::vector<RivIntersectionVertexWeights>& vertexWeights =
m_intersectionBoxGenerator->triangleVxToCellCornerInterpolationWeights();
RivIntersectionPartMgr::calculateNodeOrElementNodeBasedGeoMechTextureCoords(m_intersectionBoxFacesTextureCoords.p(), RivIntersectionPartMgr::calculateNodeOrElementNodeBasedGeoMechTextureCoords(
vertexWeights, m_intersectionBoxFacesTextureCoords.p(), vertexWeights, resultValues, isElementNodalResult, femPart, mapper);
resultValues,
isElementNodalResult,
femPart,
mapper);
} }
RivScalarMapperUtils::applyTextureResultsToPart(m_intersectionBoxFaces.p(), RivScalarMapperUtils::applyTextureResultsToPart(m_intersectionBoxFaces.p(),
m_intersectionBoxFacesTextureCoords.p(), m_intersectionBoxFacesTextureCoords.p(),
mapper, mapper,
1.0, 1.0,
caf::FC_NONE, caf::FC_NONE,
geoView->isLightingDisabled()); geoView->isLightingDisabled());
} }
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivIntersectionBoxPartMgr::generatePartGeometry() void RivIntersectionBoxPartMgr::generatePartGeometry()
{ {
bool useBufferObjects = true; bool useBufferObjects = true;
// Surface geometry // Surface geometry
{ {
@@ -288,15 +277,14 @@ void RivIntersectionBoxPartMgr::generatePartGeometry()
updatePartEffect(); updatePartEffect();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivIntersectionBoxPartMgr::updatePartEffect() void RivIntersectionBoxPartMgr::updatePartEffect()
{ {
// Set deCrossSection effect // Set deCrossSection effect
caf::SurfaceEffectGenerator geometryEffgen(m_defaultColor, caf::PO_1); caf::SurfaceEffectGenerator geometryEffgen(m_defaultColor, caf::PO_1);
cvf::ref<cvf::Effect> geometryOnlyEffect = geometryEffgen.generateCachedEffect(); cvf::ref<cvf::Effect> geometryOnlyEffect = geometryEffgen.generateCachedEffect();
if (m_intersectionBoxFaces.notNull()) if (m_intersectionBoxFaces.notNull())
@@ -305,21 +293,20 @@ void RivIntersectionBoxPartMgr::updatePartEffect()
} }
// Update mesh colors as well, in case of change // Update mesh colors as well, in case of change
//RiaPreferences* prefs = RiaApplication::instance()->preferences(); // RiaPreferences* prefs = RiaApplication::instance()->preferences();
cvf::ref<cvf::Effect> eff; cvf::ref<cvf::Effect> eff;
caf::MeshEffectGenerator CrossSectionEffGen(cvf::Color3::WHITE);//prefs->defaultCrossSectionGridLineColors()); caf::MeshEffectGenerator CrossSectionEffGen(cvf::Color3::WHITE); // prefs->defaultCrossSectionGridLineColors());
eff = CrossSectionEffGen.generateCachedEffect(); eff = CrossSectionEffGen.generateCachedEffect();
if (m_intersectionBoxGridLines.notNull()) if (m_intersectionBoxGridLines.notNull())
{ {
m_intersectionBoxGridLines->setEffect(eff.p()); m_intersectionBoxGridLines->setEffect(eff.p());
} }
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivIntersectionBoxPartMgr::appendNativeCrossSectionFacesToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform) void RivIntersectionBoxPartMgr::appendNativeCrossSectionFacesToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform)
{ {
@@ -336,7 +323,7 @@ void RivIntersectionBoxPartMgr::appendNativeCrossSectionFacesToModel(cvf::ModelB
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivIntersectionBoxPartMgr::appendMeshLinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform) void RivIntersectionBoxPartMgr::appendMeshLinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform)
{ {
@@ -352,20 +339,19 @@ void RivIntersectionBoxPartMgr::appendMeshLinePartsToModel(cvf::ModelBasicList*
} }
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
cvf::ref<RivIntersectionHexGridInterface> RivIntersectionBoxPartMgr::createHexGridInterface() cvf::ref<RivIntersectionHexGridInterface> RivIntersectionBoxPartMgr::createHexGridInterface()
{ {
RimEclipseView* eclipseView; RimEclipseView* eclipseView;
m_rimIntersectionBox->firstAncestorOrThisOfType(eclipseView); m_rimIntersectionBox->firstAncestorOrThisOfType(eclipseView);
if (eclipseView) if (eclipseView)
{ {
RigMainGrid* grid = eclipseView->mainGrid(); RigMainGrid* grid = eclipseView->mainGrid();
return new RivEclipseIntersectionGrid(grid, eclipseView->currentActiveCellInfo(), m_rimIntersectionBox->showInactiveCells()); return new RivEclipseIntersectionGrid(
grid, eclipseView->currentActiveCellInfo(), m_rimIntersectionBox->showInactiveCells());
} }
RimGeoMechView* geoView; RimGeoMechView* geoView;
@@ -378,4 +364,3 @@ cvf::ref<RivIntersectionHexGridInterface> RivIntersectionBoxPartMgr::createHexGr
return nullptr; return nullptr;
} }

View File

@@ -1,17 +1,17 @@
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) Statoil ASA // Copyright (C) Statoil ASA
// //
// ResInsight is free software: you can redistribute it and/or modify // ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or // WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. // FITNESS FOR A PARTICULAR PURPOSE.
// //
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> // See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details. // for more details.
// //
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
@@ -23,13 +23,12 @@
#include "cvfBase.h" #include "cvfBase.h"
#include "cvfObject.h" #include "cvfObject.h"
namespace cvf namespace cvf
{ {
class ModelBasicList; class ModelBasicList;
class Transform; class Transform;
class Part; class Part;
} } // namespace cvf
class RigMainGrid; class RigMainGrid;
class RigResultAccessor; class RigResultAccessor;
@@ -60,13 +59,13 @@ private:
cvf::ref<RivIntersectionHexGridInterface> createHexGridInterface(); cvf::ref<RivIntersectionHexGridInterface> createHexGridInterface();
private: private:
RimIntersectionBox* m_rimIntersectionBox; RimIntersectionBox* m_rimIntersectionBox;
cvf::Color3f m_defaultColor; cvf::Color3f m_defaultColor;
cvf::ref<cvf::Part> m_intersectionBoxFaces; cvf::ref<cvf::Part> m_intersectionBoxFaces;
cvf::ref<cvf::Part> m_intersectionBoxGridLines; cvf::ref<cvf::Part> m_intersectionBoxGridLines;
cvf::ref<cvf::Vec2fArray> m_intersectionBoxFacesTextureCoords; cvf::ref<cvf::Vec2fArray> m_intersectionBoxFacesTextureCoords;
cvf::ref<RivIntersectionBoxGeometryGenerator> m_intersectionBoxGenerator; cvf::ref<RivIntersectionBoxGeometryGenerator> m_intersectionBoxGenerator;
}; };

View File

@@ -2,17 +2,17 @@
// //
// Copyright (C) Statoil ASA // Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS // Copyright (C) Ceetron Solutions AS
// //
// ResInsight is free software: you can redistribute it and/or modify // ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or // WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. // FITNESS FOR A PARTICULAR PURPOSE.
// //
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> // See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details. // for more details.
// //
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
@@ -70,46 +70,41 @@
#include "cvfGeometryTools.h" #include "cvfGeometryTools.h"
#include "cvfModelBasicList.h" #include "cvfModelBasicList.h"
#include "cvfPart.h" #include "cvfPart.h"
#include "cvfqtUtils.h"
#include "cvfPrimitiveSetDirect.h" #include "cvfPrimitiveSetDirect.h"
#include "cvfRenderState_FF.h"
#include "cvfRenderStateDepth.h" #include "cvfRenderStateDepth.h"
#include "cvfRenderStatePoint.h" #include "cvfRenderStatePoint.h"
#include "cvfRenderState_FF.h"
#include "cvfStructGridGeometryGenerator.h" #include "cvfStructGridGeometryGenerator.h"
#include "cvfTransform.h" #include "cvfTransform.h"
#include "cvfqtUtils.h"
#include <functional> #include <functional>
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RivIntersectionPartMgr::RivIntersectionPartMgr(RimIntersection* rimCrossSection, bool isFlattened) RivIntersectionPartMgr::RivIntersectionPartMgr(RimIntersection* rimCrossSection, bool isFlattened)
: m_rimCrossSection(rimCrossSection), : m_rimCrossSection(rimCrossSection)
m_isFlattened(isFlattened) , m_isFlattened(isFlattened)
{ {
CVF_ASSERT(m_rimCrossSection); CVF_ASSERT(m_rimCrossSection);
m_crossSectionFacesTextureCoords = new cvf::Vec2fArray; m_crossSectionFacesTextureCoords = new cvf::Vec2fArray;
cvf::Vec3d flattenedPolylineStartPoint; cvf::Vec3d flattenedPolylineStartPoint;
std::vector< std::vector <cvf::Vec3d> > polyLines = m_rimCrossSection->polyLines(&flattenedPolylineStartPoint); std::vector<std::vector<cvf::Vec3d>> polyLines = m_rimCrossSection->polyLines(&flattenedPolylineStartPoint);
if (polyLines.size() > 0) if (polyLines.size() > 0)
{ {
cvf::Vec3d direction = m_rimCrossSection->extrusionDirection(); cvf::Vec3d direction = m_rimCrossSection->extrusionDirection();
cvf::ref<RivIntersectionHexGridInterface> hexGrid = createHexGridInterface(); cvf::ref<RivIntersectionHexGridInterface> hexGrid = createHexGridInterface();
m_crossSectionGenerator = new RivIntersectionGeometryGenerator(m_rimCrossSection, m_crossSectionGenerator = new RivIntersectionGeometryGenerator(
polyLines, m_rimCrossSection, polyLines, direction, hexGrid.p(), m_isFlattened, flattenedPolylineStartPoint);
direction,
hexGrid.p(),
m_isFlattened,
flattenedPolylineStartPoint);
} }
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivIntersectionPartMgr::applySingleColorEffect() void RivIntersectionPartMgr::applySingleColorEffect()
{ {
@@ -129,7 +124,7 @@ void RivIntersectionPartMgr::applySingleColorEffect()
if (m_crossSectionGridLines.notNull()) if (m_crossSectionGridLines.notNull())
{ {
cvf::ref<cvf::Effect> eff; cvf::ref<cvf::Effect> eff;
caf::MeshEffectGenerator CrossSectionEffGen(prefs->defaultGridLineColors()); caf::MeshEffectGenerator CrossSectionEffGen(prefs->defaultGridLineColors());
eff = CrossSectionEffGen.generateCachedEffect(); eff = CrossSectionEffGen.generateCachedEffect();
@@ -138,7 +133,7 @@ void RivIntersectionPartMgr::applySingleColorEffect()
if (m_crossSectionFaultGridLines.notNull()) if (m_crossSectionFaultGridLines.notNull())
{ {
cvf::ref<cvf::Effect> eff; cvf::ref<cvf::Effect> eff;
caf::MeshEffectGenerator CrossSectionEffGen(prefs->defaultFaultGridLineColors()); caf::MeshEffectGenerator CrossSectionEffGen(prefs->defaultFaultGridLineColors());
eff = CrossSectionEffGen.generateCachedEffect(); eff = CrossSectionEffGen.generateCachedEffect();
@@ -147,10 +142,10 @@ void RivIntersectionPartMgr::applySingleColorEffect()
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex, void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex,
const cvf::ScalarMapper* scalarColorMapper, const cvf::ScalarMapper* scalarColorMapper,
const RivTernaryScalarMapper* ternaryColorMapper) const RivTernaryScalarMapper* ternaryColorMapper)
{ {
CVF_ASSERT(scalarColorMapper); CVF_ASSERT(scalarColorMapper);
@@ -174,8 +169,9 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex,
if (cellResultColors->isTernarySaturationSelected()) if (cellResultColors->isTernarySaturationSelected())
{ {
RivTernaryTextureCoordsCreator texturer(cellResultColors, ternaryColorMapper, timeStepIndex); RivTernaryTextureCoordsCreator texturer(cellResultColors, ternaryColorMapper, timeStepIndex);
texturer.createTextureCoords(m_crossSectionFacesTextureCoords.p(), m_crossSectionGenerator->triangleToCellIndex()); texturer.createTextureCoords(m_crossSectionFacesTextureCoords.p(),
m_crossSectionGenerator->triangleToCellIndex());
RivScalarMapperUtils::applyTernaryTextureResultsToPart(m_crossSectionFaces.p(), RivScalarMapperUtils::applyTernaryTextureResultsToPart(m_crossSectionFaces.p(),
m_crossSectionFacesTextureCoords.p(), m_crossSectionFacesTextureCoords.p(),
@@ -196,17 +192,14 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex,
} }
else else
{ {
resultAccessor = RigResultAccessorFactory::createFromResultDefinition(cellResultColors->reservoirView()->eclipseCase()->eclipseCaseData(), resultAccessor = RigResultAccessorFactory::createFromResultDefinition(
0, cellResultColors->reservoirView()->eclipseCase()->eclipseCaseData(), 0, timeStepIndex, cellResultColors);
timeStepIndex,
cellResultColors);
} }
RivIntersectionPartMgr::calculateEclipseTextureCoordinates(m_crossSectionFacesTextureCoords.p(), RivIntersectionPartMgr::calculateEclipseTextureCoordinates(m_crossSectionFacesTextureCoords.p(),
m_crossSectionGenerator->triangleToCellIndex(), m_crossSectionGenerator->triangleToCellIndex(),
resultAccessor.p(), resultAccessor.p(),
scalarColorMapper); scalarColorMapper);
RivScalarMapperUtils::applyTextureResultsToPart(m_crossSectionFaces.p(), RivScalarMapperUtils::applyTextureResultsToPart(m_crossSectionFaces.p(),
m_crossSectionFacesTextureCoords.p(), m_crossSectionFacesTextureCoords.p(),
@@ -214,7 +207,7 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex,
1.0, 1.0,
caf::FC_NONE, caf::FC_NONE,
eclipseView->isLightingDisabled()); eclipseView->isLightingDisabled());
} }
} }
} }
@@ -224,38 +217,35 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex,
if (geoView) if (geoView)
{ {
RimGeoMechCellColors* cellResultColors = geoView->cellResult(); RimGeoMechCellColors* cellResultColors = geoView->cellResult();
RigGeoMechCaseData* caseData = cellResultColors->ownerCaseData(); RigGeoMechCaseData* caseData = cellResultColors->ownerCaseData();
if (!caseData) return; if (!caseData) return;
RigFemResultAddress resVarAddress = cellResultColors->resultAddress(); RigFemResultAddress resVarAddress = cellResultColors->resultAddress();
if (resVarAddress.resultPosType == RIG_ELEMENT) if (resVarAddress.resultPosType == RIG_ELEMENT)
{ {
const std::vector<float>& resultValues = caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex); const std::vector<float>& resultValues =
const std::vector<size_t>& triangleToCellIdx = m_crossSectionGenerator->triangleToCellIndex(); caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex);
const std::vector<size_t>& triangleToCellIdx = m_crossSectionGenerator->triangleToCellIndex();
RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords(m_crossSectionFacesTextureCoords.p(),
resultValues,
triangleToCellIdx,
scalarColorMapper);
RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords(
m_crossSectionFacesTextureCoords.p(), resultValues, triangleToCellIdx, scalarColorMapper);
} }
else if(resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE) else if (resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE)
{ {
// Special direction sensitive result calculation // Special direction sensitive result calculation
const cvf::Vec3fArray* triangelVxes = m_crossSectionGenerator->triangleVxes(); const cvf::Vec3fArray* triangelVxes = m_crossSectionGenerator->triangleVxes();
if (resVarAddress.componentName == "Pazi" || resVarAddress.componentName == "Pinc") if (resVarAddress.componentName == "Pazi" || resVarAddress.componentName == "Pinc")
{ {
RivIntersectionPartMgr::calculatePlaneAngleTextureCoords(m_crossSectionFacesTextureCoords.p(), RivIntersectionPartMgr::calculatePlaneAngleTextureCoords(
triangelVxes, m_crossSectionFacesTextureCoords.p(), triangelVxes, resVarAddress, scalarColorMapper);
resVarAddress,
scalarColorMapper);
} }
else else
{ {
const std::vector<RivIntersectionVertexWeights> &vertexWeights = m_crossSectionGenerator->triangleVxToCellCornerInterpolationWeights(); const std::vector<RivIntersectionVertexWeights>& vertexWeights =
m_crossSectionGenerator->triangleVxToCellCornerInterpolationWeights();
RivIntersectionPartMgr::calculateGeoMechTensorXfTextureCoords(m_crossSectionFacesTextureCoords.p(), RivIntersectionPartMgr::calculateGeoMechTensorXfTextureCoords(m_crossSectionFacesTextureCoords.p(),
triangelVxes, triangelVxes,
@@ -269,12 +259,15 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex,
else else
{ {
// Do a "Hack" to show elm nodal and not nodal POR results // Do a "Hack" to show elm nodal and not nodal POR results
if (resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar") resVarAddress.resultPosType = RIG_ELEMENT_NODAL; if (resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar")
resVarAddress.resultPosType = RIG_ELEMENT_NODAL;
const std::vector<float>& resultValues = caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex); const std::vector<float>& resultValues =
RigFemPart* femPart = caseData->femParts()->part(0); caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex);
bool isElementNodalResult = !(resVarAddress.resultPosType == RIG_NODAL); RigFemPart* femPart = caseData->femParts()->part(0);
const std::vector<RivIntersectionVertexWeights> &vertexWeights = m_crossSectionGenerator->triangleVxToCellCornerInterpolationWeights(); bool isElementNodalResult = !(resVarAddress.resultPosType == RIG_NODAL);
const std::vector<RivIntersectionVertexWeights>& vertexWeights =
m_crossSectionGenerator->triangleVxToCellCornerInterpolationWeights();
RivIntersectionPartMgr::calculateNodeOrElementNodeBasedGeoMechTextureCoords(m_crossSectionFacesTextureCoords.p(), RivIntersectionPartMgr::calculateNodeOrElementNodeBasedGeoMechTextureCoords(m_crossSectionFacesTextureCoords.p(),
vertexWeights, vertexWeights,
@@ -284,25 +277,25 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex,
scalarColorMapper); scalarColorMapper);
} }
RivScalarMapperUtils::applyTextureResultsToPart(m_crossSectionFaces.p(), RivScalarMapperUtils::applyTextureResultsToPart(m_crossSectionFaces.p(),
m_crossSectionFacesTextureCoords.p(), m_crossSectionFacesTextureCoords.p(),
scalarColorMapper, scalarColorMapper,
1.0, 1.0,
caf::FC_NONE, caf::FC_NONE,
geoView->isLightingDisabled()); geoView->isLightingDisabled());
} }
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivIntersectionPartMgr::calculateNodeOrElementNodeBasedGeoMechTextureCoords(cvf::Vec2fArray* textureCoords, void RivIntersectionPartMgr::calculateNodeOrElementNodeBasedGeoMechTextureCoords(
const std::vector<RivIntersectionVertexWeights> &vertexWeights, cvf::Vec2fArray* textureCoords,
const std::vector<float> &resultValues, const std::vector<RivIntersectionVertexWeights>& vertexWeights,
bool isElementNodalResult, const std::vector<float>& resultValues,
const RigFemPart* femPart, bool isElementNodalResult,
const cvf::ScalarMapper* mapper) const RigFemPart* femPart,
const cvf::ScalarMapper* mapper)
{ {
textureCoords->resize(vertexWeights.size()); textureCoords->resize(vertexWeights.size());
@@ -319,8 +312,8 @@ void RivIntersectionPartMgr::calculateNodeOrElementNodeBasedGeoMechTextureCoords
#pragma omp parallel for schedule(dynamic) #pragma omp parallel for schedule(dynamic)
for (int triangleVxIdx = 0; triangleVxIdx < vxCount; ++triangleVxIdx) for (int triangleVxIdx = 0; triangleVxIdx < vxCount; ++triangleVxIdx)
{ {
float resValue = 0; float resValue = 0;
int weightCount = vertexWeights[triangleVxIdx].size(); int weightCount = vertexWeights[triangleVxIdx].size();
for (int wIdx = 0; wIdx < weightCount; ++wIdx) for (int wIdx = 0; wIdx < weightCount; ++wIdx)
{ {
size_t resIdx; size_t resIdx;
@@ -332,13 +325,13 @@ void RivIntersectionPartMgr::calculateNodeOrElementNodeBasedGeoMechTextureCoords
{ {
resIdx = femPart->nodeIdxFromElementNodeResultIdx(vertexWeights[triangleVxIdx].vxId(wIdx)); resIdx = femPart->nodeIdxFromElementNodeResultIdx(vertexWeights[triangleVxIdx].vxId(wIdx));
} }
resValue += resultValues[resIdx] * vertexWeights[triangleVxIdx].weight(wIdx); resValue += resultValues[resIdx] * vertexWeights[triangleVxIdx].weight(wIdx);
} }
if (resValue == HUGE_VAL || resValue != resValue) // a != a is true for NAN's if (resValue == HUGE_VAL || resValue != resValue) // a != a is true for NAN's
{ {
rawPtr[triangleVxIdx][1] = 1.0f; rawPtr[triangleVxIdx][1] = 1.0f;
} }
else else
{ {
@@ -349,14 +342,14 @@ void RivIntersectionPartMgr::calculateNodeOrElementNodeBasedGeoMechTextureCoords
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords(cvf::Vec2fArray* textureCoords, void RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords(cvf::Vec2fArray* textureCoords,
const std::vector<float> &resultValues, const std::vector<float>& resultValues,
const std::vector<size_t>& triangleToCellIdx, const std::vector<size_t>& triangleToCellIdx,
const cvf::ScalarMapper* mapper) const cvf::ScalarMapper* mapper)
{ {
textureCoords->resize(triangleToCellIdx.size()*3); textureCoords->resize(triangleToCellIdx.size() * 3);
if (resultValues.size() == 0) if (resultValues.size() == 0)
{ {
@@ -368,20 +361,20 @@ void RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords(cvf::Vec2
for (size_t triangleIdx = 0; triangleIdx < triangleToCellIdx.size(); triangleIdx++) for (size_t triangleIdx = 0; triangleIdx < triangleToCellIdx.size(); triangleIdx++)
{ {
size_t resIdx = triangleToCellIdx[triangleIdx]; size_t resIdx = triangleToCellIdx[triangleIdx];
float resValue = resultValues[resIdx]; float resValue = resultValues[resIdx];
size_t triangleVxIdx = triangleIdx * 3; size_t triangleVxIdx = triangleIdx * 3;
if (resValue == HUGE_VAL || resValue != resValue) // a != a is true for NAN's if (resValue == HUGE_VAL || resValue != resValue) // a != a is true for NAN's
{ {
rawPtr[triangleVxIdx][1] = 1.0f; rawPtr[triangleVxIdx][1] = 1.0f;
rawPtr[triangleVxIdx + 1][1] = 1.0f; rawPtr[triangleVxIdx + 1][1] = 1.0f;
rawPtr[triangleVxIdx + 2][1] = 1.0f; rawPtr[triangleVxIdx + 2][1] = 1.0f;
} }
else else
{ {
rawPtr[triangleVxIdx] = mapper->mapToTextureCoord(resValue); rawPtr[triangleVxIdx] = mapper->mapToTextureCoord(resValue);
rawPtr[triangleVxIdx + 1] = mapper->mapToTextureCoord(resValue); rawPtr[triangleVxIdx + 1] = mapper->mapToTextureCoord(resValue);
rawPtr[triangleVxIdx + 2] = mapper->mapToTextureCoord(resValue); rawPtr[triangleVxIdx + 2] = mapper->mapToTextureCoord(resValue);
} }
@@ -390,96 +383,97 @@ void RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords(cvf::Vec2
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivIntersectionPartMgr::calculateGeoMechTensorXfTextureCoords(cvf::Vec2fArray* textureCoords, void RivIntersectionPartMgr::calculateGeoMechTensorXfTextureCoords(cvf::Vec2fArray* textureCoords,
const cvf::Vec3fArray* triangelVertices, const cvf::Vec3fArray* triangelVertices,
const std::vector<RivIntersectionVertexWeights> &vertexWeights, const std::vector<RivIntersectionVertexWeights>& vertexWeights,
RigGeoMechCaseData* caseData, RigGeoMechCaseData* caseData,
const RigFemResultAddress& resVarAddress, const RigFemResultAddress& resVarAddress,
int timeStepIdx, int timeStepIdx,
const cvf::ScalarMapper* mapper) const cvf::ScalarMapper* mapper)
{ {
RiuGeoMechXfTensorResultAccessor accessor(caseData->femPartResults(), resVarAddress, timeStepIdx); RiuGeoMechXfTensorResultAccessor accessor(caseData->femPartResults(), resVarAddress, timeStepIdx);
textureCoords->resize(vertexWeights.size()); textureCoords->resize(vertexWeights.size());
cvf::Vec2f* rawPtr = textureCoords->ptr(); cvf::Vec2f* rawPtr = textureCoords->ptr();
int vxCount = static_cast<int>(vertexWeights.size()); int vxCount = static_cast<int>(vertexWeights.size());
int triCount = vxCount/3; int triCount = vxCount / 3;
#pragma omp parallel for schedule(dynamic) #pragma omp parallel for schedule(dynamic)
for ( int triangleIdx = 0; triangleIdx < triCount; ++triangleIdx ) for (int triangleIdx = 0; triangleIdx < triCount; ++triangleIdx)
{ {
int triangleVxStartIdx = triangleIdx*3; int triangleVxStartIdx = triangleIdx * 3;
float values[3]; float values[3];
accessor.calculateInterpolatedValue(&((*triangelVertices)[triangleVxStartIdx]), &(vertexWeights[triangleVxStartIdx]), values ); accessor.calculateInterpolatedValue(
&((*triangelVertices)[triangleVxStartIdx]), &(vertexWeights[triangleVxStartIdx]), values);
rawPtr[triangleVxStartIdx + 0] = (values[0] != std::numeric_limits<float>::infinity()) ? mapper->mapToTextureCoord(values[0]) : cvf::Vec2f(0.0f, 1.0f); rawPtr[triangleVxStartIdx + 0] =
rawPtr[triangleVxStartIdx + 1] = (values[1] != std::numeric_limits<float>::infinity()) ? mapper->mapToTextureCoord(values[1]) : cvf::Vec2f(0.0f, 1.0f); (values[0] != std::numeric_limits<float>::infinity()) ? mapper->mapToTextureCoord(values[0]) : cvf::Vec2f(0.0f, 1.0f);
rawPtr[triangleVxStartIdx + 2] = (values[2] != std::numeric_limits<float>::infinity()) ? mapper->mapToTextureCoord(values[2]) : cvf::Vec2f(0.0f, 1.0f); rawPtr[triangleVxStartIdx + 1] =
(values[1] != std::numeric_limits<float>::infinity()) ? mapper->mapToTextureCoord(values[1]) : cvf::Vec2f(0.0f, 1.0f);
rawPtr[triangleVxStartIdx + 2] =
(values[2] != std::numeric_limits<float>::infinity()) ? mapper->mapToTextureCoord(values[2]) : cvf::Vec2f(0.0f, 1.0f);
} }
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivIntersectionPartMgr::calculatePlaneAngleTextureCoords(cvf::Vec2fArray* textureCoords, void RivIntersectionPartMgr::calculatePlaneAngleTextureCoords(cvf::Vec2fArray* textureCoords,
const cvf::Vec3fArray* triangelVertices, const cvf::Vec3fArray* triangelVertices,
const RigFemResultAddress& resVarAddress, const RigFemResultAddress& resVarAddress,
const cvf::ScalarMapper* mapper) const cvf::ScalarMapper* mapper)
{ {
textureCoords->resize(triangelVertices->size()); textureCoords->resize(triangelVertices->size());
cvf::Vec2f* rawPtr = textureCoords->ptr(); cvf::Vec2f* rawPtr = textureCoords->ptr();
int vxCount = static_cast<int>(triangelVertices->size()); int vxCount = static_cast<int>(triangelVertices->size());
int triCount = vxCount/3; int triCount = vxCount / 3;
std::function<float (const RiaOffshoreSphericalCoords& )> operation; std::function<float(const RiaOffshoreSphericalCoords&)> operation;
if (resVarAddress.componentName == "Pazi") if (resVarAddress.componentName == "Pazi")
{ {
operation = [](const RiaOffshoreSphericalCoords& sphCoord) { return (float)sphCoord.azi();}; operation = [](const RiaOffshoreSphericalCoords& sphCoord) { return (float)sphCoord.azi(); };
} }
else if ( resVarAddress.componentName == "Pinc" ) else if (resVarAddress.componentName == "Pinc")
{ {
operation = [](const RiaOffshoreSphericalCoords& sphCoord) { return (float)sphCoord.inc();}; operation = [](const RiaOffshoreSphericalCoords& sphCoord) { return (float)sphCoord.inc(); };
} }
#pragma omp parallel for schedule(dynamic) #pragma omp parallel for schedule(dynamic)
for ( int triangleIdx = 0; triangleIdx < triCount; ++triangleIdx ) for (int triangleIdx = 0; triangleIdx < triCount; ++triangleIdx)
{ {
int triangleVxStartIdx = triangleIdx*3; int triangleVxStartIdx = triangleIdx * 3;
const cvf::Vec3f* triangle = &((*triangelVertices)[triangleVxStartIdx]); const cvf::Vec3f* triangle = &((*triangelVertices)[triangleVxStartIdx]);
cvf::Mat3f rotMx = cvf::GeometryTools::computePlaneHorizontalRotationMx(triangle[1] - triangle[0], triangle[2] - triangle[0]); cvf::Mat3f rotMx =
cvf::GeometryTools::computePlaneHorizontalRotationMx(triangle[1] - triangle[0], triangle[2] - triangle[0]);
RiaOffshoreSphericalCoords sphCoord(cvf::Vec3f(rotMx.rowCol(0, 2), rotMx.rowCol(1, 2), rotMx.rowCol(2, 2))); // Use Ez from the matrix as plane normal RiaOffshoreSphericalCoords sphCoord(
cvf::Vec3f(rotMx.rowCol(0, 2), rotMx.rowCol(1, 2), rotMx.rowCol(2, 2))); // Use Ez from the matrix as plane normal
float angle = cvf::Math::toDegrees( operation(sphCoord)); float angle = cvf::Math::toDegrees(operation(sphCoord));
cvf::Vec2f texCoord = (angle != std::numeric_limits<float>::infinity()) ? mapper->mapToTextureCoord(angle) : cvf::Vec2f(0.0f, 1.0f); cvf::Vec2f texCoord =
(angle != std::numeric_limits<float>::infinity()) ? mapper->mapToTextureCoord(angle) : cvf::Vec2f(0.0f, 1.0f);
rawPtr[triangleVxStartIdx + 0] = texCoord; rawPtr[triangleVxStartIdx + 0] = texCoord;
rawPtr[triangleVxStartIdx + 1] = texCoord; rawPtr[triangleVxStartIdx + 1] = texCoord;
rawPtr[triangleVxStartIdx + 2] = texCoord; rawPtr[triangleVxStartIdx + 2] = texCoord;
} }
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// Calculates the texture coordinates in a "nearly" one dimensional texture. /// Calculates the texture coordinates in a "nearly" one dimensional texture.
/// Undefined values are coded with a y-texturecoordinate value of 1.0 instead of the normal 0.5 /// Undefined values are coded with a y-texturecoordinate value of 1.0 instead of the normal 0.5
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivIntersectionPartMgr::calculateEclipseTextureCoordinates(cvf::Vec2fArray* textureCoords, void RivIntersectionPartMgr::calculateEclipseTextureCoordinates(cvf::Vec2fArray* textureCoords,
const std::vector<size_t>& triangleToCellIdxMap, const std::vector<size_t>& triangleToCellIdxMap,
const RigResultAccessor* resultAccessor, const RigResultAccessor* resultAccessor,
const cvf::ScalarMapper* mapper) const cvf::ScalarMapper* mapper)
{ {
if (!resultAccessor) return; if (!resultAccessor) return;
size_t numVertices = triangleToCellIdxMap.size()*3; size_t numVertices = triangleToCellIdxMap.size() * 3;
textureCoords->resize(numVertices); textureCoords->resize(numVertices);
cvf::Vec2f* rawPtr = textureCoords->ptr(); cvf::Vec2f* rawPtr = textureCoords->ptr();
@@ -489,8 +483,8 @@ void RivIntersectionPartMgr::calculateEclipseTextureCoordinates(cvf::Vec2fArray*
#pragma omp parallel for #pragma omp parallel for
for (int tIdx = 0; tIdx < triangleCount; tIdx++) for (int tIdx = 0; tIdx < triangleCount; tIdx++)
{ {
double cellScalarValue = resultAccessor->cellScalarGlobIdx(triangleToCellIdxMap[tIdx]); double cellScalarValue = resultAccessor->cellScalarGlobIdx(triangleToCellIdxMap[tIdx]);
cvf::Vec2f texCoord = mapper->mapToTextureCoord(cellScalarValue); cvf::Vec2f texCoord = mapper->mapToTextureCoord(cellScalarValue);
if (cellScalarValue == HUGE_VAL || cellScalarValue != cellScalarValue) // a != a is true for NAN's if (cellScalarValue == HUGE_VAL || cellScalarValue != cellScalarValue) // a != a is true for NAN's
{ {
texCoord[1] = 1.0f; texCoord[1] = 1.0f;
@@ -498,14 +492,14 @@ void RivIntersectionPartMgr::calculateEclipseTextureCoordinates(cvf::Vec2fArray*
size_t j; size_t j;
for (j = 0; j < 3; j++) for (j = 0; j < 3; j++)
{ {
rawPtr[tIdx*3 + j] = texCoord; rawPtr[tIdx * 3 + j] = texCoord;
} }
} }
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivIntersectionPartMgr::generatePartGeometry() void RivIntersectionPartMgr::generatePartGeometry()
{ {
@@ -597,11 +591,11 @@ void RivIntersectionPartMgr::generatePartGeometry()
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivIntersectionPartMgr::createFaultLabelParts(const std::vector<std::pair<QString, cvf::Vec3d> >& labelAndAnchors) void RivIntersectionPartMgr::createFaultLabelParts(const std::vector<std::pair<QString, cvf::Vec3d>>& labelAndAnchors)
{ {
m_faultMeshLabels = nullptr; m_faultMeshLabels = nullptr;
m_faultMeshLabelLines = nullptr; m_faultMeshLabelLines = nullptr;
if (!labelAndAnchors.size()) return; if (!labelAndAnchors.size()) return;
@@ -611,9 +605,9 @@ void RivIntersectionPartMgr::createFaultLabelParts(const std::vector<std::pair<Q
RimFaultInViewCollection* faultInViewColl = eclipseView->faultCollection(); RimFaultInViewCollection* faultInViewColl = eclipseView->faultCollection();
if (!(eclipseView && faultInViewColl->showFaultLabel())) return; if (!(eclipseView && faultInViewColl->showFaultLabel())) return;
cvf::Color3f defWellLabelColor = faultInViewColl->faultLabelColor(); cvf::Color3f defWellLabelColor = faultInViewColl->faultLabelColor();
cvf::Font* font = RiaApplication::instance()->customFont(); cvf::Font* font = RiaApplication::instance()->customFont();
std::vector<cvf::Vec3f> lineVertices; std::vector<cvf::Vec3f> lineVertices;
@@ -627,18 +621,18 @@ void RivIntersectionPartMgr::createFaultLabelParts(const std::vector<std::pair<Q
drawableText->setTextColor(defWellLabelColor); drawableText->setTextColor(defWellLabelColor);
} }
cvf::BoundingBox bb = m_crossSectionFaces->boundingBox(); cvf::BoundingBox bb = m_crossSectionFaces->boundingBox();
double labelZOffset = bb.extent().z() / 10; double labelZOffset = bb.extent().z() / 10;
int visibleFaultNameCount = 0; int visibleFaultNameCount = 0;
for (const auto& labelAndAnchorPair : labelAndAnchors) for (const auto& labelAndAnchorPair : labelAndAnchors)
{ {
RimFaultInView* fault = faultInViewColl->findFaultByName(labelAndAnchorPair.first); RimFaultInView* fault = faultInViewColl->findFaultByName(labelAndAnchorPair.first);
if (!(fault && fault->showFault())) continue; if (!(fault && fault->showFault())) continue;
cvf::String cvfString = cvfqt::Utils::toString(labelAndAnchorPair.first); cvf::String cvfString = cvfqt::Utils::toString(labelAndAnchorPair.first);
cvf::Vec3f textCoord(labelAndAnchorPair.second); cvf::Vec3f textCoord(labelAndAnchorPair.second);
textCoord.z() += labelZOffset; textCoord.z() += labelZOffset;
drawableText->addText(cvfString, textCoord); drawableText->addText(cvfString, textCoord);
@@ -684,16 +678,15 @@ void RivIntersectionPartMgr::createFaultLabelParts(const std::vector<std::pair<Q
part->updateBoundingBox(); part->updateBoundingBox();
caf::MeshEffectGenerator gen(RiaApplication::instance()->preferences()->defaultFaultGridLineColors()); caf::MeshEffectGenerator gen(RiaApplication::instance()->preferences()->defaultFaultGridLineColors());
cvf::ref<cvf::Effect> eff = gen.generateCachedEffect(); cvf::ref<cvf::Effect> eff = gen.generateCachedEffect();
part->setEffect(eff.p()); part->setEffect(eff.p());
m_faultMeshLabelLines = part; m_faultMeshLabelLines = part;
} }
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivIntersectionPartMgr::createPolyLineParts(bool useBufferObjects) void RivIntersectionPartMgr::createPolyLineParts(bool useBufferObjects)
{ {
@@ -721,9 +714,9 @@ void RivIntersectionPartMgr::createPolyLineParts(bool useBufferObjects)
part->setPriority(RivPartPriority::PartType::Highlight); part->setPriority(RivPartPriority::PartType::Highlight);
// Always show this part, also when mesh is turned off // Always show this part, also when mesh is turned off
//part->setEnableMask(meshFaultBit); // part->setEnableMask(meshFaultBit);
cvf::ref<cvf::Effect> eff; cvf::ref<cvf::Effect> eff;
caf::MeshEffectGenerator lineEffGen(cvf::Color3::MAGENTA); caf::MeshEffectGenerator lineEffGen(cvf::Color3::MAGENTA);
eff = lineEffGen.generateUnCachedEffect(); eff = lineEffGen.generateUnCachedEffect();
@@ -753,9 +746,9 @@ void RivIntersectionPartMgr::createPolyLineParts(bool useBufferObjects)
part->setPriority(RivPartPriority::PartType::Highlight); part->setPriority(RivPartPriority::PartType::Highlight);
// Always show this part, also when mesh is turned off // Always show this part, also when mesh is turned off
//part->setEnableMask(meshFaultBit); // part->setEnableMask(meshFaultBit);
cvf::ref<cvf::Effect> eff; cvf::ref<cvf::Effect> eff;
caf::MeshEffectGenerator lineEffGen(cvf::Color3::MAGENTA); caf::MeshEffectGenerator lineEffGen(cvf::Color3::MAGENTA);
eff = lineEffGen.generateUnCachedEffect(); eff = lineEffGen.generateUnCachedEffect();
@@ -763,7 +756,7 @@ void RivIntersectionPartMgr::createPolyLineParts(bool useBufferObjects)
depth->enableDepthTest(false); depth->enableDepthTest(false);
eff->setRenderState(depth.p()); eff->setRenderState(depth.p());
cvf::ref<cvf::RenderStatePoint> pointRendState = new cvf::RenderStatePoint(cvf::RenderStatePoint::FIXED_SIZE); cvf::ref<cvf::RenderStatePoint> pointRendState = new cvf::RenderStatePoint(cvf::RenderStatePoint::FIXED_SIZE);
pointRendState->setSize(5.0f); pointRendState->setSize(5.0f);
eff->setRenderState(pointRendState.p()); eff->setRenderState(pointRendState.p());
@@ -775,7 +768,7 @@ void RivIntersectionPartMgr::createPolyLineParts(bool useBufferObjects)
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivIntersectionPartMgr::createExtrusionDirParts(bool useBufferObjects) void RivIntersectionPartMgr::createExtrusionDirParts(bool useBufferObjects)
{ {
@@ -785,7 +778,8 @@ void RivIntersectionPartMgr::createExtrusionDirParts(bool useBufferObjects)
if (m_rimCrossSection->direction() == RimIntersection::CS_TWO_POINTS) if (m_rimCrossSection->direction() == RimIntersection::CS_TWO_POINTS)
{ {
{ {
cvf::ref<cvf::DrawableGeo> polylineGeo = m_crossSectionGenerator->createLineAlongExtrusionLineDrawable(m_rimCrossSection->polyLinesForExtrusionDirection()); cvf::ref<cvf::DrawableGeo> polylineGeo = m_crossSectionGenerator->createLineAlongExtrusionLineDrawable(
m_rimCrossSection->polyLinesForExtrusionDirection());
if (polylineGeo.notNull()) if (polylineGeo.notNull())
{ {
if (useBufferObjects) if (useBufferObjects)
@@ -801,9 +795,9 @@ void RivIntersectionPartMgr::createExtrusionDirParts(bool useBufferObjects)
part->setPriority(RivPartPriority::PartType::Highlight); part->setPriority(RivPartPriority::PartType::Highlight);
// Always show this part, also when mesh is turned off // Always show this part, also when mesh is turned off
//part->setEnableMask(meshFaultBit); // part->setEnableMask(meshFaultBit);
cvf::ref<cvf::Effect> eff; cvf::ref<cvf::Effect> eff;
caf::MeshEffectGenerator lineEffGen(cvf::Color3::MAGENTA); caf::MeshEffectGenerator lineEffGen(cvf::Color3::MAGENTA);
eff = lineEffGen.generateUnCachedEffect(); eff = lineEffGen.generateUnCachedEffect();
@@ -817,7 +811,8 @@ void RivIntersectionPartMgr::createExtrusionDirParts(bool useBufferObjects)
} }
} }
cvf::ref<cvf::DrawableGeo> polylinePointsGeo = m_crossSectionGenerator->createPointsFromExtrusionLineDrawable(m_rimCrossSection->polyLinesForExtrusionDirection()); cvf::ref<cvf::DrawableGeo> polylinePointsGeo =
m_crossSectionGenerator->createPointsFromExtrusionLineDrawable(m_rimCrossSection->polyLinesForExtrusionDirection());
if (polylinePointsGeo.notNull()) if (polylinePointsGeo.notNull())
{ {
if (useBufferObjects) if (useBufferObjects)
@@ -833,9 +828,9 @@ void RivIntersectionPartMgr::createExtrusionDirParts(bool useBufferObjects)
part->setPriority(RivPartPriority::PartType::Highlight); part->setPriority(RivPartPriority::PartType::Highlight);
// Always show this part, also when mesh is turned off // Always show this part, also when mesh is turned off
//part->setEnableMask(meshFaultBit); // part->setEnableMask(meshFaultBit);
cvf::ref<cvf::Effect> eff; cvf::ref<cvf::Effect> eff;
caf::MeshEffectGenerator lineEffGen(cvf::Color3::MAGENTA); caf::MeshEffectGenerator lineEffGen(cvf::Color3::MAGENTA);
eff = lineEffGen.generateUnCachedEffect(); eff = lineEffGen.generateUnCachedEffect();
@@ -843,7 +838,7 @@ void RivIntersectionPartMgr::createExtrusionDirParts(bool useBufferObjects)
depth->enableDepthTest(false); depth->enableDepthTest(false);
eff->setRenderState(depth.p()); eff->setRenderState(depth.p());
cvf::ref<cvf::RenderStatePoint> pointRendState = new cvf::RenderStatePoint(cvf::RenderStatePoint::FIXED_SIZE); cvf::ref<cvf::RenderStatePoint> pointRendState = new cvf::RenderStatePoint(cvf::RenderStatePoint::FIXED_SIZE);
pointRendState->setSize(5.0f); pointRendState->setSize(5.0f);
eff->setRenderState(pointRendState.p()); eff->setRenderState(pointRendState.p());
@@ -855,12 +850,10 @@ void RivIntersectionPartMgr::createExtrusionDirParts(bool useBufferObjects)
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
cvf::ref<cvf::Part> createStdSurfacePart(cvf::DrawableGeo* geometry, cvf::ref<cvf::Part>
const cvf::Color3f& color, createStdSurfacePart(cvf::DrawableGeo* geometry, const cvf::Color3f& color, cvf::String name, cvf::Object* sourceInfo)
cvf::String name,
cvf::Object* sourceInfo)
{ {
if (!geometry) return nullptr; if (!geometry) return nullptr;
@@ -869,7 +862,7 @@ cvf::ref<cvf::Part> createStdSurfacePart(cvf::DrawableGeo* geometry,
part->setDrawable(geometry); part->setDrawable(geometry);
caf::SurfaceEffectGenerator surfaceGen(color, caf::PO_1); caf::SurfaceEffectGenerator surfaceGen(color, caf::PO_1);
cvf::ref<cvf::Effect> eff = surfaceGen.generateCachedEffect(); cvf::ref<cvf::Effect> eff = surfaceGen.generateCachedEffect();
part->setEffect(eff.p()); part->setEffect(eff.p());
part->setSourceInfo(sourceInfo); part->setSourceInfo(sourceInfo);
@@ -879,21 +872,18 @@ cvf::ref<cvf::Part> createStdSurfacePart(cvf::DrawableGeo* geometry,
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
cvf::ref<cvf::Part> createStdLinePart(cvf::DrawableGeo* geometry, cvf::ref<cvf::Part> createStdLinePart(cvf::DrawableGeo* geometry, const cvf::Color3f& color, cvf::String name)
const cvf::Color3f& color,
cvf::String name)
{ {
if ( !geometry ) return nullptr; if (!geometry) return nullptr;
cvf::ref<cvf::Part> part = new cvf::Part; cvf::ref<cvf::Part> part = new cvf::Part;
part->setName(name); part->setName(name);
part->setDrawable(geometry); part->setDrawable(geometry);
caf::MeshEffectGenerator gen(color); caf::MeshEffectGenerator gen(color);
cvf::ref<cvf::Effect> eff = gen.generateCachedEffect(); cvf::ref<cvf::Effect> eff = gen.generateCachedEffect();
part->setEffect(eff.p()); part->setEffect(eff.p());
part->updateBoundingBox(); part->updateBoundingBox();
@@ -902,7 +892,7 @@ cvf::ref<cvf::Part> createStdLinePart(cvf::DrawableGeo* geometry,
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivIntersectionPartMgr::appendNativeCrossSectionFacesToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform) void RivIntersectionPartMgr::appendNativeCrossSectionFacesToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform)
{ {
@@ -918,9 +908,8 @@ void RivIntersectionPartMgr::appendNativeCrossSectionFacesToModel(cvf::ModelBasi
} }
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivIntersectionPartMgr::appendMeshLinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform) void RivIntersectionPartMgr::appendMeshLinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform)
{ {
@@ -952,14 +941,14 @@ void RivIntersectionPartMgr::appendMeshLinePartsToModel(cvf::ModelBasicList* mod
m_faultMeshLabels->setTransform(scaleTransform); m_faultMeshLabels->setTransform(scaleTransform);
model->addPart(m_faultMeshLabels.p()); model->addPart(m_faultMeshLabels.p());
} }
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivIntersectionPartMgr::appendPolylinePartsToModel(Rim3dView &view, cvf::ModelBasicList* model, cvf::Transform* scaleTransform) void RivIntersectionPartMgr::appendPolylinePartsToModel(Rim3dView& view,
cvf::ModelBasicList* model,
cvf::Transform* scaleTransform)
{ {
Rim2dIntersectionView* curr2dView = dynamic_cast<Rim2dIntersectionView*>(&view); Rim2dIntersectionView* curr2dView = dynamic_cast<Rim2dIntersectionView*>(&view);
@@ -1010,7 +999,7 @@ void RivIntersectionPartMgr::appendPolylinePartsToModel(Rim3dView &view, cvf::Mo
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
const RimIntersection* RivIntersectionPartMgr::intersection() const const RimIntersection* RivIntersectionPartMgr::intersection() const
{ {
@@ -1018,7 +1007,7 @@ const RimIntersection* RivIntersectionPartMgr::intersection() const
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
cvf::Mat4d RivIntersectionPartMgr::unflattenTransformMatrix(const cvf::Vec3d& intersectionPointFlat) cvf::Mat4d RivIntersectionPartMgr::unflattenTransformMatrix(const cvf::Vec3d& intersectionPointFlat)
{ {
@@ -1026,7 +1015,7 @@ cvf::Mat4d RivIntersectionPartMgr::unflattenTransformMatrix(const cvf::Vec3d& in
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
cvf::ref<RivIntersectionHexGridInterface> RivIntersectionPartMgr::createHexGridInterface() cvf::ref<RivIntersectionHexGridInterface> RivIntersectionPartMgr::createHexGridInterface()
{ {
@@ -1049,4 +1038,3 @@ cvf::ref<RivIntersectionHexGridInterface> RivIntersectionPartMgr::createHexGridI
return nullptr; return nullptr;
} }

View File

@@ -2,29 +2,29 @@
// //
// Copyright (C) Statoil ASA // Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS // Copyright (C) Ceetron Solutions AS
// //
// ResInsight is free software: you can redistribute it and/or modify // ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or // WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. // FITNESS FOR A PARTICULAR PURPOSE.
// //
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> // See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details. // for more details.
// //
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
#pragma once #pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfColor4.h"
#include "cvfVector3.h"
#include "cvfArray.h" #include "cvfArray.h"
#include "cvfBase.h"
#include "cvfColor4.h"
#include "cvfMatrix4.h" #include "cvfMatrix4.h"
#include "cvfObject.h"
#include "cvfVector3.h"
#include "cafPdmPointer.h" #include "cafPdmPointer.h"
@@ -35,12 +35,12 @@
namespace cvf namespace cvf
{ {
class ModelBasicList; class ModelBasicList;
class Transform; class Transform;
class Part; class Part;
class ScalarMapper; class ScalarMapper;
class DrawableGeo; class DrawableGeo;
} } // namespace cvf
class RigFemPart; class RigFemPart;
class RigFemResultAddress; class RigFemResultAddress;
@@ -68,11 +68,10 @@ public:
explicit RivIntersectionPartMgr(RimIntersection* rimCrossSection, bool isFlattened = false); explicit RivIntersectionPartMgr(RimIntersection* rimCrossSection, bool isFlattened = false);
void applySingleColorEffect(); void applySingleColorEffect();
void updateCellResultColor(size_t timeStepIndex, void updateCellResultColor(size_t timeStepIndex,
const cvf::ScalarMapper* scalarColorMapper, const cvf::ScalarMapper* scalarColorMapper,
const RivTernaryScalarMapper* ternaryColorMapper); const RivTernaryScalarMapper* ternaryColorMapper);
void appendNativeCrossSectionFacesToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform); void appendNativeCrossSectionFacesToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform);
void appendMeshLinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform); void appendMeshLinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform);
void appendPolylinePartsToModel(Rim3dView& view, cvf::ModelBasicList* model, cvf::Transform* scaleTransform); void appendPolylinePartsToModel(Rim3dView& view, cvf::ModelBasicList* model, cvf::Transform* scaleTransform);
@@ -82,38 +81,40 @@ public:
cvf::Mat4d unflattenTransformMatrix(const cvf::Vec3d& intersectionPointFlat); cvf::Mat4d unflattenTransformMatrix(const cvf::Vec3d& intersectionPointFlat);
public: public:
static void calculateEclipseTextureCoordinates(cvf::Vec2fArray* textureCoords, static void calculateEclipseTextureCoordinates(cvf::Vec2fArray* textureCoords,
const std::vector<size_t>& triangleToCellIdxMap, const std::vector<size_t>& triangleToCellIdxMap,
const RigResultAccessor* resultAccessor, const RigResultAccessor* resultAccessor,
const cvf::ScalarMapper* mapper); const cvf::ScalarMapper* mapper);
static void calculateNodeOrElementNodeBasedGeoMechTextureCoords(cvf::Vec2fArray* textureCoords, static void
const std::vector<RivIntersectionVertexWeights> &vertexWeights, calculateNodeOrElementNodeBasedGeoMechTextureCoords(cvf::Vec2fArray* textureCoords,
const std::vector<float> &resultValues, const std::vector<RivIntersectionVertexWeights>& vertexWeights,
bool isElementNodalResult, const std::vector<float>& resultValues,
const RigFemPart* femPart, bool isElementNodalResult,
const cvf::ScalarMapper* mapper); const RigFemPart* femPart,
const cvf::ScalarMapper* mapper);
static void calculateElementBasedGeoMechTextureCoords(cvf::Vec2fArray* textureCoords, static void calculateElementBasedGeoMechTextureCoords(cvf::Vec2fArray* textureCoords,
const std::vector<float> &resultValues, const std::vector<float>& resultValues,
const std::vector<size_t>& triangleToCellIdx, const std::vector<size_t>& triangleToCellIdx,
const cvf::ScalarMapper* mapper); const cvf::ScalarMapper* mapper);
static void calculateGeoMechTensorXfTextureCoords(cvf::Vec2fArray* textureCoords, static void calculateGeoMechTensorXfTextureCoords(cvf::Vec2fArray* textureCoords,
const cvf::Vec3fArray* triangelVertices, const cvf::Vec3fArray* triangelVertices,
const std::vector<RivIntersectionVertexWeights> &vertexWeights, const std::vector<RivIntersectionVertexWeights>& vertexWeights,
RigGeoMechCaseData* caseData, RigGeoMechCaseData* caseData,
const RigFemResultAddress& resVarAddress, const RigFemResultAddress& resVarAddress,
int timeStepIdx, int timeStepIdx,
const cvf::ScalarMapper* mapper); const cvf::ScalarMapper* mapper);
static void calculatePlaneAngleTextureCoords(cvf::Vec2fArray* textureCoords,
const cvf::Vec3fArray* triangelVertices,
const RigFemResultAddress& resVarAddress,
const cvf::ScalarMapper* mapper);
static void calculatePlaneAngleTextureCoords(cvf::Vec2fArray* textureCoords,
const cvf::Vec3fArray* triangelVertices,
const RigFemResultAddress& resVarAddress,
const cvf::ScalarMapper* mapper);
private: private:
void generatePartGeometry(); void generatePartGeometry();
void createFaultLabelParts(const std::vector<std::pair<QString, cvf::Vec3d> >& labelAndAnchors); void createFaultLabelParts(const std::vector<std::pair<QString, cvf::Vec3d>>& labelAndAnchors);
void createPolyLineParts(bool useBufferObjects); void createPolyLineParts(bool useBufferObjects);
void createExtrusionDirParts(bool useBufferObjects); void createExtrusionDirParts(bool useBufferObjects);
@@ -122,30 +123,27 @@ private:
private: private:
caf::PdmPointer<RimIntersection> m_rimCrossSection; caf::PdmPointer<RimIntersection> m_rimCrossSection;
cvf::ref<RivIntersectionGeometryGenerator> m_crossSectionGenerator; cvf::ref<RivIntersectionGeometryGenerator> m_crossSectionGenerator;
cvf::ref<cvf::Part> m_crossSectionFaces;
cvf::ref<cvf::Part> m_crossSectionGridLines;
cvf::ref<cvf::Part> m_crossSectionFaultGridLines;
cvf::ref<cvf::Part> m_faultMeshLabels;
cvf::ref<cvf::Part> m_faultMeshLabelLines;
cvf::ref<cvf::Part> m_crossSectionFaces;
cvf::ref<cvf::Part> m_crossSectionGridLines;
cvf::ref<cvf::Part> m_crossSectionFaultGridLines;
cvf::ref<cvf::Part> m_faultMeshLabels;
cvf::ref<cvf::Part> m_faultMeshLabelLines;
cvf::ref<cvf::Part> m_highlightLineAlongPolyline;
cvf::ref<cvf::Part> m_highlightPointsForPolyline;
cvf::ref<cvf::Part> m_highlightLineAlongExtrusionDir;
cvf::ref<cvf::Part> m_highlightPointsForExtrusionDir;
cvf::ref<cvf::Vec2fArray> m_crossSectionFacesTextureCoords; cvf::ref<cvf::Vec2fArray> m_crossSectionFacesTextureCoords;
cvf::ref<cvf::Part> m_highlightLineAlongPolyline;
cvf::ref<cvf::Part> m_highlightPointsForPolyline;
cvf::ref<cvf::Part> m_highlightLineAlongExtrusionDir;
cvf::ref<cvf::Part> m_highlightPointsForExtrusionDir;
struct RivPipeBranchData struct RivPipeBranchData
{ {
cvf::ref<RivPipeGeometryGenerator> m_pipeGeomGenerator; cvf::ref<RivPipeGeometryGenerator> m_pipeGeomGenerator;
cvf::ref<cvf::Part> m_surfacePart; cvf::ref<cvf::Part> m_surfacePart;
cvf::ref<cvf::Part> m_centerLinePart; cvf::ref<cvf::Part> m_centerLinePart;
}; };
std::list<RivPipeBranchData> m_wellBranches; std::list<RivPipeBranchData> m_wellBranches;
bool m_isFlattened; bool m_isFlattened;
}; };

View File

@@ -2,17 +2,17 @@
// //
// Copyright (C) Statoil ASA // Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS // Copyright (C) Ceetron Solutions AS
// //
// ResInsight is free software: you can redistribute it and/or modify // ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or // WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. // FITNESS FOR A PARTICULAR PURPOSE.
// //
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> // See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details. // for more details.
// //
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
@@ -44,40 +44,42 @@
#include "RivTernaryTextureCoordsCreator.h" #include "RivTernaryTextureCoordsCreator.h"
#include "RivTextureCoordsCreator.h" #include "RivTextureCoordsCreator.h"
#include "RivMeshLinesSourceInfo.h"
#include "cvfDrawableGeo.h" #include "cvfDrawableGeo.h"
#include "cvfDrawableText.h" #include "cvfDrawableText.h"
#include "cvfModelBasicList.h" #include "cvfModelBasicList.h"
#include "cvfPart.h" #include "cvfPart.h"
#include "cvfPrimitiveSetDirect.h" #include "cvfPrimitiveSetDirect.h"
#include "cvfqtUtils.h" #include "cvfqtUtils.h"
#include "RivMeshLinesSourceInfo.h"
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RivFaultPartMgr::RivFaultPartMgr(const RigGridBase* grid, const RimFaultInViewCollection* rimFaultCollection, RimFaultInView* rimFault) RivFaultPartMgr::RivFaultPartMgr(const RigGridBase* grid,
: m_grid(grid), const RimFaultInViewCollection* rimFaultCollection,
m_rimFaultCollection(rimFaultCollection), RimFaultInView* rimFault)
m_rimFault(rimFault), : m_grid(grid)
m_opacityLevel(1.0f), , m_rimFaultCollection(rimFaultCollection)
m_defaultColor(cvf::Color3::WHITE) , m_rimFault(rimFault)
, m_opacityLevel(1.0f)
, m_defaultColor(cvf::Color3::WHITE)
{ {
cvf::ref< cvf::Array<size_t> > connIdxes = new cvf::Array<size_t>; cvf::ref<cvf::Array<size_t>> connIdxes = new cvf::Array<size_t>;
connIdxes->assign(rimFault->faultGeometry()->connectionIndices()); connIdxes->assign(rimFault->faultGeometry()->connectionIndices());
m_nativeFaultGenerator = new RivFaultGeometryGenerator(grid, rimFault->faultGeometry(), true); m_nativeFaultGenerator = new RivFaultGeometryGenerator(grid, rimFault->faultGeometry(), true);
m_oppositeFaultGenerator = new RivFaultGeometryGenerator(grid, rimFault->faultGeometry(), false); m_oppositeFaultGenerator = new RivFaultGeometryGenerator(grid, rimFault->faultGeometry(), false);
m_NNCGenerator = new RivNNCGeometryGenerator(grid->mainGrid()->nncData(), grid->mainGrid()->displayModelOffset(), connIdxes.p()); m_NNCGenerator =
new RivNNCGeometryGenerator(grid->mainGrid()->nncData(), grid->mainGrid()->displayModelOffset(), connIdxes.p());
m_nativeFaultFacesTextureCoords = new cvf::Vec2fArray; m_nativeFaultFacesTextureCoords = new cvf::Vec2fArray;
m_oppositeFaultFacesTextureCoords = new cvf::Vec2fArray; m_oppositeFaultFacesTextureCoords = new cvf::Vec2fArray;
m_NNCTextureCoords = new cvf::Vec2fArray; m_NNCTextureCoords = new cvf::Vec2fArray;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::setCellVisibility(cvf::UByteArray* cellVisibilities) void RivFaultPartMgr::setCellVisibility(cvf::UByteArray* cellVisibilities)
{ {
@@ -89,7 +91,7 @@ void RivFaultPartMgr::setCellVisibility(cvf::UByteArray* cellVisibilities)
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::applySingleColorEffect() void RivFaultPartMgr::applySingleColorEffect()
{ {
@@ -98,7 +100,7 @@ void RivFaultPartMgr::applySingleColorEffect()
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::updateCellResultColor(size_t timeStepIndex, RimEclipseCellColors* cellResultColors) void RivFaultPartMgr::updateCellResultColor(size_t timeStepIndex, RimEclipseCellColors* cellResultColors)
{ {
@@ -113,22 +115,26 @@ void RivFaultPartMgr::updateCellResultColor(size_t timeStepIndex, RimEclipseCell
{ {
if (cellResultColors->isTernarySaturationSelected()) if (cellResultColors->isTernarySaturationSelected())
{ {
RivTernaryTextureCoordsCreator texturer(cellResultColors, cellResultColors->ternaryLegendConfig(), RivTernaryTextureCoordsCreator texturer(cellResultColors,
timeStepIndex, cellResultColors->ternaryLegendConfig(),
m_grid->gridIndex(), timeStepIndex,
m_nativeFaultGenerator->quadToCellFaceMapper()); m_grid->gridIndex(),
m_nativeFaultGenerator->quadToCellFaceMapper());
texturer.createTextureCoords(m_nativeFaultFacesTextureCoords.p()); texturer.createTextureCoords(m_nativeFaultFacesTextureCoords.p());
const RivTernaryScalarMapper* mapper = cellResultColors->ternaryLegendConfig()->scalarMapper(); const RivTernaryScalarMapper* mapper = cellResultColors->ternaryLegendConfig()->scalarMapper();
RivScalarMapperUtils::applyTernaryTextureResultsToPart(m_nativeFaultFaces.p(), m_nativeFaultFacesTextureCoords.p(), mapper, m_opacityLevel, this->faceCullingMode(), eclipseView->isLightingDisabled()); RivScalarMapperUtils::applyTernaryTextureResultsToPart(m_nativeFaultFaces.p(),
m_nativeFaultFacesTextureCoords.p(),
mapper,
m_opacityLevel,
this->faceCullingMode(),
eclipseView->isLightingDisabled());
} }
else else
{ {
RivTextureCoordsCreator texturer(cellResultColors, RivTextureCoordsCreator texturer(
timeStepIndex, cellResultColors, timeStepIndex, m_grid->gridIndex(), m_nativeFaultGenerator->quadToCellFaceMapper());
m_grid->gridIndex(),
m_nativeFaultGenerator->quadToCellFaceMapper());
if (!texturer.isValid()) if (!texturer.isValid())
{ {
@@ -138,7 +144,12 @@ void RivFaultPartMgr::updateCellResultColor(size_t timeStepIndex, RimEclipseCell
texturer.createTextureCoords(m_nativeFaultFacesTextureCoords.p()); texturer.createTextureCoords(m_nativeFaultFacesTextureCoords.p());
const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper(); const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper();
RivScalarMapperUtils::applyTextureResultsToPart(m_nativeFaultFaces.p(), m_nativeFaultFacesTextureCoords.p(), mapper, m_opacityLevel, this->faceCullingMode(), eclipseView->isLightingDisabled()); RivScalarMapperUtils::applyTextureResultsToPart(m_nativeFaultFaces.p(),
m_nativeFaultFacesTextureCoords.p(),
mapper,
m_opacityLevel,
this->faceCullingMode(),
eclipseView->isLightingDisabled());
} }
} }
@@ -146,22 +157,26 @@ void RivFaultPartMgr::updateCellResultColor(size_t timeStepIndex, RimEclipseCell
{ {
if (cellResultColors->isTernarySaturationSelected()) if (cellResultColors->isTernarySaturationSelected())
{ {
RivTernaryTextureCoordsCreator texturer(cellResultColors, cellResultColors->ternaryLegendConfig(), RivTernaryTextureCoordsCreator texturer(cellResultColors,
timeStepIndex, cellResultColors->ternaryLegendConfig(),
m_grid->gridIndex(), timeStepIndex,
m_oppositeFaultGenerator->quadToCellFaceMapper()); m_grid->gridIndex(),
m_oppositeFaultGenerator->quadToCellFaceMapper());
texturer.createTextureCoords(m_oppositeFaultFacesTextureCoords.p()); texturer.createTextureCoords(m_oppositeFaultFacesTextureCoords.p());
const RivTernaryScalarMapper* mapper = cellResultColors->ternaryLegendConfig()->scalarMapper(); const RivTernaryScalarMapper* mapper = cellResultColors->ternaryLegendConfig()->scalarMapper();
RivScalarMapperUtils::applyTernaryTextureResultsToPart(m_oppositeFaultFaces.p(), m_oppositeFaultFacesTextureCoords.p(), mapper, m_opacityLevel, this->faceCullingMode(), eclipseView->isLightingDisabled()); RivScalarMapperUtils::applyTernaryTextureResultsToPart(m_oppositeFaultFaces.p(),
m_oppositeFaultFacesTextureCoords.p(),
mapper,
m_opacityLevel,
this->faceCullingMode(),
eclipseView->isLightingDisabled());
} }
else else
{ {
RivTextureCoordsCreator texturer(cellResultColors, RivTextureCoordsCreator texturer(
timeStepIndex, cellResultColors, timeStepIndex, m_grid->gridIndex(), m_oppositeFaultGenerator->quadToCellFaceMapper());
m_grid->gridIndex(),
m_oppositeFaultGenerator->quadToCellFaceMapper());
if (!texturer.isValid()) if (!texturer.isValid())
{ {
@@ -171,15 +186,22 @@ void RivFaultPartMgr::updateCellResultColor(size_t timeStepIndex, RimEclipseCell
texturer.createTextureCoords(m_oppositeFaultFacesTextureCoords.p()); texturer.createTextureCoords(m_oppositeFaultFacesTextureCoords.p());
const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper(); const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper();
RivScalarMapperUtils::applyTextureResultsToPart(m_oppositeFaultFaces.p(), m_oppositeFaultFacesTextureCoords.p(), mapper, m_opacityLevel, this->faceCullingMode(), eclipseView->isLightingDisabled()); RivScalarMapperUtils::applyTextureResultsToPart(m_oppositeFaultFaces.p(),
m_oppositeFaultFacesTextureCoords.p(),
mapper,
m_opacityLevel,
this->faceCullingMode(),
eclipseView->isLightingDisabled());
} }
} }
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::updateCellEdgeResultColor(size_t timeStepIndex, RimEclipseCellColors* cellResultColors, RimCellEdgeColors* cellEdgeResultColors) void RivFaultPartMgr::updateCellEdgeResultColor(size_t timeStepIndex,
RimEclipseCellColors* cellResultColors,
RimCellEdgeColors* cellEdgeResultColors)
{ {
updateNNCColors(timeStepIndex, cellResultColors); updateNNCColors(timeStepIndex, cellResultColors);
@@ -188,9 +210,17 @@ void RivFaultPartMgr::updateCellEdgeResultColor(size_t timeStepIndex, RimEclipse
cvf::DrawableGeo* dg = dynamic_cast<cvf::DrawableGeo*>(m_nativeFaultFaces->drawable()); cvf::DrawableGeo* dg = dynamic_cast<cvf::DrawableGeo*>(m_nativeFaultFaces->drawable());
if (dg) if (dg)
{ {
cvf::ref<cvf::Effect> eff = RivScalarMapperUtils::createCellEdgeEffect(dg, m_nativeFaultGenerator->quadToCellFaceMapper(), cvf::ref<cvf::Effect> eff =
m_grid->gridIndex(), RivScalarMapperUtils::createCellEdgeEffect(dg,
timeStepIndex, cellResultColors, cellEdgeResultColors, m_opacityLevel, m_defaultColor, this->faceCullingMode(), cellResultColors->reservoirView()->isLightingDisabled()); m_nativeFaultGenerator->quadToCellFaceMapper(),
m_grid->gridIndex(),
timeStepIndex,
cellResultColors,
cellEdgeResultColors,
m_opacityLevel,
m_defaultColor,
this->faceCullingMode(),
cellResultColors->reservoirView()->isLightingDisabled());
m_nativeFaultFaces->setEffect(eff.p()); m_nativeFaultFaces->setEffect(eff.p());
} }
@@ -201,8 +231,17 @@ void RivFaultPartMgr::updateCellEdgeResultColor(size_t timeStepIndex, RimEclipse
cvf::DrawableGeo* dg = dynamic_cast<cvf::DrawableGeo*>(m_oppositeFaultFaces->drawable()); cvf::DrawableGeo* dg = dynamic_cast<cvf::DrawableGeo*>(m_oppositeFaultFaces->drawable());
if (dg) if (dg)
{ {
cvf::ref<cvf::Effect> eff = RivScalarMapperUtils::createCellEdgeEffect(dg, m_oppositeFaultGenerator->quadToCellFaceMapper(), m_grid->gridIndex(), cvf::ref<cvf::Effect> eff =
timeStepIndex, cellResultColors, cellEdgeResultColors, m_opacityLevel, m_defaultColor, this->faceCullingMode(), cellResultColors->reservoirView()->isLightingDisabled()); RivScalarMapperUtils::createCellEdgeEffect(dg,
m_oppositeFaultGenerator->quadToCellFaceMapper(),
m_grid->gridIndex(),
timeStepIndex,
cellResultColors,
cellEdgeResultColors,
m_opacityLevel,
m_defaultColor,
this->faceCullingMode(),
cellResultColors->reservoirView()->isLightingDisabled());
m_oppositeFaultFaces->setEffect(eff.p()); m_oppositeFaultFaces->setEffect(eff.p());
} }
@@ -210,11 +249,10 @@ void RivFaultPartMgr::updateCellEdgeResultColor(size_t timeStepIndex, RimEclipse
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::generatePartGeometry() void RivFaultPartMgr::generatePartGeometry()
{ {
bool useBufferObjects = true; bool useBufferObjects = true;
// Surface geometry // Surface geometry
{ {
@@ -233,7 +271,7 @@ void RivFaultPartMgr::generatePartGeometry()
part->setDrawable(geo.p()); part->setDrawable(geo.p());
// Set mapping from triangle face index to cell index // Set mapping from triangle face index to cell index
cvf::ref<RivSourceInfo> si = new RivSourceInfo(m_rimFault, m_grid->gridIndex()); cvf::ref<RivSourceInfo> si = new RivSourceInfo(m_rimFault, m_grid->gridIndex());
si->m_cellFaceFromTriangleMapper = m_nativeFaultGenerator->triangleToCellFaceMapper(); si->m_cellFaceFromTriangleMapper = m_nativeFaultGenerator->triangleToCellFaceMapper();
part->setSourceInfo(si.p()); part->setSourceInfo(si.p());
@@ -269,7 +307,6 @@ void RivFaultPartMgr::generatePartGeometry()
} }
} }
// Surface geometry // Surface geometry
{ {
cvf::ref<cvf::DrawableGeo> geo = m_oppositeFaultGenerator->generateSurface(); cvf::ref<cvf::DrawableGeo> geo = m_oppositeFaultGenerator->generateSurface();
@@ -287,7 +324,7 @@ void RivFaultPartMgr::generatePartGeometry()
part->setDrawable(geo.p()); part->setDrawable(geo.p());
// Set mapping from triangle face index to cell index // Set mapping from triangle face index to cell index
cvf::ref<RivSourceInfo> si = new RivSourceInfo(m_rimFault, m_grid->gridIndex()); cvf::ref<RivSourceInfo> si = new RivSourceInfo(m_rimFault, m_grid->gridIndex());
si->m_cellFaceFromTriangleMapper = m_oppositeFaultGenerator->triangleToCellFaceMapper(); si->m_cellFaceFromTriangleMapper = m_oppositeFaultGenerator->triangleToCellFaceMapper();
part->setSourceInfo(si.p()); part->setSourceInfo(si.p());
@@ -340,7 +377,7 @@ void RivFaultPartMgr::generatePartGeometry()
// Set mapping from triangle face index to cell index // Set mapping from triangle face index to cell index
cvf::ref<RivSourceInfo> si = new RivSourceInfo(m_rimFault, m_grid->gridIndex()); cvf::ref<RivSourceInfo> si = new RivSourceInfo(m_rimFault, m_grid->gridIndex());
si->m_NNCIndices = m_NNCGenerator->triangleToNNCIndex().p(); si->m_NNCIndices = m_NNCGenerator->triangleToNNCIndex().p();
part->setSourceInfo(si.p()); part->setSourceInfo(si.p());
part->updateBoundingBox(); part->updateBoundingBox();
@@ -350,22 +387,21 @@ void RivFaultPartMgr::generatePartGeometry()
m_NNCFaces = part; m_NNCFaces = part;
} }
} }
createLabelWithAnchorLine(m_nativeFaultFaces.p()); createLabelWithAnchorLine(m_nativeFaultFaces.p());
updatePartEffect(); updatePartEffect();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::updatePartEffect() void RivFaultPartMgr::updatePartEffect()
{ {
// Set default effect // Set default effect
caf::SurfaceEffectGenerator geometryEffgen(m_defaultColor, caf::PO_1); caf::SurfaceEffectGenerator geometryEffgen(m_defaultColor, caf::PO_1);
geometryEffgen.setCullBackfaces(faceCullingMode()); geometryEffgen.setCullBackfaces(faceCullingMode());
cvf::ref<cvf::Effect> geometryOnlyEffect = geometryEffgen.generateCachedEffect(); cvf::ref<cvf::Effect> geometryOnlyEffect = geometryEffgen.generateCachedEffect();
if (m_nativeFaultFaces.notNull()) if (m_nativeFaultFaces.notNull())
@@ -383,7 +419,7 @@ void RivFaultPartMgr::updatePartEffect()
// Update mesh colors as well, in case of change // Update mesh colors as well, in case of change
RiaPreferences* prefs = RiaApplication::instance()->preferences(); RiaPreferences* prefs = RiaApplication::instance()->preferences();
cvf::ref<cvf::Effect> eff; cvf::ref<cvf::Effect> eff;
caf::MeshEffectGenerator faultEffGen(prefs->defaultFaultGridLineColors()); caf::MeshEffectGenerator faultEffGen(prefs->defaultFaultGridLineColors());
eff = faultEffGen.generateCachedEffect(); eff = faultEffGen.generateCachedEffect();
@@ -402,7 +438,7 @@ void RivFaultPartMgr::updatePartEffect()
// Set priority to make sure this transparent geometry are rendered last // Set priority to make sure this transparent geometry are rendered last
if (m_nativeFaultFaces.notNull()) m_nativeFaultFaces->setPriority(RivPartPriority::PartType::TransparentFault); if (m_nativeFaultFaces.notNull()) m_nativeFaultFaces->setPriority(RivPartPriority::PartType::TransparentFault);
if (m_oppositeFaultFaces.notNull()) m_oppositeFaultFaces->setPriority(RivPartPriority::PartType::TransparentFault); if (m_oppositeFaultFaces.notNull()) m_oppositeFaultFaces->setPriority(RivPartPriority::PartType::TransparentFault);
if (m_NNCFaces.notNull()) m_NNCFaces->setPriority(RivPartPriority::PartType::TransparentNnc); if (m_NNCFaces.notNull()) m_NNCFaces->setPriority(RivPartPriority::PartType::TransparentNnc);
if (m_nativeFaultGridLines.notNull()) if (m_nativeFaultGridLines.notNull())
{ {
@@ -417,11 +453,11 @@ void RivFaultPartMgr::updatePartEffect()
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::createLabelWithAnchorLine(const cvf::Part* part) void RivFaultPartMgr::createLabelWithAnchorLine(const cvf::Part* part)
{ {
m_faultLabelPart = nullptr; m_faultLabelPart = nullptr;
m_faultLabelLinePart = nullptr; m_faultLabelLinePart = nullptr;
if (!part) return; if (!part) return;
@@ -429,7 +465,7 @@ void RivFaultPartMgr::createLabelWithAnchorLine(const cvf::Part* part)
cvf::BoundingBox bb = part->boundingBox(); cvf::BoundingBox bb = part->boundingBox();
cvf::Vec3d bbTopCenter = bb.center(); cvf::Vec3d bbTopCenter = bb.center();
bbTopCenter.z() = bb.max().z(); bbTopCenter.z() = bb.max().z();
const cvf::DrawableGeo* geo = dynamic_cast<const cvf::DrawableGeo*>(part->drawable()); const cvf::DrawableGeo* geo = dynamic_cast<const cvf::DrawableGeo*>(part->drawable());
@@ -452,7 +488,7 @@ void RivFaultPartMgr::createLabelWithAnchorLine(const cvf::Part* part)
drawableText->setDrawBorder(false); drawableText->setDrawBorder(false);
drawableText->setDrawBackground(false); drawableText->setDrawBackground(false);
drawableText->setVerticalAlignment(cvf::TextDrawer::CENTER); drawableText->setVerticalAlignment(cvf::TextDrawer::CENTER);
cvf::Color3f defWellLabelColor = RiaApplication::instance()->preferences()->defaultWellLabelColor(); cvf::Color3f defWellLabelColor = RiaApplication::instance()->preferences()->defaultWellLabelColor();
{ {
{ {
@@ -460,7 +496,7 @@ void RivFaultPartMgr::createLabelWithAnchorLine(const cvf::Part* part)
m_rimFault->firstAncestorOrThisOfType(parentObject); m_rimFault->firstAncestorOrThisOfType(parentObject);
if (parentObject) if (parentObject)
{ {
defWellLabelColor = parentObject->faultLabelColor();; defWellLabelColor = parentObject->faultLabelColor();
} }
} }
} }
@@ -470,7 +506,7 @@ void RivFaultPartMgr::createLabelWithAnchorLine(const cvf::Part* part)
cvf::String cvfString = cvfqt::Utils::toString(m_rimFault->name()); cvf::String cvfString = cvfqt::Utils::toString(m_rimFault->name());
cvf::Vec3f textCoord(labelPosition); cvf::Vec3f textCoord(labelPosition);
double characteristicCellSize = bb.extent().z() / 20; double characteristicCellSize = bb.extent().z() / 20;
textCoord.z() += characteristicCellSize; textCoord.z() += characteristicCellSize;
drawableText->addText(cvfString, textCoord); drawableText->addText(cvfString, textCoord);
@@ -487,7 +523,6 @@ void RivFaultPartMgr::createLabelWithAnchorLine(const cvf::Part* part)
m_faultLabelPart = part; m_faultLabelPart = part;
} }
// Line from fault geometry to label // Line from fault geometry to label
{ {
cvf::ref<cvf::Vec3fArray> vertices = new cvf::Vec3fArray; cvf::ref<cvf::Vec3fArray> vertices = new cvf::Vec3fArray;
@@ -510,19 +545,19 @@ void RivFaultPartMgr::createLabelWithAnchorLine(const cvf::Part* part)
m_faultLabelLinePart->updateBoundingBox(); m_faultLabelLinePart->updateBoundingBox();
caf::MeshEffectGenerator gen(m_rimFault->faultColor()); caf::MeshEffectGenerator gen(m_rimFault->faultColor());
cvf::ref<cvf::Effect> eff = gen.generateCachedEffect(); cvf::ref<cvf::Effect> eff = gen.generateCachedEffect();
m_faultLabelLinePart->setEffect(eff.p()); m_faultLabelLinePart->setEffect(eff.p());
} }
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
cvf::Vec3f RivFaultPartMgr::findClosestVertex(const cvf::Vec3f& point, const cvf::Vec3fArray* vertices) cvf::Vec3f RivFaultPartMgr::findClosestVertex(const cvf::Vec3f& point, const cvf::Vec3fArray* vertices)
{ {
CVF_ASSERT(vertices); CVF_ASSERT(vertices);
if (!vertices) return cvf::Vec3f::UNDEFINED; if (!vertices) return cvf::Vec3f::UNDEFINED;
float closestDiff(HUGE_VAL); float closestDiff(HUGE_VAL);
@@ -535,7 +570,7 @@ cvf::Vec3f RivFaultPartMgr::findClosestVertex(const cvf::Vec3f& point, const cvf
if (diff < closestDiff) if (diff < closestDiff)
{ {
closestDiff = diff; closestDiff = diff;
closestIndex = i; closestIndex = i;
} }
} }
@@ -551,7 +586,7 @@ cvf::Vec3f RivFaultPartMgr::findClosestVertex(const cvf::Vec3f& point, const cvf
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::appendNativeFaultFacesToModel(cvf::ModelBasicList* model) void RivFaultPartMgr::appendNativeFaultFacesToModel(cvf::ModelBasicList* model)
{ {
@@ -562,7 +597,7 @@ void RivFaultPartMgr::appendNativeFaultFacesToModel(cvf::ModelBasicList* model)
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::appendOppositeFaultFacesToModel(cvf::ModelBasicList* model) void RivFaultPartMgr::appendOppositeFaultFacesToModel(cvf::ModelBasicList* model)
{ {
@@ -573,38 +608,38 @@ void RivFaultPartMgr::appendOppositeFaultFacesToModel(cvf::ModelBasicList* model
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::appendLabelPartsToModel(cvf::ModelBasicList* model) void RivFaultPartMgr::appendLabelPartsToModel(cvf::ModelBasicList* model)
{ {
if (m_faultLabelPart.notNull()) model->addPart(m_faultLabelPart.p()); if (m_faultLabelPart.notNull()) model->addPart(m_faultLabelPart.p());
if (m_faultLabelLinePart.notNull()) model->addPart(m_faultLabelLinePart.p()); if (m_faultLabelLinePart.notNull()) model->addPart(m_faultLabelLinePart.p());
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::appendMeshLinePartsToModel(cvf::ModelBasicList* model) void RivFaultPartMgr::appendMeshLinePartsToModel(cvf::ModelBasicList* model)
{ {
if (m_nativeFaultGridLines.notNull()) model->addPart(m_nativeFaultGridLines.p()); if (m_nativeFaultGridLines.notNull()) model->addPart(m_nativeFaultGridLines.p());
if (m_oppositeFaultGridLines.notNull()) model->addPart(m_oppositeFaultGridLines.p()); if (m_oppositeFaultGridLines.notNull()) model->addPart(m_oppositeFaultGridLines.p());
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::appendNNCFacesToModel(cvf::ModelBasicList* model) void RivFaultPartMgr::appendNNCFacesToModel(cvf::ModelBasicList* model)
{ {
if (m_NNCFaces.notNull()) model->addPart(m_NNCFaces.p()); if (m_NNCFaces.notNull()) model->addPart(m_NNCFaces.p());
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
caf::FaceCulling RivFaultPartMgr::faceCullingMode() const caf::FaceCulling RivFaultPartMgr::faceCullingMode() const
{ {
bool isShowingGrid = m_rimFaultCollection->isGridVisualizationMode(); bool isShowingGrid = m_rimFaultCollection->isGridVisualizationMode();
if (!isShowingGrid ) if (!isShowingGrid)
{ {
if (m_rimFaultCollection->faultResult() == RimFaultInViewCollection::FAULT_BACK_FACE_CULLING) if (m_rimFaultCollection->faultResult() == RimFaultInViewCollection::FAULT_BACK_FACE_CULLING)
{ {
@@ -630,7 +665,7 @@ caf::FaceCulling RivFaultPartMgr::faceCullingMode() const
} }
else else
{ {
return caf::FC_NONE; return caf::FC_NONE;
} }
} }
else else
@@ -641,7 +676,7 @@ caf::FaceCulling RivFaultPartMgr::faceCullingMode() const
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::updateNNCColors(size_t timeStepIndex, RimEclipseCellColors* cellResultColors) void RivFaultPartMgr::updateNNCColors(size_t timeStepIndex, RimEclipseCellColors* cellResultColors)
{ {
@@ -664,18 +699,19 @@ void RivFaultPartMgr::updateNNCColors(size_t timeStepIndex, RimEclipseCellColors
if (showNncsWithScalarMappedColor) if (showNncsWithScalarMappedColor)
{ {
size_t scalarSetIndex = cellResultColors->scalarResultIndex(); size_t scalarSetIndex = cellResultColors->scalarResultIndex();
RiaDefines::ResultCatType resultType = cellResultColors->resultType(); RiaDefines::ResultCatType resultType = cellResultColors->resultType();
const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper(); const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper();
if (eclipseView) if (eclipseView)
{ {
RimEclipseCase* eclipseCase = eclipseView->eclipseCase(); RimEclipseCase* eclipseCase = eclipseView->eclipseCase();
if (eclipseCase) if (eclipseCase)
{ {
size_t nativeTimeStepIndex = eclipseCase->uiToNativeTimeStepIndex(timeStepIndex); size_t nativeTimeStepIndex = eclipseCase->uiToNativeTimeStepIndex(timeStepIndex);
m_NNCGenerator->textureCoordinates(m_NNCTextureCoords.p(), mapper, resultType, scalarSetIndex, nativeTimeStepIndex); m_NNCGenerator->textureCoordinates(
m_NNCTextureCoords.p(), mapper, resultType, scalarSetIndex, nativeTimeStepIndex);
} }
} }
@@ -705,9 +741,9 @@ void RivFaultPartMgr::updateNNCColors(size_t timeStepIndex, RimEclipseCellColors
{ {
// NNC faces a bit lighter than the fault for now // NNC faces a bit lighter than the fault for now
cvf::Color3f nncColor = m_defaultColor; cvf::Color3f nncColor = m_defaultColor;
nncColor.r() += (1.0 - nncColor.r()) * 0.2; nncColor.r() += (1.0 - nncColor.r()) * 0.2;
nncColor.g() += (1.0 - nncColor.g()) * 0.2; nncColor.g() += (1.0 - nncColor.g()) * 0.2;
nncColor.b() += (1.0 - nncColor.b()) * 0.2; nncColor.b() += (1.0 - nncColor.b()) * 0.2;
CVF_ASSERT(nncColor.isValid()); CVF_ASSERT(nncColor.isValid());
cvf::ref<cvf::Effect> nncEffect; cvf::ref<cvf::Effect> nncEffect;
@@ -728,4 +764,3 @@ void RivFaultPartMgr::updateNNCColors(size_t timeStepIndex, RimEclipseCellColors
m_NNCFaces->setEffect(nncEffect.p()); m_NNCFaces->setEffect(nncEffect.p());
} }
} }