mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-09 23:16:00 -06:00
3D Well Log Curves (#2674): Show what the value axis direction is
This commit is contained in:
parent
4dc9d1ba8a
commit
5d89ad3a6d
@ -25,12 +25,14 @@
|
|||||||
#include "RigWellPathGeometryTools.h"
|
#include "RigWellPathGeometryTools.h"
|
||||||
|
|
||||||
#include "cafDisplayCoordTransform.h"
|
#include "cafDisplayCoordTransform.h"
|
||||||
|
|
||||||
#include "cvfObject.h"
|
#include "cvfObject.h"
|
||||||
#include "cvfDrawableGeo.h"
|
|
||||||
#include "cvfPrimitiveSetIndexedUInt.h"
|
#include "cvfPrimitiveSetIndexedUInt.h"
|
||||||
|
|
||||||
#include "cvfBoundingBox.h"
|
#include "cvfBoundingBox.h"
|
||||||
|
#include "cvfGeometryBuilderTriangles.h"
|
||||||
|
#include "cvfArrowGenerator.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -195,34 +197,38 @@ Riv3dWellLogGridGeometryGenerator::createGrid(const caf::DisplayCoordTransform*
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<cvf::Vec3f> vertices;
|
std::vector<cvf::Vec3f> vertices;
|
||||||
|
std::vector<cvf::Vec3f> arrowVectors;
|
||||||
vertices.reserve(interpolatedGridPoints.size());
|
vertices.reserve(interpolatedGridPoints.size());
|
||||||
|
arrowVectors.reserve(interpolatedGridPoints.size());
|
||||||
|
|
||||||
std::vector<cvf::uint> indices;
|
double shaftRelativeRadius = 0.0125f;
|
||||||
indices.reserve(interpolatedGridPoints.size());
|
double arrowHeadRelativeRadius = shaftRelativeRadius * 3;
|
||||||
cvf::uint indexCounter = 0;
|
double arrowHeadRelativeLength = arrowHeadRelativeRadius * 3;
|
||||||
// Normal lines. Start from one to avoid drawing at surface edge.
|
double totalArrowScaling = 1.0 / (1.0 - arrowHeadRelativeLength);
|
||||||
|
// Normal lines. Start from one to avoid drawing at surface edge.
|
||||||
for (size_t i = 1; i < interpolatedGridCurveNormals.size(); i++)
|
for (size_t i = 1; i < interpolatedGridCurveNormals.size(); i++)
|
||||||
{
|
{
|
||||||
vertices.push_back(cvf::Vec3f(interpolatedGridPoints[i] + interpolatedGridCurveNormals[i] * planeOffsetFromWellPathCenter));
|
vertices.push_back(cvf::Vec3f(interpolatedGridPoints[i] + interpolatedGridCurveNormals[i] * planeOffsetFromWellPathCenter));
|
||||||
|
|
||||||
vertices.push_back(cvf::Vec3f(interpolatedGridPoints[i] + interpolatedGridCurveNormals[i] * (planeOffsetFromWellPathCenter + planeWidth)));
|
arrowVectors.push_back(cvf::Vec3f(interpolatedGridCurveNormals[i] * planeWidth * totalArrowScaling));
|
||||||
|
|
||||||
indices.push_back(indexCounter++);
|
|
||||||
indices.push_back(indexCounter++);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cvf::ref<cvf::PrimitiveSetIndexedUInt> indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES);
|
m_curveNormalVectors = new cvf::DrawableVectors();
|
||||||
cvf::ref<cvf::UIntArray> indexArray = new cvf::UIntArray(indices);
|
|
||||||
|
|
||||||
cvf::ref<cvf::DrawableGeo> normalLinesDrawable = new cvf::DrawableGeo();
|
|
||||||
|
|
||||||
indexedUInt->setIndices(indexArray.p());
|
|
||||||
normalLinesDrawable->addPrimitiveSet(indexedUInt.p());
|
|
||||||
|
|
||||||
cvf::ref<cvf::Vec3fArray> vertexArray = new cvf::Vec3fArray(vertices);
|
cvf::ref<cvf::Vec3fArray> vertexArray = new cvf::Vec3fArray(vertices);
|
||||||
normalLinesDrawable->setVertexArray(vertexArray.p());
|
cvf::ref<cvf::Vec3fArray> vectorArray = new cvf::Vec3fArray(arrowVectors);
|
||||||
|
|
||||||
m_curveNormalLines = normalLinesDrawable;
|
// Create the arrow glyph for the vector drawer
|
||||||
|
cvf::GeometryBuilderTriangles arrowBuilder;
|
||||||
|
cvf::ArrowGenerator gen;
|
||||||
|
gen.setShaftRelativeRadius(shaftRelativeRadius);
|
||||||
|
gen.setHeadRelativeRadius(arrowHeadRelativeRadius);
|
||||||
|
gen.setHeadRelativeLength(arrowHeadRelativeLength);
|
||||||
|
gen.setNumSlices(4);
|
||||||
|
gen.generate(&arrowBuilder);
|
||||||
|
|
||||||
|
m_curveNormalVectors->setGlyph(arrowBuilder.trianglesUShort().p(), arrowBuilder.vertices().p());
|
||||||
|
m_curveNormalVectors->setVectors(vertexArray.p(), vectorArray.p());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -237,9 +243,9 @@ cvf::ref<cvf::DrawableGeo> Riv3dWellLogGridGeometryGenerator::border()
|
|||||||
return m_border;
|
return m_border;
|
||||||
}
|
}
|
||||||
|
|
||||||
cvf::ref<cvf::DrawableGeo> Riv3dWellLogGridGeometryGenerator::curveNormalLines()
|
cvf::ref<cvf::DrawableVectors> Riv3dWellLogGridGeometryGenerator::curveNormalVectors()
|
||||||
{
|
{
|
||||||
return m_curveNormalLines;
|
return m_curveNormalVectors;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "cvfBase.h"
|
#include "cvfBase.h"
|
||||||
#include "cvfDrawableGeo.h"
|
#include "cvfDrawableGeo.h"
|
||||||
|
#include "cvfDrawableVectors.h"
|
||||||
#include "cvfObject.h"
|
#include "cvfObject.h"
|
||||||
|
|
||||||
#include "cafPdmPointer.h"
|
#include "cafPdmPointer.h"
|
||||||
@ -53,13 +54,13 @@ public:
|
|||||||
|
|
||||||
cvf::ref<cvf::DrawableGeo> background();
|
cvf::ref<cvf::DrawableGeo> background();
|
||||||
cvf::ref<cvf::DrawableGeo> border();
|
cvf::ref<cvf::DrawableGeo> border();
|
||||||
cvf::ref<cvf::DrawableGeo> curveNormalLines();
|
cvf::ref<cvf::DrawableVectors> curveNormalVectors();
|
||||||
private:
|
private:
|
||||||
const RigWellPath* wellPathGeometry() const;
|
const RigWellPath* wellPathGeometry() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
caf::PdmPointer<RimWellPath> m_wellPath;
|
caf::PdmPointer<RimWellPath> m_wellPath;
|
||||||
cvf::ref<cvf::DrawableGeo> m_background;
|
cvf::ref<cvf::DrawableGeo> m_background;
|
||||||
cvf::ref<cvf::DrawableGeo> m_border;
|
cvf::ref<cvf::DrawableGeo> m_border;
|
||||||
cvf::ref<cvf::DrawableGeo> m_curveNormalLines;
|
cvf::ref<cvf::DrawableVectors> m_curveNormalVectors;
|
||||||
};
|
};
|
||||||
|
@ -18,8 +18,9 @@
|
|||||||
|
|
||||||
#include "Riv3dWellLogPlanePartMgr.h"
|
#include "Riv3dWellLogPlanePartMgr.h"
|
||||||
|
|
||||||
#include "RiaColorTables.h"
|
#include "RiaApplication.h"
|
||||||
|
|
||||||
|
#include "RiuViewer.h"
|
||||||
#include "Rim3dView.h"
|
#include "Rim3dView.h"
|
||||||
#include "Rim3dWellLogCurveCollection.h"
|
#include "Rim3dWellLogCurveCollection.h"
|
||||||
#include "RimCase.h"
|
#include "RimCase.h"
|
||||||
@ -36,7 +37,9 @@
|
|||||||
#include "cvfColor3.h"
|
#include "cvfColor3.h"
|
||||||
#include "cvfDrawableGeo.h"
|
#include "cvfDrawableGeo.h"
|
||||||
#include "cvfModelBasicList.h"
|
#include "cvfModelBasicList.h"
|
||||||
|
#include "cvfOpenGLResourceManager.h"
|
||||||
#include "cvfPart.h"
|
#include "cvfPart.h"
|
||||||
|
#include "cvfShaderProgram.h"
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
@ -225,9 +228,10 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList*
|
|||||||
bool showGrid = curveCollection->isShowingGrid();
|
bool showGrid = curveCollection->isShowingGrid();
|
||||||
bool showBackground = curveCollection->isShowingBackground();
|
bool showBackground = curveCollection->isShowingBackground();
|
||||||
|
|
||||||
|
cvf::Color3f gridColor(0.4f, 0.4f, 0.4f);
|
||||||
caf::SurfaceEffectGenerator backgroundEffectGen(cvf::Color4f(1.0, 1.0, 1.0, 1.0), caf::PO_2);
|
caf::SurfaceEffectGenerator backgroundEffectGen(cvf::Color4f(1.0, 1.0, 1.0, 1.0), caf::PO_2);
|
||||||
caf::MeshEffectGenerator gridBorderEffectGen(cvf::Color3f(0.4f, 0.4f, 0.4f));
|
caf::MeshEffectGenerator gridBorderEffectGen(gridColor);
|
||||||
caf::MeshEffectGenerator curveNormalsEffectGen(cvf::Color3f(0.4f, 0.4f, 0.4f));
|
caf::VectorEffectGenerator curveNormalsEffectGen;
|
||||||
backgroundEffectGen.enableLighting(false);
|
backgroundEffectGen.enableLighting(false);
|
||||||
|
|
||||||
bool gridCreated = m_3dWellLogGridGeometryGenerator->createGrid(displayCoordTransform,
|
bool gridCreated = m_3dWellLogGridGeometryGenerator->createGrid(displayCoordTransform,
|
||||||
@ -241,7 +245,7 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList*
|
|||||||
cvf::ref<cvf::Effect> backgroundEffect = backgroundEffectGen.generateCachedEffect();
|
cvf::ref<cvf::Effect> backgroundEffect = backgroundEffectGen.generateCachedEffect();
|
||||||
cvf::ref<cvf::Effect> borderEffect = gridBorderEffectGen.generateCachedEffect();
|
cvf::ref<cvf::Effect> borderEffect = gridBorderEffectGen.generateCachedEffect();
|
||||||
cvf::ref<cvf::Effect> curveNormalsEffect = curveNormalsEffectGen.generateCachedEffect();
|
cvf::ref<cvf::Effect> curveNormalsEffect = curveNormalsEffectGen.generateCachedEffect();
|
||||||
|
|
||||||
cvf::ref<cvf::DrawableGeo> background = m_3dWellLogGridGeometryGenerator->background();
|
cvf::ref<cvf::DrawableGeo> background = m_3dWellLogGridGeometryGenerator->background();
|
||||||
if (showBackground && background.notNull())
|
if (showBackground && background.notNull())
|
||||||
{
|
{
|
||||||
@ -263,9 +267,15 @@ void Riv3dWellLogPlanePartMgr::appendGridToModel(cvf::ModelBasicList*
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cvf::ref<cvf::DrawableGeo> normals = m_3dWellLogGridGeometryGenerator->curveNormalLines();
|
cvf::ref<cvf::DrawableVectors> normals = m_3dWellLogGridGeometryGenerator->curveNormalVectors();
|
||||||
if (normals.notNull())
|
if (normals.notNull())
|
||||||
{
|
{
|
||||||
|
normals->setSingleColor(gridColor);
|
||||||
|
if (RiaApplication::instance()->useShaders())
|
||||||
|
{
|
||||||
|
normals->setUniformNames("u_transformationMatrix", "u_color");
|
||||||
|
}
|
||||||
|
|
||||||
cvf::ref<cvf::Part> part = createPart(normals.p(), curveNormalsEffect.p());
|
cvf::ref<cvf::Part> part = createPart(normals.p(), curveNormalsEffect.p());
|
||||||
if (part.notNull())
|
if (part.notNull())
|
||||||
{
|
{
|
||||||
|
@ -991,4 +991,58 @@ void TextEffectGenerator::updateForFixedFunctionRendering(cvf::Effect* effect) c
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
VectorEffectGenerator::VectorEffectGenerator()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool VectorEffectGenerator::isEqual(const EffectGenerator* other) const
|
||||||
|
{
|
||||||
|
const VectorEffectGenerator* otherSurfaceEffect = dynamic_cast<const VectorEffectGenerator*>(other);
|
||||||
|
if (otherSurfaceEffect)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
EffectGenerator* VectorEffectGenerator::copy() const
|
||||||
|
{
|
||||||
|
VectorEffectGenerator* effGen = new VectorEffectGenerator;
|
||||||
|
|
||||||
|
return effGen;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void VectorEffectGenerator::updateForShaderBasedRendering(cvf::Effect* effect) const
|
||||||
|
{
|
||||||
|
cvf::ShaderProgramGenerator gen("VectorDrawerShaderProgram", cvf::ShaderSourceProvider::instance());
|
||||||
|
gen.addVertexCode(cvf::ShaderSourceRepository::vs_VectorDrawer);
|
||||||
|
gen.addFragmentCode(cvf::ShaderSourceRepository::fs_VectorDrawer);
|
||||||
|
|
||||||
|
cvf::ref<cvf::ShaderProgram> shaderProg = gen.generate();
|
||||||
|
shaderProg->disableUniformTrackingForUniform("u_transformationMatrix");
|
||||||
|
shaderProg->disableUniformTrackingForUniform("u_color");
|
||||||
|
|
||||||
|
cvf::ref<cvf::Effect> eff = effect;
|
||||||
|
eff->setShaderProgram(shaderProg.p());
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void VectorEffectGenerator::updateForFixedFunctionRendering(cvf::Effect* effect) const {}
|
||||||
|
|
||||||
} // End namespace caf
|
} // End namespace caf
|
||||||
|
@ -276,4 +276,21 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
//
|
||||||
|
// VectorEffectGenerator
|
||||||
|
//
|
||||||
|
//==================================================================================================
|
||||||
|
class VectorEffectGenerator : public EffectGenerator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
VectorEffectGenerator();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
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;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -125,6 +125,12 @@ void DrawableVectors::setSingleColor(Color3f color)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DrawableVectors::setUniformNames(String vectorMatrixUniformName, String colorUniformName)
|
||||||
|
{
|
||||||
|
m_vectorMatrixUniformName = vectorMatrixUniformName;
|
||||||
|
m_colorUniformName = colorUniformName;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -63,6 +63,7 @@ public:
|
|||||||
void setGlyph(UShortArray* triangles, Vec3fArray* vertices);
|
void setGlyph(UShortArray* triangles, Vec3fArray* vertices);
|
||||||
void setSingleColor(Color3f color);
|
void setSingleColor(Color3f color);
|
||||||
|
|
||||||
|
void setUniformNames(String vectorMatrixUniformName, String colorUniformName);
|
||||||
void setVectors(Vec3fArray* vertexArray, Vec3fArray* vectorArray);
|
void setVectors(Vec3fArray* vertexArray, Vec3fArray* vectorArray);
|
||||||
void setColors(Color3fArray* vectorColorArray);
|
void setColors(Color3fArray* vectorColorArray);
|
||||||
size_t vectorCount() const;
|
size_t vectorCount() const;
|
||||||
|
Loading…
Reference in New Issue
Block a user