mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
GeoMech with OdbReader Included in ResInsight Build
Preliminary, first shot. Added first iteration on basic visualization code.
This commit is contained in:
parent
6dad519f30
commit
a538be1775
@ -20,6 +20,9 @@ include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ReservoirDataModel
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/WellPathImportSsihub
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/GeoMech/OdbReader
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/GeoMech/GeoMechDataModel
|
||||
|
||||
${CMAKE_BINARY_DIR}/Generated
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
@ -76,6 +79,7 @@ list( APPEND REFERENCED_CMAKE_FILES
|
||||
FileInterface/CMakeLists_files.cmake
|
||||
ProjectDataModel/CMakeLists_files.cmake
|
||||
ModelVisualization/CMakeLists_files.cmake
|
||||
GeoMech/GeoMechVisualization/CMakeLists_files.cmake
|
||||
)
|
||||
|
||||
# Include source file lists from *.cmake files
|
||||
@ -89,6 +93,12 @@ list( APPEND CPP_SOURCES
|
||||
|
||||
add_subdirectory(WellPathImportSsihub)
|
||||
|
||||
add_subdirectory(GeoMech/GeoMechDataModel)
|
||||
|
||||
include(GeoMech/OdbReader/OdbSetup.cmake)
|
||||
|
||||
add_subdirectory(GeoMech/OdbReader)
|
||||
|
||||
|
||||
# Define files for MOC-ing
|
||||
set ( QT_MOC_HEADERS
|
||||
@ -274,6 +284,7 @@ endif()
|
||||
|
||||
target_link_libraries( ResInsight ${LINK_LIBRARIES} ${EXTERNAL_LINK_LIBRARIES})
|
||||
|
||||
|
||||
# Copy Dlls
|
||||
if (MSVC)
|
||||
|
||||
|
@ -15,3 +15,5 @@ add_library( ${PROJECT_NAME}
|
||||
RigGeoMechCaseData.h
|
||||
|
||||
)
|
||||
|
||||
target_link_libraries( ${PROJECT_NAME} LibCore )
|
@ -24,6 +24,7 @@
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigFemPart::RigFemPart()
|
||||
:m_elementPartId(-1)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -38,6 +38,11 @@ class RigFemPart : public cvf::Object
|
||||
public:
|
||||
RigFemPart();
|
||||
virtual ~RigFemPart();
|
||||
|
||||
int elementPartId() const { return m_elementPartId; }
|
||||
void setElementPartId(int partId) { m_elementPartId = partId; }
|
||||
|
||||
|
||||
void preAllocateElementStorage(int elementCount);
|
||||
void appendElement(RigElementType elmType, int id, const int* connectivities);
|
||||
|
||||
@ -48,8 +53,10 @@ public:
|
||||
const int* connectivities(size_t index) const { return &m_allAlementConnectivities[m_elementConnectivityStartIndices[index]];}
|
||||
|
||||
RigFemPartNodes& nodes() {return m_nodes;}
|
||||
const RigFemPartNodes& nodes() const {return m_nodes;}
|
||||
|
||||
private:
|
||||
int m_elementPartId;
|
||||
std::vector<int> m_elementId;
|
||||
std::vector<RigElementType> m_elementTypes;
|
||||
std::vector<size_t> m_elementConnectivityStartIndices;
|
||||
|
@ -0,0 +1,25 @@
|
||||
|
||||
# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly
|
||||
if (${CMAKE_VERSION} VERSION_GREATER "2.8.2")
|
||||
set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/)
|
||||
endif()
|
||||
|
||||
set (SOURCE_GROUP_HEADER_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RivFemPartGeometryGenerator.h
|
||||
${CEE_CURRENT_LIST_DIR}RivGeoMechPartMgr.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RivFemPartGeometryGenerator.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivGeoMechPartMgr.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
${SOURCE_GROUP_HEADER_FILES}
|
||||
)
|
||||
|
||||
list(APPEND CODE_SOURCE_FILES
|
||||
${SOURCE_GROUP_SOURCE_FILES}
|
||||
)
|
||||
|
||||
source_group( "GeoMechViz" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} )
|
@ -0,0 +1,223 @@
|
||||
#include "RivFemPartGeometryGenerator.h"
|
||||
|
||||
#include "cvfBase.h"
|
||||
|
||||
#include "RigFemPart.h"
|
||||
//#include "RigFemPartScalarDataAccess.h"
|
||||
|
||||
#include "cvfDebugTimer.h"
|
||||
#include "cvfGeometryBuilderDrawableGeo.h"
|
||||
#include "cvfPrimitiveSetIndexedUInt.h"
|
||||
#include "cvfScalarMapper.h"
|
||||
|
||||
#include "cvfArray.h"
|
||||
#include "cvfOutlineEdgeExtractor.h"
|
||||
#include <cmath>
|
||||
|
||||
|
||||
using namespace cvf;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivFemPartGeometryGenerator::RivFemPartGeometryGenerator(const RigFemPart* part)
|
||||
: m_part(part)
|
||||
{
|
||||
CVF_ASSERT(part);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivFemPartGeometryGenerator::~RivFemPartGeometryGenerator()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Generate surface drawable geo from the specified region
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
ref<DrawableGeo> RivFemPartGeometryGenerator::generateSurface()
|
||||
{
|
||||
computeArrays();
|
||||
|
||||
CVF_ASSERT(m_quadVertices.notNull());
|
||||
|
||||
if (m_quadVertices->size() == 0) return NULL;
|
||||
|
||||
ref<DrawableGeo> geo = new DrawableGeo;
|
||||
geo->setFromQuadVertexArray(m_quadVertices.p());
|
||||
|
||||
return geo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Generates simplified mesh as line drawing
|
||||
/// Must call generateSurface first
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
ref<DrawableGeo> RivFemPartGeometryGenerator::createMeshDrawable()
|
||||
{
|
||||
|
||||
if (!(m_quadVertices.notNull() && m_quadVertices->size() != 0)) return NULL;
|
||||
|
||||
ref<DrawableGeo> geo = new DrawableGeo;
|
||||
geo->setVertexArray(m_quadVertices.p());
|
||||
|
||||
ref<UIntArray> indices = lineIndicesFromQuadVertexArray(m_quadVertices.p());
|
||||
ref<PrimitiveSetIndexedUInt> prim = new PrimitiveSetIndexedUInt(PT_LINES);
|
||||
prim->setIndices(indices.p());
|
||||
|
||||
geo->addPrimitiveSet(prim.p());
|
||||
return geo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
ref<DrawableGeo> RivFemPartGeometryGenerator::createOutlineMeshDrawable(double creaseAngle)
|
||||
{
|
||||
if (!(m_quadVertices.notNull() && m_quadVertices->size() != 0)) return NULL;
|
||||
|
||||
cvf::OutlineEdgeExtractor ee(creaseAngle, *m_quadVertices);
|
||||
|
||||
ref<UIntArray> indices = lineIndicesFromQuadVertexArray(m_quadVertices.p());
|
||||
ee.addPrimitives(4, *indices);
|
||||
|
||||
ref<cvf::UIntArray> lineIndices = ee.lineIndices();
|
||||
if (lineIndices->size() == 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ref<PrimitiveSetIndexedUInt> prim = new PrimitiveSetIndexedUInt(PT_LINES);
|
||||
prim->setIndices(lineIndices.p());
|
||||
|
||||
ref<DrawableGeo> geo = new DrawableGeo;
|
||||
geo->setVertexArray(m_quadVertices.p());
|
||||
geo->addPrimitiveSet(prim.p());
|
||||
|
||||
return geo;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
ref<UIntArray> RivFemPartGeometryGenerator::lineIndicesFromQuadVertexArray(const Vec3fArray* vertexArray)
|
||||
{
|
||||
CVF_ASSERT(vertexArray);
|
||||
|
||||
size_t numVertices = vertexArray->size();
|
||||
int numQuads = static_cast<int>(numVertices/4);
|
||||
CVF_ASSERT(numVertices%4 == 0);
|
||||
|
||||
ref<UIntArray> indices = new UIntArray;
|
||||
indices->resize(numQuads*8);
|
||||
|
||||
#pragma omp parallel for
|
||||
for (int i = 0; i < numQuads; i++)
|
||||
{
|
||||
int idx = 8*i;
|
||||
indices->set(idx + 0, i*4 + 0);
|
||||
indices->set(idx + 1, i*4 + 1);
|
||||
indices->set(idx + 2, i*4 + 1);
|
||||
indices->set(idx + 3, i*4 + 2);
|
||||
indices->set(idx + 4, i*4 + 2);
|
||||
indices->set(idx + 5, i*4 + 3);
|
||||
indices->set(idx + 6, i*4 + 3);
|
||||
indices->set(idx + 7, i*4 + 0);
|
||||
}
|
||||
|
||||
return indices;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFemPartGeometryGenerator::computeArrays()
|
||||
{
|
||||
std::vector<Vec3f> vertices;
|
||||
|
||||
cvf::Vec3d offset = Vec3d::ZERO; //m_part->displayModelOffset();
|
||||
const std::vector<cvf::Vec3f>& nodeCoordinates = m_part->nodes().coordinates;
|
||||
|
||||
#pragma omp parallel for schedule(dynamic)
|
||||
for (int elmIdx = 0; elmIdx < static_cast<int>(m_part->elementCount()); elmIdx++)
|
||||
{
|
||||
if (m_elmVisibility.isNull() || (*m_elmVisibility)[elmIdx])
|
||||
{
|
||||
RigElementType eType = m_part->elementType(elmIdx);
|
||||
int faceCount = elmentFaceCount(eType);
|
||||
int elmQuadCount = 0;
|
||||
|
||||
const int* elmNodeIndices = m_part->connectivities(elmIdx);
|
||||
|
||||
for (int lfIdx = 0; lfIdx < faceCount; ++lfIdx)
|
||||
{
|
||||
int faceNodeCount = 0;
|
||||
const int* elmLocalFaceIndices = elementLocalFaceIndices(eType, lfIdx, &faceNodeCount);
|
||||
if (faceNodeCount == 4)
|
||||
{
|
||||
#if 0
|
||||
++elmQuadCount;
|
||||
int quad[4];
|
||||
quad[0] = elmNodeIndices[elmLocalFaceIndices[0]];
|
||||
quad[1] = elmNodeIndices[elmLocalFaceIndices[1]];
|
||||
quad[2] = elmNodeIndices[elmLocalFaceIndices[2]];
|
||||
quad[3] = elmNodeIndices[elmLocalFaceIndices[3]];
|
||||
#endif
|
||||
// Needs to get rid of opposite faces
|
||||
|
||||
vertices.push_back(nodeCoordinates[ elmNodeIndices[elmLocalFaceIndices[0]] ]);
|
||||
vertices.push_back(nodeCoordinates[ elmNodeIndices[elmLocalFaceIndices[1]] ]);
|
||||
vertices.push_back(nodeCoordinates[ elmNodeIndices[elmLocalFaceIndices[2]] ]);
|
||||
vertices.push_back(nodeCoordinates[ elmNodeIndices[elmLocalFaceIndices[3]] ]);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Handle triangles and 6 node and 8 node faces
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
m_quadVertices = new cvf::Vec3fArray;
|
||||
m_quadVertices->assign(vertices);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Calculates the texture coordinates in a "nearly" one dimentional texture.
|
||||
/// Undefined values are coded with a y-texturecoordinate value of 1.0 instead of the normal 0.5
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFemPartGeometryGenerator::textureCoordinates(Vec2fArray* textureCoords, const RigFemPartScalarDataAccess* resultAccessor, const ScalarMapper* mapper) const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFemPartGeometryGenerator::setElementVisibility(const cvf::UByteArray* cellVisibility)
|
||||
{
|
||||
m_elmVisibility = cellVisibility;
|
||||
}
|
||||
|
@ -0,0 +1,63 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cvfObject.h"
|
||||
#include "cvfArray.h"
|
||||
|
||||
#include "RigFemPart.h"
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
|
||||
class DrawableGeo;
|
||||
class ScalarMapper;
|
||||
|
||||
}
|
||||
|
||||
class RigFemPartScalarDataAccess;
|
||||
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RivFemPartGeometryGenerator : public cvf::Object
|
||||
{
|
||||
public:
|
||||
RivFemPartGeometryGenerator(const RigFemPart* part);
|
||||
~RivFemPartGeometryGenerator();
|
||||
|
||||
// Setup methods
|
||||
|
||||
void setElementVisibility(const cvf::UByteArray* cellVisibility);
|
||||
|
||||
// Access, valid after generation is done
|
||||
|
||||
const RigFemPart* activePart() { return m_part.p(); }
|
||||
|
||||
void textureCoordinates(cvf::Vec2fArray* textureCoords, const RigFemPartScalarDataAccess* resultAccessor, const cvf::ScalarMapper* mapper) const;
|
||||
|
||||
// Generated geometry
|
||||
cvf::ref<cvf::DrawableGeo> generateSurface();
|
||||
cvf::ref<cvf::DrawableGeo> createMeshDrawable();
|
||||
cvf::ref<cvf::DrawableGeo> createOutlineMeshDrawable(double creaseAngle);
|
||||
|
||||
private:
|
||||
static cvf::ref<cvf::UIntArray>
|
||||
lineIndicesFromQuadVertexArray(const cvf::Vec3fArray* vertexArray);
|
||||
void computeArrays();
|
||||
|
||||
private:
|
||||
// Input
|
||||
cvf::cref<RigFemPart> m_part; // The part being processed
|
||||
cvf::cref<cvf::UByteArray> m_elmVisibility;
|
||||
|
||||
// Created arrays
|
||||
cvf::ref<cvf::Vec3fArray> m_quadVertices;
|
||||
//cvf::ref<cvf::Vec3fArray> m_triangleVertices; // If needed, we will do it like this, I think
|
||||
|
||||
};
|
||||
|
||||
|
@ -0,0 +1,262 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- 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 "RivGeoMechPartMgr.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
#include "RigCaseCellResultsData.h"
|
||||
#include "RigCaseData.h"
|
||||
#include "RigResultAccessorFactory.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimReservoirCellResultsStorage.h"
|
||||
#include "RimReservoirView.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimTernaryLegendConfig.h"
|
||||
#include "RimWellCollection.h"
|
||||
|
||||
#include "RivCellEdgeEffectGenerator.h"
|
||||
#include "RivResultToTextureMapper.h"
|
||||
#include "RivScalarMapperUtils.h"
|
||||
#include "RivSourceInfo.h"
|
||||
#include "RivTernaryScalarMapperEffectGenerator.h"
|
||||
#include "RivTernaryTextureCoordsCreator.h"
|
||||
#include "RivTextureCoordsCreator.h"
|
||||
|
||||
#include "cafEffectGenerator.h"
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "cafProgressInfo.h"
|
||||
|
||||
#include "cvfDrawableGeo.h"
|
||||
#include "cvfMath.h"
|
||||
#include "cvfModelBasicList.h"
|
||||
#include "cvfPart.h"
|
||||
#include "cvfRenderStateBlending.h"
|
||||
#include "cvfRenderStatePolygonOffset.h"
|
||||
#include "cvfRenderState_FF.h"
|
||||
#include "cvfShaderProgram.h"
|
||||
#include "cvfShaderProgramGenerator.h"
|
||||
#include "cvfShaderSourceProvider.h"
|
||||
#include "cvfShaderSourceRepository.h"
|
||||
#include "cvfStructGrid.h"
|
||||
#include "cvfUniform.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivGeoMechPartMgr::RivGeoMechPartMgr(const RigFemPart* grid)
|
||||
: m_surfaceGenerator(grid),
|
||||
m_grid(grid),
|
||||
m_opacityLevel(1.0f),
|
||||
m_defaultColor(cvf::Color3::WHITE)
|
||||
{
|
||||
CVF_ASSERT(grid);
|
||||
m_gridIdx = grid->elementPartId();
|
||||
m_cellVisibility = new cvf::UByteArray;
|
||||
m_surfaceFacesTextureCoords = new cvf::Vec2fArray;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGeoMechPartMgr::setTransform(cvf::Transform* scaleTransform)
|
||||
{
|
||||
m_scaleTransform = scaleTransform;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGeoMechPartMgr::setCellVisibility(cvf::UByteArray* cellVisibilities)
|
||||
{
|
||||
CVF_ASSERT(m_scaleTransform.notNull());
|
||||
CVF_ASSERT(cellVisibilities);
|
||||
|
||||
m_cellVisibility = cellVisibilities;
|
||||
|
||||
m_surfaceGenerator.setElementVisibility(cellVisibilities);
|
||||
|
||||
generatePartGeometry(m_surfaceGenerator);
|
||||
}
|
||||
|
||||
void RivGeoMechPartMgr::generatePartGeometry(RivFemPartGeometryGenerator& geoBuilder)
|
||||
{
|
||||
bool useBufferObjects = true;
|
||||
// Surface geometry
|
||||
{
|
||||
cvf::ref<cvf::DrawableGeo> geo = geoBuilder.generateSurface();
|
||||
if (geo.notNull())
|
||||
{
|
||||
geo->computeNormals();
|
||||
|
||||
if (useBufferObjects)
|
||||
{
|
||||
geo->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT);
|
||||
}
|
||||
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
part->setName("FemPart " + cvf::String(m_gridIdx));
|
||||
part->setId(m_gridIdx); // !! For now, use grid index as part ID (needed for pick info)
|
||||
part->setDrawable(geo.p());
|
||||
part->setTransform(m_scaleTransform.p());
|
||||
|
||||
// Set mapping from triangle face index to cell index
|
||||
//cvf::ref<RivSourceInfo> si = new RivSourceInfo;
|
||||
//si->m_cellFaceFromTriangleMapper = geoBuilder.triangleToCellFaceMapper();
|
||||
//
|
||||
//part->setSourceInfo(si.p());
|
||||
|
||||
part->updateBoundingBox();
|
||||
|
||||
// Set default effect
|
||||
caf::SurfaceEffectGenerator geometryEffgen(cvf::Color4f(cvf::Color3f::WHITE), caf::PO_1);
|
||||
cvf::ref<cvf::Effect> geometryOnlyEffect = geometryEffgen.generateEffect();
|
||||
part->setEffect(geometryOnlyEffect.p());
|
||||
part->setEnableMask(surfaceBit);
|
||||
m_surfaceFaces = part;
|
||||
}
|
||||
}
|
||||
|
||||
// Mesh geometry
|
||||
{
|
||||
cvf::ref<cvf::DrawableGeo> geoMesh = geoBuilder.createMeshDrawable();
|
||||
if (geoMesh.notNull())
|
||||
{
|
||||
if (useBufferObjects)
|
||||
{
|
||||
geoMesh->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT);
|
||||
}
|
||||
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
part->setName("Grid mesh " + m_gridIdx);
|
||||
part->setDrawable(geoMesh.p());
|
||||
|
||||
part->setTransform(m_scaleTransform.p());
|
||||
part->updateBoundingBox();
|
||||
|
||||
RiaPreferences* prefs = RiaApplication::instance()->preferences();
|
||||
|
||||
cvf::ref<cvf::Effect> eff;
|
||||
caf::MeshEffectGenerator effGen(prefs->defaultGridLineColors());
|
||||
eff = effGen.generateEffect();
|
||||
|
||||
// Set priority to make sure fault lines are rendered first
|
||||
part->setPriority(10);
|
||||
|
||||
part->setEnableMask(meshSurfaceBit);
|
||||
part->setEffect(eff.p());
|
||||
m_surfaceGridLines = part;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGeoMechPartMgr::appendPartsToModel(cvf::ModelBasicList* model)
|
||||
{
|
||||
CVF_ASSERT(model != NULL);
|
||||
|
||||
if(m_surfaceFaces.notNull() ) model->addPart(m_surfaceFaces.p() );
|
||||
if(m_surfaceGridLines.notNull()) model->addPart(m_surfaceGridLines.p());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGeoMechPartMgr::updateCellColor(cvf::Color4f color)
|
||||
{
|
||||
if (m_surfaceFaces.isNull()) return;
|
||||
|
||||
// Set default effect
|
||||
caf::SurfaceEffectGenerator geometryEffgen(color, caf::PO_1);
|
||||
cvf::ref<cvf::Effect> geometryOnlyEffect = geometryEffgen.generateEffect();
|
||||
|
||||
if (m_surfaceFaces.notNull()) m_surfaceFaces->setEffect(geometryOnlyEffect.p());
|
||||
|
||||
if (color.a() < 1.0f)
|
||||
{
|
||||
// Set priority to make sure this transparent geometry are rendered last
|
||||
if (m_surfaceFaces.notNull()) m_surfaceFaces->setPriority(100);
|
||||
}
|
||||
|
||||
m_opacityLevel = color.a();
|
||||
m_defaultColor = color.toColor3f();
|
||||
|
||||
// Update mesh colors as well, in case of change
|
||||
RiaPreferences* prefs = RiaApplication::instance()->preferences();
|
||||
|
||||
cvf::ref<cvf::Effect> eff;
|
||||
if (m_surfaceFaces.notNull())
|
||||
{
|
||||
caf::MeshEffectGenerator effGen(prefs->defaultGridLineColors());
|
||||
eff = effGen.generateEffect();
|
||||
m_surfaceGridLines->setEffect(eff.p());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGeoMechPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechResultSlot* cellResultSlot)
|
||||
{
|
||||
CVF_ASSERT(cellResultSlot);
|
||||
|
||||
// RigCaseData* eclipseCase = cellResultSlot->reservoirView()->eclipseCase()->reservoirData();
|
||||
|
||||
cvf::ref<cvf::Color3ubArray> surfaceFacesColorArray;
|
||||
|
||||
// Outer surface
|
||||
if (m_surfaceFaces.notNull())
|
||||
{
|
||||
#if 0
|
||||
{
|
||||
RivTextureCoordsCreator texturer(cellResultSlot,
|
||||
timeStepIndex,
|
||||
m_grid->gridIndex(),
|
||||
m_surfaceGenerator.quadToCellFaceMapper());
|
||||
if (!texturer.isValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
texturer.createTextureCoords(m_surfaceFacesTextureCoords.p());
|
||||
|
||||
const cvf::ScalarMapper* mapper = cellResultSlot->legendConfig()->scalarMapper();
|
||||
RivScalarMapperUtils::applyTextureResultsToPart(m_surfaceFaces.p(), m_surfaceFacesTextureCoords.p(), mapper, m_opacityLevel, caf::FC_NONE);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivGeoMechPartMgr::~RivGeoMechPartMgr()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,81 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- 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 "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
|
||||
#include "RivFemPartGeometryGenerator.h"
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class StructGridInterface;
|
||||
class ModelBasicList;
|
||||
class Transform;
|
||||
class Part;
|
||||
class Effect;
|
||||
}
|
||||
|
||||
class RimGeoMechResultSlot;
|
||||
class RigFemPart;
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
/// RivGridGeometry: Class to handle visualization structures that embodies a specific grid at a specific time step.
|
||||
/// frame on a certain level
|
||||
/// LGR's have their own instance and the parent grid as well
|
||||
///
|
||||
//==================================================================================================
|
||||
|
||||
class RivGeoMechPartMgr: public cvf::Object
|
||||
{
|
||||
public:
|
||||
RivGeoMechPartMgr(const RigFemPart* grid);
|
||||
~RivGeoMechPartMgr();
|
||||
void setTransform(cvf::Transform* scaleTransform);
|
||||
void setCellVisibility(cvf::UByteArray* cellVisibilities );
|
||||
cvf::ref<cvf::UByteArray> cellVisibility() { return m_cellVisibility;}
|
||||
|
||||
void updateCellColor(cvf::Color4f color);
|
||||
void updateCellResultColor(size_t timeStepIndex, RimGeoMechResultSlot* cellResultSlot);
|
||||
|
||||
void appendPartsToModel(cvf::ModelBasicList* model);
|
||||
|
||||
private:
|
||||
void generatePartGeometry(RivFemPartGeometryGenerator& geoBuilder);
|
||||
|
||||
private:
|
||||
int m_gridIdx;
|
||||
cvf::cref<RigFemPart> m_grid;
|
||||
|
||||
cvf::ref<cvf::Transform> m_scaleTransform;
|
||||
float m_opacityLevel;
|
||||
cvf::Color3f m_defaultColor;
|
||||
|
||||
// Surface visualization
|
||||
RivFemPartGeometryGenerator m_surfaceGenerator;
|
||||
|
||||
cvf::ref<cvf::Part> m_surfaceFaces;
|
||||
cvf::ref<cvf::Vec2fArray> m_surfaceFacesTextureCoords;
|
||||
|
||||
cvf::ref<cvf::Part> m_surfaceGridLines;
|
||||
|
||||
cvf::ref<cvf::UByteArray> m_cellVisibility;
|
||||
};
|
@ -17,3 +17,23 @@ add_library( ${PROJECT_NAME}
|
||||
RifGeoMechReaderInterface.h
|
||||
RifGeoMechReaderInterface.cpp
|
||||
)
|
||||
|
||||
list(APPEND RI_ODB_LIBS
|
||||
${RI_ODB_API_DIR}/lib/ABQSMAOdbDdbOdb.lib
|
||||
${RI_ODB_API_DIR}/lib/ABQSMAOdbApi.lib
|
||||
${RI_ODB_API_DIR}/lib/ABQSMAOdbCore.lib
|
||||
${RI_ODB_API_DIR}/lib/ABQSMAOdbCoreGeom.lib
|
||||
${RI_ODB_API_DIR}/lib/ABQSMAOdbAttrEO.lib
|
||||
${RI_ODB_API_DIR}/lib/ABQSMAAbuBasicUtils.lib
|
||||
${RI_ODB_API_DIR}/lib/ABQSMABasShared.lib
|
||||
${RI_ODB_API_DIR}/lib/ABQSMABasCoreUtils.lib
|
||||
${RI_ODB_API_DIR}/lib/ABQSMAStiCAE_StableTime.lib
|
||||
${RI_ODB_API_DIR}/lib/ABQSMABasMem.lib
|
||||
${RI_ODB_API_DIR}/lib/ABQSMAAbuGeom.lib
|
||||
${RI_ODB_API_DIR}/lib/ABQSMARomDiagEx.lib
|
||||
${RI_ODB_API_DIR}/lib/ABQSMASspUmaCore.lib
|
||||
${RI_ODB_API_DIR}/lib/ABQSMASimInterface.lib
|
||||
${RI_ODB_API_DIR}/lib/ABQSMAMtxCoreModule.lib
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} ${RI_ODB_LIBS} RigGeoMechDataModel LibCore)
|
||||
|
21
ApplicationCode/GeoMech/OdbReader/OdbSetup.cmake
Normal file
21
ApplicationCode/GeoMech/OdbReader/OdbSetup.cmake
Normal file
@ -0,0 +1,21 @@
|
||||
|
||||
# Copy Odb Dlls
|
||||
|
||||
set(RI_ODB_API_DIR C:/pfRoot/jjsOnJacobpcCsdep/User/Sigurd/OdbApiExperiments/OdbApi/x64 CACHE PATH "Path tho the ODB api from Simulia")
|
||||
if (MSVC)
|
||||
# Find all the dlls
|
||||
file (GLOB RI_ALL_ODB_DLLS ${RI_ODB_API_DIR}/lib/*.dll)
|
||||
|
||||
# Strip off the path
|
||||
foreach (aDLL ${RI_ALL_ODB_DLLS})
|
||||
get_filename_component(filenameWithExt ${aDLL} NAME)
|
||||
list(APPEND RI_ODB_DLLS ${filenameWithExt} )
|
||||
endforeach(aDLL)
|
||||
|
||||
# Copy to target directory
|
||||
foreach (aDLL ${RI_ODB_DLLS})
|
||||
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${RI_ODB_API_DIR}/lib/${aDLL}" "$<TARGET_FILE_DIR:${PROJECT_NAME}>")
|
||||
endforeach()
|
||||
|
||||
endif(MSVC)
|
@ -42,5 +42,6 @@ public:
|
||||
|
||||
virtual std::vector<double> timeSteps() = 0;
|
||||
|
||||
|
||||
private:
|
||||
};
|
||||
|
@ -65,6 +65,7 @@ void readOdbFile(const std::string& fileName, RigGeoMechCaseData* geoMechCase)
|
||||
odb_InstanceRepository instanceRepository = odb.rootAssembly().instances();
|
||||
|
||||
odb_InstanceRepositoryIT iter(instanceRepository);
|
||||
|
||||
for (iter.first(); !iter.isDone(); iter.next())
|
||||
{
|
||||
odb_Instance& inst = instanceRepository[iter.currentKey()];
|
||||
@ -102,6 +103,7 @@ void readOdbFile(const std::string& fileName, RigGeoMechCaseData* geoMechCase)
|
||||
femPart->appendElement(elmType, odbElm.label(), odbElm.connectivity(nodeCount));
|
||||
}
|
||||
|
||||
femPart->setElementPartId(geoMechCase->partCount());
|
||||
geoMechCase->addFemPart(femPart);
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ cmake_minimum_required (VERSION 2.8)
|
||||
|
||||
project ( OdbReader_UnitTests )
|
||||
|
||||
set(RI_ODB_API_DIR C:/pfRoot/jjsOnJacobpcCsdep/User/Sigurd/OdbApiExperiments/OdbApi/x64 CACHE PATH "Path tho the ODB api from Simulia")
|
||||
set(RI_VIZ_FWK_ROOT ../../../Fwk/main/VizFwk CACHE PATH "Path to VizFwk")
|
||||
set(RI_GTEST_ROOT ../../../ThirdParty CACHE PATH "Path to forlder containing gtest folder")
|
||||
|
||||
@ -12,7 +11,7 @@ add_subdirectory(${RI_VIZ_FWK_ROOT}/LibCore buildVizFwk)
|
||||
add_subdirectory(../GeoMechDataModel buildGeoMechDataModel)
|
||||
add_subdirectory(../OdbReader buildOdbReader)
|
||||
|
||||
include_directories(${RI_ODB_API_DIR}/include)
|
||||
|
||||
include_directories(${RI_VIZ_FWK_ROOT}/LibCore)
|
||||
include_directories(../GeoMechDataModel)
|
||||
include_directories(../OdbReader)
|
||||
@ -24,50 +23,7 @@ set( UNIT_TEST_CPP_SOURCES
|
||||
${RI_GTEST_ROOT}/gtest/gtest-all.cc
|
||||
)
|
||||
|
||||
|
||||
set( LINK_LIBRARIES
|
||||
LibCore
|
||||
RigGeoMechDataModel
|
||||
RifOdbReader
|
||||
)
|
||||
|
||||
list(APPEND RI_ODB_LIBS
|
||||
${RI_ODB_API_DIR}/lib/ABQSMAOdbDdbOdb.lib
|
||||
${RI_ODB_API_DIR}/lib/ABQSMAOdbApi.lib
|
||||
${RI_ODB_API_DIR}/lib/ABQSMAOdbCore.lib
|
||||
${RI_ODB_API_DIR}/lib/ABQSMAOdbCoreGeom.lib
|
||||
${RI_ODB_API_DIR}/lib/ABQSMAOdbAttrEO.lib
|
||||
${RI_ODB_API_DIR}/lib/ABQSMAAbuBasicUtils.lib
|
||||
${RI_ODB_API_DIR}/lib/ABQSMABasShared.lib
|
||||
${RI_ODB_API_DIR}/lib/ABQSMABasCoreUtils.lib
|
||||
${RI_ODB_API_DIR}/lib/ABQSMAStiCAE_StableTime.lib
|
||||
${RI_ODB_API_DIR}/lib/ABQSMABasMem.lib
|
||||
${RI_ODB_API_DIR}/lib/ABQSMAAbuGeom.lib
|
||||
${RI_ODB_API_DIR}/lib/ABQSMARomDiagEx.lib
|
||||
${RI_ODB_API_DIR}/lib/ABQSMASspUmaCore.lib
|
||||
${RI_ODB_API_DIR}/lib/ABQSMASimInterface.lib
|
||||
${RI_ODB_API_DIR}/lib/ABQSMAMtxCoreModule.lib
|
||||
)
|
||||
|
||||
set( EXTERNAL_LINK_LIBRARIES ${RI_ODB_LIBS})
|
||||
|
||||
add_executable( ${PROJECT_NAME} ${UNIT_TEST_CPP_SOURCES} )
|
||||
target_link_libraries( ${PROJECT_NAME} ${LINK_LIBRARIES} ${EXTERNAL_LINK_LIBRARIES})
|
||||
target_link_libraries( ${PROJECT_NAME} RifOdbReader)
|
||||
|
||||
# Copy Dlls
|
||||
if (MSVC)
|
||||
file (GLOB ABA_DLLS_FULL ${RI_ODB_API_DIR}/lib/*.dll)
|
||||
|
||||
foreach (aDLL ${ABA_DLLS_FULL})
|
||||
get_filename_component(filenameWithExt ${aDLL} NAME)
|
||||
list(APPEND ABA_DLLS ${filenameWithExt} )
|
||||
endforeach(aDLL)
|
||||
|
||||
|
||||
|
||||
foreach (aDLL ${ABA_DLLS})
|
||||
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${RI_ODB_API_DIR}/lib/${aDLL}" "$<TARGET_FILE_DIR:${PROJECT_NAME}>")
|
||||
endforeach()
|
||||
|
||||
endif(MSVC)
|
||||
include(../OdbReader/OdbSetup.cmake)
|
@ -31,7 +31,7 @@ TEST(OdbReaderTest, BasicTests)
|
||||
reader->open("C:\\pfRoot\\jjsOnJacobpcCsdep\\User\\Sigurd\\OdbApiExperiments\\viewer_tutorial.odb", femData.p());
|
||||
|
||||
EXPECT_EQ(1, femData->partCount());
|
||||
EXPECT_EQ(140, femData->part(0)->elementCount());
|
||||
EXPECT_EQ(149, femData->part(0)->elementCount());
|
||||
EXPECT_EQ(CAX4, femData->part(0)->elementType(0));
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user