mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1646 Fix disappearing mesh lines by using double transformation calculations
This commit is contained in:
@@ -68,7 +68,7 @@ RivWellFracturePartMgr::~RivWellFracturePartMgr()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivWellFracturePartMgr::generateSurfacePart(const caf::DisplayCoordTransform* displayCoordTransform)
|
||||
{
|
||||
if (m_part.notNull()) return;
|
||||
if (m_surfacePart.notNull()) return;
|
||||
if (!displayCoordTransform) return;
|
||||
|
||||
if (m_rimFracture)
|
||||
@@ -94,9 +94,9 @@ void RivWellFracturePartMgr::generateSurfacePart(const caf::DisplayCoordTransfor
|
||||
cvf::ref<cvf::DrawableGeo> geo = buildDrawableGeoFromTriangles(triangleIndices, displayCoords);
|
||||
CVF_ASSERT(geo.notNull());
|
||||
|
||||
m_part = new cvf::Part(0, "FractureSurfacePart");
|
||||
m_part->setDrawable(geo.p());
|
||||
m_part->setSourceInfo(new RivObjectSourceInfo(m_rimFracture));
|
||||
m_surfacePart = new cvf::Part(0, "FractureSurfacePart");
|
||||
m_surfacePart->setDrawable(geo.p());
|
||||
m_surfacePart->setSourceInfo(new RivObjectSourceInfo(m_rimFracture));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -106,7 +106,7 @@ void RivWellFracturePartMgr::generateSurfacePart(const caf::DisplayCoordTransfor
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivWellFracturePartMgr::applyFractureUniformColor()
|
||||
{
|
||||
if ( m_part.notNull() )
|
||||
if ( m_surfacePart.notNull() )
|
||||
{
|
||||
cvf::Color4f fractureColor = cvf::Color4f(cvf::Color3f(cvf::Color3::BROWN));
|
||||
|
||||
@@ -118,7 +118,7 @@ void RivWellFracturePartMgr::applyFractureUniformColor()
|
||||
|
||||
caf::SurfaceEffectGenerator surfaceGen(fractureColor, caf::PO_1);
|
||||
cvf::ref<cvf::Effect> eff = surfaceGen.generateCachedEffect();
|
||||
m_part->setEffect(eff.p());
|
||||
m_surfacePart->setEffect(eff.p());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ void RivWellFracturePartMgr::applyFractureUniformColor()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivWellFracturePartMgr::applyResultTextureColor()
|
||||
{
|
||||
if (m_part.isNull()) return;
|
||||
if (m_surfacePart.isNull()) return;
|
||||
|
||||
if (m_rimFracture)
|
||||
{
|
||||
@@ -152,7 +152,7 @@ void RivWellFracturePartMgr::applyResultTextureColor()
|
||||
if (legendConfig)
|
||||
{
|
||||
cvf::ScalarMapper* scalarMapper = legendConfig->scalarMapper();
|
||||
cvf::DrawableGeo* geo = dynamic_cast<cvf::DrawableGeo*> (m_part->drawable());
|
||||
cvf::DrawableGeo* geo = dynamic_cast<cvf::DrawableGeo*> (m_surfacePart->drawable());
|
||||
cvf::ref<cvf::Vec2fArray> textureCoords = new cvf::Vec2fArray;
|
||||
textureCoords->resize(geo->vertexCount());
|
||||
|
||||
@@ -194,8 +194,8 @@ void RivWellFracturePartMgr::applyResultTextureColor()
|
||||
|
||||
cvf::ref<cvf::Effect> eff = effGen.generateCachedEffect();
|
||||
|
||||
m_part->setEffect(eff.p());
|
||||
m_part->setPriority(RivPartPriority::PartType::Transparent);
|
||||
m_surfacePart->setEffect(eff.p());
|
||||
m_surfacePart->setPriority(RivPartPriority::PartType::Transparent);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -287,7 +287,7 @@ cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::createStimPlanMeshDrawable(Ri
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
cvf::Mat4f m = m_rimFracture->transformMatrix();
|
||||
cvf::Mat4d m = m_rimFracture->transformMatrix();
|
||||
std::vector<cvf::Vec3f> stimPlanMeshVerticesDisplayCoords = transfromToFractureDisplayCoords(stimPlanMeshVertices, m, displayCoordTransform);
|
||||
|
||||
cvf::Vec3fArray* stimPlanMeshVertexList;
|
||||
@@ -340,7 +340,7 @@ cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::createPolygonDrawable(const c
|
||||
{
|
||||
std::vector<cvf::Vec3f> polygon = m_rimFracture->fractureTemplate()->fractureBorderPolygon(m_rimFracture->fractureUnit());
|
||||
|
||||
cvf::Mat4f m = m_rimFracture->transformMatrix();
|
||||
cvf::Mat4d m = m_rimFracture->transformMatrix();
|
||||
std::vector<cvf::Vec3f> polygonDisplayCoords = transfromToFractureDisplayCoords(polygon, m, displayCoordTransform);
|
||||
|
||||
for (size_t i = 0; i < polygonDisplayCoords.size(); ++i)
|
||||
@@ -374,17 +374,19 @@ cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::createPolygonDrawable(const c
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<cvf::Vec3f> RivWellFracturePartMgr::transfromToFractureDisplayCoords(std::vector<cvf::Vec3f> coordinatesVector,
|
||||
cvf::Mat4f m,
|
||||
std::vector<cvf::Vec3f> RivWellFracturePartMgr::transfromToFractureDisplayCoords(const std::vector<cvf::Vec3f>& coordinatesVector,
|
||||
cvf::Mat4d m,
|
||||
const caf::DisplayCoordTransform* displayCoordTransform)
|
||||
{
|
||||
std::vector<cvf::Vec3f> polygonInDisplayCoords;
|
||||
for (cvf::Vec3f v : coordinatesVector)
|
||||
polygonInDisplayCoords.reserve(coordinatesVector.size());
|
||||
|
||||
for (const cvf::Vec3f& v : coordinatesVector)
|
||||
{
|
||||
v.transformPoint(m);
|
||||
cvf::Vec3d nodeCoordsDouble = static_cast<cvf::Vec3d>(v);
|
||||
cvf::Vec3d displayCoordsDouble = displayCoordTransform->transformToDisplayCoord(nodeCoordsDouble);
|
||||
polygonInDisplayCoords.push_back(static_cast<cvf::Vec3f>(displayCoordsDouble));
|
||||
cvf::Vec3d vd(v);
|
||||
vd.transformPoint(m);
|
||||
cvf::Vec3d displayCoordsDouble = displayCoordTransform->transformToDisplayCoord(vd);
|
||||
polygonInDisplayCoords.push_back(cvf::Vec3f(displayCoordsDouble));
|
||||
}
|
||||
|
||||
return polygonInDisplayCoords;
|
||||
@@ -418,7 +420,7 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* mod
|
||||
|
||||
RimStimPlanFractureTemplate* stimPlanFracTemplate = dynamic_cast<RimStimPlanFractureTemplate*>(m_rimFracture->fractureTemplate());
|
||||
|
||||
if (m_part.isNull())
|
||||
if (m_surfacePart.isNull())
|
||||
{
|
||||
if (m_rimFracture->fractureTemplate())
|
||||
{
|
||||
@@ -442,9 +444,9 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* mod
|
||||
}
|
||||
}
|
||||
|
||||
if (m_part.notNull())
|
||||
if (m_surfacePart.notNull())
|
||||
{
|
||||
model->addPart(m_part.p());
|
||||
model->addPart(m_surfacePart.p());
|
||||
}
|
||||
|
||||
if (m_stimPlanMeshPart.notNull()
|
||||
@@ -466,7 +468,7 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* mod
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivWellFracturePartMgr::clearGeometryCache()
|
||||
{
|
||||
m_part = nullptr;
|
||||
m_surfacePart = nullptr;
|
||||
m_polygonPart = nullptr;
|
||||
m_stimPlanMeshPart = nullptr;
|
||||
}
|
||||
|
@@ -73,8 +73,8 @@ private:
|
||||
|
||||
void getPolygonBB(float &polygonXmin, float &polygonXmax, float &polygonYmin, float &polygonYmax);
|
||||
|
||||
std::vector<cvf::Vec3f> transfromToFractureDisplayCoords(std::vector<cvf::Vec3f> polygon,
|
||||
cvf::Mat4f m,
|
||||
std::vector<cvf::Vec3f> transfromToFractureDisplayCoords(const std::vector<cvf::Vec3f>& polygon,
|
||||
cvf::Mat4d m,
|
||||
const caf::DisplayCoordTransform* displayCoordTransform);
|
||||
bool stimPlanCellTouchesPolygon(const std::vector<cvf::Vec3f>& polygon,
|
||||
double xMin,
|
||||
@@ -92,7 +92,7 @@ private:
|
||||
private:
|
||||
caf::PdmPointer<RimFracture> m_rimFracture;
|
||||
|
||||
cvf::ref<cvf::Part> m_part;
|
||||
cvf::ref<cvf::Part> m_surfacePart;
|
||||
cvf::ref<cvf::Part> m_polygonPart;
|
||||
cvf::ref<cvf::Part> m_stimPlanMeshPart;
|
||||
};
|
||||
|
@@ -163,9 +163,9 @@ void RimCompletionCellIntersectionCalc::calculateFractureIntersections(const Rig
|
||||
std::vector<cvf::Vec3d> fractureCellTransformed;
|
||||
for (const auto& v : fractureCell.getPolygon())
|
||||
{
|
||||
cvf::Vec3f polygonNode = cvf::Vec3f(v);
|
||||
cvf::Vec3d polygonNode = v;
|
||||
polygonNode.transformPoint(fracture->transformMatrix());
|
||||
fractureCellTransformed.push_back(cvf::Vec3d(polygonNode));
|
||||
fractureCellTransformed.push_back(polygonNode);
|
||||
}
|
||||
|
||||
std::vector<size_t> potentialCells;
|
||||
|
@@ -230,25 +230,25 @@ cvf::Vec3d RimFracture::anchorPosition() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Mat4f RimFracture::transformMatrix() const
|
||||
cvf::Mat4d RimFracture::transformMatrix() const
|
||||
{
|
||||
cvf::Vec3d center = anchorPosition();
|
||||
|
||||
// Dip (in XY plane)
|
||||
cvf::Mat4f dipRotation = cvf::Mat4f::fromRotation(cvf::Vec3f::Z_AXIS, cvf::Math::toRadians(dip()));
|
||||
cvf::Mat4d dipRotation = cvf::Mat4d::fromRotation(cvf::Vec3d::Z_AXIS, cvf::Math::toRadians(dip()));
|
||||
|
||||
// Dip (out of XY plane)
|
||||
cvf::Mat4f tiltRotation = cvf::Mat4f::fromRotation(cvf::Vec3f::X_AXIS, cvf::Math::toRadians(tilt()));
|
||||
cvf::Mat4d tiltRotation = cvf::Mat4d::fromRotation(cvf::Vec3d::X_AXIS, cvf::Math::toRadians(tilt()));
|
||||
|
||||
|
||||
// Ellipsis geometry is produced in XY-plane, rotate 90 deg around X to get zero azimuth along Y
|
||||
cvf::Mat4f rotationFromTesselator = cvf::Mat4f::fromRotation(cvf::Vec3f::X_AXIS, cvf::Math::toRadians(90.0f));
|
||||
cvf::Mat4d rotationFromTesselator = cvf::Mat4d::fromRotation(cvf::Vec3d::X_AXIS, cvf::Math::toRadians(90.0f));
|
||||
|
||||
// Azimuth rotation
|
||||
cvf::Mat4f azimuthRotation = cvf::Mat4f::fromRotation(cvf::Vec3f::Z_AXIS, cvf::Math::toRadians(-azimuth()-90));
|
||||
cvf::Mat4d azimuthRotation = cvf::Mat4d::fromRotation(cvf::Vec3d::Z_AXIS, cvf::Math::toRadians(-azimuth()-90));
|
||||
|
||||
cvf::Mat4f m = azimuthRotation * rotationFromTesselator * dipRotation * tiltRotation;
|
||||
m.setTranslation(cvf::Vec3f(center));
|
||||
cvf::Mat4d m = azimuthRotation * rotationFromTesselator * dipRotation * tiltRotation;
|
||||
m.setTranslation(center);
|
||||
|
||||
return m;
|
||||
}
|
||||
@@ -272,11 +272,15 @@ void RimFracture::triangleGeometry(std::vector<cvf::uint>* triangleIndices, std:
|
||||
fractureDef->fractureTriangleGeometry(nodeCoords, triangleIndices, fractureUnit());
|
||||
}
|
||||
|
||||
cvf::Mat4f m = transformMatrix();
|
||||
cvf::Mat4d m = transformMatrix();
|
||||
|
||||
for (cvf::Vec3f& v : *nodeCoords)
|
||||
{
|
||||
v.transformPoint(m);
|
||||
cvf::Vec3d vd(v);
|
||||
|
||||
vd.transformPoint(m);
|
||||
|
||||
v = cvf::Vec3f(vd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -77,7 +77,7 @@ public:
|
||||
size_t globalCellIndex) const;
|
||||
size_t findAnchorEclipseCell(const RigMainGrid* mainGrid) const;
|
||||
|
||||
cvf::Mat4f transformMatrix() const;
|
||||
cvf::Mat4d transformMatrix() const;
|
||||
|
||||
void setFractureTemplate(RimFractureTemplate* fractureTemplate);
|
||||
RimFractureTemplate* fractureTemplate() const;
|
||||
|
@@ -36,7 +36,7 @@
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigEclipseToStimPlanCellTransmissibilityCalculator::RigEclipseToStimPlanCellTransmissibilityCalculator(RimEclipseCase* caseToApply,
|
||||
cvf::Mat4f fractureTransform,
|
||||
cvf::Mat4d fractureTransform,
|
||||
double skinFactor,
|
||||
double cDarcy,
|
||||
const RigFractureCell& stimPlanCell)
|
||||
@@ -109,9 +109,8 @@ void RigEclipseToStimPlanCellTransmissibilityCalculator::calculateStimPlanCellsM
|
||||
std::vector<cvf::Vec3d> stimPlanPolygonTransformed;
|
||||
for (cvf::Vec3d v : m_stimPlanCell.getPolygon())
|
||||
{
|
||||
cvf::Vec3f stimPlanPolygonNode = cvf::Vec3f(v);
|
||||
stimPlanPolygonNode.transformPoint(m_fractureTransform);
|
||||
stimPlanPolygonTransformed.push_back(cvf::Vec3d(stimPlanPolygonNode));
|
||||
v.transformPoint(m_fractureTransform);
|
||||
stimPlanPolygonTransformed.push_back(v);
|
||||
}
|
||||
|
||||
std::vector<size_t> fracCells = getPotentiallyFracturedCellsForPolygon(stimPlanPolygonTransformed);
|
||||
@@ -144,18 +143,18 @@ void RigEclipseToStimPlanCellTransmissibilityCalculator::calculateStimPlanCellsM
|
||||
RigCellGeometryTools::findCellLocalXYZ(hexCorners, localX, localY, localZ);
|
||||
|
||||
//Transform planCell polygon(s) and averageZdirection to x/y coordinate system (where fracturePolygon already is located)
|
||||
cvf::Mat4f invertedTransMatrix = m_fractureTransform.getInverted();
|
||||
cvf::Mat4d invertedTransMatrix = m_fractureTransform.getInverted();
|
||||
for (std::vector<cvf::Vec3d> & planeCellPolygon : planeCellPolygons)
|
||||
{
|
||||
for (cvf::Vec3d& v : planeCellPolygon)
|
||||
{
|
||||
v.transformPoint(static_cast<cvf::Mat4d>(invertedTransMatrix));
|
||||
v.transformPoint(invertedTransMatrix);
|
||||
}
|
||||
}
|
||||
|
||||
cvf::Vec3d localZinFracPlane;
|
||||
localZinFracPlane = localZ;
|
||||
localZinFracPlane.transformVector(static_cast<cvf::Mat4d>(invertedTransMatrix));
|
||||
localZinFracPlane.transformVector(invertedTransMatrix);
|
||||
cvf::Vec3d directionOfLength = cvf::Vec3d::ZERO;
|
||||
directionOfLength.cross(localZinFracPlane, cvf::Vec3d(0, 0, 1));
|
||||
directionOfLength.normalize();
|
||||
|
@@ -34,7 +34,7 @@ class RigEclipseToStimPlanCellTransmissibilityCalculator
|
||||
{
|
||||
public:
|
||||
explicit RigEclipseToStimPlanCellTransmissibilityCalculator(RimEclipseCase* caseToApply,
|
||||
cvf::Mat4f fractureTransform,
|
||||
cvf::Mat4d fractureTransform,
|
||||
double skinFactor,
|
||||
double cDarcy,
|
||||
const RigFractureCell& stimPlanCell);
|
||||
@@ -51,7 +51,7 @@ private:
|
||||
RimEclipseCase* m_case;
|
||||
double m_cDarcy;
|
||||
double m_fractureSkinFactor;
|
||||
cvf::Mat4f m_fractureTransform;
|
||||
cvf::Mat4d m_fractureTransform;
|
||||
const RigFractureCell& m_stimPlanCell;
|
||||
|
||||
std::vector<size_t> m_globalIndeciesToContributingEclipseCells;
|
||||
|
@@ -135,13 +135,13 @@ bool RigHexIntersectionTools::planeHexCellIntersection(cvf::Vec3d* hexCorners, c
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigHexIntersectionTools::planeHexIntersectionPolygons(std::array<cvf::Vec3d, 8> hexCorners,
|
||||
cvf::Mat4f transformMatrixForPlane,
|
||||
cvf::Mat4d transformMatrixForPlane,
|
||||
std::vector<std::vector<cvf::Vec3d> >& polygons)
|
||||
{
|
||||
bool isCellIntersected = false;
|
||||
|
||||
cvf::Plane fracturePlane;
|
||||
fracturePlane.setFromPointAndNormal(static_cast<cvf::Vec3d>(transformMatrixForPlane.translation()),
|
||||
fracturePlane.setFromPointAndNormal(transformMatrixForPlane.translation(),
|
||||
static_cast<cvf::Vec3d>(transformMatrixForPlane.col(2)));
|
||||
|
||||
//Find line-segments where cell and fracture plane intersects
|
||||
|
@@ -66,7 +66,7 @@ struct RigHexIntersectionTools
|
||||
std::list<std::pair<cvf::Vec3d, cvf::Vec3d > >& intersectionLineSegments);
|
||||
|
||||
static bool planeHexIntersectionPolygons(std::array<cvf::Vec3d, 8> hexCorners,
|
||||
cvf::Mat4f transformMatrixForPlane,
|
||||
cvf::Mat4d transformMatrixForPlane,
|
||||
std::vector<std::vector<cvf::Vec3d> > & polygons);
|
||||
};
|
||||
|
||||
|
@@ -17,7 +17,7 @@
|
||||
RigWellPathStimplanIntersector::RigWellPathStimplanIntersector(const RigWellPath* wellpathGeom, const RimFracture* rimFracture)
|
||||
{
|
||||
std::vector<cvf::Vec3d> wellPathPoints = wellpathGeom->m_wellPathPoints;
|
||||
cvf::Mat4f fractureXf = rimFracture->transformMatrix();
|
||||
cvf::Mat4d fractureXf = rimFracture->transformMatrix();
|
||||
double wellRadius = rimFracture->wellRadius(rimFracture->fractureUnit());
|
||||
std::vector<cvf::Vec3f> fracturePolygonf ;
|
||||
std::vector<std::vector<cvf::Vec3d> > stpCellPolygons;
|
||||
@@ -39,14 +39,14 @@ RigWellPathStimplanIntersector::RigWellPathStimplanIntersector(const RigWellPath
|
||||
/// Todo: Use only the perforated parts of the well path
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
void RigWellPathStimplanIntersector::calculate(const cvf::Mat4f &fractureXf,
|
||||
void RigWellPathStimplanIntersector::calculate(const cvf::Mat4d &fractureXf,
|
||||
const std::vector<cvf::Vec3d>& wellPathPointsOrg,
|
||||
double wellRadius,
|
||||
double perforationLength,
|
||||
const std::vector<std::vector<cvf::Vec3d> >& stpCellPolygons,
|
||||
std::map<size_t, WellCellIntersection>& m_stimPlanCellIdxToIntersectionInfoMap)
|
||||
{
|
||||
cvf::Mat4d toFractureXf = cvf::Mat4d(fractureXf.getInverted());
|
||||
cvf::Mat4d toFractureXf = fractureXf.getInverted();
|
||||
|
||||
std::vector<cvf::Vec3d> perforationLengthBoundingBoxPolygon;
|
||||
double cicleRadius = perforationLength / 2;
|
||||
|
@@ -44,7 +44,7 @@ public:
|
||||
|
||||
private:
|
||||
friend class RigWellPathStimplanIntersectorTester;
|
||||
static void calculate(const cvf::Mat4f& fractureXf,
|
||||
static void calculate(const cvf::Mat4d& fractureXf,
|
||||
const std::vector<cvf::Vec3d>& wellPathPoints,
|
||||
double wellRadius,
|
||||
double perforationLength,
|
||||
@@ -58,7 +58,7 @@ private:
|
||||
class RigWellPathStimplanIntersectorTester
|
||||
{
|
||||
public:
|
||||
static void testCalculate(const cvf::Mat4f& fractureXf,
|
||||
static void testCalculate(const cvf::Mat4d& fractureXf,
|
||||
const std::vector<cvf::Vec3d>& wellPathPoints,
|
||||
double wellRadius,
|
||||
double perforationLength,
|
||||
|
@@ -281,7 +281,7 @@ TEST(RigWellPathStimplanIntersector, intersection)
|
||||
{
|
||||
|
||||
{
|
||||
cvf::Mat4f fractureXf = cvf::Mat4f::IDENTITY;
|
||||
cvf::Mat4d fractureXf = cvf::Mat4d::IDENTITY;
|
||||
fractureXf.setTranslation({ 50.0f, 0.0f, 0.0f });
|
||||
|
||||
//std::vector<cvf::Vec3f> fracturePolygon ={ {0.0f, 0.0f, 0.0f}, {5.0f, 10.0f, 0.0f}, {10.0f, 0.0f, 0.0f} };
|
||||
@@ -315,7 +315,7 @@ TEST(RigWellPathStimplanIntersector, intersection)
|
||||
}
|
||||
|
||||
{
|
||||
cvf::Mat4f fractureXf = cvf::Mat4f::IDENTITY;
|
||||
cvf::Mat4d fractureXf = cvf::Mat4d::IDENTITY;
|
||||
|
||||
// std::vector<cvf::Vec3f> fracturePolygon ={ {0.0f, 0.0f, 0.0f}, {5.0f, 10.0f, 0.0f}, {10.0f, 0.0f, 0.0f} };
|
||||
double perforationLength = 10;
|
||||
|
Reference in New Issue
Block a user