#3401 HoloLens : Add detection of mesh line parts

This commit is contained in:
Magne Sjaastad 2018-09-21 11:36:32 +02:00
parent b028c36116
commit 32237b6c7c
11 changed files with 212 additions and 64 deletions

View File

@ -18,6 +18,9 @@
#include "RicHoloLensExportImpl.h"
#include "RiaApplication.h"
#include "RiaPreferences.h"
#include "RigMainGrid.h"
#include "RimEclipseCase.h"
@ -28,6 +31,10 @@
#include "RimWellPath.h"
#include "RiuViewer.h"
#include "RivFemPickSourceInfo.h"
#include "RivIntersectionBoxSourceInfo.h"
#include "RivIntersectionSourceInfo.h"
#include "RivMeshLinesSourceInfo.h"
#include "RivSimWellPipeSourceInfo.h"
#include "RivSourceInfo.h"
#include "RivWellPathSourceInfo.h"
@ -173,6 +180,26 @@ std::vector<VdeExportPart> RicHoloLensExportImpl::partsForExport(const RimGridVi
}
}
exportParts.push_back(partForExport);
}
else if (RicHoloLensExportImpl::isMeshLines(scenePart.p()))
{
VdeExportPart partForExport(scenePart.p());
partForExport.setSourceObjectType(VdeExportPart::OBJ_TYPE_GRID_MESH);
cvf::Color3f lineColor = RiaApplication::instance()->preferences()->defaultGridLineColors();
auto linesSourceInfo = dynamic_cast<const RivMeshLinesSourceInfo*>(scenePart->sourceInfo());
if (linesSourceInfo)
{
if (dynamic_cast<RimFaultInView*>(linesSourceInfo->object()))
{
lineColor = RiaApplication::instance()->preferences()->defaultFaultGridLineColors();
}
}
partForExport.setColor(lineColor);
exportParts.push_back(partForExport);
}
}
@ -248,10 +275,36 @@ bool RicHoloLensExportImpl::isGrid(const cvf::Part* part)
auto sourceInfo = part->sourceInfo();
{
auto gridSourceInfo = dynamic_cast<const RivSourceInfo*>(sourceInfo);
if (gridSourceInfo)
{
return true;
auto sourceInfoOfType = dynamic_cast<const RivSourceInfo*>(sourceInfo);
if (sourceInfoOfType)
{
return true;
}
}
{
auto sourceInfoOfType = dynamic_cast<const RivIntersectionSourceInfo*>(sourceInfo);
if (sourceInfoOfType)
{
return true;
}
}
{
auto sourceInfoOfType = dynamic_cast<const RivIntersectionBoxSourceInfo*>(sourceInfo);
if (sourceInfoOfType)
{
return true;
}
}
{
auto sourceInfoOfType = dynamic_cast<const RivFemPickSourceInfo*>(sourceInfo);
if (sourceInfoOfType)
{
return true;
}
}
}
@ -263,9 +316,7 @@ bool RicHoloLensExportImpl::isGrid(const cvf::Part* part)
//--------------------------------------------------------------------------------------------------
bool RicHoloLensExportImpl::isPipe(const cvf::Part* part)
{
if (!part) return "";
QString nameOfObject;
if (!part) return false;
auto sourceInfo = part->sourceInfo();
@ -293,5 +344,17 @@ bool RicHoloLensExportImpl::isPipe(const cvf::Part* part)
//--------------------------------------------------------------------------------------------------
bool RicHoloLensExportImpl::isMeshLines(const cvf::Part* part)
{
if (!part) return false;
auto sourceInfo = part->sourceInfo();
{
auto linesSourceInfo = dynamic_cast<const RivMeshLinesSourceInfo*>(sourceInfo);
if (linesSourceInfo)
{
return true;
}
}
return false;
}

View File

@ -36,6 +36,7 @@
#include "RimRegularLegendConfig.h"
#include "RivFemPickSourceInfo.h"
#include "RivMeshLinesSourceInfo.h"
#include "RivPartPriority.h"
#include "RivResultToTextureMapper.h"
#include "RivScalarMapperUtils.h"
@ -99,6 +100,9 @@ void RivFemPartPartMgr::setCellVisibility(cvf::UByteArray* cellVisibilities)
generatePartGeometry(m_surfaceGenerator);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFemPartPartMgr::generatePartGeometry(RivFemPartGeometryGenerator& geoBuilder)
{
bool useBufferObjects = true;
@ -166,6 +170,9 @@ void RivFemPartPartMgr::generatePartGeometry(RivFemPartGeometryGenerator& geoBui
part->setEnableMask(meshSurfaceBit);
part->setEffect(eff.p());
part->setSourceInfo(new RivMeshLinesSourceInfo(nullptr));
m_surfaceGridLines = part;
}
}

View File

@ -44,6 +44,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionFactorGeometryGenerator.h
${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionSourceInfo.h
${CMAKE_CURRENT_LIST_DIR}/RivSimWellConnectionSourceInfo.h
${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogDrawSurfaceGenerator.h
${CMAKE_CURRENT_LIST_DIR}/RivMeshLinesSourceInfo.h
)
set (SOURCE_GROUP_SOURCE_FILES
@ -86,6 +87,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionFactorGeometryGenerator.cpp
${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionSourceInfo.cpp
${CMAKE_CURRENT_LIST_DIR}/RivSimWellConnectionSourceInfo.cpp
${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogDrawSurfaceGenerator.cpp
${CMAKE_CURRENT_LIST_DIR}/RivMeshLinesSourceInfo.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -37,6 +37,7 @@
#include "RivIntersectionBoxSourceInfo.h"
#include "RivIntersectionPartMgr.h"
#include "RivMeshLinesSourceInfo.h"
#include "RivPartPriority.h"
#include "RivResultToTextureMapper.h"
#include "RivScalarMapperUtils.h"
@ -278,6 +279,8 @@ void RivIntersectionBoxPartMgr::generatePartGeometry()
part->setEnableMask(intersectionCellMeshBit);
part->setPriority(RivPartPriority::PartType::MeshLines);
part->setSourceInfo(new RivMeshLinesSourceInfo(m_rimIntersectionBox));
m_intersectionBoxGridLines = part;
}
}

View File

@ -19,6 +19,10 @@
#include "RivIntersectionPartMgr.h"
#include "RiaApplication.h"
#include "RiaOffshoreSphericalCoords.h"
#include "RiaPreferences.h"
#include "RigCaseCellResultsData.h"
#include "RigFemPartCollection.h"
#include "RigFemPartResultsCollection.h"
@ -27,14 +31,15 @@
#include "RigResultAccessorFactory.h"
#include "Rim2dIntersectionView.h"
#include "RimIntersection.h"
#include "RimEclipseCase.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseView.h"
#include "RimFaultInView.h"
#include "RimFaultInViewCollection.h"
#include "RimGeoMechCase.h"
#include "RimGeoMechCellColors.h"
#include "RimGeoMechView.h"
#include "RimIntersection.h"
#include "RimRegularLegendConfig.h"
#include "RimSimWellInView.h"
#include "RimSimWellInViewCollection.h"
@ -42,10 +47,13 @@
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "RiuGeoMechXfTensorResultAccessor.h"
#include "RivHexGridIntersectionTools.h"
#include "RivIntersectionGeometryGenerator.h"
#include "RivObjectSourceInfo.h"
#include "RivIntersectionSourceInfo.h"
#include "RivMeshLinesSourceInfo.h"
#include "RivObjectSourceInfo.h"
#include "RivPartPriority.h"
#include "RivPipeGeometryGenerator.h"
#include "RivResultToTextureMapper.h"
@ -55,8 +63,6 @@
#include "RivTernaryTextureCoordsCreator.h"
#include "RivWellPathSourceInfo.h"
#include "RiuGeoMechXfTensorResultAccessor.h"
#include "cafTensor3.h"
#include "cvfDrawableGeo.h"
@ -73,10 +79,6 @@
#include "cvfTransform.h"
#include <functional>
#include "RiaApplication.h"
#include "RiaPreferences.h"
#include "RimFaultInView.h"
#include "RiaOffshoreSphericalCoords.h"
//--------------------------------------------------------------------------------------------------
@ -556,6 +558,8 @@ void RivIntersectionPartMgr::generatePartGeometry()
part->setEnableMask(intersectionCellMeshBit);
part->setPriority(RivPartPriority::PartType::MeshLines);
part->setSourceInfo(new RivMeshLinesSourceInfo(m_rimCrossSection));
m_crossSectionGridLines = part;
}
}
@ -578,6 +582,8 @@ void RivIntersectionPartMgr::generatePartGeometry()
part->setEnableMask(intersectionFaultMeshBit);
part->setPriority(RivPartPriority::PartType::FaultMeshLines);
part->setSourceInfo(new RivMeshLinesSourceInfo(m_rimCrossSection));
m_crossSectionFaultGridLines = part;
}
}

View File

@ -20,15 +20,16 @@
#include "RiaApplication.h"
#include "RiuViewer.h"
#include "Rim3dView.h"
#include "Rim3dWellLogCurveCollection.h"
#include "RimCase.h"
#include "RimGridView.h"
#include "RimWellPath.h"
#include "RiuViewer.h"
#include "Riv3dWellLogCurveGeometryGenerator.h"
#include "Riv3dWellLogDrawSurfaceGenerator.h"
#include "RivMeshLinesSourceInfo.h"
#include "RivObjectSourceInfo.h"
#include "cafDisplayCoordTransform.h"
@ -118,14 +119,13 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurveToModel(cvf::ModelBasicList*
}
generator->createCurveDrawables(displayCoordTransform,
wellPathClipBoundingBox,
rim3dWellLogCurve,
wellPathCenterToPlotStartOffset(rim3dWellLogCurve->drawPlane()),
planeWidth(),
drawSurfaceVertices,
m_gridView->currentTimeStep());
wellPathClipBoundingBox,
rim3dWellLogCurve,
wellPathCenterToPlotStartOffset(rim3dWellLogCurve->drawPlane()),
planeWidth(),
drawSurfaceVertices,
m_gridView->currentTimeStep());
cvf::ref<cvf::DrawableGeo> curveDrawable = generator->curveDrawable();
if (curveDrawable.notNull() && curveDrawable->boundingBox().isValid())
{
@ -133,14 +133,13 @@ void Riv3dWellLogPlanePartMgr::append3dWellLogCurveToModel(cvf::ModelBasicList*
meshEffectGen.setLineWidth(3.0f);
cvf::ref<cvf::Effect> effect = meshEffectGen.generateCachedEffect();
cvf::ref<cvf::Part> part = new cvf::Part;
part->setDrawable(curveDrawable.p());
part->setEffect(effect.p());
if (part.notNull())
{
model->addPart(part.p());
}
cvf::ref<cvf::Part> part = new cvf::Part;
part->setDrawable(curveDrawable.p());
part->setEffect(effect.p());
part->setSourceInfo(new RivMeshLinesSourceInfo(rim3dWellLogCurve));
model->addPart(part.p());
}
}
@ -165,14 +164,13 @@ cvf::ref<cvf::Part> Riv3dWellLogPlanePartMgr::createPart(cvf::Drawable* drawable
//--------------------------------------------------------------------------------------------------
double Riv3dWellLogPlanePartMgr::wellPathCenterToPlotStartOffset(Rim3dWellLogCurve::DrawPlane drawPlane) const
{
if (drawPlane == Rim3dWellLogCurve::HORIZONTAL_CENTER ||
drawPlane == Rim3dWellLogCurve::VERTICAL_CENTER)
if (drawPlane == Rim3dWellLogCurve::HORIZONTAL_CENTER || drawPlane == Rim3dWellLogCurve::VERTICAL_CENTER)
{
return -0.5*planeWidth();
return -0.5 * planeWidth();
}
else
{
double cellSize = m_gridView->ownerCase()->characteristicCellSize();
double cellSize = m_gridView->ownerCase()->characteristicCellSize();
double wellPathOffset = std::min(m_wellPath->wellPathRadius(cellSize), 0.1 * planeWidth());
return m_wellPath->wellPathRadius(cellSize) + wellPathOffset;
}
@ -185,32 +183,32 @@ double Riv3dWellLogPlanePartMgr::planeWidth() const
{
if (!m_gridView) return 0;
double cellSize = m_gridView->ownerCase()->characteristicCellSize();
const Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection();
double cellSize = m_gridView->ownerCase()->characteristicCellSize();
const Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection();
return cellSize * curveCollection->planeWidthScaling();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Riv3dWellLogPlanePartMgr::appendDrawSurfaceToModel(cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& wellPathClipBoundingBox,
Rim3dWellLogCurve::DrawPlane drawPlane,
double samplingInterval)
void Riv3dWellLogPlanePartMgr::appendDrawSurfaceToModel(cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& wellPathClipBoundingBox,
Rim3dWellLogCurve::DrawPlane drawPlane,
double samplingInterval)
{
Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection();
cvf::ref<RivObjectSourceInfo> sourceInfo = new RivObjectSourceInfo(curveCollection);
Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection();
cvf::ref<RivObjectSourceInfo> sourceInfo = new RivObjectSourceInfo(curveCollection);
bool showCoordinateSystemMesh = curveCollection->isShowingGrid();
bool showBackground = curveCollection->isShowingBackground();
cvf::Color3f borderColor(0.4f, 0.4f, 0.4f);
cvf::Color3f borderColor(0.4f, 0.4f, 0.4f);
caf::SurfaceEffectGenerator backgroundEffectGen(cvf::Color4f(1.0, 1.0, 1.0, 1.0), caf::PO_2);
caf::MeshEffectGenerator borderEffectGen(borderColor);
caf::VectorEffectGenerator curveNormalsEffectGen;
backgroundEffectGen.enableLighting(false);
if (!showBackground)
{
// Make the background invisible but still present for picking.
@ -219,20 +217,21 @@ void Riv3dWellLogPlanePartMgr::appendDrawSurfaceToModel(cvf::ModelBasicList*
backgroundEffectGen.enableDepthWrite(false);
}
bool drawSurfaceCreated = m_3dWellLogDrawSurfaceGeometryGenerators[drawPlane]->createDrawSurface(displayCoordTransform,
wellPathClipBoundingBox,
Rim3dWellLogCurve::drawPlaneAngle(drawPlane),
wellPathCenterToPlotStartOffset(drawPlane),
planeWidth(),
samplingInterval);
bool drawSurfaceCreated =
m_3dWellLogDrawSurfaceGeometryGenerators[drawPlane]->createDrawSurface(displayCoordTransform,
wellPathClipBoundingBox,
Rim3dWellLogCurve::drawPlaneAngle(drawPlane),
wellPathCenterToPlotStartOffset(drawPlane),
planeWidth(),
samplingInterval);
if (!drawSurfaceCreated) return;
cvf::ref<cvf::Effect> backgroundEffect = backgroundEffectGen.generateCachedEffect();
cvf::ref<cvf::Effect> borderEffect = borderEffectGen.generateCachedEffect();
cvf::ref<cvf::Effect> backgroundEffect = backgroundEffectGen.generateCachedEffect();
cvf::ref<cvf::Effect> borderEffect = borderEffectGen.generateCachedEffect();
cvf::ref<cvf::Effect> curveNormalsEffect = curveNormalsEffectGen.generateCachedEffect();
cvf::ref<cvf::DrawableGeo> background = m_3dWellLogDrawSurfaceGeometryGenerators[drawPlane]->background();
if (background.notNull())
{
cvf::ref<cvf::Part> part = createPart(background.p(), backgroundEffect.p());

View File

@ -50,12 +50,13 @@
#include "cvfPart.h"
#include "cvfPrimitiveSetDirect.h"
#include "cvfqtUtils.h"
#include "RivMeshLinesSourceInfo.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivFaultPartMgr::RivFaultPartMgr(const RigGridBase* grid, const RimFaultInViewCollection* rimFaultCollection, const RimFaultInView* rimFault)
RivFaultPartMgr::RivFaultPartMgr(const RigGridBase* grid, const RimFaultInViewCollection* rimFaultCollection, RimFaultInView* rimFault)
: m_grid(grid),
m_rimFaultCollection(rimFaultCollection),
m_rimFault(rimFault),
@ -232,7 +233,7 @@ void RivFaultPartMgr::generatePartGeometry()
part->setDrawable(geo.p());
// Set mapping from triangle face index to cell index
cvf::ref<RivSourceInfo> si = new RivSourceInfo(const_cast<RimFaultInView*>(m_rimFault), m_grid->gridIndex());
cvf::ref<RivSourceInfo> si = new RivSourceInfo(m_rimFault, m_grid->gridIndex());
si->m_cellFaceFromTriangleMapper = m_nativeFaultGenerator->triangleToCellFaceMapper();
part->setSourceInfo(si.p());
@ -262,6 +263,8 @@ void RivFaultPartMgr::generatePartGeometry()
part->setEnableMask(meshFaultBit);
part->setPriority(RivPartPriority::PartType::FaultMeshLines);
part->setSourceInfo(new RivMeshLinesSourceInfo(m_rimFault));
m_nativeFaultGridLines = part;
}
}
@ -284,7 +287,7 @@ void RivFaultPartMgr::generatePartGeometry()
part->setDrawable(geo.p());
// Set mapping from triangle face index to cell index
cvf::ref<RivSourceInfo> si = new RivSourceInfo(const_cast<RimFaultInView*>(m_rimFault), m_grid->gridIndex());
cvf::ref<RivSourceInfo> si = new RivSourceInfo(m_rimFault, m_grid->gridIndex());
si->m_cellFaceFromTriangleMapper = m_oppositeFaultGenerator->triangleToCellFaceMapper();
part->setSourceInfo(si.p());
@ -314,6 +317,8 @@ void RivFaultPartMgr::generatePartGeometry()
part->setEnableMask(meshFaultBit);
part->setPriority(RivPartPriority::PartType::FaultMeshLines);
part->setSourceInfo(new RivMeshLinesSourceInfo(m_rimFault));
m_oppositeFaultGridLines = part;
}
}
@ -334,7 +339,7 @@ void RivFaultPartMgr::generatePartGeometry()
part->setDrawable(geo.p());
// Set mapping from triangle face index to cell index
cvf::ref<RivSourceInfo> si = new RivSourceInfo(const_cast<RimFaultInView*>(m_rimFault), m_grid->gridIndex());
cvf::ref<RivSourceInfo> si = new RivSourceInfo(m_rimFault, m_grid->gridIndex());
si->m_NNCIndices = m_NNCGenerator->triangleToNNCIndex().p();
part->setSourceInfo(si.p());
@ -450,11 +455,9 @@ void RivFaultPartMgr::createLabelWithAnchorLine(const cvf::Part* part)
cvf::Color3f defWellLabelColor = RiaApplication::instance()->preferences()->defaultWellLabelColor();
{
RimFaultInView* noConstRimFault = const_cast<RimFaultInView*>(m_rimFault);
if (noConstRimFault)
{
RimFaultInViewCollection* parentObject;
noConstRimFault->firstAncestorOrThisOfType(parentObject);
m_rimFault->firstAncestorOrThisOfType(parentObject);
if (parentObject)
{
defWellLabelColor = parentObject->faultLabelColor();;

View File

@ -24,6 +24,7 @@
#include "cvfArray.h"
#include "cafEffectGenerator.h"
#include "cafPdmPointer.h"
namespace cvf
{
@ -51,7 +52,7 @@ class RivNNCGeometryGenerator;
class RivFaultPartMgr : public cvf::Object
{
public:
RivFaultPartMgr(const RigGridBase* grid, const RimFaultInViewCollection* rimFaultCollection, const RimFaultInView* rimFault);
RivFaultPartMgr(const RigGridBase* grid, const RimFaultInViewCollection* rimFaultCollection, RimFaultInView* rimFault);
void setCellVisibility(cvf::UByteArray* cellVisibilities);
@ -79,7 +80,7 @@ private:
static cvf::Vec3f findClosestVertex(const cvf::Vec3f& point, const cvf::Vec3fArray* vertices);
private:
cvf::cref<RigGridBase> m_grid;
const RimFaultInView* m_rimFault;
caf::PdmPointer<RimFaultInView> m_rimFault;
const RimFaultInViewCollection* m_rimFaultCollection;
float m_opacityLevel;

View File

@ -38,6 +38,7 @@
#include "RivCellEdgeEffectGenerator.h"
#include "RivCompletionTypeResultToTextureMapper.h"
#include "RivMeshLinesSourceInfo.h"
#include "RivPartPriority.h"
#include "RivResultToTextureMapper.h"
#include "RivScalarMapperUtils.h"
@ -184,6 +185,9 @@ void RivGridPartMgr::generatePartGeometry(cvf::StructGridGeometryGenerator& geoB
part->setEnableMask(meshSurfaceBit);
part->setEffect(eff.p());
part->setSourceInfo(new RivMeshLinesSourceInfo(m_eclipseCase));
m_surfaceGridLines = part;
}
}

View File

@ -0,0 +1,29 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 - 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 "RivMeshLinesSourceInfo.h"
#include "cafPdmObject.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivMeshLinesSourceInfo::RivMeshLinesSourceInfo(caf::PdmObject* object)
: RivObjectSourceInfo(object)
{
}

View File

@ -0,0 +1,31 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RivObjectSourceInfo.h"
//==================================================================================================
///
///
//==================================================================================================
class RivMeshLinesSourceInfo : public RivObjectSourceInfo
{
public:
explicit RivMeshLinesSourceInfo(caf::PdmObject* pdmObject);
};