Whitespace

This commit is contained in:
Magne Sjaastad
2018-09-12 14:24:24 +02:00
parent fce3d586ca
commit a1518bd9ec
2 changed files with 93 additions and 74 deletions

View File

@@ -3,17 +3,17 @@
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
//
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
@@ -31,12 +31,13 @@
#include "RimEclipseCase.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseView.h"
#include "RimSimWellInViewCollection.h"
#include "RimRegularLegendConfig.h"
#include "RimReservoirCellResultsStorage.h"
#include "RimSimWellInViewCollection.h"
#include "RimTernaryLegendConfig.h"
#include "RivCellEdgeEffectGenerator.h"
#include "RivCompletionTypeResultToTextureMapper.h"
#include "RivPartPriority.h"
#include "RivResultToTextureMapper.h"
#include "RivScalarMapperUtils.h"
@@ -44,7 +45,6 @@
#include "RivTernaryScalarMapperEffectGenerator.h"
#include "RivTernaryTextureCoordsCreator.h"
#include "RivTextureCoordsCreator.h"
#include "RivCompletionTypeResultToTextureMapper.h"
#include "cafEffectGenerator.h"
#include "cafPdmFieldCvfColor.h"
@@ -55,9 +55,9 @@
#include "cvfMath.h"
#include "cvfModelBasicList.h"
#include "cvfPart.h"
#include "cvfRenderState_FF.h"
#include "cvfRenderStateBlending.h"
#include "cvfRenderStatePolygonOffset.h"
#include "cvfRenderState_FF.h"
#include "cvfShaderProgram.h"
#include "cvfShaderProgramGenerator.h"
#include "cvfShaderSourceProvider.h"
@@ -66,26 +66,24 @@
#include "cvfTransform.h"
#include "cvfUniform.h"
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RivGridPartMgr::RivGridPartMgr(const RigGridBase* grid, size_t gridIdx)
: m_surfaceGenerator(grid),
m_gridIdx(gridIdx),
m_grid(grid),
m_surfaceFaceFilter(grid),
m_opacityLevel(1.0f),
m_defaultColor(cvf::Color3::WHITE)
: m_surfaceGenerator(grid)
, m_gridIdx(gridIdx)
, m_grid(grid)
, m_surfaceFaceFilter(grid)
, m_opacityLevel(1.0f)
, m_defaultColor(cvf::Color3::WHITE)
{
CVF_ASSERT(grid);
m_cellVisibility = new cvf::UByteArray;
m_cellVisibility = new cvf::UByteArray;
m_surfaceFacesTextureCoords = new cvf::Vec2fArray;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RivGridPartMgr::setTransform(cvf::Transform* scaleTransform)
{
@@ -93,7 +91,7 @@ void RivGridPartMgr::setTransform(cvf::Transform* scaleTransform)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RivGridPartMgr::setCellVisibility(cvf::UByteArray* cellVisibilities)
{
@@ -108,6 +106,9 @@ void RivGridPartMgr::setCellVisibility(cvf::UByteArray* cellVisibilities)
generatePartGeometry(m_surfaceGenerator);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGridPartMgr::generatePartGeometry(cvf::StructGridGeometryGenerator& geoBuilder)
{
bool useBufferObjects = true;
@@ -130,16 +131,16 @@ void RivGridPartMgr::generatePartGeometry(cvf::StructGridGeometryGenerator& geoB
part->setTransform(m_scaleTransform.p());
// Set mapping from triangle face index to cell index
cvf::ref<RivSourceInfo> si = new RivSourceInfo(m_gridIdx);
cvf::ref<RivSourceInfo> si = new RivSourceInfo(m_gridIdx);
si->m_cellFaceFromTriangleMapper = geoBuilder.triangleToCellFaceMapper();
part->setSourceInfo(si.p());
part->updateBoundingBox();
// Set default effect
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->setEnableMask(surfaceBit);
@@ -171,7 +172,7 @@ void RivGridPartMgr::generatePartGeometry(cvf::StructGridGeometryGenerator& geoB
RiaPreferences* prefs = RiaApplication::instance()->preferences();
cvf::ref<cvf::Effect> eff;
cvf::ref<cvf::Effect> eff;
caf::MeshEffectGenerator effGen(prefs->defaultGridLineColors());
eff = effGen.generateCachedEffect();
@@ -185,18 +186,18 @@ void RivGridPartMgr::generatePartGeometry(cvf::StructGridGeometryGenerator& geoB
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RivGridPartMgr::appendPartsToModel(cvf::ModelBasicList* model)
{
CVF_ASSERT(model != nullptr);
if(m_surfaceFaces.notNull() ) model->addPart(m_surfaceFaces.p() );
if(m_surfaceGridLines.notNull()) model->addPart(m_surfaceGridLines.p());
if (m_surfaceFaces.notNull()) model->addPart(m_surfaceFaces.p());
if (m_surfaceGridLines.notNull()) model->addPart(m_surfaceGridLines.p());
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RivGridPartMgr::updateCellColor(cvf::Color4f color)
{
@@ -207,24 +208,26 @@ void RivGridPartMgr::updateCellColor(cvf::Color4f color)
// Set default effect
caf::SurfaceEffectGenerator geometryEffgen(color, caf::PO_1);
cvf::ref<cvf::Effect> geometryOnlyEffect = geometryEffgen.generateCachedEffect();
cvf::ref<cvf::Effect> geometryOnlyEffect = geometryEffgen.generateCachedEffect();
m_surfaceFaces->setEffect(geometryOnlyEffect.p());
if (m_opacityLevel < 1.0f) m_surfaceFaces->setPriority(RivPartPriority::PartType::Transparent);
else m_surfaceFaces->setPriority(RivPartPriority::PartType::BaseLevel);
if (m_opacityLevel < 1.0f)
m_surfaceFaces->setPriority(RivPartPriority::PartType::Transparent);
else
m_surfaceFaces->setPriority(RivPartPriority::PartType::BaseLevel);
// Update mesh colors as well, in case of change
if (m_surfaceGridLines.notNull())
{
RiaPreferences* prefs = RiaApplication::instance()->preferences();
RiaPreferences* prefs = RiaApplication::instance()->preferences();
caf::MeshEffectGenerator effGen(prefs->defaultGridLineColors());
cvf::ref<cvf::Effect> eff = effGen.generateCachedEffect();
cvf::ref<cvf::Effect> eff = effGen.generateCachedEffect();
m_surfaceGridLines->setEffect(eff.p());
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimEclipseCellColors* cellResultColors)
{
@@ -237,7 +240,8 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimEclipseCellC
if (cellResultColors->isTernarySaturationSelected())
{
RivTernaryTextureCoordsCreator texturer(cellResultColors, cellResultColors->ternaryLegendConfig(),
RivTernaryTextureCoordsCreator texturer(cellResultColors,
cellResultColors->ternaryLegendConfig(),
timeStepIndex,
m_grid->gridIndex(),
m_surfaceGenerator.quadToCellFaceMapper());
@@ -245,19 +249,17 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimEclipseCellC
texturer.createTextureCoords(m_surfaceFacesTextureCoords.p());
const RivTernaryScalarMapper* mapper = cellResultColors->ternaryLegendConfig()->scalarMapper();
RivScalarMapperUtils::applyTernaryTextureResultsToPart(m_surfaceFaces.p(),
m_surfaceFacesTextureCoords.p(),
mapper,
RivScalarMapperUtils::applyTernaryTextureResultsToPart(m_surfaceFaces.p(),
m_surfaceFacesTextureCoords.p(),
mapper,
effectiveOpacityLevel,
caf::FC_NONE,
caf::FC_NONE,
cellResultColors->reservoirView()->isLightingDisabled());
}
else
{
RivTextureCoordsCreator texturer(cellResultColors,
timeStepIndex,
m_grid->gridIndex(),
m_surfaceGenerator.quadToCellFaceMapper());
RivTextureCoordsCreator texturer(
cellResultColors, timeStepIndex, m_grid->gridIndex(), m_surfaceGenerator.quadToCellFaceMapper());
if (!texturer.isValid())
{
return;
@@ -265,7 +267,8 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimEclipseCellC
if (cellResultColors->isCompletionTypeSelected())
{
cvf::ref<RigPipeInCellEvaluator> pipeInCellEval = RivTextureCoordsCreator::createPipeInCellEvaluator(cellResultColors, timeStepIndex, m_grid->gridIndex());
cvf::ref<RigPipeInCellEvaluator> pipeInCellEval =
RivTextureCoordsCreator::createPipeInCellEvaluator(cellResultColors, timeStepIndex, m_grid->gridIndex());
const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper();
texturer.setResultToTextureMapper(new RivCompletionTypeResultToTextureMapper(mapper, pipeInCellEval.p()));
@@ -275,42 +278,57 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimEclipseCellC
texturer.createTextureCoords(m_surfaceFacesTextureCoords.p());
const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper();
RivScalarMapperUtils::applyTextureResultsToPart(m_surfaceFaces.p(),
m_surfaceFacesTextureCoords.p(),
mapper,
effectiveOpacityLevel,
caf::FC_NONE,
RivScalarMapperUtils::applyTextureResultsToPart(m_surfaceFaces.p(),
m_surfaceFacesTextureCoords.p(),
mapper,
effectiveOpacityLevel,
caf::FC_NONE,
cellResultColors->reservoirView()->isLightingDisabled());
}
if (effectiveOpacityLevel < 1.0f) m_surfaceFaces->setPriority(RivPartPriority::PartType::Transparent);
else m_surfaceFaces->setPriority(RivPartPriority::PartType::BaseLevel);
if (effectiveOpacityLevel < 1.0f)
m_surfaceFaces->setPriority(RivPartPriority::PartType::Transparent);
else
m_surfaceFaces->setPriority(RivPartPriority::PartType::BaseLevel);
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RivGridPartMgr::updateCellEdgeResultColor(size_t timeStepIndex, RimEclipseCellColors* cellResultColors, RimCellEdgeColors* cellEdgeResultColors)
void RivGridPartMgr::updateCellEdgeResultColor(size_t timeStepIndex,
RimEclipseCellColors* cellResultColors,
RimCellEdgeColors* cellEdgeResultColors)
{
if (m_surfaceFaces.notNull())
{
cvf::DrawableGeo* dg = dynamic_cast<cvf::DrawableGeo*>(m_surfaceFaces->drawable());
if (dg)
{
cvf::ref<cvf::Effect> eff = RivScalarMapperUtils::createCellEdgeEffect(dg, m_surfaceGenerator.quadToCellFaceMapper(), m_grid->gridIndex(),
timeStepIndex, cellResultColors, cellEdgeResultColors, m_opacityLevel, m_defaultColor, caf::FC_NONE, cellResultColors->reservoirView()->isLightingDisabled());
cvf::ref<cvf::Effect> eff =
RivScalarMapperUtils::createCellEdgeEffect(dg,
m_surfaceGenerator.quadToCellFaceMapper(),
m_grid->gridIndex(),
timeStepIndex,
cellResultColors,
cellEdgeResultColors,
m_opacityLevel,
m_defaultColor,
caf::FC_NONE,
cellResultColors->reservoirView()->isLightingDisabled());
m_surfaceFaces->setEffect(eff.p());
if (m_opacityLevel < 1.0f) m_surfaceFaces->setPriority(RivPartPriority::PartType::Transparent);
else m_surfaceFaces->setPriority(RivPartPriority::PartType::BaseLevel);
if (m_opacityLevel < 1.0f)
m_surfaceFaces->setPriority(RivPartPriority::PartType::Transparent);
else
m_surfaceFaces->setPriority(RivPartPriority::PartType::BaseLevel);
}
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RivGridPartMgr::~RivGridPartMgr()
{
@@ -321,5 +339,3 @@ RivGridPartMgr::~RivGridPartMgr()
if (m_surfaceFaces.notNull()) m_surfaceFaces->deleteOrReleaseOpenGLResources();
#endif
}

View File

@@ -19,11 +19,13 @@
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RigGridBase.h"
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfStructGridGeometryGenerator.h"
#include "RigGridBase.h"
namespace cvf
{
@@ -59,29 +61,30 @@ public:
void updateCellColor(cvf::Color4f color);
void updateCellResultColor(size_t timeStepIndex, RimEclipseCellColors* cellResultColors);
void updateCellEdgeResultColor(size_t timeStepIndex, RimEclipseCellColors* cellResultColors,
RimCellEdgeColors* cellEdgeResultColors);
void updateCellEdgeResultColor(size_t timeStepIndex,
RimEclipseCellColors* cellResultColors,
RimCellEdgeColors* cellEdgeResultColors);
void appendPartsToModel(cvf::ModelBasicList* model);
private:
void generatePartGeometry(cvf::StructGridGeometryGenerator& geoBuilder);
void generatePartGeometry(cvf::StructGridGeometryGenerator& geoBuilder);
private:
size_t m_gridIdx;
cvf::cref<RigGridBase> m_grid;
size_t m_gridIdx;
cvf::cref<RigGridBase> m_grid;
cvf::ref<cvf::Transform> m_scaleTransform;
float m_opacityLevel;
cvf::Color3f m_defaultColor;
cvf::ref<cvf::Transform> m_scaleTransform;
float m_opacityLevel;
cvf::Color3f m_defaultColor;
// Surface visualization
cvf::StructGridGeometryGenerator m_surfaceGenerator;
RigGridCellFaceVisibilityFilter m_surfaceFaceFilter;
cvf::ref<cvf::Part> m_surfaceFaces;
cvf::ref<cvf::Vec2fArray> m_surfaceFacesTextureCoords;
cvf::StructGridGeometryGenerator m_surfaceGenerator;
RigGridCellFaceVisibilityFilter m_surfaceFaceFilter;
cvf::ref<cvf::Part> m_surfaceFaces;
cvf::ref<cvf::Vec2fArray> m_surfaceFacesTextureCoords;
cvf::ref<cvf::Part> m_surfaceGridLines;
cvf::ref<cvf::Part> m_surfaceGridLines;
cvf::ref<cvf::UByteArray> m_cellVisibility;
cvf::ref<cvf::UByteArray> m_cellVisibility;
};