From 97c2ebd955719bd230fd811e450d0bcf1ef64891 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 23 Mar 2018 15:08:24 +0100 Subject: [PATCH] #2436 Intersection Fault lines are now separated and have a separate color --- .../RivHexGridIntersectionTools.cpp | 18 +++++ .../RivHexGridIntersectionTools.h | 9 ++- .../RivIntersectionGeometryGenerator.cpp | 70 +++++++++++++++---- .../RivIntersectionGeometryGenerator.h | 3 + .../Intersections/RivIntersectionPartMgr.cpp | 48 +++++++++++-- .../Intersections/RivIntersectionPartMgr.h | 2 + .../ReservoirDataModel/RigMainGrid.cpp | 2 +- 7 files changed, 133 insertions(+), 19 deletions(-) diff --git a/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.cpp b/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.cpp index 766b08442c..98bca93107 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.cpp @@ -89,6 +89,15 @@ void RivEclipseIntersectionGrid::cellCornerIndices(size_t cellIndex, size_t corn memcpy(cornerIndices, cornerIndicesSource.data(), 8); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigFault* RivEclipseIntersectionGrid::findFaultFromCellIndexAndCellFace(size_t reservoirCellIndex, + cvf::StructGridInterface::FaceType face) const +{ + return m_mainGrid->findFaultFromCellIndexAndCellFace(reservoirCellIndex, face); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -172,3 +181,12 @@ void RivFemIntersectionGrid::cellCornerIndices(size_t cellIndex, size_t cornerIn cornerIndices[7] = m_femPart->elementNodeResultIdx(elmIdx, 7); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigFault* RivFemIntersectionGrid::findFaultFromCellIndexAndCellFace(size_t reservoirCellIndex, + cvf::StructGridInterface::FaceType face) const +{ + return nullptr; +} + diff --git a/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.h b/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.h index 0cc00291d5..5d9b147e27 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.h +++ b/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.h @@ -24,11 +24,12 @@ #include "cvfBoundingBox.h" #include +#include "cvfStructGrid.h" class RigActiveCellInfo; class RigFemPart; class RigMainGrid; - +class RigFault; //-------------------------------------------------------------------------------------------------- /// Interface definition used to compute the geometry for planes intersecting a grid @@ -42,6 +43,8 @@ public: virtual bool useCell(size_t cellIndex) const = 0; virtual void cellCornerVertices(size_t cellIndex, cvf::Vec3d cellCorners[8]) const = 0; virtual void cellCornerIndices(size_t cellIndex, size_t cornerIndices[8]) const = 0; + virtual const RigFault* findFaultFromCellIndexAndCellFace(size_t reservoirCellIndex, + cvf::StructGridInterface::FaceType face) const = 0; }; //-------------------------------------------------------------------------------------------------- @@ -58,6 +61,8 @@ public: virtual bool useCell(size_t cellIndex) const; virtual void cellCornerVertices(size_t cellIndex, cvf::Vec3d cellCorners[8]) const; virtual void cellCornerIndices(size_t cellIndex, size_t cornerIndices[8]) const; + virtual const RigFault* findFaultFromCellIndexAndCellFace(size_t reservoirCellIndex, + cvf::StructGridInterface::FaceType face) const override; private: cvf::cref m_mainGrid; @@ -79,6 +84,8 @@ public: virtual bool useCell(size_t cellIndex) const; virtual void cellCornerVertices(size_t cellIndex, cvf::Vec3d cellCorners[8]) const; virtual void cellCornerIndices(size_t cellIndex, size_t cornerIndices[8]) const; + virtual const RigFault* findFaultFromCellIndexAndCellFace(size_t reservoirCellIndex, + cvf::StructGridInterface::FaceType face) const override; private: cvf::cref m_femPart; diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp index ff05996f45..e73e491060 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp @@ -71,6 +71,8 @@ RivIntersectionGeometryGenerator::RivIntersectionGeometryGenerator( RimIntersect { m_triangleVxes = new cvf::Vec3fArray; m_cellBorderLineVxes = new cvf::Vec3fArray; + m_faultCellBorderLineVxes = new cvf::Vec3fArray; + if (m_isFlattened) m_extrusionDirection = -cvf::Vec3d::Z_AXIS; } @@ -152,6 +154,7 @@ void RivIntersectionGeometryGenerator::calculateArrays() m_extrusionDirection.normalize(); std::vector triangleVertices; std::vector cellBorderLineVxes; + std::vector faultCellBorderLineVxes; cvf::Vec3d displayOffset = m_hexGrid->displayOffset(); cvf::BoundingBox gridBBox = m_hexGrid->boundingBox(); @@ -315,21 +318,46 @@ void RivIntersectionGeometryGenerator::calculateArrays() // Accumulate mesh lines #define isFace( faceEnum ) (0 <= faceEnum && faceEnum <= 5 ) + using FaceType = cvf::StructGridInterface::FaceType; - if ( isFace( cellFaceForEachClippedTriangleEdge[triVxIdx]) ) + if ( isFace(cellFaceForEachClippedTriangleEdge[triVxIdx]) ) { - cellBorderLineVxes.emplace_back(p0); - cellBorderLineVxes.emplace_back(p1); + if ( m_hexGrid->findFaultFromCellIndexAndCellFace(globalCellIdx, (FaceType)cellFaceForEachClippedTriangleEdge[triVxIdx]) ) + { + faultCellBorderLineVxes.emplace_back(p0); + faultCellBorderLineVxes.emplace_back(p1); + } + else + { + cellBorderLineVxes.emplace_back(p0); + cellBorderLineVxes.emplace_back(p1); + } } - if ( isFace( cellFaceForEachClippedTriangleEdge[triVxIdx+1]) ) + if ( isFace(cellFaceForEachClippedTriangleEdge[triVxIdx+1]) ) { - cellBorderLineVxes.emplace_back(p1); - cellBorderLineVxes.emplace_back(p2); + if ( m_hexGrid->findFaultFromCellIndexAndCellFace(globalCellIdx, (FaceType)cellFaceForEachClippedTriangleEdge[triVxIdx+1]) ) + { + faultCellBorderLineVxes.emplace_back(p1); + faultCellBorderLineVxes.emplace_back(p2); + } + else + { + cellBorderLineVxes.emplace_back(p1); + cellBorderLineVxes.emplace_back(p2); + } } - if ( isFace( cellFaceForEachClippedTriangleEdge[triVxIdx+2]) ) + if ( isFace(cellFaceForEachClippedTriangleEdge[triVxIdx+2]) ) { - cellBorderLineVxes.emplace_back(p2); - cellBorderLineVxes.emplace_back(p0); + if ( m_hexGrid->findFaultFromCellIndexAndCellFace(globalCellIdx, (FaceType)cellFaceForEachClippedTriangleEdge[triVxIdx+2]) ) + { + faultCellBorderLineVxes.emplace_back(p2); + faultCellBorderLineVxes.emplace_back(p0); + } + else + { + cellBorderLineVxes.emplace_back(p2); + cellBorderLineVxes.emplace_back(p0); + } } // Mapping to cell index @@ -352,9 +380,8 @@ void RivIntersectionGeometryGenerator::calculateArrays() m_triVxToCellCornerWeights.push_back( RivIntersectionVertexWeights(cvx1.clippedEdgeVx1Id, cvx1.clippedEdgeVx2Id, cvx1.normDistFromEdgeVx1, - cvx2.clippedEdgeVx1Id, cvx2.clippedEdgeVx2Id, cvx2.normDistFromEdgeVx1, - cvx.normDistFromEdgeVx1)); - + cvx2.clippedEdgeVx1Id, cvx2.clippedEdgeVx2Id, cvx2.normDistFromEdgeVx1, + cvx.normDistFromEdgeVx1)); } } } @@ -364,6 +391,7 @@ void RivIntersectionGeometryGenerator::calculateArrays() } m_triangleVxes->assign(triangleVertices); m_cellBorderLineVxes->assign(cellBorderLineVxes); + m_faultCellBorderLineVxes->assign(faultCellBorderLineVxes); } @@ -405,6 +433,24 @@ cvf::ref RivIntersectionGeometryGenerator::createMeshDrawable( } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RivIntersectionGeometryGenerator::createFaultMeshDrawable() +{ + if (!(m_faultCellBorderLineVxes.notNull() && m_faultCellBorderLineVxes->size() != 0)) return nullptr; + + cvf::ref geo = new cvf::DrawableGeo; + geo->setVertexArray(m_faultCellBorderLineVxes.p()); + + + cvf::ref prim = new cvf::PrimitiveSetDirect(cvf::PT_LINES); + prim->setIndexCount(m_faultCellBorderLineVxes->size()); + + geo->addPrimitiveSet(prim.p()); + return geo; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h index 75e2fbcaec..6bc7363ce8 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h @@ -60,6 +60,8 @@ public: // Generate geometry cvf::ref generateSurface(); cvf::ref createMeshDrawable(); + cvf::ref createFaultMeshDrawable(); + cvf::ref createLineAlongPolylineDrawable(); cvf::ref createLineAlongExtrusionLineDrawable(const std::vector& extrusionLine); cvf::ref createPointsFromPolylineDrawable(); @@ -98,6 +100,7 @@ private: // Output arrays cvf::ref m_triangleVxes; cvf::ref m_cellBorderLineVxes; + cvf::ref m_faultCellBorderLineVxes; std::vector m_triangleToCellIdxMap; std::vector m_triVxToCellCornerWeights; std::vector > m_flattenedOrOffsettedPolyLines; diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp index 5f4099e843..8968a0bf8c 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp @@ -70,6 +70,8 @@ #include "cvfTransform.h" #include +#include "RiaApplication.h" +#include "RiaPreferences.h" //-------------------------------------------------------------------------------------------------- @@ -116,16 +118,25 @@ void RivIntersectionPartMgr::applySingleColorEffect() } // Update mesh colors as well, in case of change - //RiaPreferences* prefs = RiaApplication::instance()->preferences(); - - cvf::ref eff; - caf::MeshEffectGenerator CrossSectionEffGen(cvf::Color3::WHITE);//prefs->defaultCrossSectionGridLineColors()); - eff = CrossSectionEffGen.generateCachedEffect(); + RiaPreferences* prefs = RiaApplication::instance()->preferences(); if (m_crossSectionGridLines.notNull()) { + cvf::ref eff; + caf::MeshEffectGenerator CrossSectionEffGen(prefs->defaultGridLineColors()); + eff = CrossSectionEffGen.generateCachedEffect(); + m_crossSectionGridLines->setEffect(eff.p()); } + + if (m_crossSectionFaultGridLines.notNull()) + { + cvf::ref eff; + caf::MeshEffectGenerator CrossSectionEffGen(prefs->defaultFaultGridLineColors()); + eff = CrossSectionEffGen.generateCachedEffect(); + + m_crossSectionFaultGridLines->setEffect(eff.p()); + } } //-------------------------------------------------------------------------------------------------- @@ -546,6 +557,27 @@ void RivIntersectionPartMgr::generatePartGeometry() } } + // Mesh geometry + { + cvf::ref geoMesh = m_crossSectionGenerator->createFaultMeshDrawable(); + if (geoMesh.notNull()) + { + if (useBufferObjects) + { + geoMesh->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT); + } + + cvf::ref part = new cvf::Part; + part->setName("Cross Section faultmesh"); + part->setDrawable(geoMesh.p()); + + part->updateBoundingBox(); + part->setEnableMask(meshFaultBit); + part->setPriority(RivPartPriority::PartType::FaultMeshLines); + + m_crossSectionFaultGridLines = part; + } + } createPolyLineParts(useBufferObjects); createExtrusionDirParts(useBufferObjects); @@ -796,6 +828,12 @@ void RivIntersectionPartMgr::appendMeshLinePartsToModel(cvf::ModelBasicList* mod m_crossSectionGridLines->setTransform(scaleTransform); model->addPart(m_crossSectionGridLines.p()); } + + if (m_crossSectionFaultGridLines.notNull()) + { + m_crossSectionFaultGridLines->setTransform(scaleTransform); + model->addPart(m_crossSectionFaultGridLines.p()); + } } diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h index 6537664c13..4410ec3f6b 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h @@ -121,6 +121,8 @@ private: cvf::ref m_crossSectionGenerator; cvf::ref m_crossSectionFaces; cvf::ref m_crossSectionGridLines; + cvf::ref m_crossSectionFaultGridLines; + cvf::ref m_crossSectionFacesTextureCoords; cvf::ref m_highlightLineAlongPolyline; diff --git a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp index 23a835aa7d..5853a121a4 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp @@ -474,7 +474,7 @@ bool RigMainGrid::isFaceNormalsOutwards() const //-------------------------------------------------------------------------------------------------- const RigFault* RigMainGrid::findFaultFromCellIndexAndCellFace(size_t reservoirCellIndex, cvf::StructGridInterface::FaceType face) const { - CVF_ASSERT(m_faultsPrCellAcc.notNull()); + CVF_TIGHT_ASSERT(m_faultsPrCellAcc.notNull()); if (face == cvf::StructGridInterface::NO_FACE) return nullptr;