#3343 Holo Lens : Use VdeExportPart

This commit is contained in:
Magne Sjaastad 2018-09-19 14:33:08 +02:00
parent 6eb5cb21c8
commit 2198ae61ae
5 changed files with 35 additions and 85 deletions

View File

@ -21,6 +21,7 @@
#include "RigMainGrid.h"
#include "RimEclipseCase.h"
#include "RimEclipseView.h"
#include "RimFaultInView.h"
#include "RimGridView.h"
#include "RimSimWellInView.h"
@ -103,13 +104,11 @@ std::vector<VdeExportPart> RicHoloLensExportImpl::partsForExport(const RimGridVi
}
}
auto* singleColorEffect = dynamic_cast<caf::SurfaceEffectGenerator*>(scenePart->effect());
auto* si = dynamic_cast<RivSourceInfo*>(scenePart->sourceInfo());
if (si)
{
RimFaultInView* faultInView = dynamic_cast<RimFaultInView*>(si->object());
if (faultInView && singleColorEffect)
if (faultInView)
{
partForExport.setSourceObjectName(faultInView->name());
partForExport.setColor(faultInView->faultColor());
@ -127,10 +126,18 @@ std::vector<VdeExportPart> RicHoloLensExportImpl::partsForExport(const RimGridVi
nameOfObject += " Grid " + QString::number(gridIndex);
}
partForExport.setSourceObjectName(nameOfObject);
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);
QString text = RicHoloLensExportImpl::gridCellSetTypeText(si->cellSetType());
partForExport.setSourceObjectCellSetType(text);
}
partForExport.setSourceObjectName(nameOfObject);
}
}
@ -172,48 +179,6 @@ std::vector<VdeExportPart> RicHoloLensExportImpl::partsForExport(const RimGridVi
return exportParts;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicHoloLensExportImpl::nameFromPart(const cvf::Part* part)
{
if (!part) return "";
QString nameOfObject;
auto sourceInfo = part->sourceInfo();
{
auto gridSourceInfo = dynamic_cast<const RivSourceInfo*>(sourceInfo);
if (gridSourceInfo)
{
size_t gridIndex = gridSourceInfo->gridIndex();
nameOfObject = "Grid " + QString::number(gridIndex);
}
}
{
auto simWellSourceInfo = dynamic_cast<const RivSimWellPipeSourceInfo*>(sourceInfo);
if (simWellSourceInfo)
{
RimSimWellInView* simulationWell = simWellSourceInfo->well();
nameOfObject = simulationWell->name();
}
}
{
auto wellPathSourceInfo = dynamic_cast<const RivWellPathSourceInfo*>(sourceInfo);
if (wellPathSourceInfo)
{
RimWellPath* wellPath = wellPathSourceInfo->wellPath();
nameOfObject = wellPath->name();
}
}
return nameOfObject;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -39,11 +39,10 @@ class Part;
class RicHoloLensExportImpl
{
public:
static void partsForExport(const RimGridView* view, cvf::Collection<cvf::Part>* partCollection);
static std::vector<VdeExportPart> partsForExport(const RimGridView& view);
static QString nameFromPart(const cvf::Part* part);
private:
static void partsForExport(const RimGridView* view, cvf::Collection<cvf::Part>* partCollection);
static QString gridCellSetTypeText(RivCellSetEnum cellSetType);
static bool isGrid(const cvf::Part* part);

View File

@ -106,7 +106,7 @@ VdeExportPart::SourceObjectType VdeExportPart::sourceObjectType() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Part* VdeExportPart::part()
const cvf::Part* VdeExportPart::part() const
{
return m_part.p();
}

View File

@ -54,7 +54,7 @@ public:
void setOpacity(float opacity);
void setWinding(Winding winding);
cvf::Part* part();
const cvf::Part* part() const;
QString sourceObjectName() const;
QString sourceObjectCellSetType() const;
SourceObjectType sourceObjectType() const;
@ -63,7 +63,7 @@ public:
Winding winding() const;
private:
cvf::ref<cvf::Part> m_part;
cvf::cref<cvf::Part> m_part;
QString m_sourceObjectName;
QString m_sourceObjectCellSetType;

View File

@ -57,36 +57,31 @@ VdeFileExporter::VdeFileExporter(QString absOutputFolder)
//--------------------------------------------------------------------------------------------------
bool VdeFileExporter::exportViewContents(const RimGridView& view)
{
cvf::Collection<cvf::Part> allPartsColl;
RicHoloLensExportImpl::partsForExport(&view, &allPartsColl);
std::vector<VdeMesh> meshArr;
std::vector<cvf::Color3f> colorArr;
colorArr.push_back(cvf::Color3f::fromByteColor( 81, 134, 148));
colorArr.push_back(cvf::Color3f::fromByteColor(212, 158, 97));
colorArr.push_back(cvf::Color3f::fromByteColor(217, 82, 28));
colorArr.push_back(cvf::Color3f::fromByteColor(212, 148, 138));
colorArr.push_back(cvf::Color3f::fromByteColor(115, 173, 181));
colorArr.push_back(cvf::Color3f::fromByteColor(125, 84, 56));
colorArr.push_back(cvf::Color3f::fromByteColor(206, 193, 55));
colorArr.push_back(cvf::Color3f::fromByteColor(252, 209, 158));
for (size_t i = 0; i < allPartsColl.size(); i++)
{
const cvf::Part* part = allPartsColl.at(i);
if (part)
std::vector<VdeExportPart> exportParts = RicHoloLensExportImpl::partsForExport(view);
for (const auto& exportPart : exportParts)
{
VdeMesh mesh;
if (extractMeshFromPart(view, *part, &mesh))
const cvf::Part* part = exportPart.part();
if (part)
{
mesh.color = colorArr[i % colorArr.size()];
meshArr.push_back(mesh);
VdeMesh mesh;
if (extractMeshFromPart(view, *part, &mesh))
{
QString srcObjType = "unknown";
if (exportPart.sourceObjectType() == VdeExportPart::OBJ_TYPE_GRID) srcObjType = "grid";
else if (exportPart.sourceObjectType() == VdeExportPart::OBJ_TYPE_PIPE) srcObjType = "pipe";
mesh.meshSourceObjTypeStr = srcObjType;
mesh.meshSourceObjName = exportPart.sourceObjectName();
mesh.color = exportPart.color();
meshArr.push_back(mesh);
}
}
}
}
std::vector<VdeMeshContentIds> meshContentIdsArr;
int nextArrayId = 0;
@ -218,15 +213,6 @@ bool VdeFileExporter::extractMeshFromPart(const RimGridView& view, const cvf::Pa
}
}
const QString nameOfObject = RicHoloLensExportImpl::nameFromPart(&part);
QString srcObjType = "unknown";
if (RicHoloLensExportImpl::isGrid(&part)) srcObjType = "grid";
else if (RicHoloLensExportImpl::isPipe(&part)) srcObjType = "pipe";
mesh->meshSourceObjTypeStr = srcObjType;
mesh->meshSourceObjName = nameOfObject;
return true;
}