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_grid(grid),
|
||||||
m_fault(fault)
|
m_fault(fault)
|
||||||
{
|
{
|
||||||
|
m_showNativeFaultFaces = true;
|
||||||
|
m_showOppositeFaultFaces = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -153,30 +155,22 @@ void RivFaultGeometryGenerator::computeArrays()
|
|||||||
|
|
||||||
cvf::Vec3d offset = m_grid->displayModelOffset();
|
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);
|
for (size_t fIdx = 0; fIdx < faultFaces.size(); fIdx++)
|
||||||
const std::vector<cvf::CellRange>& cellRanges = m_fault->cellRangeForFace(faceEnum);
|
|
||||||
|
|
||||||
for (size_t i = 0; i < cellRanges.size(); i++)
|
|
||||||
{
|
{
|
||||||
const cvf::CellRange& cellRange = cellRanges[i];
|
size_t cellIndex = faultFaces[fIdx].m_globalCellIndex;
|
||||||
|
|
||||||
std::vector<size_t> gridCellIndices;
|
|
||||||
computeGlobalCellIndices(cellRange, gridCellIndices);
|
|
||||||
|
|
||||||
for (size_t gIdx = 0; gIdx < gridCellIndices.size(); gIdx++)
|
|
||||||
{
|
|
||||||
size_t cellIndex = gridCellIndices[gIdx];
|
|
||||||
|
|
||||||
if (!(*m_cellVisibility)[cellIndex]) continue;
|
if (!(*m_cellVisibility)[cellIndex]) continue;
|
||||||
|
|
||||||
|
cvf::StructGridInterface::FaceType face = faultFaces[fIdx].m_face;
|
||||||
|
|
||||||
cvf::Vec3d cornerVerts[8];
|
cvf::Vec3d cornerVerts[8];
|
||||||
m_grid->cellCornerVertices(cellIndex, cornerVerts);
|
m_grid->cellCornerVertices(cellIndex, cornerVerts);
|
||||||
|
|
||||||
cvf::ubyte faceConn[4];
|
cvf::ubyte faceConn[4];
|
||||||
m_grid->cellFaceVertexIndices(faceEnum, faceConn);
|
m_grid->cellFaceVertexIndices(face, faceConn);
|
||||||
|
|
||||||
// Critical section to avoid two threads accessing the arrays at the same time.
|
// Critical section to avoid two threads accessing the arrays at the same time.
|
||||||
#pragma omp critical
|
#pragma omp critical
|
||||||
@ -189,10 +183,47 @@ void RivFaultGeometryGenerator::computeArrays()
|
|||||||
|
|
||||||
// Keep track of the source cell index per quad
|
// Keep track of the source cell index per quad
|
||||||
m_quadsToGridCells.push_back(cellIndex);
|
m_quadsToGridCells.push_back(cellIndex);
|
||||||
m_quadsToFace.push_back(faceEnum);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_vertices = new cvf::Vec3fArray;
|
m_vertices = new cvf::Vec3fArray;
|
||||||
@ -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;
|
m_showNativeFaultFaces = showNativeFaultFaces;
|
||||||
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++)
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RivFaultGeometryGenerator::setShowOppositeFaultFaces(bool showOppositeFaultFaces)
|
||||||
{
|
{
|
||||||
if (j >= m_grid->cellCountJ())
|
m_showOppositeFaultFaces = showOppositeFaultFaces;
|
||||||
{
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +47,9 @@ public:
|
|||||||
|
|
||||||
void setCellVisibility(const cvf::UByteArray* cellVisibilities );
|
void setCellVisibility(const cvf::UByteArray* cellVisibilities );
|
||||||
|
|
||||||
|
void setShowNativeFaultFaces(bool showNativeFaultFaces);
|
||||||
|
void setShowOppositeFaultFaces(bool showOppositeFaultFaces);
|
||||||
|
|
||||||
void textureCoordinates(cvf::Vec2fArray* textureCoords,
|
void textureCoordinates(cvf::Vec2fArray* textureCoords,
|
||||||
const cvf::StructGridScalarDataAccess* dataAccessObject,
|
const cvf::StructGridScalarDataAccess* dataAccessObject,
|
||||||
const cvf::ScalarMapper* mapper) const;
|
const cvf::ScalarMapper* mapper) const;
|
||||||
@ -65,8 +68,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
static cvf::ref<cvf::UIntArray> lineIndicesFromQuadVertexArray(const cvf::Vec3fArray* vertexArray);
|
static cvf::ref<cvf::UIntArray> lineIndicesFromQuadVertexArray(const cvf::Vec3fArray* vertexArray);
|
||||||
|
|
||||||
void computeGlobalCellIndices(const cvf::CellRange& cellRange, std::vector<size_t>& gridCellIndices) const;
|
|
||||||
|
|
||||||
void computeArrays();
|
void computeArrays();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -75,6 +76,9 @@ private:
|
|||||||
cvf::cref<RigFault> m_fault;
|
cvf::cref<RigFault> m_fault;
|
||||||
cvf::cref<cvf::UByteArray> m_cellVisibility;
|
cvf::cref<cvf::UByteArray> m_cellVisibility;
|
||||||
|
|
||||||
|
bool m_showNativeFaultFaces;
|
||||||
|
bool m_showOppositeFaultFaces;
|
||||||
|
|
||||||
// Created arrays
|
// Created arrays
|
||||||
cvf::ref<cvf::Vec3fArray> m_vertices;
|
cvf::ref<cvf::Vec3fArray> m_vertices;
|
||||||
|
|
||||||
|
@ -49,8 +49,6 @@ public:
|
|||||||
|
|
||||||
void setCellVisibility(cvf::UByteArray* cellVisibilities);
|
void setCellVisibility(cvf::UByteArray* cellVisibilities);
|
||||||
|
|
||||||
void updatePartEffect();
|
|
||||||
|
|
||||||
void updateCellColor(cvf::Color4f color);
|
void updateCellColor(cvf::Color4f color);
|
||||||
void updateCellResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot);
|
void updateCellResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot);
|
||||||
void updateCellEdgeResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot, RimCellEdgeResultSlot* cellEdgeResultSlot);
|
void updateCellEdgeResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot, RimCellEdgeResultSlot* cellEdgeResultSlot);
|
||||||
@ -59,6 +57,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void generatePartGeometry();
|
void generatePartGeometry();
|
||||||
|
void updatePartEffect();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
cvf::cref<RigGridBase> m_grid;
|
cvf::cref<RigGridBase> m_grid;
|
||||||
|
Loading…
Reference in New Issue
Block a user