Cleaned up fault viz config

This commit is contained in:
Magne Sjaastad 2013-12-09 21:13:02 +01:00
parent 1f210e36c1
commit 98b9bdac03
8 changed files with 124 additions and 224 deletions

View File

@ -33,13 +33,11 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivFaultGeometryGenerator::RivFaultGeometryGenerator(const cvf::StructGridInterface* grid, const RigFault* fault)
RivFaultGeometryGenerator::RivFaultGeometryGenerator(const cvf::StructGridInterface* grid, const RigFault* fault, bool computeNativeFaultFaces)
: m_grid(grid),
m_fault(fault)
m_fault(fault),
m_computeNativeFaultFaces(computeNativeFaultFaces)
{
m_showNativeFaultFaces = true;
m_showOppositeFaultFaces = true;
m_limitFaultsToFilters = true;
}
//--------------------------------------------------------------------------------------------------
@ -158,81 +156,38 @@ void RivFaultGeometryGenerator::computeArrays()
const std::vector<RigFault::FaultFace>& faultFaces = m_fault->faultFaces();
if (m_showNativeFaultFaces)
{
#pragma omp parallel for
for (int fIdx = 0; fIdx < faultFaces.size(); fIdx++)
for (int fIdx = 0; fIdx < faultFaces.size(); fIdx++)
{
size_t cellIndex = faultFaces[fIdx].m_nativeGlobalCellIndex;
cvf::StructGridInterface::FaceType face = faultFaces[fIdx].m_nativeFace;
if (!m_computeNativeFaultFaces)
{
size_t cellIndex = faultFaces[fIdx].m_nativeGlobalCellIndex;
if (m_limitFaultsToFilters)
{
if (!(*m_cellVisibility)[cellIndex]) continue;
}
cvf::StructGridInterface::FaceType face = faultFaces[fIdx].m_nativeFace;
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);
}
cellIndex = faultFaces[fIdx].m_oppositeGlobalCellIndex;
face = faultFaces[fIdx].m_oppositeFace;
}
}
if (m_showOppositeFaultFaces)
{
#pragma omp parallel for
for (int fIdx = 0; fIdx < faultFaces.size(); fIdx++)
{
size_t cellIndex = faultFaces[fIdx].m_oppositeGlobalCellIndex;
cvf::StructGridInterface::FaceType face = faultFaces[fIdx].m_oppositeFace;
if (!(*m_cellVisibility)[cellIndex]) continue;
/*
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);
cvf::Vec3d cornerVerts[8];
m_grid->cellCornerVertices(cellIndex, cornerVerts);
size_t cellIndex = m_grid->cellIndexFromIJK(ni, nj, nk);
*/
if (m_limitFaultsToFilters)
{
if (!(*m_cellVisibility)[cellIndex]) continue;
}
cvf::ubyte faceConn[4];
m_grid->cellFaceVertexIndices(face, faceConn);
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.
// 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(face);
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);
}
}
@ -314,27 +269,3 @@ const std::vector<cvf::StructGridInterface::FaceType>& RivFaultGeometryGenerator
return m_quadsToFace;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultGeometryGenerator::setShowNativeFaultFaces(bool showNativeFaultFaces)
{
m_showNativeFaultFaces = showNativeFaultFaces;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultGeometryGenerator::setShowOppositeFaultFaces(bool showOppositeFaultFaces)
{
m_showOppositeFaultFaces = showOppositeFaultFaces;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultGeometryGenerator::setLimitFaultsToFilter(bool limitFaultsToFilter)
{
// m_limitFaultsToFilters = limitFaultsToFilter;
}

View File

@ -42,15 +42,11 @@ class RigFault;
class RivFaultGeometryGenerator : public cvf::Object
{
public:
RivFaultGeometryGenerator(const cvf::StructGridInterface* grid, const RigFault* fault);
RivFaultGeometryGenerator(const cvf::StructGridInterface* grid, const RigFault* fault, bool computeNativeFaultFaces);
~RivFaultGeometryGenerator();
void setCellVisibility(const cvf::UByteArray* cellVisibilities );
void setShowNativeFaultFaces(bool showNativeFaultFaces);
void setShowOppositeFaultFaces(bool showOppositeFaultFaces);
void setLimitFaultsToFilter(bool limitFaultsToFilter);
void textureCoordinates(cvf::Vec2fArray* textureCoords,
const cvf::StructGridScalarDataAccess* dataAccessObject,
const cvf::ScalarMapper* mapper) const;
@ -77,9 +73,7 @@ private:
cvf::cref<RigFault> m_fault;
cvf::cref<cvf::UByteArray> m_cellVisibility;
bool m_showNativeFaultFaces;
bool m_showOppositeFaultFaces;
bool m_limitFaultsToFilters;
bool m_computeNativeFaultFaces;
// Created arrays
cvf::ref<cvf::Vec3fArray> m_vertices;

View File

@ -57,20 +57,11 @@ RivFaultPartMgr::RivFaultPartMgr(const RigGridBase* grid, const RimFault* rimFau
m_rimFault(rimFault),
m_opacityLevel(1.0f),
m_defaultColor(cvf::Color3::WHITE),
m_nativeFaultGenerator(grid, rimFault->faultGeometry()),
m_oppositeFaultGenerator(grid, rimFault->faultGeometry())
m_nativeFaultGenerator(grid, rimFault->faultGeometry(), true),
m_oppositeFaultGenerator(grid, rimFault->faultGeometry(), false)
{
m_nativeFaultFacesTextureCoords = new cvf::Vec2fArray;
m_nativeFaultGenerator.setShowNativeFaultFaces(true);
m_nativeFaultGenerator.setShowOppositeFaultFaces(false);
m_oppositeFaultFacesTextureCoords = new cvf::Vec2fArray;
m_oppositeFaultGenerator.setShowNativeFaultFaces(false);
m_oppositeFaultGenerator.setShowOppositeFaultFaces(true);
m_showNativeFaces = true;
m_showOppositeFaces = true;
m_showLabel = true;
}
//--------------------------------------------------------------------------------------------------
@ -87,46 +78,23 @@ void RivFaultPartMgr::setCellVisibility(cvf::UByteArray* cellVisibilities)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::updateCellColor(cvf::Color4f color)
void RivFaultPartMgr::applySingleColorEffect()
{
m_defaultColor = color;
m_defaultColor = m_rimFault->faultColor();
// Set default effect
caf::SurfaceEffectGenerator geometryEffgen(m_defaultColor, true);
cvf::ref<cvf::Effect> geometryOnlyEffect = geometryEffgen.generateEffect();
updatePartEffect();
}
if (m_nativeFaultFaces.notNull()) m_nativeFaultFaces->setEffect(geometryOnlyEffect.p());
if (m_oppositeFaultFaces.notNull()) m_oppositeFaultFaces->setEffect(geometryOnlyEffect.p());
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::setShowNativeFaces(bool showNativeFaces)
{
m_showNativeFaces = showNativeFaces;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::setShowOppositeFaces(bool showOppositeFaces)
{
m_showOppositeFaces = showOppositeFaces;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::setShowLabel(bool showLabel)
{
m_showLabel = showLabel;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::setLimitFaultToVisibleCells(bool limitFaultToVisibleCells)
{
m_nativeFaultGenerator.setLimitFaultsToFilter(limitFaultToVisibleCells);
m_oppositeFaultGenerator.setLimitFaultsToFilter(limitFaultToVisibleCells);
// generatePartGeometry();
if (m_opacityLevel < 1.0f)
{
// Set priority to make sure this transparent geometry are rendered last
if (m_nativeFaultFaces.notNull()) m_nativeFaultFaces->setPriority(100);
if (m_oppositeFaultFaces.notNull()) m_oppositeFaultFaces->setPriority(100);
}
}
//--------------------------------------------------------------------------------------------------
@ -264,37 +232,6 @@ void RivFaultPartMgr::updateCellEdgeResultColor(size_t timeStepIndex, RimResultS
*/
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::appendPartsToModel(cvf::ModelBasicList* model)
{
CVF_ASSERT(model != NULL);
if (!m_rimFault) return;
if (!m_rimFault->showFault()) return;
if (m_showNativeFaces && m_nativeFaultFaces.notNull())
{
model->addPart(m_nativeFaultFaces.p());
}
if (m_showOppositeFaces && m_oppositeFaultFaces.notNull())
{
model->addPart(m_oppositeFaultFaces.p());
}
// Always show grid lines for both native and opposite fault faces
if (m_nativeFaultGridLines.notNull()) model->addPart(m_nativeFaultGridLines.p());
if (m_oppositeFaultGridLines.notNull()) model->addPart(m_oppositeFaultGridLines.p());
if (m_showLabel)
{
if (m_faultLabelPart.notNull()) model->addPart(m_faultLabelPart.p());
if (m_faultLabelLinePart.notNull()) model->addPart(m_faultLabelLinePart.p());
}
}
//--------------------------------------------------------------------------------------------------
///
@ -400,7 +337,7 @@ void RivFaultPartMgr::generatePartGeometry()
}
m_faultLabelPart = NULL;
if (m_rimFault->showFaultLabel())
{
cvf::ref<cvf::Part> partToAttachLabelTo;
if (m_nativeFaultFaces.notNull())
@ -427,14 +364,7 @@ void RivFaultPartMgr::generatePartGeometry()
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::updatePartEffect()
{
cvf::Color3f partColor = m_defaultColor.toColor3f();
if (m_rimFault->showFaultColor())
{
partColor = m_rimFault->faultColor();
}
m_opacityLevel = m_defaultColor.a();
cvf::Color3f partColor = m_defaultColor;
// Set default effect
caf::SurfaceEffectGenerator geometryEffgen(partColor, true);
@ -443,21 +373,11 @@ void RivFaultPartMgr::updatePartEffect()
if (m_nativeFaultFaces.notNull())
{
m_nativeFaultFaces->setEffect(geometryOnlyEffect.p());
if (m_defaultColor.a() < 1.0f)
{
// Set priority to make sure this transparent geometry are rendered last
m_nativeFaultFaces->setPriority(100);
}
}
if (m_oppositeFaultFaces.notNull())
{
m_oppositeFaultFaces->setEffect(geometryOnlyEffect.p());
if (m_defaultColor.a() < 1.0f)
{
// Set priority to make sure this transparent geometry are rendered last
m_oppositeFaultFaces->setPriority(100);
}
}
@ -511,7 +431,10 @@ void RivFaultPartMgr::createLabelWithAnchorLine(const cvf::Part* part)
drawableText->setDrawBorder(false);
drawableText->setDrawBackground(false);
drawableText->setVerticalAlignment(cvf::TextDrawer::CENTER);
drawableText->setTextColor(m_rimFault->faultColor());
cvf::Color3f defWellLabelColor = RiaApplication::instance()->preferences()->defaultWellLabelColor();
drawableText->setTextColor(defWellLabelColor);
cvf::String cvfString = cvfqt::Utils::toString(m_rimFault->name());
@ -596,3 +519,43 @@ cvf::Vec3f RivFaultPartMgr::findClosestVertex(const cvf::Vec3f& point, const cvf
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::appendNativeFaultFacesToModel(cvf::ModelBasicList* model)
{
if (m_nativeFaultFaces.notNull())
{
model->addPart(m_nativeFaultFaces.p());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::appendOppositeFaultFacesToModel(cvf::ModelBasicList* model)
{
if (m_oppositeFaultFaces.notNull())
{
model->addPart(m_oppositeFaultFaces.p());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::appendLabelPartsToModel(cvf::ModelBasicList* model)
{
if (m_faultLabelPart.notNull()) model->addPart(m_faultLabelPart.p());
if (m_faultLabelLinePart.notNull()) model->addPart(m_faultLabelLinePart.p());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFaultPartMgr::appendMeshLinePartsToModel(cvf::ModelBasicList* model)
{
if (m_nativeFaultGridLines.notNull()) model->addPart(m_nativeFaultGridLines.p());
if (m_oppositeFaultGridLines.notNull()) model->addPart(m_oppositeFaultGridLines.p());
}

View File

@ -49,17 +49,14 @@ public:
void setCellVisibility(cvf::UByteArray* cellVisibilities);
void updateCellColor(cvf::Color4f color);
void applySingleColorEffect();
void updateCellResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot);
void updateCellEdgeResultColor(size_t timeStepIndex, RimResultSlot* cellResultSlot, RimCellEdgeResultSlot* cellEdgeResultSlot);
// TODO: Remove all
void setShowNativeFaces(bool showNativeFaces);
void setShowOppositeFaces(bool showOppositeFaces);
void setShowLabel(bool showLabel);
void setLimitFaultToVisibleCells(bool limitFaultToVisibleCells);
void appendPartsToModel(cvf::ModelBasicList* model);
void appendNativeFaultFacesToModel(cvf::ModelBasicList* model);
void appendOppositeFaultFacesToModel(cvf::ModelBasicList* model);
void appendLabelPartsToModel(cvf::ModelBasicList* model);
void appendMeshLinePartsToModel(cvf::ModelBasicList* model);
private:
void generatePartGeometry();
@ -74,7 +71,7 @@ private:
const RimFault* m_rimFault;
float m_opacityLevel;
cvf::Color4f m_defaultColor;
cvf::Color3f m_defaultColor;
bool m_showNativeFaces;
bool m_showOppositeFaces;

View File

@ -102,14 +102,27 @@ void RivReservoirFaultsPartMgr::appendPartsToModel(cvf::ModelBasicList* model)
if (rimFault->showFault())
{
cvf::ref<RivFaultPartMgr> rivFaultPart = m_faultParts[i];
CVF_ASSERT(rivFaultPart.notNull());
// Propagate settings from RimFaultCollection to RivFaultPart
rivFaultPart->setShowNativeFaces(m_faultCollection->showFaultFaces());
rivFaultPart->setShowOppositeFaces(m_faultCollection->showOppositeFaultFaces());
rivFaultPart->setShowLabel(m_faultCollection->showFaultLabel());
rivFaultPart->setLimitFaultToVisibleCells(m_faultCollection->limitFaultsToFilter());
if (m_faultCollection->showFaultFaces())
{
rivFaultPart->appendNativeFaultFacesToModel(&parts);
}
rivFaultPart->appendPartsToModel(&parts);
if (m_faultCollection->showOppositeFaultFaces())
{
rivFaultPart->appendOppositeFaultFacesToModel(&parts);
}
if (m_faultCollection->showFaultLabel())
{
rivFaultPart->appendLabelPartsToModel(&parts);
}
if (m_faultCollection->showFaultFaces() || m_faultCollection->showOppositeFaultFaces())
{
rivFaultPart->appendMeshLinePartsToModel(&parts);
}
}
}
@ -127,9 +140,13 @@ void RivReservoirFaultsPartMgr::appendPartsToModel(cvf::ModelBasicList* model)
//--------------------------------------------------------------------------------------------------
void RivReservoirFaultsPartMgr::updateCellColor(cvf::Color4f color)
{
CVF_UNUSED(color);
// NB color is not used, as the color is defined per fault
for (size_t i = 0; i < m_faultParts.size(); i++)
{
m_faultParts[i]->updateCellColor(color);
m_faultParts[i]->applySingleColorEffect();
}
}

View File

@ -96,6 +96,11 @@ void RivReservoirPartMgr::updateCellColor(cvf::Color4f color)
{
m_allGrids[i]->updateCellColor(color);
}
if (m_faultsPartMgr.notNull())
{
m_faultsPartMgr->updateCellColor(color);
}
}
//--------------------------------------------------------------------------------------------------

View File

@ -44,12 +44,8 @@ RimFault::RimFault()
CAF_PDM_InitField(&showFault, "ShowFault", true, "Show fault", "", "", "");
showFault.setUiHidden(true);
CAF_PDM_InitField(&showFaultLabel, "ShowFaultLabel", true, "Show fault label", "", "", "");
CAF_PDM_InitField(&showFaultColor, "ShowFaultColor", true, "Show fault color", "", "", "");
CAF_PDM_InitField(&faultColor, "Color", cvf::Color3f(0.588f, 0.588f, 0.804f), "Fault color", "", "", "");
m_rigFault = NULL;
}

View File

@ -51,12 +51,9 @@ public:
caf::PdmField<bool> showFault;
caf::PdmField<QString> name;
caf::PdmField<bool> showFaultLabel;
caf::PdmField<bool> showFaultColor;
caf::PdmField<cvf::Color3f> faultColor;
private:
const RigFault* m_rigFault;
};