2015-11-18 02:15:13 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// 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 "RimCrossSection.h"
|
|
|
|
|
2015-11-18 05:16:04 -06:00
|
|
|
#include "RiaApplication.h"
|
|
|
|
|
2015-11-27 10:18:30 -06:00
|
|
|
#include "RicCommandFeature.h"
|
|
|
|
|
|
|
|
#include "RigSimulationWellCenterLineCalculator.h"
|
|
|
|
|
|
|
|
#include "RimCase.h"
|
2015-11-18 05:16:04 -06:00
|
|
|
#include "RimEclipseView.h"
|
|
|
|
#include "RimEclipseWell.h"
|
|
|
|
#include "RimEclipseWellCollection.h"
|
|
|
|
#include "RimOilField.h"
|
|
|
|
#include "RimProject.h"
|
2015-11-27 10:18:30 -06:00
|
|
|
#include "RimView.h"
|
2015-11-18 05:16:04 -06:00
|
|
|
#include "RimWellPath.h"
|
2015-11-18 02:15:13 -06:00
|
|
|
|
2015-11-27 10:18:30 -06:00
|
|
|
#include "RiuViewer.h"
|
2015-11-19 04:41:16 -06:00
|
|
|
#include "RivCrossSectionPartMgr.h"
|
2015-11-27 10:18:30 -06:00
|
|
|
|
|
|
|
#include "cafCmdFeature.h"
|
|
|
|
#include "cafCmdFeatureManager.h"
|
2015-11-30 08:12:00 -06:00
|
|
|
#include "cafPdmUiListEditor.h"
|
2015-11-27 10:18:30 -06:00
|
|
|
#include "cafPdmUiPushButtonEditor.h"
|
2015-11-18 02:15:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
namespace caf {
|
|
|
|
|
2015-11-18 03:06:42 -06:00
|
|
|
template<>
|
|
|
|
void caf::AppEnum< RimCrossSection::CrossSectionEnum >::setUp()
|
|
|
|
{
|
2015-11-18 08:55:05 -06:00
|
|
|
addItem(RimCrossSection::CS_WELL_PATH, "CS_WELL_PATH", "Well Path");
|
2015-11-26 04:08:38 -06:00
|
|
|
addItem(RimCrossSection::CS_SIMULATION_WELL, "CS_SIMULATION_WELL", "Simulation Well");
|
2015-11-27 10:18:30 -06:00
|
|
|
addItem(RimCrossSection::CS_POLYLINE, "CS_POLYLINE", "Polyline");
|
2015-11-18 03:06:42 -06:00
|
|
|
setDefault(RimCrossSection::CS_WELL_PATH);
|
|
|
|
}
|
2015-11-18 02:15:13 -06:00
|
|
|
|
2015-11-18 08:55:05 -06:00
|
|
|
template<>
|
|
|
|
void caf::AppEnum< RimCrossSection::CrossSectionDirEnum >::setUp()
|
|
|
|
{
|
|
|
|
addItem(RimCrossSection::CS_VERTICAL, "CS_VERTICAL", "Vertical");
|
|
|
|
addItem(RimCrossSection::CS_HORIZONTAL, "CS_HORIZONTAL", "Horizontal");
|
|
|
|
setDefault(RimCrossSection::CS_VERTICAL);
|
|
|
|
}
|
|
|
|
|
2015-11-18 02:15:13 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CAF_PDM_SOURCE_INIT(RimCrossSection, "CrossSection");
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimCrossSection::RimCrossSection()
|
|
|
|
{
|
2015-11-24 06:26:45 -06:00
|
|
|
CAF_PDM_InitObject("Intersection", ":/CrossSection16x16.png", "", "");
|
2015-11-18 02:15:13 -06:00
|
|
|
|
2015-11-23 02:07:35 -06:00
|
|
|
CAF_PDM_InitField(&name, "UserDescription", QString("Intersection Name"), "Name", "", "", "");
|
2015-11-18 02:15:13 -06:00
|
|
|
CAF_PDM_InitField(&isActive, "Active", true, "Active", "", "", "");
|
|
|
|
isActive.uiCapability()->setUiHidden(true);
|
|
|
|
|
2015-11-26 08:59:02 -06:00
|
|
|
CAF_PDM_InitFieldNoDefault(&type, "Type", "Type", "", "", "");
|
|
|
|
CAF_PDM_InitFieldNoDefault(&direction, "Direction", "Direction", "", "", "");
|
2015-11-27 06:50:31 -06:00
|
|
|
CAF_PDM_InitFieldNoDefault(&wellPath, "WellPath", "Well Path ", "", "", "");
|
2015-11-26 08:59:02 -06:00
|
|
|
CAF_PDM_InitFieldNoDefault(&simulationWell, "SimulationWell", "Simulation Well", "", "", "");
|
2015-12-01 08:25:06 -06:00
|
|
|
CAF_PDM_InitFieldNoDefault(&m_userPolyline, "Points", "Points", "", "Use Ctrl-C for copy and Ctrl-V for paste", "");
|
2015-11-26 08:59:02 -06:00
|
|
|
CAF_PDM_InitField (&m_branchIndex, "Branch", -1, "Branch", "", "", "");
|
|
|
|
CAF_PDM_InitField (&m_extentLength, "ExtentLength", 200.0, "Extent length", "", "", "");
|
2015-11-27 06:35:17 -06:00
|
|
|
CAF_PDM_InitField (&showInactiveCells, "ShowInactiveCells", false, "Inactive Cells", "", "", "");
|
2015-11-27 10:18:30 -06:00
|
|
|
|
2015-11-30 06:23:11 -06:00
|
|
|
CAF_PDM_InitFieldNoDefault(&inputFromViewerEnabled, "m_activateUiAppendPointsCommand", "", "", "", "");
|
|
|
|
inputFromViewerEnabled.xmlCapability()->setIOWritable(false);
|
|
|
|
inputFromViewerEnabled.xmlCapability()->setIOReadable(false);
|
|
|
|
inputFromViewerEnabled.uiCapability()->setUiEditorTypeName(caf::PdmUiPushButtonEditor::uiEditorTypeName());
|
2015-11-27 10:18:30 -06:00
|
|
|
|
2015-11-30 06:23:11 -06:00
|
|
|
inputFromViewerEnabled = false;
|
2015-11-26 08:59:02 -06:00
|
|
|
|
2015-11-18 05:16:04 -06:00
|
|
|
uiCapability()->setUiChildrenHidden(true);
|
2015-11-18 02:15:13 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimCrossSection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
|
|
|
{
|
2015-11-19 11:56:23 -06:00
|
|
|
if (changedField == &isActive ||
|
|
|
|
changedField == &type ||
|
|
|
|
changedField == &direction ||
|
|
|
|
changedField == &wellPath ||
|
2015-11-26 06:39:31 -06:00
|
|
|
changedField == &simulationWell ||
|
2015-11-26 08:59:02 -06:00
|
|
|
changedField == &m_branchIndex ||
|
2015-11-27 06:35:17 -06:00
|
|
|
changedField == &m_extentLength ||
|
|
|
|
changedField == &showInactiveCells)
|
2015-11-19 04:41:16 -06:00
|
|
|
{
|
2015-11-27 10:18:30 -06:00
|
|
|
rebuildGeometryAndScheduleCreateDisplayModel();
|
2015-11-19 04:41:16 -06:00
|
|
|
}
|
2015-11-26 06:39:31 -06:00
|
|
|
|
|
|
|
if (changedField == &simulationWell
|
|
|
|
|| changedField == &isActive
|
|
|
|
|| changedField == &type)
|
|
|
|
{
|
|
|
|
m_wellBranchCenterlines.clear();
|
|
|
|
updateWellCenterline();
|
2015-11-26 08:59:02 -06:00
|
|
|
m_branchIndex = -1;
|
2015-11-26 06:39:31 -06:00
|
|
|
}
|
2015-11-27 03:13:29 -06:00
|
|
|
|
|
|
|
|
|
|
|
if (changedField == &simulationWell
|
|
|
|
|| changedField == &wellPath
|
|
|
|
|| changedField == &m_branchIndex)
|
|
|
|
{
|
|
|
|
updateName();
|
|
|
|
}
|
|
|
|
|
2015-11-30 06:54:56 -06:00
|
|
|
if (changedField == &inputFromViewerEnabled
|
|
|
|
|| changedField == &m_userPolyline)
|
2015-11-27 10:18:30 -06:00
|
|
|
{
|
|
|
|
rebuildGeometryAndScheduleCreateDisplayModel();
|
|
|
|
}
|
2015-11-18 02:15:13 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimCrossSection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
|
|
|
{
|
2015-11-18 05:16:04 -06:00
|
|
|
uiOrdering.add(&name);
|
2015-11-27 06:50:31 -06:00
|
|
|
caf::PdmUiGroup* geometryGroup = uiOrdering.addNewGroup("Intersecting Geometry");
|
|
|
|
geometryGroup->add(&type);
|
2015-11-18 05:16:04 -06:00
|
|
|
|
2015-11-18 08:55:05 -06:00
|
|
|
if (type == CS_WELL_PATH)
|
2015-11-18 05:16:04 -06:00
|
|
|
{
|
2015-11-27 06:50:31 -06:00
|
|
|
geometryGroup->add(&wellPath);
|
2015-11-18 05:16:04 -06:00
|
|
|
}
|
2015-11-18 08:55:05 -06:00
|
|
|
else if (type == CS_SIMULATION_WELL)
|
2015-11-18 05:16:04 -06:00
|
|
|
{
|
2015-11-27 06:50:31 -06:00
|
|
|
geometryGroup->add(&simulationWell);
|
2015-11-26 06:39:31 -06:00
|
|
|
updateWellCenterline();
|
|
|
|
if (simulationWell() && m_wellBranchCenterlines.size() > 1)
|
|
|
|
{
|
2015-11-27 06:50:31 -06:00
|
|
|
geometryGroup->add(&m_branchIndex);
|
2015-11-26 06:39:31 -06:00
|
|
|
}
|
2015-11-18 05:16:04 -06:00
|
|
|
}
|
2015-11-27 10:18:30 -06:00
|
|
|
else if (type == CS_POLYLINE)
|
2015-11-18 05:16:04 -06:00
|
|
|
{
|
2015-11-30 03:00:06 -06:00
|
|
|
geometryGroup->add(&m_userPolyline);
|
2015-11-30 06:23:11 -06:00
|
|
|
geometryGroup->add(&inputFromViewerEnabled);
|
2015-11-18 05:16:04 -06:00
|
|
|
}
|
|
|
|
|
2015-11-27 06:50:31 -06:00
|
|
|
caf::PdmUiGroup* optionsGroup = uiOrdering.addNewGroup("Options");
|
|
|
|
|
|
|
|
optionsGroup->add(&direction);
|
|
|
|
optionsGroup->add(&m_extentLength);
|
|
|
|
optionsGroup->add(&showInactiveCells);
|
2015-11-27 06:35:17 -06:00
|
|
|
|
2015-11-30 07:01:13 -06:00
|
|
|
if (type == CS_POLYLINE)
|
|
|
|
{
|
|
|
|
m_extentLength.uiCapability()->setUiReadOnly(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_extentLength.uiCapability()->setUiReadOnly(false);
|
|
|
|
}
|
|
|
|
|
2015-11-26 09:47:45 -06:00
|
|
|
updateWellExtentDefaultValue();
|
2015-11-26 08:59:02 -06:00
|
|
|
|
2015-11-18 05:16:04 -06:00
|
|
|
uiOrdering.setForgetRemainingFields(true);
|
2015-11-18 02:15:13 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QList<caf::PdmOptionItemInfo> RimCrossSection::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
|
|
|
|
{
|
|
|
|
QList<caf::PdmOptionItemInfo> options;
|
|
|
|
|
2015-11-18 05:16:04 -06:00
|
|
|
if (fieldNeedingOptions == &wellPath)
|
|
|
|
{
|
|
|
|
RimProject* proj = RiaApplication::instance()->project();
|
|
|
|
if (proj->activeOilField()->wellPathCollection())
|
|
|
|
{
|
|
|
|
caf::PdmChildArrayField<RimWellPath*>& wellPaths = proj->activeOilField()->wellPathCollection()->wellPaths;
|
|
|
|
|
|
|
|
QIcon wellIcon(":/Well.png");
|
|
|
|
for (size_t i = 0; i < wellPaths.size(); i++)
|
|
|
|
{
|
|
|
|
options.push_back(caf::PdmOptionItemInfo(wellPaths[i]->name(), QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(wellPaths[i])), false, wellIcon));
|
|
|
|
}
|
|
|
|
}
|
2015-11-18 02:15:13 -06:00
|
|
|
|
2015-11-18 05:16:04 -06:00
|
|
|
if (options.size() == 0)
|
|
|
|
{
|
|
|
|
options.push_front(caf::PdmOptionItemInfo("None", QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(NULL))));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (fieldNeedingOptions == &simulationWell)
|
2015-11-18 02:15:13 -06:00
|
|
|
{
|
2015-11-18 05:16:04 -06:00
|
|
|
RimEclipseWellCollection* coll = simulationWellCollection();
|
|
|
|
if (coll)
|
2015-11-18 02:15:13 -06:00
|
|
|
{
|
2015-11-18 05:16:04 -06:00
|
|
|
caf::PdmChildArrayField<RimEclipseWell*>& eclWells = coll->wells;
|
2015-11-18 02:15:13 -06:00
|
|
|
|
2015-11-18 05:16:04 -06:00
|
|
|
QIcon simWellIcon(":/Well.png");
|
|
|
|
for (size_t i = 0; i < eclWells.size(); i++)
|
2015-11-18 02:15:13 -06:00
|
|
|
{
|
2015-11-18 05:16:04 -06:00
|
|
|
options.push_back(caf::PdmOptionItemInfo(eclWells[i]->name(), QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(eclWells[i])), false, simWellIcon));
|
2015-11-18 02:15:13 -06:00
|
|
|
}
|
2015-11-18 05:16:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
if (options.size() == 0)
|
|
|
|
{
|
|
|
|
options.push_front(caf::PdmOptionItemInfo("None", QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(NULL))));
|
2015-11-18 02:15:13 -06:00
|
|
|
}
|
|
|
|
}
|
2015-11-26 08:59:02 -06:00
|
|
|
else if (fieldNeedingOptions == &m_branchIndex)
|
2015-11-26 06:39:31 -06:00
|
|
|
{
|
|
|
|
updateWellCenterline();
|
|
|
|
|
|
|
|
size_t branchCount = m_wellBranchCenterlines.size();
|
|
|
|
|
|
|
|
options.push_back(caf::PdmOptionItemInfo("All", -1));
|
2015-11-18 05:16:04 -06:00
|
|
|
|
2015-12-01 07:19:49 -06:00
|
|
|
for (size_t bIdx = 0; bIdx < branchCount; ++bIdx)
|
2015-11-26 06:39:31 -06:00
|
|
|
{
|
|
|
|
options.push_back(caf::PdmOptionItemInfo(QString::number(bIdx + 1), QVariant::fromValue(bIdx)));
|
|
|
|
}
|
|
|
|
}
|
2015-11-18 02:15:13 -06:00
|
|
|
return options;
|
|
|
|
}
|
2015-11-18 03:06:42 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
caf::PdmFieldHandle* RimCrossSection::userDescriptionField()
|
|
|
|
{
|
|
|
|
return &name;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
caf::PdmFieldHandle* RimCrossSection::objectToggleField()
|
|
|
|
{
|
|
|
|
return &isActive;
|
|
|
|
}
|
2015-11-18 05:16:04 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimEclipseWellCollection* RimCrossSection::simulationWellCollection()
|
|
|
|
{
|
|
|
|
RimEclipseView* eclipseView = NULL;
|
|
|
|
firstAnchestorOrThisOfType(eclipseView);
|
|
|
|
|
|
|
|
if (eclipseView)
|
|
|
|
{
|
|
|
|
return eclipseView->wellCollection;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2015-11-18 08:55:05 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector< std::vector <cvf::Vec3d> > RimCrossSection::polyLines() const
|
|
|
|
{
|
2015-11-23 07:26:45 -06:00
|
|
|
std::vector< std::vector <cvf::Vec3d> > lines;
|
2015-11-18 08:55:05 -06:00
|
|
|
if (type == CS_WELL_PATH)
|
|
|
|
{
|
2015-11-26 04:08:38 -06:00
|
|
|
if (wellPath())
|
2015-11-18 08:55:05 -06:00
|
|
|
{
|
2015-11-23 07:26:45 -06:00
|
|
|
lines.push_back(wellPath->wellPathGeometry()->m_wellPathPoints);
|
2015-11-27 04:27:06 -06:00
|
|
|
clipToReservoir(lines[0]);
|
2015-11-18 08:55:05 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (type == CS_SIMULATION_WELL)
|
|
|
|
{
|
2015-11-26 04:08:38 -06:00
|
|
|
if (simulationWell())
|
|
|
|
{
|
2015-11-26 06:39:31 -06:00
|
|
|
updateWellCenterline();
|
|
|
|
|
2015-12-01 07:19:49 -06:00
|
|
|
if (0 <= m_branchIndex && m_branchIndex < static_cast<int>(m_wellBranchCenterlines.size()))
|
2015-11-26 06:39:31 -06:00
|
|
|
{
|
2015-11-26 08:59:02 -06:00
|
|
|
lines.push_back(m_wellBranchCenterlines[m_branchIndex]);
|
2015-11-26 06:39:31 -06:00
|
|
|
}
|
|
|
|
|
2015-11-26 08:59:02 -06:00
|
|
|
if (m_branchIndex == -1)
|
2015-11-26 06:39:31 -06:00
|
|
|
{
|
|
|
|
lines = m_wellBranchCenterlines;
|
|
|
|
}
|
2015-11-26 04:08:38 -06:00
|
|
|
}
|
2015-11-18 08:55:05 -06:00
|
|
|
}
|
2015-11-27 10:18:30 -06:00
|
|
|
else if (type == CS_POLYLINE)
|
2015-11-18 08:55:05 -06:00
|
|
|
{
|
2015-11-30 03:00:06 -06:00
|
|
|
lines.push_back(m_userPolyline);
|
2015-11-18 08:55:05 -06:00
|
|
|
}
|
|
|
|
|
2015-11-23 07:26:45 -06:00
|
|
|
if (type == CS_WELL_PATH || type == CS_SIMULATION_WELL)
|
|
|
|
{
|
2015-12-01 07:19:49 -06:00
|
|
|
for (size_t lIdx = 0; lIdx < lines.size(); ++lIdx)
|
2015-11-23 07:26:45 -06:00
|
|
|
{
|
2015-11-26 08:59:02 -06:00
|
|
|
std::vector<cvf::Vec3d>& polyLine = lines[lIdx];
|
|
|
|
addExtents(polyLine);
|
2015-11-23 07:26:45 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return lines;
|
2015-11-18 08:55:05 -06:00
|
|
|
}
|
|
|
|
|
2015-11-19 04:41:16 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RivCrossSectionPartMgr* RimCrossSection::crossSectionPartMgr()
|
|
|
|
{
|
|
|
|
if (m_crossSectionPartMgr.isNull()) m_crossSectionPartMgr = new RivCrossSectionPartMgr(this);
|
|
|
|
|
|
|
|
return m_crossSectionPartMgr.p();
|
|
|
|
}
|
|
|
|
|
2015-11-26 06:39:31 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimCrossSection::updateWellCenterline() const
|
|
|
|
{
|
|
|
|
if (isActive() && type == CS_SIMULATION_WELL && simulationWell())
|
|
|
|
{
|
|
|
|
if (m_wellBranchCenterlines.size() == 0)
|
|
|
|
{
|
|
|
|
std::vector< std::vector <RigWellResultPoint> > pipeBranchesCellIds;
|
|
|
|
|
|
|
|
RigSimulationWellCenterLineCalculator::calculateWellPipeCenterline(simulationWell(), m_wellBranchCenterlines, pipeBranchesCellIds);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_wellBranchCenterlines.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-26 08:59:02 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimCrossSection::addExtents(std::vector<cvf::Vec3d> &polyLine) const
|
|
|
|
{
|
|
|
|
size_t lineVxCount = polyLine.size();
|
|
|
|
|
|
|
|
if (lineVxCount == 0) return;
|
|
|
|
|
|
|
|
// Add extent at end of well
|
|
|
|
{
|
|
|
|
size_t endIdxOffset = lineVxCount > 3 ? 3: lineVxCount;
|
|
|
|
cvf::Vec3d endDirection = (polyLine[lineVxCount-1] - polyLine[lineVxCount-endIdxOffset]);
|
|
|
|
endDirection[2] = 0; // Remove z. make extent lenght be horizontally
|
|
|
|
if (endDirection.length() < 1e-2)
|
|
|
|
{
|
|
|
|
endDirection = polyLine.back() - polyLine.front();
|
|
|
|
endDirection[2] = 0;
|
|
|
|
|
|
|
|
if (endDirection.length() < 1e-2)
|
|
|
|
{
|
|
|
|
endDirection = cvf::Vec3d::X_AXIS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
endDirection.normalize();
|
|
|
|
|
|
|
|
cvf::Vec3d newEnd = polyLine.back() + endDirection * m_extentLength();
|
|
|
|
|
|
|
|
polyLine.push_back(newEnd);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add extent at start
|
|
|
|
{
|
|
|
|
size_t endIdxOffset = lineVxCount > 3 ? 3: lineVxCount-1;
|
|
|
|
cvf::Vec3d startDirection = (polyLine[0] - polyLine[endIdxOffset]);
|
|
|
|
startDirection[2] = 0; // Remove z. make extent lenght be horizontally
|
|
|
|
if (startDirection.length() < 1e-2)
|
|
|
|
{
|
|
|
|
startDirection = polyLine.front() - polyLine.back();
|
|
|
|
startDirection[2] = 0;
|
|
|
|
|
|
|
|
if (startDirection.length() < 1e-2)
|
|
|
|
{
|
|
|
|
startDirection = -cvf::Vec3d::X_AXIS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
startDirection.normalize();
|
|
|
|
|
|
|
|
cvf::Vec3d newStart = polyLine.front() + startDirection * m_extentLength();
|
|
|
|
|
|
|
|
polyLine.insert(polyLine.begin(), newStart);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-26 09:47:45 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimCrossSection::updateWellExtentDefaultValue()
|
|
|
|
{
|
|
|
|
RimCase* ownerCase = NULL;
|
|
|
|
firstAnchestorOrThisOfType(ownerCase);
|
|
|
|
|
|
|
|
if (ownerCase)
|
|
|
|
{
|
|
|
|
cvf::BoundingBox caseBB = ownerCase->activeCellsBoundingBox();
|
|
|
|
if (m_extentLength == m_extentLength.defaultValue() && caseBB.radius() < 1000)
|
|
|
|
{
|
|
|
|
m_extentLength = caseBB.radius() * 0.1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-27 03:13:29 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimCrossSection::updateName()
|
|
|
|
{
|
|
|
|
if (type == CS_SIMULATION_WELL && simulationWell())
|
|
|
|
{
|
|
|
|
name = simulationWell()->name();
|
|
|
|
if (m_branchIndex() != -1)
|
|
|
|
{
|
|
|
|
name = name() + " Branch " + QString::number(m_branchIndex() + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (type() == CS_WELL_PATH && wellPath())
|
|
|
|
{
|
|
|
|
name = wellPath()->name();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-11-27 04:27:06 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimCrossSection::clipToReservoir(std::vector<cvf::Vec3d> &polyLine) const
|
|
|
|
{
|
|
|
|
RimCase* ownerCase = NULL;
|
|
|
|
firstAnchestorOrThisOfType(ownerCase);
|
|
|
|
|
|
|
|
std::vector<cvf::Vec3d> clippedPolyLine;
|
|
|
|
|
|
|
|
if (ownerCase)
|
|
|
|
{
|
|
|
|
cvf::BoundingBox caseBB = ownerCase->activeCellsBoundingBox();
|
|
|
|
bool hasEnteredReservoirBB = false;
|
|
|
|
for (size_t vxIdx = 0 ; vxIdx < polyLine.size(); ++vxIdx)
|
|
|
|
{
|
|
|
|
if (!caseBB.contains(polyLine[vxIdx]))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!hasEnteredReservoirBB)
|
|
|
|
{
|
|
|
|
if (vxIdx > 0)
|
|
|
|
{
|
|
|
|
// clip line, and add vx to start
|
|
|
|
cvf::Plane topPlane;
|
|
|
|
topPlane.setFromPointAndNormal(caseBB.max(), cvf::Vec3d::Z_AXIS);
|
|
|
|
cvf::Vec3d intersection;
|
|
|
|
|
|
|
|
if (topPlane.intersect(polyLine[vxIdx-1], polyLine[vxIdx], &intersection))
|
|
|
|
{
|
|
|
|
clippedPolyLine.push_back(intersection);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
hasEnteredReservoirBB = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
clippedPolyLine.push_back(polyLine[vxIdx]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
polyLine.swap(clippedPolyLine);
|
|
|
|
}
|
|
|
|
|
2015-11-27 10:18:30 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimCrossSection::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute)
|
|
|
|
{
|
2015-11-30 06:23:11 -06:00
|
|
|
if (field == &inputFromViewerEnabled)
|
2015-11-27 10:18:30 -06:00
|
|
|
{
|
|
|
|
caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*> (attribute);
|
|
|
|
|
2015-11-30 06:23:11 -06:00
|
|
|
if (inputFromViewerEnabled)
|
2015-11-27 10:18:30 -06:00
|
|
|
{
|
2015-11-30 06:23:11 -06:00
|
|
|
attrib->m_buttonText = "Stop picking points";
|
2015-11-27 10:18:30 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-11-30 06:23:11 -06:00
|
|
|
attrib->m_buttonText = "Start picking points";
|
2015-11-27 10:18:30 -06:00
|
|
|
}
|
|
|
|
}
|
2015-11-30 08:12:00 -06:00
|
|
|
else if (field == &m_userPolyline)
|
|
|
|
{
|
|
|
|
caf::PdmUiListEditorAttribute* myAttr = dynamic_cast<caf::PdmUiListEditorAttribute*>(attribute);
|
|
|
|
if (myAttr && inputFromViewerEnabled)
|
|
|
|
{
|
|
|
|
myAttr->m_baseColor.setRgb(255, 220, 255);
|
|
|
|
}
|
|
|
|
}
|
2015-11-27 10:18:30 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimCrossSection::appendPointToPolyLine(const cvf::Vec3d& point)
|
|
|
|
{
|
2015-11-30 03:00:06 -06:00
|
|
|
m_userPolyline.v().push_back(point);
|
2015-11-27 10:18:30 -06:00
|
|
|
|
2015-11-30 03:00:06 -06:00
|
|
|
m_userPolyline.uiCapability()->updateConnectedEditors();
|
2015-11-27 10:18:30 -06:00
|
|
|
|
|
|
|
rebuildGeometryAndScheduleCreateDisplayModel();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimCrossSection::rebuildGeometryAndScheduleCreateDisplayModel()
|
|
|
|
{
|
|
|
|
m_crossSectionPartMgr = NULL;
|
|
|
|
|
|
|
|
RimView* rimView = NULL;
|
|
|
|
this->firstAnchestorOrThisOfType(rimView);
|
|
|
|
if (rimView)
|
|
|
|
{
|
|
|
|
rimView->scheduleCreateDisplayModelAndRedraw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|