mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Use global cell indices instead of cell ranges
This commit is contained in:
parent
d515d0342b
commit
363d624d38
@ -37,6 +37,8 @@ RivFaultGeometryGenerator::RivFaultGeometryGenerator(const cvf::StructGridInterf
|
||||
: m_grid(grid),
|
||||
m_fault(fault)
|
||||
{
|
||||
m_showNativeFaultFaces = true;
|
||||
m_showOppositeFaultFaces = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -153,44 +155,73 @@ void RivFaultGeometryGenerator::computeArrays()
|
||||
|
||||
cvf::Vec3d offset = m_grid->displayModelOffset();
|
||||
|
||||
const std::vector<RigFault::FaultFace>& faultFaces = m_fault->faultFaces();
|
||||
|
||||
for (size_t faceType = 0; faceType < 6; faceType++)
|
||||
if (m_showNativeFaultFaces)
|
||||
{
|
||||
cvf::StructGridInterface::FaceType faceEnum = cvf::StructGridInterface::FaceType(faceType);
|
||||
const std::vector<cvf::CellRange>& cellRanges = m_fault->cellRangeForFace(faceEnum);
|
||||
|
||||
for (size_t i = 0; i < cellRanges.size(); i++)
|
||||
for (size_t fIdx = 0; fIdx < faultFaces.size(); fIdx++)
|
||||
{
|
||||
const cvf::CellRange& cellRange = cellRanges[i];
|
||||
size_t cellIndex = faultFaces[fIdx].m_globalCellIndex;
|
||||
if (!(*m_cellVisibility)[cellIndex]) continue;
|
||||
|
||||
std::vector<size_t> gridCellIndices;
|
||||
computeGlobalCellIndices(cellRange, gridCellIndices);
|
||||
cvf::StructGridInterface::FaceType face = faultFaces[fIdx].m_face;
|
||||
|
||||
for (size_t gIdx = 0; gIdx < gridCellIndices.size(); gIdx++)
|
||||
cvf::Vec3d cornerVerts[8];
|
||||
m_grid->cellCornerVertices(cellIndex, cornerVerts);
|
||||
|
||||
cvf::ubyte faceConn[4];
|
||||
m_grid->cellFaceVertexIndices(face, faceConn);
|
||||
|
||||
// Critical section to avoid two threads accessing the arrays at the same time.
|
||||
#pragma omp critical
|
||||
{
|
||||
size_t cellIndex = gridCellIndices[gIdx];
|
||||
|
||||
if (!(*m_cellVisibility)[cellIndex]) continue;
|
||||
|
||||
cvf::Vec3d cornerVerts[8];
|
||||
m_grid->cellCornerVertices(cellIndex, cornerVerts);
|
||||
|
||||
cvf::ubyte faceConn[4];
|
||||
m_grid->cellFaceVertexIndices(faceEnum, faceConn);
|
||||
|
||||
// Critical section to avoid two threads accessing the arrays at the same time.
|
||||
#pragma omp critical
|
||||
int n;
|
||||
for (n = 0; n < 4; n++)
|
||||
{
|
||||
int n;
|
||||
for (n = 0; n < 4; n++)
|
||||
{
|
||||
vertices.push_back(cvf::Vec3f(cornerVerts[faceConn[n]] - offset));
|
||||
}
|
||||
|
||||
// Keep track of the source cell index per quad
|
||||
m_quadsToGridCells.push_back(cellIndex);
|
||||
m_quadsToFace.push_back(faceEnum);
|
||||
vertices.push_back(cvf::Vec3f(cornerVerts[faceConn[n]] - offset));
|
||||
}
|
||||
|
||||
// Keep track of the source cell index per quad
|
||||
m_quadsToGridCells.push_back(cellIndex);
|
||||
m_quadsToFace.push_back(face);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_showOppositeFaultFaces)
|
||||
{
|
||||
for (size_t fIdx = 0; fIdx < faultFaces.size(); fIdx++)
|
||||
{
|
||||
size_t currentCellIndex = faultFaces[fIdx].m_globalCellIndex;
|
||||
cvf::StructGridInterface::FaceType currentFace = faultFaces[fIdx].m_face;
|
||||
cvf::StructGridInterface::FaceType face = m_grid->oppositeFace(currentFace);
|
||||
|
||||
size_t i, j, k, ni, nj, nk;
|
||||
m_grid->ijkFromCellIndex(currentCellIndex, &i, &j, &k);
|
||||
m_grid->neighborIJKAtCellFace(i, j, k, currentFace, &ni, &nj, &nk);
|
||||
|
||||
size_t cellIndex = m_grid->cellIndexFromIJK(ni, nj, nk);
|
||||
|
||||
if (!(*m_cellVisibility)[cellIndex]) continue;
|
||||
|
||||
cvf::Vec3d cornerVerts[8];
|
||||
m_grid->cellCornerVertices(cellIndex, cornerVerts);
|
||||
|
||||
cvf::ubyte faceConn[4];
|
||||
m_grid->cellFaceVertexIndices(face, faceConn);
|
||||
|
||||
// Critical section to avoid two threads accessing the arrays at the same time.
|
||||
#pragma omp critical
|
||||
{
|
||||
int n;
|
||||
for (n = 0; n < 4; n++)
|
||||
{
|
||||
vertices.push_back(cvf::Vec3f(cornerVerts[faceConn[n]] - offset));
|
||||
}
|
||||
|
||||
// Keep track of the source cell index per quad
|
||||
m_quadsToGridCells.push_back(cellIndex);
|
||||
m_quadsToFace.push_back(face);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -276,34 +307,16 @@ const std::vector<cvf::StructGridInterface::FaceType>& RivFaultGeometryGenerator
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFaultGeometryGenerator::computeGlobalCellIndices(const cvf::CellRange& cellRange, std::vector<size_t>& gridCellIndices) const
|
||||
void RivFaultGeometryGenerator::setShowNativeFaultFaces(bool showNativeFaultFaces)
|
||||
{
|
||||
cvf::Vec3st min, max;
|
||||
cellRange.range(min, max);
|
||||
|
||||
for (size_t i = min.x(); i <= max.x(); i++)
|
||||
{
|
||||
if (i >= m_grid->cellCountI())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (size_t j = min.y(); j <= max.y(); j++)
|
||||
{
|
||||
if (j >= m_grid->cellCountJ())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (size_t k = min.z(); k <= max.z(); k++)
|
||||
{
|
||||
if (k >= m_grid->cellCountK())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
gridCellIndices.push_back(m_grid->cellIndexFromIJK(i, j, k));
|
||||
}
|
||||
}
|
||||
}
|
||||
m_showNativeFaultFaces = showNativeFaultFaces;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFaultGeometryGenerator::setShowOppositeFaultFaces(bool showOppositeFaultFaces)
|
||||
{
|
||||
m_showOppositeFaultFaces = showOppositeFaultFaces;
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,10 @@ public:
|
||||
~RivFaultGeometryGenerator();
|
||||
|
||||
void setCellVisibility(const cvf::UByteArray* cellVisibilities );
|
||||
|
||||
|
||||
void setShowNativeFaultFaces(bool showNativeFaultFaces);
|
||||
void setShowOppositeFaultFaces(bool showOppositeFaultFaces);
|
||||
|
||||
void textureCoordinates(cvf::Vec2fArray* textureCoords,
|
||||
const cvf::StructGridScalarDataAccess* dataAccessObject,
|
||||
const cvf::ScalarMapper* mapper) const;
|
||||
@ -65,8 +68,6 @@ public:
|
||||
private:
|
||||
static cvf::ref<cvf::UIntArray> lineIndicesFromQuadVertexArray(const cvf::Vec3fArray* vertexArray);
|
||||
|
||||
void computeGlobalCellIndices(const cvf::CellRange& cellRange, std::vector<size_t>& gridCellIndices) const;
|
||||
|
||||
void computeArrays();
|
||||
|
||||
private:
|
||||
@ -74,6 +75,9 @@ private:
|
||||
cvf::cref<cvf::StructGridInterface> m_grid;
|
||||
cvf::cref<RigFault> m_fault;
|
||||
cvf::cref<cvf::UByteArray> m_cellVisibility;
|
||||
|
||||
bool m_showNativeFaultFaces;
|
||||
bool m_showOppositeFaultFaces;
|
||||
|
||||
// Created arrays
|
||||
cvf::ref<cvf::Vec3fArray> m_vertices;
|
||||
|
@ -49,8 +49,6 @@ public:
|
||||
|
||||
void setCellVisibility(cvf::UByteArray* cellVisibilities);
|
||||
|
||||
void updatePartEffect();
|
||||
|
||||
void updateCellColor(cvf::Color4f color);
|
||||
void updateCellResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot);
|
||||
void updateCellEdgeResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot, RimCellEdgeResultSlot* cellEdgeResultSlot);
|
||||
@ -59,6 +57,7 @@ public:
|
||||
|
||||
private:
|
||||
void generatePartGeometry();
|
||||
void updatePartEffect();
|
||||
|
||||
private:
|
||||
cvf::cref<RigGridBase> m_grid;
|
||||
|
Loading…
Reference in New Issue
Block a user