2012-05-18 02:45:23 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2011-2012 Statoil ASA, 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>
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "cafEffectGenerator.h"
|
|
|
|
|
|
|
|
namespace cvf
|
|
|
|
{
|
|
|
|
class StructGridGeometryGenerator;
|
|
|
|
class DrawableGeo;
|
|
|
|
}
|
|
|
|
|
|
|
|
class RimCellEdgeResultSlot;
|
|
|
|
class RimResultSlot;
|
|
|
|
class RigGridBase;
|
2014-08-12 07:36:15 -05:00
|
|
|
class RigResultAccessor;
|
|
|
|
class RigCaseData;
|
2014-08-13 02:24:04 -05:00
|
|
|
class RivTernaryScalarMapper;
|
2012-05-18 02:45:23 -05:00
|
|
|
|
|
|
|
class RivCellEdgeGeometryGenerator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static void addCellEdgeResultsToDrawableGeo(size_t timeStepIndex,
|
|
|
|
RimResultSlot* cellResultSlot,
|
|
|
|
RimCellEdgeResultSlot* cellEdgeResultSlot,
|
|
|
|
cvf::StructGridGeometryGenerator* generator,
|
2013-04-26 09:46:38 -05:00
|
|
|
cvf::DrawableGeo* geo,
|
|
|
|
size_t gridIndex,
|
|
|
|
float opacityLevel);
|
2014-08-12 07:36:15 -05:00
|
|
|
|
2014-08-13 02:24:04 -05:00
|
|
|
static void addTernaryCellEdgeResultsToDrawableGeo(size_t timeStepIndex,
|
|
|
|
RimResultSlot* cellResultSlot,
|
|
|
|
RimCellEdgeResultSlot* cellEdgeResultSlot,
|
|
|
|
cvf::StructGridGeometryGenerator* generator,
|
|
|
|
cvf::DrawableGeo* geo,
|
|
|
|
size_t gridIndex,
|
|
|
|
float opacityLevel);
|
|
|
|
|
|
|
|
|
2014-08-12 07:36:15 -05:00
|
|
|
private:
|
|
|
|
static cvf::ref<RigResultAccessor> createCellCenterResultAccessor(
|
|
|
|
RimResultSlot* cellResultSlot,
|
|
|
|
size_t timeStepIndex,
|
|
|
|
RigCaseData* eclipseCase,
|
|
|
|
const RigGridBase* grid);
|
|
|
|
|
|
|
|
static cvf::ref<RigResultAccessor> createCellEdgeCenterResultAccessor(
|
|
|
|
RimResultSlot* cellResultSlot,
|
|
|
|
RimCellEdgeResultSlot* cellEdgeResultSlot,
|
|
|
|
size_t timeStepIndex,
|
|
|
|
RigCaseData* eclipseCase,
|
|
|
|
const RigGridBase* grid);
|
2012-05-18 02:45:23 -05:00
|
|
|
};
|
|
|
|
|
2014-06-24 15:49:56 -05:00
|
|
|
/*
|
|
|
|
Thoughts on organizing the texture coords generation a bit.
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2014-06-24 15:49:56 -05:00
|
|
|
Conceptually several mappings takes place:
|
|
|
|
|
|
|
|
1. ResultValues to ResultPointValues <-- Eg. Cell Center values to CellFace Values
|
|
|
|
2. ResultPointValues to GeometryPointValues <-- Eg. CellCenter Values to Triangle Vertex
|
|
|
|
3. GeometryPointValues to TextureCoordinates/Colors <-- Handled by ScalarMapper
|
|
|
|
|
|
|
|
When evaluating, we normally use the geometry as starting point, as that often is
|
|
|
|
a subset of the total results/geometry domain.
|
|
|
|
|
|
|
|
To make this efficient, a minimum of internal storage should be used, so we want
|
|
|
|
to make the mappings as a set of functions called for each (or a few) texture
|
|
|
|
coordinate positions
|
|
|
|
|
|
|
|
The mapping is then actually accessed in the opposite way of the above, while calculated in the 1-3 order
|
|
|
|
|
|
|
|
Accessing correct values:
|
|
|
|
GeometryPointIdx->ResultPointIdx->ResultValueIdx
|
|
|
|
Calculating color:
|
|
|
|
ResultValue->ResultPointValue->GeometryPointValue->Texture/ColorValue
|
|
|
|
|
|
|
|
In ResInsight (for now)
|
|
|
|
the ResultPointValue will be the same for all the corresponding GeometryPoints,
|
|
|
|
which means each quadvertex has the same texcoord for all corners.
|
|
|
|
|
|
|
|
Proposal:
|
|
|
|
----------
|
|
|
|
Let the FaceValue to Face vertex texture coordinate mapping be the same for all.
|
|
|
|
Extract that from the code floating around.
|
|
|
|
|
|
|
|
Create a PrimitiveFaceIdx to CellIdx with Face mapper class that handles the lookup,
|
|
|
|
created by the geometry generation
|
|
|
|
|
|
|
|
Create separate calculators/mappers/Strategies to create FaceValues from results.
|
|
|
|
|
|
|
|
Test Code
|
|
|
|
-----------
|
|
|
|
// Example code
|
|
|
|
// 1. CellCenterToCellFace
|
|
|
|
// 2. CellFace to Quad Corners
|
|
|
|
// 3. Quad Corner Values to tex coords
|
|
|
|
|
|
|
|
texCoords.resize(m_quadsToGridCells.size()*4);
|
|
|
|
for (i = 0; i < m_quadsToGridCells.size(); ++i)
|
|
|
|
{
|
2014-08-07 07:55:33 -05:00
|
|
|
cvf::Vec2f texCoord = scalarMapper->mapToTextureCoord(resultAccessor->cellScalar(m_quadsToGridCells[i]));
|
2014-06-24 15:49:56 -05:00
|
|
|
ResValue ResPoint To ResValue
|
|
|
|
texCoords[i*4 + 0] = texCoord;
|
|
|
|
texCoords[i*4 + 1] = texCoord;
|
|
|
|
texCoords[i*4 + 2] = texCoord;
|
|
|
|
texCoords[i*4 + 3] = texCoord;
|
|
|
|
}
|
|
|
|
|
2014-08-06 09:51:09 -05:00
|
|
|
Texturing needs in ResInsight:
|
|
|
|
* ScalarMapper
|
|
|
|
* Handle HugeVal/nan
|
|
|
|
* PipeCellTransparency
|
|
|
|
- includes geometry point to cell mapping
|
|
|
|
* Modify the Scalarmapper Texture
|
|
|
|
* The domain values to convert pr geometry point
|
|
|
|
|
2014-06-24 15:49:56 -05:00
|
|
|
|
|
|
|
|
|
|
|
*/
|
2012-05-18 02:45:23 -05:00
|
|
|
|
|
|
|
//==================================================================================================
|
|
|
|
//
|
|
|
|
// Cell Face Effect
|
|
|
|
//
|
|
|
|
//==================================================================================================
|
|
|
|
class CellEdgeEffectGenerator : public caf::EffectGenerator
|
|
|
|
{
|
|
|
|
public:
|
2014-08-13 02:24:04 -05:00
|
|
|
CellEdgeEffectGenerator(const cvf::ScalarMapper* edgeScalarMapper);
|
|
|
|
|
|
|
|
void setScalarMapper(const cvf::ScalarMapper* cellScalarMapper);
|
|
|
|
void setTernaryScalarMapper(const RivTernaryScalarMapper* ternaryScalarMapper);
|
2012-05-18 02:45:23 -05:00
|
|
|
|
|
|
|
void setOpacityLevel(float opacity) { m_opacityLevel = cvf::Math::clamp(opacity, 0.0f , 1.0f ); }
|
|
|
|
void setUndefinedColor(cvf::Color3f color) { m_undefinedColor = color; }
|
|
|
|
void setCullBackfaces(bool cullBackFaces) { m_cullBackfaces = cullBackFaces; }
|
|
|
|
void setDefaultCellColor(cvf::Color3f color) { m_defaultCellColor = color; }
|
|
|
|
|
2012-08-31 12:12:47 -05:00
|
|
|
protected:
|
2012-05-18 02:45:23 -05:00
|
|
|
virtual bool isEqual( const EffectGenerator* other ) const;
|
|
|
|
virtual EffectGenerator* copy() const;
|
|
|
|
|
|
|
|
virtual void updateForShaderBasedRendering(cvf::Effect* effect) const;
|
|
|
|
virtual void updateForFixedFunctionRendering(cvf::Effect* effect) const;
|
|
|
|
|
|
|
|
private:
|
2012-08-31 12:12:47 -05:00
|
|
|
cvf::cref<cvf::ScalarMapper> m_edgeScalarMapper;
|
|
|
|
mutable cvf::ref<cvf::TextureImage> m_edgeTextureImage;
|
|
|
|
cvf::cref<cvf::ScalarMapper> m_cellScalarMapper;
|
|
|
|
mutable cvf::ref<cvf::TextureImage> m_cellTextureImage;
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2014-08-13 02:24:04 -05:00
|
|
|
cvf::cref<RivTernaryScalarMapper> m_ternaryCellScalarMapper;
|
|
|
|
|
|
|
|
float m_opacityLevel;
|
2012-05-18 02:45:23 -05:00
|
|
|
bool m_cullBackfaces;
|
|
|
|
cvf::Color3f m_undefinedColor;
|
|
|
|
cvf::Color3f m_defaultCellColor;
|
|
|
|
};
|
|
|
|
|