2018-03-09 06:15:01 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2018- Statoil ASA
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "Riv3dWellLogCurveGeomertyGenerator.h"
|
|
|
|
|
2018-03-20 07:51:51 -05:00
|
|
|
#include "RimWellPath.h"
|
2018-03-21 03:48:51 -05:00
|
|
|
#include "RimWellPathCollection.h"
|
2018-03-20 07:51:51 -05:00
|
|
|
|
2018-03-13 03:25:29 -05:00
|
|
|
#include "RigCurveDataTools.h"
|
2018-03-12 10:18:40 -05:00
|
|
|
#include "RigWellPath.h"
|
|
|
|
|
|
|
|
#include "cafDisplayCoordTransform.h"
|
2018-03-13 03:25:29 -05:00
|
|
|
#include "cvfPrimitiveSetIndexedUInt.h"
|
2018-03-09 06:15:01 -06:00
|
|
|
|
2018-03-21 03:48:51 -05:00
|
|
|
#include "cvfBoundingBox.h"
|
|
|
|
|
2018-03-13 03:42:54 -05:00
|
|
|
#include <cmath>
|
|
|
|
|
2018-03-21 10:22:35 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-03-22 03:54:58 -05:00
|
|
|
Riv3dWellLogCurveGeometryGenerator::Riv3dWellLogCurveGeometryGenerator(RimWellPath* wellPath)
|
2018-03-21 10:22:35 -05:00
|
|
|
: m_wellPath(wellPath)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-03-09 06:15:01 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-03-13 03:25:29 -05:00
|
|
|
///
|
2018-03-09 06:15:01 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-03-13 03:25:29 -05:00
|
|
|
cvf::ref<cvf::DrawableGeo>
|
|
|
|
Riv3dWellLogCurveGeometryGenerator::createCurveLine(const caf::DisplayCoordTransform* displayCoordTransform,
|
2018-03-21 07:15:48 -05:00
|
|
|
const cvf::BoundingBox& wellPathClipBoundingBox,
|
2018-03-22 02:54:48 -05:00
|
|
|
const std::vector<double>& resultValues,
|
|
|
|
const std::vector<double>& resultMds,
|
2018-03-22 03:54:58 -05:00
|
|
|
double planeAngle,
|
|
|
|
double planeOffsetFromWellPathCenter,
|
|
|
|
double planeWidth) const
|
2018-03-09 06:15:01 -06:00
|
|
|
{
|
2018-03-13 03:25:29 -05:00
|
|
|
std::vector<cvf::Vec3f> vertices;
|
|
|
|
std::vector<cvf::uint> indices;
|
|
|
|
|
2018-03-22 05:45:11 -05:00
|
|
|
createCurveVerticesAndIndices(resultValues,
|
|
|
|
resultMds,
|
|
|
|
planeAngle,
|
|
|
|
planeOffsetFromWellPathCenter,
|
|
|
|
planeWidth,
|
|
|
|
displayCoordTransform,
|
|
|
|
wellPathClipBoundingBox,
|
|
|
|
&vertices,
|
|
|
|
&indices);
|
2018-03-12 10:18:40 -05:00
|
|
|
|
2018-03-15 07:04:39 -05:00
|
|
|
if (vertices.empty() || indices.empty())
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2018-03-09 06:15:01 -06:00
|
|
|
cvf::ref<cvf::PrimitiveSetIndexedUInt> indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES);
|
2018-03-13 03:25:29 -05:00
|
|
|
cvf::ref<cvf::UIntArray> indexArray = new cvf::UIntArray(indices);
|
2018-03-09 06:15:01 -06:00
|
|
|
|
|
|
|
cvf::ref<cvf::DrawableGeo> drawable = new cvf::DrawableGeo();
|
|
|
|
|
|
|
|
indexedUInt->setIndices(indexArray.p());
|
|
|
|
drawable->addPrimitiveSet(indexedUInt.p());
|
|
|
|
|
|
|
|
cvf::ref<cvf::Vec3fArray> vertexArray = new cvf::Vec3fArray(vertices);
|
|
|
|
drawable->setVertexArray(vertexArray.p());
|
|
|
|
|
|
|
|
return drawable;
|
|
|
|
}
|
2018-03-12 10:18:40 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-03-13 03:25:29 -05:00
|
|
|
///
|
2018-03-12 10:18:40 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-03-13 03:25:29 -05:00
|
|
|
cvf::ref<cvf::DrawableGeo> Riv3dWellLogCurveGeometryGenerator::createGrid(const caf::DisplayCoordTransform* displayCoordTransform,
|
2018-03-21 03:48:51 -05:00
|
|
|
const cvf::BoundingBox& wellPathClipBoundingBox,
|
2018-03-22 03:54:58 -05:00
|
|
|
double planeAngle,
|
|
|
|
double planeOffsetFromWellPathCenter,
|
|
|
|
double planeWidth,
|
2018-03-22 02:54:48 -05:00
|
|
|
double gridIntervalSize) const
|
2018-03-12 10:18:40 -05:00
|
|
|
{
|
2018-03-20 02:26:28 -05:00
|
|
|
CVF_ASSERT(gridIntervalSize > 0);
|
|
|
|
|
2018-03-20 07:51:51 -05:00
|
|
|
if (!wellPathGeometry()) return nullptr;
|
2018-03-21 03:48:51 -05:00
|
|
|
if (!wellPathClipBoundingBox.isValid()) return nullptr;
|
|
|
|
|
|
|
|
RimWellPathCollection* wellPathCollection = nullptr;
|
|
|
|
m_wellPath->firstAncestorOrThisOfTypeAsserted(wellPathCollection);
|
2018-03-15 07:04:39 -05:00
|
|
|
|
2018-03-20 07:51:51 -05:00
|
|
|
std::vector<cvf::Vec3d> wellPathPoints = wellPathGeometry()->m_wellPathPoints;
|
2018-03-20 02:26:28 -05:00
|
|
|
if (wellPathPoints.empty()) return nullptr;
|
2018-03-20 09:36:57 -05:00
|
|
|
|
2018-03-21 03:48:51 -05:00
|
|
|
size_t originalWellPathSize = wellPathPoints.size();
|
|
|
|
|
|
|
|
if (wellPathCollection->wellPathClip)
|
|
|
|
{
|
|
|
|
double horizontalLengthAlongWellToClipPoint;
|
|
|
|
double maxZClipHeight = wellPathClipBoundingBox.max().z() + wellPathCollection->wellPathClipZDistance;
|
2018-03-21 10:22:35 -05:00
|
|
|
size_t indexToFirstVisibleSegment;
|
|
|
|
wellPathPoints = RigWellPath::clipPolylineStartAboveZ(
|
|
|
|
wellPathPoints, maxZClipHeight, &horizontalLengthAlongWellToClipPoint, &indexToFirstVisibleSegment);
|
2018-03-21 03:48:51 -05:00
|
|
|
}
|
|
|
|
if (wellPathPoints.empty()) return nullptr;
|
2018-03-20 02:26:28 -05:00
|
|
|
|
|
|
|
std::vector<cvf::Vec3d> gridPoints;
|
|
|
|
|
2018-03-20 07:51:51 -05:00
|
|
|
if (wellPathGeometry()->m_measuredDepths.empty()) return nullptr;
|
2018-03-20 02:26:28 -05:00
|
|
|
|
2018-03-21 03:48:51 -05:00
|
|
|
size_t newStartIndex = originalWellPathSize - wellPathPoints.size();
|
|
|
|
double firstMd = wellPathGeometry()->m_measuredDepths.at(newStartIndex);
|
|
|
|
double lastMd = wellPathGeometry()->m_measuredDepths.back();
|
|
|
|
|
|
|
|
double md = lastMd;
|
|
|
|
while (md >= firstMd)
|
2018-03-20 02:26:28 -05:00
|
|
|
{
|
2018-03-20 07:51:51 -05:00
|
|
|
cvf::Vec3d point = wellPathGeometry()->interpolatedPointAlongWellPath(md);
|
2018-03-20 02:26:28 -05:00
|
|
|
gridPoints.push_back(point);
|
2018-03-21 03:48:51 -05:00
|
|
|
md -= gridIntervalSize;
|
2018-03-20 02:26:28 -05:00
|
|
|
}
|
2018-03-12 10:18:40 -05:00
|
|
|
|
2018-03-21 07:14:22 -05:00
|
|
|
std::vector<cvf::Vec3d> pointNormals;
|
2018-03-21 10:22:35 -05:00
|
|
|
|
2018-03-21 09:32:03 -05:00
|
|
|
std::vector<cvf::Vec3d> closestPoints;
|
2018-03-22 05:45:11 -05:00
|
|
|
calculatePairsOfClosestSamplingPointsAlongWellPath(&closestPoints, gridPoints);
|
2018-03-21 07:14:22 -05:00
|
|
|
|
2018-03-22 03:54:58 -05:00
|
|
|
pointNormals = calculateLineSegmentNormals(planeAngle, closestPoints, LINE_SEGMENTS);
|
2018-03-20 03:10:06 -05:00
|
|
|
if (pointNormals.size() != gridPoints.size()) return nullptr;
|
|
|
|
|
2018-03-14 08:22:14 -05:00
|
|
|
std::vector<cvf::Vec3f> vertices;
|
2018-03-20 02:26:28 -05:00
|
|
|
vertices.reserve(gridPoints.size() * 2);
|
2018-03-12 10:18:40 -05:00
|
|
|
|
|
|
|
std::vector<cvf::uint> indices;
|
2018-03-20 02:26:28 -05:00
|
|
|
indices.reserve(gridPoints.size() * 2);
|
2018-03-12 10:18:40 -05:00
|
|
|
|
2018-03-21 10:22:35 -05:00
|
|
|
cvf::uint indexCounter = 0;
|
|
|
|
|
2018-03-20 07:51:51 -05:00
|
|
|
// Normal lines
|
2018-03-20 02:26:28 -05:00
|
|
|
for (size_t i = 0; i < pointNormals.size(); i++)
|
2018-03-12 10:18:40 -05:00
|
|
|
{
|
2018-03-20 09:36:57 -05:00
|
|
|
vertices.push_back(cvf::Vec3f(
|
2018-03-22 03:54:58 -05:00
|
|
|
displayCoordTransform->transformToDisplayCoord(gridPoints[i] + pointNormals[i] * planeOffsetFromWellPathCenter)));
|
2018-03-21 10:22:35 -05:00
|
|
|
|
2018-03-20 09:36:57 -05:00
|
|
|
vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(
|
2018-03-22 03:54:58 -05:00
|
|
|
gridPoints[i] + pointNormals[i] * (planeOffsetFromWellPathCenter + planeWidth))));
|
2018-03-12 10:18:40 -05:00
|
|
|
|
2018-03-21 10:22:35 -05:00
|
|
|
indices.push_back(indexCounter++);
|
|
|
|
indices.push_back(indexCounter++);
|
2018-03-12 10:18:40 -05:00
|
|
|
}
|
|
|
|
|
2018-03-21 10:22:35 -05:00
|
|
|
// calculateLineSegmentNormals returns normals for the whole well path. Erase the part which is clipped off
|
|
|
|
std::vector<cvf::Vec3d> wellPathSegmentNormals =
|
2018-03-22 03:54:58 -05:00
|
|
|
calculateLineSegmentNormals(planeAngle, wellPathGeometry()->m_wellPathPoints, POLYLINE);
|
2018-03-21 07:14:22 -05:00
|
|
|
wellPathSegmentNormals.erase(wellPathSegmentNormals.begin(), wellPathSegmentNormals.end() - wellPathPoints.size());
|
2018-03-20 07:51:51 -05:00
|
|
|
|
|
|
|
// Line along and close to well
|
|
|
|
for (size_t i = 0; i < wellPathPoints.size(); i++)
|
|
|
|
{
|
2018-03-20 09:36:57 -05:00
|
|
|
vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(
|
2018-03-22 03:54:58 -05:00
|
|
|
wellPathPoints[i] + wellPathSegmentNormals[i] * planeOffsetFromWellPathCenter)));
|
2018-03-21 10:22:35 -05:00
|
|
|
|
|
|
|
indices.push_back(indexCounter);
|
|
|
|
indices.push_back(++indexCounter);
|
2018-03-20 07:51:51 -05:00
|
|
|
}
|
2018-03-21 10:22:35 -05:00
|
|
|
// Indices are added as line segments for the current point and the next point. The last point does not have a next point,
|
|
|
|
// therefore we remove the last line segment
|
2018-03-20 07:51:51 -05:00
|
|
|
indices.pop_back();
|
|
|
|
indices.pop_back();
|
|
|
|
|
|
|
|
// Line along and far away from well
|
|
|
|
for (size_t i = 0; i < wellPathPoints.size(); i++)
|
|
|
|
{
|
2018-03-20 09:36:57 -05:00
|
|
|
vertices.push_back(cvf::Vec3f(displayCoordTransform->transformToDisplayCoord(
|
2018-03-22 03:54:58 -05:00
|
|
|
wellPathPoints[i] + wellPathSegmentNormals[i] * (planeOffsetFromWellPathCenter + planeWidth))));
|
2018-03-21 09:32:03 -05:00
|
|
|
|
2018-03-21 10:22:35 -05:00
|
|
|
indices.push_back(indexCounter);
|
|
|
|
indices.push_back(++indexCounter);
|
2018-03-20 07:51:51 -05:00
|
|
|
}
|
|
|
|
indices.pop_back();
|
|
|
|
indices.pop_back();
|
|
|
|
|
2018-03-12 10:18:40 -05:00
|
|
|
cvf::ref<cvf::PrimitiveSetIndexedUInt> indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES);
|
2018-03-13 03:25:29 -05:00
|
|
|
cvf::ref<cvf::UIntArray> indexArray = new cvf::UIntArray(indices);
|
2018-03-12 10:18:40 -05:00
|
|
|
|
2018-03-20 02:26:28 -05:00
|
|
|
cvf::ref<cvf::DrawableGeo> drawable = new cvf::DrawableGeo();
|
2018-03-12 10:18:40 -05:00
|
|
|
|
|
|
|
indexedUInt->setIndices(indexArray.p());
|
|
|
|
drawable->addPrimitiveSet(indexedUInt.p());
|
|
|
|
|
|
|
|
cvf::ref<cvf::Vec3fArray> vertexArray = new cvf::Vec3fArray(vertices);
|
|
|
|
drawable->setVertexArray(vertexArray.p());
|
|
|
|
|
|
|
|
return drawable;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-03-13 03:25:29 -05:00
|
|
|
///
|
2018-03-12 10:18:40 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-03-22 02:54:48 -05:00
|
|
|
void Riv3dWellLogCurveGeometryGenerator::createCurveVerticesAndIndices(const std::vector<double>& resultValues,
|
|
|
|
const std::vector<double>& resultMds,
|
2018-03-22 03:54:58 -05:00
|
|
|
double planeAngle,
|
|
|
|
double planeOffsetFromWellPathCenter,
|
|
|
|
double planeWidth,
|
2018-03-13 03:25:29 -05:00
|
|
|
const caf::DisplayCoordTransform* displayCoordTransform,
|
2018-03-21 07:15:48 -05:00
|
|
|
const cvf::BoundingBox& wellPathClipBoundingBox,
|
2018-03-13 03:25:29 -05:00
|
|
|
std::vector<cvf::Vec3f>* vertices,
|
|
|
|
std::vector<cvf::uint>* indices) const
|
2018-03-12 10:18:40 -05:00
|
|
|
{
|
2018-03-20 07:51:51 -05:00
|
|
|
if (!wellPathGeometry()) return;
|
2018-03-21 07:15:48 -05:00
|
|
|
if (wellPathGeometry()->m_wellPathPoints.empty()) return;
|
|
|
|
if (!wellPathClipBoundingBox.isValid()) return;
|
2018-03-15 06:55:50 -05:00
|
|
|
|
|
|
|
if (resultValues.empty()) return;
|
2018-03-21 10:22:35 -05:00
|
|
|
CVF_ASSERT(resultValues.size() == resultMds.size());
|
2018-03-13 03:25:29 -05:00
|
|
|
|
2018-03-21 07:15:48 -05:00
|
|
|
RimWellPathCollection* wellPathCollection = nullptr;
|
|
|
|
m_wellPath->firstAncestorOrThisOfTypeAsserted(wellPathCollection);
|
|
|
|
|
|
|
|
double maxZClipHeight = wellPathGeometry()->m_wellPathPoints.front().z();
|
|
|
|
if (wellPathCollection->wellPathClip)
|
|
|
|
{
|
|
|
|
maxZClipHeight = wellPathClipBoundingBox.max().z() + wellPathCollection->wellPathClipZDistance;
|
|
|
|
}
|
2018-03-14 08:22:14 -05:00
|
|
|
|
|
|
|
std::vector<cvf::Vec3d> interpolatedWellPathPoints;
|
2018-03-12 10:18:40 -05:00
|
|
|
|
2018-03-21 10:22:35 -05:00
|
|
|
// Iterate from bottom of well path and up to be able to stop at given Z max clipping height
|
|
|
|
for (auto md = resultMds.rbegin(); md != resultMds.rend(); md++)
|
2018-03-13 03:25:29 -05:00
|
|
|
{
|
2018-03-21 10:22:35 -05:00
|
|
|
cvf::Vec3d point = wellPathGeometry()->interpolatedPointAlongWellPath(*md);
|
2018-03-21 07:15:48 -05:00
|
|
|
if (point.z() > maxZClipHeight) break;
|
|
|
|
|
|
|
|
interpolatedWellPathPoints.push_back(point);
|
2018-03-13 03:25:29 -05:00
|
|
|
}
|
2018-03-21 10:22:35 -05:00
|
|
|
if (interpolatedWellPathPoints.empty()) return;
|
2018-03-13 03:25:29 -05:00
|
|
|
|
2018-03-22 02:54:48 -05:00
|
|
|
// Reverse list, since it was filled in the opposite order
|
2018-03-21 10:22:35 -05:00
|
|
|
std::reverse(interpolatedWellPathPoints.begin(), interpolatedWellPathPoints.end());
|
2018-03-21 07:15:48 -05:00
|
|
|
|
2018-03-22 02:54:48 -05:00
|
|
|
// The result values for the part of the well which is not clipped off, matching interpolatedWellPathPoints size
|
|
|
|
std::vector<double> resultValuesForInterpolatedPoints(resultValues.end() - interpolatedWellPathPoints.size(),
|
|
|
|
resultValues.end());
|
2018-03-21 07:15:48 -05:00
|
|
|
|
2018-03-21 10:22:35 -05:00
|
|
|
std::vector<cvf::Vec3d> pairsOfWellPathPoints;
|
2018-03-22 05:45:11 -05:00
|
|
|
calculatePairsOfClosestSamplingPointsAlongWellPath(&pairsOfWellPathPoints, interpolatedWellPathPoints);
|
2018-03-21 09:32:03 -05:00
|
|
|
|
2018-03-22 03:54:58 -05:00
|
|
|
std::vector<cvf::Vec3d> pointNormals = calculateLineSegmentNormals(planeAngle, pairsOfWellPathPoints, LINE_SEGMENTS);
|
2018-03-20 03:10:06 -05:00
|
|
|
if (interpolatedWellPathPoints.size() != pointNormals.size()) return;
|
2018-03-12 10:18:40 -05:00
|
|
|
|
2018-03-13 03:25:29 -05:00
|
|
|
double maxResult = -HUGE_VAL;
|
|
|
|
double minResult = HUGE_VAL;
|
|
|
|
|
2018-03-22 02:54:48 -05:00
|
|
|
for (double result : resultValuesForInterpolatedPoints)
|
2018-03-12 10:18:40 -05:00
|
|
|
{
|
2018-03-13 03:25:29 -05:00
|
|
|
if (!RigCurveDataTools::isValidValue(result, false)) continue;
|
2018-03-12 10:18:40 -05:00
|
|
|
|
2018-03-13 03:25:29 -05:00
|
|
|
maxResult = std::max(result, maxResult);
|
|
|
|
minResult = std::min(result, minResult);
|
|
|
|
}
|
2018-03-12 10:18:40 -05:00
|
|
|
|
2018-03-14 08:22:14 -05:00
|
|
|
vertices->resize(interpolatedWellPathPoints.size());
|
|
|
|
|
2018-03-22 03:54:58 -05:00
|
|
|
double plotRangeToResultRangeFactor = planeWidth / (maxResult - minResult);
|
2018-03-12 10:18:40 -05:00
|
|
|
|
2018-03-14 08:22:14 -05:00
|
|
|
for (size_t i = 0; i < pointNormals.size(); i++)
|
2018-03-12 10:18:40 -05:00
|
|
|
{
|
2018-03-20 09:36:57 -05:00
|
|
|
double scaledResult = 0;
|
2018-03-13 03:25:29 -05:00
|
|
|
|
2018-03-22 02:54:48 -05:00
|
|
|
if (RigCurveDataTools::isValidValue(resultValuesForInterpolatedPoints[i], false))
|
2018-03-13 03:25:29 -05:00
|
|
|
{
|
2018-03-22 02:54:48 -05:00
|
|
|
scaledResult =
|
2018-03-22 03:54:58 -05:00
|
|
|
planeOffsetFromWellPathCenter + (resultValuesForInterpolatedPoints[i] - minResult) * plotRangeToResultRangeFactor;
|
2018-03-13 03:25:29 -05:00
|
|
|
}
|
|
|
|
|
2018-03-14 08:22:14 -05:00
|
|
|
(*vertices)[i] = cvf::Vec3f(
|
2018-03-20 09:36:57 -05:00
|
|
|
displayCoordTransform->transformToDisplayCoord(interpolatedWellPathPoints[i] + scaledResult * pointNormals[i]));
|
2018-03-12 10:18:40 -05:00
|
|
|
}
|
|
|
|
|
2018-03-13 03:25:29 -05:00
|
|
|
std::vector<std::pair<size_t, size_t>> valuesIntervals =
|
2018-03-22 02:54:48 -05:00
|
|
|
RigCurveDataTools::calculateIntervalsOfValidValues(resultValuesForInterpolatedPoints, false);
|
2018-03-13 03:25:29 -05:00
|
|
|
|
|
|
|
for (const std::pair<size_t, size_t>& interval : valuesIntervals)
|
|
|
|
{
|
|
|
|
for (size_t i = interval.first; i < interval.second; i++)
|
|
|
|
{
|
|
|
|
indices->push_back(cvf::uint(i));
|
|
|
|
indices->push_back(cvf::uint(i + 1));
|
|
|
|
}
|
|
|
|
}
|
2018-03-12 10:18:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-03-13 03:25:29 -05:00
|
|
|
///
|
2018-03-12 10:18:40 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-03-22 02:54:48 -05:00
|
|
|
std::vector<cvf::Vec3d> Riv3dWellLogCurveGeometryGenerator::calculateLineSegmentNormals(double angle,
|
2018-03-21 09:32:03 -05:00
|
|
|
const std::vector<cvf::Vec3d>& vertices,
|
|
|
|
VertexOrganization organization) const
|
2018-03-12 10:18:40 -05:00
|
|
|
{
|
2018-03-20 03:10:06 -05:00
|
|
|
std::vector<cvf::Vec3d> pointNormals;
|
2018-03-20 09:36:57 -05:00
|
|
|
|
2018-03-20 07:51:51 -05:00
|
|
|
if (!wellPathGeometry()) return pointNormals;
|
2018-03-21 09:32:03 -05:00
|
|
|
if (vertices.empty()) return pointNormals;
|
2018-03-21 07:15:48 -05:00
|
|
|
|
|
|
|
const cvf::Vec3d globalDirection =
|
|
|
|
(wellPathGeometry()->m_wellPathPoints.back() - wellPathGeometry()->m_wellPathPoints.front()).getNormalized();
|
2018-03-21 10:22:35 -05:00
|
|
|
|
2018-03-14 08:22:14 -05:00
|
|
|
const cvf::Vec3d up(0, 0, 1);
|
|
|
|
|
2018-03-21 09:32:03 -05:00
|
|
|
size_t intervalSize;
|
|
|
|
if (organization == LINE_SEGMENTS)
|
2018-03-12 10:18:40 -05:00
|
|
|
{
|
2018-03-21 09:32:03 -05:00
|
|
|
pointNormals.reserve(vertices.size() / 2);
|
|
|
|
intervalSize = 2;
|
|
|
|
}
|
2018-03-21 10:22:35 -05:00
|
|
|
else // organization == POLYLINE
|
2018-03-21 09:32:03 -05:00
|
|
|
{
|
|
|
|
pointNormals.reserve(vertices.size());
|
|
|
|
intervalSize = 1;
|
2018-03-12 10:18:40 -05:00
|
|
|
}
|
2018-03-20 07:51:51 -05:00
|
|
|
|
|
|
|
cvf::Vec3d normal;
|
2018-03-21 10:22:35 -05:00
|
|
|
|
2018-03-21 09:32:03 -05:00
|
|
|
for (size_t i = 0; i < vertices.size() - 1; i += intervalSize)
|
2018-03-20 07:51:51 -05:00
|
|
|
{
|
2018-03-21 09:32:03 -05:00
|
|
|
cvf::Vec3d p1 = vertices[i];
|
2018-03-21 10:22:35 -05:00
|
|
|
cvf::Vec3d p2 = vertices[i + 1];
|
2018-03-20 07:51:51 -05:00
|
|
|
|
|
|
|
cvf::Vec3d vecAlongPath = (p2 - p1).getNormalized();
|
|
|
|
|
|
|
|
double dotProduct = up * vecAlongPath;
|
|
|
|
|
|
|
|
cvf::Vec3d Ex;
|
|
|
|
|
|
|
|
if (cvf::Math::abs(dotProduct) > 0.7071)
|
|
|
|
{
|
|
|
|
Ex = globalDirection;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Ex = vecAlongPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
cvf::Vec3d Ey = (up ^ Ex).getNormalized();
|
|
|
|
|
2018-03-22 02:54:48 -05:00
|
|
|
cvf::Mat3d rotation;
|
|
|
|
normal = Ey.getTransformedVector(rotation.fromRotation(Ex, angle));
|
2018-03-20 07:51:51 -05:00
|
|
|
|
2018-03-21 09:32:03 -05:00
|
|
|
pointNormals.push_back(normal);
|
2018-03-20 07:51:51 -05:00
|
|
|
}
|
|
|
|
|
2018-03-21 09:32:03 -05:00
|
|
|
if (organization == POLYLINE)
|
|
|
|
{
|
|
|
|
pointNormals.push_back(normal);
|
|
|
|
}
|
2018-03-20 07:51:51 -05:00
|
|
|
|
2018-03-21 09:32:03 -05:00
|
|
|
return pointNormals;
|
2018-03-20 07:51:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-03-20 09:36:57 -05:00
|
|
|
///
|
2018-03-20 07:51:51 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
const RigWellPath* Riv3dWellLogCurveGeometryGenerator::wellPathGeometry() const
|
|
|
|
{
|
|
|
|
return m_wellPath->wellPathGeometry();
|
|
|
|
}
|
2018-03-21 09:32:03 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-03-21 10:22:35 -05:00
|
|
|
///
|
2018-03-21 09:32:03 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-03-22 05:45:11 -05:00
|
|
|
void Riv3dWellLogCurveGeometryGenerator::calculatePairsOfClosestSamplingPointsAlongWellPath(
|
2018-03-21 10:22:35 -05:00
|
|
|
std::vector<cvf::Vec3d>* closestWellPathPoints,
|
|
|
|
std::vector<cvf::Vec3d>& points) const
|
2018-03-21 09:32:03 -05:00
|
|
|
{
|
|
|
|
CVF_ASSERT(closestWellPathPoints != nullptr);
|
|
|
|
|
|
|
|
for (const cvf::Vec3d point : points)
|
|
|
|
{
|
|
|
|
cvf::Vec3d p1 = cvf::Vec3d::UNDEFINED;
|
|
|
|
cvf::Vec3d p2 = cvf::Vec3d::UNDEFINED;
|
|
|
|
wellPathGeometry()->twoClosestPoints(point, &p1, &p2);
|
|
|
|
if (p1.isUndefined() || p2.isUndefined()) continue;
|
|
|
|
|
|
|
|
closestWellPathPoints->push_back(p1);
|
|
|
|
closestWellPathPoints->push_back(p2);
|
|
|
|
}
|
|
|
|
}
|