(#266) Added interface for all/activeCellsBoundingBox and displayModelOffset

This commit is contained in:
Magne Sjaastad 2015-11-16 07:16:30 +01:00
parent 7ff7f42adc
commit bca5720968
20 changed files with 337 additions and 164 deletions

View File

@ -326,7 +326,7 @@ float RigFemPart::characteristicElementSize()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::BoundingBox RigFemPart::boundingBox()
cvf::BoundingBox RigFemPart::boundingBox() const
{
if (m_boundingBox.isValid()) return m_boundingBox;

View File

@ -77,7 +77,7 @@ public:
int neighborFace(int elementIndex, int faceIndex) const
{ return m_elmNeighbors[elementIndex].faceInNeighborElm[faceIndex]; }
cvf::BoundingBox boundingBox();
cvf::BoundingBox boundingBox() const;
float characteristicElementSize();
const std::vector<int>& possibleGridCornerElements() const { return m_possibleGridCornerElements; }
void findIntersectingCells(const cvf::BoundingBox& inputBB, std::vector<size_t>* elementIndices) const;
@ -107,7 +107,7 @@ private:
std::vector<int> m_possibleGridCornerElements;
float m_characteristicElementSize;
cvf::BoundingBox m_boundingBox;
mutable cvf::BoundingBox m_boundingBox;
mutable cvf::ref<cvf::BoundingBoxTree> m_elementSearchTree;

View File

@ -103,7 +103,7 @@ float RigFemPartCollection::characteristicElementSize()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::BoundingBox RigFemPartCollection::boundingBox()
cvf::BoundingBox RigFemPartCollection::boundingBox() const
{
cvf::BoundingBox bBox;
for (int i = 0; i < partCount(); i++)

View File

@ -37,7 +37,7 @@ public:
size_t totalElementCount() const;
float characteristicElementSize();
cvf::BoundingBox boundingBox();
cvf::BoundingBox boundingBox() const;
private:

View File

@ -38,42 +38,53 @@ RivGridBoxGenerator::RivGridBoxGenerator()
{
m_gridBoxModel = new cvf::ModelBasicList;
m_linDiscreteScalarMapper = new cvf::ScalarMapperDiscreteLinear;
m_scaleZ = 1.0;
m_displayModelOffset = cvf::Vec3d::ZERO;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGridBoxGenerator::setTransform(cvf::Transform* scaleTransform)
void RivGridBoxGenerator::setScaleZ(double scaleZ)
{
m_scaleTransform = scaleTransform;
m_scaleZ = scaleZ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGridBoxGenerator::setBoundingBox(const cvf::BoundingBox& boundingBox)
void RivGridBoxGenerator::setDisplayModelOffset(cvf::Vec3d offset)
{
m_boundingBox = boundingBox;
m_displayModelOffset = offset;
}
m_xValues.clear();
m_yValues.clear();
m_zValues.clear();
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGridBoxGenerator::setGridBoxDomainCoordBoundingBox(const cvf::BoundingBox& bb)
{
m_domainCoordsBoundingBox = bb;
cvf::Vec3d min = m_boundingBox.min();
cvf::Vec3d max = m_boundingBox.max();
m_domainCoordsXValues.clear();
m_domainCoordsYValues.clear();
m_domainCoordsZValues.clear();
m_linDiscreteScalarMapper->setRange(min.x(), max.x());
m_linDiscreteScalarMapper->setLevelCount(5, true);
m_linDiscreteScalarMapper->majorTickValues(&m_xValues);
cvf::Vec3d min = m_domainCoordsBoundingBox.min();
cvf::Vec3d max = m_domainCoordsBoundingBox.max();
m_linDiscreteScalarMapper->setRange(min.y(), max.y());
m_linDiscreteScalarMapper->setLevelCount(5, true);
m_linDiscreteScalarMapper->majorTickValues(&m_yValues);
cvf::ScalarMapperDiscreteLinear m_linDiscreteScalarMapper;
m_linDiscreteScalarMapper->setRange(min.z(), max.z());
m_linDiscreteScalarMapper->setLevelCount(5, true);
m_linDiscreteScalarMapper->majorTickValues(&m_zValues);
m_linDiscreteScalarMapper.setRange(min.x(), max.x());
m_linDiscreteScalarMapper.setLevelCount(5, true);
m_linDiscreteScalarMapper.majorTickValues(&m_domainCoordsXValues);
m_linDiscreteScalarMapper.setRange(min.y(), max.y());
m_linDiscreteScalarMapper.setLevelCount(5, true);
m_linDiscreteScalarMapper.majorTickValues(&m_domainCoordsYValues);
m_linDiscreteScalarMapper.setRange(min.z(), max.z());
m_linDiscreteScalarMapper.setLevelCount(5, true);
m_linDiscreteScalarMapper.majorTickValues(&m_domainCoordsZValues);
}
//--------------------------------------------------------------------------------------------------
@ -81,6 +92,8 @@ void RivGridBoxGenerator::setBoundingBox(const cvf::BoundingBox& boundingBox)
//--------------------------------------------------------------------------------------------------
void RivGridBoxGenerator::createGridBoxParts()
{
computeDisplayCoords();
createGridBoxSideParts();
createGridBoxLegendParts();
}
@ -128,9 +141,13 @@ void RivGridBoxGenerator::createGridBoxSideParts()
{
m_gridBoxSideParts.clear();
cvf::Vec3d min = m_boundingBox.min();
cvf::Vec3d max = m_boundingBox.max();
CVF_ASSERT(m_displayCoordsBoundingBox.isValid());
CVF_ASSERT(m_displayCoordsXValues.size() > 0);
CVF_ASSERT(m_displayCoordsYValues.size() > 0);
CVF_ASSERT(m_displayCoordsZValues.size() > 0);
cvf::Vec3d min = m_displayCoordsBoundingBox.min();
cvf::Vec3d max = m_displayCoordsBoundingBox.max();
for (int face = POS_X; face <= NEG_Z; face++)
{
@ -141,37 +158,37 @@ void RivGridBoxGenerator::createGridBoxSideParts()
{
patchGen.setOrigin(cvf::Vec3d(max.x(), 0.0, 0.0));
patchGen.setAxes(cvf::Vec3d::Y_AXIS, cvf::Vec3d::Z_AXIS);
patchGen.setSubdivisions(m_yValues, m_zValues);
patchGen.setSubdivisions(m_displayCoordsYValues, m_displayCoordsZValues);
}
else if (face == NEG_X)
{
patchGen.setOrigin(cvf::Vec3d(min.x(), 0.0, 0.0));
patchGen.setAxes(cvf::Vec3d::Y_AXIS, cvf::Vec3d::Z_AXIS);
patchGen.setSubdivisions(m_yValues, m_zValues);
patchGen.setSubdivisions(m_displayCoordsYValues, m_displayCoordsZValues);
}
else if (face == POS_Y)
{
patchGen.setOrigin(cvf::Vec3d(0.0, max.y(), 0.0));
patchGen.setAxes(cvf::Vec3d::X_AXIS, cvf::Vec3d::Z_AXIS);
patchGen.setSubdivisions(m_xValues, m_zValues);
patchGen.setSubdivisions(m_displayCoordsXValues, m_displayCoordsZValues);
}
else if (face == NEG_Y)
{
patchGen.setOrigin(cvf::Vec3d(0.0, min.y(), 0.0));
patchGen.setAxes(cvf::Vec3d::X_AXIS, cvf::Vec3d::Z_AXIS);
patchGen.setSubdivisions(m_xValues, m_zValues);
patchGen.setSubdivisions(m_displayCoordsXValues, m_displayCoordsZValues);
}
else if (face == POS_Z)
{
patchGen.setOrigin(cvf::Vec3d(0.0, 0.0, max.z()));
patchGen.setAxes(cvf::Vec3d::X_AXIS, cvf::Vec3d::Y_AXIS);
patchGen.setSubdivisions(m_xValues, m_yValues);
patchGen.setSubdivisions(m_displayCoordsXValues, m_displayCoordsYValues);
}
else if (face == NEG_Z)
{
patchGen.setOrigin(cvf::Vec3d(0.0, 0.0, min.z()));
patchGen.setAxes(cvf::Vec3d::X_AXIS, cvf::Vec3d::Y_AXIS);
patchGen.setSubdivisions(m_xValues, m_yValues);
patchGen.setSubdivisions(m_displayCoordsXValues, m_displayCoordsYValues);
}
else
{
@ -196,7 +213,6 @@ void RivGridBoxGenerator::createGridBoxSideParts()
part->setName("Grid box ");
part->setDrawable(geo.p());
part->setTransform(m_scaleTransform.p());
part->updateBoundingBox();
cvf::ref<cvf::Effect> eff;
@ -217,6 +233,11 @@ void RivGridBoxGenerator::createGridBoxLegendParts()
{
m_gridBoxLegendParts.clear();
CVF_ASSERT(m_displayCoordsBoundingBox.isValid());
CVF_ASSERT(m_displayCoordsXValues.size() > 0);
CVF_ASSERT(m_displayCoordsYValues.size() > 0);
CVF_ASSERT(m_displayCoordsZValues.size() > 0);
for (int edge = POS_Z_POS_X; edge <= NEG_X_NEG_Y; edge++)
{
cvf::Collection<cvf::Part> parts;
@ -230,6 +251,17 @@ void RivGridBoxGenerator::createGridBoxLegendParts()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3d RivGridBoxGenerator::displayModelCoordFromDomainCoord(const cvf::Vec3d& domainCoord) const
{
cvf::Vec3d coord = domainCoord - m_displayModelOffset;
coord.z() *= m_scaleZ;
return coord;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -238,10 +270,9 @@ void RivGridBoxGenerator::createLegend(EdgeType edge, cvf::Collection<cvf::Part>
cvf::Vec3d posMin;
cvf::Vec3d posMax;
cvf::Vec3d min = m_boundingBox.min();
cvf::Vec3d max = m_boundingBox.max();
cvf::Vec3d min = m_displayCoordsBoundingBox.min();
cvf::Vec3d max = m_displayCoordsBoundingBox.max();
std::vector<double>* tickValues = NULL;
AxisType axis;
cvf::Vec3f tickMarkDir;
@ -250,84 +281,72 @@ void RivGridBoxGenerator::createLegend(EdgeType edge, cvf::Collection<cvf::Part>
{
case RivGridBoxGenerator::POS_Z_POS_X:
axis = Y_AXIS;
tickValues = &m_yValues;
posMin.set(max.x(), min.y(), max.z());
posMax.set(max.x(), max.y(), max.z());
tickMarkDir = cornerDirection(POS_Z, POS_X);
break;
case RivGridBoxGenerator::POS_Z_NEG_X:
axis = Y_AXIS;
tickValues = &m_yValues;
posMin.set(min.x(), min.y(), max.z());
posMax.set(min.x(), max.y(), max.z());
tickMarkDir = cornerDirection(POS_Z, NEG_X);
break;
case RivGridBoxGenerator::POS_Z_POS_Y:
axis = X_AXIS;
tickValues = &m_xValues;
posMin.set(min.x(), max.y(), max.z());
posMax.set(max.x(), max.y(), max.z());
tickMarkDir = cornerDirection(POS_Z, POS_Y);
break;
case RivGridBoxGenerator::POS_Z_NEG_Y:
axis = X_AXIS;
tickValues = &m_xValues;
posMin.set(min.x(), min.y(), max.z());
posMax.set(max.x(), min.y(), max.z());
tickMarkDir = cornerDirection(POS_Z, NEG_Y);
break;
case RivGridBoxGenerator::NEG_Z_POS_X:
axis = Y_AXIS;
tickValues = &m_yValues;
posMin.set(max.x(), min.y(), min.z());
posMax.set(max.x(), max.y(), min.z());
tickMarkDir = cornerDirection(NEG_Z, POS_X);
break;
case RivGridBoxGenerator::NEG_Z_NEG_X:
axis = Y_AXIS;
tickValues = &m_yValues;
posMin.set(min.x(), min.y(), min.z());
posMax.set(min.x(), max.y(), min.z());
tickMarkDir = cornerDirection(NEG_Z, NEG_X);
break;
case RivGridBoxGenerator::NEG_Z_POS_Y:
axis = X_AXIS;
tickValues = &m_xValues;
posMin.set(min.x(), max.y(), min.z());
posMax.set(max.x(), max.y(), min.z());
tickMarkDir = cornerDirection(NEG_Z, POS_Y);
break;
case RivGridBoxGenerator::NEG_Z_NEG_Y:
axis = X_AXIS;
tickValues = &m_xValues;
posMin.set(min.x(), min.y(), min.z());
posMax.set(max.x(), min.y(), min.z());
tickMarkDir = cornerDirection(NEG_Z, NEG_Y);
break;
case RivGridBoxGenerator::POS_X_POS_Y:
axis = Z_AXIS;
tickValues = &m_zValues;
posMin.set(max.x(), max.y(), min.z());
posMax.set(max.x(), max.y(), max.z());
tickMarkDir = cornerDirection(POS_X, POS_Y);
break;
case RivGridBoxGenerator::POS_X_NEG_Y:
axis = Z_AXIS;
tickValues = &m_zValues;
posMin.set(max.x(), min.y(), min.z());
posMax.set(max.x(), min.y(), max.z());
tickMarkDir = cornerDirection(POS_X, NEG_Y);
break;
case RivGridBoxGenerator::NEG_X_POS_Y:
axis = Z_AXIS;
tickValues = &m_zValues;
posMin.set(min.x(), max.y(), min.z());
posMax.set(min.x(), max.y(), max.z());
tickMarkDir = cornerDirection(NEG_X, POS_Y);
break;
case RivGridBoxGenerator::NEG_X_NEG_Y:
axis = Z_AXIS;
tickValues = &m_zValues;
posMin.set(min.x(), min.y(), min.z());
posMax.set(min.x(), min.y(), max.z());
tickMarkDir = cornerDirection(NEG_X, NEG_Y);
@ -336,10 +355,30 @@ void RivGridBoxGenerator::createLegend(EdgeType edge, cvf::Collection<cvf::Part>
break;
}
CVF_ASSERT(tickValues);
std::vector<double>* displayCoordsTickValues = NULL;
std::vector<double>* domainCoordsTickValues = NULL;
size_t numVerts = (tickValues->size()) * 2;
size_t numLines = (tickValues->size()) + 1;
if (axis == X_AXIS)
{
displayCoordsTickValues = &m_displayCoordsXValues;
domainCoordsTickValues = &m_domainCoordsXValues;
}
else if (axis == Y_AXIS)
{
displayCoordsTickValues = &m_displayCoordsYValues;
domainCoordsTickValues = &m_domainCoordsYValues;
}
else if (axis == Z_AXIS)
{
displayCoordsTickValues = &m_displayCoordsZValues;
domainCoordsTickValues = &m_domainCoordsZValues;
}
CVF_ASSERT(displayCoordsTickValues);
CVF_ASSERT(domainCoordsTickValues);
size_t numVerts = (displayCoordsTickValues->size()) * 2;
size_t numLines = (displayCoordsTickValues->size()) + 1;
cvf::ref<cvf::Vec3fArray> vertices = new cvf::Vec3fArray;
vertices->reserve(numVerts);
@ -348,15 +387,15 @@ void RivGridBoxGenerator::createLegend(EdgeType edge, cvf::Collection<cvf::Part>
indices->reserve(2 * numLines);
float tickLength = static_cast<float>(m_boundingBox.extent().length() / 100.0);
float tickLength = static_cast<float>(m_displayCoordsBoundingBox.extent().length() / 100.0);
cvf::Vec3f point = cvf::Vec3f(posMin);
cvf::Vec3f tickPoint;
// Tick marks
for (size_t i = 0; i < tickValues->size(); ++i)
for (size_t i = 0; i < displayCoordsTickValues->size(); ++i)
{
point[axis] = static_cast<float>(tickValues->at(i));
point[axis] = static_cast<float>(displayCoordsTickValues->at(i));
vertices->add(point);
tickPoint = point + tickLength*tickMarkDir;;
@ -383,7 +422,6 @@ void RivGridBoxGenerator::createLegend(EdgeType edge, cvf::Collection<cvf::Part>
part->setName("Legend lines ");
part->setDrawable(geo.p());
part->setTransform(m_scaleTransform.p());
part->updateBoundingBox();
cvf::ref<cvf::Effect> eff;
@ -395,7 +433,6 @@ void RivGridBoxGenerator::createLegend(EdgeType edge, cvf::Collection<cvf::Part>
parts->push_back(part.p());
}
{
// Text labels
@ -406,14 +443,13 @@ void RivGridBoxGenerator::createLegend(EdgeType edge, cvf::Collection<cvf::Part>
geo->setDrawBorder(false);
//textGeo->setCheckPosVisible(false);
for (size_t idx = 0; idx < tickValues->size(); idx++)
for (size_t idx = 0; idx < domainCoordsTickValues->size(); idx++)
{
geo->addText(cvf::String(tickValues->at(idx)), vertices->get(idx*2 + 1) + (0.5f * tickLength) * tickMarkDir);
geo->addText(cvf::String(domainCoordsTickValues->at(idx)), vertices->get(idx*2 + 1) + (0.5f * tickLength) * tickMarkDir);
}
cvf::ref<cvf::Part> part = new cvf::Part;
part->setDrawable(geo.p());
part->setTransform(m_scaleTransform.p());
part->updateBoundingBox();
cvf::ref<cvf::Effect> eff = new cvf::Effect;
@ -462,12 +498,12 @@ cvf::Vec3d RivGridBoxGenerator::pointOnSide(FaceType face)
case RivGridBoxGenerator::POS_X:
case RivGridBoxGenerator::POS_Y:
case RivGridBoxGenerator::POS_Z:
return cvf::Vec3d(m_boundingBox.max());
return cvf::Vec3d(m_displayCoordsBoundingBox.max());
case RivGridBoxGenerator::NEG_X:
case RivGridBoxGenerator::NEG_Y:
case RivGridBoxGenerator::NEG_Z:
return cvf::Vec3d(m_boundingBox.min());
return cvf::Vec3d(m_displayCoordsBoundingBox.min());
default:
break;
}
@ -485,3 +521,32 @@ cvf::Vec3f RivGridBoxGenerator::cornerDirection(FaceType face1, FaceType face2)
return dir;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGridBoxGenerator::computeDisplayCoords()
{
m_displayCoordsBoundingBox.reset();
m_displayCoordsXValues.clear();
m_displayCoordsYValues.clear();
m_displayCoordsZValues.clear();
m_displayCoordsBoundingBox.add(displayModelCoordFromDomainCoord(m_domainCoordsBoundingBox.min()));
m_displayCoordsBoundingBox.add(displayModelCoordFromDomainCoord(m_domainCoordsBoundingBox.max()));
for (size_t i = 0; i < m_domainCoordsXValues.size(); i++)
{
m_displayCoordsXValues.push_back(m_domainCoordsXValues[i] - m_displayModelOffset.x());
}
for (size_t i = 0; i < m_domainCoordsYValues.size(); i++)
{
m_displayCoordsYValues.push_back(m_domainCoordsYValues[i] - m_displayModelOffset.y());
}
for (size_t i = 0; i < m_domainCoordsZValues.size(); i++)
{
m_displayCoordsZValues.push_back(m_scaleZ * (m_domainCoordsZValues[i] - m_displayModelOffset.z()));
}
}

View File

@ -44,8 +44,9 @@ class RivGridBoxGenerator
public:
RivGridBoxGenerator();
void setTransform(cvf::Transform* scaleTransform);
void setBoundingBox(const cvf::BoundingBox& boundingBox);
void setScaleZ(double scaleZ);
void setDisplayModelOffset(cvf::Vec3d offset);
void setGridBoxDomainCoordBoundingBox(const cvf::BoundingBox& boundingBox);
void createGridBoxParts();
void updateFromCamera(const cvf::Camera* camera);
@ -93,12 +94,15 @@ private:
void createGridBoxSideParts();
void createGridBoxLegendParts();
cvf::Vec3d displayModelCoordFromDomainCoord(const cvf::Vec3d& domainCoord) const;
void createLegend(EdgeType edge, cvf::Collection<cvf::Part>* parts);
cvf::Vec3f sideNormalOutwards(FaceType face);
cvf::Vec3d pointOnSide(FaceType face);
cvf::Vec3f cornerDirection(FaceType face1, FaceType face2);
void computeDisplayCoords();
private:
cvf::Collection<cvf::Part> m_gridBoxSideParts;
@ -106,13 +110,17 @@ private:
cvf::ref<cvf::ModelBasicList> m_gridBoxModel;
cvf::ref<cvf::Transform> m_scaleTransform;
cvf::BoundingBox m_boundingBox;
cvf::BoundingBox m_domainCoordsBoundingBox;
std::vector<double> m_domainCoordsXValues;
std::vector<double> m_domainCoordsYValues;
std::vector<double> m_domainCoordsZValues;
cvf::ref<cvf::ScalarMapperDiscreteLinear> m_linDiscreteScalarMapper;
cvf::BoundingBox m_displayCoordsBoundingBox;
std::vector<double> m_displayCoordsXValues;
std::vector<double> m_displayCoordsYValues;
std::vector<double> m_displayCoordsZValues;
std::vector<double> m_xValues;
std::vector<double> m_yValues;
std::vector<double> m_zValues;
double m_scaleZ;
cvf::Vec3d m_displayModelOffset;
};

View File

@ -87,46 +87,6 @@ void RivPatchGenerator::setWindingCCW(bool windingCCW)
//--------------------------------------------------------------------------------------------------
void RivPatchGenerator::generate(cvf::GeometryBuilder* builder)
{
/*
CVF_ASSERT(m_cellCountU > 0);
CVF_ASSERT(m_cellCountV > 0);
size_t numVertices = (m_cellCountU + 1)*(m_cellCountV + 1);
Vec3fArray vertices;
vertices.reserve(numVertices);
const Vec3d unitU = (m_extentU*m_axisU)/m_cellCountU;
const Vec3d unitV = (m_extentV*m_axisV)/m_cellCountV;
uint v;
for (v = 0; v <= m_cellCountV; v++)
{
Vec3d rowOrigo(m_origin + unitV*v);
uint u;
for (u = 0; u <= m_cellCountU; u++)
{
vertices.add(Vec3f(rowOrigo + unitU*u));
}
}
uint baseNodeIdx = builder->addVertices(vertices);
if (m_useQuads)
{
UIntArray conn;
GeometryUtils::tesselatePatchAsQuads(m_cellCountU + 1, m_cellCountV + 1, baseNodeIdx, m_windingCCW, &conn);
builder->addQuads(conn);
}
else
{
UIntArray conn;
GeometryUtils::tesselatePatchAsTriangles(m_cellCountU + 1, m_cellCountV + 1, baseNodeIdx, m_windingCCW, &conn);
builder->addTriangles(conn);
}
*/
CVF_ASSERT(m_uValues.size() > 0);
CVF_ASSERT(m_vValues.size() > 0);

View File

@ -18,6 +18,7 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RimCase.h"
#include "cafPdmObjectFactory.h"
#include <QFile>
@ -203,4 +204,12 @@ QString RimCase::relocateFile(const QString& orgFileName, const QString& orgNew
if (foundFile) *foundFile = false;
return fileName;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3d RimCase::displayModelOffset() const
{
return cvf::Vec3d::ZERO;
}

View File

@ -18,13 +18,20 @@
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cvfVector3.h"
#include <vector>
class RimView;
namespace cvf {
class BoundingBox;
}
class RimCase : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
@ -44,6 +51,11 @@ public:
virtual QStringList timeStepStrings() = 0;
virtual QString timeStepName(int frameIdx) = 0;
virtual cvf::BoundingBox activeCellsBoundingBox() const = 0;
virtual cvf::BoundingBox allCellsBoundingBox() const = 0;
virtual cvf::Vec3d displayModelOffset() const;
protected:
static QString relocateFile(const QString& fileName, const QString& newProjectPath, const QString& oldProjectPath,
bool* foundFile, std::vector<QString>* searchedPaths);

View File

@ -356,6 +356,51 @@ void RimEclipseCase::setReservoirData(RigCaseData* eclipseCase)
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::BoundingBox RimEclipseCase::activeCellsBoundingBox() const
{
if (m_rigEclipseCase.notNull() && m_rigEclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS))
{
return m_rigEclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->geometryBoundingBox();
}
else
{
return cvf::BoundingBox();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::BoundingBox RimEclipseCase::allCellsBoundingBox() const
{
if (m_rigEclipseCase.notNull() && m_rigEclipseCase->mainGrid())
{
return m_rigEclipseCase->mainGrid()->boundingBox();
}
else
{
return cvf::BoundingBox();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3d RimEclipseCase::displayModelOffset() const
{
if (m_rigEclipseCase.notNull() && m_rigEclipseCase->mainGrid())
{
return m_rigEclipseCase->mainGrid()->displayModelOffset();
}
else
{
return cvf::Vec3d::ZERO;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -468,4 +513,4 @@ QString RimEclipseCase::timeStepName(int frameIdx)
QDateTime date = results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->timeStepDate(0,frameIdx);
return date.toString(m_timeStepFormatString);
}
}

View File

@ -71,9 +71,9 @@ public:
RigCaseData* reservoirData();
const RigCaseData* reservoirData() const;
RimReservoirCellResultsStorage* results(RifReaderInterface::PorosityModelResultType porosityModel);
RimReservoirCellResultsStorage* results(RifReaderInterface::PorosityModelResultType porosityModel);
RimEclipseView* createAndAddReservoirView();
RimEclipseView* createAndAddReservoirView();
void removeResult(const QString& resultName);
@ -88,6 +88,10 @@ public:
virtual QStringList timeStepStrings();
virtual QString timeStepName(int frameIdx);
virtual cvf::BoundingBox activeCellsBoundingBox() const;
virtual cvf::BoundingBox allCellsBoundingBox() const;
virtual cvf::Vec3d displayModelOffset() const;
// Overridden methods from PdmObject
public:

View File

@ -70,6 +70,7 @@
#include <QMessageBox>
#include <limits.h>
#include "RivGridBoxGenerator.h"
@ -227,6 +228,8 @@ void RimEclipseView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c
}
else if (changedField == &showInactiveCells)
{
this->updateGridBoxData();
this->scheduleGeometryRegen(INACTIVE);
this->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE);
@ -480,8 +483,6 @@ void RimEclipseView::createDisplayModel()
m_overlayInfoConfig()->update3DInfo();
updateLegends();
}
m_viewer->showGridBox(true);
}
@ -1682,6 +1683,32 @@ void RimEclipseView::calculateCurrentTotalCellVisibility(cvf::UByteArray* totalV
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseView::updateGridBoxData()
{
if (viewer())
{
RivGridBoxGenerator* gridBoxGen = viewer()->gridBoxGenerator();
gridBoxGen->setScaleZ(scaleZ);
if (showInactiveCells)
{
gridBoxGen->setGridBoxDomainCoordBoundingBox(ownerCase()->allCellsBoundingBox());
}
else
{
gridBoxGen->setGridBoxDomainCoordBoundingBox(ownerCase()->activeCellsBoundingBox());
}
gridBoxGen->setDisplayModelOffset(ownerCase()->displayModelOffset());
gridBoxGen->createGridBoxParts();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -126,6 +126,8 @@ public:
const std::vector<RivCellSetEnum>& visibleGridParts() const { return m_visibleGridParts;}
cvf::cref<RivReservoirViewPartMgr> reservoirGridPartManager() const { return m_reservoirGridPartManager.p(); }
virtual void updateGridBoxData();
// Does this belong here, really ?
void calculateVisibleWellCellsIncFence(cvf::UByteArray* visibleCells, RigGridBase * grid);

View File

@ -18,14 +18,19 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RimGeoMechCase.h"
#include "RimGeoMechView.h"
#include "RiaApplication.h"
#include "RiaPreferences.h"
#include "RifOdbReader.h"
#include "RigGeoMechCaseData.h"
#include "RigFemPartCollection.h"
#include "RigFemPartResultsCollection.h"
#include "RimProject.h"
#include "RigGeoMechCaseData.h"
#include "RimGeoMechView.h"
#include "RimMainPlotCollection.h"
#include "RimProject.h"
#include "RimWellLogPlotCollection.h"
#include <QFile>
@ -179,3 +184,26 @@ QString RimGeoMechCase::timeStepName(int frameIdx)
return QString::fromStdString(stepNames[frameIdx]);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::BoundingBox RimGeoMechCase::activeCellsBoundingBox() const
{
return allCellsBoundingBox();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::BoundingBox RimGeoMechCase::allCellsBoundingBox() const
{
if (m_geoMechCaseData.notNull() && m_geoMechCaseData->femParts())
{
return m_geoMechCaseData->femParts()->boundingBox();
}
else
{
return cvf::BoundingBox();
}
}

View File

@ -59,6 +59,9 @@ public:
virtual QStringList timeStepStrings();
virtual QString timeStepName(int frameIdx);
virtual cvf::BoundingBox activeCellsBoundingBox() const;
virtual cvf::BoundingBox allCellsBoundingBox() const;
// Fields:
caf::PdmChildArrayField<RimGeoMechView*> geoMechViews;

View File

@ -250,8 +250,6 @@ void RimGeoMechView::createDisplayModel()
m_vizLogic->updateStaticCellColors(-1);
m_overlayInfoConfig()->update3DInfo();
}
m_viewer->showGridBox(true);
}
//--------------------------------------------------------------------------------------------------

View File

@ -19,6 +19,7 @@
#include "RiuMainWindow.h"
#include "RiuViewer.h"
#include "RivGridBoxGenerator.h"
#include "RivWellPathCollectionPartMgr.h"
#include "cafFrameAnimationControl.h"
@ -178,6 +179,7 @@ void RimView::updateViewerWidget()
m_viewer = new RiuViewer(glFormat, NULL);
m_viewer->setOwnerReservoirView(this);
this->updateGridBoxData();
RiuMainWindow::instance()->addViewer(m_viewer->layoutWidget(), windowGeometry());
m_viewer->setMinNearPlaneDistance(10);
@ -246,6 +248,17 @@ void RimView::setCurrentTimeStep(int frameIndex)
m_currentReservoirCellVisibility = NULL;
}
this->updateCurrentTimeStep();
cvf::Scene* frameScene = m_viewer->frame(m_currentTimeStep);
if (frameScene)
{
frameScene->removeModel(m_viewer->gridBoxGenerator()->model());
if (true)
{
frameScene->addModel(m_viewer->gridBoxGenerator()->model());
}
}
}
//--------------------------------------------------------------------------------------------------
///
@ -464,6 +477,8 @@ void RimView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QV
{
if (scaleZ < 1) scaleZ = 1;
this->updateGridBoxData();
// Regenerate well paths
RimOilField* oilFields = RiaApplication::instance()->project() ? RiaApplication::instance()->project()->activeOilField() : NULL;
RimWellPathCollection* wellPathCollection = (oilFields) ? oilFields->wellPathCollection() : NULL;
@ -771,3 +786,20 @@ void RimView::removeModelByName(cvf::Scene* scene, const cvf::String& modelName)
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView::updateGridBoxData()
{
if (viewer())
{
RivGridBoxGenerator* gridBoxGen = viewer()->gridBoxGenerator();
gridBoxGen->setScaleZ(scaleZ);
gridBoxGen->setDisplayModelOffset(cvf::Vec3d::ZERO);
gridBoxGen->setGridBoxDomainCoordBoundingBox(ownerCase()->allCellsBoundingBox());
gridBoxGen->createGridBoxParts();
}
}

View File

@ -137,6 +137,8 @@ public:
cvf::ref<cvf::UByteArray> currentTotalCellVisibility();
virtual void updateGridBoxData();
public:
virtual void loadDataAndUpdate() = 0;
virtual RimCase* ownerCase() = 0;

View File

@ -163,7 +163,6 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent)
// which solves the problem
setContextMenuPolicy(Qt::PreventContextMenu);
m_showGridBox = true;
m_gridBoxGenerator = new RivGridBoxGenerator;
}
@ -173,12 +172,12 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent)
//--------------------------------------------------------------------------------------------------
RiuViewer::~RiuViewer()
{
if (m_reservoirView)
if (m_rimView)
{
m_reservoirView->showWindow = false;
m_reservoirView->uiCapability()->updateUiIconFromToggleField();
m_rimView->showWindow = false;
m_rimView->uiCapability()->updateUiIconFromToggleField();
m_reservoirView->cameraPosition = m_mainCamera->viewMatrix();
m_rimView->cameraPosition = m_mainCamera->viewMatrix();
}
delete m_InfoLabel;
delete m_animationProgress;
@ -258,7 +257,7 @@ void RiuViewer::slotEndAnimation()
cvf::Rendering* firstRendering = m_renderingSequence->firstRendering();
CVF_ASSERT(firstRendering);
if (m_reservoirView) m_reservoirView->endAnimation();
if (m_rimView) m_rimView->endAnimation();
caf::Viewer::slotEndAnimation();
@ -272,12 +271,12 @@ void RiuViewer::slotSetCurrentFrame(int frameIndex)
{
setCurrentFrame(frameIndex);
if (m_reservoirView)
if (m_rimView)
{
RimViewLinker* viewLinker = m_reservoirView->assosiatedViewLinker();
RimViewLinker* viewLinker = m_rimView->assosiatedViewLinker();
if (viewLinker)
{
viewLinker->updateTimeStep(m_reservoirView, frameIndex);
viewLinker->updateTimeStep(m_rimView, frameIndex);
}
}
}
@ -303,7 +302,7 @@ void RiuViewer::setPointOfInterest(cvf::Vec3d poi)
//--------------------------------------------------------------------------------------------------
void RiuViewer::setOwnerReservoirView(RimView * owner)
{
m_reservoirView = owner;
m_rimView = owner;
m_viewerCommands->setOwnerView(owner);
}
@ -340,7 +339,7 @@ void RiuViewer::paintOverlayItems(QPainter* painter)
if (showAnimBar && m_showAnimProgress)
{
QString stepName = m_reservoirView->ownerCase()->timeStepName(currentFrameIndex());
QString stepName = m_rimView->ownerCase()->timeStepName(currentFrameIndex());
m_animationProgress->setFormat("Time Step: %v/%m " + stepName);
m_animationProgress->setMinimum(0);
m_animationProgress->setMaximum(static_cast<int>(frameCount()) - 1);
@ -501,17 +500,12 @@ void RiuViewer::navigationPolicyUpdate()
{
caf::Viewer::navigationPolicyUpdate();
if (m_reservoirView)
if (m_rimView)
{
RimViewLinker* viewLinker = m_reservoirView->assosiatedViewLinker();
RimViewLinker* viewLinker = m_rimView->assosiatedViewLinker();
if (viewLinker)
{
viewLinker->updateCamera(m_reservoirView);
}
if (m_showGridBox)
{
m_gridBoxGenerator->updateFromCamera(mainCamera());
viewLinker->updateCamera(m_rimView);
}
}
}
@ -524,7 +518,7 @@ void RiuViewer::setCurrentFrame(int frameIndex)
cvf::Rendering* firstRendering = m_renderingSequence->firstRendering();
CVF_ASSERT(firstRendering);
if (m_reservoirView) m_reservoirView->setCurrentTimeStep(frameIndex);
if (m_rimView) m_rimView->setCurrentTimeStep(frameIndex);
caf::Viewer::slotSetCurrentFrame(frameIndex);
}
@ -534,27 +528,13 @@ void RiuViewer::setCurrentFrame(int frameIndex)
//--------------------------------------------------------------------------------------------------
RimView* RiuViewer::ownerReservoirView()
{
return m_reservoirView;
return m_rimView;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuViewer::showGridBox(bool enable)
RivGridBoxGenerator* RiuViewer::gridBoxGenerator() const
{
m_showGridBox = enable;
if (!enable)
{
currentScene()->removeModel(m_gridBoxGenerator->model());
}
else
{
m_gridBoxGenerator->setBoundingBox(mainScene()->boundingBox());
// m_gridBoxGenerator->setTransform();
m_gridBoxGenerator->updateFromCamera(mainCamera());
m_gridBoxGenerator->createGridBoxParts();
currentScene()->addModel(m_gridBoxGenerator->model());
}
return m_gridBoxGenerator;
}

View File

@ -69,7 +69,7 @@ public:
void setHistogram(double min, double max, const std::vector<size_t>& histogram);
void setHistogramPercentiles(double pmin, double pmax, double mean);
void showGridBox(bool enable);
RivGridBoxGenerator* gridBoxGenerator() const;
void showAnimationProgress(bool enable);
@ -92,7 +92,6 @@ private:
void mouseReleaseEvent(QMouseEvent* event);
void mousePressEvent(QMouseEvent* event);
QLabel* m_InfoLabel;
QLabel* m_versionInfoLabel;
bool m_showInfoText;
@ -107,12 +106,11 @@ private:
cvf::Collection<cvf::OverlayItem> m_visibleLegends;
caf::PdmPointer<RimView> m_reservoirView;
QPoint m_lastMousePressPosition;
caf::PdmPointer<RimView> m_rimView;
QPoint m_lastMousePressPosition;
RiuViewerCommands* m_viewerCommands;
RiuViewerCommands* m_viewerCommands;
bool m_showGridBox;
RivGridBoxGenerator* m_gridBoxGenerator;
RivGridBoxGenerator* m_gridBoxGenerator;
};