#1272, #1271 - pre-proto - Adding field for setting unit system for fracture, and converting geometry/polygon between unit systems

This commit is contained in:
astridkbjorke 2017-03-02 10:08:45 +01:00
parent e29c6474bd
commit 2811e5aa4d
8 changed files with 116 additions and 19 deletions

View File

@ -250,7 +250,7 @@ void RivWellFracturePartMgr::generateFractureOutlinePolygonPart(caf::DisplayCoor
cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::createPolygonDrawable(caf::DisplayCoordTransform* displayCoordTransform) 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 //Transform to model coordinates and then display coords
std::vector<cvf::Vec3f> polygonInDisplayCoords; std::vector<cvf::Vec3f> polygonInDisplayCoords;

View File

@ -18,6 +18,8 @@
#include "RimEllipseFractureTemplate.h" #include "RimEllipseFractureTemplate.h"
#include "RiaLogging.h"
#include "RigTesselatorTools.h" #include "RigTesselatorTools.h"
#include "RimDefines.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); RigEllipsisTesselator tesselator(20);
float a = halfLength; float a = cvf::UNDEFINED_FLOAT;
float b = height / 2.0f; 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); 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> polygon;
std::vector<cvf::Vec3f> nodeCoords; std::vector<cvf::Vec3f> nodeCoords;
std::vector<cvf::uint> triangleIndices; std::vector<cvf::uint> triangleIndices;
fractureGeometry(&nodeCoords, &triangleIndices); fractureGeometry(&nodeCoords, &triangleIndices, fractureUnit);
for (size_t i = 1; i < nodeCoords.size(); i++) for (size_t i = 1; i < nodeCoords.size(); i++)
{ {

View File

@ -53,8 +53,8 @@ public:
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; 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); void fractureGeometry(std::vector<cvf::Vec3f>* nodeCoords, std::vector<cvf::uint>* polygonIndices, caf::AppEnum< RimDefines::UnitSystem > fractureTemplateUnit);
std::vector<cvf::Vec3f> fracturePolygon(); std::vector<cvf::Vec3f> fracturePolygon(caf::AppEnum< RimDefines::UnitSystem > fractureTemplateUnit);
void changeUnits(); void changeUnits();
protected: protected:

View File

@ -33,6 +33,7 @@
#include "RigResultAccessorFactory.h" #include "RigResultAccessorFactory.h"
#include "RigTesselatorTools.h" #include "RigTesselatorTools.h"
#include "RimDefines.h"
#include "RimEclipseCase.h" #include "RimEclipseCase.h"
#include "RimEclipseCellColors.h" #include "RimEclipseCellColors.h"
#include "RimEclipseView.h" #include "RimEclipseView.h"
@ -83,6 +84,7 @@ RimFracture::RimFracture(void)
azimuth.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); azimuth.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName());
CAF_PDM_InitField(&perforationLength, "PerforationLength", 0.0, "Perforation Length", "", "", ""); CAF_PDM_InitField(&perforationLength, "PerforationLength", 0.0, "Perforation Length", "", "", "");
CAF_PDM_InitField(&showPolygonFractureOutline, "showPolygonFractureOutline", true, "Show Polygon Outline", "", "", ""); 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", "", "", ""); 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 == &m_fractureTemplate ||
changedField == &stimPlanTimeIndexToPlot || changedField == &stimPlanTimeIndexToPlot ||
changedField == this->objectToggleField() || changedField == this->objectToggleField() ||
changedField == &showPolygonFractureOutline) changedField == &showPolygonFractureOutline ||
changedField == &fractureUnit)
{ {
setRecomputeGeometryFlag(); setRecomputeGeometryFlag();
@ -225,7 +228,7 @@ void RimFracture::computeGeometry()
RimFractureTemplate* fractureDef = attachedFractureDefinition(); RimFractureTemplate* fractureDef = attachedFractureDefinition();
if (fractureDef ) if (fractureDef )
{ {
fractureDef->fractureGeometry(&nodeCoords, &triangleIndices); fractureDef->fractureGeometry(&nodeCoords, &triangleIndices, fractureUnit);
} }
cvf::Mat4f m = transformMatrix(); cvf::Mat4f m = transformMatrix();
@ -371,7 +374,7 @@ void RimFracture::computeTransmissibility(RimEclipseCase* caseToApply)
if (attachedFractureDefinition()) if (attachedFractureDefinition())
{ {
std::vector<cvf::Vec3f> fracPolygon = attachedFractureDefinition()->fracturePolygon(); std::vector<cvf::Vec3f> fracPolygon = attachedFractureDefinition()->fracturePolygon(fractureUnit);
std::vector<cvf::Vec3d> fracPolygonDouble; std::vector<cvf::Vec3d> fracPolygonDouble;
for (auto v : fracPolygon) fracPolygonDouble.push_back(static_cast<cvf::Vec3d>(v)); for (auto v : fracPolygon) fracPolygonDouble.push_back(static_cast<cvf::Vec3d>(v));

View File

@ -19,6 +19,7 @@
#pragma once #pragma once
#include "RimCheckableNamedObject.h" #include "RimCheckableNamedObject.h"
#include "RimDefines.h"
#include "cvfBase.h" #include "cvfBase.h"
#include "cvfObject.h" #include "cvfObject.h"
@ -26,6 +27,7 @@
#include "cvfMatrix4.h" #include "cvfMatrix4.h"
#include "cvfPlane.h" #include "cvfPlane.h"
#include "cafAppEnum.h"
#include "cafPdmChildField.h" #include "cafPdmChildField.h"
#include "cafPdmFieldCvfVec3d.h" #include "cafPdmFieldCvfVec3d.h"
#include "cafPdmProxyValueField.h" #include "cafPdmProxyValueField.h"
@ -56,6 +58,8 @@ public:
caf::PdmField<int> stimPlanTimeIndexToPlot; caf::PdmField<int> stimPlanTimeIndexToPlot;
caf::PdmField<bool> showPolygonFractureOutline; caf::PdmField<bool> showPolygonFractureOutline;
caf::PdmField< caf::AppEnum< RimDefines::UnitSystem > > fractureUnit;
cvf::Vec3d anchorPosition(); cvf::Vec3d anchorPosition();
void setAnchorPosition(const cvf::Vec3d& pos); void setAnchorPosition(const cvf::Vec3d& pos);

View File

@ -69,8 +69,8 @@ public:
virtual caf::PdmFieldHandle* userDescriptionField() override; virtual caf::PdmFieldHandle* userDescriptionField() override;
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) 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 void fractureGeometry(std::vector<cvf::Vec3f>* nodeCoords, std::vector<cvf::uint>* triangleIndices, caf::AppEnum< RimDefines::UnitSystem > fractureTemplateUnit) = 0;
virtual std::vector<cvf::Vec3f> fracturePolygon() = 0; virtual std::vector<cvf::Vec3f> fracturePolygon(caf::AppEnum< RimDefines::UnitSystem > fractureTemplateUnit) = 0;
protected: protected:
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering); virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering);
}; };

View File

@ -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()) if (m_stimPlanFractureDefinitionData.isNull())
@ -506,6 +506,30 @@ void RimStimPlanFractureTemplate::fractureGeometry(std::vector<cvf::Vec3f>* node
std::vector<double> adjustedDepths = adjustedDepthCoordsAroundWellPathPosition(); 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 k = 0; k < adjustedDepths.size(); k++)
{ {
for (cvf::uint i = 0; i < lenXcoords; i++) 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; std::vector<cvf::Vec3f> polygon;
QString parameterName; QString parameterName;
@ -661,14 +685,14 @@ std::vector<cvf::Vec3f> RimStimPlanFractureTemplate::fracturePolygon()
} }
std::vector<cvf::Vec3f> negPolygon; std::vector<cvf::Vec3f> negPolygon;
for (const auto& node : polygon) for (const cvf::Vec3f& node : polygon)
{ {
cvf::Vec3f negNode = node; cvf::Vec3f negNode = node;
negNode.x() = -negNode.x(); negNode.x() = -negNode.x();
negPolygon.insert(negPolygon.begin(), negNode); negPolygon.insert(negPolygon.begin(), negNode);
} }
for (const auto& negNode : negPolygon) for (const cvf::Vec3f& negNode : negPolygon)
{ {
polygon.push_back(negNode); polygon.push_back(negNode);
} }
@ -676,6 +700,44 @@ std::vector<cvf::Vec3f> RimStimPlanFractureTemplate::fracturePolygon()
//Adding first point last - to close the polygon //Adding first point last - to close the polygon
if (polygon.size()>0) polygon.push_back(polygon[0]); 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; return polygon;
} }

View File

@ -59,8 +59,8 @@ public:
const QString& fileName(); const QString& fileName();
QString fileNameWithOutPath(); QString fileNameWithOutPath();
void fractureGeometry(std::vector<cvf::Vec3f>* nodeCoords, std::vector<cvf::uint>* triangleIndices); void fractureGeometry(std::vector<cvf::Vec3f>* nodeCoords, std::vector<cvf::uint>* triangleIndices, caf::AppEnum< RimDefines::UnitSystem > fractureUnit) override;
std::vector<cvf::Vec3f> fracturePolygon(); std::vector<cvf::Vec3f> fracturePolygon(caf::AppEnum< RimDefines::UnitSystem > fractureUnit);
std::vector<double> getNegAndPosXcoords(); std::vector<double> getNegAndPosXcoords();
std::vector<double> adjustedDepthCoordsAroundWellPathPosition(); std::vector<double> adjustedDepthCoordsAroundWellPathPosition();