IJK-Slice context menu commands for GeoMech

#306
Added picking source data to the viz model
Generalized the picking methods in RiuViewer, but there is more serious
refactoring needed.
This commit is contained in:
Jacob Støren
2015-06-05 15:17:02 +02:00
parent ba633bd847
commit 0130a01ca2
9 changed files with 265 additions and 110 deletions

View File

@@ -8,12 +8,15 @@ set (SOURCE_GROUP_HEADER_FILES
${CEE_CURRENT_LIST_DIR}RivFemPartGeometryGenerator.h
${CEE_CURRENT_LIST_DIR}RivFemPartPartMgr.h
${CEE_CURRENT_LIST_DIR}RivGeoMechPartMgr.h
${CEE_CURRENT_LIST_DIR}RivFemPickSourceInfo.h
)
set (SOURCE_GROUP_SOURCE_FILES
${CEE_CURRENT_LIST_DIR}RivFemPartGeometryGenerator.cpp
${CEE_CURRENT_LIST_DIR}RivFemPartPartMgr.cpp
${CEE_CURRENT_LIST_DIR}RivGeoMechPartMgr.cpp
${CEE_CURRENT_LIST_DIR}RivFemPickSourceInfo.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@@ -30,7 +30,7 @@ RivFemPartGeometryGenerator::RivFemPartGeometryGenerator(const RigFemPart* part)
: m_part(part)
{
CVF_ASSERT(part);
m_triangleMapper = new RivFemPartTriangleToElmMapper;
}
@@ -153,16 +153,21 @@ ref<UIntArray> RivFemPartGeometryGenerator::lineIndicesFromQuadVertexArray(const
void RivFemPartGeometryGenerator::computeArrays()
{
std::vector<Vec3f> vertices;
std::vector<int>& trianglesToElements = m_triangleMapper->triangleToElmIndexMap();
std::vector<char>& trianglesToElementFaces = m_triangleMapper->triangleToElmFaceMap();
m_quadVerticesToNodeIdx.clear();
m_quadVerticesToGlobalElmNodeIdx.clear();
trianglesToElements.clear();
trianglesToElementFaces.clear();
size_t estimatedQuadVxCount = m_part->elementCount()*6*4;
vertices.reserve(estimatedQuadVxCount);
m_quadVerticesToNodeIdx.reserve(estimatedQuadVxCount);
m_quadVerticesToGlobalElmNodeIdx.reserve(estimatedQuadVxCount);
trianglesToElements.reserve(estimatedQuadVxCount/2);
trianglesToElementFaces.reserve(estimatedQuadVxCount/2);
cvf::Vec3d offset = Vec3d::ZERO; //m_part->displayModelOffset();
const std::vector<cvf::Vec3f>& nodeCoordinates = m_part->nodes().coordinates;
@@ -229,6 +234,11 @@ void RivFemPartGeometryGenerator::computeArrays()
m_quadVerticesToGlobalElmNodeIdx.push_back(qElmNodeResIdx[1]);
m_quadVerticesToGlobalElmNodeIdx.push_back(qElmNodeResIdx[2]);
m_quadVerticesToGlobalElmNodeIdx.push_back(qElmNodeResIdx[3]);
trianglesToElements.push_back(elmIdx);
trianglesToElements.push_back(elmIdx);
trianglesToElementFaces.push_back(lfIdx);
trianglesToElementFaces.push_back(lfIdx);
}
}
else

View File

@@ -5,6 +5,7 @@
#include "cvfArray.h"
#include "RigFemPart.h"
#include "cvfStructGrid.h"
namespace cvf
{
@@ -16,7 +17,22 @@ class ScalarMapper;
class RigFemPartScalarDataAccess;
class RivFemPartTriangleToElmMapper : public cvf::Object
{
public:
size_t triangleCount() const { return m_trianglesToElementIndex.size();}
int elementIndex(size_t triangleIdx) const { return m_trianglesToElementIndex[triangleIdx]; }
char elementFace(size_t triangleIdx) const { return m_trianglesToElmFace[triangleIdx]; }
// Interface for building the mappings
std::vector<int>& triangleToElmIndexMap() { return m_trianglesToElementIndex; }
std::vector<char>& triangleToElmFaceMap() { return m_trianglesToElmFace; }
private:
std::vector<int> m_trianglesToElementIndex;
std::vector<char> m_trianglesToElmFace;
};
//==================================================================================================
//
@@ -38,13 +54,16 @@ public:
const RigFemPart* activePart() { return m_part.p(); }
// Generated geometry
cvf::ref<cvf::DrawableGeo> generateSurface();
cvf::ref<cvf::DrawableGeo> createMeshDrawable();
cvf::ref<cvf::DrawableGeo> createOutlineMeshDrawable(double creaseAngle);
const std::vector<size_t>& quadVerticesToNodeIdxMapping() const { return m_quadVerticesToNodeIdx;}
const std::vector<size_t>& quadVerticesToNodeIdxMapping() const { return m_quadVerticesToNodeIdx;}
const std::vector<size_t>& quadVerticesToGlobalElmNodeIdx() const { return m_quadVerticesToGlobalElmNodeIdx;}
RivFemPartTriangleToElmMapper* triangleToElementMapper() { return m_triangleMapper.p();}
private:
static cvf::ref<cvf::UIntArray>
lineIndicesFromQuadVertexArray(const cvf::Vec3fArray* vertexArray);
@@ -53,13 +72,16 @@ private:
private:
// Input
cvf::cref<RigFemPart> m_part; // The part being processed
cvf::cref<cvf::UByteArray> m_elmVisibility;
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
std::vector<size_t> m_quadVerticesToNodeIdx;
std::vector<size_t> m_quadVerticesToGlobalElmNodeIdx;
//cvf::ref<cvf::Vec3fArray> m_triangleVertices; // If needed, we will do it like this, I think
std::vector<size_t> m_quadVerticesToNodeIdx;
std::vector<size_t> m_quadVerticesToGlobalElmNodeIdx;
// Mappings
cvf::ref<RivFemPartTriangleToElmMapper> m_triangleMapper;
};

View File

@@ -51,6 +51,7 @@
#include "RigGeoMechCaseData.h"
#include "RigFemScalarResultFrames.h"
#include "RigFemPartResultsCollection.h"
#include "RivFemPickSourceInfo.h"
//--------------------------------------------------------------------------------------------------
@@ -110,15 +111,13 @@ void RivFemPartPartMgr::generatePartGeometry(RivFemPartGeometryGenerator& geoBui
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->setId(m_gridIdx); // Use grid index as part ID
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());
// Set mapping from triangle face index to element index
cvf::ref<RivFemPickSourceInfo> si = new RivFemPickSourceInfo(m_gridIdx, geoBuilder.triangleToElementMapper());
part->setSourceInfo(si.p());
part->updateBoundingBox();

View File

@@ -49,33 +49,33 @@ class RivFemPartPartMgr: public cvf::Object
public:
RivFemPartPartMgr(const RigFemPart* femPart);
~RivFemPartPartMgr();
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);
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:
void generatePartGeometry(RivFemPartGeometryGenerator& geoBuilder);
int m_gridIdx;
cvf::cref<RigFemPart> m_grid;
private:
int m_gridIdx;
cvf::cref<RigFemPart> m_grid;
cvf::ref<cvf::Transform> m_scaleTransform;
float m_opacityLevel;
cvf::Color3f m_defaultColor;
cvf::ref<cvf::Transform> m_scaleTransform;
float m_opacityLevel;
cvf::Color3f m_defaultColor;
// Surface visualization
RivFemPartGeometryGenerator m_surfaceGenerator;
RivFemPartGeometryGenerator m_surfaceGenerator;
cvf::ref<cvf::Part> m_surfaceFaces;
cvf::ref<cvf::Vec2fArray> m_surfaceFacesTextureCoords;
cvf::ref<cvf::Part> m_surfaceFaces;
cvf::ref<cvf::Vec2fArray> m_surfaceFacesTextureCoords;
cvf::ref<cvf::Part> m_surfaceGridLines;
cvf::ref<cvf::Part> m_surfaceGridLines;
cvf::ref<cvf::UByteArray> m_cellVisibility;
cvf::ref<cvf::UByteArray> m_cellVisibility;
};

View File

@@ -0,0 +1,41 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RivFemPickSourceInfo.h"
#include "RivFemPartGeometryGenerator.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivFemPickSourceInfo::RivFemPickSourceInfo(int partIndex, RivFemPartTriangleToElmMapper * triangleToElmMapper)
: m_fempartIndex(partIndex),
m_triangleToElmMapper(triangleToElmMapper)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivFemPickSourceInfo::~RivFemPickSourceInfo()
{
}

View File

@@ -0,0 +1,41 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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"
class RivFemPartTriangleToElmMapper;
class RivFemPickSourceInfo : public cvf::Object
{
public:
RivFemPickSourceInfo(int partIndex, RivFemPartTriangleToElmMapper * triangleToElmMapper);
~RivFemPickSourceInfo();
int femPartIndex() const { return m_fempartIndex; }
const RivFemPartTriangleToElmMapper* triangleToElmMapper() const { return m_triangleToElmMapper.p(); }
private:
int m_fempartIndex;
cvf::cref<RivFemPartTriangleToElmMapper> m_triangleToElmMapper;
};