mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-27 08:47:00 -06:00
#1272, #1271 - pre-proto - Adding field for setting unit system for fracture, and converting geometry/polygon between unit systems
This commit is contained in:
parent
e29c6474bd
commit
2811e5aa4d
@ -250,7 +250,7 @@ void RivWellFracturePartMgr::generateFractureOutlinePolygonPart(caf::DisplayCoor
|
||||
cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::createPolygonDrawable(caf::DisplayCoordTransform* displayCoordTransform)
|
||||
{
|
||||
|
||||
std::vector<cvf::Vec3f> polygon = m_rimFracture->attachedFractureDefinition()->fracturePolygon();
|
||||
std::vector<cvf::Vec3f> polygon = m_rimFracture->attachedFractureDefinition()->fracturePolygon(m_rimFracture->fractureUnit);
|
||||
|
||||
//Transform to model coordinates and then display coords
|
||||
std::vector<cvf::Vec3f> polygonInDisplayCoords;
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
#include "RimEllipseFractureTemplate.h"
|
||||
|
||||
#include "RiaLogging.h"
|
||||
|
||||
#include "RigTesselatorTools.h"
|
||||
|
||||
#include "RimDefines.h"
|
||||
@ -99,12 +101,38 @@ void RimEllipseFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* cha
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEllipseFractureTemplate::fractureGeometry(std::vector<cvf::Vec3f>* nodeCoords, std::vector<cvf::uint>* triangleIndices)
|
||||
void RimEllipseFractureTemplate::fractureGeometry(std::vector<cvf::Vec3f>* nodeCoords, std::vector<cvf::uint>* triangleIndices, caf::AppEnum< RimDefines::UnitSystem > fractureUnit)
|
||||
{
|
||||
RigEllipsisTesselator tesselator(20);
|
||||
|
||||
float a = halfLength;
|
||||
float b = height / 2.0f;
|
||||
float a = cvf::UNDEFINED_FLOAT;
|
||||
float b = cvf::UNDEFINED_FLOAT;
|
||||
|
||||
if (fractureUnit == fractureTemplateUnit())
|
||||
{
|
||||
a = halfLength;
|
||||
b = height / 2.0f;
|
||||
|
||||
}
|
||||
else if (fractureTemplateUnit() == RimDefines::UNITS_METRIC && fractureUnit == RimDefines::UNITS_FIELD)
|
||||
{
|
||||
RiaLogging::info(QString("Converting fracture template geometry from metric to field"));
|
||||
a = RimDefines::meterToFeet(halfLength);
|
||||
b = RimDefines::meterToFeet(height / 2.0f);
|
||||
}
|
||||
else if (fractureTemplateUnit() == RimDefines::UNITS_FIELD && fractureUnit == RimDefines::UNITS_METRIC)
|
||||
{
|
||||
RiaLogging::info(QString("Converting fracture template geometry from field to metric"));
|
||||
a = RimDefines::feetToMeter(halfLength);
|
||||
b = RimDefines::feetToMeter(height / 2.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Should never get here...
|
||||
RiaLogging::error(QString("Error: Could not convert units for fracture / fracture template"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
tesselator.tesselateEllipsis(a, b, triangleIndices, nodeCoords);
|
||||
}
|
||||
@ -112,14 +140,14 @@ void RimEllipseFractureTemplate::fractureGeometry(std::vector<cvf::Vec3f>* nodeC
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<cvf::Vec3f> RimEllipseFractureTemplate::fracturePolygon()
|
||||
std::vector<cvf::Vec3f> RimEllipseFractureTemplate::fracturePolygon(caf::AppEnum< RimDefines::UnitSystem > fractureUnit)
|
||||
{
|
||||
std::vector<cvf::Vec3f> polygon;
|
||||
|
||||
std::vector<cvf::Vec3f> nodeCoords;
|
||||
std::vector<cvf::uint> triangleIndices;
|
||||
|
||||
fractureGeometry(&nodeCoords, &triangleIndices);
|
||||
fractureGeometry(&nodeCoords, &triangleIndices, fractureUnit);
|
||||
|
||||
for (size_t i = 1; i < nodeCoords.size(); i++)
|
||||
{
|
||||
|
@ -53,8 +53,8 @@ public:
|
||||
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
|
||||
void fractureGeometry(std::vector<cvf::Vec3f>* nodeCoords, std::vector<cvf::uint>* polygonIndices);
|
||||
std::vector<cvf::Vec3f> fracturePolygon();
|
||||
void fractureGeometry(std::vector<cvf::Vec3f>* nodeCoords, std::vector<cvf::uint>* polygonIndices, caf::AppEnum< RimDefines::UnitSystem > fractureTemplateUnit);
|
||||
std::vector<cvf::Vec3f> fracturePolygon(caf::AppEnum< RimDefines::UnitSystem > fractureTemplateUnit);
|
||||
void changeUnits();
|
||||
|
||||
protected:
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "RigResultAccessorFactory.h"
|
||||
#include "RigTesselatorTools.h"
|
||||
|
||||
#include "RimDefines.h"
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseCellColors.h"
|
||||
#include "RimEclipseView.h"
|
||||
@ -83,6 +84,7 @@ RimFracture::RimFracture(void)
|
||||
azimuth.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName());
|
||||
CAF_PDM_InitField(&perforationLength, "PerforationLength", 0.0, "Perforation Length", "", "", "");
|
||||
CAF_PDM_InitField(&showPolygonFractureOutline, "showPolygonFractureOutline", true, "Show Polygon Outline", "", "", "");
|
||||
CAF_PDM_InitField(&fractureUnit, "fractureUnit", caf::AppEnum<RimDefines::UnitSystem>(RimDefines::UNITS_METRIC), "Fracture Unit System", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&stimPlanTimeIndexToPlot, "timeIndexToPlot", 0, "StimPlan Time Step", "", "", "");
|
||||
|
||||
@ -181,7 +183,8 @@ void RimFracture::fieldChangedByUi(const caf::PdmFieldHandle* changedField, cons
|
||||
changedField == &m_fractureTemplate ||
|
||||
changedField == &stimPlanTimeIndexToPlot ||
|
||||
changedField == this->objectToggleField() ||
|
||||
changedField == &showPolygonFractureOutline)
|
||||
changedField == &showPolygonFractureOutline ||
|
||||
changedField == &fractureUnit)
|
||||
{
|
||||
|
||||
setRecomputeGeometryFlag();
|
||||
@ -225,7 +228,7 @@ void RimFracture::computeGeometry()
|
||||
RimFractureTemplate* fractureDef = attachedFractureDefinition();
|
||||
if (fractureDef )
|
||||
{
|
||||
fractureDef->fractureGeometry(&nodeCoords, &triangleIndices);
|
||||
fractureDef->fractureGeometry(&nodeCoords, &triangleIndices, fractureUnit);
|
||||
}
|
||||
|
||||
cvf::Mat4f m = transformMatrix();
|
||||
@ -371,7 +374,7 @@ void RimFracture::computeTransmissibility(RimEclipseCase* caseToApply)
|
||||
|
||||
if (attachedFractureDefinition())
|
||||
{
|
||||
std::vector<cvf::Vec3f> fracPolygon = attachedFractureDefinition()->fracturePolygon();
|
||||
std::vector<cvf::Vec3f> fracPolygon = attachedFractureDefinition()->fracturePolygon(fractureUnit);
|
||||
|
||||
std::vector<cvf::Vec3d> fracPolygonDouble;
|
||||
for (auto v : fracPolygon) fracPolygonDouble.push_back(static_cast<cvf::Vec3d>(v));
|
||||
|
@ -19,6 +19,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "RimCheckableNamedObject.h"
|
||||
#include "RimDefines.h"
|
||||
|
||||
#include "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
@ -26,6 +27,7 @@
|
||||
#include "cvfMatrix4.h"
|
||||
#include "cvfPlane.h"
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
#include "cafPdmChildField.h"
|
||||
#include "cafPdmFieldCvfVec3d.h"
|
||||
#include "cafPdmProxyValueField.h"
|
||||
@ -56,6 +58,8 @@ public:
|
||||
caf::PdmField<int> stimPlanTimeIndexToPlot;
|
||||
caf::PdmField<bool> showPolygonFractureOutline;
|
||||
|
||||
caf::PdmField< caf::AppEnum< RimDefines::UnitSystem > > fractureUnit;
|
||||
|
||||
|
||||
cvf::Vec3d anchorPosition();
|
||||
void setAnchorPosition(const cvf::Vec3d& pos);
|
||||
|
@ -69,8 +69,8 @@ public:
|
||||
virtual caf::PdmFieldHandle* userDescriptionField() override;
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
|
||||
virtual void fractureGeometry(std::vector<cvf::Vec3f>* nodeCoords, std::vector<cvf::uint>* triangleIndices) = 0;
|
||||
virtual std::vector<cvf::Vec3f> fracturePolygon() = 0;
|
||||
virtual void fractureGeometry(std::vector<cvf::Vec3f>* nodeCoords, std::vector<cvf::uint>* triangleIndices, caf::AppEnum< RimDefines::UnitSystem > fractureTemplateUnit) = 0;
|
||||
virtual std::vector<cvf::Vec3f> fracturePolygon(caf::AppEnum< RimDefines::UnitSystem > fractureTemplateUnit) = 0;
|
||||
protected:
|
||||
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering);
|
||||
};
|
||||
|
@ -492,7 +492,7 @@ QString RimStimPlanFractureTemplate::getAttributeValueString(QXmlStreamReader &x
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimStimPlanFractureTemplate::fractureGeometry(std::vector<cvf::Vec3f>* nodeCoords, std::vector<cvf::uint>* triangleIndices)
|
||||
void RimStimPlanFractureTemplate::fractureGeometry(std::vector<cvf::Vec3f>* nodeCoords, std::vector<cvf::uint>* triangleIndices, caf::AppEnum< RimDefines::UnitSystem > fractureUnit)
|
||||
{
|
||||
|
||||
if (m_stimPlanFractureDefinitionData.isNull())
|
||||
@ -506,6 +506,30 @@ void RimStimPlanFractureTemplate::fractureGeometry(std::vector<cvf::Vec3f>* node
|
||||
|
||||
std::vector<double> adjustedDepths = adjustedDepthCoordsAroundWellPathPosition();
|
||||
|
||||
if (fractureUnit == fractureTemplateUnit())
|
||||
{
|
||||
RiaLogging::debug(QString("No conversion necessary for %1").arg(name));
|
||||
}
|
||||
|
||||
else if (fractureTemplateUnit() == RimDefines::UNITS_METRIC && fractureUnit == RimDefines::UNITS_FIELD)
|
||||
{
|
||||
RiaLogging::info(QString("Converting StimPlan geometry from metric to field for fracture template %1").arg(name));
|
||||
for (double& value : adjustedDepths) value = RimDefines::meterToFeet(value);
|
||||
for (double& value : xCoords) value = RimDefines::meterToFeet(value);
|
||||
}
|
||||
else if (fractureTemplateUnit() == RimDefines::UNITS_FIELD && fractureUnit == RimDefines::UNITS_METRIC)
|
||||
{
|
||||
RiaLogging::info(QString("Converting StimPlan geometry from field to metric for fracture template %1").arg(name));
|
||||
for (double& value : adjustedDepths) value = RimDefines::feetToMeter(value);
|
||||
for (double& value : xCoords) value = RimDefines::feetToMeter(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Should never get here...
|
||||
RiaLogging::error(QString("Error: Could not convert units for fracture template %1").arg(name));
|
||||
return;
|
||||
}
|
||||
|
||||
for (cvf::uint k = 0; k < adjustedDepths.size(); k++)
|
||||
{
|
||||
for (cvf::uint i = 0; i < lenXcoords; i++)
|
||||
@ -622,7 +646,7 @@ void RimStimPlanFractureTemplate::computeMinMax(const QString& resultName, const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<cvf::Vec3f> RimStimPlanFractureTemplate::fracturePolygon()
|
||||
std::vector<cvf::Vec3f> RimStimPlanFractureTemplate::fracturePolygon(caf::AppEnum< RimDefines::UnitSystem > fractureUnit)
|
||||
{
|
||||
std::vector<cvf::Vec3f> polygon;
|
||||
QString parameterName;
|
||||
@ -661,14 +685,14 @@ std::vector<cvf::Vec3f> RimStimPlanFractureTemplate::fracturePolygon()
|
||||
}
|
||||
|
||||
std::vector<cvf::Vec3f> negPolygon;
|
||||
for (const auto& node : polygon)
|
||||
for (const cvf::Vec3f& node : polygon)
|
||||
{
|
||||
cvf::Vec3f negNode = node;
|
||||
negNode.x() = -negNode.x();
|
||||
negPolygon.insert(negPolygon.begin(), negNode);
|
||||
}
|
||||
|
||||
for (const auto& negNode : negPolygon)
|
||||
for (const cvf::Vec3f& negNode : negPolygon)
|
||||
{
|
||||
polygon.push_back(negNode);
|
||||
}
|
||||
@ -676,6 +700,44 @@ std::vector<cvf::Vec3f> RimStimPlanFractureTemplate::fracturePolygon()
|
||||
//Adding first point last - to close the polygon
|
||||
if (polygon.size()>0) polygon.push_back(polygon[0]);
|
||||
|
||||
|
||||
if (fractureUnit == fractureTemplateUnit())
|
||||
{
|
||||
RiaLogging::debug(QString("No conversion necessary for %1").arg(name));
|
||||
}
|
||||
|
||||
else if (fractureTemplateUnit() == RimDefines::UNITS_METRIC && fractureUnit == RimDefines::UNITS_FIELD)
|
||||
{
|
||||
RiaLogging::info(QString("Converting StimPlan geometry from metric to field for fracture template %1").arg(name));
|
||||
for (cvf::Vec3f& node : polygon)
|
||||
{
|
||||
float x = RimDefines::meterToFeet(node.x());
|
||||
float y = RimDefines::meterToFeet(node.y());
|
||||
float z = RimDefines::meterToFeet(node.z());
|
||||
node = cvf::Vec3f(x, y, z);
|
||||
}
|
||||
}
|
||||
else if (fractureTemplateUnit() == RimDefines::UNITS_FIELD && fractureUnit == RimDefines::UNITS_METRIC)
|
||||
{
|
||||
RiaLogging::info(QString("Converting StimPlan geometry from field to metric for fracture template %1").arg(name));
|
||||
for (cvf::Vec3f& node : polygon)
|
||||
{
|
||||
float x = RimDefines::feetToMeter(node.x());
|
||||
float y = RimDefines::feetToMeter(node.y());
|
||||
float z = RimDefines::feetToMeter(node.z());
|
||||
node = cvf::Vec3f(x, y, z);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Should never get here...
|
||||
RiaLogging::error(QString("Error: Could not convert units for fracture template %1").arg(name));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return polygon;
|
||||
}
|
||||
|
||||
|
@ -59,8 +59,8 @@ public:
|
||||
const QString& fileName();
|
||||
QString fileNameWithOutPath();
|
||||
|
||||
void fractureGeometry(std::vector<cvf::Vec3f>* nodeCoords, std::vector<cvf::uint>* triangleIndices);
|
||||
std::vector<cvf::Vec3f> fracturePolygon();
|
||||
void fractureGeometry(std::vector<cvf::Vec3f>* nodeCoords, std::vector<cvf::uint>* triangleIndices, caf::AppEnum< RimDefines::UnitSystem > fractureUnit) override;
|
||||
std::vector<cvf::Vec3f> fracturePolygon(caf::AppEnum< RimDefines::UnitSystem > fractureUnit);
|
||||
|
||||
std::vector<double> getNegAndPosXcoords();
|
||||
std::vector<double> adjustedDepthCoordsAroundWellPathPosition();
|
||||
|
Loading…
Reference in New Issue
Block a user