mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3343 Holo Lens : Add extraction of texture image
This commit is contained in:
@@ -35,38 +35,15 @@
|
||||
#include "cafEffectGenerator.h"
|
||||
|
||||
#include "cvfPart.h"
|
||||
#include "cvfRenderState.h"
|
||||
#include "cvfRenderStateTextureBindings.h"
|
||||
#include "cvfRenderState_FF.h"
|
||||
#include "cvfScene.h"
|
||||
#include "cvfTexture.h"
|
||||
#include "cvfTexture2D_FF.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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -141,6 +118,32 @@ std::vector<VdeExportPart> RicHoloLensExportImpl::partsForExport(const RimGridVi
|
||||
}
|
||||
}
|
||||
|
||||
// Check if texture image is present
|
||||
if (scenePart->effect())
|
||||
{
|
||||
{
|
||||
auto textureBindings = dynamic_cast<cvf::RenderStateTextureBindings*>(
|
||||
scenePart->effect()->renderStateOfType(cvf::RenderState::TEXTURE_BINDINGS));
|
||||
|
||||
if (textureBindings && textureBindings->bindingCount() > 0)
|
||||
{
|
||||
cvf::Texture* textureBinding = textureBindings->texture(0);
|
||||
partForExport.setTextureImage(textureBinding->image());
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
auto textureMappingFF = dynamic_cast<cvf::RenderStateTextureMapping_FF*>(
|
||||
scenePart->effect()->renderStateOfType(cvf::RenderState::TEXTURE_MAPPING_FF));
|
||||
|
||||
if (textureMappingFF && textureMappingFF->texture())
|
||||
{
|
||||
auto* texture = textureMappingFF->texture();
|
||||
partForExport.setTextureImage(texture->image());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exportParts.push_back(partForExport);
|
||||
}
|
||||
else if (RicHoloLensExportImpl::isPipe(scenePart.p()))
|
||||
@@ -284,3 +287,11 @@ bool RicHoloLensExportImpl::isPipe(const cvf::Part* part)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicHoloLensExportImpl::isMeshLines(const cvf::Part* part)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -42,9 +42,9 @@ public:
|
||||
static std::vector<VdeExportPart> partsForExport(const RimGridView& view);
|
||||
|
||||
private:
|
||||
static void partsForExport(const RimGridView* view, cvf::Collection<cvf::Part>* partCollection);
|
||||
static QString gridCellSetTypeText(RivCellSetEnum cellSetType);
|
||||
|
||||
static bool isGrid(const cvf::Part* part);
|
||||
static bool isPipe(const cvf::Part* part);
|
||||
static bool isMeshLines(const cvf::Part* part);
|
||||
};
|
||||
|
||||
@@ -31,6 +31,14 @@ VdeExportPart::VdeExportPart(cvf::Part* part)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void VdeExportPart::setTextureImage(const cvf::TextureImage* textureImage)
|
||||
{
|
||||
m_textureImage = textureImage;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -111,6 +119,14 @@ const cvf::Part* VdeExportPart::part() const
|
||||
return m_part.p();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const cvf::TextureImage* VdeExportPart::textureImage() const
|
||||
{
|
||||
return m_textureImage.p();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -126,3 +142,11 @@ float VdeExportPart::opacity() const
|
||||
{
|
||||
return m_opacity;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
VdeExportPart::Winding VdeExportPart::winding() const
|
||||
{
|
||||
return m_winding;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cvfPart.h"
|
||||
#include "cvfTextureImage.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
@@ -47,6 +48,7 @@ public:
|
||||
public:
|
||||
VdeExportPart(cvf::Part* part);
|
||||
|
||||
void setTextureImage(const cvf::TextureImage* textureImage);
|
||||
void setSourceObjectType(SourceObjectType sourceObjectType);
|
||||
void setSourceObjectName(const QString& sourceObjectName);
|
||||
void setSourceObjectCellSetType(const QString& sourceObjectCellSetType);
|
||||
@@ -54,7 +56,9 @@ public:
|
||||
void setOpacity(float opacity);
|
||||
void setWinding(Winding winding);
|
||||
|
||||
const cvf::Part* part() const;
|
||||
const cvf::Part* part() const;
|
||||
const cvf::TextureImage* textureImage() const;
|
||||
|
||||
QString sourceObjectName() const;
|
||||
QString sourceObjectCellSetType() const;
|
||||
SourceObjectType sourceObjectType() const;
|
||||
@@ -63,7 +67,8 @@ public:
|
||||
Winding winding() const;
|
||||
|
||||
private:
|
||||
cvf::cref<cvf::Part> m_part;
|
||||
cvf::cref<cvf::Part> m_part;
|
||||
cvf::cref<cvf::TextureImage> m_textureImage;
|
||||
|
||||
QString m_sourceObjectName;
|
||||
QString m_sourceObjectCellSetType;
|
||||
|
||||
Reference in New Issue
Block a user