mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-24 15:26:48 -06:00
287 lines
9.8 KiB
C++
287 lines
9.8 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) 2018 Statoil ASA
|
|
//
|
|
// 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 "RicHoloLensExportImpl.h"
|
|
|
|
#include "RigMainGrid.h"
|
|
|
|
#include "RimEclipseCase.h"
|
|
#include "RimEclipseView.h"
|
|
#include "RimFaultInView.h"
|
|
#include "RimGridView.h"
|
|
#include "RimSimWellInView.h"
|
|
#include "RimWellPath.h"
|
|
|
|
#include "RiuViewer.h"
|
|
#include "RivSimWellPipeSourceInfo.h"
|
|
#include "RivSourceInfo.h"
|
|
#include "RivWellPathSourceInfo.h"
|
|
|
|
#include "cafEffectGenerator.h"
|
|
|
|
#include "cvfPart.h"
|
|
#include "cvfScene.h"
|
|
|
|
#include <QString>
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicHoloLensExportImpl::partsForExport(const RimGridView* view, cvf::Collection<cvf::Part>* partCollection)
|
|
{
|
|
CVF_ASSERT(partCollection);
|
|
|
|
if (!view) return;
|
|
|
|
if (view->viewer())
|
|
{
|
|
cvf::Scene* scene = view->viewer()->mainScene();
|
|
if (scene)
|
|
{
|
|
cvf::Collection<cvf::Part> sceneParts;
|
|
scene->allParts(&sceneParts);
|
|
|
|
for (auto& scenePart : sceneParts)
|
|
{
|
|
if (RicHoloLensExportImpl::isGrid(scenePart.p()) || RicHoloLensExportImpl::isPipe(scenePart.p()))
|
|
{
|
|
partCollection->push_back(scenePart.p());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
std::vector<VdeExportPart> RicHoloLensExportImpl::partsForExport(const RimGridView& view)
|
|
{
|
|
std::vector<VdeExportPart> exportParts;
|
|
|
|
RimEclipseCase* rimEclipseCase = nullptr;
|
|
view.firstAncestorOrThisOfType(rimEclipseCase);
|
|
|
|
if (view.viewer())
|
|
{
|
|
cvf::Scene* scene = view.viewer()->mainScene();
|
|
if (scene)
|
|
{
|
|
cvf::Collection<cvf::Part> sceneParts;
|
|
scene->allParts(&sceneParts);
|
|
|
|
for (auto& scenePart : sceneParts)
|
|
{
|
|
if (RicHoloLensExportImpl::isGrid(scenePart.p()))
|
|
{
|
|
VdeExportPart partForExport(scenePart.p());
|
|
partForExport.setSourceObjectType(VdeExportPart::OBJ_TYPE_GRID);
|
|
|
|
if (rimEclipseCase && rimEclipseCase->mainGrid())
|
|
{
|
|
if (rimEclipseCase->mainGrid()->isFaceNormalsOutwards())
|
|
{
|
|
partForExport.setWinding(VdeExportPart::CLOCKWISE);
|
|
}
|
|
else
|
|
{
|
|
partForExport.setWinding(VdeExportPart::COUNTERCLOCKWISE);
|
|
}
|
|
}
|
|
|
|
auto* si = dynamic_cast<RivSourceInfo*>(scenePart->sourceInfo());
|
|
if (si)
|
|
{
|
|
RimFaultInView* faultInView = dynamic_cast<RimFaultInView*>(si->object());
|
|
if (faultInView)
|
|
{
|
|
partForExport.setSourceObjectName(faultInView->name());
|
|
partForExport.setColor(faultInView->faultColor());
|
|
}
|
|
|
|
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(si->object());
|
|
if (eclipseCase)
|
|
{
|
|
QString nameOfObject = rimEclipseCase->gridFileName();
|
|
auto gridSourceInfo = dynamic_cast<const RivSourceInfo*>(scenePart->sourceInfo());
|
|
if (gridSourceInfo)
|
|
{
|
|
size_t gridIndex = gridSourceInfo->gridIndex();
|
|
|
|
nameOfObject += " Grid " + QString::number(gridIndex);
|
|
}
|
|
|
|
const RimEclipseView* eclipseView = dynamic_cast<const RimEclipseView*>(&view);
|
|
if (eclipseView)
|
|
{
|
|
cvf::Color4f color = eclipseView->colorFromCellCategory(si->cellSetType());
|
|
partForExport.setColor(color.toColor3f());
|
|
partForExport.setOpacity(color.a());
|
|
|
|
QString text = RicHoloLensExportImpl::gridCellSetTypeText(si->cellSetType());
|
|
partForExport.setSourceObjectCellSetType(text);
|
|
}
|
|
|
|
partForExport.setSourceObjectName(nameOfObject);
|
|
}
|
|
}
|
|
|
|
exportParts.push_back(partForExport);
|
|
}
|
|
else if (RicHoloLensExportImpl::isPipe(scenePart.p()))
|
|
{
|
|
VdeExportPart partForExport(scenePart.p());
|
|
partForExport.setSourceObjectType(VdeExportPart::OBJ_TYPE_PIPE);
|
|
|
|
auto simWellSourceInfo = dynamic_cast<const RivSimWellPipeSourceInfo*>(scenePart->sourceInfo());
|
|
if (simWellSourceInfo)
|
|
{
|
|
auto simWell = simWellSourceInfo->well();
|
|
if (simWell)
|
|
{
|
|
partForExport.setSourceObjectName(simWell->name());
|
|
partForExport.setColor(simWell->wellPipeColor());
|
|
}
|
|
}
|
|
|
|
auto wellPathSourceInfo = dynamic_cast<const RivWellPathSourceInfo*>(scenePart->sourceInfo());
|
|
if (wellPathSourceInfo)
|
|
{
|
|
RimWellPath* wellPath = wellPathSourceInfo->wellPath();
|
|
if (wellPath)
|
|
{
|
|
partForExport.setSourceObjectName(wellPath->name());
|
|
partForExport.setColor(wellPath->wellPathColor());
|
|
}
|
|
}
|
|
|
|
exportParts.push_back(partForExport);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return exportParts;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
QString RicHoloLensExportImpl::gridCellSetTypeText(RivCellSetEnum cellSetType)
|
|
{
|
|
switch (cellSetType)
|
|
{
|
|
case OVERRIDDEN_CELL_VISIBILITY:
|
|
return "OVERRIDDEN_CELL_VISIBILITY";
|
|
break;
|
|
case ALL_CELLS:
|
|
return "ALL_CELLS";
|
|
break;
|
|
case ACTIVE:
|
|
return "ACTIVE";
|
|
break;
|
|
case ALL_WELL_CELLS:
|
|
return "ALL_WELL_CELLS";
|
|
break;
|
|
case VISIBLE_WELL_CELLS:
|
|
return "VISIBLE_WELL_CELLS";
|
|
break;
|
|
case VISIBLE_WELL_FENCE_CELLS:
|
|
return "VISIBLE_WELL_FENCE_CELLS";
|
|
break;
|
|
case INACTIVE:
|
|
return "INACTIVE";
|
|
break;
|
|
case RANGE_FILTERED:
|
|
return "RANGE_FILTERED";
|
|
break;
|
|
case RANGE_FILTERED_INACTIVE:
|
|
return "RANGE_FILTERED_INACTIVE";
|
|
break;
|
|
case RANGE_FILTERED_WELL_CELLS:
|
|
return "RANGE_FILTERED_WELL_CELLS";
|
|
break;
|
|
case VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER:
|
|
return "VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER";
|
|
break;
|
|
case VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER:
|
|
return "VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER";
|
|
break;
|
|
case PROPERTY_FILTERED:
|
|
return "PROPERTY_FILTERED";
|
|
break;
|
|
case PROPERTY_FILTERED_WELL_CELLS:
|
|
return "PROPERTY_FILTERED_WELL_CELLS";
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return "INVALID_CELL_SET_TYPE";
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RicHoloLensExportImpl::isGrid(const cvf::Part* part)
|
|
{
|
|
if (!part) return false;
|
|
|
|
auto sourceInfo = part->sourceInfo();
|
|
|
|
{
|
|
auto gridSourceInfo = dynamic_cast<const RivSourceInfo*>(sourceInfo);
|
|
if (gridSourceInfo)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RicHoloLensExportImpl::isPipe(const cvf::Part* part)
|
|
{
|
|
if (!part) return "";
|
|
|
|
QString nameOfObject;
|
|
|
|
auto sourceInfo = part->sourceInfo();
|
|
|
|
{
|
|
auto simWellSourceInfo = dynamic_cast<const RivSimWellPipeSourceInfo*>(sourceInfo);
|
|
if (simWellSourceInfo)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
{
|
|
auto wellPathSourceInfo = dynamic_cast<const RivWellPathSourceInfo*>(sourceInfo);
|
|
if (wellPathSourceInfo)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|