#7909 Surface Extraction : Updates based on review

This commit is contained in:
Magne Sjaastad
2021-08-30 10:46:15 +02:00
parent 5c564c152a
commit 264e1decdc
4 changed files with 69 additions and 71 deletions

View File

@@ -300,7 +300,7 @@ void RimGridCaseSurface::extractGridDataUsingFourVerticesPerCell()
size_t zeroBasedLayerIndex = static_cast<size_t>( m_oneBasedSliceIndex ) - 1;
cvf::StructGridInterface::FaceType faceType = cvf::StructGridInterface::NEG_K;
cvf::StructGridInterface::FaceType extractionFace = cvf::StructGridInterface::NEG_K;
std::vector<unsigned> triangleIndices;
std::vector<cvf::Vec3d> vertices;
@@ -320,7 +320,7 @@ void RimGridCaseSurface::extractGridDataUsingFourVerticesPerCell()
{
cvf::ubyte currentFaceConn[4];
grid->cellCornerVertices( currentCellIndex, currentCornerVerts );
grid->cellFaceVertexIndices( faceType, currentFaceConn );
grid->cellFaceVertexIndices( extractionFace, currentFaceConn );
auto currentCellStartIndex = static_cast<unsigned>( vertices.size() );
@@ -340,71 +340,21 @@ void RimGridCaseSurface::extractGridDataUsingFourVerticesPerCell()
if ( m_watertight() )
{
if ( grid->findFaultFromCellIndexAndCellFace( currentCellIndex, cvf::StructGridInterface::POS_I ) )
{
auto nextCell = grid->cell( currentCellIndex ).neighborCell( cvf::StructGridInterface::POS_I );
if ( !nextCell.isInvalid() )
{
size_t nextCellIndex = nextCell.mainGridCellIndex();
cvf::Vec3d nextCellCornerVerts[8];
grid->cellCornerVertices( nextCellIndex, nextCellCornerVerts );
addGeometryForFaultFaces( grid,
currentCellIndex,
extractionFace,
cvf::StructGridInterface::POS_I,
currentCornerVerts,
vertices,
triangleIndices );
auto startIndex = static_cast<unsigned>( vertices.size() );
{
auto edgeVertexIndices =
grid->edgeVertexIndices( faceType, cvf::StructGridInterface::POS_I );
vertices.push_back( currentCornerVerts[edgeVertexIndices.first] );
vertices.push_back( currentCornerVerts[edgeVertexIndices.second] );
}
{
auto edgeVertexIndices =
grid->edgeVertexIndices( faceType, cvf::StructGridInterface::NEG_I );
vertices.push_back( nextCellCornerVerts[edgeVertexIndices.first] );
vertices.push_back( nextCellCornerVerts[edgeVertexIndices.second] );
}
triangleIndices.push_back( startIndex );
triangleIndices.push_back( startIndex + 1 );
triangleIndices.push_back( startIndex + 2 );
triangleIndices.push_back( startIndex );
triangleIndices.push_back( startIndex + 2 );
triangleIndices.push_back( startIndex + 3 );
}
}
if ( grid->findFaultFromCellIndexAndCellFace( currentCellIndex, cvf::StructGridInterface::POS_J ) )
{
auto nextCell = grid->cell( currentCellIndex ).neighborCell( cvf::StructGridInterface::POS_J );
if ( !nextCell.isInvalid() )
{
size_t nextCellIndex = nextCell.mainGridCellIndex();
cvf::Vec3d nextCellCornerVerts[8];
grid->cellCornerVertices( nextCellIndex, nextCellCornerVerts );
auto startIndex = static_cast<unsigned>( vertices.size() );
{
auto edgeVertexIndices =
grid->edgeVertexIndices( faceType, cvf::StructGridInterface::POS_J );
vertices.push_back( currentCornerVerts[edgeVertexIndices.first] );
vertices.push_back( currentCornerVerts[edgeVertexIndices.second] );
}
{
auto edgeVertexIndices =
grid->edgeVertexIndices( faceType, cvf::StructGridInterface::NEG_J );
vertices.push_back( nextCellCornerVerts[edgeVertexIndices.first] );
vertices.push_back( nextCellCornerVerts[edgeVertexIndices.second] );
}
triangleIndices.push_back( startIndex );
triangleIndices.push_back( startIndex + 1 );
triangleIndices.push_back( startIndex + 2 );
triangleIndices.push_back( startIndex );
triangleIndices.push_back( startIndex + 2 );
triangleIndices.push_back( startIndex + 3 );
}
}
addGeometryForFaultFaces( grid,
currentCellIndex,
extractionFace,
cvf::StructGridInterface::POS_J,
currentCornerVerts,
vertices,
triangleIndices );
}
}
}
@@ -414,6 +364,50 @@ void RimGridCaseSurface::extractGridDataUsingFourVerticesPerCell()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGridCaseSurface::addGeometryForFaultFaces( const RigMainGrid* grid,
size_t currentCellIndex,
cvf::StructGridInterface::FaceType extractionFace,
cvf::StructGridInterface::FaceType faultFace,
cvf::Vec3d* currentCornerVerts,
std::vector<cvf::Vec3d>& vertices,
std::vector<unsigned>& triangleIndices )
{
if ( grid->findFaultFromCellIndexAndCellFace( currentCellIndex, faultFace ) )
{
auto nextCell = grid->cell( currentCellIndex ).neighborCell( faultFace );
if ( !nextCell.isInvalid() )
{
size_t nextCellIndex = nextCell.mainGridCellIndex();
cvf::Vec3d nextCellCornerVerts[8];
grid->cellCornerVertices( nextCellIndex, nextCellCornerVerts );
auto startIndex = static_cast<unsigned>( vertices.size() );
{
auto edgeVertexIndices = grid->edgeVertexIndices( extractionFace, faultFace );
vertices.push_back( currentCornerVerts[edgeVertexIndices.first] );
vertices.push_back( currentCornerVerts[edgeVertexIndices.second] );
}
{
auto oppositeFaultFace = cvf::StructGridInterface::oppositeFace( faultFace );
auto edgeVertexIndices = grid->edgeVertexIndices( extractionFace, oppositeFaultFace );
vertices.push_back( nextCellCornerVerts[edgeVertexIndices.first] );
vertices.push_back( nextCellCornerVerts[edgeVertexIndices.second] );
}
triangleIndices.push_back( startIndex );
triangleIndices.push_back( startIndex + 1 );
triangleIndices.push_back( startIndex + 2 );
triangleIndices.push_back( startIndex );
triangleIndices.push_back( startIndex + 2 );
triangleIndices.push_back( startIndex + 3 );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -65,6 +65,14 @@ private:
// Extract 4 vertices per grid cell
void extractGridDataUsingFourVerticesPerCell();
void addGeometryForFaultFaces( const RigMainGrid* grid,
size_t currentCellIndex,
cvf::StructGridInterface::FaceType extractionFace,
cvf::StructGridInterface::FaceType faultFace,
cvf::Vec3d* currentCornerVerts,
std::vector<cvf::Vec3d>& vertices,
std::vector<unsigned>& triangleIndices );
// This method will populate m_structGridIndices used when exporting to PTL file format
// Fault geometry will be smoothed using this method
void extractStructuredSurfaceFromGridData();

View File

@@ -1,7 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS
// Copyright (C) 2021- Equinor 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

View File

@@ -158,11 +158,8 @@ void StructGridInterface::cellFaceVertexIndices( FaceType face, cvf::ubyte verte
//--------------------------------------------------------------------------------------------------
std::pair<ubyte, ubyte> StructGridInterface::edgeVertexIndices( FaceType face1, FaceType face2 )
{
//
// Return the two shared vertex indices between two faces
// Asserts if the two faces do not have any shared vertices
// The ordering is identical to the ordering in StructGridInterface::cellFaceVertexIndices
//
// Ensure face1 has the largest enum value
if ( face2 > face1 ) std::swap( face1, face2 );