mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merged intersection-box into dev
This commit is contained in:
@@ -9,8 +9,6 @@ ${CEE_CURRENT_LIST_DIR}RivCellEdgeEffectGenerator.h
|
||||
${CEE_CURRENT_LIST_DIR}RivColorTableArray.h
|
||||
${CEE_CURRENT_LIST_DIR}RivFaultPartMgr.h
|
||||
${CEE_CURRENT_LIST_DIR}RivFaultGeometryGenerator.h
|
||||
${CEE_CURRENT_LIST_DIR}RivCrossSectionGeometryGenerator.h
|
||||
${CEE_CURRENT_LIST_DIR}RivCrossSectionPartMgr.h
|
||||
${CEE_CURRENT_LIST_DIR}RivNNCGeometryGenerator.h
|
||||
${CEE_CURRENT_LIST_DIR}RivGridPartMgr.h
|
||||
${CEE_CURRENT_LIST_DIR}RivTernarySaturationOverlayItem.h
|
||||
@@ -36,7 +34,6 @@ ${CEE_CURRENT_LIST_DIR}RivCellEdgeGeometryUtils.h
|
||||
${CEE_CURRENT_LIST_DIR}RivPipeQuadToSegmentMapper.h
|
||||
${CEE_CURRENT_LIST_DIR}RivSingleCellPartGenerator.h
|
||||
${CEE_CURRENT_LIST_DIR}RivWellPipeSourceInfo.h
|
||||
${CEE_CURRENT_LIST_DIR}RivCrossSectionSourceInfo.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@@ -44,8 +41,6 @@ ${CEE_CURRENT_LIST_DIR}RivCellEdgeEffectGenerator.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivColorTableArray.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivFaultPartMgr.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivNNCGeometryGenerator.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivCrossSectionGeometryGenerator.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivCrossSectionPartMgr.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivFaultGeometryGenerator.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivGridPartMgr.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivTernarySaturationOverlayItem.cpp
|
||||
@@ -69,7 +64,6 @@ ${CEE_CURRENT_LIST_DIR}RivCellEdgeGeometryUtils.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivPipeQuadToSegmentMapper.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivSingleCellPartGenerator.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivWellPipeSourceInfo.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivCrossSectionSourceInfo.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
|
||||
# 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}RivIntersectionGeometryGenerator.h
|
||||
${CEE_CURRENT_LIST_DIR}RivIntersectionPartMgr.h
|
||||
${CEE_CURRENT_LIST_DIR}RivIntersectionSourceInfo.h
|
||||
${CEE_CURRENT_LIST_DIR}RivHexGridIntersectionTools.h
|
||||
${CEE_CURRENT_LIST_DIR}RivIntersectionBoxGeometryGenerator.h
|
||||
${CEE_CURRENT_LIST_DIR}RivIntersectionBoxPartMgr.h
|
||||
${CEE_CURRENT_LIST_DIR}RivIntersectionBoxSourceInfo.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RivIntersectionGeometryGenerator.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivIntersectionPartMgr.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivIntersectionSourceInfo.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivHexGridIntersectionTools.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivIntersectionBoxGeometryGenerator.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivIntersectionBoxPartMgr.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivIntersectionBoxSourceInfo.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
${SOURCE_GROUP_HEADER_FILES}
|
||||
)
|
||||
|
||||
list(APPEND CODE_SOURCE_FILES
|
||||
${SOURCE_GROUP_SOURCE_FILES}
|
||||
)
|
||||
|
||||
source_group( "ModelVisualization\\Intersections" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake )
|
||||
@@ -0,0 +1,174 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) Statoil ASA
|
||||
//
|
||||
// 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 "RivHexGridIntersectionTools.h"
|
||||
|
||||
#include "RigActiveCellInfo.h"
|
||||
#include "RigFemPart.h"
|
||||
#include "RigMainGrid.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivEclipseIntersectionGrid::RivEclipseIntersectionGrid(const RigMainGrid * mainGrid,
|
||||
const RigActiveCellInfo* activeCellInfo,
|
||||
bool showInactiveCells)
|
||||
: m_mainGrid(mainGrid),
|
||||
m_activeCellInfo(activeCellInfo),
|
||||
m_showInactiveCells(showInactiveCells)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Vec3d RivEclipseIntersectionGrid::displayOffset() const
|
||||
{
|
||||
return m_mainGrid->displayModelOffset();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::BoundingBox RivEclipseIntersectionGrid::boundingBox() const
|
||||
{
|
||||
return m_mainGrid->boundingBox();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivEclipseIntersectionGrid::findIntersectingCells(const cvf::BoundingBox& intersectingBB, std::vector<size_t>* intersectedCells) const
|
||||
{
|
||||
m_mainGrid->findIntersectingCells(intersectingBB, intersectedCells);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RivEclipseIntersectionGrid::useCell(size_t cellIndex) const
|
||||
{
|
||||
const RigCell& cell = m_mainGrid->globalCellArray()[cellIndex];
|
||||
if (m_showInactiveCells)
|
||||
return !(cell.isInvalid() || (cell.subGrid() != NULL));
|
||||
else
|
||||
return m_activeCellInfo->isActive(cellIndex) && (cell.subGrid() == NULL);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivEclipseIntersectionGrid::cellCornerVertices(size_t cellIndex, cvf::Vec3d cellCorners[8]) const
|
||||
{
|
||||
m_mainGrid->cellCornerVertices(cellIndex, cellCorners);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivEclipseIntersectionGrid::cellCornerIndices(size_t cellIndex, size_t cornerIndices[8]) const
|
||||
{
|
||||
const caf::SizeTArray8& cornerIndicesSource = m_mainGrid->globalCellArray()[cellIndex].cornerIndices();
|
||||
memcpy(cornerIndices, cornerIndicesSource.data(), 8);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivFemIntersectionGrid::RivFemIntersectionGrid(const RigFemPart * femPart) : m_femPart(femPart)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Vec3d RivFemIntersectionGrid::displayOffset() const
|
||||
{
|
||||
return cvf::Vec3d::ZERO;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::BoundingBox RivFemIntersectionGrid::boundingBox() const
|
||||
{
|
||||
return m_femPart->boundingBox();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFemIntersectionGrid::findIntersectingCells(const cvf::BoundingBox& intersectingBB, std::vector<size_t>* intersectedCells) const
|
||||
{
|
||||
m_femPart->findIntersectingCells(intersectingBB, intersectedCells);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RivFemIntersectionGrid::useCell(size_t cellIndex) const
|
||||
{
|
||||
RigElementType elmType = m_femPart->elementType(cellIndex);
|
||||
|
||||
if (!(elmType == HEX8 || elmType == HEX8P)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFemIntersectionGrid::cellCornerVertices(size_t cellIndex, cvf::Vec3d cellCorners[8]) const
|
||||
{
|
||||
RigElementType elmType = m_femPart->elementType(cellIndex);
|
||||
if (!(elmType == HEX8 || elmType == HEX8P)) return;
|
||||
|
||||
const std::vector<cvf::Vec3f>& nodeCoords = m_femPart->nodes().coordinates;
|
||||
const int* cornerIndices = m_femPart->connectivities(cellIndex);
|
||||
|
||||
cellCorners[0] = cvf::Vec3d(nodeCoords[cornerIndices[0]]);
|
||||
cellCorners[1] = cvf::Vec3d(nodeCoords[cornerIndices[1]]);
|
||||
cellCorners[2] = cvf::Vec3d(nodeCoords[cornerIndices[2]]);
|
||||
cellCorners[3] = cvf::Vec3d(nodeCoords[cornerIndices[3]]);
|
||||
cellCorners[4] = cvf::Vec3d(nodeCoords[cornerIndices[4]]);
|
||||
cellCorners[5] = cvf::Vec3d(nodeCoords[cornerIndices[5]]);
|
||||
cellCorners[6] = cvf::Vec3d(nodeCoords[cornerIndices[6]]);
|
||||
cellCorners[7] = cvf::Vec3d(nodeCoords[cornerIndices[7]]);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFemIntersectionGrid::cellCornerIndices(size_t cellIndex, size_t cornerIndices[8]) const
|
||||
{
|
||||
RigElementType elmType = m_femPart->elementType(cellIndex);
|
||||
if (!(elmType == HEX8 || elmType == HEX8P)) return;
|
||||
int elmIdx = static_cast<int>(cellIndex);
|
||||
cornerIndices[0] = m_femPart->elementNodeResultIdx(elmIdx, 0);
|
||||
cornerIndices[1] = m_femPart->elementNodeResultIdx(elmIdx, 1);
|
||||
cornerIndices[2] = m_femPart->elementNodeResultIdx(elmIdx, 2);
|
||||
cornerIndices[3] = m_femPart->elementNodeResultIdx(elmIdx, 3);
|
||||
cornerIndices[4] = m_femPart->elementNodeResultIdx(elmIdx, 4);
|
||||
cornerIndices[5] = m_femPart->elementNodeResultIdx(elmIdx, 5);
|
||||
cornerIndices[6] = m_femPart->elementNodeResultIdx(elmIdx, 6);
|
||||
cornerIndices[7] = m_femPart->elementNodeResultIdx(elmIdx, 7);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) Statoil ASA
|
||||
//
|
||||
// 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 "cvfObject.h"
|
||||
#include "cvfVector3.h"
|
||||
#include "cvfBoundingBox.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RigActiveCellInfo;
|
||||
class RigFemPart;
|
||||
class RigMainGrid;
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Interface definition used to compute the geometry for planes intersecting a grid
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RivIntersectionHexGridInterface : public cvf::Object
|
||||
{
|
||||
public:
|
||||
virtual cvf::Vec3d displayOffset() const = 0;
|
||||
virtual cvf::BoundingBox boundingBox() const = 0;
|
||||
virtual void findIntersectingCells(const cvf::BoundingBox& intersectingBB, std::vector<size_t>* intersectedCells) const = 0;
|
||||
virtual bool useCell(size_t cellIndex) const = 0;
|
||||
virtual void cellCornerVertices(size_t cellIndex, cvf::Vec3d cellCorners[8]) const = 0;
|
||||
virtual void cellCornerIndices(size_t cellIndex, size_t cornerIndices[8]) const = 0;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RivEclipseIntersectionGrid : public RivIntersectionHexGridInterface
|
||||
{
|
||||
public:
|
||||
RivEclipseIntersectionGrid(const RigMainGrid * mainGrid, const RigActiveCellInfo* activeCellInfo, bool showInactiveCells);
|
||||
|
||||
virtual cvf::Vec3d displayOffset() const;
|
||||
virtual cvf::BoundingBox boundingBox() const;
|
||||
virtual void findIntersectingCells(const cvf::BoundingBox& intersectingBB, std::vector<size_t>* intersectedCells) const;
|
||||
virtual bool useCell(size_t cellIndex) const;
|
||||
virtual void cellCornerVertices(size_t cellIndex, cvf::Vec3d cellCorners[8]) const;
|
||||
virtual void cellCornerIndices(size_t cellIndex, size_t cornerIndices[8]) const;
|
||||
|
||||
private:
|
||||
cvf::cref<RigMainGrid> m_mainGrid;
|
||||
cvf::cref<RigActiveCellInfo> m_activeCellInfo;
|
||||
bool m_showInactiveCells;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RivFemIntersectionGrid : public RivIntersectionHexGridInterface
|
||||
{
|
||||
public:
|
||||
RivFemIntersectionGrid(const RigFemPart * femPart);
|
||||
|
||||
virtual cvf::Vec3d displayOffset() const;
|
||||
virtual cvf::BoundingBox boundingBox() const;
|
||||
virtual void findIntersectingCells(const cvf::BoundingBox& intersectingBB, std::vector<size_t>* intersectedCells) const;
|
||||
virtual bool useCell(size_t cellIndex) const;
|
||||
virtual void cellCornerVertices(size_t cellIndex, cvf::Vec3d cellCorners[8]) const;
|
||||
virtual void cellCornerIndices(size_t cellIndex, size_t cornerIndices[8]) const;
|
||||
|
||||
private:
|
||||
cvf::cref<RigFemPart> m_femPart;
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RivIntersectionVertexWeights
|
||||
{
|
||||
public:
|
||||
explicit RivIntersectionVertexWeights(): m_count(0) {}
|
||||
|
||||
/*
|
||||
v111 k11 v11 v112 v211 k21 v21 v212
|
||||
+------+-----+ +--------+------+
|
||||
| |
|
||||
|k1 |k2
|
||||
| k |
|
||||
v1+--------+------------+v2
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
+------+----+ +--------+-------+
|
||||
v121 k12 v12 v122 v221 k22 v22 v222
|
||||
|
||||
Where the k's are normalized distances along the edge, from the edge start vertex .
|
||||
|
||||
This is the interpolation sceme:
|
||||
|
||||
v = (1 - k )* v1 + k *v2;
|
||||
|
||||
v1 = (1 - k1 )* v11 + k1*v12;
|
||||
v2 = (1 - k2 )* v21 + k2*v22;
|
||||
|
||||
v11 = (1 - k11)* v111 + k11*v112;
|
||||
v12 = (1 - k12)* v121 + k12*v122;
|
||||
v21 = (1 - k21)* v211 + k21*v212;
|
||||
v22 = (1 - k22)* v221 + k22*v222;
|
||||
|
||||
Substitution and reorganizing gives the expressions seen below.
|
||||
|
||||
*/
|
||||
|
||||
explicit RivIntersectionVertexWeights( size_t edgeVx111, size_t edgeVx112, double k11,
|
||||
size_t edgeVx121, size_t edgeVx122, double k12,
|
||||
size_t edgeVx211, size_t edgeVx212, double k21,
|
||||
size_t edgeVx221, size_t edgeVx222, double k22,
|
||||
double k1,
|
||||
double k2,
|
||||
double k) : m_count(8)
|
||||
{
|
||||
m_vxIds[0] = (edgeVx111);
|
||||
m_vxIds[1] = (edgeVx112);
|
||||
m_vxIds[2] = (edgeVx121);
|
||||
m_vxIds[3] = (edgeVx122);
|
||||
m_vxIds[4] = (edgeVx211);
|
||||
m_vxIds[5] = (edgeVx212);
|
||||
m_vxIds[6] = (edgeVx221);
|
||||
m_vxIds[7] = (edgeVx222);
|
||||
|
||||
m_weights[7] = ((float)(k * k2 * k22));
|
||||
m_weights[6] = ((float)(k * k2 - k * k2 * k22));
|
||||
m_weights[5] = ((float)(( k - k * k2 ) * k21));
|
||||
m_weights[4] = ((float)((k * k2 - k ) * k21 - k * k2 + k));
|
||||
m_weights[3] = ((float)((1-k) * k1 * k12));
|
||||
m_weights[2] = ((float)((k-1) * k1 * k12 + ( 1 - k ) * k1));
|
||||
m_weights[1] = ((float)(( (k-1) * k1 - k + 1 ) * k11));
|
||||
m_weights[0] = ((float)(( (1-k) * k1 + k - 1 ) * k11 + ( k - 1 ) * k1 - k + 1));
|
||||
}
|
||||
|
||||
explicit RivIntersectionVertexWeights(size_t edge1Vx1, size_t edge1Vx2, double normDistFromE1V1,
|
||||
size_t edge2Vx1, size_t edge2Vx2, double normDistFromE2V1,
|
||||
double normDistFromE1Cut) : m_count(4)
|
||||
{
|
||||
m_vxIds[0] = (edge1Vx1);
|
||||
m_vxIds[1] = (edge1Vx2);
|
||||
m_vxIds[2] = (edge2Vx1);
|
||||
m_vxIds[3] = (edge2Vx2);
|
||||
|
||||
m_weights[0] = ((float)(1.0 - normDistFromE1V1 - normDistFromE1Cut + normDistFromE1V1*normDistFromE1Cut));
|
||||
m_weights[1] = ((float)(normDistFromE1V1 - normDistFromE1V1*normDistFromE1Cut));
|
||||
m_weights[2] = ((float)(normDistFromE1Cut - normDistFromE2V1*normDistFromE1Cut));
|
||||
m_weights[3] = ((float)(normDistFromE2V1*normDistFromE1Cut));
|
||||
}
|
||||
|
||||
explicit RivIntersectionVertexWeights(size_t edge1Vx1, size_t edge1Vx2, double normDistFromE1V1) : m_count(2)
|
||||
{
|
||||
m_vxIds[0] = (edge1Vx1);
|
||||
m_vxIds[1] = (edge1Vx2);
|
||||
|
||||
m_weights[0] = ((float)(1.0 - normDistFromE1V1));
|
||||
m_weights[1] = ((float)(normDistFromE1V1));
|
||||
}
|
||||
|
||||
int size() const { return m_count; }
|
||||
size_t vxId(int idx) const { return m_vxIds[idx]; }
|
||||
float weight(int idx)const { return m_weights[idx]; }
|
||||
|
||||
private:
|
||||
|
||||
size_t m_vxIds[8];
|
||||
float m_weights[8];
|
||||
int m_count;
|
||||
};
|
||||
@@ -0,0 +1,454 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) Statoil ASA
|
||||
//
|
||||
// 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 "RivIntersectionBoxGeometryGenerator.h"
|
||||
|
||||
#include "cvfDrawableGeo.h"
|
||||
#include "cvfPrimitiveSetDirect.h"
|
||||
#include "cvfPlane.h"
|
||||
#include <array>
|
||||
#include "RimIntersectionBox.h"
|
||||
#include "cvfStructGrid.h"
|
||||
#include "cafHexGridIntersectionTools/cafHexGridIntersectionTools.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivIntersectionBoxGeometryGenerator::RivIntersectionBoxGeometryGenerator(const RimIntersectionBox* intersectionBox, const RivIntersectionHexGridInterface* grid)
|
||||
: m_intersectionBoxDefinition(intersectionBox),
|
||||
m_hexGrid(grid)
|
||||
{
|
||||
m_triangleVxes = new cvf::Vec3fArray;
|
||||
m_cellBorderLineVxes = new cvf::Vec3fArray;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivIntersectionBoxGeometryGenerator::~RivIntersectionBoxGeometryGenerator()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RivIntersectionBoxGeometryGenerator::isAnyGeometryPresent() const
|
||||
{
|
||||
if (m_triangleVxes->size() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo> RivIntersectionBoxGeometryGenerator::generateSurface()
|
||||
{
|
||||
calculateArrays();
|
||||
|
||||
CVF_ASSERT(m_triangleVxes.notNull());
|
||||
|
||||
if (m_triangleVxes->size() == 0) return NULL;
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
|
||||
geo->setFromTriangleVertexArray(m_triangleVxes.p());
|
||||
|
||||
return geo;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo> RivIntersectionBoxGeometryGenerator::createMeshDrawable()
|
||||
{
|
||||
if (!(m_cellBorderLineVxes.notNull() && m_cellBorderLineVxes->size() != 0)) return NULL;
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
|
||||
geo->setVertexArray(m_cellBorderLineVxes.p());
|
||||
|
||||
|
||||
cvf::ref<cvf::PrimitiveSetDirect> prim = new cvf::PrimitiveSetDirect(cvf::PT_LINES);
|
||||
prim->setIndexCount(m_cellBorderLineVxes->size());
|
||||
|
||||
geo->addPrimitiveSet(prim.p());
|
||||
return geo;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<size_t>& RivIntersectionBoxGeometryGenerator::triangleToCellIndex() const
|
||||
{
|
||||
CVF_ASSERT(m_triangleVxes->size());
|
||||
return m_triangleToCellIdxMap;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<RivIntersectionVertexWeights>& RivIntersectionBoxGeometryGenerator::triangleVxToCellCornerInterpolationWeights() const
|
||||
{
|
||||
CVF_ASSERT(m_triangleVxes->size());
|
||||
return m_triVxToCellCornerWeights;
|
||||
}
|
||||
|
||||
|
||||
class Box
|
||||
{
|
||||
public:
|
||||
using FaceType = cvf::StructGridInterface::FaceType;
|
||||
|
||||
Box(const cvf::Mat4d& origin, const cvf::Vec3d& size) : m_origin(origin), m_size(size) {}
|
||||
|
||||
std::array<cvf::Plane, 6> planes()
|
||||
{
|
||||
std::array<cvf::Plane, 6> boxPlanes;
|
||||
|
||||
boxPlanes[FaceType::POS_I].setFromPointAndNormal( m_origin.translation() + m_size, cvf::Vec3d(m_origin.col(0)));
|
||||
boxPlanes[FaceType::NEG_I].setFromPointAndNormal( m_origin.translation() , -cvf::Vec3d(m_origin.col(0)));
|
||||
boxPlanes[FaceType::POS_J].setFromPointAndNormal( m_origin.translation() + m_size, cvf::Vec3d(m_origin.col(1)));
|
||||
boxPlanes[FaceType::NEG_J].setFromPointAndNormal( m_origin.translation() , -cvf::Vec3d(m_origin.col(1)));
|
||||
boxPlanes[FaceType::POS_K].setFromPointAndNormal( m_origin.translation() + m_size, cvf::Vec3d(m_origin.col(2)));
|
||||
boxPlanes[FaceType::NEG_K].setFromPointAndNormal( m_origin.translation() , -cvf::Vec3d(m_origin.col(2)));
|
||||
|
||||
return boxPlanes;
|
||||
}
|
||||
|
||||
std::array<cvf::Vec3d, 4> faceCorners(FaceType face)
|
||||
{
|
||||
std::array<cvf::Vec3d, 4> corners;
|
||||
|
||||
cvf::Vec3d sx = cvf::Vec3d(m_origin.col(0)) * m_size[0] ;
|
||||
cvf::Vec3d sy = cvf::Vec3d(m_origin.col(1)) * m_size[1] ;
|
||||
cvf::Vec3d sz = cvf::Vec3d(m_origin.col(2)) * m_size[2] ;
|
||||
|
||||
switch(face)
|
||||
{
|
||||
case FaceType::POS_I:
|
||||
corners[0] = m_origin.translation() + sx;
|
||||
corners[1] = m_origin.translation() + sx + sy;
|
||||
corners[2] = m_origin.translation() + sx + sy + sz;
|
||||
corners[3] = m_origin.translation() + sx + sz;
|
||||
break;
|
||||
case FaceType::NEG_I:
|
||||
corners[0] = m_origin.translation();
|
||||
corners[1] = m_origin.translation() + sz;
|
||||
corners[2] = m_origin.translation() + sy + sz;
|
||||
corners[3] = m_origin.translation() + sy;
|
||||
break;
|
||||
case FaceType::POS_J:
|
||||
corners[0] = m_origin.translation() + sy;
|
||||
corners[1] = m_origin.translation() + sy + sz;
|
||||
corners[2] = m_origin.translation() + sy + sx + sz;
|
||||
corners[3] = m_origin.translation() + sy + sx;
|
||||
break;
|
||||
case FaceType::NEG_J:
|
||||
corners[0] = m_origin.translation() ;
|
||||
corners[1] = m_origin.translation() + sx;
|
||||
corners[2] = m_origin.translation() + sx + sz;
|
||||
corners[3] = m_origin.translation() + sz;
|
||||
break;
|
||||
case FaceType::POS_K:
|
||||
corners[0] = m_origin.translation() + sz;
|
||||
corners[1] = m_origin.translation() + sz + sx;
|
||||
corners[2] = m_origin.translation() + sz + sx + sy;
|
||||
corners[3] = m_origin.translation() + sz + sy;
|
||||
break;
|
||||
case FaceType::NEG_K:
|
||||
corners[0] = m_origin.translation();
|
||||
corners[1] = m_origin.translation() + sy;
|
||||
corners[2] = m_origin.translation() + sx + sy;
|
||||
corners[3] = m_origin.translation() + sx;
|
||||
break;
|
||||
}
|
||||
|
||||
return corners;
|
||||
}
|
||||
|
||||
// Returns the four adjacent faces in the Pos, Neg, Pos, Neg order
|
||||
|
||||
std::array<FaceType, 4> adjacentFaces(FaceType face)
|
||||
{
|
||||
std::array<FaceType, 4> clipFaces;
|
||||
FaceType oppFace = cvf::StructGridInterface::oppositeFace(face);
|
||||
int clipFaceCount = 0;
|
||||
for (int faceCand = 0; faceCand < 6; ++faceCand )
|
||||
{
|
||||
if (faceCand != face && faceCand != oppFace)
|
||||
{
|
||||
clipFaces[clipFaceCount] = (FaceType) faceCand;
|
||||
clipFaceCount++;
|
||||
}
|
||||
}
|
||||
|
||||
return clipFaces;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
cvf::Mat4d m_origin;
|
||||
cvf::Vec3d m_size;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const RimIntersectionBox* RivIntersectionBoxGeometryGenerator::intersectionBox() const
|
||||
{
|
||||
return m_intersectionBoxDefinition;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivIntersectionBoxGeometryGenerator::calculateArrays()
|
||||
{
|
||||
if(m_triangleVxes->size()) return;
|
||||
|
||||
std::vector<cvf::Vec3f> triangleVertices;
|
||||
std::vector<cvf::Vec3f> cellBorderLineVxes;
|
||||
cvf::Vec3d displayOffset = m_hexGrid->displayOffset();
|
||||
cvf::BoundingBox gridBBox = m_hexGrid->boundingBox();
|
||||
|
||||
Box box(m_intersectionBoxDefinition->boxOrigin(), m_intersectionBoxDefinition->boxSize());
|
||||
std::array<cvf::Plane, 6> boxPlanes = box.planes();
|
||||
|
||||
RimIntersectionBox::SinglePlaneState singlePlane = m_intersectionBoxDefinition->singlePlaneState();
|
||||
|
||||
int startFace = 0; int endFace = 5;
|
||||
if (singlePlane == RimIntersectionBox::PLANE_STATE_X) startFace = endFace = Box::FaceType::POS_I;
|
||||
if (singlePlane == RimIntersectionBox::PLANE_STATE_Y) startFace = endFace = Box::FaceType::POS_J;
|
||||
if (singlePlane == RimIntersectionBox::PLANE_STATE_Z) startFace = endFace = Box::FaceType::POS_K;
|
||||
|
||||
for (int faceIdx = startFace; faceIdx <= endFace; ++faceIdx)
|
||||
{
|
||||
cvf::Plane plane = boxPlanes[faceIdx];
|
||||
|
||||
std::array<Box::FaceType, 4> clipFaces = box.adjacentFaces((Box::FaceType)faceIdx);
|
||||
|
||||
cvf::Plane p1Plane = boxPlanes[clipFaces[1]];
|
||||
cvf::Plane p2Plane = boxPlanes[clipFaces[0]];
|
||||
cvf::Plane p3Plane = boxPlanes[clipFaces[3]];
|
||||
cvf::Plane p4Plane = boxPlanes[clipFaces[2]];
|
||||
|
||||
p1Plane.flip();
|
||||
p2Plane.flip();
|
||||
p3Plane.flip();
|
||||
p4Plane.flip();
|
||||
|
||||
std::array<cvf::Vec3d, 4> faceCorners = box.faceCorners((Box::FaceType)faceIdx);
|
||||
|
||||
cvf::BoundingBox sectionBBox;
|
||||
|
||||
for (cvf::Vec3d& corner : faceCorners) sectionBBox.add(corner);
|
||||
|
||||
// Similar code as IntersectionGenerator :
|
||||
|
||||
std::vector<size_t> columnCellCandidates;
|
||||
m_hexGrid->findIntersectingCells(sectionBBox, &columnCellCandidates);
|
||||
|
||||
std::vector<caf::HexGridIntersectionTools::ClipVx> hexPlaneCutTriangleVxes;
|
||||
hexPlaneCutTriangleVxes.reserve(5*3);
|
||||
std::vector<bool> isTriangleEdgeCellContour;
|
||||
isTriangleEdgeCellContour.reserve(5*3);
|
||||
cvf::Vec3d cellCorners[8];
|
||||
size_t cornerIndices[8];
|
||||
|
||||
for(size_t cccIdx = 0; cccIdx < columnCellCandidates.size(); ++cccIdx)
|
||||
{
|
||||
size_t globalCellIdx = columnCellCandidates[cccIdx];
|
||||
|
||||
if(!m_hexGrid->useCell(globalCellIdx)) continue;
|
||||
|
||||
hexPlaneCutTriangleVxes.clear();
|
||||
m_hexGrid->cellCornerVertices(globalCellIdx, cellCorners);
|
||||
m_hexGrid->cellCornerIndices(globalCellIdx, cornerIndices);
|
||||
|
||||
caf::HexGridIntersectionTools::planeHexIntersectionMC(plane,
|
||||
cellCorners,
|
||||
cornerIndices,
|
||||
&hexPlaneCutTriangleVxes,
|
||||
&isTriangleEdgeCellContour);
|
||||
|
||||
std::vector<caf::HexGridIntersectionTools::ClipVx> clippedTriangleVxes_once;
|
||||
std::vector<bool> isClippedTriEdgeCellContour_once;
|
||||
caf::HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(hexPlaneCutTriangleVxes, isTriangleEdgeCellContour, p1Plane, p2Plane,
|
||||
&clippedTriangleVxes_once, &isClippedTriEdgeCellContour_once);
|
||||
|
||||
for (caf::HexGridIntersectionTools::ClipVx& clvx : clippedTriangleVxes_once) if (!clvx.isVxIdsNative) clvx.derivedVxLevel = 0;
|
||||
|
||||
std::vector<caf::HexGridIntersectionTools::ClipVx> clippedTriangleVxes;
|
||||
std::vector<bool> isClippedTriEdgeCellContour;
|
||||
|
||||
caf::HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(clippedTriangleVxes_once, isClippedTriEdgeCellContour_once, p3Plane, p4Plane,
|
||||
&clippedTriangleVxes, &isClippedTriEdgeCellContour);
|
||||
for (caf::HexGridIntersectionTools::ClipVx& clvx : clippedTriangleVxes) if (!clvx.isVxIdsNative && clvx.derivedVxLevel == -1) clvx.derivedVxLevel = 1;
|
||||
|
||||
size_t clippedTriangleCount = clippedTriangleVxes.size()/3;
|
||||
|
||||
for(uint tIdx = 0; tIdx < clippedTriangleCount; ++tIdx)
|
||||
{
|
||||
uint triVxIdx = tIdx*3;
|
||||
|
||||
// Accumulate triangle vertices
|
||||
|
||||
cvf::Vec3f p0(clippedTriangleVxes[triVxIdx+0].vx - displayOffset);
|
||||
cvf::Vec3f p1(clippedTriangleVxes[triVxIdx+1].vx - displayOffset);
|
||||
cvf::Vec3f p2(clippedTriangleVxes[triVxIdx+2].vx - displayOffset);
|
||||
|
||||
triangleVertices.push_back(p0);
|
||||
triangleVertices.push_back(p1);
|
||||
triangleVertices.push_back(p2);
|
||||
|
||||
|
||||
// Accumulate mesh lines
|
||||
|
||||
if(isClippedTriEdgeCellContour[triVxIdx])
|
||||
{
|
||||
cellBorderLineVxes.push_back(p0);
|
||||
cellBorderLineVxes.push_back(p1);
|
||||
}
|
||||
if(isClippedTriEdgeCellContour[triVxIdx+1])
|
||||
{
|
||||
cellBorderLineVxes.push_back(p1);
|
||||
cellBorderLineVxes.push_back(p2);
|
||||
}
|
||||
if(isClippedTriEdgeCellContour[triVxIdx+2])
|
||||
{
|
||||
cellBorderLineVxes.push_back(p2);
|
||||
cellBorderLineVxes.push_back(p0);
|
||||
}
|
||||
|
||||
// Mapping to cell index
|
||||
|
||||
m_triangleToCellIdxMap.push_back(globalCellIdx);
|
||||
|
||||
// Interpolation from nodes
|
||||
for(int i = 0; i < 3; ++i)
|
||||
{
|
||||
caf::HexGridIntersectionTools::ClipVx cvx = clippedTriangleVxes[triVxIdx + i];
|
||||
if(cvx.isVxIdsNative)
|
||||
{
|
||||
m_triVxToCellCornerWeights.push_back(
|
||||
RivIntersectionVertexWeights(cvx.clippedEdgeVx1Id, cvx.clippedEdgeVx2Id, cvx.normDistFromEdgeVx1));
|
||||
}
|
||||
else
|
||||
{
|
||||
caf::HexGridIntersectionTools::ClipVx cvx1;
|
||||
caf::HexGridIntersectionTools::ClipVx cvx2;
|
||||
|
||||
if (cvx.derivedVxLevel == 0)
|
||||
{
|
||||
cvx1 = hexPlaneCutTriangleVxes[cvx.clippedEdgeVx1Id];
|
||||
cvx2 = hexPlaneCutTriangleVxes[cvx.clippedEdgeVx2Id];
|
||||
}
|
||||
else if(cvx.derivedVxLevel == 1)
|
||||
{
|
||||
cvx1 = clippedTriangleVxes_once[cvx.clippedEdgeVx1Id];
|
||||
cvx2 = clippedTriangleVxes_once[cvx.clippedEdgeVx2Id];
|
||||
}
|
||||
else
|
||||
{
|
||||
CVF_ASSERT(false);
|
||||
}
|
||||
|
||||
if(cvx1.isVxIdsNative && cvx2.isVxIdsNative)
|
||||
{
|
||||
m_triVxToCellCornerWeights.push_back(
|
||||
RivIntersectionVertexWeights(cvx1.clippedEdgeVx1Id, cvx1.clippedEdgeVx2Id, cvx1.normDistFromEdgeVx1,
|
||||
cvx2.clippedEdgeVx1Id, cvx2.clippedEdgeVx2Id, cvx2.normDistFromEdgeVx1,
|
||||
cvx.normDistFromEdgeVx1));
|
||||
}
|
||||
else
|
||||
{
|
||||
caf::HexGridIntersectionTools::ClipVx cvx11;
|
||||
caf::HexGridIntersectionTools::ClipVx cvx12;
|
||||
caf::HexGridIntersectionTools::ClipVx cvx21;
|
||||
caf::HexGridIntersectionTools::ClipVx cvx22;
|
||||
|
||||
if(cvx1.isVxIdsNative)
|
||||
{
|
||||
cvx11 = cvx1;
|
||||
cvx12 = cvx1;
|
||||
}
|
||||
else if(cvx1.derivedVxLevel == 0)
|
||||
{
|
||||
cvx11 = hexPlaneCutTriangleVxes[cvx1.clippedEdgeVx1Id];
|
||||
cvx12 = hexPlaneCutTriangleVxes[cvx1.clippedEdgeVx2Id];
|
||||
}
|
||||
else if(cvx2.derivedVxLevel == 1)
|
||||
{
|
||||
cvx11 = clippedTriangleVxes_once[cvx1.clippedEdgeVx1Id];
|
||||
cvx12 = clippedTriangleVxes_once[cvx1.clippedEdgeVx2Id];
|
||||
}
|
||||
else
|
||||
{
|
||||
CVF_ASSERT(false);
|
||||
}
|
||||
|
||||
|
||||
if(cvx2.isVxIdsNative)
|
||||
{
|
||||
cvx21 = cvx2;
|
||||
cvx22 = cvx2;
|
||||
}
|
||||
else if(cvx2.derivedVxLevel == 0)
|
||||
{
|
||||
cvx21 = hexPlaneCutTriangleVxes[cvx2.clippedEdgeVx1Id];
|
||||
cvx22 = hexPlaneCutTriangleVxes[cvx2.clippedEdgeVx2Id];
|
||||
}
|
||||
else if(cvx2.derivedVxLevel == 1)
|
||||
{
|
||||
cvx21 = clippedTriangleVxes_once[cvx2.clippedEdgeVx1Id];
|
||||
cvx22 = clippedTriangleVxes_once[cvx2.clippedEdgeVx2Id];
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
CVF_ASSERT(false);
|
||||
}
|
||||
|
||||
CVF_TIGHT_ASSERT(cvx11.isVxIdsNative && cvx12.isVxIdsNative && cvx21.isVxIdsNative && cvx22.isVxIdsNative);
|
||||
|
||||
m_triVxToCellCornerWeights.push_back(
|
||||
RivIntersectionVertexWeights(cvx11.clippedEdgeVx1Id, cvx11.clippedEdgeVx2Id, cvx11.normDistFromEdgeVx1,
|
||||
cvx12.clippedEdgeVx1Id, cvx12.clippedEdgeVx2Id, cvx2.normDistFromEdgeVx1,
|
||||
cvx21.clippedEdgeVx1Id, cvx21.clippedEdgeVx2Id, cvx21.normDistFromEdgeVx1,
|
||||
cvx22.clippedEdgeVx1Id, cvx22.clippedEdgeVx2Id, cvx22.normDistFromEdgeVx1,
|
||||
cvx1.normDistFromEdgeVx1,
|
||||
cvx2.normDistFromEdgeVx1,
|
||||
cvx.normDistFromEdgeVx1));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
m_cellBorderLineVxes->assign(cellBorderLineVxes);
|
||||
m_triangleVxes->assign(triangleVertices);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) Statoil ASA
|
||||
//
|
||||
// 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 "RivHexGridIntersectionTools.h"
|
||||
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
#include "cvfArray.h"
|
||||
#include "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RimIntersectionBox;
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class ScalarMapper;
|
||||
class DrawableGeo;
|
||||
}
|
||||
|
||||
|
||||
class RivIntersectionBoxGeometryGenerator : public cvf::Object
|
||||
{
|
||||
public:
|
||||
RivIntersectionBoxGeometryGenerator(const RimIntersectionBox* intersectionBox,
|
||||
const RivIntersectionHexGridInterface* grid);
|
||||
|
||||
~RivIntersectionBoxGeometryGenerator();
|
||||
|
||||
bool isAnyGeometryPresent() const;
|
||||
|
||||
// Generate geometry
|
||||
cvf::ref<cvf::DrawableGeo> generateSurface();
|
||||
cvf::ref<cvf::DrawableGeo> createMeshDrawable();
|
||||
|
||||
// Mapping between cells and geometry
|
||||
const std::vector<size_t>& triangleToCellIndex() const;
|
||||
const std::vector<RivIntersectionVertexWeights>& triangleVxToCellCornerInterpolationWeights() const;
|
||||
|
||||
const RimIntersectionBox* intersectionBox() const;
|
||||
|
||||
private:
|
||||
void calculateArrays();
|
||||
|
||||
cvf::cref<RivIntersectionHexGridInterface> m_hexGrid;
|
||||
|
||||
// Output arrays
|
||||
cvf::ref<cvf::Vec3fArray> m_triangleVxes;
|
||||
cvf::ref<cvf::Vec3fArray> m_cellBorderLineVxes;
|
||||
std::vector<size_t> m_triangleToCellIdxMap;
|
||||
std::vector<RivIntersectionVertexWeights> m_triVxToCellCornerWeights;
|
||||
|
||||
const RimIntersectionBox* m_intersectionBoxDefinition;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,428 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) Statoil ASA
|
||||
//
|
||||
// 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 "RivIntersectionBoxPartMgr.h"
|
||||
|
||||
#include "RigCaseCellResultsData.h"
|
||||
#include "RigCaseData.h"
|
||||
#include "RigFemPartCollection.h"
|
||||
#include "RigFemPartResultsCollection.h"
|
||||
#include "RigGeoMechCaseData.h"
|
||||
#include "RigResultAccessor.h"
|
||||
#include "RigResultAccessorFactory.h"
|
||||
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseCellColors.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimGeoMechCase.h"
|
||||
#include "RimGeoMechCellColors.h"
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimIntersectionBox.h"
|
||||
#include "RimLegendConfig.h"
|
||||
#include "RimTernaryLegendConfig.h"
|
||||
|
||||
#include "RivIntersectionBoxSourceInfo.h"
|
||||
#include "RivResultToTextureMapper.h"
|
||||
#include "RivScalarMapperUtils.h"
|
||||
#include "RivTernaryScalarMapper.h"
|
||||
#include "RivTernaryTextureCoordsCreator.h"
|
||||
|
||||
#include "cvfDrawableGeo.h"
|
||||
#include "cvfModelBasicList.h"
|
||||
#include "cvfPart.h"
|
||||
#include "cvfPrimitiveSetDirect.h"
|
||||
#include "cvfRenderState_FF.h"
|
||||
#include "cvfRenderStateDepth.h"
|
||||
#include "cvfRenderStatePoint.h"
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivIntersectionBoxPartMgr::RivIntersectionBoxPartMgr(const RimIntersectionBox* intersectionBox)
|
||||
: m_rimIntersectionBox(intersectionBox),
|
||||
m_defaultColor(cvf::Color3::WHITE)
|
||||
{
|
||||
CVF_ASSERT(m_rimIntersectionBox);
|
||||
|
||||
m_intersectionBoxFacesTextureCoords = new cvf::Vec2fArray;
|
||||
|
||||
cvf::ref<RivIntersectionHexGridInterface> hexGrid = createHexGridInterface();
|
||||
m_intersectionBoxGenerator = new RivIntersectionBoxGeometryGenerator(m_rimIntersectionBox, hexGrid.p());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivIntersectionBoxPartMgr::applySingleColorEffect()
|
||||
{
|
||||
m_defaultColor = cvf::Color3f::OLIVE;//m_rimCrossSection->CrossSectionColor();
|
||||
this->updatePartEffect();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivIntersectionBoxPartMgr::updateCellResultColor(size_t timeStepIndex)
|
||||
{
|
||||
|
||||
if (!m_intersectionBoxGenerator->isAnyGeometryPresent()) return;
|
||||
|
||||
RimEclipseView* eclipseView;
|
||||
m_rimIntersectionBox->firstAnchestorOrThisOfType(eclipseView);
|
||||
|
||||
if (eclipseView)
|
||||
{
|
||||
RimEclipseCellColors* cellResultColors = eclipseView->cellResult();
|
||||
CVF_ASSERT(cellResultColors);
|
||||
|
||||
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResultColors->porosityModel());
|
||||
RigCaseData* eclipseCase = eclipseView->eclipseCase()->reservoirData();
|
||||
|
||||
// CrossSections
|
||||
if (m_intersectionBoxFaces.notNull())
|
||||
{
|
||||
if (cellResultColors->isTernarySaturationSelected())
|
||||
{
|
||||
RivTernaryTextureCoordsCreator texturer(cellResultColors, cellResultColors->ternaryLegendConfig(), timeStepIndex);
|
||||
|
||||
texturer.createTextureCoords(m_intersectionBoxFacesTextureCoords.p(), m_intersectionBoxGenerator->triangleToCellIndex());
|
||||
|
||||
const RivTernaryScalarMapper* mapper = cellResultColors->ternaryLegendConfig()->scalarMapper();
|
||||
RivScalarMapperUtils::applyTernaryTextureResultsToPart(m_intersectionBoxFaces.p(),
|
||||
m_intersectionBoxFacesTextureCoords.p(),
|
||||
mapper,
|
||||
1.0,
|
||||
caf::FC_NONE,
|
||||
eclipseView->isLightingDisabled());
|
||||
}
|
||||
else
|
||||
{
|
||||
CVF_ASSERT(m_intersectionBoxGenerator.notNull());
|
||||
|
||||
const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper();
|
||||
cvf::ref<RigResultAccessor> resultAccessor;
|
||||
|
||||
if (RimDefines::isPerCellFaceResult(cellResultColors->resultVariable()))
|
||||
{
|
||||
resultAccessor = new RigHugeValResultAccessor;
|
||||
}
|
||||
else
|
||||
{
|
||||
resultAccessor = RigResultAccessorFactory::createResultAccessor(cellResultColors->reservoirView()->eclipseCase()->reservoirData(),
|
||||
0,
|
||||
timeStepIndex,
|
||||
cellResultColors);
|
||||
}
|
||||
|
||||
RivIntersectionBoxPartMgr::calculateEclipseTextureCoordinates(m_intersectionBoxFacesTextureCoords.p(),
|
||||
m_intersectionBoxGenerator->triangleToCellIndex(),
|
||||
resultAccessor.p(),
|
||||
mapper);
|
||||
|
||||
|
||||
RivScalarMapperUtils::applyTextureResultsToPart(m_intersectionBoxFaces.p(),
|
||||
m_intersectionBoxFacesTextureCoords.p(),
|
||||
mapper,
|
||||
1.0,
|
||||
caf::FC_NONE,
|
||||
eclipseView->isLightingDisabled());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RimGeoMechView* geoView;
|
||||
m_rimIntersectionBox->firstAnchestorOrThisOfType(geoView);
|
||||
|
||||
if (geoView)
|
||||
{
|
||||
RimGeoMechCellColors* cellResultColors = geoView->cellResult();
|
||||
RigGeoMechCaseData* caseData = cellResultColors->ownerCaseData();
|
||||
|
||||
if (!caseData) return;
|
||||
|
||||
RigFemResultAddress resVarAddress = cellResultColors->resultAddress();
|
||||
|
||||
// Do a "Hack" to show elm nodal and not nodal POR results
|
||||
if (resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar") resVarAddress.resultPosType = RIG_ELEMENT_NODAL;
|
||||
|
||||
const std::vector<RivIntersectionVertexWeights> &vertexWeights = m_intersectionBoxGenerator->triangleVxToCellCornerInterpolationWeights();
|
||||
const std::vector<float>& resultValues = caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex);
|
||||
bool isElementNodalResult = !(resVarAddress.resultPosType == RIG_NODAL);
|
||||
RigFemPart* femPart = caseData->femParts()->part(0);
|
||||
const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper();
|
||||
|
||||
RivIntersectionBoxPartMgr::calculateGeoMechTextureCoords(m_intersectionBoxFacesTextureCoords.p(),
|
||||
vertexWeights,
|
||||
resultValues,
|
||||
isElementNodalResult,
|
||||
femPart,
|
||||
mapper);
|
||||
|
||||
RivScalarMapperUtils::applyTextureResultsToPart(m_intersectionBoxFaces.p(),
|
||||
m_intersectionBoxFacesTextureCoords.p(),
|
||||
mapper,
|
||||
1.0,
|
||||
caf::FC_NONE,
|
||||
geoView->isLightingDisabled());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivIntersectionBoxPartMgr::calculateGeoMechTextureCoords(cvf::Vec2fArray* textureCoords,
|
||||
const std::vector<RivIntersectionVertexWeights> &vertexWeights,
|
||||
const std::vector<float> &resultValues,
|
||||
bool isElementNodalResult,
|
||||
const RigFemPart* femPart,
|
||||
const cvf::ScalarMapper* mapper)
|
||||
{
|
||||
textureCoords->resize(vertexWeights.size());
|
||||
|
||||
if (resultValues.size() == 0)
|
||||
{
|
||||
textureCoords->setAll(cvf::Vec2f(0.0, 1.0f));
|
||||
}
|
||||
else
|
||||
{
|
||||
cvf::Vec2f* rawPtr = textureCoords->ptr();
|
||||
|
||||
int vxCount = static_cast<int>(vertexWeights.size());
|
||||
|
||||
#pragma omp parallel for schedule(dynamic)
|
||||
for (int triangleVxIdx = 0; triangleVxIdx < vxCount; ++triangleVxIdx)
|
||||
{
|
||||
float resValue = 0;
|
||||
int weightCount = vertexWeights[triangleVxIdx].size();
|
||||
for (int wIdx = 0; wIdx < weightCount; ++wIdx)
|
||||
{
|
||||
size_t resIdx = isElementNodalResult ? vertexWeights[triangleVxIdx].vxId(wIdx) :
|
||||
femPart->nodeIdxFromElementNodeResultIdx(vertexWeights[triangleVxIdx].vxId(wIdx));
|
||||
resValue += resultValues[resIdx] * vertexWeights[triangleVxIdx].weight(wIdx);
|
||||
}
|
||||
|
||||
if (resValue == HUGE_VAL || resValue != resValue) // a != a is true for NAN's
|
||||
{
|
||||
rawPtr[triangleVxIdx][1] = 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
rawPtr[triangleVxIdx] = mapper->mapToTextureCoord(resValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Calculates the texture coordinates in a "nearly" one dimensional texture.
|
||||
/// Undefined values are coded with a y-texture coordinate value of 1.0 instead of the normal 0.5
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivIntersectionBoxPartMgr::calculateEclipseTextureCoordinates(cvf::Vec2fArray* textureCoords,
|
||||
const std::vector<size_t>& triangleToCellIdxMap,
|
||||
const RigResultAccessor* resultAccessor,
|
||||
const cvf::ScalarMapper* mapper)
|
||||
{
|
||||
if (!resultAccessor) return;
|
||||
|
||||
size_t numVertices = triangleToCellIdxMap.size()*3;
|
||||
|
||||
textureCoords->resize(numVertices);
|
||||
cvf::Vec2f* rawPtr = textureCoords->ptr();
|
||||
|
||||
int triangleCount = static_cast<int>(triangleToCellIdxMap.size());
|
||||
|
||||
#pragma omp parallel for
|
||||
for (int tIdx = 0; tIdx < triangleCount; tIdx++)
|
||||
{
|
||||
double cellScalarValue = resultAccessor->cellScalarGlobIdx(triangleToCellIdxMap[tIdx]);
|
||||
cvf::Vec2f texCoord = mapper->mapToTextureCoord(cellScalarValue);
|
||||
if (cellScalarValue == HUGE_VAL || cellScalarValue != cellScalarValue) // a != a is true for NAN's
|
||||
{
|
||||
texCoord[1] = 1.0f;
|
||||
}
|
||||
|
||||
size_t j;
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
rawPtr[tIdx*3 + j] = texCoord;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const int priCrossSectionGeo = 1;
|
||||
const int priNncGeo = 2;
|
||||
const int priMesh = 3;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivIntersectionBoxPartMgr::generatePartGeometry()
|
||||
{
|
||||
|
||||
bool useBufferObjects = true;
|
||||
// Surface geometry
|
||||
{
|
||||
cvf::ref<cvf::DrawableGeo> geo = m_intersectionBoxGenerator->generateSurface();
|
||||
if (geo.notNull())
|
||||
{
|
||||
geo->computeNormals();
|
||||
|
||||
if (useBufferObjects)
|
||||
{
|
||||
geo->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT);
|
||||
}
|
||||
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
part->setName("Intersection Box");
|
||||
part->setDrawable(geo.p());
|
||||
|
||||
// Set mapping from triangle face index to cell index
|
||||
cvf::ref<RivIntersectionBoxSourceInfo> si = new RivIntersectionBoxSourceInfo(m_intersectionBoxGenerator.p());
|
||||
part->setSourceInfo(si.p());
|
||||
|
||||
part->updateBoundingBox();
|
||||
part->setEnableMask(faultBit);
|
||||
part->setPriority(priCrossSectionGeo);
|
||||
|
||||
m_intersectionBoxFaces = part;
|
||||
}
|
||||
}
|
||||
|
||||
// Mesh geometry
|
||||
{
|
||||
cvf::ref<cvf::DrawableGeo> geoMesh = m_intersectionBoxGenerator->createMeshDrawable();
|
||||
if (geoMesh.notNull())
|
||||
{
|
||||
if (useBufferObjects)
|
||||
{
|
||||
geoMesh->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT);
|
||||
}
|
||||
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
part->setName("Intersection box mesh");
|
||||
part->setDrawable(geoMesh.p());
|
||||
|
||||
part->updateBoundingBox();
|
||||
part->setEnableMask(meshFaultBit);
|
||||
part->setPriority(priMesh);
|
||||
|
||||
m_intersectionBoxGridLines = part;
|
||||
}
|
||||
}
|
||||
|
||||
updatePartEffect();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivIntersectionBoxPartMgr::updatePartEffect()
|
||||
{
|
||||
// Set deCrossSection effect
|
||||
caf::SurfaceEffectGenerator geometryEffgen(m_defaultColor, caf::PO_1);
|
||||
|
||||
cvf::ref<cvf::Effect> geometryOnlyEffect = geometryEffgen.generateCachedEffect();
|
||||
|
||||
if (m_intersectionBoxFaces.notNull())
|
||||
{
|
||||
m_intersectionBoxFaces->setEffect(geometryOnlyEffect.p());
|
||||
}
|
||||
|
||||
// Update mesh colors as well, in case of change
|
||||
//RiaPreferences* prefs = RiaApplication::instance()->preferences();
|
||||
|
||||
cvf::ref<cvf::Effect> eff;
|
||||
caf::MeshEffectGenerator CrossSectionEffGen(cvf::Color3::WHITE);//prefs->defaultCrossSectionGridLineColors());
|
||||
eff = CrossSectionEffGen.generateCachedEffect();
|
||||
|
||||
if (m_intersectionBoxGridLines.notNull())
|
||||
{
|
||||
m_intersectionBoxGridLines->setEffect(eff.p());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivIntersectionBoxPartMgr::appendNativeCrossSectionFacesToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform)
|
||||
{
|
||||
if (m_intersectionBoxFaces.isNull() && m_intersectionBoxGridLines.isNull())
|
||||
{
|
||||
generatePartGeometry();
|
||||
}
|
||||
|
||||
if (m_intersectionBoxFaces.notNull())
|
||||
{
|
||||
m_intersectionBoxFaces->setTransform(scaleTransform);
|
||||
model->addPart(m_intersectionBoxFaces.p());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivIntersectionBoxPartMgr::appendMeshLinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform)
|
||||
{
|
||||
if (m_intersectionBoxFaces.isNull() && m_intersectionBoxGridLines.isNull())
|
||||
{
|
||||
generatePartGeometry();
|
||||
}
|
||||
|
||||
if (m_intersectionBoxGridLines.notNull())
|
||||
{
|
||||
m_intersectionBoxGridLines->setTransform(scaleTransform);
|
||||
model->addPart(m_intersectionBoxGridLines.p());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<RivIntersectionHexGridInterface> RivIntersectionBoxPartMgr::createHexGridInterface()
|
||||
{
|
||||
|
||||
RimEclipseView* eclipseView;
|
||||
m_rimIntersectionBox->firstAnchestorOrThisOfType(eclipseView);
|
||||
if (eclipseView)
|
||||
{
|
||||
RigMainGrid* grid = NULL;
|
||||
grid = eclipseView->eclipseCase()->reservoirData()->mainGrid();
|
||||
|
||||
// TODO: Should flag for inactive cells be available at a centralized object?
|
||||
return new RivEclipseIntersectionGrid(grid, eclipseView->currentActiveCellInfo(), false);
|
||||
}
|
||||
|
||||
RimGeoMechView* geoView;
|
||||
m_rimIntersectionBox->firstAnchestorOrThisOfType(geoView);
|
||||
if (geoView)
|
||||
{
|
||||
RigFemPart* femPart = geoView->geoMechCase()->geoMechData()->femParts()->part(0);
|
||||
return new RivFemIntersectionGrid(femPart);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) Statoil ASA
|
||||
//
|
||||
// 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 "RivIntersectionBoxGeometryGenerator.h"
|
||||
|
||||
#include "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class ModelBasicList;
|
||||
class Transform;
|
||||
class Part;
|
||||
}
|
||||
|
||||
class RigMainGrid;
|
||||
class RigResultAccessor;
|
||||
class RimCellEdgeColors;
|
||||
class RimEclipseCellColors;
|
||||
class RimIntersectionBox;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
|
||||
class RivIntersectionBoxPartMgr : public cvf::Object
|
||||
{
|
||||
public:
|
||||
RivIntersectionBoxPartMgr(const RimIntersectionBox* intersectionBox);
|
||||
|
||||
void applySingleColorEffect();
|
||||
void updateCellResultColor(size_t timeStepIndex);
|
||||
|
||||
|
||||
void appendNativeCrossSectionFacesToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform);
|
||||
void appendMeshLinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform);
|
||||
|
||||
private:
|
||||
void updatePartEffect();
|
||||
void generatePartGeometry();
|
||||
|
||||
static void calculateEclipseTextureCoordinates(cvf::Vec2fArray* textureCoords,
|
||||
const std::vector<size_t>& triangleToCellIdxMap,
|
||||
const RigResultAccessor* resultAccessor,
|
||||
const cvf::ScalarMapper* mapper);
|
||||
|
||||
static void calculateGeoMechTextureCoords(cvf::Vec2fArray* textureCoords,
|
||||
const std::vector<RivIntersectionVertexWeights> &vertexWeights,
|
||||
const std::vector<float> &resultValues,
|
||||
bool isElementNodalResult,
|
||||
const RigFemPart* femPart,
|
||||
const cvf::ScalarMapper* mapper);
|
||||
|
||||
cvf::ref<RivIntersectionHexGridInterface> createHexGridInterface();
|
||||
private:
|
||||
const RimIntersectionBox* m_rimIntersectionBox;
|
||||
|
||||
cvf::Color3f m_defaultColor;
|
||||
|
||||
cvf::ref<cvf::Part> m_intersectionBoxFaces;
|
||||
cvf::ref<cvf::Part> m_intersectionBoxGridLines;
|
||||
cvf::ref<cvf::Vec2fArray> m_intersectionBoxFacesTextureCoords;
|
||||
|
||||
cvf::ref<RivIntersectionBoxGeometryGenerator> m_intersectionBoxGenerator;
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) Statoil ASA
|
||||
//
|
||||
// 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 "RivIntersectionBoxSourceInfo.h"
|
||||
|
||||
#include "RivIntersectionBoxGeometryGenerator.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivIntersectionBoxSourceInfo::RivIntersectionBoxSourceInfo(RivIntersectionBoxGeometryGenerator* geometryGenerator)
|
||||
: m_intersectionBoxGeometryGenerator(geometryGenerator)
|
||||
{
|
||||
CVF_ASSERT(m_intersectionBoxGeometryGenerator.notNull());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<size_t>& RivIntersectionBoxSourceInfo::triangleToCellIndex() const
|
||||
{
|
||||
CVF_ASSERT(m_intersectionBoxGeometryGenerator.notNull());
|
||||
|
||||
return m_intersectionBoxGeometryGenerator->triangleToCellIndex();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) Statoil ASA
|
||||
//
|
||||
// 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 "cvfArray.h"
|
||||
|
||||
class RivIntersectionBoxGeometryGenerator;
|
||||
class RimIntersectionBox;
|
||||
|
||||
class RivIntersectionBoxSourceInfo : public cvf::Object
|
||||
{
|
||||
public:
|
||||
RivIntersectionBoxSourceInfo(RivIntersectionBoxGeometryGenerator* geometryGenerator);
|
||||
|
||||
const std::vector<size_t>& triangleToCellIndex() const;
|
||||
|
||||
private:
|
||||
cvf::cref<RivIntersectionBoxGeometryGenerator> m_intersectionBoxGeometryGenerator;
|
||||
};
|
||||
@@ -0,0 +1,387 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RivIntersectionGeometryGenerator.h"
|
||||
|
||||
#include "RigMainGrid.h"
|
||||
#include "RigResultAccessor.h"
|
||||
|
||||
#include "RimIntersection.h"
|
||||
|
||||
#include "cafHexGridIntersectionTools/cafHexGridIntersectionTools.h"
|
||||
|
||||
#include "cvfDrawableGeo.h"
|
||||
#include "cvfPrimitiveSetDirect.h"
|
||||
#include "cvfPrimitiveSetIndexedUInt.h"
|
||||
#include "cvfScalarMapper.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivIntersectionGeometryGenerator::RivIntersectionGeometryGenerator(const RimIntersection* crossSection,
|
||||
std::vector<std::vector<cvf::Vec3d> > &polylines,
|
||||
const cvf::Vec3d& extrusionDirection,
|
||||
const RivIntersectionHexGridInterface* grid)
|
||||
: m_crossSection(crossSection),
|
||||
m_polyLines(polylines),
|
||||
m_extrusionDirection(extrusionDirection),
|
||||
m_hexGrid(grid)
|
||||
{
|
||||
m_triangleVxes = new cvf::Vec3fArray;
|
||||
m_cellBorderLineVxes = new cvf::Vec3fArray;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivIntersectionGeometryGenerator::~RivIntersectionGeometryGenerator()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivIntersectionGeometryGenerator::calculateArrays()
|
||||
{
|
||||
if (m_triangleVxes->size()) return;
|
||||
|
||||
m_extrusionDirection.normalize();
|
||||
std::vector<cvf::Vec3f> triangleVertices;
|
||||
std::vector<cvf::Vec3f> cellBorderLineVxes;
|
||||
cvf::Vec3d displayOffset = m_hexGrid->displayOffset();
|
||||
cvf::BoundingBox gridBBox = m_hexGrid->boundingBox();
|
||||
|
||||
for (size_t pLineIdx = 0; pLineIdx < m_polyLines.size(); ++pLineIdx)
|
||||
{
|
||||
const std::vector<cvf::Vec3d>& m_polyLine = m_polyLines[pLineIdx];
|
||||
|
||||
if (m_polyLine.size() < 2) continue;
|
||||
|
||||
std::vector<cvf::Vec3d> m_adjustedPolyline;
|
||||
adjustPolyline(m_polyLine, m_extrusionDirection, &m_adjustedPolyline);
|
||||
|
||||
size_t lineCount = m_adjustedPolyline.size();
|
||||
for (size_t lIdx = 0; lIdx < lineCount - 1; ++lIdx)
|
||||
{
|
||||
cvf::Vec3d p1 = m_adjustedPolyline[lIdx];
|
||||
cvf::Vec3d p2 = m_adjustedPolyline[lIdx+1];
|
||||
|
||||
cvf::BoundingBox sectionBBox;
|
||||
sectionBBox.add(p1);
|
||||
sectionBBox.add(p2);
|
||||
double maxSectionHeight = gridBBox.radius();
|
||||
sectionBBox.add(p1 + m_extrusionDirection*maxSectionHeight);
|
||||
sectionBBox.add(p1 - m_extrusionDirection*maxSectionHeight);
|
||||
sectionBBox.add(p2 + m_extrusionDirection*maxSectionHeight);
|
||||
sectionBBox.add(p2 - m_extrusionDirection*maxSectionHeight);
|
||||
|
||||
std::vector<size_t> columnCellCandidates;
|
||||
m_hexGrid->findIntersectingCells(sectionBBox, &columnCellCandidates);
|
||||
|
||||
cvf::Plane plane;
|
||||
plane.setFromPoints(p1, p2, p2 + m_extrusionDirection*maxSectionHeight);
|
||||
|
||||
cvf::Plane p1Plane;
|
||||
p1Plane.setFromPoints(p1, p1 + m_extrusionDirection*maxSectionHeight, p1 + plane.normal());
|
||||
cvf::Plane p2Plane;
|
||||
p2Plane.setFromPoints(p2, p2 + m_extrusionDirection*maxSectionHeight, p2 - plane.normal());
|
||||
|
||||
|
||||
std::vector<caf::HexGridIntersectionTools::ClipVx> hexPlaneCutTriangleVxes;
|
||||
hexPlaneCutTriangleVxes.reserve(5*3);
|
||||
std::vector<bool> isTriangleEdgeCellContour;
|
||||
isTriangleEdgeCellContour.reserve(5*3);
|
||||
cvf::Vec3d cellCorners[8];
|
||||
size_t cornerIndices[8];
|
||||
|
||||
for (size_t cccIdx = 0; cccIdx < columnCellCandidates.size(); ++cccIdx)
|
||||
{
|
||||
size_t globalCellIdx = columnCellCandidates[cccIdx];
|
||||
|
||||
if (!m_hexGrid->useCell(globalCellIdx)) continue;
|
||||
|
||||
hexPlaneCutTriangleVxes.clear();
|
||||
m_hexGrid->cellCornerVertices(globalCellIdx, cellCorners);
|
||||
m_hexGrid->cellCornerIndices(globalCellIdx, cornerIndices);
|
||||
|
||||
caf::HexGridIntersectionTools::planeHexIntersectionMC(plane,
|
||||
cellCorners,
|
||||
cornerIndices,
|
||||
&hexPlaneCutTriangleVxes,
|
||||
&isTriangleEdgeCellContour);
|
||||
|
||||
std::vector<caf::HexGridIntersectionTools::ClipVx> clippedTriangleVxes;
|
||||
std::vector<bool> isClippedTriEdgeCellContour;
|
||||
|
||||
caf::HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(hexPlaneCutTriangleVxes, isTriangleEdgeCellContour, p1Plane, p2Plane,
|
||||
&clippedTriangleVxes, &isClippedTriEdgeCellContour);
|
||||
|
||||
size_t clippedTriangleCount = clippedTriangleVxes.size()/3;
|
||||
|
||||
for (uint tIdx = 0; tIdx < clippedTriangleCount; ++tIdx)
|
||||
{
|
||||
uint triVxIdx = tIdx*3;
|
||||
|
||||
// Accumulate triangle vertices
|
||||
|
||||
cvf::Vec3f p0(clippedTriangleVxes[triVxIdx+0].vx - displayOffset);
|
||||
cvf::Vec3f p1(clippedTriangleVxes[triVxIdx+1].vx - displayOffset);
|
||||
cvf::Vec3f p2(clippedTriangleVxes[triVxIdx+2].vx - displayOffset);
|
||||
|
||||
triangleVertices.push_back(p0);
|
||||
triangleVertices.push_back(p1);
|
||||
triangleVertices.push_back(p2);
|
||||
|
||||
|
||||
// Accumulate mesh lines
|
||||
|
||||
if (isClippedTriEdgeCellContour[triVxIdx])
|
||||
{
|
||||
cellBorderLineVxes.push_back(p0);
|
||||
cellBorderLineVxes.push_back(p1);
|
||||
}
|
||||
if (isClippedTriEdgeCellContour[triVxIdx+1])
|
||||
{
|
||||
cellBorderLineVxes.push_back(p1);
|
||||
cellBorderLineVxes.push_back(p2);
|
||||
}
|
||||
if (isClippedTriEdgeCellContour[triVxIdx+2])
|
||||
{
|
||||
cellBorderLineVxes.push_back(p2);
|
||||
cellBorderLineVxes.push_back(p0);
|
||||
}
|
||||
|
||||
// Mapping to cell index
|
||||
|
||||
m_triangleToCellIdxMap.push_back(globalCellIdx);
|
||||
|
||||
// Interpolation from nodes
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
caf::HexGridIntersectionTools::ClipVx cvx = clippedTriangleVxes[triVxIdx + i];
|
||||
if (cvx.isVxIdsNative)
|
||||
{
|
||||
m_triVxToCellCornerWeights.push_back(
|
||||
RivIntersectionVertexWeights(cvx.clippedEdgeVx1Id, cvx.clippedEdgeVx2Id, cvx.normDistFromEdgeVx1));
|
||||
}
|
||||
else
|
||||
{
|
||||
caf::HexGridIntersectionTools::ClipVx cvx1 = hexPlaneCutTriangleVxes[cvx.clippedEdgeVx1Id];
|
||||
caf::HexGridIntersectionTools::ClipVx cvx2 = hexPlaneCutTriangleVxes[cvx.clippedEdgeVx2Id];
|
||||
|
||||
m_triVxToCellCornerWeights.push_back(
|
||||
RivIntersectionVertexWeights(cvx1.clippedEdgeVx1Id, cvx1.clippedEdgeVx2Id, cvx1.normDistFromEdgeVx1,
|
||||
cvx2.clippedEdgeVx1Id, cvx2.clippedEdgeVx2Id, cvx2.normDistFromEdgeVx1,
|
||||
cvx.normDistFromEdgeVx1));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
m_triangleVxes->assign(triangleVertices);
|
||||
m_cellBorderLineVxes->assign(cellBorderLineVxes);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Generate surface drawable geo from the specified region
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo> RivIntersectionGeometryGenerator::generateSurface()
|
||||
{
|
||||
calculateArrays();
|
||||
|
||||
CVF_ASSERT(m_triangleVxes.notNull());
|
||||
|
||||
if (m_triangleVxes->size() == 0) return NULL;
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
|
||||
geo->setFromTriangleVertexArray(m_triangleVxes.p());
|
||||
|
||||
return geo;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo> RivIntersectionGeometryGenerator::createMeshDrawable()
|
||||
{
|
||||
if (!(m_cellBorderLineVxes.notNull() && m_cellBorderLineVxes->size() != 0)) return NULL;
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
|
||||
geo->setVertexArray(m_cellBorderLineVxes.p());
|
||||
|
||||
|
||||
cvf::ref<cvf::PrimitiveSetDirect> prim = new cvf::PrimitiveSetDirect(cvf::PT_LINES);
|
||||
prim->setIndexCount(m_cellBorderLineVxes->size());
|
||||
|
||||
geo->addPrimitiveSet(prim.p());
|
||||
return geo;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo> RivIntersectionGeometryGenerator::createLineAlongPolylineDrawable()
|
||||
{
|
||||
std::vector<cvf::uint> lineIndices;
|
||||
std::vector<cvf::Vec3f> vertices;
|
||||
|
||||
cvf::Vec3d displayOffset = m_hexGrid->displayOffset();
|
||||
|
||||
for (size_t pLineIdx = 0; pLineIdx < m_polyLines.size(); ++pLineIdx)
|
||||
{
|
||||
const std::vector<cvf::Vec3d>& m_polyLine = m_polyLines[pLineIdx];
|
||||
if (m_polyLine.size() < 2) continue;
|
||||
|
||||
for (size_t i = 0; i < m_polyLine.size(); ++i)
|
||||
{
|
||||
vertices.push_back(cvf::Vec3f(m_polyLine[i] - displayOffset));
|
||||
if (i < m_polyLine.size() - 1)
|
||||
{
|
||||
lineIndices.push_back(static_cast<cvf::uint>(i));
|
||||
lineIndices.push_back(static_cast<cvf::uint>(i + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (vertices.size() == 0) return NULL;
|
||||
|
||||
cvf::ref<cvf::Vec3fArray> vx = new cvf::Vec3fArray;
|
||||
vx->assign(vertices);
|
||||
cvf::ref<cvf::UIntArray> idxes = new cvf::UIntArray;
|
||||
idxes->assign(lineIndices);
|
||||
|
||||
cvf::ref<cvf::PrimitiveSetIndexedUInt> prim = new cvf::PrimitiveSetIndexedUInt(cvf::PT_LINES);
|
||||
prim->setIndices(idxes.p());
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> polylineGeo = new cvf::DrawableGeo;
|
||||
polylineGeo->setVertexArray(vx.p());
|
||||
polylineGeo->addPrimitiveSet(prim.p());
|
||||
|
||||
return polylineGeo;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo> RivIntersectionGeometryGenerator::createPointsFromPolylineDrawable()
|
||||
{
|
||||
std::vector<cvf::Vec3f> vertices;
|
||||
|
||||
cvf::Vec3d displayOffset = m_hexGrid->displayOffset();
|
||||
|
||||
for (size_t pLineIdx = 0; pLineIdx < m_polyLines.size(); ++pLineIdx)
|
||||
{
|
||||
const std::vector<cvf::Vec3d>& m_polyLine = m_polyLines[pLineIdx];
|
||||
for (size_t i = 0; i < m_polyLine.size(); ++i)
|
||||
{
|
||||
vertices.push_back(cvf::Vec3f(m_polyLine[i] - displayOffset));
|
||||
}
|
||||
}
|
||||
|
||||
if (vertices.size() == 0) return NULL;
|
||||
|
||||
cvf::ref<cvf::PrimitiveSetDirect> primSet = new cvf::PrimitiveSetDirect(cvf::PT_POINTS);
|
||||
primSet->setStartIndex(0);
|
||||
primSet->setIndexCount(vertices.size());
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
|
||||
|
||||
cvf::ref<cvf::Vec3fArray> vx = new cvf::Vec3fArray(vertices);
|
||||
geo->setVertexArray(vx.p());
|
||||
geo->addPrimitiveSet(primSet.p());
|
||||
|
||||
return geo;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Remove the lines from the polyline that is nearly parallel to the extrusion direction
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivIntersectionGeometryGenerator::adjustPolyline(const std::vector<cvf::Vec3d>& polyLine,
|
||||
const cvf::Vec3d extrDir,
|
||||
std::vector<cvf::Vec3d>* adjustedPolyline)
|
||||
{
|
||||
size_t lineCount = polyLine.size();
|
||||
if (!polyLine.size()) return;
|
||||
|
||||
adjustedPolyline->push_back(polyLine[0]);
|
||||
cvf::Vec3d p1 = polyLine[0];
|
||||
|
||||
for (size_t lIdx = 1; lIdx < lineCount; ++lIdx)
|
||||
{
|
||||
cvf::Vec3d p2 = polyLine[lIdx];
|
||||
cvf::Vec3d p1p2 = p2 - p1;
|
||||
|
||||
if ((p1p2 - (p1p2 * extrDir)*extrDir).length() > 0.1 )
|
||||
{
|
||||
adjustedPolyline->push_back(p2);
|
||||
p1 = p2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<size_t>& RivIntersectionGeometryGenerator::triangleToCellIndex() const
|
||||
{
|
||||
CVF_ASSERT(m_triangleVxes->size());
|
||||
return m_triangleToCellIdxMap;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<RivIntersectionVertexWeights>& RivIntersectionGeometryGenerator::triangleVxToCellCornerInterpolationWeights() const
|
||||
{
|
||||
CVF_ASSERT(m_triangleVxes->size());
|
||||
return m_triVxToCellCornerWeights;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const RimIntersection* RivIntersectionGeometryGenerator::crossSection() const
|
||||
{
|
||||
return m_crossSection;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RivIntersectionGeometryGenerator::isAnyGeometryPresent() const
|
||||
{
|
||||
if (m_triangleVxes->size() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RivHexGridIntersectionTools.h"
|
||||
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
#include "cvfArray.h"
|
||||
#include "cvfBase.h"
|
||||
#include "cvfBoundingBox.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RigMainGrid;
|
||||
class RigActiveCellInfo;
|
||||
class RigResultAccessor;
|
||||
class RimIntersection;
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class ScalarMapper;
|
||||
class DrawableGeo;
|
||||
}
|
||||
|
||||
|
||||
class RivIntersectionGeometryGenerator : public cvf::Object
|
||||
{
|
||||
public:
|
||||
RivIntersectionGeometryGenerator(const RimIntersection* crossSection,
|
||||
std::vector<std::vector<cvf::Vec3d> > &polylines,
|
||||
const cvf::Vec3d& extrusionDirection,
|
||||
const RivIntersectionHexGridInterface* grid );
|
||||
|
||||
~RivIntersectionGeometryGenerator();
|
||||
|
||||
bool isAnyGeometryPresent() const;
|
||||
|
||||
// Generate geometry
|
||||
cvf::ref<cvf::DrawableGeo> generateSurface();
|
||||
cvf::ref<cvf::DrawableGeo> createMeshDrawable();
|
||||
cvf::ref<cvf::DrawableGeo> createLineAlongPolylineDrawable();
|
||||
cvf::ref<cvf::DrawableGeo> createPointsFromPolylineDrawable();
|
||||
|
||||
// Mapping between cells and geometry
|
||||
const std::vector<size_t>& triangleToCellIndex() const;
|
||||
const std::vector<RivIntersectionVertexWeights>& triangleVxToCellCornerInterpolationWeights() const;
|
||||
|
||||
const RimIntersection* crossSection() const;
|
||||
|
||||
private:
|
||||
void calculateArrays();
|
||||
static void adjustPolyline(const std::vector<cvf::Vec3d>& polyLine,
|
||||
const cvf::Vec3d extrDir,
|
||||
std::vector<cvf::Vec3d>* adjustedPolyline);
|
||||
|
||||
cvf::cref<RivIntersectionHexGridInterface> m_hexGrid;
|
||||
const std::vector<std::vector<cvf::Vec3d> > m_polyLines;
|
||||
cvf::Vec3d m_extrusionDirection;
|
||||
|
||||
// Output arrays
|
||||
cvf::ref<cvf::Vec3fArray> m_triangleVxes;
|
||||
cvf::ref<cvf::Vec3fArray> m_cellBorderLineVxes;
|
||||
std::vector<size_t> m_triangleToCellIdxMap;
|
||||
std::vector<RivIntersectionVertexWeights> m_triVxToCellCornerWeights;
|
||||
|
||||
const RimIntersection* m_crossSection;
|
||||
};
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RivCrossSectionPartMgr.h"
|
||||
#include "RivIntersectionPartMgr.h"
|
||||
|
||||
#include "RigCaseCellResultsData.h"
|
||||
#include "RigCaseData.h"
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "RigResultAccessor.h"
|
||||
#include "RigResultAccessorFactory.h"
|
||||
|
||||
#include "RimCrossSection.h"
|
||||
#include "RimIntersection.h"
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseCellColors.h"
|
||||
#include "RimEclipseView.h"
|
||||
@@ -37,7 +37,7 @@
|
||||
#include "RimLegendConfig.h"
|
||||
#include "RimTernaryLegendConfig.h"
|
||||
|
||||
#include "RivCrossSectionSourceInfo.h"
|
||||
#include "RivIntersectionSourceInfo.h"
|
||||
#include "RivResultToTextureMapper.h"
|
||||
#include "RivScalarMapperUtils.h"
|
||||
#include "RivTernaryScalarMapper.h"
|
||||
@@ -55,7 +55,7 @@
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivCrossSectionPartMgr::RivCrossSectionPartMgr(const RimCrossSection* rimCrossSection)
|
||||
RivIntersectionPartMgr::RivIntersectionPartMgr(const RimIntersection* rimCrossSection)
|
||||
: m_rimCrossSection(rimCrossSection),
|
||||
m_defaultColor(cvf::Color3::WHITE)
|
||||
{
|
||||
@@ -69,7 +69,7 @@ RivCrossSectionPartMgr::RivCrossSectionPartMgr(const RimCrossSection* rimCrossSe
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivCrossSectionPartMgr::applySingleColorEffect()
|
||||
void RivIntersectionPartMgr::applySingleColorEffect()
|
||||
{
|
||||
if (m_crossSectionGenerator.isNull()) return;
|
||||
|
||||
@@ -80,7 +80,7 @@ void RivCrossSectionPartMgr::applySingleColorEffect()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivCrossSectionPartMgr::updateCellResultColor(size_t timeStepIndex)
|
||||
void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex)
|
||||
{
|
||||
if (m_crossSectionGenerator.isNull()) return;
|
||||
|
||||
@@ -133,7 +133,7 @@ void RivCrossSectionPartMgr::updateCellResultColor(size_t timeStepIndex)
|
||||
cellResultColors);
|
||||
}
|
||||
|
||||
RivCrossSectionPartMgr::calculateEclipseTextureCoordinates(m_crossSectionFacesTextureCoords.p(),
|
||||
RivIntersectionPartMgr::calculateEclipseTextureCoordinates(m_crossSectionFacesTextureCoords.p(),
|
||||
m_crossSectionGenerator->triangleToCellIndex(),
|
||||
resultAccessor.p(),
|
||||
mapper);
|
||||
@@ -164,13 +164,13 @@ void RivCrossSectionPartMgr::updateCellResultColor(size_t timeStepIndex)
|
||||
// Do a "Hack" to show elm nodal and not nodal POR results
|
||||
if (resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar") resVarAddress.resultPosType = RIG_ELEMENT_NODAL;
|
||||
|
||||
const std::vector<RivVertexWeights> &vertexWeights = m_crossSectionGenerator->triangleVxToCellCornerInterpolationWeights();
|
||||
const std::vector<RivIntersectionVertexWeights> &vertexWeights = m_crossSectionGenerator->triangleVxToCellCornerInterpolationWeights();
|
||||
const std::vector<float>& resultValues = caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex);
|
||||
bool isElementNodalResult = !(resVarAddress.resultPosType == RIG_NODAL);
|
||||
RigFemPart* femPart = caseData->femParts()->part(0);
|
||||
const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper();
|
||||
|
||||
RivCrossSectionPartMgr::calculateGeoMechTextureCoords(m_crossSectionFacesTextureCoords.p(),
|
||||
RivIntersectionPartMgr::calculateGeoMechTextureCoords(m_crossSectionFacesTextureCoords.p(),
|
||||
vertexWeights,
|
||||
resultValues,
|
||||
isElementNodalResult,
|
||||
@@ -190,8 +190,8 @@ void RivCrossSectionPartMgr::updateCellResultColor(size_t timeStepIndex)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivCrossSectionPartMgr::calculateGeoMechTextureCoords(cvf::Vec2fArray* textureCoords,
|
||||
const std::vector<RivVertexWeights> &vertexWeights,
|
||||
void RivIntersectionPartMgr::calculateGeoMechTextureCoords(cvf::Vec2fArray* textureCoords,
|
||||
const std::vector<RivIntersectionVertexWeights> &vertexWeights,
|
||||
const std::vector<float> &resultValues,
|
||||
bool isElementNodalResult,
|
||||
const RigFemPart* femPart,
|
||||
@@ -239,7 +239,7 @@ void RivCrossSectionPartMgr::calculateGeoMechTextureCoords(cvf::Vec2fArray* text
|
||||
/// Calculates the texture coordinates in a "nearly" one dimensional texture.
|
||||
/// Undefined values are coded with a y-texturecoordinate value of 1.0 instead of the normal 0.5
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivCrossSectionPartMgr::calculateEclipseTextureCoordinates(cvf::Vec2fArray* textureCoords,
|
||||
void RivIntersectionPartMgr::calculateEclipseTextureCoordinates(cvf::Vec2fArray* textureCoords,
|
||||
const std::vector<size_t>& triangleToCellIdxMap,
|
||||
const RigResultAccessor* resultAccessor,
|
||||
const cvf::ScalarMapper* mapper)
|
||||
@@ -278,7 +278,7 @@ const int priMesh = 3;
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivCrossSectionPartMgr::generatePartGeometry()
|
||||
void RivIntersectionPartMgr::generatePartGeometry()
|
||||
{
|
||||
if (m_crossSectionGenerator.isNull()) return;
|
||||
|
||||
@@ -300,7 +300,7 @@ void RivCrossSectionPartMgr::generatePartGeometry()
|
||||
part->setDrawable(geo.p());
|
||||
|
||||
// Set mapping from triangle face index to cell index
|
||||
cvf::ref<RivCrossSectionSourceInfo> si = new RivCrossSectionSourceInfo(m_crossSectionGenerator.p());
|
||||
cvf::ref<RivIntersectionSourceInfo> si = new RivIntersectionSourceInfo(m_crossSectionGenerator.p());
|
||||
part->setSourceInfo(si.p());
|
||||
|
||||
part->updateBoundingBox();
|
||||
@@ -338,7 +338,7 @@ void RivCrossSectionPartMgr::generatePartGeometry()
|
||||
m_highlightLineAlongPolyline = NULL;
|
||||
m_highlightPointsForPolyline = NULL;
|
||||
|
||||
if (m_rimCrossSection->type == RimCrossSection::CS_POLYLINE)
|
||||
if (m_rimCrossSection->type == RimIntersection::CS_POLYLINE)
|
||||
{
|
||||
{
|
||||
cvf::ref<cvf::DrawableGeo> polylineGeo = m_crossSectionGenerator->createLineAlongPolylineDrawable();
|
||||
@@ -416,7 +416,7 @@ void RivCrossSectionPartMgr::generatePartGeometry()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivCrossSectionPartMgr::updatePartEffect()
|
||||
void RivIntersectionPartMgr::updatePartEffect()
|
||||
{
|
||||
if (m_crossSectionGenerator.isNull()) return;
|
||||
|
||||
@@ -447,7 +447,7 @@ void RivCrossSectionPartMgr::updatePartEffect()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivCrossSectionPartMgr::appendNativeCrossSectionFacesToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform)
|
||||
void RivIntersectionPartMgr::appendNativeCrossSectionFacesToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform)
|
||||
{
|
||||
if (m_crossSectionFaces.isNull())
|
||||
{
|
||||
@@ -465,7 +465,7 @@ void RivCrossSectionPartMgr::appendNativeCrossSectionFacesToModel(cvf::ModelBasi
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivCrossSectionPartMgr::appendMeshLinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform)
|
||||
void RivIntersectionPartMgr::appendMeshLinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform)
|
||||
{
|
||||
if (m_crossSectionGridLines.isNull())
|
||||
{
|
||||
@@ -483,7 +483,7 @@ void RivCrossSectionPartMgr::appendMeshLinePartsToModel(cvf::ModelBasicList* mod
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivCrossSectionPartMgr::appendPolylinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform)
|
||||
void RivIntersectionPartMgr::appendPolylinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform)
|
||||
{
|
||||
if (m_highlightLineAlongPolyline.notNull())
|
||||
{
|
||||
@@ -500,21 +500,21 @@ void RivCrossSectionPartMgr::appendPolylinePartsToModel(cvf::ModelBasicList* mod
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivCrossSectionPartMgr::computeData()
|
||||
void RivIntersectionPartMgr::computeData()
|
||||
{
|
||||
std::vector< std::vector <cvf::Vec3d> > polyLines = m_rimCrossSection->polyLines();
|
||||
if (polyLines.size() > 0)
|
||||
{
|
||||
cvf::Vec3d direction = extrusionDirection(polyLines[0]);
|
||||
cvf::ref<RivCrossSectionHexGridIntf> hexGrid = createHexGridInterface();
|
||||
m_crossSectionGenerator = new RivCrossSectionGeometryGenerator(m_rimCrossSection, polyLines, direction, hexGrid.p());
|
||||
cvf::ref<RivIntersectionHexGridInterface> hexGrid = createHexGridInterface();
|
||||
m_crossSectionGenerator = new RivIntersectionGeometryGenerator(m_rimCrossSection, polyLines, direction, hexGrid.p());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<RivCrossSectionHexGridIntf> RivCrossSectionPartMgr::createHexGridInterface()
|
||||
cvf::ref<RivIntersectionHexGridInterface> RivIntersectionPartMgr::createHexGridInterface()
|
||||
{
|
||||
|
||||
RimEclipseView* eclipseView;
|
||||
@@ -523,7 +523,7 @@ cvf::ref<RivCrossSectionHexGridIntf> RivCrossSectionPartMgr::createHexGridInterf
|
||||
{
|
||||
RigMainGrid* grid = NULL;
|
||||
grid = eclipseView->eclipseCase()->reservoirData()->mainGrid();
|
||||
return new RivEclipseCrossSectionGrid(grid, eclipseView->currentActiveCellInfo(), m_rimCrossSection->showInactiveCells());
|
||||
return new RivEclipseIntersectionGrid(grid, eclipseView->currentActiveCellInfo(), m_rimCrossSection->showInactiveCells());
|
||||
}
|
||||
|
||||
RimGeoMechView* geoView;
|
||||
@@ -531,7 +531,7 @@ cvf::ref<RivCrossSectionHexGridIntf> RivCrossSectionPartMgr::createHexGridInterf
|
||||
if (geoView)
|
||||
{
|
||||
RigFemPart* femPart = geoView->geoMechCase()->geoMechData()->femParts()->part(0);
|
||||
return new RivFemCrossSectionGrid(femPart);
|
||||
return new RivFemIntersectionGrid(femPart);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -540,13 +540,13 @@ cvf::ref<RivCrossSectionHexGridIntf> RivCrossSectionPartMgr::createHexGridInterf
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Vec3d RivCrossSectionPartMgr::extrusionDirection(const std::vector<cvf::Vec3d>& polyline) const
|
||||
cvf::Vec3d RivIntersectionPartMgr::extrusionDirection(const std::vector<cvf::Vec3d>& polyline) const
|
||||
{
|
||||
CVF_ASSERT(m_rimCrossSection);
|
||||
|
||||
cvf::Vec3d dir = cvf::Vec3d::Z_AXIS;
|
||||
|
||||
if (m_rimCrossSection->direction == RimCrossSection::CS_HORIZONTAL &&
|
||||
if (m_rimCrossSection->direction == RimIntersection::CS_HORIZONTAL &&
|
||||
polyline.size() > 1)
|
||||
{
|
||||
// Use first and last point of polyline to approximate orientation of polyline
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RivCrossSectionGeometryGenerator.h"
|
||||
#include "RivIntersectionGeometryGenerator.h"
|
||||
|
||||
#include "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
@@ -37,17 +37,17 @@ namespace cvf
|
||||
class RigMainGrid;
|
||||
class RimEclipseCellColors;
|
||||
class RimCellEdgeColors;
|
||||
class RimCrossSection;
|
||||
class RimIntersection;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
|
||||
class RivCrossSectionPartMgr : public cvf::Object
|
||||
class RivIntersectionPartMgr : public cvf::Object
|
||||
{
|
||||
public:
|
||||
RivCrossSectionPartMgr(const RimCrossSection* rimCrossSection);
|
||||
RivIntersectionPartMgr(const RimIntersection* rimCrossSection);
|
||||
|
||||
void applySingleColorEffect();
|
||||
void updateCellResultColor(size_t timeStepIndex);
|
||||
@@ -68,19 +68,19 @@ private:
|
||||
const RigResultAccessor* resultAccessor,
|
||||
const cvf::ScalarMapper* mapper);
|
||||
static void calculateGeoMechTextureCoords(cvf::Vec2fArray* textureCoords,
|
||||
const std::vector<RivVertexWeights> &vertexWeights,
|
||||
const std::vector<RivIntersectionVertexWeights> &vertexWeights,
|
||||
const std::vector<float> &resultValues,
|
||||
bool isElementNodalResult,
|
||||
const RigFemPart* femPart,
|
||||
const cvf::ScalarMapper* mapper);
|
||||
cvf::ref<RivCrossSectionHexGridIntf> createHexGridInterface();
|
||||
cvf::ref<RivIntersectionHexGridInterface> createHexGridInterface();
|
||||
private:
|
||||
|
||||
const RimCrossSection* m_rimCrossSection;
|
||||
const RimIntersection* m_rimCrossSection;
|
||||
|
||||
cvf::Color3f m_defaultColor;
|
||||
|
||||
cvf::ref<RivCrossSectionGeometryGenerator> m_crossSectionGenerator;
|
||||
cvf::ref<RivIntersectionGeometryGenerator> m_crossSectionGenerator;
|
||||
cvf::ref<cvf::Part> m_crossSectionFaces;
|
||||
cvf::ref<cvf::Part> m_crossSectionGridLines;
|
||||
cvf::ref<cvf::Vec2fArray> m_crossSectionFacesTextureCoords;
|
||||
@@ -17,15 +17,15 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RivCrossSectionSourceInfo.h"
|
||||
#include "RivIntersectionSourceInfo.h"
|
||||
|
||||
#include "RivCrossSectionGeometryGenerator.h"
|
||||
#include "RivIntersectionGeometryGenerator.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivCrossSectionSourceInfo::RivCrossSectionSourceInfo(RivCrossSectionGeometryGenerator* geometryGenerator)
|
||||
RivIntersectionSourceInfo::RivIntersectionSourceInfo(RivIntersectionGeometryGenerator* geometryGenerator)
|
||||
: m_crossSectionGeometryGenerator(geometryGenerator)
|
||||
{
|
||||
CVF_ASSERT(m_crossSectionGeometryGenerator.notNull());
|
||||
@@ -34,7 +34,7 @@ RivCrossSectionSourceInfo::RivCrossSectionSourceInfo(RivCrossSectionGeometryGene
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<size_t>& RivCrossSectionSourceInfo::triangleToCellIndex() const
|
||||
const std::vector<size_t>& RivIntersectionSourceInfo::triangleToCellIndex() const
|
||||
{
|
||||
CVF_ASSERT(m_crossSectionGeometryGenerator.notNull());
|
||||
|
||||
@@ -44,7 +44,7 @@ const std::vector<size_t>& RivCrossSectionSourceInfo::triangleToCellIndex() cons
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const RimCrossSection* RivCrossSectionSourceInfo::crossSection() const
|
||||
const RimIntersection* RivIntersectionSourceInfo::crossSection() const
|
||||
{
|
||||
return m_crossSectionGeometryGenerator->crossSection();
|
||||
}
|
||||
@@ -23,18 +23,18 @@
|
||||
#include "cvfObject.h"
|
||||
#include "cvfArray.h"
|
||||
|
||||
class RivCrossSectionGeometryGenerator;
|
||||
class RimCrossSection;
|
||||
class RivIntersectionGeometryGenerator;
|
||||
class RimIntersection;
|
||||
|
||||
class RivCrossSectionSourceInfo : public cvf::Object
|
||||
class RivIntersectionSourceInfo : public cvf::Object
|
||||
{
|
||||
public:
|
||||
RivCrossSectionSourceInfo(RivCrossSectionGeometryGenerator* geometryGenerator);
|
||||
RivIntersectionSourceInfo(RivIntersectionGeometryGenerator* geometryGenerator);
|
||||
|
||||
const std::vector<size_t>& triangleToCellIndex() const;
|
||||
|
||||
const RimCrossSection* crossSection() const;
|
||||
const RimIntersection* crossSection() const;
|
||||
|
||||
private:
|
||||
cvf::cref<RivCrossSectionGeometryGenerator> m_crossSectionGeometryGenerator;
|
||||
cvf::cref<RivIntersectionGeometryGenerator> m_crossSectionGeometryGenerator;
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,173 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "cafPdmPointer.h"
|
||||
|
||||
#include "cvfArray.h"
|
||||
#include "cvfBase.h"
|
||||
#include "cvfBoundingBox.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RigMainGrid;
|
||||
class RigActiveCellInfo;
|
||||
class RigResultAccessor;
|
||||
class RimCrossSection;
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class ScalarMapper;
|
||||
class DrawableGeo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
class RivCrossSectionHexGridIntf : public cvf::Object
|
||||
{
|
||||
public:
|
||||
virtual cvf::Vec3d displayOffset() const = 0;
|
||||
virtual cvf::BoundingBox boundingBox() const = 0;
|
||||
virtual void findIntersectingCells(const cvf::BoundingBox& intersectingBB, std::vector<size_t>* intersectedCells) const = 0;
|
||||
virtual bool useCell(size_t cellIndex) const = 0;
|
||||
virtual void cellCornerVertices(size_t cellIndex, cvf::Vec3d cellCorners[8]) const = 0;
|
||||
virtual void cellCornerIndices(size_t cellIndex, size_t cornerIndices[8]) const = 0;
|
||||
};
|
||||
|
||||
|
||||
class RivEclipseCrossSectionGrid : public RivCrossSectionHexGridIntf
|
||||
{
|
||||
public:
|
||||
RivEclipseCrossSectionGrid(const RigMainGrid * mainGrid, const RigActiveCellInfo* activeCellInfo, bool showInactiveCells);
|
||||
|
||||
virtual cvf::Vec3d displayOffset() const;
|
||||
virtual cvf::BoundingBox boundingBox() const;
|
||||
virtual void findIntersectingCells(const cvf::BoundingBox& intersectingBB, std::vector<size_t>* intersectedCells) const;
|
||||
virtual bool useCell(size_t cellIndex) const;
|
||||
virtual void cellCornerVertices(size_t cellIndex, cvf::Vec3d cellCorners[8]) const;
|
||||
virtual void cellCornerIndices(size_t cellIndex, size_t cornerIndices[8]) const;
|
||||
|
||||
private:
|
||||
cvf::cref<RigMainGrid> m_mainGrid;
|
||||
cvf::cref<RigActiveCellInfo> m_activeCellInfo;
|
||||
bool m_showInactiveCells;
|
||||
};
|
||||
|
||||
class RigFemPart;
|
||||
|
||||
class RivFemCrossSectionGrid : public RivCrossSectionHexGridIntf
|
||||
{
|
||||
public:
|
||||
RivFemCrossSectionGrid(const RigFemPart * femPart);
|
||||
|
||||
virtual cvf::Vec3d displayOffset() const;
|
||||
virtual cvf::BoundingBox boundingBox() const;
|
||||
virtual void findIntersectingCells(const cvf::BoundingBox& intersectingBB, std::vector<size_t>* intersectedCells) const;
|
||||
virtual bool useCell(size_t cellIndex) const;
|
||||
virtual void cellCornerVertices(size_t cellIndex, cvf::Vec3d cellCorners[8]) const;
|
||||
virtual void cellCornerIndices(size_t cellIndex, size_t cornerIndices[8]) const;
|
||||
|
||||
private:
|
||||
cvf::cref<RigFemPart> m_femPart;
|
||||
};
|
||||
|
||||
class RivVertexWeights
|
||||
{
|
||||
public:
|
||||
explicit RivVertexWeights(size_t edge1Vx1, size_t edge1Vx2, double normDistFromE1V1,
|
||||
size_t edge2Vx1, size_t edge2Vx2, double normDistFromE2V1,
|
||||
double normDistFromE1Cut) : m_count(4)
|
||||
{
|
||||
m_vxIds[0] = (edge1Vx1);
|
||||
m_vxIds[1] = (edge1Vx2);
|
||||
m_vxIds[2] = (edge2Vx1);
|
||||
m_vxIds[3] = (edge2Vx2);
|
||||
|
||||
m_weights[0] = ((float)(1.0 - normDistFromE1V1 - normDistFromE1Cut + normDistFromE1V1*normDistFromE1Cut));
|
||||
m_weights[1] = ((float)(normDistFromE1V1 - normDistFromE1V1*normDistFromE1Cut));
|
||||
m_weights[2] = ((float)(normDistFromE1Cut - normDistFromE2V1*normDistFromE1Cut));
|
||||
m_weights[3] = ((float)(normDistFromE2V1*normDistFromE1Cut));
|
||||
}
|
||||
|
||||
explicit RivVertexWeights(size_t edge1Vx1, size_t edge1Vx2, double normDistFromE1V1) : m_count(2)
|
||||
{
|
||||
m_vxIds[0] = (edge1Vx1);
|
||||
m_vxIds[1] = (edge1Vx2);
|
||||
|
||||
m_weights[0] = ((float)(1.0 - normDistFromE1V1));
|
||||
m_weights[1] = ((float)(normDistFromE1V1));
|
||||
}
|
||||
|
||||
int size() const { return m_count;}
|
||||
size_t vxId(int idx) const { return m_vxIds[idx];}
|
||||
float weight(int idx)const { return m_weights[idx];}
|
||||
|
||||
private:
|
||||
|
||||
size_t m_vxIds[4];
|
||||
float m_weights[4];
|
||||
int m_count;
|
||||
};
|
||||
|
||||
class RivCrossSectionGeometryGenerator : public cvf::Object
|
||||
{
|
||||
public:
|
||||
RivCrossSectionGeometryGenerator(const RimCrossSection* crossSection,
|
||||
std::vector<std::vector<cvf::Vec3d> > &polylines,
|
||||
const cvf::Vec3d& extrusionDirection,
|
||||
const RivCrossSectionHexGridIntf* grid );
|
||||
|
||||
~RivCrossSectionGeometryGenerator();
|
||||
|
||||
bool isAnyGeometryPresent() const;
|
||||
|
||||
// Generate geometry
|
||||
cvf::ref<cvf::DrawableGeo> generateSurface();
|
||||
cvf::ref<cvf::DrawableGeo> createMeshDrawable();
|
||||
cvf::ref<cvf::DrawableGeo> createLineAlongPolylineDrawable();
|
||||
cvf::ref<cvf::DrawableGeo> createPointsFromPolylineDrawable();
|
||||
|
||||
// Mapping between cells and geometry
|
||||
const std::vector<size_t>& triangleToCellIndex() const;
|
||||
const std::vector<RivVertexWeights>& triangleVxToCellCornerInterpolationWeights() const;
|
||||
|
||||
const RimCrossSection* crossSection() const;
|
||||
|
||||
private:
|
||||
void calculateArrays();
|
||||
static void adjustPolyline(const std::vector<cvf::Vec3d>& polyLine,
|
||||
const cvf::Vec3d extrDir,
|
||||
std::vector<cvf::Vec3d>* adjustedPolyline);
|
||||
|
||||
cvf::cref<RivCrossSectionHexGridIntf> m_hexGrid;
|
||||
const std::vector<std::vector<cvf::Vec3d> > m_polyLines;
|
||||
cvf::Vec3d m_extrusionDirection;
|
||||
|
||||
// Output arrays
|
||||
cvf::ref<cvf::Vec3fArray> m_triangleVxes;
|
||||
cvf::ref<cvf::Vec3fArray> m_cellBorderLineVxes;
|
||||
std::vector<size_t> m_triangleToCellIdxMap;
|
||||
std::vector<RivVertexWeights> m_triVxToCellCornerWeights;
|
||||
|
||||
const RimCrossSection* m_crossSection;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user