mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-03 20:57:39 -06:00
#2544 Well CF Visualization: Make the orientation of the star geometry follow well path
This commit is contained in:
parent
4ac0a6354c
commit
f55d029256
@ -93,7 +93,7 @@ void RivVirtualConnFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::pair<cvf::Vec3f, double>> centerColorPairs;
|
std::vector<CompletionVizData> centerColorPairs;
|
||||||
for (const auto& cell : conn)
|
for (const auto& cell : conn)
|
||||||
{
|
{
|
||||||
size_t gridIndex = cell.first.globalCellIndex();
|
size_t gridIndex = cell.first.globalCellIndex();
|
||||||
@ -101,6 +101,7 @@ void RivVirtualConnFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBa
|
|||||||
const RigCell& rigCell = mainGrid->cell(gridIndex);
|
const RigCell& rigCell = mainGrid->cell(gridIndex);
|
||||||
|
|
||||||
cvf::Vec3d locationInDomainCoord = rigCell.center();
|
cvf::Vec3d locationInDomainCoord = rigCell.center();
|
||||||
|
cvf::Vec3d wellPathDirection = cvf::Vec3d::X_AXIS;
|
||||||
|
|
||||||
if (!wellPathCellIntersections.empty())
|
if (!wellPathCellIntersections.empty())
|
||||||
{
|
{
|
||||||
@ -115,6 +116,12 @@ void RivVirtualConnFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBa
|
|||||||
|
|
||||||
locationInDomainCoord = m_rimWell->wellPathGeometry()->interpolatedPointAlongWellPath(middleMD);
|
locationInDomainCoord = m_rimWell->wellPathGeometry()->interpolatedPointAlongWellPath(middleMD);
|
||||||
|
|
||||||
|
cvf::Vec3d p1;
|
||||||
|
cvf::Vec3d p2;
|
||||||
|
m_rimWell->wellPathGeometry()->twoClosestPoints(locationInDomainCoord, &p1, &p2);
|
||||||
|
|
||||||
|
wellPathDirection = (p2 - p1).getNormalized();
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,7 +135,7 @@ void RivVirtualConnFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBa
|
|||||||
transmissibility = cell.second.front().transmissibility();
|
transmissibility = cell.second.front().transmissibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
centerColorPairs.push_back(std::make_pair(cvf::Vec3f(displayCoord), transmissibility));
|
centerColorPairs.push_back(CompletionVizData(displayCoord, wellPathDirection, transmissibility));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!centerColorPairs.empty())
|
if (!centerColorPairs.empty())
|
||||||
@ -146,9 +153,9 @@ void RivVirtualConnFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBa
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
cvf::ref<cvf::Part> RivVirtualConnFactorPartMgr::createPart(std::vector<std::pair<cvf::Vec3f, double>>& centerColorPairs,
|
cvf::ref<cvf::Part> RivVirtualConnFactorPartMgr::createPart(std::vector<CompletionVizData>& vizDataItems,
|
||||||
double radius,
|
double radius,
|
||||||
cvf::ScalarMapper* scalarMapper)
|
cvf::ScalarMapper* scalarMapper)
|
||||||
{
|
{
|
||||||
std::vector<cvf::Vec3f> verticesForOneObject;
|
std::vector<cvf::Vec3f> verticesForOneObject;
|
||||||
std::vector<cvf::uint> indicesForOneObject;
|
std::vector<cvf::uint> indicesForOneObject;
|
||||||
@ -159,29 +166,33 @@ cvf::ref<cvf::Part> RivVirtualConnFactorPartMgr::createPart(std::vector<std::pai
|
|||||||
cvf::ref<cvf::UIntArray> indices = new cvf::UIntArray;
|
cvf::ref<cvf::UIntArray> indices = new cvf::UIntArray;
|
||||||
cvf::ref<cvf::Vec2fArray> textureCoords = new cvf::Vec2fArray();
|
cvf::ref<cvf::Vec2fArray> textureCoords = new cvf::Vec2fArray();
|
||||||
|
|
||||||
auto indexCount = centerColorPairs.size() * indicesForOneObject.size();
|
auto indexCount = vizDataItems.size() * indicesForOneObject.size();
|
||||||
auto vertexCount = centerColorPairs.size() * verticesForOneObject.size();
|
auto vertexCount = vizDataItems.size() * verticesForOneObject.size();
|
||||||
indices->reserve(indexCount);
|
indices->reserve(indexCount);
|
||||||
vertices->reserve(vertexCount);
|
vertices->reserve(vertexCount);
|
||||||
textureCoords->reserve(vertexCount);
|
textureCoords->reserve(vertexCount);
|
||||||
|
|
||||||
textureCoords->setAll(cvf::Vec2f(0.5f, 1.0f));
|
textureCoords->setAll(cvf::Vec2f(0.5f, 1.0f));
|
||||||
|
|
||||||
for (const auto& centerColorPair : centerColorPairs)
|
for (const auto& item : vizDataItems)
|
||||||
{
|
{
|
||||||
|
auto rotMatrix = rotationMatrixBetweenVectors(cvf::Vec3d::Y_AXIS, item.m_direction);
|
||||||
|
|
||||||
cvf::uint indexOffset = static_cast<cvf::uint>(vertices->size());
|
cvf::uint indexOffset = static_cast<cvf::uint>(vertices->size());
|
||||||
|
|
||||||
for (const auto& v : verticesForOneObject)
|
for (const auto& v : verticesForOneObject)
|
||||||
{
|
{
|
||||||
vertices->add(centerColorPair.first + v);
|
auto rotatedPoint = v.getTransformedPoint(rotMatrix);
|
||||||
|
|
||||||
if (centerColorPair.second == HUGE_VAL)
|
vertices->add(cvf::Vec3f(item.m_anchor) + rotatedPoint);
|
||||||
|
|
||||||
|
if (item.m_connectionFactor == HUGE_VAL)
|
||||||
{
|
{
|
||||||
textureCoords->add(cvf::Vec2f(0.5f, 1.0f));
|
textureCoords->add(cvf::Vec2f(0.5f, 1.0f));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
textureCoords->add(scalarMapper->mapToTextureCoord(centerColorPair.second));
|
textureCoords->add(scalarMapper->mapToTextureCoord(item.m_connectionFactor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,3 +327,24 @@ void RivVirtualConnFactorPartMgr::createStarGeometry(std::vector<cvf::Vec3f>* ve
|
|||||||
indices->push_back(5);
|
indices->push_back(5);
|
||||||
indices->push_back(9);
|
indices->push_back(9);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
/// Taken from OverlayNavigationCube::computeNewUpVector
|
||||||
|
/// Consider move to geometry util class
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
cvf::Mat4f RivVirtualConnFactorPartMgr::rotationMatrixBetweenVectors(const cvf::Vec3d& v1, const cvf::Vec3d& v2)
|
||||||
|
{
|
||||||
|
using namespace cvf;
|
||||||
|
|
||||||
|
Vec3d rotAxis = v1 ^ v2;
|
||||||
|
rotAxis.normalize();
|
||||||
|
|
||||||
|
// Guard acos against out-of-domain input
|
||||||
|
const double dotProduct = Math::clamp(v1*v2, -1.0, 1.0);
|
||||||
|
const double angle = Math::acos(dotProduct);
|
||||||
|
Mat4d rotMat = Mat4d::fromRotation(rotAxis, angle);
|
||||||
|
|
||||||
|
Mat4f myMat(rotMat);
|
||||||
|
|
||||||
|
return myMat;
|
||||||
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "cvfBase.h"
|
#include "cvfBase.h"
|
||||||
#include "cvfObject.h"
|
#include "cvfObject.h"
|
||||||
#include "cvfVector3.h"
|
#include "cvfVector3.h"
|
||||||
|
#include "cvfMatrix4.h"
|
||||||
|
|
||||||
#include "cafPdmPointer.h"
|
#include "cafPdmPointer.h"
|
||||||
|
|
||||||
@ -41,6 +42,21 @@ namespace caf
|
|||||||
class DisplayCoordTransform;
|
class DisplayCoordTransform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct CompletionVizData
|
||||||
|
{
|
||||||
|
CompletionVizData(cvf::Vec3d anchor, cvf::Vec3d direction, double connectionFactor)
|
||||||
|
: m_anchor(anchor)
|
||||||
|
, m_direction(direction)
|
||||||
|
, m_connectionFactor(connectionFactor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
cvf::Vec3d m_anchor;
|
||||||
|
cvf::Vec3d m_direction;
|
||||||
|
double m_connectionFactor;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
/// Based on RivWellSpheresPartMgr
|
/// Based on RivWellSpheresPartMgr
|
||||||
@ -55,12 +71,14 @@ public:
|
|||||||
void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex);
|
void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static cvf::ref<cvf::Part> createPart(std::vector<std::pair<cvf::Vec3f, double>>& centerColorPairs,
|
static cvf::ref<cvf::Part> createPart(std::vector<CompletionVizData>& centerColorPairs,
|
||||||
double radius,
|
double radius,
|
||||||
cvf::ScalarMapper* scalarMapper);
|
cvf::ScalarMapper* scalarMapper);
|
||||||
|
|
||||||
static void createStarGeometry(std::vector<cvf::Vec3f>* vertices, std::vector<cvf::uint>* indices, double radius, double thickness);
|
static void createStarGeometry(std::vector<cvf::Vec3f>* vertices, std::vector<cvf::uint>* indices, double radius, double thickness);
|
||||||
|
|
||||||
|
static cvf::Mat4f rotationMatrixBetweenVectors(const cvf::Vec3d& v1, const cvf::Vec3d& v2);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
caf::PdmPointer<RimWellPath> m_rimWell;
|
caf::PdmPointer<RimWellPath> m_rimWell;
|
||||||
caf::PdmPointer<RimVirtualPerforationResults> m_virtualPerforationResult;
|
caf::PdmPointer<RimVirtualPerforationResults> m_virtualPerforationResult;
|
||||||
|
Loading…
Reference in New Issue
Block a user