Noderesults are now read and displayed

The legend is not updated etc, but this is a start
This commit is contained in:
Jacob Støren
2015-05-04 18:16:57 +02:00
parent 6ff5f406d5
commit 20a8527607
6 changed files with 98 additions and 25 deletions

View File

@@ -42,6 +42,8 @@ public:
cvf::ref<cvf::DrawableGeo> createMeshDrawable();
cvf::ref<cvf::DrawableGeo> createOutlineMeshDrawable(double creaseAngle);
const std::vector<size_t>& quadVerticesToNodeIdxMapping() const { return m_quadVerticesToNodeIdx;}
private:
static cvf::ref<cvf::UIntArray>
lineIndicesFromQuadVertexArray(const cvf::Vec3fArray* vertexArray);

View File

@@ -23,6 +23,8 @@
#include "RiaPreferences.h"
#include "RimReservoirView.h"
#include "RimGeoMechResultSlot.h"
#include "RimLegendConfig.h"
#include "RivResultToTextureMapper.h"
#include "RivScalarMapperUtils.h"
@@ -44,6 +46,7 @@
#include "cvfShaderSourceRepository.h"
#include "cvfStructGrid.h"
#include "cvfUniform.h"
#include "RifGeoMechReaderInterface.h"
//--------------------------------------------------------------------------------------------------
@@ -212,26 +215,39 @@ void RivFemPartPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechRe
cvf::ref<cvf::Color3ubArray> surfaceFacesColorArray;
// Outer surface
if (m_surfaceFaces.notNull())
{
#if 0
{
RivTextureCoordsCreator texturer(cellResultSlot,
timeStepIndex,
m_grid->gridIndex(),
m_surfaceGenerator.quadToCellFaceMapper());
if (!texturer.isValid())
{
return;
}
if (m_surfaceFaces.notNull())
{
texturer.createTextureCoords(m_surfaceFacesTextureCoords.p());
const cvf::ScalarMapper* mapper = cellResultSlot->legendConfig()->scalarMapper();
RifGeoMechReaderInterface* reader = cellResultSlot->resultReaderInterface();
std::vector<float> resultValues;
reader->readScalarNodeField(cellResultSlot->resultFieldName().toStdString(),
cellResultSlot->resultComponentName().toStdString(),
m_gridIdx, 0, timeStepIndex, &resultValues);
const cvf::ScalarMapper* mapper = cellResultSlot->legendConfig()->scalarMapper();
RivScalarMapperUtils::applyTextureResultsToPart(m_surfaceFaces.p(), m_surfaceFacesTextureCoords.p(), mapper, m_opacityLevel, caf::FC_NONE);
}
#endif
}
const std::vector<size_t>& vxToResultMapping = m_surfaceGenerator.quadVerticesToNodeIdxMapping();
m_surfaceFacesTextureCoords->resize(vxToResultMapping.size());
cvf::Vec2f* rawPtr = m_surfaceFacesTextureCoords->ptr();
#pragma omp parallel for schedule(dynamic)
for (int vxIdx = 0; vxIdx < vxToResultMapping.size(); ++vxIdx)
{
float resultValue = resultValues[vxToResultMapping[vxIdx]];
if (resultValue == HUGE_VAL || resultValue != resultValue) // a != a is true for NAN's
{
rawPtr[vxIdx][1] = 1.0f;
}
else
{
rawPtr[vxIdx] = mapper->mapToTextureCoord(resultValue);
}
}
RivScalarMapperUtils::applyTextureResultsToPart(m_surfaceFaces.p(), m_surfaceFacesTextureCoords.p(), mapper, m_opacityLevel, caf::FC_NONE);
}
}

View File

@@ -259,4 +259,6 @@ RifGeoMechReaderInterface* RimGeoMechResultSlot::resultReaderInterface()
}
}
return NULL;
}

View File

@@ -26,6 +26,7 @@
class RimLegendConfig;
class RimGeoMechView;
class RifGeoMechReaderInterface;
//==================================================================================================
///
@@ -39,18 +40,23 @@ public:
RimGeoMechResultSlot(void);
virtual ~RimGeoMechResultSlot(void);
void setReservoirView(RimGeoMechView* ownerReservoirView);
void setReservoirView(RimGeoMechView* ownerReservoirView);
RifGeoMechReaderInterface* resultReaderInterface();
caf::PdmField<RimLegendConfig*> legendConfig;
enum ResultPositionEnum {
NODAL,
ELEMENT_NODAL,
INTEGRATION_POINT
};
ResultPositionEnum resultPositionType() { return m_resultPositionType();}
QString resultFieldName() { return m_resultFieldName();}
QString resultComponentName() { return m_resultComponentName();}
caf::PdmField<RimLegendConfig*> legendConfig;
private:
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
bool * useOptionsOnly);

View File

@@ -39,6 +39,7 @@
#include "RiuViewer.h"
#include "RivGeoMechPartMgr.h"
#include "RigGeoMechCaseData.h"
#include "cvfqtUtils.h"
namespace caf {
@@ -170,7 +171,10 @@ void RimGeoMechView::createDisplayModelAndRedraw()
}
m_geoMechVizModel->updateCellColor(cvf::Color4f(cvf::Color3f::ORANGE));
if (cellResult()->resultFieldName() != "")
{
m_geoMechVizModel->updateCellResultColor(m_currentTimeStep(), this->cellResult());
}
m_geoMechVizModel->appendGridPartsToModel(cvfModel.p());
cvf::ref<cvf::Scene> scene = new cvf::Scene;
@@ -212,11 +216,54 @@ void RimGeoMechView::resetLegendsInViewer()
//--------------------------------------------------------------------------------------------------
void RimGeoMechView::updateLegends()
{
if (m_viewer)
if (m_viewer)
{
m_viewer->removeAllColorLegends();
}
if (!m_geomechCase || !m_viewer || !m_geomechCase->geoMechData() )
{
return;
}
RigGeoMechCaseData* gmCase = m_geomechCase->geoMechData();
CVF_ASSERT(gmCase);
double localMin, localMax;
double localPosClosestToZero, localNegClosestToZero;
#if 0
RigCaseCellResultsData* results = gmCase->results(porosityModel);
CVF_ASSERT(results);
if (cellResult->hasDynamicResult())
{
cellResultsData->minMaxCellScalarValues(cellResult->scalarResultIndex(), m_currentTimeStep, localMin, localMax);
cellResultsData->posNegClosestToZero(cellResult->scalarResultIndex(), m_currentTimeStep, localPosClosestToZero, localNegClosestToZero);
}
else
{
localMin = globalMin;
localMax = globalMax;
localPosClosestToZero = globalPosClosestToZero;
localNegClosestToZero = globalNegClosestToZero;
}
cellResult->legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero);
cellResult->legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax);
#endif
caf::AppEnum<RimGeoMechResultSlot::ResultPositionEnum> resPosType = cellResult->resultPositionType();
QString fieldName = cellResult->resultFieldName();
QString compName = cellResult->resultComponentName();
m_viewer->addColorLegendToBottomLeftCorner(cellResult->legendConfig->legend());
cellResult->legendConfig->legend()->setTitle(cvfqt::Utils::toString( resPosType.text() + "\n" + fieldName + " " + compName));
}
//--------------------------------------------------------------------------------------------------

View File

@@ -67,6 +67,7 @@ public:
RimGeoMechCase* geoMechCase();
void loadDataAndUpdate();
virtual void createDisplayModelAndRedraw();
virtual void setCurrentTimeStep(int frameIdx){}
virtual void updateCurrentTimeStepAndRedraw(){}
@@ -80,7 +81,6 @@ public:
private:
virtual void updateViewerWidgetWindowTitle();
virtual void createDisplayModelAndRedraw();
virtual void resetLegendsInViewer();
void updateLegends();