Now reading Odb-file and creating display model

Nothing shows up yet, but we're getting there
This commit is contained in:
Jacob Støren 2015-04-27 13:51:22 +02:00
parent ea3d2dc40d
commit 0f3d9ffa60
14 changed files with 327 additions and 8 deletions

View File

@ -22,6 +22,7 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/WellPathImportSsihub
${CMAKE_CURRENT_SOURCE_DIR}/GeoMech/OdbReader
${CMAKE_CURRENT_SOURCE_DIR}/GeoMech/GeoMechDataModel
${CMAKE_CURRENT_SOURCE_DIR}/GeoMech/GeoMechVisualization
${CMAKE_BINARY_DIR}/Generated
${CMAKE_CURRENT_BINARY_DIR}

View File

@ -56,9 +56,17 @@ RigFemPart* RigFemPartCollection::part(size_t index)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigFemPartCollection::partCount()
const RigFemPart* RigFemPartCollection::part(size_t index) const
{
return m_femParts.size();
return m_femParts[index].p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RigFemPartCollection::partCount() const
{
return static_cast<int>(m_femParts.size());
}

View File

@ -31,7 +31,9 @@ public:
void addFemPart(RigFemPart* part);
RigFemPart* part(size_t index);
size_t partCount();
const RigFemPart* part(size_t index) const ;
int partCount() const;
private:
cvf::Collection<RigFemPart> m_femParts;

View File

@ -42,3 +42,11 @@ RigFemPartCollection* RigGeoMechCaseData::femParts()
{
return m_femParts.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RigFemPartCollection* RigGeoMechCaseData::femParts() const
{
return m_femParts.p();
}

View File

@ -29,7 +29,8 @@ public:
~RigGeoMechCaseData();
RigFemPartCollection* femParts();
const RigFemPartCollection* femParts() const;
private:
cvf::ref<RigFemPartCollection> m_femParts;

View File

@ -7,11 +7,13 @@ endif()
set (SOURCE_GROUP_HEADER_FILES
${CEE_CURRENT_LIST_DIR}RivFemPartGeometryGenerator.h
${CEE_CURRENT_LIST_DIR}RivFemPartPartMgr.h
${CEE_CURRENT_LIST_DIR}RivGeoMechPartMgr.h
)
set (SOURCE_GROUP_SOURCE_FILES
${CEE_CURRENT_LIST_DIR}RivFemPartGeometryGenerator.cpp
${CEE_CURRENT_LIST_DIR}RivFemPartPartMgr.cpp
${CEE_CURRENT_LIST_DIR}RivGeoMechPartMgr.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -156,7 +156,7 @@ void RivFemPartGeometryGenerator::computeArrays()
cvf::Vec3d offset = Vec3d::ZERO; //m_part->displayModelOffset();
const std::vector<cvf::Vec3f>& nodeCoordinates = m_part->nodes().coordinates;
#pragma omp parallel for schedule(dynamic)
//#pragma omp parallel for schedule(dynamic)
for (int elmIdx = 0; elmIdx < static_cast<int>(m_part->elementCount()); elmIdx++)
{
if (m_elmVisibility.isNull() || (*m_elmVisibility)[elmIdx])

View File

@ -47,7 +47,7 @@ class RigFemPart;
class RivFemPartPartMgr: public cvf::Object
{
public:
RivFemPartPartMgr(const RigFemPart* grid);
RivFemPartPartMgr(const RigFemPart* femPart);
~RivFemPartPartMgr();
void setTransform(cvf::Transform* scaleTransform);
void setCellVisibility(cvf::UByteArray* cellVisibilities );

View File

@ -0,0 +1,140 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RivGeoMechPartMgr.h"
#include "cvfPart.h"
#include "cvfModelBasicList.h"
#include "RigGeoMechCaseData.h"
#include "RigFemPartCollection.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivGeoMechPartMgr::RivGeoMechPartMgr()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivGeoMechPartMgr::~RivGeoMechPartMgr()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGeoMechPartMgr::clearAndSetReservoir(const RigGeoMechCaseData* geoMechCase, RimGeoMechView* geomechView)
{
m_femPartPartMgrs.clear();
if (geoMechCase)
{
const RigFemPartCollection* femParts = geoMechCase->femParts();
for (size_t i = 0; i < femParts->partCount(); ++i)
{
m_femPartPartMgrs.push_back(new RivFemPartPartMgr(femParts->part(i)));
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGeoMechPartMgr::setTransform(cvf::Transform* scaleTransform)
{
for (size_t i = 0; i < m_femPartPartMgrs.size() ; ++i)
{
m_femPartPartMgrs[i]->setTransform(scaleTransform);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGeoMechPartMgr::setCellVisibility(size_t gridIndex, cvf::UByteArray* cellVisibilities)
{
CVF_ASSERT(gridIndex < m_femPartPartMgrs.size());
m_femPartPartMgrs[gridIndex]->setCellVisibility(cellVisibilities);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::UByteArray> RivGeoMechPartMgr::cellVisibility(size_t gridIdx)
{
CVF_ASSERT(gridIdx < m_femPartPartMgrs.size());
return m_femPartPartMgrs[gridIdx]->cellVisibility();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGeoMechPartMgr::updateCellColor(cvf::Color4f color)
{
for (size_t i = 0; i < m_femPartPartMgrs.size() ; ++i)
{
m_femPartPartMgrs[i]->updateCellColor(color);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGeoMechPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechResultSlot* cellResultSlot)
{
for (size_t i = 0; i < m_femPartPartMgrs.size() ; ++i)
{
m_femPartPartMgrs[i]->updateCellResultColor(timeStepIndex, cellResultSlot);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGeoMechPartMgr::appendGridPartsToModel(cvf::ModelBasicList* model)
{
for (size_t i = 0; i < m_femPartPartMgrs.size() ; ++i)
{
m_femPartPartMgrs[i]->appendPartsToModel(model);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGeoMechPartMgr::appendGridPartsToModel(cvf::ModelBasicList* model, const std::vector<size_t>& gridIndices)
{
for (size_t i = 0; i < gridIndices.size() ; ++i)
{
if (gridIndices[i] < m_femPartPartMgrs.size())
{
m_femPartPartMgrs[gridIndices[i]]->appendPartsToModel(model);
}
}
}

View File

@ -0,0 +1,66 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfArray.h"
#include "cvfCollection.h"
#include "RivFemPartPartMgr.h"
namespace cvf
{
class ModelBasicList;
class Transform;
}
class RimGeoMechResultSlot;
class RigGeoMechCaseData;
class RimGeoMechView;
//==================================================================================================
///
/// Class to handle visualization structures that embodies a complete Geo-mech reservoir at a specific
/// time step.
///
//==================================================================================================
class RivGeoMechPartMgr: public cvf::Object
{
public:
RivGeoMechPartMgr();
~RivGeoMechPartMgr();
void clearAndSetReservoir(const RigGeoMechCaseData* geoMechCase, RimGeoMechView* geomechView);
void setTransform(cvf::Transform* scaleTransform);
void setCellVisibility(size_t partIndex, cvf::UByteArray* cellVisibilities );
cvf::ref<cvf::UByteArray>
cellVisibility(size_t partIndex);
void updateCellColor(cvf::Color4f color);
void updateCellResultColor(size_t timeStepIndex, RimGeoMechResultSlot* cellResultSlot);
void appendGridPartsToModel(cvf::ModelBasicList* model, const std::vector<size_t>& partIndices);
void appendGridPartsToModel(cvf::ModelBasicList* model);
private:
cvf::Collection<RivFemPartPartMgr> m_femPartPartMgrs;
};

View File

@ -56,6 +56,8 @@ RimGeoMechView* RimGeoMechCase::createAndAddReservoirView()
RimGeoMechView* gmv = new RimGeoMechView();
size_t i = geoMechViews().size();
gmv->name = QString("View %1").arg(i + 1);
gmv->setGeoMechCase(this);
geoMechViews.push_back(gmv);
return gmv;

View File

@ -41,6 +41,9 @@ public:
void setFileName(const QString& fileName) {m_caseFileName = fileName;}
bool openGeoMechCase();
RigGeoMechCaseData* geoMechData() { return m_geoMechCaseData.p(); }
const RigGeoMechCaseData* geoMechData() const { return m_geoMechCaseData.p(); }
RimGeoMechView* createAndAddReservoirView();
virtual caf::PdmFieldHandle* userDescriptionField();

View File

@ -18,21 +18,28 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RimGeoMechView.h"
#include "RimReservoirView.h"
#include "Rim3dOverlayInfoConfig.h"
#include "RiaApplication.h"
#include "RiaPreferences.h"
#include "RimGeoMechResultSlot.h"
#include "RiuViewer.h"
#include "RiuMainWindow.h"
#include "cafCeetronPlusNavigation.h"
#include "cafCadNavigation.h"
#include "RimLegendConfig.h"
#include "cvfOverlayScalarMapperLegend.h"
#include "RimGeoMechCase.h"
#include "cvfPart.h"
#include "cvfViewport.h"
#include "cvfModelBasicList.h"
#include "cvfScene.h"
#include "RimReservoirView.h"
#include "RiuViewer.h"
#include "RivGeoMechPartMgr.h"
#include "RigGeoMechCaseData.h"
namespace caf {
@ -204,6 +211,63 @@ void RimGeoMechView::updateViewerWidgetWindowTitle()
//--------------------------------------------------------------------------------------------------
void RimGeoMechView::loadDataAndUpdate()
{
if (m_geomechCase)
{
m_geomechCase->openGeoMechCase();
}
updateViewerWidget();
createDisplayModelAndRedraw();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechView::createDisplayModelAndRedraw()
{
if (m_viewer && m_geomechCase)
{
cvf::ref<cvf::Transform> scaleTransform = new cvf::Transform();
scaleTransform->setLocalTransform(cvf::Mat4d::IDENTITY);
cvf::ref<cvf::ModelBasicList> cvfModel = new cvf::ModelBasicList;
m_geoMechVizModel = new RivGeoMechPartMgr();
m_geoMechVizModel->clearAndSetReservoir(m_geomechCase->geoMechData(), this);
for (int femPartIdx = 0; femPartIdx < m_geomechCase->geoMechData()->femParts()->partCount(); ++femPartIdx)
{
cvf::ref<cvf::UByteArray> elmVisibility = m_geoMechVizModel->cellVisibility(femPartIdx);
m_geoMechVizModel->setTransform(scaleTransform.p());
RivElmVisibilityCalculator::computeAllVisible(elmVisibility.p(), m_geomechCase->geoMechData()->femParts()->part(femPartIdx));
m_geoMechVizModel->setCellVisibility(femPartIdx, elmVisibility.p());
}
m_geoMechVizModel->appendGridPartsToModel(cvfModel.p());
cvf::ref<cvf::Scene> scene = new cvf::Scene;
scene->addModel(cvfModel.p());
m_viewer->setMainScene(scene.p());
m_viewer->update();
}
RiuMainWindow::instance()->refreshAnimationActions();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechView::setGeoMechCase(RimGeoMechCase* gmCase)
{
m_geomechCase = gmCase;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivElmVisibilityCalculator::computeAllVisible(cvf::UByteArray* elmVisibilities, const RigFemPart* femPart)
{
elmVisibilities->resize(femPart->elementCount());
elmVisibilities->setAll(true);
}

View File

@ -26,9 +26,15 @@
#include "cafPdmFieldCvfColor.h"
#include "cafPdmFieldCvfMat4d.h"
#include "cvfObject.h"
class RimGeoMechResultSlot;
class Rim3dOverlayInfoConfig;
class RiuViewer;
class RimGeoMechCase;
class RivGeoMechPartMgr;
class RigFemPart;
//==================================================================================================
///
@ -56,6 +62,8 @@ public:
FAULTS,
NO_SURFACE
};
void setGeoMechCase(RimGeoMechCase* gmCase);
void loadDataAndUpdate();
caf::PdmField<RimGeoMechResultSlot*> cellResult;
@ -78,5 +86,19 @@ protected:
private:
void updateViewerWidget();
void updateViewerWidgetWindowTitle();
void createDisplayModelAndRedraw();
QPointer<RiuViewer> m_viewer;
caf::PdmPointer<RimGeoMechCase> m_geomechCase;
cvf::ref<RivGeoMechPartMgr> m_geoMechVizModel;
};
#include "cvfArray.h"
class RivElmVisibilityCalculator
{
public:
static void computeAllVisible(cvf::UByteArray* elmVisibilities, const RigFemPart* femPart );
};