mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#632) Added support for creation of mesh part from a single cell
This commit is contained in:
@@ -92,6 +92,8 @@ set( USER_INTERFACE_FILES
|
||||
UserInterface/RiuProjectPropertyView.cpp
|
||||
UserInterface/RiuTimeHistoryQwtPlot.h
|
||||
UserInterface/RiuTimeHistoryQwtPlot.cpp
|
||||
UserInterface/RiuSelectionManager.h
|
||||
UserInterface/RiuSelectionManager.cpp
|
||||
)
|
||||
|
||||
set( SOCKET_INTERFACE_FILES
|
||||
|
||||
@@ -32,8 +32,7 @@ ${CEE_CURRENT_LIST_DIR}RivTernaryScalarMapperEffectGenerator.h
|
||||
${CEE_CURRENT_LIST_DIR}RivScalarMapperUtils.h
|
||||
${CEE_CURRENT_LIST_DIR}RivCellEdgeGeometryUtils.h
|
||||
${CEE_CURRENT_LIST_DIR}RivPipeQuadToSegmentMapper.h
|
||||
|
||||
|
||||
${CEE_CURRENT_LIST_DIR}RivSingleCellPartGenerator.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@@ -62,6 +61,7 @@ ${CEE_CURRENT_LIST_DIR}RivTernaryScalarMapperEffectGenerator.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivScalarMapperUtils.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivCellEdgeGeometryUtils.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivPipeQuadToSegmentMapper.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivSingleCellPartGenerator.cpp
|
||||
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) Statoil ASA
|
||||
// Copyright (C) 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 "RivSingleCellPartGenerator.h"
|
||||
|
||||
#include "RigCaseData.h"
|
||||
|
||||
#include "cafEffectGenerator.h"
|
||||
#include "cvfPart.h"
|
||||
#include "cvfRenderStateDepth.h"
|
||||
#include "cvfStructGridGeometryGenerator.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivSingleCellPartGenerator::RivSingleCellPartGenerator(RigCaseData* rigCaseData, size_t gridIndex, size_t cellIndex)
|
||||
: m_rigCaseData(rigCaseData),
|
||||
m_gridIndex(gridIndex),
|
||||
m_cellIndex(cellIndex)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::Part> RivSingleCellPartGenerator::createPart(const cvf::Color3f color)
|
||||
{
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
part->setName("Hightlight part for cell index " + m_cellIndex);
|
||||
part->setDrawable(createMeshDrawable().p());
|
||||
|
||||
cvf::ref<cvf::Effect> eff;
|
||||
caf::MeshEffectGenerator effGen(color);
|
||||
eff = effGen.generateUnCachedEffect();
|
||||
|
||||
cvf::ref<cvf::RenderStateDepth> depth = new cvf::RenderStateDepth;
|
||||
depth->enableDepthTest(false);
|
||||
eff->setRenderState(depth.p());
|
||||
|
||||
part->setEffect(eff.p());
|
||||
|
||||
return part;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo> RivSingleCellPartGenerator::createMeshDrawable()
|
||||
{
|
||||
if (m_rigCaseData &&
|
||||
m_cellIndex != cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
return cvf::StructGridGeometryGenerator::createMeshDrawableFromSingleCell(m_rigCaseData->grid(m_gridIndex), m_cellIndex);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) Statoil ASA
|
||||
// Copyright (C) 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
#include "cvfDrawableGeo.h"
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class Part;
|
||||
}
|
||||
|
||||
class RigCaseData;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RivSingleCellPartGenerator
|
||||
{
|
||||
public:
|
||||
RivSingleCellPartGenerator(RigCaseData* rigCaseData, size_t gridIndex, size_t cellIndex);
|
||||
|
||||
cvf::ref<cvf::Part> createPart(const cvf::Color3f color);
|
||||
|
||||
private:
|
||||
cvf::ref<cvf::DrawableGeo> createMeshDrawable();
|
||||
|
||||
private:
|
||||
RigCaseData* m_rigCaseData;
|
||||
size_t m_gridIndex;
|
||||
size_t m_cellIndex;
|
||||
};
|
||||
@@ -252,6 +252,46 @@ ref<DrawableGeo> StructGridGeometryGenerator::createOutlineMeshDrawable(double c
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
ref<DrawableGeo> StructGridGeometryGenerator::createMeshDrawableFromSingleCell(const StructGridInterface* grid, size_t cellIndex)
|
||||
{
|
||||
cvf::Vec3d cornerVerts[8];
|
||||
grid->cellCornerVertices(cellIndex, cornerVerts);
|
||||
|
||||
std::vector<Vec3f> vertices;
|
||||
|
||||
for (int enumInt = cvf::StructGridInterface::POS_I; enumInt < cvf::StructGridInterface::NO_FACE; enumInt++)
|
||||
{
|
||||
cvf::StructGridInterface::FaceType face = static_cast<cvf::StructGridInterface::FaceType>(enumInt);
|
||||
|
||||
ubyte faceConn[4];
|
||||
grid->cellFaceVertexIndices(face, faceConn);
|
||||
|
||||
int n;
|
||||
for (n = 0; n < 4; n++)
|
||||
{
|
||||
vertices.push_back(cvf::Vec3f(cornerVerts[faceConn[n]] - grid->displayModelOffset()));
|
||||
}
|
||||
}
|
||||
|
||||
cvf::ref<cvf::Vec3fArray> cvfVertices = new cvf::Vec3fArray;
|
||||
cvfVertices->assign(vertices);
|
||||
|
||||
if (!(cvfVertices.notNull() && cvfVertices->size() != 0)) return NULL;
|
||||
|
||||
ref<DrawableGeo> geo = new DrawableGeo;
|
||||
geo->setVertexArray(cvfVertices.p());
|
||||
|
||||
ref<UIntArray> indices = lineIndicesFromQuadVertexArray(cvfVertices.p());
|
||||
ref<PrimitiveSetIndexedUInt> prim = new PrimitiveSetIndexedUInt(PT_LINES);
|
||||
prim->setIndices(indices.p());
|
||||
|
||||
geo->addPrimitiveSet(prim.p());
|
||||
return geo;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
|
||||
@@ -187,6 +187,8 @@ public:
|
||||
ref<DrawableGeo> createMeshDrawable();
|
||||
ref<DrawableGeo> createOutlineMeshDrawable(double creaseAngle);
|
||||
|
||||
static ref<DrawableGeo> createMeshDrawableFromSingleCell(const StructGridInterface* grid, size_t cellIndex);
|
||||
|
||||
private:
|
||||
static ref<UIntArray>
|
||||
lineIndicesFromQuadVertexArray(const Vec3fArray* vertexArray);
|
||||
|
||||
Reference in New Issue
Block a user