Merge pull request #715 from OPM/dev

Pull request for 1.6.0 for dev to master
This commit is contained in:
Magne Sjaastad 2016-01-11 12:10:04 +01:00
commit bde4d86b6b
377 changed files with 41430 additions and 4909 deletions

View File

@ -66,6 +66,7 @@
#include "RiuMainWindow.h"
#include "RiuProcessMonitor.h"
#include "RiuSelectionManager.h"
#include "RiuViewer.h"
#include "cafAppEnum.h"
@ -207,6 +208,35 @@ RiaApplication* RiaApplication::instance()
}
//--------------------------------------------------------------------------------------------------
/// Return -1 if unit test is not executed, returns 0 if test passed, returns 1 if tests failed
//--------------------------------------------------------------------------------------------------
int RiaApplication::parseArgumentsAndRunUnitTestsIfRequested()
{
cvf::ProgramOptions progOpt;
progOpt.registerOption("unittest", "", "Execute unit tests");
progOpt.setOptionPrefix(cvf::ProgramOptions::DOUBLE_DASH);
QStringList arguments = QCoreApplication::arguments();
bool parseOk = progOpt.parse(cvfqt::Utils::toStringVector(arguments));
if (!parseOk)
{
return -1;
}
// Unit testing
// --------------------------------------------------------
if (cvf::Option o = progOpt.option("unittest"))
{
int testReturnValue = launchUnitTestsWithConsole();
return testReturnValue;
}
return -1;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -350,7 +380,6 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi
{
//printf("Create well path collection for oil field %i in loadProject.\n", oilFieldIdx);
oilField->wellPathCollection = new RimWellPathCollection();
oilField->wellPathCollection->setProject(m_project);
}
if (oilField->wellPathCollection) oilField->wellPathCollection->readWellPathFiles();
@ -473,7 +502,6 @@ void RiaApplication::addWellPathsToModel(QList<QString> wellPathFilePaths)
{
//printf("Create well path collection.\n");
oilField->wellPathCollection = new RimWellPathCollection();
oilField->wellPathCollection->setProject(m_project);
m_project->updateConnectedEditors();
}
@ -496,7 +524,6 @@ void RiaApplication::addWellLogsToModel(const QList<QString>& wellLogFilePaths)
if (oilField->wellPathCollection == NULL)
{
oilField->wellPathCollection = new RimWellPathCollection();
oilField->wellPathCollection->setProject(m_project);
m_project->updateConnectedEditors();
}
@ -568,11 +595,20 @@ bool RiaApplication::saveProjectPromptForFileName()
bool RiaApplication::saveProjectAs(const QString& fileName)
{
m_project->fileName = fileName;
m_project->writeFile();
if (!m_project->writeFile())
{
QMessageBox::warning(NULL, "Error when saving project file", QString("Not possible to save project file. Make sure you have sufficient access rights.\n\nProject file location : %1").arg(fileName));
return false;
}
m_preferences->lastUsedProjectFileName = fileName;
caf::PdmSettings::writeFieldsToApplicationStore(m_preferences);
RiuMainWindow* mainWnd = RiuMainWindow::instance();
mainWnd->addRecentFiles(fileName);
return true;
}
@ -608,6 +644,8 @@ bool RiaApplication::closeProject(bool askToSaveIfDirty)
}
}
RiuSelectionManager::instance()->deleteAllItems();
mainWnd->cleanupGuiBeforeProjectClose();
caf::EffectGenerator::clearEffectCache();
@ -721,7 +759,7 @@ bool RiaApplication::openEclipseCase(const QString& caseName, const QString& cas
analysisModels->updateConnectedEditors();
RiuMainWindow::instance()->setCurrentObjectInTreeView(riv->cellResult());
RiuMainWindow::instance()->selectAsCurrentItem(riv->cellResult());
return true;
@ -757,7 +795,7 @@ bool RiaApplication::openInputEclipseCaseFromFileNames(const QStringList& fileNa
analysisModels->updateConnectedEditors();
RiuMainWindow::instance()->setCurrentObjectInTreeView(riv->cellResult());
RiuMainWindow::instance()->selectAsCurrentItem(riv->cellResult());
return true;
}
@ -803,7 +841,7 @@ bool RiaApplication::openOdbCaseFromFile(const QString& fileName)
m_project->updateConnectedEditors();
RiuMainWindow::instance()->setCurrentObjectInTreeView(riv->cellResult());
RiuMainWindow::instance()->selectAsCurrentItem(riv->cellResult());
return true;
}
@ -1140,34 +1178,36 @@ bool RiaApplication::parseArguments()
return false;
}
// Unit testing
// --------------------------------------------------------
if (cvf::Option o = progOpt.option("unittest"))
{
launchUnitTests();
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication::launchUnitTests()
int RiaApplication::launchUnitTests()
{
#ifdef USE_UNIT_TESTS
cvf::Assert::setReportMode(cvf::Assert::CONSOLE);
int argc = QCoreApplication::argc();
testing::InitGoogleTest(&argc, QCoreApplication::argv());
//int result = RUN_ALL_TESTS();
RUN_ALL_TESTS();
// Use this macro in main() to run all tests. It returns 0 if all
// tests are successful, or 1 otherwise.
//
// RUN_ALL_TESTS() should be invoked after the command line has been
// parsed by InitGoogleTest().
return RUN_ALL_TESTS();
#else
return -1;
#endif
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication::launchUnitTestsWithConsole()
int RiaApplication::launchUnitTestsWithConsole()
{
// Following code is taken from cvfAssert.cpp
#ifdef WIN32
@ -1215,7 +1255,7 @@ void RiaApplication::launchUnitTestsWithConsole()
}
#endif
launchUnitTests();
return launchUnitTests();
}
//--------------------------------------------------------------------------------------------------
@ -1334,7 +1374,7 @@ void RiaApplication::slotWorkerProcessFinished(int exitCode, QProcess::ExitStatu
}
// If multiple cases are present, invoke launchProcess() which will set next current case, and run script on this case
if (m_currentCaseIds.size() > 0)
if (!m_currentCaseIds.empty())
{
launchProcess(m_currentProgram, m_currentArguments);
}
@ -1353,7 +1393,7 @@ bool RiaApplication::launchProcess(const QString& program, const QStringList& ar
if (m_workerProcess == NULL)
{
// If multiple cases are present, pop the first case ID from the list and set as current case
if (m_currentCaseIds.size() > 0)
if (!m_currentCaseIds.empty())
{
int nextCaseId = m_currentCaseIds.front();
m_currentCaseIds.pop_front();
@ -1619,6 +1659,10 @@ void RiaApplication::saveSnapshotForAllViews(const QString& snapshotFolderName)
clearViewsScheduledForUpdate();
//riv->updateCurrentTimeStepAndRedraw();
riv->createDisplayModelAndRedraw();
viewer->repaint();
QString fileName = cas->caseUserDescription() + "-" + riv->name();
fileName.replace(" ", "_");
@ -1713,6 +1757,19 @@ void RiaApplication::runRegressionTest(const QString& testRootPath)
RiaImageCompareReporter imageCompareReporter;
// Minor workaround
// Use registry to define if interactive diff images should be created
// Defined by user in RiaRegressionTest
{
QSettings settings;
bool useInteractiveDiff = settings.value("showInteractiveDiffImages").toBool();
if (useInteractiveDiff)
{
imageCompareReporter.showInteractiveOnly();
}
}
for (int dirIdx = 0; dirIdx < folderList.size(); ++dirIdx)
{
QDir testCaseFolder(folderList[dirIdx].filePath());
@ -1731,21 +1788,6 @@ void RiaApplication::runRegressionTest(const QString& testRootPath)
// Open HTML report
QDesktopServices::openUrl(htmlReportFileName);
// Keep current preferences values to be able to restore when regression tests are completed
std::vector<QVariant> preferencesValues;
{
std::vector<caf::PdmFieldHandle*> fields;
this->preferences()->fields(fields);
for (size_t i = 0; i < fields.size(); i++)
{
QVariant v = fields[i]->uiCapability()->uiValue();
preferencesValues.push_back(v);
}
}
// Set preferences to make sure regression tests behave identical
this->preferences()->configureForRegressionTests();
for (int dirIdx = 0; dirIdx < folderList.size(); ++dirIdx)
{
QDir testCaseFolder(folderList[dirIdx].filePath());
@ -1785,18 +1827,6 @@ void RiaApplication::runRegressionTest(const QString& testRootPath)
closeProject(false);
}
// Restore preferences
{
std::vector<caf::PdmFieldHandle*> fields;
this->preferences()->fields(fields);
CVF_ASSERT(fields.size() == preferencesValues.size());
for (size_t i = 0; i < preferencesValues.size(); i++)
{
fields[i]->uiCapability()->setValueFromUi(preferencesValues[i]);
}
}
}
m_runningRegressionTests = false;
@ -1925,7 +1955,7 @@ bool RiaApplication::addEclipseCases(const QStringList& fileNames)
if (gridCaseGroup->statisticsCaseCollection()->reservoirs.size() > 0)
{
RiuMainWindow::instance()->setCurrentObjectInTreeView(gridCaseGroup->statisticsCaseCollection()->reservoirs[0]);
RiuMainWindow::instance()->selectAsCurrentItem(gridCaseGroup->statisticsCaseCollection()->reservoirs[0]);
}
return true;
@ -2158,16 +2188,16 @@ void RiaApplication::executeCommandObjects()
{
toBeRemoved->redo();
it++;
++it;
m_commandQueue.remove(toBeRemoved);
}
else
{
it++;
++it;
}
}
if (m_commandQueue.size() > 0)
if (!m_commandQueue.empty())
{
std::list< RimCommandObject* >::iterator it = m_commandQueue.begin();
@ -2245,19 +2275,6 @@ void RiaApplication::regressionTestConfigureProject()
// This size is set to match the regression test reference images
riv->viewer()->setFixedSize(1000, 745);
}
RimEclipseView* resvView = dynamic_cast<RimEclipseView*>(riv);
if (resvView)
{
resvView->faultCollection->setShowFaultsOutsideFilters(false);
caf::PdmUiFieldHandle* uiFieldHandle = resvView->faultResultSettings->showCustomFaultResult.uiCapability();
if (uiFieldHandle)
{
uiFieldHandle->setValueFromUi(false);
}
}
}
}
}

View File

@ -72,6 +72,7 @@ public:
~RiaApplication();
static RiaApplication* instance();
int parseArgumentsAndRunUnitTestsIfRequested();
bool parseArguments();
void executeRegressionTests(const QString& regressionTestPath);
@ -159,8 +160,8 @@ public:
bool isRunningRegressionTests() const;
void launchUnitTests();
void launchUnitTestsWithConsole();
int launchUnitTests();
int launchUnitTestsWithConsole();
private:
enum ProjectLoadAction

View File

@ -23,6 +23,9 @@
RiaImageCompareReporter::RiaImageCompareReporter(void)
{
m_showOriginal = true;
m_showGenerated = true;
m_showInteractiveDiff = false;
}
@ -68,6 +71,12 @@ void RiaImageCompareReporter::generateHTMLReport(const std::string& fileName)
html += "<html>\n";
html += "<head>\n";
html += "<title>Regression-Test Report</title>\n";
if (m_showInteractiveDiff)
{
html += cssString();
}
html += "</head>\n";
html += "\n";
html += "<body>\n";
@ -93,8 +102,21 @@ void RiaImageCompareReporter::generateHTMLReport(const std::string& fileName)
html += " </tr>\n";
html += " <tr>\n";
html += " <td> <img src=\"" + baseImageFolder + "/" + baseImageNames[fIdx] + "\" width=\"100%\" alt=\"" + baseImageFolder + "/" + baseImageNames[fIdx] + "\" > </td>\n";
html += " <td> <img src=\"" + genImageFolder + "/" + baseImageNames[fIdx] + "\" width=\"100%\" alt=\"" + genImageFolder + "/" + baseImageNames[fIdx] + "\" > </td>\n";
if (m_showOriginal)
{
html += " <td> <img src=\"" + baseImageFolder + "/" + baseImageNames[fIdx] + "\" width=\"100%\" alt=\"" + baseImageFolder + "/" + baseImageNames[fIdx] + "\" > </td>\n";
}
if (m_showGenerated)
{
html += " <td> <img src=\"" + genImageFolder + "/" + baseImageNames[fIdx] + "\" width=\"100%\" alt=\"" + genImageFolder + "/" + baseImageNames[fIdx] + "\" > </td>\n";
}
if (m_showInteractiveDiff)
{
html += " <td> <div class = \"image-slider\"> <div> <img src=\"" + baseImageFolder + "/" + baseImageNames[fIdx] + "\" > </div> <img src = \"" + genImageFolder + "/" + baseImageNames[fIdx] + "\" > </div> </td>\n";
}
html += " <td> <img src=\"" + diffImageFolder + "/" + baseImageNames[fIdx] + "\" width=\"100%\" alt=\"" + diffImageFolder + "/" + baseImageNames[fIdx] + "\" > </td>\n";
html += " </tr>\n";
@ -110,6 +132,16 @@ void RiaImageCompareReporter::generateHTMLReport(const std::string& fileName)
output << html;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaImageCompareReporter::showInteractiveOnly()
{
m_showOriginal = false;
m_showGenerated = false;
m_showInteractiveDiff = true;
}
//--------------------------------------------------------------------------------------------------
/// Retuns the names of the *.png files in a directory. The names are without path, but with extention
//--------------------------------------------------------------------------------------------------
@ -133,3 +165,51 @@ std::vector<std::string> RiaImageCompareReporter::getPngFilesInDirectory(const s
return fileNames;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string RiaImageCompareReporter::cssString() const
{
std::string html;
html += "<style media=\"screen\" type=\"text/css\">";
html += "";
html += ".image-slider {";
html += "position:relative;";
html += "display: inline-block;";
html += "line-height: 0;";
html += "}";
html += ".image-slider > div {";
html += "position: absolute;";
html += "top: 0; bottom: 0; left: 0;";
html += "width: 25px;";
html += "max-width: 100%;";
html += "overflow: hidden;";
html += "resize: horizontal;";
html += "}";
html += ".image-slider > div:before {";
html += "content: '';";
html += "position: absolute;";
html += "right: 0; bottom: 0;";
html += "width: 23px; height: 23px;";
html += "padding: 5px;";
html += "background: linear-gradient(-45deg, gray 50%, transparent 0);";
html += "background-clip: content-box;";
html += "cursor: ew-resize;";
html += "-webkit-filter: drop-shadow(0 0 6px black);";
html += "filter: drop-shadow(0 0 6px black);";
html += "}";
html += ".image-slider img {";
html += "user-select: none;";
html += "max-width: 1000px;";
html += "}";
html += "</style>";
return html;
}

View File

@ -30,10 +30,14 @@ public:
void addImageDirectoryComparisonSet(const std::string& title, const std::string& baseImageDir, const std::string& newImagesDir, const std::string& diffImagesDir );
void generateHTMLReport(const std::string& filenName);
void showInteractiveOnly();
private:
static std::vector<std::string> getPngFilesInDirectory(const std::string& searchPath);
std::string cssString() const;
private:
struct DirSet
{
DirSet(const std::string& title, const std::string& baseImageDir, const std::string& newImagesDir, const std::string& diffImagesDir )
@ -50,5 +54,9 @@ private:
};
std::vector<DirSet> m_directorySets;
bool m_showOriginal;
bool m_showGenerated;
bool m_showInteractiveDiff;
};

View File

@ -90,7 +90,7 @@ RiaPreferences::RiaPreferences(void)
//--------------------------------------------------------------------------------------------------
RiaPreferences::~RiaPreferences(void)
{
delete readerSettings;
}
//--------------------------------------------------------------------------------------------------

View File

@ -32,6 +32,8 @@ RiaRegressionTest::RiaRegressionTest(void)
CAF_PDM_InitFieldNoDefault(&regressionTestFolder, "regressionTestFolder", "Regression Test Folder", "", "", "");
regressionTestFolder.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
CAF_PDM_InitField(&showInteractiveDiffImages, "showInteractiveDiffImages", false, "Interactive diff images", "", "", "");
}
//--------------------------------------------------------------------------------------------------

View File

@ -35,6 +35,7 @@ public:
public:
caf::PdmField<QString> applicationWorkingFolder;
caf::PdmField<QString> regressionTestFolder;
caf::PdmField<bool> showInteractiveDiffImages;
protected:
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute);

View File

@ -31,6 +31,7 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/FileInterface
${CMAKE_CURRENT_SOURCE_DIR}/SocketInterface
${CMAKE_CURRENT_SOURCE_DIR}/ModelVisualization
${CMAKE_CURRENT_SOURCE_DIR}/ModelVisualization/GridBox
${CMAKE_CURRENT_SOURCE_DIR}/UserInterface
${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel
${CMAKE_CURRENT_SOURCE_DIR}/ResultStatisticsCache
@ -60,8 +61,6 @@ set( APPLICATION_FILES
Application/RiaImageCompareReporter.cpp
Application/RiaProjectModifier.cpp
Application/RiaRegressionTest.cpp
${ResInsight_SOURCE_DIR}/ThirdParty/gtest/gtest-all.cc
)
set( USER_INTERFACE_FILES
@ -84,12 +83,20 @@ set( USER_INTERFACE_FILES
UserInterface/RiuTreeViewEventFilter.h
UserInterface/RiuWellLogPlot.cpp
UserInterface/RiuWellLogPlot.h
UserInterface/RiuWellLogPlotCurve.cpp
UserInterface/RiuWellLogPlotCurve.h
UserInterface/RiuWellLogTrackPlot.cpp
UserInterface/RiuWellLogTrackPlot.h
UserInterface/RiuLineSegmentQwtPlotCurve.cpp
UserInterface/RiuLineSegmentQwtPlotCurve.h
UserInterface/RiuWellLogTrack.cpp
UserInterface/RiuWellLogTrack.h
UserInterface/RiuProjectPropertyView.h
UserInterface/RiuProjectPropertyView.cpp
UserInterface/RiuResultQwtPlot.h
UserInterface/RiuResultQwtPlot.cpp
UserInterface/RiuSelectionManager.h
UserInterface/RiuSelectionManager.cpp
UserInterface/RiuSelectionColors.h
UserInterface/RiuSelectionColors.cpp
UserInterface/RiuSelectionChangedHandler.h
UserInterface/RiuSelectionChangedHandler.cpp
)
set( SOCKET_INTERFACE_FILES
@ -103,12 +110,6 @@ set( SOCKET_INTERFACE_FILES
SocketInterface/RiaSocketDataTransfer.cpp
)
set( UNIT_TEST_FILES
ProjectDataModel/ProjectDataModel_UnitTests/RimWellLogExtractionCurveImpl-Test.cpp
ProjectDataModel/ProjectDataModel_UnitTests/WellPathAsciiFileReader-Test.cpp
)
list( APPEND CPP_SOURCES
${APPLICATION_FILES}
${USER_INTERFACE_FILES}
@ -116,24 +117,41 @@ list( APPEND CPP_SOURCES
${UNIT_TEST_FILES}
)
list( APPEND REFERENCED_CMAKE_FILES
ReservoirDataModel/CMakeLists_files.cmake
ReservoirDataModel/CMakeLists_filesNotToUnitTest.cmake
FileInterface/CMakeLists_files.cmake
ProjectDataModel/CMakeLists_files.cmake
GeoMech/GeoMechVisualization/CMakeLists_files.cmake
ModelVisualization/CMakeLists_files.cmake
GeoMech/GeoMechVisualization/CMakeLists_files.cmake
Commands/CMakeLists_files.cmake
ModelVisualization/GridBox/CMakeLists_files.cmake
Commands/CMakeLists_files.cmake
Commands/OperationsUsingObjReferences/CMakeLists_files.cmake
Commands/ToggleCommands/CMakeLists_files.cmake
Commands/OctaveScriptCommands/CMakeLists_files.cmake
Commands/ViewLink/CMakeLists_files.cmake
Commands/WellLogCommands/CMakeLists_files.cmake
Commands/WellPathCommands/CMakeLists_files.cmake
Commands/CrossSectionCommands/CMakeLists_files.cmake
)
option (RESINSIGHT_INCLUDE_APPLICATION_UNIT_TESTS "Include ApplicationCode Unit Tests" OFF)
if (RESINSIGHT_INCLUDE_APPLICATION_UNIT_TESTS)
add_definitions(-DUSE_UNIT_TESTS)
list( APPEND REFERENCED_CMAKE_FILES
UnitTests/CMakeLists_files.cmake
)
list( APPEND CPP_SOURCES
${ResInsight_SOURCE_DIR}/ThirdParty/gtest/gtest-all.cc
)
endif()
# Include source file lists from *.cmake files
foreach (referencedfile ${REFERENCED_CMAKE_FILES})
include (${referencedfile})
@ -182,7 +200,7 @@ set ( QT_MOC_HEADERS
UserInterface/RiuViewerCommands.h
UserInterface/RiuTreeViewEventFilter.h
UserInterface/RiuWellLogPlot.h
UserInterface/RiuWellLogTrackPlot.h
UserInterface/RiuWellLogTrack.h
)
qt4_wrap_cpp( MOC_FILES_CPP ${QT_MOC_HEADERS} )
@ -487,6 +505,12 @@ if (RESINSIGHT_PRIVATE_INSTALL)
set (RESINSIGHT_FILES ${RESINSIGHT_FILES} ${RI_ALL_ODB_DLLS})
endif()
# CRT
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP ON)
set(CMAKE_INSTALL_OPENMP_LIBRARIES ON)
include(InstallRequiredSystemLibraries)
install(PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} DESTINATION ${RESINSIGHT_FINAL_NAME})
endif()
set (RESINSIGHT_FILES ${RESINSIGHT_FILES} ${RESINSIGHT_LICENSE_FILES})

View File

@ -49,6 +49,8 @@ ${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.h
${CEE_CURRENT_LIST_DIR}RicDeleteItemExec.h
${CEE_CURRENT_LIST_DIR}RicDeleteItemExecData.h
${CEE_CURRENT_LIST_DIR}RicDeleteItemFeature.h
${CEE_CURRENT_LIST_DIR}RicCommandFeature.h
)
set (SOURCE_GROUP_SOURCE_FILES

View File

@ -0,0 +1,29 @@
# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly
if (${CMAKE_VERSION} VERSION_GREATER "2.8.2")
set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/)
endif()
set (SOURCE_GROUP_HEADER_FILES
${CEE_CURRENT_LIST_DIR}RicAppendCrossSectionFeature.h
${CEE_CURRENT_LIST_DIR}RicNewSimWellCrossSectionFeature.h
${CEE_CURRENT_LIST_DIR}RicNewWellPathCrossSectionFeature.h
${CEE_CURRENT_LIST_DIR}RicNewPolylineCrossSectionFeature.h
)
set (SOURCE_GROUP_SOURCE_FILES
${CEE_CURRENT_LIST_DIR}RicAppendCrossSectionFeature.cpp
${CEE_CURRENT_LIST_DIR}RicNewSimWellCrossSectionFeature.cpp
${CEE_CURRENT_LIST_DIR}RicNewWellPathCrossSectionFeature.cpp
${CEE_CURRENT_LIST_DIR}RicNewPolylineCrossSectionFeature.cpp
)
list(APPEND CODE_HEADER_FILES
${SOURCE_GROUP_HEADER_FILES}
)
list(APPEND CODE_SOURCE_FILES
${SOURCE_GROUP_SOURCE_FILES}
)
source_group( "CommandFeature\\CrossSection" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake )

View File

@ -0,0 +1,110 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicAppendCrossSectionFeature.h"
#include "RimCrossSection.h"
#include "RimCrossSectionCollection.h"
#include "cafCmdExecCommandManager.h"
#include "cafSelectionManager.h"
#include "cvfAssert.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicAppendCrossSectionFeature, "RicAppendCrossSectionFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicAppendCrossSectionFeature::isCommandEnabled()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicAppendCrossSectionFeature::onActionTriggered(bool isChecked)
{
std::vector<caf::PdmObjectHandle*> collection;
caf::SelectionManager::instance()->objectsByType(&collection);
CVF_ASSERT(collection.size() == 1);
RimCrossSectionCollection* crossSectionCollection = NULL;
collection[0]->firstAnchestorOrThisOfType(crossSectionCollection);
CVF_ASSERT(crossSectionCollection);
RicAppendCrossSectionFeatureCmd* cmd = new RicAppendCrossSectionFeatureCmd(crossSectionCollection);
caf::CmdExecCommandManager::instance()->processExecuteCommand(cmd);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicAppendCrossSectionFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setIcon(QIcon(":/CrossSection16x16.png"));
actionToSetup->setText("New Intersection");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicAppendCrossSectionFeatureCmd::RicAppendCrossSectionFeatureCmd(RimCrossSectionCollection* crossSectionCollection)
: CmdExecuteCommand(NULL),
m_crossSectionCollection(crossSectionCollection)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicAppendCrossSectionFeatureCmd::~RicAppendCrossSectionFeatureCmd()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicAppendCrossSectionFeatureCmd::name()
{
return "New Intersection";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicAppendCrossSectionFeatureCmd::redo()
{
CVF_ASSERT(m_crossSectionCollection);
RimCrossSection* crossSection = new RimCrossSection();
crossSection->name = QString("Intersection");
m_crossSectionCollection->appendCrossSection(crossSection);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicAppendCrossSectionFeatureCmd::undo()
{
}

View File

@ -0,0 +1,62 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cafCmdFeature.h"
#include "cafCmdExecuteCommand.h"
#include "cafPdmPointer.h"
class RimCrossSectionCollection;
//==================================================================================================
///
//==================================================================================================
class RicAppendCrossSectionFeatureCmd : public caf::CmdExecuteCommand
{
public:
RicAppendCrossSectionFeatureCmd(RimCrossSectionCollection* crossSectionCollection);
virtual ~RicAppendCrossSectionFeatureCmd();
virtual QString name();
virtual void redo();
virtual void undo();
private:
caf::PdmPointer<RimCrossSectionCollection> m_crossSectionCollection;
};
//==================================================================================================
///
//==================================================================================================
class RicAppendCrossSectionFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered( bool isChecked );
virtual void setupActionLook( QAction* actionToSetup );
};

View File

@ -0,0 +1,157 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicNewPolylineCrossSectionFeature.h"
#include "RiaApplication.h"
#include "RimCase.h"
#include "RimCrossSection.h"
#include "RimCrossSectionCollection.h"
#include "RimView.h"
#include "RiuMainWindow.h"
#include "RiuSelectionManager.h"
#include "cafCmdExecCommandManager.h"
#include "cafSelectionManager.h"
#include "cvfAssert.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicNewPolylineCrossSectionFeature, "RicNewPolylineCrossSectionFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicNewPolylineCrossSectionFeature::RicNewPolylineCrossSectionFeature()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewPolylineCrossSectionFeature::isCommandEnabled()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewPolylineCrossSectionFeature::onActionTriggered(bool isChecked)
{
RimView* activeView = RiaApplication::instance()->activeReservoirView();
if (!activeView) return;
RicNewPolylineCrossSectionFeatureCmd* cmd = new RicNewPolylineCrossSectionFeatureCmd(activeView->crossSectionCollection);
caf::CmdExecCommandManager::instance()->processExecuteCommand(cmd);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewPolylineCrossSectionFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setIcon(QIcon(":/CrossSection16x16.png"));
actionToSetup->setText("New Polyline Intersection");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewPolylineCrossSectionFeature::handleEvent(cvf::Object* eventObject)
{
std::vector<RimCrossSection*> selection;
caf::SelectionManager::instance()->objectsByType(&selection);
if (selection.size() == 1)
{
RicViewerEventObject* polylineUiEvent = dynamic_cast<RicViewerEventObject*>(eventObject);
if (polylineUiEvent)
{
RimCrossSection* crossSection = selection[0];
if (crossSection->inputFromViewerEnabled())
{
RimCase* rimCase = NULL;
crossSection->firstAnchestorOrThisOfType(rimCase);
CVF_ASSERT(rimCase);
crossSection->appendPointToPolyLine(rimCase->displayModelOffset() + polylineUiEvent->localIntersectionPoint);
// Further Ui processing is stopped when true is returned
return true;
}
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicNewPolylineCrossSectionFeatureCmd::RicNewPolylineCrossSectionFeatureCmd(RimCrossSectionCollection* crossSectionCollection)
: CmdExecuteCommand(NULL),
m_crossSectionCollection(crossSectionCollection)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicNewPolylineCrossSectionFeatureCmd::~RicNewPolylineCrossSectionFeatureCmd()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicNewPolylineCrossSectionFeatureCmd::name()
{
return "Start Polyline Intersection";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewPolylineCrossSectionFeatureCmd::redo()
{
CVF_ASSERT(m_crossSectionCollection);
RimCrossSection* crossSection = new RimCrossSection();
crossSection->name = "Polyline";
crossSection->type = RimCrossSection::CS_POLYLINE;
crossSection->inputFromViewerEnabled = true;
m_crossSectionCollection->appendCrossSection(crossSection);
RiuSelectionManager::instance()->deleteAllItems();
RiuMainWindow::instance()->selectAsCurrentItem(crossSection);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewPolylineCrossSectionFeatureCmd::undo()
{
}

View File

@ -0,0 +1,72 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicViewerEventInterface.h"
#include "cafCmdExecuteCommand.h"
#include "cafPdmPointer.h"
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfVector3.h"
class RimCrossSectionCollection;
//==================================================================================================
///
//==================================================================================================
class RicNewPolylineCrossSectionFeatureCmd : public caf::CmdExecuteCommand
{
public:
RicNewPolylineCrossSectionFeatureCmd(RimCrossSectionCollection* crossSectionCollection);
virtual ~RicNewPolylineCrossSectionFeatureCmd();
virtual QString name();
virtual void redo();
virtual void undo();
private:
caf::PdmPointer<RimCrossSectionCollection> m_crossSectionCollection;
};
//==================================================================================================
///
//==================================================================================================
class RicNewPolylineCrossSectionFeature : public caf::CmdFeature, public RicViewerEventInterface
{
CAF_CMD_HEADER_INIT;
public:
RicNewPolylineCrossSectionFeature();
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered( bool isChecked );
virtual void setupActionLook( QAction* actionToSetup );
virtual bool handleEvent(cvf::Object* eventObject);
};

View File

@ -0,0 +1,118 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicNewSimWellCrossSectionFeature.h"
#include "RimCrossSection.h"
#include "RimCrossSectionCollection.h"
#include "RimEclipseView.h"
#include "RimEclipseWell.h"
#include "cafCmdExecCommandManager.h"
#include "cafSelectionManager.h"
#include "cvfAssert.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicNewSimWellCrossSectionFeature, "RicNewSimWellCrossSectionFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewSimWellCrossSectionFeature::isCommandEnabled()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewSimWellCrossSectionFeature::onActionTriggered(bool isChecked)
{
std::vector<RimEclipseWell*> collection;
caf::SelectionManager::instance()->objectsByType(&collection);
CVF_ASSERT(collection.size() == 1);
RimEclipseWell* eclWell = collection[0];
RimEclipseView* eclView = NULL;
eclWell->firstAnchestorOrThisOfType(eclView);
CVF_ASSERT(eclView);
RicNewSimWellCrossSectionCmd* cmd = new RicNewSimWellCrossSectionCmd(eclView->crossSectionCollection, eclWell);
caf::CmdExecCommandManager::instance()->processExecuteCommand(cmd);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewSimWellCrossSectionFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setIcon(QIcon(":/CrossSection16x16.png"));
actionToSetup->setText("New Intersection");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicNewSimWellCrossSectionCmd::RicNewSimWellCrossSectionCmd(RimCrossSectionCollection* crossSectionCollection, RimEclipseWell* simWell)
: CmdExecuteCommand(NULL),
m_crossSectionCollection(crossSectionCollection),
m_wellPath(simWell)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicNewSimWellCrossSectionCmd::~RicNewSimWellCrossSectionCmd()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicNewSimWellCrossSectionCmd::name()
{
return "Create Intersection From Well";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewSimWellCrossSectionCmd::redo()
{
CVF_ASSERT(m_crossSectionCollection);
CVF_ASSERT(m_wellPath);
RimCrossSection* crossSection = new RimCrossSection();
crossSection->name = m_wellPath->name;
crossSection->type = RimCrossSection::CS_SIMULATION_WELL;
crossSection->simulationWell = m_wellPath;
m_crossSectionCollection->appendCrossSection(crossSection);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewSimWellCrossSectionCmd::undo()
{
}

View File

@ -0,0 +1,64 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cafCmdFeature.h"
#include "cafCmdExecuteCommand.h"
#include "cafPdmPointer.h"
class RimCrossSectionCollection;
class RimEclipseWell;
//==================================================================================================
///
//==================================================================================================
class RicNewSimWellCrossSectionCmd : public caf::CmdExecuteCommand
{
public:
RicNewSimWellCrossSectionCmd(RimCrossSectionCollection* crossSectionCollection, RimEclipseWell* simWell);
virtual ~RicNewSimWellCrossSectionCmd();
virtual QString name();
virtual void redo();
virtual void undo();
private:
caf::PdmPointer<RimCrossSectionCollection> m_crossSectionCollection;
caf::PdmPointer<RimEclipseWell> m_wellPath;
};
//==================================================================================================
///
//==================================================================================================
class RicNewSimWellCrossSectionFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered( bool isChecked );
virtual void setupActionLook( QAction* actionToSetup );
};

View File

@ -0,0 +1,127 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicNewWellPathCrossSectionFeature.h"
#include "RiaApplication.h"
#include "RimCrossSection.h"
#include "RimCrossSectionCollection.h"
#include "RimWellPath.h"
#include "RimView.h"
#include "cafCmdExecCommandManager.h"
#include "cafSelectionManager.h"
#include "cvfAssert.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicNewWellPathCrossSectionFeature, "RicNewWellPathCrossSectionFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicNewWellPathCrossSectionFeature::RicNewWellPathCrossSectionFeature()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewWellPathCrossSectionFeature::isCommandEnabled()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewWellPathCrossSectionFeature::onActionTriggered(bool isChecked)
{
RimView* activeView = RiaApplication::instance()->activeReservoirView();
if (!activeView) return;
std::vector<RimWellPath*> collection;
caf::SelectionManager::instance()->objectsByType(&collection);
CVF_ASSERT(collection.size() == 1);
RimWellPath* wellPath = collection[0];
RicNewWellPathCrossSectionFeatureCmd* cmd = new RicNewWellPathCrossSectionFeatureCmd(activeView->crossSectionCollection, wellPath);
caf::CmdExecCommandManager::instance()->processExecuteCommand(cmd);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewWellPathCrossSectionFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setIcon(QIcon(":/CrossSection16x16.png"));
actionToSetup->setText("New Intersection");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicNewWellPathCrossSectionFeatureCmd::RicNewWellPathCrossSectionFeatureCmd(RimCrossSectionCollection* crossSectionCollection, RimWellPath* wellPath)
: CmdExecuteCommand(NULL),
m_crossSectionCollection(crossSectionCollection),
m_wellPath(wellPath)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicNewWellPathCrossSectionFeatureCmd::~RicNewWellPathCrossSectionFeatureCmd()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicNewWellPathCrossSectionFeatureCmd::name()
{
return "Create Intersection From Well Path";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewWellPathCrossSectionFeatureCmd::redo()
{
CVF_ASSERT(m_crossSectionCollection);
CVF_ASSERT(m_wellPath);
RimCrossSection* crossSection = new RimCrossSection();
crossSection->name = m_wellPath->name;
crossSection->type = RimCrossSection::CS_WELL_PATH;
crossSection->wellPath = m_wellPath;
m_crossSectionCollection->appendCrossSection(crossSection);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewWellPathCrossSectionFeatureCmd::undo()
{
}

View File

@ -0,0 +1,67 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cafCmdFeature.h"
#include "cafCmdExecuteCommand.h"
#include "cafPdmPointer.h"
class RimCrossSectionCollection;
class RimWellPath;
//==================================================================================================
///
//==================================================================================================
class RicNewWellPathCrossSectionFeatureCmd : public caf::CmdExecuteCommand
{
public:
RicNewWellPathCrossSectionFeatureCmd(RimCrossSectionCollection* crossSectionCollection, RimWellPath* wellPath);
virtual ~RicNewWellPathCrossSectionFeatureCmd();
virtual QString name();
virtual void redo();
virtual void undo();
private:
caf::PdmPointer<RimCrossSectionCollection> m_crossSectionCollection;
caf::PdmPointer<RimWellPath> m_wellPath;
};
//==================================================================================================
///
//==================================================================================================
class RicNewWellPathCrossSectionFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
RicNewWellPathCrossSectionFeature();
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered( bool isChecked );
virtual void setupActionLook( QAction* actionToSetup );
};

View File

@ -81,30 +81,31 @@ void RicPasteEclipseViewsFeature::onActionTriggered(bool isChecked)
if (objectGroup.objects.size() == 0) return;
std::vector<caf::PdmPointer<RimEclipseView> > eclipseViews;
objectGroup.createCopyByType(&eclipseViews, PdmDefaultObjectFactory::instance());
objectGroup.objectsByType(&eclipseViews);
if (eclipseViews.size() != 0)
// Add cases to case group
for (size_t i = 0; i < eclipseViews.size(); i++)
{
// Add cases to case group
for (size_t i = 0; i < eclipseViews.size(); i++)
{
RimEclipseView* rimReservoirView = eclipseViews[i];
QString nameOfCopy = QString("Copy of ") + rimReservoirView->name;
rimReservoirView->name = nameOfCopy;
eclipseCase->reservoirViews().push_back(rimReservoirView);
RimEclipseView* rimReservoirView = dynamic_cast<RimEclipseView*>(eclipseViews[i]->xmlCapability()->copyByXmlSerialization(PdmDefaultObjectFactory::instance()));
CVF_ASSERT(rimReservoirView);
// Delete all wells to be able to copy/paste between cases, as the wells differ between cases
rimReservoirView->wellCollection()->wells().deleteAllChildObjects();
QString nameOfCopy = QString("Copy of ") + rimReservoirView->name;
rimReservoirView->name = nameOfCopy;
eclipseCase->reservoirViews().push_back(rimReservoirView);
rimReservoirView->initAfterReadRecursively();
rimReservoirView->setEclipseCase(eclipseCase);
rimReservoirView->setEclipseCase(eclipseCase);
caf::PdmDocument::updateUiIconStateRecursively(rimReservoirView);
// Resolve references after reservoir view has been inserted into Rim structures
// Intersections referencing a well path/ simulation well requires this
// TODO: initAfterReadRecursively can probably be removed
rimReservoirView->initAfterReadRecursively();
rimReservoirView->resolveReferencesRecursively();
rimReservoirView->loadDataAndUpdate();
rimReservoirView->loadDataAndUpdate();
eclipseCase->updateConnectedEditors();
}
caf::PdmDocument::updateUiIconStateRecursively(rimReservoirView);
eclipseCase->updateConnectedEditors();
}
}

View File

@ -75,27 +75,28 @@ void RicPasteGeoMechViewsFeature::onActionTriggered(bool isChecked)
if (objectGroup.objects.size() == 0) return;
std::vector<caf::PdmPointer<RimGeoMechView> > geomViews;
objectGroup.createCopyByType(&geomViews, PdmDefaultObjectFactory::instance());
objectGroup.objectsByType(&geomViews);
if (geomViews.size() != 0)
// Add cases to case group
for (size_t i = 0; i < geomViews.size(); i++)
{
// Add cases to case group
for (size_t i = 0; i < geomViews.size(); i++)
{
RimGeoMechView* rimReservoirView = geomViews[i];
QString nameOfCopy = QString("Copy of ") + rimReservoirView->name;
rimReservoirView->name = nameOfCopy;
geomCase->geoMechViews().push_back(rimReservoirView);
RimGeoMechView* rimReservoirView = dynamic_cast<RimGeoMechView*>(geomViews[i]->xmlCapability()->copyByXmlSerialization(PdmDefaultObjectFactory::instance()));
QString nameOfCopy = QString("Copy of ") + rimReservoirView->name;
rimReservoirView->name = nameOfCopy;
geomCase->geoMechViews().push_back(rimReservoirView);
rimReservoirView->initAfterReadRecursively();
rimReservoirView->setGeoMechCase(geomCase);
rimReservoirView->setGeoMechCase(geomCase);
caf::PdmDocument::updateUiIconStateRecursively(rimReservoirView);
// Resolve references after reservoir view has been inserted into Rim structures
// Intersections referencing a well path requires this
rimReservoirView->initAfterReadRecursively();
rimReservoirView->resolveReferencesRecursively();
rimReservoirView->loadDataAndUpdate();
caf::PdmDocument::updateUiIconStateRecursively(rimReservoirView);
geomCase->updateConnectedEditors();
}
rimReservoirView->loadDataAndUpdate();
geomCase->updateConnectedEditors();
}
}

View File

@ -22,6 +22,7 @@
#include "RicDeleteItemExecData.h"
#include "RimCellRangeFilterCollection.h"
#include "RimCrossSectionCollection.h"
#include "RimEclipsePropertyFilterCollection.h"
#include "RimGeoMechPropertyFilterCollection.h"
#include "RimProject.h"
@ -29,7 +30,7 @@
#include "RimViewLinkerCollection.h"
#include "RimWellLogPlot.h"
#include "RimWellLogPlotCollection.h"
#include "RimWellLogPlotTrack.h"
#include "RimWellLogTrack.h"
#include "RimWellPathCollection.h"
#include "cafNotificationCenter.h"
@ -102,6 +103,13 @@ void RicDeleteItemExec::redo()
view->scheduleCreateDisplayModelAndRedraw();
}
RimCrossSectionCollection* crossSectionColl;
parentObj->firstAnchestorOrThisOfType(crossSectionColl);
if (view && crossSectionColl)
{
view->scheduleCreateDisplayModelAndRedraw();
}
RimWellPathCollection* wellPathColl;
parentObj->firstAnchestorOrThisOfType(wellPathColl);
@ -117,14 +125,14 @@ void RicDeleteItemExec::redo()
if (wellLogPlot)
{
wellLogPlot->calculateAvailableDepthRange();
wellLogPlot->zoomAllDepth();
wellLogPlot->updateDepthZoom();
}
RimWellLogPlotTrack* wellLogPlotTrack;
RimWellLogTrack* wellLogPlotTrack;
parentObj->firstAnchestorOrThisOfType(wellLogPlotTrack);
if (wellLogPlotTrack)
{
wellLogPlotTrack->zoomAllXAxis();
wellLogPlotTrack->zoomAllXAxisIfAutoScale();
}
// Update due to delete plots

View File

@ -22,7 +22,7 @@
#include "RicDeleteItemExecData.h"
#include "RimWellLogPlot.h"
#include "RimWellLogPlotTrack.h"
#include "RimWellLogTrack.h"
#include "cafCmdExecCommandManager.h"
#include "cafCmdSelectionHelper.h"

View File

@ -73,7 +73,7 @@ void RicEclipseCaseNewGroupExec::redo()
analysisModels->caseGroups().push_back(createdObject);
analysisModels->updateConnectedEditors();
RiuMainWindow::instance()->setCurrentObjectInTreeView(createdObject);
RiuMainWindow::instance()->selectAsCurrentItem(createdObject);
RiuMainWindow::instance()->setExpanded(createdObject, true);
}
}

View File

@ -65,7 +65,7 @@ void RicEclipsePropertyFilterFeatureImpl::addPropertyFilter(RimEclipsePropertyFi
propertyFilterCollection->reservoirView()->scheduleGeometryRegen(PROPERTY_FILTERED);
propertyFilterCollection->updateConnectedEditors();
RiuMainWindow::instance()->setCurrentObjectInTreeView(propertyFilter);
RiuMainWindow::instance()->selectAsCurrentItem(propertyFilter);
}
@ -81,7 +81,7 @@ void RicEclipsePropertyFilterFeatureImpl::insertPropertyFilter(RimEclipsePropert
propertyFilterCollection->reservoirView()->scheduleGeometryRegen(PROPERTY_FILTERED);
propertyFilterCollection->updateConnectedEditors();
RiuMainWindow::instance()->setCurrentObjectInTreeView(propertyFilter);
RiuMainWindow::instance()->selectAsCurrentItem(propertyFilter);
}
//--------------------------------------------------------------------------------------------------

View File

@ -19,7 +19,7 @@
#include "RicExportToLasFileFeature.h"
#include "RimWellLogPlotCurve.h"
#include "RimWellLogCurve.h"
#include "RigWellLogFile.h"
#include "RiuMainWindow.h"
@ -46,7 +46,7 @@ bool RicExportToLasFileFeature::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
void RicExportToLasFileFeature::onActionTriggered(bool isChecked)
{
RimWellLogPlotCurve* curve = selectedWellLogPlotCurve();
RimWellLogCurve* curve = selectedWellLogPlotCurve();
if (curve)
{
QString defaultDir = RiaApplication::instance()->defaultFileDialogDirectory("WELL_LOGS_DIR");
@ -54,6 +54,8 @@ void RicExportToLasFileFeature::onActionTriggered(bool isChecked)
QString defaultFileName = curve->name().trimmed();
defaultFileName.replace(".", "_");
defaultFileName.replace(",", "_");
defaultFileName.replace(":", "_");
defaultFileName.replace(";", "_");
defaultFileName.replace(" ", "_");
defaultFileName.replace(QRegExp("_+"), "_");
defaultFileName.append(".las");
@ -77,9 +79,9 @@ void RicExportToLasFileFeature::setupActionLook(QAction* actionToSetup)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogPlotCurve* RicExportToLasFileFeature::selectedWellLogPlotCurve() const
RimWellLogCurve* RicExportToLasFileFeature::selectedWellLogPlotCurve() const
{
std::vector<RimWellLogPlotCurve*> selection;
std::vector<RimWellLogCurve*> selection;
caf::SelectionManager::instance()->objectsByType(&selection);
if (selection.size() > 0)

View File

@ -23,7 +23,7 @@
#include <vector>
class RimWellLogPlotCurve;
class RimWellLogCurve;
//==================================================================================================
///
@ -39,7 +39,7 @@ protected:
virtual void setupActionLook( QAction* actionToSetup );
private:
RimWellLogPlotCurve* selectedWellLogPlotCurve() const;
RimWellLogCurve* selectedWellLogPlotCurve() const;
};

View File

@ -66,7 +66,7 @@ void RicGeoMechPropertyFilterFeatureImpl::addPropertyFilter(RimGeoMechPropertyFi
propertyFilterCollection->reservoirView()->scheduleCreateDisplayModelAndRedraw();
propertyFilterCollection->updateConnectedEditors();
RiuMainWindow::instance()->setCurrentObjectInTreeView(propertyFilter);
RiuMainWindow::instance()->selectAsCurrentItem(propertyFilter);
}
@ -83,7 +83,7 @@ void RicGeoMechPropertyFilterFeatureImpl::insertPropertyFilter(RimGeoMechPropert
propertyFilterCollection->reservoirView()->scheduleCreateDisplayModelAndRedraw();
propertyFilterCollection->updateConnectedEditors();
RiuMainWindow::instance()->setCurrentObjectInTreeView(propertyFilter);
RiuMainWindow::instance()->selectAsCurrentItem(propertyFilter);
}

View File

@ -29,7 +29,6 @@
#include "RiuMainWindow.h"
#include "cafSelectionManager.h"
#include "cafPdmUiTreeView.h"
#include <QAction>
@ -54,7 +53,7 @@ void RicNewStatisticsCaseFeature::onActionTriggered(bool isChecked)
RimEclipseStatisticsCase* newCase = addStatisticalCalculation(uiItem);
if (newCase)
{
RiuMainWindow::instance()->projectTreeView()->selectAsCurrentItem(newCase);
RiuMainWindow::instance()->selectAsCurrentItem(newCase);
}
}
}

View File

@ -69,7 +69,7 @@ void RicRangeFilterInsertExec::redo()
m_cellRangeFilterCollection->updateConnectedEditors();
RiuMainWindow::instance()->setCurrentObjectInTreeView(rangeFilter);
RiuMainWindow::instance()->selectAsCurrentItem(rangeFilter);
}
}

View File

@ -72,7 +72,7 @@ void RicRangeFilterNewExec::redo()
m_cellRangeFilterCollection->updateConnectedEditors();
RiuMainWindow::instance()->setCurrentObjectInTreeView(rangeFilter);
RiuMainWindow::instance()->selectAsCurrentItem(rangeFilter);
}
}

View File

@ -0,0 +1,53 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cafCmdFeature.h"
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfVector3.h"
namespace cvf {
class Part;
}
class RicViewerEventInterface
{
public:
virtual bool handleEvent(cvf::Object* eventObject) = 0;
};
class RicViewerEventObject : public cvf::Object
{
public:
RicViewerEventObject(cvf::Vec3d localIntersectionPoint, cvf::Part* firstHitPart, cvf::uint firstPartTriangleIndex)
: localIntersectionPoint(localIntersectionPoint),
firstHitPart(firstHitPart),
firstPartTriangleIndex(firstPartTriangleIndex)
{
}
cvf::Vec3d localIntersectionPoint;
cvf::Part* firstHitPart;
cvf::uint firstPartTriangleIndex;
};

View File

@ -27,7 +27,6 @@
#include "RiuMainWindow.h"
#include "cafSelectionManager.h"
#include "cafPdmUiTreeView.h"
#include <QAction>
@ -62,7 +61,7 @@ void RicShowLinkOptionsFeature::onActionTriggered(bool isChecked)
RimViewController* viewController = activeView->viewController();
RiuMainWindow::instance()->projectTreeView()->selectAsCurrentItem(viewController);
RiuMainWindow::instance()->selectAsCurrentItem(viewController);
}
//--------------------------------------------------------------------------------------------------

View File

@ -25,7 +25,7 @@
#include "RimWellLogFile.h"
#include "RimWellLogFileChannel.h"
#include "RimWellLogPlot.h"
#include "RimWellLogPlotTrack.h"
#include "RimWellLogTrack.h"
#include "RimWellLogFileCurve.h"
#include "RimProject.h"
#include "RimMainPlotCollection.h"
@ -37,7 +37,7 @@
#include "RiaApplication.h"
#include "RiuMainWindow.h"
#include "RiuWellLogTrackPlot.h"
#include "RiuWellLogTrack.h"
#include "cafSelectionManager.h"
#include "cafPdmUiTreeView.h"
@ -68,14 +68,12 @@ void RicAddWellLogToPlotFeature::onActionTriggered(bool isChecked)
RimWellLogPlot* plot = RicNewWellLogPlotFeatureImpl::createWellLogPlot();
RimWellLogPlotTrack* plotTrack = new RimWellLogPlotTrack();
RimWellLogTrack* plotTrack = new RimWellLogTrack();
plot->addTrack(plotTrack);
plotTrack->setDescription(QString("Track %1").arg(plot->trackCount()));
plot->loadDataAndUpdate();
caf::PdmUiItem* uiItem = NULL;
for (size_t wlIdx = 0; wlIdx < selection.size(); wlIdx++)
{
RimWellLogFileChannel* wellLog = selection[wlIdx];
@ -87,38 +85,34 @@ void RicAddWellLogToPlotFeature::onActionTriggered(bool isChecked)
wellLog->firstAnchestorOrThisOfType(wellLogFile);
if (wellLogFile)
{
size_t curveIdx = plotTrack->curveCount();
RimWellLogFileCurve* curve = new RimWellLogFileCurve;
plotTrack->addCurve(curve);
RigWellLogFile* wellLogDataFile = wellLogFile->wellLogFile();
CVF_ASSERT(wellLogDataFile);
if (wlIdx == 0)
{
// Initialize plot with depth unit from the first log file
plot->setDepthUnit(wellLogDataFile->depthUnit());
}
cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable();
curve->setColor(curveColor);
curve->setWellPath(wellPath);
curve->setWellLogChannelName(wellLog->name());
curve->updatePlotData();
if (wlIdx == selection.size() - 1)
{
uiItem = curve;
}
}
}
plot->calculateAvailableDepthRange();
plot->zoomAllDepth();
plot->updateDepthZoom();
plotTrack->viewer()->replot();
RiaApplication::instance()->project()->updateConnectedEditors();
if (uiItem)
{
RiuMainWindow::instance()->projectTreeView()->selectAsCurrentItem(uiItem);
}
RiuMainWindow::instance()->projectTreeView()->selectAsCurrentItem(selection.back());
}
//--------------------------------------------------------------------------------------------------

View File

@ -19,7 +19,7 @@
#include "RicDeleteWellLogPlotTrackFeature.h"
#include "RimWellLogPlotTrack.h"
#include "RimWellLogTrack.h"
#include "RimWellLogPlot.h"
#include "cafSelectionManager.h"
@ -34,7 +34,7 @@ CAF_CMD_SOURCE_INIT(RicDeleteWellLogPlotTrackFeature, "RicDeleteWellLogPlotTrack
//--------------------------------------------------------------------------------------------------
bool RicDeleteWellLogPlotTrackFeature::isCommandEnabled()
{
std::vector<RimWellLogPlotTrack*> selection;
std::vector<RimWellLogTrack*> selection;
caf::SelectionManager::instance()->objectsByType(&selection);
if (selection.size() > 0)
@ -55,12 +55,12 @@ bool RicDeleteWellLogPlotTrackFeature::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
void RicDeleteWellLogPlotTrackFeature::onActionTriggered(bool isChecked)
{
std::vector<RimWellLogPlotTrack*> selection;
std::vector<RimWellLogTrack*> selection;
caf::SelectionManager::instance()->objectsByType(&selection);
for (size_t i = 0; i < selection.size(); i++)
{
RimWellLogPlotTrack* track = selection[i];
RimWellLogTrack* track = selection[i];
RimWellLogPlot* wellLogPlot = NULL;
track->firstAnchestorOrThisOfType(wellLogPlot);
@ -71,7 +71,7 @@ void RicDeleteWellLogPlotTrackFeature::onActionTriggered(bool isChecked)
delete track;
wellLogPlot->calculateAvailableDepthRange();
wellLogPlot->zoomAllDepth();
wellLogPlot->updateDepthZoom();
wellLogPlot->uiCapability()->updateConnectedEditors();
}
}

View File

@ -22,12 +22,13 @@
#include "RicWellLogPlotCurveFeatureImpl.h"
#include "RicNewWellLogPlotFeatureImpl.h"
#include "RimWellLogPlotTrack.h"
#include "RimProject.h"
#include "RimView.h"
#include "RimWellLogExtractionCurve.h"
#include "RimWellLogPlot.h"
#include "RimWellLogTrack.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "RimView.h"
#include "RimProject.h"
#include "RiuMainWindow.h"
#include "RiaApplication.h"
@ -54,7 +55,7 @@ bool RicNewWellLogCurveExtractionFeature::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
void RicNewWellLogCurveExtractionFeature::onActionTriggered(bool isChecked)
{
RimWellLogPlotTrack* wellLogPlotTrack = selectedWellLogPlotTrack();
RimWellLogTrack* wellLogPlotTrack = selectedWellLogPlotTrack();
if (wellLogPlotTrack)
{
addCurve(wellLogPlotTrack, NULL, NULL);
@ -64,10 +65,18 @@ void RicNewWellLogCurveExtractionFeature::onActionTriggered(bool isChecked)
RimWellPath* wellPath = selectedWellPath();
if (wellPath)
{
RimWellLogPlotTrack* wellLogPlotTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack();
RimWellLogTrack* wellLogPlotTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack();
RimWellLogExtractionCurve* plotCurve = addCurve(wellLogPlotTrack, RiaApplication::instance()->activeReservoirView(), wellPath);
plotCurve->updatePlotData();
RimWellLogPlot* plot = NULL;
wellLogPlotTrack->firstAnchestorOrThisOfType(plot);
if (plot && plotCurve->curveData())
{
plot->setDepthUnit(plotCurve->curveData()->depthUnit());
}
plotCurve->updateConnectedEditors();
}
}
@ -84,9 +93,9 @@ void RicNewWellLogCurveExtractionFeature::setupActionLook(QAction* actionToSetup
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogPlotTrack* RicNewWellLogCurveExtractionFeature::selectedWellLogPlotTrack() const
RimWellLogTrack* RicNewWellLogCurveExtractionFeature::selectedWellLogPlotTrack() const
{
std::vector<RimWellLogPlotTrack*> selection;
std::vector<RimWellLogTrack*> selection;
caf::SelectionManager::instance()->objectsByType(&selection);
return selection.size() > 0 ? selection[0] : NULL;
}
@ -115,12 +124,9 @@ bool RicNewWellLogCurveExtractionFeature::caseAvailable() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogExtractionCurve* RicNewWellLogCurveExtractionFeature::addCurve(RimWellLogPlotTrack* plotTrack, RimView* view, RimWellPath* wellPath)
RimWellLogExtractionCurve* RicNewWellLogCurveExtractionFeature::addCurve(RimWellLogTrack* plotTrack, RimView* view, RimWellPath* wellPath)
{
CVF_ASSERT(plotTrack);
size_t curveIndex = plotTrack->curveCount();
RimWellLogExtractionCurve* curve = new RimWellLogExtractionCurve();
cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable();
@ -130,7 +136,7 @@ RimWellLogExtractionCurve* RicNewWellLogCurveExtractionFeature::addCurve(RimWell
plotTrack->addCurve(curve);
plotTrack->updateConnectedEditors();
RiuMainWindow::instance()->setCurrentObjectInTreeView(curve);
RiuMainWindow::instance()->selectAsCurrentItem(curve);
return curve;
}

View File

@ -22,7 +22,7 @@
#include "cafCmdFeature.h"
class RimWellLogExtractionCurve;
class RimWellLogPlotTrack;
class RimWellLogTrack;
class RimWellPath;
class RimView;
@ -34,7 +34,7 @@ class RicNewWellLogCurveExtractionFeature : public caf::CmdFeature
CAF_CMD_HEADER_INIT;
public:
static RimWellLogExtractionCurve* addCurve(RimWellLogPlotTrack* plotTrack, RimView* view, RimWellPath* wellPath);
static RimWellLogExtractionCurve* addCurve(RimWellLogTrack* plotTrack, RimView* view, RimWellPath* wellPath);
protected:
@ -44,7 +44,7 @@ protected:
virtual void setupActionLook( QAction* actionToSetup );
private:
RimWellLogPlotTrack* selectedWellLogPlotTrack() const;
RimWellLogTrack* selectedWellLogPlotTrack() const;
RimWellPath* selectedWellPath() const;
bool caseAvailable() const;
};

View File

@ -23,7 +23,7 @@
#include "RicNewWellLogPlotFeatureImpl.h"
#include "RimWellLogFileCurve.h"
#include "RimWellLogPlotTrack.h"
#include "RimWellLogTrack.h"
#include "RimWellLogFile.h"
#include "RimWellLogFileChannel.h"
#include "RimWellPath.h"
@ -56,7 +56,7 @@ bool RicNewWellLogFileCurveFeature::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
void RicNewWellLogFileCurveFeature::onActionTriggered(bool isChecked)
{
RimWellLogPlotTrack* wellLogPlotTrack = selectedWellLogPlotTrack();
RimWellLogTrack* wellLogPlotTrack = selectedWellLogPlotTrack();
if (wellLogPlotTrack)
{
addCurve(wellLogPlotTrack);
@ -66,7 +66,7 @@ void RicNewWellLogFileCurveFeature::onActionTriggered(bool isChecked)
RimWellPath* wellPath = selectedWellPathWithLogFile();
if (wellPath)
{
RimWellLogPlotTrack* wellLogPlotTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack();
RimWellLogTrack* wellLogPlotTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack();
RimWellLogFileCurve* plotCurve = addCurve(wellLogPlotTrack);
plotCurve->setWellPath(wellPath);
plotCurve->updateConnectedEditors();
@ -85,9 +85,9 @@ void RicNewWellLogFileCurveFeature::setupActionLook(QAction* actionToSetup)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogPlotTrack* RicNewWellLogFileCurveFeature::selectedWellLogPlotTrack() const
RimWellLogTrack* RicNewWellLogFileCurveFeature::selectedWellLogPlotTrack() const
{
std::vector<RimWellLogPlotTrack*> selection;
std::vector<RimWellLogTrack*> selection;
caf::SelectionManager::instance()->objectsByType(&selection);
return selection.size() > 0 ? selection[0] : NULL;
}
@ -140,12 +140,10 @@ bool RicNewWellLogFileCurveFeature::wellLogFilesAvailable() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogFileCurve* RicNewWellLogFileCurveFeature::addCurve(RimWellLogPlotTrack* plotTrack)
RimWellLogFileCurve* RicNewWellLogFileCurveFeature::addCurve(RimWellLogTrack* plotTrack)
{
CVF_ASSERT(plotTrack);
size_t curveIndex = plotTrack->curveCount();
RimWellLogFileCurve* curve = new RimWellLogFileCurve();
plotTrack->addCurve(curve);
@ -154,7 +152,7 @@ RimWellLogFileCurve* RicNewWellLogFileCurveFeature::addCurve(RimWellLogPlotTrack
plotTrack->updateConnectedEditors();
RiuMainWindow::instance()->setCurrentObjectInTreeView(curve);
RiuMainWindow::instance()->selectAsCurrentItem(curve);
return curve;
}
@ -162,7 +160,7 @@ RimWellLogFileCurve* RicNewWellLogFileCurveFeature::addCurve(RimWellLogPlotTrack
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewWellLogFileCurveFeature::addWellLogChannelsToPlotTrack(RimWellLogPlotTrack* plotTrack, const std::vector<RimWellLogFileChannel*>& wellLogFileChannels)
void RicNewWellLogFileCurveFeature::addWellLogChannelsToPlotTrack(RimWellLogTrack* plotTrack, const std::vector<RimWellLogFileChannel*>& wellLogFileChannels)
{
for (size_t cIdx = 0; cIdx < wellLogFileChannels.size(); cIdx++)
{

View File

@ -23,7 +23,7 @@
#include <vector>
class RimWellLogPlotTrack;
class RimWellLogTrack;
class RimWellLogFileCurve;
class RimWellPath;
class RimWellLogFileChannel;
@ -37,9 +37,9 @@ class RicNewWellLogFileCurveFeature : public caf::CmdFeature
CAF_CMD_HEADER_INIT;
public:
static RimWellLogFileCurve* addCurve(RimWellLogPlotTrack* plotTrack);
static RimWellLogFileCurve* addCurve(RimWellLogTrack* plotTrack);
static void addWellLogChannelsToPlotTrack(RimWellLogPlotTrack* plotTrack, const std::vector<RimWellLogFileChannel*>& wellLogFileChannels);
static void addWellLogChannelsToPlotTrack(RimWellLogTrack* plotTrack, const std::vector<RimWellLogFileChannel*>& wellLogFileChannels);
protected:
// Overrides
@ -48,7 +48,7 @@ protected:
virtual void setupActionLook( QAction* actionToSetup );
private:
RimWellLogPlotTrack* selectedWellLogPlotTrack() const;
RimWellLogTrack* selectedWellLogPlotTrack() const;
RimWellPath* selectedWellPathWithLogFile() const;
bool wellLogFilesAvailable() const;
};

View File

@ -25,8 +25,8 @@
#include "RimProject.h"
#include "RimWellLogPlot.h"
#include "RimWellLogPlotTrack.h"
#include "RimWellLogPlotCurve.h"
#include "RimWellLogTrack.h"
#include "RimWellLogCurve.h"
#include "RiaApplication.h"
@ -50,7 +50,7 @@ bool RicNewWellLogPlotFeature::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
void RicNewWellLogPlotFeature::onActionTriggered(bool isChecked)
{
RimWellLogPlotTrack* plotTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack();
RimWellLogTrack* plotTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack();
RicNewWellLogCurveExtractionFeature::addCurve(plotTrack, NULL, NULL);
}

View File

@ -19,50 +19,16 @@
#include "RicNewWellLogPlotFeatureImpl.h"
#include "RimProject.h"
#include "RimMainPlotCollection.h"
#include "RimWellLogPlotCollection.h"
#include "RimProject.h"
#include "RimWellLogPlot.h"
#include "RimWellLogPlotTrack.h"
#include "RimWellLogPlotCollection.h"
#include "RimWellLogTrack.h"
#include "RiaApplication.h"
#include "cvfAssert.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimMainPlotCollection* RicNewWellLogPlotFeatureImpl::mainPlotCollection()
{
RimProject* project = RiaApplication::instance()->project();
CVF_ASSERT(project);
RimMainPlotCollection* mainPlotColl = project->mainPlotCollection();
if (!mainPlotColl)
{
project->recreateMainPlotCollection();
}
return project->mainPlotCollection();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogPlotCollection* RicNewWellLogPlotFeatureImpl::wellLogPlotCollection()
{
RimMainPlotCollection* mainPlotColl = mainPlotCollection();
CVF_ASSERT(mainPlotColl);
RimWellLogPlotCollection* wellLogPlotColl = mainPlotColl->wellLogPlotCollection();
if (!wellLogPlotColl)
{
mainPlotColl->recreateWellLogPlotCollection();
}
return mainPlotColl->wellLogPlotCollection();
}
//--------------------------------------------------------------------------------------------------
///
@ -83,11 +49,11 @@ RimWellLogPlot* RicNewWellLogPlotFeatureImpl::createWellLogPlot()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogPlotTrack* RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack()
RimWellLogTrack* RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack()
{
RimWellLogPlot* plot = createWellLogPlot();
RimWellLogPlotTrack* plotTrack = new RimWellLogPlotTrack();
RimWellLogTrack* plotTrack = new RimWellLogTrack();
plot->addTrack(plotTrack);
plotTrack->setDescription(QString("Track %1").arg(plot->trackCount()));
@ -97,3 +63,20 @@ RimWellLogPlotTrack* RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack()
return plotTrack;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogPlotCollection* RicNewWellLogPlotFeatureImpl::wellLogPlotCollection()
{
RimProject* project = RiaApplication::instance()->project();
CVF_ASSERT(project);
RimMainPlotCollection* mainPlotColl = project->mainPlotCollection();
CVF_ASSERT(mainPlotColl);
RimWellLogPlotCollection* wellLogPlotColl = mainPlotColl->wellLogPlotCollection();
CVF_ASSERT(wellLogPlotColl);
return mainPlotColl->wellLogPlotCollection();
}

View File

@ -19,10 +19,9 @@
#pragma once
class RimMainPlotCollection;
class RimWellLogPlotCollection;
class RimWellLogPlot;
class RimWellLogPlotTrack;
class RimWellLogTrack;
//==================================================================================================
///
@ -30,9 +29,9 @@ class RimWellLogPlotTrack;
class RicNewWellLogPlotFeatureImpl
{
public:
static RimWellLogPlot* createWellLogPlot();
static RimWellLogTrack* createWellLogPlotTrack();
static RimMainPlotCollection* mainPlotCollection();
static RimWellLogPlotCollection* wellLogPlotCollection();
static RimWellLogPlot* createWellLogPlot();
static RimWellLogPlotTrack* createWellLogPlotTrack();
private:
static RimWellLogPlotCollection* wellLogPlotCollection();
};

View File

@ -20,7 +20,7 @@
#include "RicNewWellLogPlotTrackFeature.h"
#include "RimWellLogPlot.h"
#include "RimWellLogPlotTrack.h"
#include "RimWellLogTrack.h"
#include "RiuMainWindow.h"
@ -49,7 +49,7 @@ void RicNewWellLogPlotTrackFeature::onActionTriggered(bool isChecked)
RimWellLogPlot* wellLogPlot = selectedWellLogPlot();
if (wellLogPlot)
{
RimWellLogPlotTrack* plotTrack = new RimWellLogPlotTrack;
RimWellLogTrack* plotTrack = new RimWellLogTrack;
wellLogPlot->addTrack(plotTrack);
plotTrack->setDescription(QString("Track %1").arg(wellLogPlot->trackCount()));

View File

@ -20,8 +20,8 @@
#include "RicWellLogPlotTrackFeatureImpl.h"
#include "RimWellLogPlot.h"
#include "RimWellLogPlotTrack.h"
#include "RimWellLogPlotCurve.h"
#include "RimWellLogTrack.h"
#include "RimWellLogCurve.h"
#include "RiuMainWindow.h"
@ -30,20 +30,20 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicWellLogPlotTrackFeatureImpl::moveCurvesToWellLogPlotTrack(RimWellLogPlotTrack* destTrack,
const std::vector<RimWellLogPlotCurve*>& curves,
RimWellLogPlotCurve* curveToInsertAfter)
void RicWellLogPlotTrackFeatureImpl::moveCurvesToWellLogPlotTrack(RimWellLogTrack* destTrack,
const std::vector<RimWellLogCurve*>& curves,
RimWellLogCurve* curveToInsertAfter)
{
CVF_ASSERT(destTrack );
std::set<RimWellLogPlotTrack*> srcTracks;
std::set<RimWellLogTrack*> srcTracks;
std::set<RimWellLogPlot*> srcPlots;
for (size_t cIdx = 0; cIdx < curves.size(); cIdx++)
{
RimWellLogPlotCurve* curve = curves[cIdx];
RimWellLogCurve* curve = curves[cIdx];
RimWellLogPlotTrack* wellLogPlotTrack;
RimWellLogTrack* wellLogPlotTrack;
curve->firstAnchestorOrThisOfType(wellLogPlotTrack);
if (wellLogPlotTrack)
{
@ -69,7 +69,7 @@ void RicWellLogPlotTrackFeatureImpl::moveCurvesToWellLogPlotTrack(RimWellLogPlot
(*pIt)->calculateAvailableDepthRange();
}
for (std::set<RimWellLogPlotTrack*>::iterator tIt = srcTracks.begin(); tIt != srcTracks.end(); ++tIt)
for (std::set<RimWellLogTrack*>::iterator tIt = srcTracks.begin(); tIt != srcTracks.end(); ++tIt)
{
(*tIt)->zoomAllXAndZoomAllDepthOnOwnerPlot();
}
@ -83,8 +83,8 @@ void RicWellLogPlotTrackFeatureImpl::moveCurvesToWellLogPlotTrack(RimWellLogPlot
///
//--------------------------------------------------------------------------------------------------
void RicWellLogPlotTrackFeatureImpl::moveTracksToWellLogPlot(RimWellLogPlot* dstWellLogPlot,
const std::vector<RimWellLogPlotTrack*>& tracksToMove,
RimWellLogPlotTrack* trackToInsertAfter)
const std::vector<RimWellLogTrack*>& tracksToMove,
RimWellLogTrack* trackToInsertAfter)
{
CVF_ASSERT(dstWellLogPlot);
@ -92,7 +92,7 @@ void RicWellLogPlotTrackFeatureImpl::moveTracksToWellLogPlot(RimWellLogPlot* dst
for (size_t tIdx = 0; tIdx < tracksToMove.size(); tIdx++)
{
RimWellLogPlotTrack* track = tracksToMove[tIdx];
RimWellLogTrack* track = tracksToMove[tIdx];
RimWellLogPlot* srcPlot;
track->firstAnchestorOrThisOfType(srcPlot);
@ -108,7 +108,7 @@ void RicWellLogPlotTrackFeatureImpl::moveTracksToWellLogPlot(RimWellLogPlot* dst
{
(*pIt)->calculateAvailableDepthRange();
(*pIt)->updateTrackNames();
(*pIt)->zoomAllDepth();
(*pIt)->updateDepthZoom();
(*pIt)->updateConnectedEditors();
}

View File

@ -22,8 +22,8 @@
#include <vector>
class RimWellLogPlot;
class RimWellLogPlotTrack;
class RimWellLogPlotCurve;
class RimWellLogTrack;
class RimWellLogCurve;
//==================================================================================================
///
@ -32,10 +32,10 @@ class RicWellLogPlotTrackFeatureImpl
{
public:
static void moveCurvesToWellLogPlotTrack(RimWellLogPlotTrack* dstTrack,
const std::vector<RimWellLogPlotCurve*>& curves,
RimWellLogPlotCurve* insertAfterCurve);
static void moveCurvesToWellLogPlotTrack(RimWellLogTrack* dstTrack,
const std::vector<RimWellLogCurve*>& curves,
RimWellLogCurve* insertAfterCurve);
static void moveTracksToWellLogPlot(RimWellLogPlot* wellLogPlot,
const std::vector<RimWellLogPlotTrack*>& tracks,
RimWellLogPlotTrack* trackToInsertAfter);
const std::vector<RimWellLogTrack*>& tracks,
RimWellLogTrack* trackToInsertAfter);
};

View File

@ -9,6 +9,7 @@ ${CEE_CURRENT_LIST_DIR}RicWellPathDeleteFeature.h
${CEE_CURRENT_LIST_DIR}RicWellPathsDeleteAllFeature.h
${CEE_CURRENT_LIST_DIR}RicWellPathsImportFileFeature.h
${CEE_CURRENT_LIST_DIR}RicWellPathsImportSsihubFeature.h
${CEE_CURRENT_LIST_DIR}RicWellPathViewerEventHandler.h
)
set (SOURCE_GROUP_SOURCE_FILES
@ -16,6 +17,7 @@ ${CEE_CURRENT_LIST_DIR}RicWellPathDeleteFeature.cpp
${CEE_CURRENT_LIST_DIR}RicWellPathsDeleteAllFeature.cpp
${CEE_CURRENT_LIST_DIR}RicWellPathsImportFileFeature.cpp
${CEE_CURRENT_LIST_DIR}RicWellPathsImportSsihubFeature.cpp
${CEE_CURRENT_LIST_DIR}RicWellPathViewerEventHandler.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -0,0 +1,93 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicWellPathViewerEventHandler.h"
#include "RiaApplication.h"
#include "RimCase.h"
#include "RimView.h"
#include "RimWellPath.h"
#include "RiuMainWindow.h"
#include "RivWellPathSourceInfo.h"
#include "cvfPart.h"
#include "cvfVector3.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicWellPathViewerEventHandler* RicWellPathViewerEventHandler::instance()
{
static RicWellPathViewerEventHandler* singleton = new RicWellPathViewerEventHandler;
return singleton;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicWellPathViewerEventHandler::handleEvent(cvf::Object* eventObject)
{
RicViewerEventObject* uiEvent = dynamic_cast<RicViewerEventObject*>(eventObject);
if (!uiEvent) return false;
if (uiEvent->firstHitPart && uiEvent->firstHitPart->sourceInfo())
{
const RivWellPathSourceInfo* wellPathSourceInfo = dynamic_cast<const RivWellPathSourceInfo*>(uiEvent->firstHitPart->sourceInfo());
if (wellPathSourceInfo)
{
cvf::Vec3d displayModelOffset = cvf::Vec3d::ZERO;
RimView* activeView = RiaApplication::instance()->activeReservoirView();
if (!activeView) return false;
RimCase* rimCase = NULL;
activeView->firstAnchestorOrThisOfType(rimCase);
if (rimCase)
{
displayModelOffset = rimCase->displayModelOffset();
}
cvf::Vec3d unscaledIntersection = uiEvent->localIntersectionPoint;
unscaledIntersection.z() /= activeView->scaleZ;
double measuredDepth = wellPathSourceInfo->measuredDepth(uiEvent->firstPartTriangleIndex, unscaledIntersection + displayModelOffset);
cvf::Vec3d trueVerticalDepth = wellPathSourceInfo->trueVerticalDepth(uiEvent->firstPartTriangleIndex, unscaledIntersection + displayModelOffset);
QString wellPathText;
wellPathText += QString("Well path name : %1\n").arg(wellPathSourceInfo->wellPath()->name);
wellPathText += QString("Measured depth : %1\n").arg(measuredDepth);
QString formattedText;
formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", trueVerticalDepth.x(), trueVerticalDepth.y(), -trueVerticalDepth.z());
wellPathText += formattedText;
RiuMainWindow::instance()->setResultInfo(wellPathText);
RiuMainWindow::instance()->selectAsCurrentItem(wellPathSourceInfo->wellPath());
return true;
}
}
return false;
}

View File

@ -0,0 +1,35 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicViewerEventInterface.h"
//==================================================================================================
///
//==================================================================================================
class RicWellPathViewerEventHandler : public RicViewerEventInterface
{
public:
static RicWellPathViewerEventHandler* instance();
virtual bool handleEvent(cvf::Object* eventObject);
};

View File

@ -86,16 +86,14 @@ void RicWellPathsImportSsihubFeature::onActionTriggered(bool isChecked)
// Get password/username from application cache
{
#ifdef _DEBUG
// Valid credentials for ssihubfake received in mail from Håkon
QString ssihubUsername = "admin";
QString ssihubPassword = "resinsight";
#else
QString ssihubUsername = app->cacheDataObject("ssihub_username").toString();
QString ssihubPassword = app->cacheDataObject("ssihub_password").toString();
#ifdef _DEBUG
// Valid credentials for ssihubfake received in mail from Håkon
ssihubUsername = "admin";
ssihubPassword = "resinsight";
#endif
wellImportwizard.setCredentials(ssihubUsername, ssihubPassword);
}

View File

@ -1,114 +0,0 @@
cmake_minimum_required (VERSION 2.8)
SET (ProjectName FileInterface_UnitTests)
project ( ${ProjectName} )
# Qt
find_package (Qt4 COMPONENTS QtCore QtGui QtMain QtOpenGl REQUIRED)
include (${QT_USE_FILE})
include_directories(
${ResInsight_SOURCE_DIR}/ApplicationCode
${ResInsight_SOURCE_DIR}/ApplicationCode/ResultStatisticsCache
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel
${ResInsight_SOURCE_DIR}/ApplicationCode/FileInterface
${ResInsight_SOURCE_DIR}/ApplicationCode/ProjectDataModel
${ResInsight_SOURCE_DIR}/ThirdParty
${ResInsight_SOURCE_DIR}/Fwk/AppFwk/cafProjectDataModel
${ResInsight_SOURCE_DIR}/Fwk/AppFwk/CommonCode
#Remove when RigStatistics is out
${ResInsight_SOURCE_DIR}/ApplicationCode/ModelVisualization
)
# Populate variables from read from CMakeLists_files.cmake
set (CODE_SOURCE_FILES )
include ("${ResInsight_SOURCE_DIR}/ApplicationCode/FileInterface/CMakeLists_files.cmake")
set( CPP_SOURCES
${CPP_SOURCES}
${CODE_SOURCE_FILES}
)
source_group( "FileInterface" FILES ${CODE_SOURCE_FILES} )
# Populate variables from read from CMakeLists_files.cmake
set (CODE_SOURCE_FILES )
include ("${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake")
set( CPP_SOURCES
${CPP_SOURCES}
${CODE_SOURCE_FILES}
)
source_group( "ReservoirDataModel" FILES ${CODE_SOURCE_FILES} )
set( CPP_SOURCES
${CPP_SOURCES}
${ResInsight_SOURCE_DIR}/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp
)
source_group( "Headers" FILES ${CODE_HEADER_FILES} )
set( UNIT_TEST_CPP_SOURCES
main.cpp
RifReaderEclipseOutput-Test.cpp
RifEclipseInputFileTools-Test.cpp
Ert-Test.cpp
)
set( LINK_LIBRARIES
cafProjectDataModel
CommonCode
ResultStatisticsCache
LibViewing
LibRender
LibGeometry
LibCore
ecl
ert_util
ert_geometry
ecl_well
${QT_LIBRARIES}
)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_CXX_FLAGS "-DGTEST_USE_OWN_TR1_TUPLE=1")
endif()
add_executable( ${ProjectName}
${CODE_HEADER_FILES}
${CPP_SOURCES}
${UNIT_TEST_CPP_SOURCES}
${ResInsight_SOURCE_DIR}/ThirdParty/gtest/gtest-all.cc
${ResInsight_SOURCE_DIR}/ApplicationCode/FileInterface/CMakeLists_files.cmake
${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake
)
set( EXTERNAL_LINK_LIBRARIES ${ERT_LIBRARY_LIST} )
target_link_libraries( ${ProjectName} ${LINK_LIBRARIES} ${EXTERNAL_LINK_LIBRARIES})
# Copy Dlls
if (MSVC)
# Qt DLLs
set (QTLIBLIST QtCore QtCored QtGui QtGuid QtOpenGl QtOpenGld QtNetwork QtNetworkd QtScript QtScriptd QtScriptTools QtScriptToolsd)
foreach (qtlib ${QTLIBLIST})
add_custom_command(TARGET ${ProjectName} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${QT_BINARY_DIR}/${qtlib}4.dll"
${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>)
endforeach( qtlib )
endif(MSVC)

View File

@ -811,7 +811,7 @@ bool RifEclipseInputFileTools::readFaultsAndParseIncludeStatementsRecursively(QF
QFile includeFile(absoluteFilename);
if (includeFile.open(QFile::ReadOnly))
{
qDebug() << "Found include statement, and start parsing of\n " << absoluteFilename;
//qDebug() << "Found include statement, and start parsing of\n " << absoluteFilename;
if (!readFaultsAndParseIncludeStatementsRecursively(includeFile, 0, faults, filenamesWithFaults, isEditKeywordDetected))
{
@ -875,7 +875,7 @@ void RifEclipseInputFileTools::readFaults(QFile &data, qint64 filePos, cvf::Coll
return;
}
qDebug() << "Reading faults from\n " << data.fileName();
// qDebug() << "Reading faults from\n " << data.fileName();
RigFault* fault = NULL;

View File

@ -58,11 +58,10 @@ void getDayMonthYear(const ecl_kw_type* intehead_kw, int* day, int* month, int*
*year = ecl_kw_iget_int(intehead_kw, INTEHEAD_YEAR_INDEX);
}
//--------------------------------------------------------------------------------------------------
/// Get list of time step texts (dates)
//--------------------------------------------------------------------------------------------------
void RifEclipseOutputFileTools::timeSteps(ecl_file_type* ecl_file, std::vector<QDateTime>* timeSteps, bool* detectedFractionOfDay )
void RifEclipseOutputFileTools::timeSteps(ecl_file_type* ecl_file, std::vector<QDateTime>* timeSteps)
{
CVF_ASSERT(timeSteps);
CVF_ASSERT(ecl_file);
@ -73,38 +72,30 @@ void RifEclipseOutputFileTools::timeSteps(ecl_file_type* ecl_file, std::vector<Q
// Get the number of occurrences of the DOUBHEAD keyword
int numDOUBHEAD = ecl_file_get_num_named_kw(ecl_file, DOUBHEAD_KW);
//CVF_ASSERT(numINTEHEAD == numDOUBHEAD);
std::vector<double> dayFractions(numINTEHEAD, 0.0); // Init fraction to zero
bool hasFractionOfDay = false;
bool foundAllDayValues = false;
const double delta = 0.001;
// Find all days, and stop when the double value is lower than the previous
QList<double> days;
for (int i = 0; i < numDOUBHEAD; i++)
// Read out fraction of day if number of keywords are identical
if (numINTEHEAD == numDOUBHEAD)
{
if (foundAllDayValues) continue;;
ecl_kw_type* kwDOUBHEAD = ecl_file_iget_named_kw(ecl_file, DOUBHEAD_KW, i);
if (kwDOUBHEAD)
for (int i = 0; i < numDOUBHEAD; i++)
{
double dayValue = ecl_kw_iget_double(kwDOUBHEAD, DOUBHEAD_DAYS_INDEX);
double floorDayValue = cvf::Math::floor(dayValue);
if (dayValue - floorDayValue > delta)
ecl_kw_type* kwDOUBHEAD = ecl_file_iget_named_kw(ecl_file, DOUBHEAD_KW, i);
if (kwDOUBHEAD)
{
hasFractionOfDay = true;
}
double dayValue = ecl_kw_iget_double(kwDOUBHEAD, DOUBHEAD_DAYS_INDEX);
double floorDayValue = cvf::Math::floor(dayValue);
days.push_back(dayValue);
double dayDelta = dayValue - floorDayValue;
dayFractions[i] = dayDelta;
}
}
}
std::vector<QDateTime> timeStepsFound;
if (hasFractionOfDay)
for (int i = 0; i < numINTEHEAD; i++)
{
ecl_kw_type* kwINTEHEAD = ecl_file_iget_named_kw(ecl_file, INTEHEAD_KW, 0);
ecl_kw_type* kwINTEHEAD = ecl_file_iget_named_kw(ecl_file, INTEHEAD_KW, i);
CVF_ASSERT(kwINTEHEAD);
if (kwINTEHEAD)
{
int day = 0;
@ -112,66 +103,24 @@ void RifEclipseOutputFileTools::timeSteps(ecl_file_type* ecl_file, std::vector<Q
int year = 0;
getDayMonthYear(kwINTEHEAD, &day, &month, &year);
QDateTime simulationStart(QDate(year, month, day));
for (int i = 0; i < days.size(); i++)
QDateTime reportDateTime(QDate(year, month, day));
CVF_ASSERT(reportDateTime.isValid());
double dayFraction = dayFractions[i];
int seconds = static_cast<int>(dayFraction * 24.0 * 60.0 * 60.0);
QTime time(0, 0);
time = time.addSecs(seconds);
reportDateTime.setTime(time);
if (std::find(timeSteps->begin(), timeSteps->end(), reportDateTime) == timeSteps->end())
{
QDateTime reportDateTime(simulationStart);
CVF_ASSERT(reportDateTime.isValid());
double dayValue = days[i];
double floorDayValue = cvf::Math::floor(dayValue);
reportDateTime = reportDateTime.addDays(static_cast<int>(floorDayValue));
double dayFraction = dayValue - floorDayValue;
int seconds = static_cast<int>(dayFraction * 24.0 * 60.0 * 60.0);
QTime time(0, 0);
time = time.addSecs(seconds);
reportDateTime.setTime(time);
if (std::find(timeStepsFound.begin(), timeStepsFound.end(), reportDateTime) == timeStepsFound.end())
{
timeStepsFound.push_back(reportDateTime);
}
timeSteps->push_back(reportDateTime);
}
}
}
else
{
for (int i = 0; i < numINTEHEAD; i++)
{
ecl_kw_type* kwINTEHEAD = ecl_file_iget_named_kw(ecl_file, INTEHEAD_KW, i);
if (kwINTEHEAD)
{
int day = 0;
int month = 0;
int year = 0;
getDayMonthYear(kwINTEHEAD, &day, &month, &year);
QDateTime reportDateTime(QDate(year, month, day));
QTime time(0, 0);
reportDateTime.setTime(time);
CVF_ASSERT(reportDateTime.isValid());
if (std::find(timeStepsFound.begin(), timeStepsFound.end(), reportDateTime) == timeStepsFound.end())
{
timeStepsFound.push_back(reportDateTime);
}
}
}
}
// Return time step info to caller
*timeSteps = timeStepsFound;
if (detectedFractionOfDay)
{
*detectedFractionOfDay = hasFractionOfDay;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -216,7 +165,6 @@ bool RifEclipseOutputFileTools::keywordData(ecl_file_type* ecl_file, const QStri
return false;
}
//--------------------------------------------------------------------------------------------------
/// Get first occurrence of file of given type in given list of filenames, as filename or NULL if not found
//--------------------------------------------------------------------------------------------------
@ -236,7 +184,6 @@ QString RifEclipseOutputFileTools::firstFileNameOfType(const QStringList& fileSe
return QString::null;
}
//--------------------------------------------------------------------------------------------------
/// Get all files of the given type from the provided list of filenames
//--------------------------------------------------------------------------------------------------
@ -285,7 +232,6 @@ bool RifEclipseOutputFileTools::findSiblingFilesWithSameBaseName(const QString&
return baseNameFiles->count() > 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -49,8 +49,7 @@ public:
static bool keywordData(ecl_file_type* ecl_file, const QString& keyword, size_t fileKeywordOccurrence, std::vector<double>* values);
static bool keywordData(ecl_file_type* ecl_file, const QString& keyword, size_t fileKeywordOccurrence, std::vector<int>* values);
// static void timeStepsText(ecl_file_type* ecl_file, QStringList* timeSteps);
static void timeSteps(ecl_file_type* ecl_file, std::vector<QDateTime>* timeSteps, bool* detectedFractionOfDay = NULL);
static void timeSteps(ecl_file_type* ecl_file, std::vector<QDateTime>* timeSteps);
static bool findSiblingFilesWithSameBaseName(const QString& fileName, QStringList* fileSet);

View File

@ -99,12 +99,12 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigActiveCellInfo* activeCellIn
CVF_ASSERT(activeCellInfo && fractureActiveCellInfo);
int cellCount = ecl_grid_get_global_size(localEclGrid);
size_t cellStartIndex = mainGrid->cells().size();
size_t cellStartIndex = mainGrid->globalCellArray().size();
size_t nodeStartIndex = mainGrid->nodes().size();
RigCell defaultCell;
defaultCell.setHostGrid(localGrid);
mainGrid->cells().resize(cellStartIndex + cellCount, defaultCell);
mainGrid->globalCellArray().resize(cellStartIndex + cellCount, defaultCell);
mainGrid->nodes().resize(nodeStartIndex + cellCount*8, cvf::Vec3d(0,0,0));
@ -117,7 +117,7 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigActiveCellInfo* activeCellIn
#pragma omp parallel for
for (int gridLocalCellIndex = 0; gridLocalCellIndex < cellCount; ++gridLocalCellIndex)
{
RigCell& cell = mainGrid->cells()[cellStartIndex + gridLocalCellIndex];
RigCell& cell = mainGrid->globalCellArray()[cellStartIndex + gridLocalCellIndex];
cell.setGridLocalCellIndex(gridLocalCellIndex);
@ -295,7 +295,7 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid,
// Reserve room for the cells and nodes and fill them with data
mainGrid->cells().reserve(totalCellCount);
mainGrid->globalCellArray().reserve(totalCellCount);
mainGrid->nodes().reserve(8*totalCellCount);
caf::ProgressInfo progInfo(3 + numLGRs, "");
@ -569,7 +569,7 @@ bool RifReaderEclipseOutput::readActiveCellInfo()
}
// Check if number of cells is matching
if (m_eclipseCase->mainGrid()->cells().size() != reservoirCellCount)
if (m_eclipseCase->mainGrid()->globalCellArray().size() != reservoirCellCount)
{
return false;
}
@ -920,7 +920,7 @@ RigWellResultPoint RifReaderEclipseOutput::createWellResultPoint(const RigGridBa
/// Inverse distance interpolation of the supplied points and distance weights for
/// the contributing points which are closest above, and closest below
//--------------------------------------------------------------------------------------------------
cvf::Vec3d interpolate3DPosition(const std::vector<SegmentPositionContribution> positions)
cvf::Vec3d interpolate3DPosition(const std::vector<SegmentPositionContribution>& positions)
{
std::vector<SegmentPositionContribution> filteredPositions;
filteredPositions.reserve(positions.size());
@ -1179,6 +1179,10 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid, boo
if (ert_wellhead)
{
wellResFrame.m_wellHead = createWellResultPoint(grids[gridNr], ert_wellhead, -1, -1 );
// HACK: Ert returns open as "this is equally wrong as closed for well heads".
// Well heads are not open jfr mail communication with HHGS and JH Statoil 07.01.2016
wellResFrame.m_wellHead.m_isOpen = false;
break;
}
}
@ -1480,7 +1484,7 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid, boo
while (posContribIt != segmentIdToPositionContrib.end())
{
bottomPositions[posContribIt->first] = interpolate3DPosition(posContribIt->second);
posContribIt++;
++posContribIt;
}
// Distribute the positions to the resultpoints stored in the wellResultBranch.m_branchResultPoints
@ -1528,6 +1532,10 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid, boo
if (ert_wellhead)
{
wellResFrame.m_wellHead = createWellResultPoint(grids[gridNr], ert_wellhead, -1, -1 );
// HACK: Ert returns open as "this is equally wrong as closed for well heads".
// Well heads are not open jfr mail communication with HHGS and JH Statoil 07.01.2016
wellResFrame.m_wellHead.m_isOpen = false;
//std::cout << "Wellhead YES at timeIdx: " << timeIdx << " wellIdx: " << wellIdx << " Grid: " << gridNr << std::endl;
}
else

View File

@ -122,7 +122,7 @@ bool RifReaderMockModel::dynamicResult(const QString& result, RifReaderInterface
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifReaderMockModel::RifReaderMockModel()
RifReaderMockModel::RifReaderMockModel() : m_reservoir(NULL)
{
/*
m_cellResults.push_back("Dummy results");

View File

@ -27,11 +27,15 @@ add_library( ${PROJECT_NAME}
RigFemScalarResultFrames.cpp
RigFemNativeStatCalc.h
RigFemNativeStatCalc.cpp
RigFemNativeVisibleCellsStatCalc.h
RigFemNativeVisibleCellsStatCalc.cpp
RigFemFaceComparator.h
RigFemPartGrid.h
RigFemPartGrid.cpp
RigFemResultAddress.h
RigFemResultPosEnum.h
RigFemTimeHistoryResultAccessor.h
RigFemTimeHistoryResultAccessor.cpp
)
target_link_libraries( ${PROJECT_NAME} LibCore cafTensor ResultStatisticsCache)

View File

@ -38,7 +38,7 @@ RigFemNativeStatCalc::RigFemNativeStatCalc(RigFemPartResultsCollection* femResul
//--------------------------------------------------------------------------------------------------
void RigFemNativeStatCalc::minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max)
{
for (int pIdx = 0; pIdx < static_cast<int>(m_resultsData->m_femPartResults.size()); ++pIdx)
for (int pIdx = 0; pIdx < m_resultsData->partCount(); ++pIdx)
{
const std::vector<float>& values = m_resultsData->resultValues(m_resVarAddr, pIdx, (int)timeStepIndex);
@ -68,7 +68,7 @@ void RigFemNativeStatCalc::minMaxCellScalarValues(size_t timeStepIndex, double&
//--------------------------------------------------------------------------------------------------
void RigFemNativeStatCalc::posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg)
{
for (int pIdx = 0; pIdx < static_cast<int>(m_resultsData->m_femPartResults.size()); ++pIdx)
for (int pIdx = 0; pIdx < m_resultsData->partCount(); ++pIdx)
{
const std::vector<float>& values = m_resultsData->resultValues(m_resVarAddr, pIdx, (int)timeStepIndex);
@ -92,53 +92,48 @@ void RigFemNativeStatCalc::posNegClosestToZero(size_t timeStepIndex, double& pos
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFemNativeStatCalc::valueSumAndSampleCount(double& valueSum, size_t& sampleCount)
{
int timestepCount = (int)(this->timeStepCount());
int partCount = static_cast<int>(m_resultsData->m_femPartResults.size());
for (int pIdx = 0; pIdx < partCount; ++pIdx)
{
for (int tIdx = 0; tIdx < timestepCount; tIdx++)
{
const std::vector<float>& values = m_resultsData->resultValues(m_resVarAddr, pIdx, tIdx);
size_t undefValueCount = 0;
for (size_t cIdx = 0; cIdx < values.size(); ++cIdx)
{
double value = values[cIdx];
if (value == HUGE_VAL || value != value)
{
++undefValueCount;
continue;
}
valueSum += value;
}
sampleCount += values.size();
sampleCount -= undefValueCount;
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFemNativeStatCalc::addDataToHistogramCalculator(RigHistogramCalculator& histogramCalculator)
void RigFemNativeStatCalc::valueSumAndSampleCount(size_t timeStepIndex, double& valueSum, size_t& sampleCount)
{
int timestepCount = (int)(this->timeStepCount());
int partCount = static_cast<int>(m_resultsData->m_femPartResults.size());
int tsIdx = static_cast<int>(timeStepIndex);
int partCount = m_resultsData->partCount();
for (int pIdx = 0; pIdx < partCount; ++pIdx)
{
for (int tIdx = 0; tIdx < timestepCount; tIdx++)
const std::vector<float>& values = m_resultsData->resultValues(m_resVarAddr, pIdx, tsIdx);
size_t undefValueCount = 0;
for (size_t cIdx = 0; cIdx < values.size(); ++cIdx)
{
const std::vector<float>& values = m_resultsData->resultValues(m_resVarAddr, pIdx, tIdx);
double value = values[cIdx];
if (value == HUGE_VAL || value != value)
{
++undefValueCount;
continue;
}
histogramCalculator.addData(values);
valueSum += value;
}
sampleCount += values.size();
sampleCount -= undefValueCount;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFemNativeStatCalc::addDataToHistogramCalculator(size_t timeStepIndex, RigHistogramCalculator& histogramCalculator)
{
int partCount = m_resultsData->partCount();
for (int pIdx = 0; pIdx < partCount; ++pIdx)
{
const std::vector<float>& values = m_resultsData->resultValues(m_resVarAddr, pIdx, static_cast<int>(timeStepIndex));
histogramCalculator.addData(values);
}
}

View File

@ -37,9 +37,11 @@ public:
virtual void minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max);
virtual void posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg);
virtual void valueSumAndSampleCount(double& valueSum, size_t& sampleCount);
virtual void addDataToHistogramCalculator(RigHistogramCalculator& histogramCalculator);
virtual void valueSumAndSampleCount(size_t timeStepIndex, double& valueSum, size_t& sampleCount);
virtual void addDataToHistogramCalculator(size_t timeStepIndex, RigHistogramCalculator& histogramCalculator);
virtual size_t timeStepCount();
private:

View File

@ -0,0 +1,93 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RigFemNativeVisibleCellsStatCalc.h"
#include "RigFemScalarResultFrames.h"
#include "RigFemPartResultsCollection.h"
#include <math.h>
#include "RigStatisticsMath.h"
#include "RigGeoMechCaseData.h"
#include "RigFemPartCollection.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemNativeVisibleCellsStatCalc::RigFemNativeVisibleCellsStatCalc(RigGeoMechCaseData* femCase,
const RigFemResultAddress& resVarAddr,
const cvf::UByteArray* cellVisibilities)
: m_caseData(femCase), m_resVarAddr(resVarAddr), m_cellVisibilities(cellVisibilities)
{
m_resultsData = femCase->femPartResults();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFemNativeVisibleCellsStatCalc::minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max)
{
MinMaxAccumulator acc(min, max);
traverseElementNodes(acc, timeStepIndex);
min = acc.min;
max = acc.max;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFemNativeVisibleCellsStatCalc::posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg)
{
PosNegAccumulator acc(pos, neg);
traverseElementNodes(acc, timeStepIndex);
pos = acc.pos;
neg = acc.neg;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFemNativeVisibleCellsStatCalc::valueSumAndSampleCount(size_t timeStepIndex, double& valueSum, size_t& sampleCount)
{
SumCountAccumulator acc(valueSum, sampleCount);
traverseElementNodes(acc, timeStepIndex);
valueSum = acc.valueSum;
sampleCount = acc.sampleCount;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFemNativeVisibleCellsStatCalc::addDataToHistogramCalculator(size_t timeStepIndex, RigHistogramCalculator& histogramCalculator)
{
traverseElementNodes(histogramCalculator, timeStepIndex);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RigFemNativeVisibleCellsStatCalc::timeStepCount()
{
return m_resultsData->frameCount();
}

View File

@ -0,0 +1,121 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RigStatisticsCalculator.h"
#include "RigFemResultAddress.h"
#include "RigGeoMechCaseData.h"
#include "RigFemPartCollection.h"
#include "RigFemPartResultsCollection.h"
#include "cvfArray.h"
class RigFemPartResultsCollection;
class RigFemNativeVisibleCellsStatCalc : public RigStatisticsCalculator
{
public:
RigFemNativeVisibleCellsStatCalc(RigGeoMechCaseData* femCase,
const RigFemResultAddress& resVarAddr,
const cvf::UByteArray* cellVisibilities);
virtual void minMaxCellScalarValues(size_t timeStepIndex, double& min, double& max);
virtual void posNegClosestToZero(size_t timeStepIndex, double& pos, double& neg);
virtual void valueSumAndSampleCount(size_t timeStepIndex, double& valueSum, size_t& sampleCount);
virtual void addDataToHistogramCalculator(size_t timeStepIndex, RigHistogramCalculator& histogramCalculator);
virtual size_t timeStepCount();
private:
RigGeoMechCaseData* m_caseData;
RigFemPartResultsCollection* m_resultsData;
RigFemResultAddress m_resVarAddr;
cvf::cref<cvf::UByteArray> m_cellVisibilities;
template <typename StatisticsAccumulator>
void traverseElementNodes(StatisticsAccumulator& accumulator, size_t timeStepIndex)
{
int partCount = m_caseData->femParts()->partCount();
if (m_resVarAddr.resultPosType == RIG_NODAL)
{
for (int pIdx = 0; pIdx < partCount; ++pIdx)
{
RigFemPart* part = m_caseData->femParts()->part(pIdx);
const std::vector<float>& values = m_resultsData->resultValues(m_resVarAddr, pIdx, (int)timeStepIndex);
size_t nodeCount = values.size();
cvf::UByteArray nodeVisibilities(nodeCount);
nodeVisibilities.setAll(false);
int elmCount = part->elementCount();
for (int elmIdx = 0; elmIdx < elmCount; ++elmIdx)
{
if (!(*m_cellVisibilities)[elmIdx]) continue;
int elmNodeCount = RigFemTypes::elmentNodeCount(part->elementType(elmIdx));
for (int elmLocIdx = 0; elmLocIdx < elmNodeCount; ++elmLocIdx)
{
size_t elmNodeResIdx = part->elementNodeResultIdx(elmIdx, elmLocIdx);
int nodeIdx = part->nodeIdxFromElementNodeResultIdx(elmNodeResIdx);
nodeVisibilities[nodeIdx] = true;
}
}
for (size_t nodeIdx = 0; nodeIdx < nodeCount; ++nodeIdx)
{
if (nodeVisibilities[nodeIdx])
{
accumulator.addValue(values[nodeIdx]);
}
}
}
}
else
{
for (int pIdx = 0; pIdx < partCount; ++pIdx)
{
RigFemPart* part = m_caseData->femParts()->part(pIdx);
const std::vector<float>& values = m_resultsData->resultValues(m_resVarAddr, pIdx, (int)timeStepIndex);
int elmCount = part->elementCount();
for (int elmIdx = 0; elmIdx < elmCount; ++elmIdx)
{
if (!(*m_cellVisibilities)[elmIdx]) continue;
int elmNodeCount = RigFemTypes::elmentNodeCount(part->elementType(elmIdx));
for (int elmLocIdx = 0; elmLocIdx < elmNodeCount; ++elmLocIdx)
{
size_t elmNodeResIdx = part->elementNodeResultIdx(elmIdx, elmLocIdx);
accumulator.addValue(values[elmNodeResIdx]);
}
}
}
}
}
};

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

@ -245,16 +245,27 @@ cvf::Vec3i RigFemPartGrid::findMainIJKFaces(int elementIndex) const
CVF_ASSERT(false);
}
mainElmDirections[0].normalize();
mainElmDirections[1].normalize();
mainElmDirections[2].normalize();
// Match the element main directions with best XYZ match (IJK respectively)
// Find the max component of a mainElmDirection.
// Assign the index of that mainElmDirection to the mainElmDirectionIdxForIJK at the index of the max component.
// Find the mainElmDirection with the largest component starting with Z
// and use that for the corresponding IJK direction.
// Find the Z (for K) first. Then select among the other two the Y (for J),
// and select the remaining for I
int mainElmDirectionIdxForIJK[3] ={ -1, -1, -1 };
for (int dIdx = 0; dIdx < 3; ++dIdx)
for (int cIdx = 2; cIdx >= 0 ; --cIdx) // Check Z first as it is more important
{
double maxAbsComp = 0;
for (int cIdx = 2; cIdx >= 0 ; --cIdx)
double maxAbsComp = -1.0;
int usedDir1 = -1;
int usedDir2 = -1;
for (int dIdx = 0; dIdx < 3 ; ++dIdx)
{
if (dIdx == usedDir1 || dIdx == usedDir2) continue;
float absComp = fabs(mainElmDirections[dIdx][cIdx]);
if (absComp > maxAbsComp)
{
@ -262,25 +273,9 @@ cvf::Vec3i RigFemPartGrid::findMainIJKFaces(int elementIndex) const
mainElmDirectionIdxForIJK[cIdx] = dIdx;
}
}
}
// make sure all the main directions are used
bool mainDirsUsed[3] ={ false, false, false };
mainDirsUsed[mainElmDirectionIdxForIJK[0]] = true;
mainDirsUsed[mainElmDirectionIdxForIJK[1]] = true;
mainDirsUsed[mainElmDirectionIdxForIJK[2]] = true;
int unusedDir = -1;
if (!mainDirsUsed[0]) unusedDir = 0;
if (!mainDirsUsed[1]) unusedDir = 1;
if (!mainDirsUsed[2]) unusedDir = 2;
if (unusedDir >= 0)
{
if (mainElmDirectionIdxForIJK[0] == mainElmDirectionIdxForIJK[1]) mainElmDirectionIdxForIJK[0] = unusedDir;
else if (mainElmDirectionIdxForIJK[1] == mainElmDirectionIdxForIJK[2]) mainElmDirectionIdxForIJK[1] = unusedDir;
else if (mainElmDirectionIdxForIJK[2] == mainElmDirectionIdxForIJK[0]) mainElmDirectionIdxForIJK[2] = unusedDir;
if (usedDir1 == -1) usedDir1 = mainElmDirectionIdxForIJK[cIdx];
else usedDir2 = mainElmDirectionIdxForIJK[cIdx];
}
// Assign the correct face based on the main direction

View File

@ -781,6 +781,14 @@ void RigFemPartResultsCollection::meanScalarValue(const RigFemResultAddress& res
this->statistics(resVarAddr)->meanCellScalarValues(*meanValue);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFemPartResultsCollection::meanScalarValue(const RigFemResultAddress& resVarAddr, int frameIndex, double* meanValue)
{
this->statistics(resVarAddr)->meanCellScalarValues(frameIndex, *meanValue);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -789,6 +797,14 @@ void RigFemPartResultsCollection::p10p90ScalarValues(const RigFemResultAddress&
this->statistics(resVarAddr)->p10p90CellScalarValues(*p10, *p90);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFemPartResultsCollection::p10p90ScalarValues(const RigFemResultAddress& resVarAddr, int frameIndex, double* p10, double* p90)
{
this->statistics(resVarAddr)->p10p90CellScalarValues(frameIndex, *p10, *p90);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -797,3 +813,19 @@ const std::vector<size_t>& RigFemPartResultsCollection::scalarValuesHistogram(co
return this->statistics(resVarAddr)->cellScalarValuesHistogram();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<size_t>& RigFemPartResultsCollection::scalarValuesHistogram(const RigFemResultAddress& resVarAddr, int frameIndex)
{
return this->statistics(resVarAddr)->cellScalarValuesHistogram(frameIndex);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RigFemPartResultsCollection::partCount() const
{
return m_femParts->partCount();
}

View File

@ -43,17 +43,20 @@ public:
std::vector<std::string> stepNames();
bool assertResultsLoaded(const RigFemResultAddress& resVarAddr);
const std::vector<float>& resultValues(const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex);
int partCount() const;
int frameCount();
void minMaxScalarValues (const RigFemResultAddress& resVarAddr, int frameIndex, double* localMin, double* localMax);
void posNegClosestToZero(const RigFemResultAddress& resVarAddr, int frameIndex, double* localPosClosestToZero, double* localNegClosestToZero);
void minMaxScalarValues (const RigFemResultAddress& resVarAddr, double* globalMin, double* globalMax);
void posNegClosestToZero(const RigFemResultAddress& resVarAddr, int frameIndex, double* localPosClosestToZero, double* localNegClosestToZero);
void posNegClosestToZero(const RigFemResultAddress& resVarAddr, double* globalPosClosestToZero, double* globalNegClosestToZero);
void meanScalarValue(const RigFemResultAddress& resVarAddr, double* meanValue);
void meanScalarValue(const RigFemResultAddress& resVarAddr, int frameIndex, double* meanValue);
void p10p90ScalarValues(const RigFemResultAddress& resVarAddr, double* p10, double* p90);
void p10p90ScalarValues(const RigFemResultAddress& resVarAddr, int frameIndex, double* p10, double* p90);
const std::vector<size_t>& scalarValuesHistogram(const RigFemResultAddress& resVarAddr);
const std::vector<size_t>& scalarValuesHistogram(const RigFemResultAddress& resVarAddr, int frameIndex);
private:
RigFemScalarResultFrames* findOrLoadScalarResult(int partIndex,
@ -64,7 +67,6 @@ private:
RigFemScalarResultFrames* calculateBarConvertedResult(int partIndex, const RigFemResultAddress &convertedResultAddr, const std::string fieldNameToConvert);
RigFemScalarResultFrames* calculateEnIpPorBarResult(int partIndex, const RigFemResultAddress &convertedResultAddr);
friend class RigFemNativeStatCalc;
cvf::Collection<RigFemPartResults> m_femPartResults;
cvf::ref<RifGeoMechReaderInterface> m_readerInterface;
cvf::cref<RigFemPartCollection> m_femParts;

View File

@ -0,0 +1,148 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Statoil ASA
// Copyright (C) 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 "RigFemTimeHistoryResultAccessor.h"
#include "RigFemPart.h"
#include "RigFemPartCollection.h"
#include "RigFemPartGrid.h"
#include "RigFemPartResultsCollection.h"
#include "RigFemTypes.h"
#include "RigGeoMechCaseData.h"
#include <cmath> // Needed for HUGE_VAL on Linux
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemTimeHistoryResultAccessor::RigFemTimeHistoryResultAccessor(RigGeoMechCaseData* geomData, RigFemResultAddress femResultAddress,
size_t gridIndex, size_t cellIndex, const cvf::Vec3d& intersectionPoint)
: m_geoMechCaseData(geomData),
m_femResultAddress(femResultAddress),
m_gridIndex(gridIndex),
m_cellIndex(cellIndex),
m_intersectionPoint(intersectionPoint)
{
computeTimeHistoryData();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RigFemTimeHistoryResultAccessor::topologyText() const
{
QString text;
if (m_geoMechCaseData)
{
RigFemPart* femPart = m_geoMechCaseData->femParts()->part(m_gridIndex);
int elementId = femPart->elmId(m_cellIndex);
text += QString("Element : Id[%1]").arg(elementId);
size_t i = 0;
size_t j = 0;
size_t k = 0;
if (m_geoMechCaseData->femParts()->part(m_gridIndex)->structGrid()->ijkFromCellIndex(m_cellIndex, &i, &j, &k))
{
// Adjust to 1-based Eclipse indexing
i++;
j++;
k++;
cvf::Vec3d domainCoord = m_intersectionPoint;
text += QString(", ijk[%1, %2, %3]").arg(i).arg(j).arg(k);
QString formattedText;
formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", domainCoord.x(), domainCoord.y(), -domainCoord.z());
text += formattedText;
}
}
return text;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RigFemTimeHistoryResultAccessor::timeHistoryValues() const
{
return m_timeHistoryValues;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFemTimeHistoryResultAccessor::computeTimeHistoryData()
{
m_timeHistoryValues.clear();
size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T;
// Compute scalar result index from geometry
{
RigFemPart* femPart = m_geoMechCaseData->femParts()->part(m_gridIndex);
RigElementType elmType = femPart->elementType(m_cellIndex);
const int* elmentConn = femPart->connectivities(m_cellIndex);
int elmNodeCount = RigFemTypes::elmentNodeCount(elmType);
// Find the closest node
int closestLocalNode = -1;
float minDist = std::numeric_limits<float>::infinity();
for (int lNodeIdx = 0; lNodeIdx < elmNodeCount; ++lNodeIdx)
{
int nodeIdx = elmentConn[lNodeIdx];
cvf::Vec3f nodePos = femPart->nodes().coordinates[nodeIdx];
float dist = (nodePos - cvf::Vec3f(m_intersectionPoint)).lengthSquared();
if (dist < minDist)
{
closestLocalNode = lNodeIdx;
minDist = dist;
}
}
// Create a text showing the results from the closest node
if (closestLocalNode >= 0)
{
int nodeIdx = elmentConn[closestLocalNode];
if (m_femResultAddress.resultPosType == RIG_NODAL)
{
scalarResultIndex = static_cast<size_t>(nodeIdx);
}
else
{
scalarResultIndex = femPart->elementNodeResultIdx(static_cast<int>(m_cellIndex), closestLocalNode);
}
}
}
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) return;
RigFemPartResultsCollection* femPartResultsColl = m_geoMechCaseData->femPartResults();
for (int frameIdx = 0; frameIdx < femPartResultsColl->frameCount(); frameIdx++)
{
const std::vector<float>& scalarResults = m_geoMechCaseData->femPartResults()->resultValues(m_femResultAddress, static_cast<int>(m_gridIndex), frameIdx);
if (scalarResults.size())
{
float scalarValue = scalarResults[scalarResultIndex];
m_timeHistoryValues.push_back(scalarValue);
}
}
}

View File

@ -0,0 +1,54 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Statoil ASA
// Copyright (C) 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 "RigFemResultAddress.h"
#include "cvfStructGrid.h"
#include "cvfVector3.h"
class RigGeoMechCaseData;
class RigFemTimeHistoryResultAccessor
{
public:
RigFemTimeHistoryResultAccessor(RigGeoMechCaseData* geomData, RigFemResultAddress femResultAddress,
size_t gridIndex, size_t cellIndex, const cvf::Vec3d& intersectionPoint);
QString topologyText() const;
std::vector<double> timeHistoryValues() const;
private:
void computeTimeHistoryData();
private:
RigGeoMechCaseData* m_geoMechCaseData;
RigFemResultAddress m_femResultAddress;
size_t m_gridIndex;
size_t m_cellIndex;
size_t m_scalarResultIndex;
cvf::Vec3d m_intersectionPoint;
std::vector<double> m_timeHistoryValues;
};

View File

@ -119,8 +119,6 @@ void RivFemElmVisibilityCalculator::computePropertyVisibility(cvf::UByteArray* c
// Do a "Hack" to use elm nodal and not nodal POR results
if (resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar") resVarAddress.resultPosType = RIG_ELEMENT_NODAL;
size_t adjustedTimeStepIndex = timeStepIndex;
const RimCellFilter::FilterModeType filterType = propertyFilter->filterMode();
RigGeoMechCaseData* caseData = propFilterColl->reservoirView()->geoMechCase()->geoMechData();

View File

@ -1,18 +1,17 @@
#include <stdlib.h>
#include "RivFemPartGeometryGenerator.h"
#include "cvfBase.h"
#include "RigFemPart.h"
//#include "RigFemPartScalarDataAccess.h"
#include "cvfBase.h"
#include "cvfArray.h"
#include "cvfDebugTimer.h"
#include "cvfGeometryBuilderDrawableGeo.h"
#include "cvfDrawableGeo.h"
#include "cvfOutlineEdgeExtractor.h"
#include "cvfPrimitiveSetIndexedUInt.h"
#include "cvfScalarMapper.h"
#include "cvfArray.h"
#include "cvfOutlineEdgeExtractor.h"
#include <stdlib.h>
#include <cmath>
@ -68,7 +67,6 @@ ref<DrawableGeo> RivFemPartGeometryGenerator::generateSurface()
//--------------------------------------------------------------------------------------------------
ref<DrawableGeo> RivFemPartGeometryGenerator::createMeshDrawable()
{
if (!(m_quadVertices.notNull() && m_quadVertices->size() != 0)) return NULL;
ref<DrawableGeo> geo = new DrawableGeo;
@ -179,7 +177,6 @@ void RivFemPartGeometryGenerator::computeArrays()
{
RigElementType eType = m_part->elementType(elmIdx);
int faceCount = RigFemTypes::elmentFaceCount(eType);
int elmQuadCount = 0;
const int* elmNodeIndices = m_part->connectivities(elmIdx);
@ -265,3 +262,54 @@ void RivFemPartGeometryGenerator::setElementVisibility(const cvf::UByteArray* ce
m_elmVisibility = cellVisibility;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableGeo> RivFemPartGeometryGenerator::createMeshDrawableFromSingleElement(const RigFemPart* part, size_t elmIdx)
{
cvf::ref<cvf::Vec3fArray> quadVertices;
{
std::vector<Vec3f> vertices;
const std::vector<cvf::Vec3f>& nodeCoordinates = part->nodes().coordinates;
RigElementType eType = part->elementType(elmIdx);
int faceCount = RigFemTypes::elmentFaceCount(eType);
const int* elmNodeIndices = part->connectivities(elmIdx);
for (int lfIdx = 0; lfIdx < faceCount; ++lfIdx)
{
int faceNodeCount = 0;
const int* localElmNodeIndicesForFace = RigFemTypes::localElmNodeIndicesForFace(eType, lfIdx, &faceNodeCount);
if (faceNodeCount == 4)
{
vertices.push_back(nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[0]]]);
vertices.push_back(nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[1]]]);
vertices.push_back(nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[2]]]);
vertices.push_back(nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[3]]]);
}
else
{
// Handle triangles and 6 node and 8 node faces
}
}
quadVertices = new cvf::Vec3fArray;
quadVertices->assign(vertices);
}
if (!(quadVertices.notNull() && quadVertices->size() != 0)) return NULL;
ref<DrawableGeo> geo = new DrawableGeo;
geo->setVertexArray(quadVertices.p());
ref<UIntArray> indices = lineIndicesFromQuadVertexArray(quadVertices.p());
ref<PrimitiveSetIndexedUInt> prim = new PrimitiveSetIndexedUInt(PT_LINES);
prim->setIndices(indices.p());
geo->addPrimitiveSet(prim.p());
return geo;
}

View File

@ -1,6 +1,7 @@
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfArray.h"
@ -64,6 +65,8 @@ public:
RivFemPartTriangleToElmMapper* triangleToElementMapper() { return m_triangleMapper.p();}
static cvf::ref<cvf::DrawableGeo> createMeshDrawableFromSingleElement(const RigFemPart* grid, size_t elementIndex);
private:
static cvf::ref<cvf::UIntArray>
lineIndicesFromQuadVertexArray(const cvf::Vec3fArray* vertexArray);

View File

@ -144,7 +144,7 @@ void RivFemPartPartMgr::generatePartGeometry(RivFemPartGeometryGenerator& geoBui
}
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName("Grid mesh " + m_gridIdx);
part->setName("Grid mesh " + cvf::String(m_gridIdx));
part->setDrawable(geoMesh.p());
part->setTransform(m_scaleTransform.p());
@ -218,8 +218,6 @@ void RivFemPartPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechCe
{
CVF_ASSERT(cellResultColors);
// RigCaseData* eclipseCase = cellResultColors->reservoirView()->eclipseCase()->reservoirData();
cvf::ref<cvf::Color3ubArray> surfaceFacesColorArray;
// Outer surface
@ -295,7 +293,12 @@ void RivFemPartPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechCe
cellResultColors->firstAnchestorOrThisOfType(view);
CVF_ASSERT(view);
RivScalarMapperUtils::applyTextureResultsToPart(m_surfaceFaces.p(), m_surfaceFacesTextureCoords.p(), mapper, m_opacityLevel, caf::FC_NONE, view->isLightingDisabled());
RivScalarMapperUtils::applyTextureResultsToPart(m_surfaceFaces.p(),
m_surfaceFacesTextureCoords.p(),
mapper,
m_opacityLevel,
caf::FC_NONE,
view->isLightingDisabled());
}
}

View File

@ -114,7 +114,7 @@ void RivGeoMechVizLogic::scheduleGeometryRegen(RivCellSetEnum geometryType)
this->scheduleRegenOfDirectlyDependentGeometry(geometryType);
int frameCount = 0;
if (m_geomechView->geoMechCase()->geoMechData())
if (m_geomechView->geoMechCase() && m_geomechView->geoMechCase()->geoMechData())
{
frameCount = m_geomechView->geoMechCase()->geoMechData()->femPartResults()->frameCount();
}
@ -144,7 +144,7 @@ std::vector<RivGeoMechPartMgrCache::Key> RivGeoMechVizLogic::keysToVisiblePartMg
{
visiblePartMgrs.push_back(RivGeoMechPartMgrCache::Key(OVERRIDDEN_CELL_VISIBILITY, -1));
}
else if (timeStepIndex >= 0 && m_geomechView->propertyFilterCollection()->hasActiveFilters())
else if (timeStepIndex >= 0 && m_geomechView->geoMechPropertyFilterCollection()->hasActiveFilters())
{
visiblePartMgrs.push_back(RivGeoMechPartMgrCache::Key(PROPERTY_FILTERED, timeStepIndex));
}
@ -209,7 +209,7 @@ RivGeoMechPartMgr* RivGeoMechVizLogic::getUpdatedPartMgr(RivGeoMechPartMgrCache:
caseData->femParts()->part(femPartIdx),
pMgrKey.frameIndex(),
rangeFiltVisibility.p(),
m_geomechView->propertyFilterCollection()
m_geomechView->geoMechPropertyFilterCollection()
);
}
else if (pMgrKey.geometryType() == OVERRIDDEN_CELL_VISIBILITY)

View File

@ -9,6 +9,8 @@ ${CEE_CURRENT_LIST_DIR}RivCellEdgeEffectGenerator.h
${CEE_CURRENT_LIST_DIR}RivColorTableArray.h
${CEE_CURRENT_LIST_DIR}RivFaultPartMgr.h
${CEE_CURRENT_LIST_DIR}RivFaultGeometryGenerator.h
${CEE_CURRENT_LIST_DIR}RivCrossSectionGeometryGenerator.h
${CEE_CURRENT_LIST_DIR}RivCrossSectionPartMgr.h
${CEE_CURRENT_LIST_DIR}RivNNCGeometryGenerator.h
${CEE_CURRENT_LIST_DIR}RivGridPartMgr.h
${CEE_CURRENT_LIST_DIR}RivTernarySaturationOverlayItem.h
@ -32,8 +34,9 @@ ${CEE_CURRENT_LIST_DIR}RivTernaryScalarMapperEffectGenerator.h
${CEE_CURRENT_LIST_DIR}RivScalarMapperUtils.h
${CEE_CURRENT_LIST_DIR}RivCellEdgeGeometryUtils.h
${CEE_CURRENT_LIST_DIR}RivPipeQuadToSegmentMapper.h
${CEE_CURRENT_LIST_DIR}RivSingleCellPartGenerator.h
${CEE_CURRENT_LIST_DIR}RivWellPipeSourceInfo.h
${CEE_CURRENT_LIST_DIR}RivCrossSectionSourceInfo.h
)
set (SOURCE_GROUP_SOURCE_FILES
@ -41,6 +44,8 @@ ${CEE_CURRENT_LIST_DIR}RivCellEdgeEffectGenerator.cpp
${CEE_CURRENT_LIST_DIR}RivColorTableArray.cpp
${CEE_CURRENT_LIST_DIR}RivFaultPartMgr.cpp
${CEE_CURRENT_LIST_DIR}RivNNCGeometryGenerator.cpp
${CEE_CURRENT_LIST_DIR}RivCrossSectionGeometryGenerator.cpp
${CEE_CURRENT_LIST_DIR}RivCrossSectionPartMgr.cpp
${CEE_CURRENT_LIST_DIR}RivFaultGeometryGenerator.cpp
${CEE_CURRENT_LIST_DIR}RivGridPartMgr.cpp
${CEE_CURRENT_LIST_DIR}RivTernarySaturationOverlayItem.cpp
@ -62,7 +67,9 @@ ${CEE_CURRENT_LIST_DIR}RivTernaryScalarMapperEffectGenerator.cpp
${CEE_CURRENT_LIST_DIR}RivScalarMapperUtils.cpp
${CEE_CURRENT_LIST_DIR}RivCellEdgeGeometryUtils.cpp
${CEE_CURRENT_LIST_DIR}RivPipeQuadToSegmentMapper.cpp
${CEE_CURRENT_LIST_DIR}RivSingleCellPartGenerator.cpp
${CEE_CURRENT_LIST_DIR}RivWellPipeSourceInfo.cpp
${CEE_CURRENT_LIST_DIR}RivCrossSectionSourceInfo.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -0,0 +1,26 @@
# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly
if (${CMAKE_VERSION} VERSION_GREATER "2.8.2")
set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/)
endif()
set (SOURCE_GROUP_HEADER_FILES
${CEE_CURRENT_LIST_DIR}RivPatchGenerator.h
${CEE_CURRENT_LIST_DIR}RivGridBoxGenerator.h
)
set (SOURCE_GROUP_SOURCE_FILES
${CEE_CURRENT_LIST_DIR}RivPatchGenerator.cpp
${CEE_CURRENT_LIST_DIR}RivGridBoxGenerator.cpp
)
list(APPEND CODE_HEADER_FILES
${SOURCE_GROUP_HEADER_FILES}
)
list(APPEND CODE_SOURCE_FILES
${SOURCE_GROUP_SOURCE_FILES}
)
source_group( "ModelVisualization\\GridBox" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake )

View File

@ -0,0 +1,714 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RivGridBoxGenerator.h"
#include "RiaApplication.h"
#include "RivPatchGenerator.h"
#include "cafEffectGenerator.h"
#include "cvfCamera.h"
#include "cvfDrawableText.h"
#include "cvfFixedAtlasFont.h"
#include "cvfGeometryBuilderDrawableGeo.h"
#include "cvfGeometryBuilderFaceList.h"
#include "cvfMeshEdgeExtractor.h"
#include "cvfPrimitiveSetIndexedUInt.h"
#include "cvfRenderStateDepth.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivGridBoxGenerator::RivGridBoxGenerator()
: m_gridColor(cvf::Color3f::LIGHT_GRAY),
m_gridLegendColor(cvf::Color3f::BLACK)
{
m_gridBoxModel = new cvf::ModelBasicList;
m_scaleZ = 1.0;
m_displayModelOffset = cvf::Vec3d::ZERO;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGridBoxGenerator::setScaleZ(double scaleZ)
{
m_scaleZ = scaleZ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGridBoxGenerator::setDisplayModelOffset(cvf::Vec3d offset)
{
m_displayModelOffset = offset;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGridBoxGenerator::setGridBoxDomainCoordBoundingBox(const cvf::BoundingBox& bb)
{
cvf::BoundingBox expandedBB;
{
double expandFactor = 0.05;
cvf::Vec3d expandedMin;
expandedMin.x() = bb.min().x() - bb.extent().x() * expandFactor;
expandedMin.y() = bb.min().y() - bb.extent().y() * expandFactor;
expandedMin.z() = bb.min().z() - bb.extent().z() * expandFactor;
cvf::Vec3d expandedMax;
expandedMax.x() = bb.max().x() + bb.extent().x() * expandFactor;
expandedMax.y() = bb.max().y() + bb.extent().y() * expandFactor;
expandedMax.z() = bb.max().z() + bb.extent().z() * expandFactor;
expandedBB.add(expandedMin);
expandedBB.add(expandedMax);
}
m_domainCoordsBoundingBox = expandedBB;
m_domainCoordsXValues.clear();
m_domainCoordsYValues.clear();
m_domainCoordsZValues.clear();
cvf::Vec3d min = m_domainCoordsBoundingBox.min();
cvf::Vec3d max = m_domainCoordsBoundingBox.max();
cvf::ScalarMapperDiscreteLinear m_linDiscreteScalarMapper;
size_t levelCount = 6;
m_linDiscreteScalarMapper.setRange(min.x(), max.x());
m_linDiscreteScalarMapper.setLevelCount(levelCount, true);
m_linDiscreteScalarMapper.majorTickValues(&m_domainCoordsXValues);
m_linDiscreteScalarMapper.setRange(min.y(), max.y());
m_linDiscreteScalarMapper.setLevelCount(levelCount, true);
m_linDiscreteScalarMapper.majorTickValues(&m_domainCoordsYValues);
m_linDiscreteScalarMapper.setRange(min.z(), max.z());
m_linDiscreteScalarMapper.setLevelCount(levelCount, true);
m_linDiscreteScalarMapper.majorTickValues(&m_domainCoordsZValues);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGridBoxGenerator::createGridBoxParts()
{
computeDisplayCoords();
createGridBoxFaceParts();
createGridBoxLegendParts();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGridBoxGenerator::updateFromCamera(const cvf::Camera* camera)
{
m_gridBoxModel->removeAllParts();
if (m_gridBoxFaceParts.size() == 0) return;
std::vector<bool> faceVisibility(6, false);
for (size_t i = POS_X; i <= NEG_Z; i++)
{
cvf::Vec3f sideNorm = sideNormalOutwards((FaceType)i);
cvf::Vec3d camToSide = camera->position() - pointOnSide((FaceType)i);
camToSide.normalize();
if (sideNorm.dot(cvf::Vec3f(camToSide)) < 0.0)
{
m_gridBoxModel->addPart(m_gridBoxFaceParts[i].p());
faceVisibility[i] = true;
}
}
std::vector<bool> edgeVisibility(12, false);
computeEdgeVisibility(faceVisibility, edgeVisibility);
CVF_ASSERT(m_gridBoxLegendParts.size() == (NEG_X_NEG_Y + 1)*2);
for (size_t i = POS_Z_POS_X; i <= NEG_X_NEG_Y; i++)
{
if (edgeVisibility[i])
{
// We have two parts for each edge - line and text
m_gridBoxModel->addPart(m_gridBoxLegendParts[2 * i].p());
m_gridBoxModel->addPart(m_gridBoxLegendParts[2 * i + 1].p());
}
}
m_gridBoxModel->updateBoundingBoxesRecursive();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGridBoxGenerator::computeEdgeVisibility(const std::vector<bool>& faceVisibility, std::vector<bool>& edgeVisibility)
{
CVF_ASSERT(faceVisibility.size() == NEG_Z + 1);
CVF_ASSERT(edgeVisibility.size() == NEG_X_NEG_Y + 1);
// POS Z
if (faceVisibility[POS_Z] ^ faceVisibility[POS_X])
{
edgeVisibility[POS_Z_POS_X] = true;
}
if (faceVisibility[POS_Z] ^ faceVisibility[NEG_X])
{
edgeVisibility[POS_Z_NEG_X] = true;
}
if (faceVisibility[POS_Z] ^ faceVisibility[POS_Y])
{
edgeVisibility[POS_Z_POS_Y] = true;
}
if (faceVisibility[POS_Z] ^ faceVisibility[NEG_Y])
{
edgeVisibility[POS_Z_NEG_Y] = true;
}
// NEG Z
if (faceVisibility[NEG_Z] ^ faceVisibility[POS_X])
{
edgeVisibility[NEG_Z_POS_X] = true;
}
if (faceVisibility[NEG_Z] ^ faceVisibility[NEG_X])
{
edgeVisibility[NEG_Z_NEG_X] = true;
}
if (faceVisibility[NEG_Z] ^ faceVisibility[POS_Y])
{
edgeVisibility[NEG_Z_POS_Y] = true;
}
if (faceVisibility[NEG_Z] ^ faceVisibility[NEG_Y])
{
edgeVisibility[NEG_Z_NEG_Y] = true;
}
// POS X
if (faceVisibility[POS_X] ^ faceVisibility[POS_Y])
{
edgeVisibility[POS_X_POS_Y] = true;
}
if (faceVisibility[POS_X] ^ faceVisibility[NEG_Y])
{
edgeVisibility[POS_X_NEG_Y] = true;
}
// NEG X
if (faceVisibility[NEG_X] ^ faceVisibility[POS_Y])
{
edgeVisibility[NEG_X_POS_Y] = true;
}
if (faceVisibility[NEG_X] ^ faceVisibility[NEG_Y])
{
edgeVisibility[NEG_X_NEG_Y] = true;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Model* RivGridBoxGenerator::model()
{
return m_gridBoxModel.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGridBoxGenerator::createGridBoxFaceParts()
{
m_gridBoxFaceParts.clear();
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++)
{
// TODO: move out of loop
RivPatchGenerator patchGen;
if (face == POS_X)
{
patchGen.setOrigin(cvf::Vec3d(max.x(), 0.0, 0.0));
patchGen.setAxes(cvf::Vec3d::Y_AXIS, cvf::Vec3d::Z_AXIS);
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_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_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_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_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_displayCoordsXValues, m_displayCoordsYValues);
}
else
{
CVF_ASSERT(false);
}
cvf::GeometryBuilderFaceList builder;
patchGen.generate(&builder);
cvf::ref<cvf::Vec3fArray> vertexArray = builder.vertices();
cvf::ref<cvf::UIntArray> faceList = builder.faceList();
{
// Box mesh
cvf::MeshEdgeExtractor ee;
ee.addFaceList(*faceList);
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
geo->setVertexArray(vertexArray.p());
geo->addPrimitiveSet(new cvf::PrimitiveSetIndexedUInt(cvf::PT_LINES, ee.lineIndices().p()));
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName("Grid box ");
part->setDrawable(geo.p());
part->updateBoundingBox();
cvf::ref<cvf::Effect> eff;
caf::MeshEffectGenerator effGen(m_gridColor);
eff = effGen.generateCachedEffect();
part->setEffect(eff.p());
m_gridBoxFaceParts.push_back(part.p());
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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;
createLegend((EdgeType)edge, &parts);
for (size_t i = 0; i < parts.size(); i++)
{
m_gridBoxLegendParts.push_back(parts.at(i));
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3d RivGridBoxGenerator::displayModelCoordFromDomainCoord(const cvf::Vec3d& domainCoord) const
{
cvf::Vec3d coord = domainCoord - m_displayModelOffset;
coord.z() *= m_scaleZ;
return coord;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGridBoxGenerator::createLegend(EdgeType edge, cvf::Collection<cvf::Part>* parts)
{
cvf::Vec3d posMin = cvf::Vec3d::ZERO;
cvf::Vec3d posMax = cvf::Vec3d::ZERO;
cvf::Vec3d min = m_displayCoordsBoundingBox.min();
cvf::Vec3d max = m_displayCoordsBoundingBox.max();
AxisType axis = X_AXIS;
cvf::Vec3f tickMarkDir = cvf::Vec3f::X_AXIS;
switch (edge)
{
case RivGridBoxGenerator::POS_Z_POS_X:
axis = Y_AXIS;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
posMin.set(min.x(), min.y(), min.z());
posMax.set(min.x(), min.y(), max.z());
tickMarkDir = cornerDirection(NEG_X, NEG_Y);
break;
default:
CVF_TIGHT_ASSERT(false);
break;
}
std::vector<double>* displayCoordsTickValues = NULL;
std::vector<double>* domainCoordsTickValues = NULL;
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);
cvf::ref<cvf::UIntArray> indices = new cvf::UIntArray;
indices->reserve(2 * numLines);
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 < displayCoordsTickValues->size(); ++i)
{
point[axis] = static_cast<float>(displayCoordsTickValues->at(i));
vertices->add(point);
tickPoint = point + tickLength*tickMarkDir;;
vertices->add(tickPoint);
if (i == 0 || i == displayCoordsTickValues->size() - 1)
{
// Do not show tick mark at ends of legend
// Add to list of indices to keep surrounding code unchanged
indices->add(2 * static_cast<cvf::uint>(i));
indices->add(2 * static_cast<cvf::uint>(i));
}
else
{
indices->add(2 * static_cast<cvf::uint>(i));
indices->add(2 * static_cast<cvf::uint>(i) + 1);
}
}
// Backbone of legend
indices->add(0);
indices->add(static_cast<cvf::uint>(numVerts) - 2);
{
// Legend lines
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
geo->setVertexArray(vertices.p());
cvf::ref<cvf::PrimitiveSetIndexedUInt> primSet = new cvf::PrimitiveSetIndexedUInt(cvf::PT_LINES);
primSet->setIndices(indices.p());
geo->addPrimitiveSet(primSet.p());
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName("Legend lines");
part->setDrawable(geo.p());
part->updateBoundingBox();
cvf::ref<cvf::Effect> eff;
caf::MeshEffectGenerator effGen(m_gridLegendColor);
eff = effGen.generateUnCachedEffect();
cvf::ref<cvf::RenderStateDepth> depth = new cvf::RenderStateDepth;
depth->enableDepthTest(false);
eff->setRenderState(depth.p());
part->setPriority(1500);
part->setEffect(eff.p());
parts->push_back(part.p());
}
{
// Text labels
cvf::ref<cvf::DrawableText> geo = new cvf::DrawableText;
cvf::Font* standardFont = RiaApplication::instance()->standardFont();
geo->setFont(standardFont);
geo->setTextColor(m_gridLegendColor);
geo->setCheckPosVisible(false);
geo->setDrawBackground(false);
geo->setDrawBorder(false);
// Do not draw legend labels at first/last tick mark
for (size_t idx = 1; idx < domainCoordsTickValues->size() - 1; idx++)
{
double legendValue = domainCoordsTickValues->at(idx);
if (axis == Z_AXIS)
{
legendValue = -domainCoordsTickValues->at(idx);
}
cvf::int64 integerValue = static_cast<cvf::int64>(legendValue);
cvf::String numberText = cvf::String("%1").arg(integerValue);
geo->addText(numberText, vertices->get(idx*2 + 1) + (0.5f * tickLength) * tickMarkDir);
}
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName("Legend text");
part->setDrawable(geo.p());
part->updateBoundingBox();
caf::TextEffectGenerator textGen;
cvf::ref<cvf::Effect> eff = textGen.generateCachedEffect();
part->setEffect(eff.p());
parts->push_back(part.p());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3f RivGridBoxGenerator::sideNormalOutwards(FaceType face)
{
switch (face)
{
case RivGridBoxGenerator::POS_X:
return cvf::Vec3f::X_AXIS;
case RivGridBoxGenerator::NEG_X:
return -cvf::Vec3f::X_AXIS;
case RivGridBoxGenerator::POS_Y:
return cvf::Vec3f::Y_AXIS;
case RivGridBoxGenerator::NEG_Y:
return -cvf::Vec3f::Y_AXIS;
case RivGridBoxGenerator::POS_Z:
return cvf::Vec3f::Z_AXIS;
case RivGridBoxGenerator::NEG_Z:
return -cvf::Vec3f::Z_AXIS;
default:
break;
}
return cvf::Vec3f::ZERO;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3d RivGridBoxGenerator::pointOnSide(FaceType face)
{
switch (face)
{
case RivGridBoxGenerator::POS_X:
case RivGridBoxGenerator::POS_Y:
case RivGridBoxGenerator::POS_Z:
return cvf::Vec3d(m_displayCoordsBoundingBox.max());
case RivGridBoxGenerator::NEG_X:
case RivGridBoxGenerator::NEG_Y:
case RivGridBoxGenerator::NEG_Z:
return cvf::Vec3d(m_displayCoordsBoundingBox.min());
default:
break;
}
return cvf::Vec3d::ZERO;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3f RivGridBoxGenerator::cornerDirection(FaceType face1, FaceType face2)
{
cvf::Vec3f dir = sideNormalOutwards(face1) + sideNormalOutwards(face2);
dir.normalize();
return dir;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivGridBoxGenerator::updateFromBackgroundColor(const cvf::Color3f& backgroundColor)
{
double adjustmentFactor = 0.3;
float gridR = 0.0;
float gridG = 0.0;
float gridB = 0.0;
if (backgroundColor.r() + backgroundColor.g() + backgroundColor.b() > 1.5f)
{
gridR = backgroundColor.r() - (backgroundColor.r() * adjustmentFactor);
gridG = backgroundColor.g() - (backgroundColor.g() * adjustmentFactor);
gridB = backgroundColor.b() - (backgroundColor.b() * adjustmentFactor);
m_gridLegendColor = cvf::Color3f::fromByteColor(10, 10, 10);
}
else
{
gridR = backgroundColor.r() + (1.0 - backgroundColor.r()) * adjustmentFactor;
gridG = backgroundColor.g() + (1.0 - backgroundColor.g()) * adjustmentFactor;
gridB = backgroundColor.b() + (1.0 - backgroundColor.b()) * adjustmentFactor;
m_gridLegendColor = cvf::Color3f::WHITE;
}
m_gridColor.set(gridR, gridG, gridB);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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

@ -0,0 +1,130 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cvfBase.h"
#include "cvfCollection.h"
#include "cvfModelBasicList.h"
#include "cvfPart.h"
#include "cvfTransform.h"
#include "cvfScalarMapperDiscreteLinear.h"
namespace cvf
{
class Camera;
class ShaderProgram;
}
//==================================================================================================
//
//
//==================================================================================================
class RivGridBoxGenerator
{
public:
RivGridBoxGenerator();
void setScaleZ(double scaleZ);
void setDisplayModelOffset(cvf::Vec3d offset);
void setGridBoxDomainCoordBoundingBox(const cvf::BoundingBox& boundingBox);
void updateFromBackgroundColor(const cvf::Color3f& backgroundColor);
void createGridBoxParts();
void updateFromCamera(const cvf::Camera* camera);
cvf::Model* model();
private:
enum AxisType
{
X_AXIS,
Y_AXIS,
Z_AXIS
};
enum FaceType
{
POS_X,
NEG_X,
POS_Y,
NEG_Y,
POS_Z,
NEG_Z
};
enum EdgeType
{
POS_Z_POS_X,
POS_Z_NEG_X,
POS_Z_POS_Y,
POS_Z_NEG_Y,
NEG_Z_POS_X,
NEG_Z_NEG_X,
NEG_Z_POS_Y,
NEG_Z_NEG_Y,
POS_X_POS_Y,
POS_X_NEG_Y,
NEG_X_POS_Y,
NEG_X_NEG_Y
};
private:
void createGridBoxFaceParts();
void createGridBoxLegendParts();
void createLegend(EdgeType edge, cvf::Collection<cvf::Part>* parts);
void computeEdgeVisibility(const std::vector<bool>& faceVisibility, std::vector<bool>& edgeVisibility);
void computeDisplayCoords();
cvf::Vec3d displayModelCoordFromDomainCoord(const cvf::Vec3d& domainCoord) const;
cvf::Vec3f sideNormalOutwards(FaceType face);
cvf::Vec3d pointOnSide(FaceType face);
cvf::Vec3f cornerDirection(FaceType face1, FaceType face2);
private:
cvf::BoundingBox m_domainCoordsBoundingBox;
std::vector<double> m_domainCoordsXValues;
std::vector<double> m_domainCoordsYValues;
std::vector<double> m_domainCoordsZValues;
cvf::BoundingBox m_displayCoordsBoundingBox;
std::vector<double> m_displayCoordsXValues;
std::vector<double> m_displayCoordsYValues;
std::vector<double> m_displayCoordsZValues;
double m_scaleZ;
cvf::Vec3d m_displayModelOffset;
cvf::Collection<cvf::Part> m_gridBoxFaceParts;
cvf::Collection<cvf::Part> m_gridBoxLegendParts;
cvf::ref<cvf::ModelBasicList> m_gridBoxModel;
cvf::Color3f m_gridColor;
cvf::Color3f m_gridLegendColor;
};

View File

@ -0,0 +1,123 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RivPatchGenerator.h"
#include "cvfGeometryUtils.h"
#include "cvfArray.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivPatchGenerator::RivPatchGenerator()
: m_origin(0, 0, 0),
m_axisU(cvf::Vec3d::X_AXIS),
m_axisV(cvf::Vec3d::Y_AXIS),
m_useQuads(true),
m_windingCCW(true)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivPatchGenerator::setOrigin(const cvf::Vec3d& origin)
{
m_origin = origin;
}
//--------------------------------------------------------------------------------------------------
/// Set the axes
///
/// The specified axes will be normalized
//--------------------------------------------------------------------------------------------------
void RivPatchGenerator::setAxes(const cvf::Vec3d& axisU, const cvf::Vec3d& axisV)
{
m_axisU = axisU.getNormalized();
m_axisV = axisV.getNormalized();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivPatchGenerator::setSubdivisions(const std::vector<double>& uValues, const std::vector<double>& vValues)
{
m_uValues = uValues;
m_vValues = vValues;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivPatchGenerator::setQuads(bool useQuads)
{
m_useQuads = useQuads;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivPatchGenerator::setWindingCCW(bool windingCCW)
{
m_windingCCW = windingCCW;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivPatchGenerator::generate(cvf::GeometryBuilder* builder)
{
CVF_ASSERT(m_uValues.size() > 0);
CVF_ASSERT(m_vValues.size() > 0);
size_t numVertices = m_uValues.size() * m_vValues.size();
cvf::Vec3fArray vertices;
vertices.reserve(numVertices);
for (size_t v = 0; v < m_vValues.size(); v++)
{
cvf::Vec3d rowOrigo(m_origin + m_axisV * m_vValues[v]);
for (size_t u = 0; u < m_uValues.size(); u++)
{
vertices.add(cvf::Vec3f(rowOrigo + m_axisU * m_uValues[u]));
}
}
cvf::uint baseNodeIdx = builder->addVertices(vertices);
if (m_useQuads)
{
cvf::UIntArray conn;
cvf::GeometryUtils::tesselatePatchAsQuads(static_cast<int>(m_uValues.size()), static_cast<int>(m_vValues.size()), baseNodeIdx, m_windingCCW, &conn);
builder->addQuads(conn);
}
else
{
cvf::UIntArray conn;
cvf::GeometryUtils::tesselatePatchAsTriangles(static_cast<int>(m_uValues.size()), static_cast<int>(m_vValues.size()), baseNodeIdx, m_windingCCW, &conn);
builder->addTriangles(conn);
}
}

View File

@ -0,0 +1,64 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cvfBase.h"
#include "cvfVector3.h"
#include <vector>
namespace cvf
{
class GeometryBuilder;
}
//==================================================================================================
//
// Generates 2D patches based on predefined coordinates along u and v axis
// Inspired by cvf::PatchGenerator
//
//==================================================================================================
class RivPatchGenerator
{
public:
RivPatchGenerator();
void setOrigin(const cvf::Vec3d& origin);
void setAxes(const cvf::Vec3d& axisU, const cvf::Vec3d& axisV);
void setSubdivisions(const std::vector<double>& uValues, const std::vector<double>& vValues);
void setQuads(bool useQuads);
void setWindingCCW(bool windingCCW);
void generate(cvf::GeometryBuilder* builder);
private:
cvf::Vec3d m_origin; // Origin. Default (0, 0, 0)
cvf::Vec3d m_axisU; // First axis of patch. Default is global X-axis
cvf::Vec3d m_axisV; // Second axis of patch. Default is global Y-axis
std::vector<double> m_uValues;
std::vector<double> m_vValues;
bool m_useQuads; // If true, quads will be generated, otherwise triangles. Default is quads
bool m_windingCCW; // Winding of the generated quads. Controls which side of the patch will be front facing.
};

View File

@ -1,71 +0,0 @@
cmake_minimum_required (VERSION 2.8)
SET (ProjectName ModelVisualization_UnitTests)
project ( ${ProjectName} )
include_directories(
${LibCore_SOURCE_DIR}
${LibGeometry_SOURCE_DIR}
${LibRender_SOURCE_DIR}
${LibViewing_SOURCE_DIR}
${ResInsight_SOURCE_DIR}/ThirdParty
${ResInsight_SOURCE_DIR}/ApplicationCode/ModelVisualization
${CommonCode_SOURCE_DIR}
)
set( MODEL_VISUALIZATION_CPP_SOURCES
../RivPipeGeometryGenerator.cpp
../RivTernaryScalarMapper.cpp
)
set( CPP_SOURCES
${MODEL_VISUALIZATION_CPP_SOURCES}
)
set( UNIT_TEST_CPP_SOURCES
main.cpp
RivPipeGeometryGenerator-Test.cpp
RivTernaryScalarMapper-Test.cpp
)
set( LINK_LIBRARIES
LibViewing
LibRender
LibGeometry
LibCore
LibGuiQt
CommonCode
${OPENGL_LIBRARIES}
${QT_LIBRARIES}
)
add_executable( ${ProjectName}
${CPP_SOURCES}
${UNIT_TEST_CPP_SOURCES}
${ResInsight_SOURCE_DIR}/ThirdParty/gtest/gtest-all.cc
)
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set( EXTERNAL_LINK_LIBRARIES
pthread
)
ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set( CMAKE_CXX_FLAGS
"-DGTEST_USE_OWN_TR1_TUPLE=1"
)
ENDIF()
target_link_libraries( ${ProjectName} ${LINK_LIBRARIES} ${EXTERNAL_LINK_LIBRARIES})

View File

@ -86,12 +86,12 @@ void RivCellEdgeGeometryUtils::addCellEdgeResultsToDrawableGeo(
double ignoredScalarValue = cellEdgeResultColors->ignoredScalarValue();
const std::vector<cvf::ubyte>* isWellPipeVisible = NULL;
cvf::ref<cvf::UIntArray> gridCellToWellindexMap;
cvf::cref<cvf::UIntArray> gridCellToWellindexMap;
if (opacityLevel < 1.0f)
{
isWellPipeVisible = &(cellResultColors->reservoirView()->wellCollection()->isWellPipesVisible(timeStepIndex));
gridCellToWellindexMap = eclipseCase->gridCellToWellIndex(gridIndex);
isWellPipeVisible = &(cellResultColors->reservoirView()->wellCollection()->resultWellPipeVisibilities(timeStepIndex));
gridCellToWellindexMap = eclipseCase->gridCellToResultWellIndex(gridIndex);
}
#pragma omp parallel for
@ -144,10 +144,9 @@ void RivCellEdgeGeometryUtils::addCellEdgeResultsToDrawableGeo(
}
float edgeColor;
for (size_t cubeFaceIdx = 0; cubeFaceIdx < 6; cubeFaceIdx++)
{
edgeColor = -1.0f; // Undefined texture coord. Shader handles this.
float edgeColor = -1.0f; // Undefined texture coord. Shader handles this.
double scalarValue = cellEdgeResultAccessor->cellFaceScalar(cellIndex, static_cast<cvf::StructGridInterface::FaceType>(cubeFaceIdx));
@ -244,10 +243,9 @@ void RivCellEdgeGeometryUtils::addTernaryCellEdgeResultsToDrawableGeo(size_t tim
size_t cellIndex = quadToCellFaceMapper->cellIndex(quadIdx);
float edgeColor;
for (size_t cubeFaceIdx = 0; cubeFaceIdx < 6; cubeFaceIdx++)
{
edgeColor = -1.0f; // Undefined texture coord. Shader handles this.
float edgeColor = -1.0f; // Undefined texture coord. Shader handles this.
double scalarValue = cellEdgeResultAccessor->cellFaceScalar(cellIndex, static_cast<cvf::StructGridInterface::FaceType>(cubeFaceIdx));

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,173 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Statoil ASA
// Copyright (C) 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 "cafPdmPointer.h"
#include "cvfArray.h"
#include "cvfBase.h"
#include "cvfBoundingBox.h"
#include "cvfObject.h"
#include "cvfVector3.h"
#include <vector>
class RigMainGrid;
class RigActiveCellInfo;
class RigResultAccessor;
class RimCrossSection;
namespace cvf
{
class ScalarMapper;
class DrawableGeo;
}
class RivCrossSectionHexGridIntf : public cvf::Object
{
public:
virtual cvf::Vec3d displayOffset() const = 0;
virtual cvf::BoundingBox boundingBox() const = 0;
virtual void findIntersectingCells(const cvf::BoundingBox& intersectingBB, std::vector<size_t>* intersectedCells) const = 0;
virtual bool useCell(size_t cellIndex) const = 0;
virtual void cellCornerVertices(size_t cellIndex, cvf::Vec3d cellCorners[8]) const = 0;
virtual void cellCornerIndices(size_t cellIndex, size_t cornerIndices[8]) const = 0;
};
class RivEclipseCrossSectionGrid : public RivCrossSectionHexGridIntf
{
public:
RivEclipseCrossSectionGrid(const RigMainGrid * mainGrid, const RigActiveCellInfo* activeCellInfo, bool showInactiveCells);
virtual cvf::Vec3d displayOffset() const;
virtual cvf::BoundingBox boundingBox() const;
virtual void findIntersectingCells(const cvf::BoundingBox& intersectingBB, std::vector<size_t>* intersectedCells) const;
virtual bool useCell(size_t cellIndex) const;
virtual void cellCornerVertices(size_t cellIndex, cvf::Vec3d cellCorners[8]) const;
virtual void cellCornerIndices(size_t cellIndex, size_t cornerIndices[8]) const;
private:
cvf::cref<RigMainGrid> m_mainGrid;
cvf::cref<RigActiveCellInfo> m_activeCellInfo;
bool m_showInactiveCells;
};
class RigFemPart;
class RivFemCrossSectionGrid : public RivCrossSectionHexGridIntf
{
public:
RivFemCrossSectionGrid(const RigFemPart * femPart);
virtual cvf::Vec3d displayOffset() const;
virtual cvf::BoundingBox boundingBox() const;
virtual void findIntersectingCells(const cvf::BoundingBox& intersectingBB, std::vector<size_t>* intersectedCells) const;
virtual bool useCell(size_t cellIndex) const;
virtual void cellCornerVertices(size_t cellIndex, cvf::Vec3d cellCorners[8]) const;
virtual void cellCornerIndices(size_t cellIndex, size_t cornerIndices[8]) const;
private:
cvf::cref<RigFemPart> m_femPart;
};
class RivVertexWeights
{
public:
explicit RivVertexWeights(size_t edge1Vx1, size_t edge1Vx2, double normDistFromE1V1,
size_t edge2Vx1, size_t edge2Vx2, double normDistFromE2V1,
double normDistFromE1Cut) : m_count(4)
{
m_vxIds[0] = (edge1Vx1);
m_vxIds[1] = (edge1Vx2);
m_vxIds[2] = (edge2Vx1);
m_vxIds[3] = (edge2Vx2);
m_weights[0] = ((float)(1.0 - normDistFromE1V1 - normDistFromE1Cut + normDistFromE1V1*normDistFromE1Cut));
m_weights[1] = ((float)(normDistFromE1V1 - normDistFromE1V1*normDistFromE1Cut));
m_weights[2] = ((float)(normDistFromE1Cut - normDistFromE2V1*normDistFromE1Cut));
m_weights[3] = ((float)(normDistFromE2V1*normDistFromE1Cut));
}
explicit RivVertexWeights(size_t edge1Vx1, size_t edge1Vx2, double normDistFromE1V1) : m_count(2)
{
m_vxIds[0] = (edge1Vx1);
m_vxIds[1] = (edge1Vx2);
m_weights[0] = ((float)(1.0 - normDistFromE1V1));
m_weights[1] = ((float)(normDistFromE1V1));
}
int size() const { return m_count;}
size_t vxId(int idx) const { return m_vxIds[idx];}
float weight(int idx)const { return m_weights[idx];}
private:
size_t m_vxIds[4];
float m_weights[4];
int m_count;
};
class RivCrossSectionGeometryGenerator : public cvf::Object
{
public:
RivCrossSectionGeometryGenerator(const RimCrossSection* crossSection,
std::vector<std::vector<cvf::Vec3d> > &polylines,
const cvf::Vec3d& extrusionDirection,
const RivCrossSectionHexGridIntf* grid );
~RivCrossSectionGeometryGenerator();
bool isAnyGeometryPresent() const;
// Generate geometry
cvf::ref<cvf::DrawableGeo> generateSurface();
cvf::ref<cvf::DrawableGeo> createMeshDrawable();
cvf::ref<cvf::DrawableGeo> createLineAlongPolylineDrawable();
cvf::ref<cvf::DrawableGeo> createPointsFromPolylineDrawable();
// Mapping between cells and geometry
const std::vector<size_t>& triangleToCellIndex() const;
const std::vector<RivVertexWeights>& triangleVxToCellCornerInterpolationWeights() const;
const RimCrossSection* crossSection() const;
private:
void calculateArrays();
static void adjustPolyline(const std::vector<cvf::Vec3d>& polyLine,
const cvf::Vec3d extrDir,
std::vector<cvf::Vec3d>* adjustedPolyline);
cvf::cref<RivCrossSectionHexGridIntf> m_hexGrid;
const std::vector<std::vector<cvf::Vec3d> > m_polyLines;
cvf::Vec3d m_extrusionDirection;
// Output arrays
cvf::ref<cvf::Vec3fArray> m_triangleVxes;
cvf::ref<cvf::Vec3fArray> m_cellBorderLineVxes;
std::vector<size_t> m_triangleToCellIdxMap;
std::vector<RivVertexWeights> m_triVxToCellCornerWeights;
const RimCrossSection* m_crossSection;
};

View File

@ -0,0 +1,564 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Statoil ASA
// Copyright (C) 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 "RivCrossSectionPartMgr.h"
#include "RigCaseCellResultsData.h"
#include "RigCaseData.h"
#include "RigFemPartCollection.h"
#include "RigFemPartResultsCollection.h"
#include "RigGeoMechCaseData.h"
#include "RigResultAccessor.h"
#include "RigResultAccessorFactory.h"
#include "RimCrossSection.h"
#include "RimEclipseCase.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseView.h"
#include "RimGeoMechCase.h"
#include "RimGeoMechCellColors.h"
#include "RimGeoMechView.h"
#include "RimTernaryLegendConfig.h"
#include "RivCrossSectionSourceInfo.h"
#include "RivResultToTextureMapper.h"
#include "RivScalarMapperUtils.h"
#include "RivTernaryScalarMapper.h"
#include "RivTernaryTextureCoordsCreator.h"
#include "cvfDrawableGeo.h"
#include "cvfModelBasicList.h"
#include "cvfPart.h"
#include "cvfPrimitiveSetDirect.h"
#include "cvfRenderState_FF.h"
#include "cvfRenderStateDepth.h"
#include "cvfRenderStatePoint.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivCrossSectionPartMgr::RivCrossSectionPartMgr(const RimCrossSection* rimCrossSection)
: m_rimCrossSection(rimCrossSection),
m_defaultColor(cvf::Color3::WHITE)
{
CVF_ASSERT(m_rimCrossSection);
m_crossSectionFacesTextureCoords = new cvf::Vec2fArray;
computeData();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivCrossSectionPartMgr::applySingleColorEffect()
{
if (m_crossSectionGenerator.isNull()) return;
m_defaultColor = cvf::Color3f::OLIVE;//m_rimCrossSection->CrossSectionColor();
this->updatePartEffect();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivCrossSectionPartMgr::updateCellResultColor(size_t timeStepIndex)
{
if (m_crossSectionGenerator.isNull()) return;
if (!m_crossSectionGenerator->isAnyGeometryPresent()) return;
RimEclipseView* eclipseView;
m_rimCrossSection->firstAnchestorOrThisOfType(eclipseView);
if (eclipseView)
{
RimEclipseCellColors* cellResultColors = eclipseView->cellResult();
CVF_ASSERT(cellResultColors);
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResultColors->porosityModel());
RigCaseData* eclipseCase = eclipseView->eclipseCase()->reservoirData();
// CrossSections
if (m_crossSectionFaces.notNull())
{
if (cellResultColors->isTernarySaturationSelected())
{
RivTernaryTextureCoordsCreator texturer(cellResultColors, cellResultColors->ternaryLegendConfig(), timeStepIndex);
texturer.createTextureCoords(m_crossSectionFacesTextureCoords.p(), m_crossSectionGenerator->triangleToCellIndex());
const RivTernaryScalarMapper* mapper = cellResultColors->ternaryLegendConfig()->scalarMapper();
RivScalarMapperUtils::applyTernaryTextureResultsToPart(m_crossSectionFaces.p(),
m_crossSectionFacesTextureCoords.p(),
mapper,
1.0,
caf::FC_NONE,
eclipseView->isLightingDisabled());
}
else
{
CVF_ASSERT(m_crossSectionGenerator.notNull());
const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper();
cvf::ref<RigResultAccessor> resultAccessor;
if (RimDefines::isPerCellFaceResult(cellResultColors->resultVariable()))
{
resultAccessor = new RigHugeValResultAccessor;
}
else
{
resultAccessor = RigResultAccessorFactory::createResultAccessor(cellResultColors->reservoirView()->eclipseCase()->reservoirData(),
0,
timeStepIndex,
cellResultColors);
}
RivCrossSectionPartMgr::calculateEclipseTextureCoordinates(m_crossSectionFacesTextureCoords.p(),
m_crossSectionGenerator->triangleToCellIndex(),
resultAccessor.p(),
mapper);
RivScalarMapperUtils::applyTextureResultsToPart(m_crossSectionFaces.p(),
m_crossSectionFacesTextureCoords.p(),
mapper,
1.0,
caf::FC_NONE,
eclipseView->isLightingDisabled());
}
}
}
RimGeoMechView* geoView;
m_rimCrossSection->firstAnchestorOrThisOfType(geoView);
if (geoView)
{
RimGeoMechCellColors* cellResultColors = geoView->cellResult();
RigGeoMechCaseData* caseData = cellResultColors->ownerCaseData();
if (!caseData) return;
RigFemResultAddress resVarAddress = cellResultColors->resultAddress();
// Do a "Hack" to show elm nodal and not nodal POR results
if (resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar") resVarAddress.resultPosType = RIG_ELEMENT_NODAL;
const std::vector<RivVertexWeights> &vertexWeights = m_crossSectionGenerator->triangleVxToCellCornerInterpolationWeights();
const std::vector<float>& resultValues = caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex);
bool isElementNodalResult = !(resVarAddress.resultPosType == RIG_NODAL);
RigFemPart* femPart = caseData->femParts()->part(0);
const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper();
RivCrossSectionPartMgr::calculateGeoMechTextureCoords(m_crossSectionFacesTextureCoords.p(),
vertexWeights,
resultValues,
isElementNodalResult,
femPart,
mapper);
RivScalarMapperUtils::applyTextureResultsToPart(m_crossSectionFaces.p(),
m_crossSectionFacesTextureCoords.p(),
mapper,
1.0,
caf::FC_NONE,
geoView->isLightingDisabled());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivCrossSectionPartMgr::calculateGeoMechTextureCoords(cvf::Vec2fArray* textureCoords,
const std::vector<RivVertexWeights> &vertexWeights,
const std::vector<float> &resultValues,
bool isElementNodalResult,
const RigFemPart* femPart,
const cvf::ScalarMapper* mapper)
{
textureCoords->resize(vertexWeights.size());
if (resultValues.size() == 0)
{
textureCoords->setAll(cvf::Vec2f(0.0, 1.0f));
}
else
{
cvf::Vec2f* rawPtr = textureCoords->ptr();
int vxCount = static_cast<int>(vertexWeights.size());
#pragma omp parallel for schedule(dynamic)
for (int triangleVxIdx = 0; triangleVxIdx < vxCount; ++triangleVxIdx)
{
float resValue = 0;
int weightCount = vertexWeights[triangleVxIdx].size();
for (int wIdx = 0; wIdx < weightCount; ++wIdx)
{
size_t resIdx = isElementNodalResult ? vertexWeights[triangleVxIdx].vxId(wIdx) :
femPart->nodeIdxFromElementNodeResultIdx(vertexWeights[triangleVxIdx].vxId(wIdx));
resValue += resultValues[resIdx] * vertexWeights[triangleVxIdx].weight(wIdx);
}
if (resValue == HUGE_VAL || resValue != resValue) // a != a is true for NAN's
{
rawPtr[triangleVxIdx][1] = 1.0f;
}
else
{
rawPtr[triangleVxIdx] = mapper->mapToTextureCoord(resValue);
}
}
}
}
//--------------------------------------------------------------------------------------------------
/// Calculates the texture coordinates in a "nearly" one dimensional texture.
/// Undefined values are coded with a y-texturecoordinate value of 1.0 instead of the normal 0.5
//--------------------------------------------------------------------------------------------------
void RivCrossSectionPartMgr::calculateEclipseTextureCoordinates(cvf::Vec2fArray* textureCoords,
const std::vector<size_t>& triangleToCellIdxMap,
const RigResultAccessor* resultAccessor,
const cvf::ScalarMapper* mapper)
{
if (!resultAccessor) return;
size_t numVertices = triangleToCellIdxMap.size()*3;
textureCoords->resize(numVertices);
cvf::Vec2f* rawPtr = textureCoords->ptr();
double cellScalarValue;
cvf::Vec2f texCoord;
int triangleCount = static_cast<int>(triangleToCellIdxMap.size());
#pragma omp parallel for private(texCoord, cellScalarValue)
for (int tIdx = 0; tIdx < triangleCount; tIdx++)
{
cellScalarValue = resultAccessor->cellScalarGlobIdx(triangleToCellIdxMap[tIdx]);
texCoord = mapper->mapToTextureCoord(cellScalarValue);
if (cellScalarValue == HUGE_VAL || cellScalarValue != cellScalarValue) // a != a is true for NAN's
{
texCoord[1] = 1.0f;
}
size_t j;
for (j = 0; j < 3; j++)
{
rawPtr[tIdx*3 + j] = texCoord;
}
}
}
const int priCrossSectionGeo = 1;
const int priNncGeo = 2;
const int priMesh = 3;
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivCrossSectionPartMgr::generatePartGeometry()
{
if (m_crossSectionGenerator.isNull()) return;
bool useBufferObjects = true;
// Surface geometry
{
cvf::ref<cvf::DrawableGeo> geo = m_crossSectionGenerator->generateSurface();
if (geo.notNull())
{
geo->computeNormals();
if (useBufferObjects)
{
geo->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT);
}
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName("Cross Section");
part->setDrawable(geo.p());
// Set mapping from triangle face index to cell index
cvf::ref<RivCrossSectionSourceInfo> si = new RivCrossSectionSourceInfo(m_crossSectionGenerator.p());
part->setSourceInfo(si.p());
part->updateBoundingBox();
part->setEnableMask(faultBit);
part->setPriority(priCrossSectionGeo);
m_crossSectionFaces = part;
}
}
// Mesh geometry
{
cvf::ref<cvf::DrawableGeo> geoMesh = m_crossSectionGenerator->createMeshDrawable();
if (geoMesh.notNull())
{
if (useBufferObjects)
{
geoMesh->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT);
}
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName("Cross Section mesh");
part->setDrawable(geoMesh.p());
part->updateBoundingBox();
part->setEnableMask(meshFaultBit);
part->setPriority(priMesh);
m_crossSectionGridLines = part;
}
}
// Highlight line
m_highlightLineAlongPolyline = NULL;
m_highlightPointsForPolyline = NULL;
if (m_rimCrossSection->type == RimCrossSection::CS_POLYLINE)
{
{
cvf::ref<cvf::DrawableGeo> polylineGeo = m_crossSectionGenerator->createLineAlongPolylineDrawable();
if (polylineGeo.notNull())
{
if (useBufferObjects)
{
polylineGeo->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT);
}
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName("Cross Section Polyline");
part->setDrawable(polylineGeo.p());
part->updateBoundingBox();
part->setPriority(10000);
// Always show this part, also when mesh is turned off
//part->setEnableMask(meshFaultBit);
cvf::ref<cvf::Effect> eff;
caf::MeshEffectGenerator lineEffGen(cvf::Color3::MAGENTA);
eff = lineEffGen.generateUnCachedEffect();
cvf::ref<cvf::RenderStateDepth> depth = new cvf::RenderStateDepth;
depth->enableDepthTest(false);
eff->setRenderState(depth.p());
part->setEffect(eff.p());
m_highlightLineAlongPolyline = part;
}
}
cvf::ref<cvf::DrawableGeo> polylinePointsGeo = m_crossSectionGenerator->createPointsFromPolylineDrawable();
if (polylinePointsGeo.notNull())
{
if (useBufferObjects)
{
polylinePointsGeo->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT);
}
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName("Cross Section Polyline");
part->setDrawable(polylinePointsGeo.p());
part->updateBoundingBox();
part->setPriority(10000);
// Always show this part, also when mesh is turned off
//part->setEnableMask(meshFaultBit);
cvf::ref<cvf::Effect> eff;
caf::MeshEffectGenerator lineEffGen(cvf::Color3::MAGENTA);
eff = lineEffGen.generateUnCachedEffect();
cvf::ref<cvf::RenderStateDepth> depth = new cvf::RenderStateDepth;
depth->enableDepthTest(false);
eff->setRenderState(depth.p());
cvf::ref<cvf::RenderStatePoint> pointRendState = new cvf::RenderStatePoint(cvf::RenderStatePoint::FIXED_SIZE);
pointRendState->setSize(5.0f);
eff->setRenderState(pointRendState.p());
part->setEffect(eff.p());
m_highlightPointsForPolyline = part;
}
}
updatePartEffect();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivCrossSectionPartMgr::updatePartEffect()
{
if (m_crossSectionGenerator.isNull()) return;
// Set deCrossSection effect
caf::SurfaceEffectGenerator geometryEffgen(m_defaultColor, caf::PO_1);
cvf::ref<cvf::Effect> geometryOnlyEffect = geometryEffgen.generateCachedEffect();
if (m_crossSectionFaces.notNull())
{
m_crossSectionFaces->setEffect(geometryOnlyEffect.p());
}
// Update mesh colors as well, in case of change
//RiaPreferences* prefs = RiaApplication::instance()->preferences();
cvf::ref<cvf::Effect> eff;
caf::MeshEffectGenerator CrossSectionEffGen(cvf::Color3::WHITE);//prefs->defaultCrossSectionGridLineColors());
eff = CrossSectionEffGen.generateCachedEffect();
if (m_crossSectionGridLines.notNull())
{
m_crossSectionGridLines->setEffect(eff.p());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivCrossSectionPartMgr::appendNativeCrossSectionFacesToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform)
{
if (m_crossSectionFaces.isNull())
{
generatePartGeometry();
}
if (m_crossSectionFaces.notNull())
{
m_crossSectionFaces->setTransform(scaleTransform);
model->addPart(m_crossSectionFaces.p());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivCrossSectionPartMgr::appendMeshLinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform)
{
if (m_crossSectionGridLines.isNull())
{
generatePartGeometry();
}
if (m_crossSectionGridLines.notNull())
{
m_crossSectionGridLines->setTransform(scaleTransform);
model->addPart(m_crossSectionGridLines.p());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivCrossSectionPartMgr::appendPolylinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform)
{
if (m_highlightLineAlongPolyline.notNull())
{
m_highlightLineAlongPolyline->setTransform(scaleTransform);
model->addPart(m_highlightLineAlongPolyline.p());
}
if (m_highlightPointsForPolyline.notNull())
{
m_highlightPointsForPolyline->setTransform(scaleTransform);
model->addPart(m_highlightPointsForPolyline.p());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivCrossSectionPartMgr::computeData()
{
std::vector< std::vector <cvf::Vec3d> > polyLines = m_rimCrossSection->polyLines();
if (polyLines.size() > 0)
{
cvf::Vec3d direction = extrusionDirection(polyLines[0]);
cvf::ref<RivCrossSectionHexGridIntf> hexGrid = createHexGridInterface();
m_crossSectionGenerator = new RivCrossSectionGeometryGenerator(m_rimCrossSection, polyLines, direction, hexGrid.p());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<RivCrossSectionHexGridIntf> RivCrossSectionPartMgr::createHexGridInterface()
{
RimEclipseView* eclipseView;
m_rimCrossSection->firstAnchestorOrThisOfType(eclipseView);
if (eclipseView)
{
RigMainGrid* grid = NULL;
grid = eclipseView->eclipseCase()->reservoirData()->mainGrid();
return new RivEclipseCrossSectionGrid(grid, eclipseView->currentActiveCellInfo(), m_rimCrossSection->showInactiveCells());
}
RimGeoMechView* geoView;
m_rimCrossSection->firstAnchestorOrThisOfType(geoView);
if (geoView)
{
RigFemPart* femPart = geoView->geoMechCase()->geoMechData()->femParts()->part(0);
return new RivFemCrossSectionGrid(femPart);
}
return NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Vec3d RivCrossSectionPartMgr::extrusionDirection(const std::vector<cvf::Vec3d>& polyline) const
{
CVF_ASSERT(m_rimCrossSection);
cvf::Vec3d dir = cvf::Vec3d::Z_AXIS;
if (m_rimCrossSection->direction == RimCrossSection::CS_HORIZONTAL &&
polyline.size() > 1)
{
// Use first and last point of polyline to approximate orientation of polyline
// Then cross with Z axis to find extrusion direction
cvf::Vec3d polyLineDir = polyline[polyline.size() - 1] - polyline[0];
cvf::Vec3d up = cvf::Vec3d::Z_AXIS;
dir = polyLineDir ^ up;
}
return dir;
}

View File

@ -0,0 +1,90 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Statoil ASA
// Copyright (C) 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 "RivCrossSectionGeometryGenerator.h"
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfColor4.h"
#include "cvfVector3.h"
namespace cvf
{
class ModelBasicList;
class Transform;
class Part;
}
class RigMainGrid;
class RimEclipseCellColors;
class RimCellEdgeColors;
class RimCrossSection;
//==================================================================================================
///
///
//==================================================================================================
class RivCrossSectionPartMgr : public cvf::Object
{
public:
RivCrossSectionPartMgr(const RimCrossSection* rimCrossSection);
void applySingleColorEffect();
void updateCellResultColor(size_t timeStepIndex);
void appendNativeCrossSectionFacesToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform);
void appendMeshLinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform);
void appendPolylinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform);
private:
void updatePartEffect();
void generatePartGeometry();
void computeData();
cvf::Vec3d extrusionDirection(const std::vector<cvf::Vec3d>& polyline) const;
static void calculateEclipseTextureCoordinates(cvf::Vec2fArray* textureCoords,
const std::vector<size_t>& triangleToCellIdxMap,
const RigResultAccessor* resultAccessor,
const cvf::ScalarMapper* mapper);
static void calculateGeoMechTextureCoords(cvf::Vec2fArray* textureCoords,
const std::vector<RivVertexWeights> &vertexWeights,
const std::vector<float> &resultValues,
bool isElementNodalResult,
const RigFemPart* femPart,
const cvf::ScalarMapper* mapper);
cvf::ref<RivCrossSectionHexGridIntf> createHexGridInterface();
private:
const RimCrossSection* m_rimCrossSection;
cvf::Color3f m_defaultColor;
cvf::ref<RivCrossSectionGeometryGenerator> m_crossSectionGenerator;
cvf::ref<cvf::Part> m_crossSectionFaces;
cvf::ref<cvf::Part> m_crossSectionGridLines;
cvf::ref<cvf::Vec2fArray> m_crossSectionFacesTextureCoords;
cvf::ref<cvf::Part> m_highlightLineAlongPolyline;
cvf::ref<cvf::Part> m_highlightPointsForPolyline;
};

View File

@ -0,0 +1,50 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Statoil ASA
// Copyright (C) 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 "RivCrossSectionSourceInfo.h"
#include "RivCrossSectionGeometryGenerator.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivCrossSectionSourceInfo::RivCrossSectionSourceInfo(RivCrossSectionGeometryGenerator* geometryGenerator)
: m_crossSectionGeometryGenerator(geometryGenerator)
{
CVF_ASSERT(m_crossSectionGeometryGenerator.notNull());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<size_t>& RivCrossSectionSourceInfo::triangleToCellIndex() const
{
CVF_ASSERT(m_crossSectionGeometryGenerator.notNull());
return m_crossSectionGeometryGenerator->triangleToCellIndex();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RimCrossSection* RivCrossSectionSourceInfo::crossSection() const
{
return m_crossSectionGeometryGenerator->crossSection();
}

View File

@ -1,6 +1,7 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
// Copyright (C) Statoil ASA
// Copyright (C) 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
@ -16,28 +17,24 @@
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfArray.h"
#include "gtest/gtest.h"
#include <stdio.h>
class RivCrossSectionGeometryGenerator;
class RimCrossSection;
#include "cvfTrace.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int main(int argc, char **argv)
class RivCrossSectionSourceInfo : public cvf::Object
{
cvf::Assert::setReportMode(cvf::Assert::CONSOLE);
public:
RivCrossSectionSourceInfo(RivCrossSectionGeometryGenerator* geometryGenerator);
testing::InitGoogleTest(&argc, argv);
const std::vector<size_t>& triangleToCellIndex() const;
int result = RUN_ALL_TESTS();
const RimCrossSection* crossSection() const;
std::cout << "Please press <Enter> to close the window.";
std::cin.get();
return result;
}
private:
cvf::cref<RivCrossSectionGeometryGenerator> m_crossSectionGeometryGenerator;
};

View File

@ -83,8 +83,6 @@ private:
float m_opacityLevel;
cvf::Color3f m_defaultColor;
bool m_showNativeFaces;
bool m_showOppositeFaces;
bool m_showLabel;
cvf::ref<cvf::UByteArray> m_cellVisibility;

View File

@ -79,7 +79,7 @@ void RivNNCGeometryGenerator::computeArrays()
std::vector<RigCell>* allCells = NULL;
if (isVisibilityCalcActive)
{
allCells = &(m_grid->mainGrid()->cells());
allCells = &(m_grid->mainGrid()->globalCellArray());
}
#pragma omp parallel for ordered

View File

@ -1,6 +1,8 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron 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
@ -35,6 +37,7 @@ RivPipeGeometryGenerator::RivPipeGeometryGenerator()
m_crossSectionNodeCount = 8;
m_minimumBendAngle = 80.0;
m_bendScalingFactor = 0.00001;
m_firstSegmentIndex = 0;
}
//--------------------------------------------------------------------------------------------------
@ -582,3 +585,21 @@ void RivPipeGeometryGenerator::clearComputedData()
m_filteredPipeSegmentToResult.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RivPipeGeometryGenerator::segmentIndexFromTriangleIndex(size_t triangleIndex) const
{
size_t filteredIndex = triangleIndex / (m_crossSectionNodeCount * 2);
return filteredIndex + m_firstSegmentIndex;
}
//--------------------------------------------------------------------------------------------------
/// Well pipes are clipped, set index to first segment in visible well path
//--------------------------------------------------------------------------------------------------
void RivPipeGeometryGenerator::setFirstSegmentIndex(size_t segmentIndex)
{
m_firstSegmentIndex = segmentIndex;
}

View File

@ -1,6 +1,8 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron 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
@ -18,8 +20,6 @@
#pragma once
//class RivPipeQuadToSegmentMapper;
class RivPipeGeometryGenerator : public cvf::Object
{
public:
@ -31,6 +31,7 @@ public:
// Pipe bends with a opening angle below given angle is modified with extra bend coordinates
void setMinimumBendAngle(double degrees);
// Scaling factor used to control how far from original pipe position the extra bend coordinates are located
// This will affect how sharp or smooth bend will appear
void setBendScalingFactor(double scaleFactor);
@ -46,6 +47,9 @@ public:
void pipeSurfaceTextureCoords(cvf::Vec2fArray* textureCoords, const std::vector<double>& segmentResults, const cvf::ScalarMapper* mapper) const;
void centerlineTextureCoords(cvf::Vec2fArray* textureCoords, const std::vector<double>& segmentResults, const cvf::ScalarMapper* mapper) const;
void setFirstSegmentIndex(size_t segmentIndex);
size_t segmentIndexFromTriangleIndex(size_t triangleIndex) const;
private:
void clearComputedData();
void updateFilteredPipeCenterCoords();
@ -72,8 +76,7 @@ private:
// Map from generated cylinder segments to pipe result indices
std::vector<size_t> m_filteredPipeSegmentToResult;
// TODO: implement
//RivPipeQuadToSegmentMapper* m_quadToSegmentMapper;
size_t m_firstSegmentIndex;
double m_radius;
double m_minimumBendAngle;

View File

@ -139,3 +139,16 @@ void RivReservoirPipesPartMgr::updatePipeResultColor(size_t frameIndex)
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector< std::vector <cvf::Vec3d> >* RivReservoirPipesPartMgr::centerLineOfWellBranches(int wellIdx)
{
if (wellIdx < static_cast<int>(m_wellPipesPartMgrs.size()))
{
return &(m_wellPipesPartMgrs[wellIdx]->centerLineOfWellBranches());
}
return NULL;
}

View File

@ -21,6 +21,7 @@
#include "RimEclipseWellCollection.h"
#include "cvfCollection.h"
#include "cvfVector3.h"
namespace cvf
{
@ -46,6 +47,8 @@ public:
void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex);
void updatePipeResultColor(size_t frameIndex);
const std::vector< std::vector <cvf::Vec3d> >* centerLineOfWellBranches(int wellIdx);
private:
caf::PdmPointer<RimEclipseView> m_reservoirView;
cvf::ref<cvf::Transform> m_scaleTransform;

View File

@ -458,7 +458,7 @@ void RivReservoirViewPartMgr::createPropertyFilteredNoneWellCellGeometry(size_t
(*cellVisibility)[cellIdx] = (*rangeVisibility)[cellIdx] || (*fenceVisibility)[cellIdx];
}
computePropertyVisibility(cellVisibility.p(), grids[gIdx], frameIndex, cellVisibility.p(), m_reservoirView->propertyFilterCollection());
computePropertyVisibility(cellVisibility.p(), grids[gIdx], frameIndex, cellVisibility.p(), m_reservoirView->eclipsePropertyFilterCollection());
m_propFilteredGeometryFrames[frameIndex]->setCellVisibility(gIdx, cellVisibility.p());
}
@ -542,7 +542,7 @@ void RivReservoirViewPartMgr::createPropertyFilteredWellGeometry(size_t frameInd
(*cellVisibility)[cellIdx] = (*wellFenceCells)[cellIdx] || (*rangeVisibility)[cellIdx] || (*wellCellsOutsideRange)[cellIdx];
}
computePropertyVisibility(cellVisibility.p(), grids[gIdx], frameIndex, cellVisibility.p(), m_reservoirView->propertyFilterCollection());
computePropertyVisibility(cellVisibility.p(), grids[gIdx], frameIndex, cellVisibility.p(), m_reservoirView->eclipsePropertyFilterCollection());
m_propFilteredWellGeometryFrames[frameIndex]->setCellVisibility(gIdx, cellVisibility.p());
}
@ -785,6 +785,10 @@ void RivReservoirViewPartMgr::computePropertyVisibility(cvf::UByteArray* cellVis
const double lowerBound = propertyFilter->lowerBound();
const double upperBound = propertyFilter->upperBound();
const RimCellFilter::FilterModeType filterType = propertyFilter->filterMode();
RigCaseData* eclipseCase = propFilterColl->reservoirView()->eclipseCase()->reservoirData();
size_t adjustedTimeStepIndex = timeStepIndex;
// Set time step to zero for static results
@ -793,12 +797,9 @@ void RivReservoirViewPartMgr::computePropertyVisibility(cvf::UByteArray* cellVis
adjustedTimeStepIndex = 0;
}
const RimCellFilter::FilterModeType filterType = propertyFilter->filterMode();
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(propertyFilter->resultDefinition()->porosityModel());
RigCaseData* eclipseCase = propFilterColl->reservoirView()->eclipseCase()->reservoirData();
cvf::ref<RigResultAccessor> resultAccessor = RigResultAccessorFactory::createResultAccessor(eclipseCase, grid->gridIndex(), porosityModel, adjustedTimeStepIndex, propertyFilter->resultDefinition->resultVariable(), propertyFilter->resultDefinition->resultType());
CVF_ASSERT(resultAccessor.notNull());
//#pragma omp parallel for schedule(dynamic)

View File

@ -0,0 +1,103 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Statoil ASA
// Copyright (C) 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 "RivSingleCellPartGenerator.h"
#include "RigCaseData.h"
#include "RigFemPartCollection.h"
#include "RigGeoMechCaseData.h"
#include "RimGeoMechCase.h"
#include "RivFemPartGeometryGenerator.h"
#include "cafEffectGenerator.h"
#include "cvfPart.h"
#include "cvfRenderStateDepth.h"
#include "cvfStructGridGeometryGenerator.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivSingleCellPartGenerator::RivSingleCellPartGenerator(RigCaseData* rigCaseData, size_t gridIndex, size_t cellIndex)
: m_rigCaseData(rigCaseData),
m_gridIndex(gridIndex),
m_cellIndex(cellIndex),
m_geoMechCase(NULL)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivSingleCellPartGenerator::RivSingleCellPartGenerator(RimGeoMechCase* rimGeoMechCase, size_t gridIndex, size_t cellIndex)
: m_geoMechCase(rimGeoMechCase),
m_gridIndex(gridIndex),
m_cellIndex(cellIndex),
m_rigCaseData(NULL)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::Part> RivSingleCellPartGenerator::createPart(const cvf::Color3f color)
{
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName(cvf::String("Hightlight part for cell index ") + cvf::String((cvf::int64)m_cellIndex));
part->setDrawable(createMeshDrawable().p());
cvf::ref<cvf::Effect> eff;
caf::MeshEffectGenerator effGen(color);
eff = effGen.generateUnCachedEffect();
cvf::ref<cvf::RenderStateDepth> depth = new cvf::RenderStateDepth;
depth->enableDepthTest(false);
eff->setRenderState(depth.p());
part->setEffect(eff.p());
part->setPriority(10000);
return part;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableGeo> RivSingleCellPartGenerator::createMeshDrawable()
{
if (m_rigCaseData && m_cellIndex != cvf::UNDEFINED_SIZE_T)
{
return cvf::StructGridGeometryGenerator::createMeshDrawableFromSingleCell(m_rigCaseData->grid(m_gridIndex), m_cellIndex);
}
else if (m_geoMechCase && m_cellIndex != cvf::UNDEFINED_SIZE_T)
{
CVF_ASSERT(m_geoMechCase->geoMechData());
CVF_ASSERT(m_geoMechCase->geoMechData()->femParts()->partCount() > static_cast<int>(m_gridIndex));
RigFemPart* femPart = m_geoMechCase->geoMechData()->femParts()->part(m_gridIndex);
CVF_ASSERT(femPart);
return RivFemPartGeometryGenerator::createMeshDrawableFromSingleElement(femPart, m_cellIndex);
}
return NULL;
}

View File

@ -0,0 +1,53 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Statoil ASA
// Copyright (C) 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 "cvfBase.h"
#include "cvfDrawableGeo.h"
namespace cvf
{
class Part;
}
class RigCaseData;
class RimGeoMechCase;
//==================================================================================================
///
///
//==================================================================================================
class RivSingleCellPartGenerator
{
public:
RivSingleCellPartGenerator(RigCaseData* rigCaseData, size_t gridIndex, size_t cellIndex);
RivSingleCellPartGenerator(RimGeoMechCase* rimGeoMechCase, size_t gridIndex, size_t cellIndex);
cvf::ref<cvf::Part> createPart(const cvf::Color3f color);
private:
cvf::ref<cvf::DrawableGeo> createMeshDrawable();
private:
RigCaseData* m_rigCaseData;
RimGeoMechCase* m_geoMechCase;
size_t m_gridIndex;
size_t m_cellIndex;
};

View File

@ -39,7 +39,19 @@ public:
cvf::Vec2f getTexCoord(double soil, double sgas, size_t cellIndex) const
{
bool isTransparent = m_pipeInCellEvaluator->isWellPipeInCell(cellIndex);
if (soil == HUGE_VAL || soil != soil ||
sgas == HUGE_VAL || sgas != sgas) // a != a is true for NAN's
{
cvf::Vec2f texCoord(1.0, 1.0);
return texCoord;
}
bool isTransparent = false;
if (m_pipeInCellEvaluator.notNull())
{
isTransparent = m_pipeInCellEvaluator->isWellPipeInCell(cellIndex);
}
return m_scalarMapper->mapToTextureCoord(soil, sgas, isTransparent);
}

View File

@ -77,10 +77,7 @@ bool RivTernaryScalarMapper::updateTexture(cvf::TextureImage* image, float opaci
CVF_ASSERT(image);
image->allocate(m_textureSize.x(), m_textureSize.y());
// For now fill with white so we can see any errors more easily
image->fill(cvf::Color4ub(cvf::Color3::WHITE));
image->fill(cvf::Color4ub(cvf::Color3ub(m_undefScalarColor)));
cvf::uint halfTextureHeight = m_textureSize.y() / 2;

View File

@ -44,10 +44,10 @@ RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator(
size_t gridIndex,
const cvf::StructGridQuadToCellFaceMapper* quadMapper)
{
RigCaseData* eclipseCase = cellResultColors->reservoirView()->eclipseCase()->reservoirData();
CVF_ASSERT(quadMapper);
m_quadMapper = quadMapper;
CVF_ASSERT(quadMapper && eclipseCase );
RigCaseData* eclipseCase = cellResultColors->reservoirView()->eclipseCase()->reservoirData();
size_t resTimeStepIdx = timeStepIndex;
@ -58,12 +58,13 @@ RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator(
cvf::ref<RigResultAccessor> soil = RigResultAccessorFactory::createResultAccessor(eclipseCase, gridIndex, porosityModel, resTimeStepIdx, "SOIL");
cvf::ref<RigResultAccessor> sgas = RigResultAccessorFactory::createResultAccessor(eclipseCase, gridIndex, porosityModel, resTimeStepIdx, "SGAS");
cvf::ref<RigResultAccessor> swat = RigResultAccessorFactory::createResultAccessor(eclipseCase, gridIndex, porosityModel, resTimeStepIdx, "SWAT");
m_resultAccessor = new RigTernaryResultAccessor();
m_resultAccessor->setTernaryResultAccessors(soil.p(), sgas.p(), swat.p());
cvf::ref<RigPipeInCellEvaluator> pipeInCellEval = new RigPipeInCellEvaluator( cellResultColors->reservoirView()->wellCollection()->isWellPipesVisible(timeStepIndex),
eclipseCase->gridCellToWellIndex(gridIndex));
cvf::ref<RigPipeInCellEvaluator> pipeInCellEval =
new RigPipeInCellEvaluator(cellResultColors->reservoirView()->wellCollection()->resultWellPipeVisibilities(timeStepIndex),
eclipseCase->gridCellToResultWellIndex(gridIndex));
const RivTernaryScalarMapper* mapper = ternaryLegendConfig->scalarMapper();
@ -71,14 +72,57 @@ RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator(
CVF_ASSERT(m_texMapper.notNull());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator(
RimEclipseCellColors* cellResultColors,
RimTernaryLegendConfig* ternaryLegendConfig,
size_t timeStepIndex)
: m_quadMapper(NULL)
{
RigCaseData* eclipseCase = cellResultColors->reservoirView()->eclipseCase()->reservoirData();
size_t resTimeStepIdx = timeStepIndex;
if (cellResultColors->hasStaticResult()) resTimeStepIdx = 0;
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResultColors->porosityModel());
size_t gridIndex = 0;
cvf::ref<RigResultAccessor> soil = RigResultAccessorFactory::createResultAccessor(eclipseCase, gridIndex, porosityModel, resTimeStepIdx, "SOIL");
cvf::ref<RigResultAccessor> sgas = RigResultAccessorFactory::createResultAccessor(eclipseCase, gridIndex, porosityModel, resTimeStepIdx, "SGAS");
cvf::ref<RigResultAccessor> swat = RigResultAccessorFactory::createResultAccessor(eclipseCase, gridIndex, porosityModel, resTimeStepIdx, "SWAT");
m_resultAccessor = new RigTernaryResultAccessor();
m_resultAccessor->setTernaryResultAccessors(soil.p(), sgas.p(), swat.p());
const RivTernaryScalarMapper* mapper = ternaryLegendConfig->scalarMapper();
// Create a texture mapper without detecting transparency using RigPipeInCellEvaluator
m_texMapper = new RivTernaryResultToTextureMapper(mapper, NULL);
CVF_ASSERT(m_texMapper.notNull());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivTernaryTextureCoordsCreator::createTextureCoords(cvf::Vec2fArray* quadTextureCoords)
{
CVF_ASSERT(m_quadMapper.notNull());
createTextureCoords(quadTextureCoords, m_quadMapper.p(), m_resultAccessor.p(), m_texMapper.p());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivTernaryTextureCoordsCreator::createTextureCoords(cvf::Vec2fArray* triTextureCoords, const std::vector<size_t>& triangleToCellIdx)
{
CVF_ASSERT(m_quadMapper.isNull());
createTextureCoords(triTextureCoords, triangleToCellIdx, m_resultAccessor.p(), m_texMapper.p());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -113,3 +157,33 @@ void RivTernaryTextureCoordsCreator::createTextureCoords(
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivTernaryTextureCoordsCreator::createTextureCoords(cvf::Vec2fArray* textureCoords, const std::vector<size_t>& triangleToCellIdx, const RigTernaryResultAccessor* resultAccessor, const RivTernaryResultToTextureMapper* texMapper)
{
CVF_ASSERT(textureCoords && resultAccessor && texMapper);
size_t numVertices = triangleToCellIdx.size() * 3;
textureCoords->resize(numVertices);
cvf::Vec2f* rawPtr = textureCoords->ptr();
cvf::Vec2d resultValue;
cvf::Vec2f texCoord;
#pragma omp parallel for private(texCoord, resultValue)
for (int i = 0; i < static_cast<int>(triangleToCellIdx.size()); i++)
{
size_t cellIdx = triangleToCellIdx[i];
resultValue = resultAccessor->cellScalarGlobIdx(cellIdx);
texCoord = texMapper->getTexCoord(resultValue.x(), resultValue.y(), cellIdx);
size_t j;
for (j = 0; j < 3; j++)
{
rawPtr[i * 3 + j] = texCoord;
}
}
}

View File

@ -41,13 +41,18 @@ namespace cvf
class RivTernaryTextureCoordsCreator
{
public:
RivTernaryTextureCoordsCreator( RimEclipseCellColors* cellResultColors,
RivTernaryTextureCoordsCreator( RimEclipseCellColors* cellResultColors,
RimTernaryLegendConfig* ternaryLegendConfig,
size_t timeStepIndex,
size_t gridIndex,
const cvf::StructGridQuadToCellFaceMapper* quadMapper);
RivTernaryTextureCoordsCreator( RimEclipseCellColors* cellResultColors,
RimTernaryLegendConfig* ternaryLegendConfig,
size_t timeStepIndex);
void createTextureCoords(cvf::Vec2fArray* quadTextureCoords);
void createTextureCoords(cvf::Vec2fArray* triTextureCoords, const std::vector<size_t>& triangleToCellIdx);
private:
static void createTextureCoords(cvf::Vec2fArray* quadTextureCoords,
@ -55,6 +60,10 @@ private:
const RigTernaryResultAccessor* resultAccessor,
const RivTernaryResultToTextureMapper* texMapper);
static void createTextureCoords(cvf::Vec2fArray* triTextureCoords,
const std::vector<size_t>& triangleToCellIdx,
const RigTernaryResultAccessor* resultAccessor,
const RivTernaryResultToTextureMapper* texMapper);
private:
cvf::cref<cvf::StructGridQuadToCellFaceMapper> m_quadMapper;
cvf::ref<RigTernaryResultAccessor> m_resultAccessor;

Some files were not shown because too many files have changed in this diff Show More