mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4683 clang-format on all files in ApplicationCode
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -22,22 +22,20 @@
|
||||
#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)
|
||||
RivEclipseIntersectionGrid::RivEclipseIntersectionGrid( const RigMainGrid* mainGrid,
|
||||
const RigActiveCellInfo* activeCellInfo,
|
||||
bool showInactiveCells )
|
||||
: m_mainGrid( mainGrid )
|
||||
, m_activeCellInfo( activeCellInfo )
|
||||
, m_showInactiveCells( showInactiveCells )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Vec3d RivEclipseIntersectionGrid::displayOffset() const
|
||||
{
|
||||
@@ -45,7 +43,7 @@ cvf::Vec3d RivEclipseIntersectionGrid::displayOffset() const
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::BoundingBox RivEclipseIntersectionGrid::boundingBox() const
|
||||
{
|
||||
@@ -53,65 +51,66 @@ cvf::BoundingBox RivEclipseIntersectionGrid::boundingBox() const
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivEclipseIntersectionGrid::findIntersectingCells(const cvf::BoundingBox& intersectingBB, std::vector<size_t>* intersectedCells) const
|
||||
void RivEclipseIntersectionGrid::findIntersectingCells( const cvf::BoundingBox& intersectingBB,
|
||||
std::vector<size_t>* intersectedCells ) const
|
||||
{
|
||||
m_mainGrid->findIntersectingCells(intersectingBB, intersectedCells);
|
||||
m_mainGrid->findIntersectingCells( intersectingBB, intersectedCells );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RivEclipseIntersectionGrid::useCell(size_t cellIndex) const
|
||||
bool RivEclipseIntersectionGrid::useCell( size_t cellIndex ) const
|
||||
{
|
||||
const RigCell& cell = m_mainGrid->globalCellArray()[cellIndex];
|
||||
if (m_showInactiveCells)
|
||||
return !(cell.isInvalid() || (cell.subGrid() != nullptr));
|
||||
if ( m_showInactiveCells )
|
||||
return !( cell.isInvalid() || ( cell.subGrid() != nullptr ) );
|
||||
else
|
||||
return m_activeCellInfo->isActive(cellIndex) && (cell.subGrid() == nullptr);
|
||||
return m_activeCellInfo->isActive( cellIndex ) && ( cell.subGrid() == nullptr );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivEclipseIntersectionGrid::cellCornerVertices(size_t cellIndex, cvf::Vec3d cellCorners[8]) const
|
||||
void RivEclipseIntersectionGrid::cellCornerVertices( size_t cellIndex, cvf::Vec3d cellCorners[8] ) const
|
||||
{
|
||||
m_mainGrid->cellCornerVertices(cellIndex, cellCorners);
|
||||
m_mainGrid->cellCornerVertices( cellIndex, cellCorners );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivEclipseIntersectionGrid::cellCornerIndices(size_t cellIndex, size_t cornerIndices[8]) const
|
||||
void RivEclipseIntersectionGrid::cellCornerIndices( size_t cellIndex, size_t cornerIndices[8] ) const
|
||||
{
|
||||
const std::array<size_t, 8>& cornerIndicesSource = m_mainGrid->globalCellArray()[cellIndex].cornerIndices();
|
||||
|
||||
for (size_t i = 0; i < 8; i++)
|
||||
for ( size_t i = 0; i < 8; i++ )
|
||||
{
|
||||
cornerIndices[i] = cornerIndicesSource[i];
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const RigFault* RivEclipseIntersectionGrid::findFaultFromCellIndexAndCellFace(size_t reservoirCellIndex,
|
||||
cvf::StructGridInterface::FaceType face) const
|
||||
const RigFault* RivEclipseIntersectionGrid::findFaultFromCellIndexAndCellFace( size_t reservoirCellIndex,
|
||||
cvf::StructGridInterface::FaceType face ) const
|
||||
{
|
||||
return m_mainGrid->findFaultFromCellIndexAndCellFace(reservoirCellIndex, face);
|
||||
return m_mainGrid->findFaultFromCellIndexAndCellFace( reservoirCellIndex, face );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivFemIntersectionGrid::RivFemIntersectionGrid(const RigFemPart * femPart) : m_femPart(femPart)
|
||||
RivFemIntersectionGrid::RivFemIntersectionGrid( const RigFemPart* femPart )
|
||||
: m_femPart( femPart )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Vec3d RivFemIntersectionGrid::displayOffset() const
|
||||
{
|
||||
@@ -119,7 +118,7 @@ cvf::Vec3d RivFemIntersectionGrid::displayOffset() const
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::BoundingBox RivFemIntersectionGrid::boundingBox() const
|
||||
{
|
||||
@@ -127,70 +126,70 @@ cvf::BoundingBox RivFemIntersectionGrid::boundingBox() const
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFemIntersectionGrid::findIntersectingCells(const cvf::BoundingBox& intersectingBB, std::vector<size_t>* intersectedCells) const
|
||||
void RivFemIntersectionGrid::findIntersectingCells( const cvf::BoundingBox& intersectingBB,
|
||||
std::vector<size_t>* intersectedCells ) const
|
||||
{
|
||||
m_femPart->findIntersectingCells(intersectingBB, intersectedCells);
|
||||
m_femPart->findIntersectingCells( intersectingBB, intersectedCells );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RivFemIntersectionGrid::useCell(size_t cellIndex) const
|
||||
bool RivFemIntersectionGrid::useCell( size_t cellIndex ) const
|
||||
{
|
||||
RigElementType elmType = m_femPart->elementType(cellIndex);
|
||||
RigElementType elmType = m_femPart->elementType( cellIndex );
|
||||
|
||||
if (!(elmType == HEX8 || elmType == HEX8P)) return false;
|
||||
if ( !( elmType == HEX8 || elmType == HEX8P ) ) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFemIntersectionGrid::cellCornerVertices(size_t cellIndex, cvf::Vec3d cellCorners[8]) const
|
||||
void RivFemIntersectionGrid::cellCornerVertices( size_t cellIndex, cvf::Vec3d cellCorners[8] ) const
|
||||
{
|
||||
RigElementType elmType = m_femPart->elementType(cellIndex);
|
||||
if (!(elmType == HEX8 || elmType == HEX8P)) return;
|
||||
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);
|
||||
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]]);
|
||||
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
|
||||
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);
|
||||
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 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const RigFault* RivFemIntersectionGrid::findFaultFromCellIndexAndCellFace(size_t reservoirCellIndex,
|
||||
cvf::StructGridInterface::FaceType face) const
|
||||
const RigFault* RivFemIntersectionGrid::findFaultFromCellIndexAndCellFace( size_t reservoirCellIndex,
|
||||
cvf::StructGridInterface::FaceType face ) const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,32 +1,31 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "cvfBoundingBox.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cvfVector3.h"
|
||||
#include "cvfBoundingBox.h"
|
||||
|
||||
#include "cvfStructGrid.h"
|
||||
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include <vector>
|
||||
|
||||
class RigActiveCellInfo;
|
||||
class RigFemPart;
|
||||
@@ -39,157 +38,188 @@ class RigFault;
|
||||
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;
|
||||
virtual const RigFault* findFaultFromCellIndexAndCellFace(size_t reservoirCellIndex,
|
||||
cvf::StructGridInterface::FaceType face) const = 0;
|
||||
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;
|
||||
virtual const RigFault* findFaultFromCellIndexAndCellFace( size_t reservoirCellIndex,
|
||||
cvf::StructGridInterface::FaceType face ) const = 0;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RivEclipseIntersectionGrid : public RivIntersectionHexGridInterface
|
||||
{
|
||||
public:
|
||||
RivEclipseIntersectionGrid(const RigMainGrid * mainGrid, const RigActiveCellInfo* activeCellInfo, bool showInactiveCells);
|
||||
RivEclipseIntersectionGrid( const RigMainGrid* mainGrid,
|
||||
const RigActiveCellInfo* activeCellInfo,
|
||||
bool showInactiveCells );
|
||||
|
||||
cvf::Vec3d displayOffset() const override;
|
||||
cvf::Vec3d displayOffset() const override;
|
||||
cvf::BoundingBox boundingBox() const override;
|
||||
void findIntersectingCells(const cvf::BoundingBox& intersectingBB, std::vector<size_t>* intersectedCells) const override;
|
||||
bool useCell(size_t cellIndex) const override;
|
||||
void cellCornerVertices(size_t cellIndex, cvf::Vec3d cellCorners[8]) const override;
|
||||
void cellCornerIndices(size_t cellIndex, size_t cornerIndices[8]) const override;
|
||||
const RigFault* findFaultFromCellIndexAndCellFace(size_t reservoirCellIndex,
|
||||
cvf::StructGridInterface::FaceType face) const override;
|
||||
void findIntersectingCells( const cvf::BoundingBox& intersectingBB,
|
||||
std::vector<size_t>* intersectedCells ) const override;
|
||||
bool useCell( size_t cellIndex ) const override;
|
||||
void cellCornerVertices( size_t cellIndex, cvf::Vec3d cellCorners[8] ) const override;
|
||||
void cellCornerIndices( size_t cellIndex, size_t cornerIndices[8] ) const override;
|
||||
const RigFault* findFaultFromCellIndexAndCellFace( size_t reservoirCellIndex,
|
||||
cvf::StructGridInterface::FaceType face ) const override;
|
||||
|
||||
private:
|
||||
cvf::cref<RigMainGrid> m_mainGrid;
|
||||
cvf::cref<RigActiveCellInfo> m_activeCellInfo;
|
||||
bool m_showInactiveCells;
|
||||
bool m_showInactiveCells;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RivFemIntersectionGrid : public RivIntersectionHexGridInterface
|
||||
{
|
||||
public:
|
||||
explicit RivFemIntersectionGrid(const RigFemPart * femPart);
|
||||
explicit RivFemIntersectionGrid( const RigFemPart* femPart );
|
||||
|
||||
cvf::Vec3d displayOffset() const override;
|
||||
cvf::Vec3d displayOffset() const override;
|
||||
cvf::BoundingBox boundingBox() const override;
|
||||
void findIntersectingCells(const cvf::BoundingBox& intersectingBB, std::vector<size_t>* intersectedCells) const override;
|
||||
bool useCell(size_t cellIndex) const override;
|
||||
void cellCornerVertices(size_t cellIndex, cvf::Vec3d cellCorners[8]) const override;
|
||||
void cellCornerIndices(size_t cellIndex, size_t cornerIndices[8]) const override;
|
||||
const RigFault* findFaultFromCellIndexAndCellFace(size_t reservoirCellIndex,
|
||||
cvf::StructGridInterface::FaceType face) const override;
|
||||
void findIntersectingCells( const cvf::BoundingBox& intersectingBB,
|
||||
std::vector<size_t>* intersectedCells ) const override;
|
||||
bool useCell( size_t cellIndex ) const override;
|
||||
void cellCornerVertices( size_t cellIndex, cvf::Vec3d cellCorners[8] ) const override;
|
||||
void cellCornerIndices( size_t cellIndex, size_t cornerIndices[8] ) const override;
|
||||
const RigFault* findFaultFromCellIndexAndCellFace( size_t reservoirCellIndex,
|
||||
cvf::StructGridInterface::FaceType face ) const override;
|
||||
|
||||
private:
|
||||
cvf::cref<RigFemPart> m_femPart;
|
||||
cvf::cref<RigFemPart> m_femPart;
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RivIntersectionVertexWeights
|
||||
{
|
||||
public:
|
||||
explicit RivIntersectionVertexWeights(): m_count(0) {}
|
||||
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
|
||||
/*
|
||||
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 .
|
||||
Where the k's are normalized distances along the edge, from the edge start vertex .
|
||||
|
||||
This is the interpolation sceme:
|
||||
This is the interpolation sceme:
|
||||
|
||||
v = (1 - k )* v1 + k *v2;
|
||||
v = (1 - k )* v1 + k *v2;
|
||||
|
||||
v1 = (1 - k1 )* v11 + k1*v12;
|
||||
v2 = (1 - k2 )* v21 + k2*v22;
|
||||
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;
|
||||
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.
|
||||
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,
|
||||
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)
|
||||
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_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));
|
||||
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)
|
||||
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_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));
|
||||
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)
|
||||
explicit RivIntersectionVertexWeights( size_t edge1Vx1, size_t edge1Vx2, double normDistFromE1V1 )
|
||||
: m_count( 2 )
|
||||
{
|
||||
m_vxIds[0] = (edge1Vx1);
|
||||
m_vxIds[1] = (edge1Vx2);
|
||||
m_vxIds[0] = ( edge1Vx1 );
|
||||
m_vxIds[1] = ( edge1Vx2 );
|
||||
|
||||
m_weights[0] = ((float)(1.0 - normDistFromE1V1));
|
||||
m_weights[1] = ((float)(normDistFromE1V1));
|
||||
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]; }
|
||||
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:
|
||||
std::array<size_t, 8> m_vxIds;
|
||||
std::array<float, 8> m_weights;
|
||||
int m_count;
|
||||
std::array<float, 8> m_weights;
|
||||
int m_count;
|
||||
};
|
||||
|
||||
@@ -1,56 +1,54 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// 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"
|
||||
#include "cvfDrawableGeo.h"
|
||||
#include "cvfPlane.h"
|
||||
#include "cvfPrimitiveSetDirect.h"
|
||||
#include "cvfStructGrid.h"
|
||||
#include <array>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivIntersectionBoxGeometryGenerator::RivIntersectionBoxGeometryGenerator(RimIntersectionBox* intersectionBox, const RivIntersectionHexGridInterface* grid)
|
||||
: m_intersectionBoxDefinition(intersectionBox),
|
||||
m_hexGrid(grid)
|
||||
RivIntersectionBoxGeometryGenerator::RivIntersectionBoxGeometryGenerator( RimIntersectionBox* intersectionBox,
|
||||
const RivIntersectionHexGridInterface* grid )
|
||||
: m_intersectionBoxDefinition( intersectionBox )
|
||||
, m_hexGrid( grid )
|
||||
{
|
||||
m_triangleVxes = new cvf::Vec3fArray;
|
||||
m_triangleVxes = new cvf::Vec3fArray;
|
||||
m_cellBorderLineVxes = new cvf::Vec3fArray;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivIntersectionBoxGeometryGenerator::~RivIntersectionBoxGeometryGenerator()
|
||||
{
|
||||
|
||||
}
|
||||
RivIntersectionBoxGeometryGenerator::~RivIntersectionBoxGeometryGenerator() {}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RivIntersectionBoxGeometryGenerator::isAnyGeometryPresent() const
|
||||
{
|
||||
if (m_triangleVxes->size() == 0)
|
||||
if ( m_triangleVxes->size() == 0 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -61,70 +59,70 @@ bool RivIntersectionBoxGeometryGenerator::isAnyGeometryPresent() const
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo> RivIntersectionBoxGeometryGenerator::generateSurface()
|
||||
{
|
||||
calculateArrays();
|
||||
|
||||
CVF_ASSERT(m_triangleVxes.notNull());
|
||||
CVF_ASSERT( m_triangleVxes.notNull() );
|
||||
|
||||
if (m_triangleVxes->size() == 0) return nullptr;
|
||||
if ( m_triangleVxes->size() == 0 ) return nullptr;
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
|
||||
geo->setFromTriangleVertexArray(m_triangleVxes.p());
|
||||
geo->setFromTriangleVertexArray( m_triangleVxes.p() );
|
||||
|
||||
return geo;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo> RivIntersectionBoxGeometryGenerator::createMeshDrawable()
|
||||
{
|
||||
if (!(m_cellBorderLineVxes.notNull() && m_cellBorderLineVxes->size() != 0)) return nullptr;
|
||||
if ( !( m_cellBorderLineVxes.notNull() && m_cellBorderLineVxes->size() != 0 ) ) return nullptr;
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
|
||||
geo->setVertexArray(m_cellBorderLineVxes.p());
|
||||
geo->setVertexArray( m_cellBorderLineVxes.p() );
|
||||
|
||||
cvf::ref<cvf::PrimitiveSetDirect> prim = new cvf::PrimitiveSetDirect( cvf::PT_LINES );
|
||||
prim->setIndexCount( m_cellBorderLineVxes->size() );
|
||||
|
||||
cvf::ref<cvf::PrimitiveSetDirect> prim = new cvf::PrimitiveSetDirect(cvf::PT_LINES);
|
||||
prim->setIndexCount(m_cellBorderLineVxes->size());
|
||||
|
||||
geo->addPrimitiveSet(prim.p());
|
||||
geo->addPrimitiveSet( prim.p() );
|
||||
return geo;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<size_t>& RivIntersectionBoxGeometryGenerator::triangleToCellIndex() const
|
||||
{
|
||||
CVF_ASSERT(m_triangleVxes->size());
|
||||
CVF_ASSERT( m_triangleVxes->size() );
|
||||
return m_triangleToCellIdxMap;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<RivIntersectionVertexWeights>& RivIntersectionBoxGeometryGenerator::triangleVxToCellCornerInterpolationWeights() const
|
||||
const std::vector<RivIntersectionVertexWeights>&
|
||||
RivIntersectionBoxGeometryGenerator::triangleVxToCellCornerInterpolationWeights() const
|
||||
{
|
||||
CVF_ASSERT(m_triangleVxes->size());
|
||||
CVF_ASSERT( m_triangleVxes->size() );
|
||||
return m_triVxToCellCornerWeights;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const cvf::Vec3fArray* RivIntersectionBoxGeometryGenerator::triangleVxes() const
|
||||
{
|
||||
CVF_ASSERT(m_triangleVxes->size());
|
||||
CVF_ASSERT( m_triangleVxes->size() );
|
||||
|
||||
return m_triangleVxes.p();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
class Box
|
||||
@@ -132,68 +130,75 @@ class Box
|
||||
public:
|
||||
using FaceType = cvf::StructGridInterface::FaceType;
|
||||
|
||||
Box(const cvf::Mat4d& origin, const cvf::Vec3d& size) : m_origin(origin), m_size(size) {}
|
||||
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)));
|
||||
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> 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] ;
|
||||
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)
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
@@ -201,16 +206,16 @@ public:
|
||||
|
||||
// Returns the four adjacent faces in the Pos, Neg, Pos, Neg order
|
||||
|
||||
std::array<FaceType, 4> adjacentFaces(FaceType face)
|
||||
std::array<FaceType, 4> adjacentFaces( FaceType face )
|
||||
{
|
||||
std::array<FaceType, 4> clipFaces = {FaceType::NO_FACE, FaceType::NO_FACE, FaceType::NO_FACE, FaceType::NO_FACE} ;
|
||||
FaceType oppFace = cvf::StructGridInterface::oppositeFace(face);
|
||||
int clipFaceCount = 0;
|
||||
for (int faceCand = 0; faceCand < 6; ++faceCand )
|
||||
std::array<FaceType, 4> clipFaces = {FaceType::NO_FACE, FaceType::NO_FACE, FaceType::NO_FACE, FaceType::NO_FACE};
|
||||
FaceType oppFace = cvf::StructGridInterface::oppositeFace( face );
|
||||
int clipFaceCount = 0;
|
||||
for ( int faceCand = 0; faceCand < 6; ++faceCand )
|
||||
{
|
||||
if (faceCand != face && faceCand != oppFace)
|
||||
if ( faceCand != face && faceCand != oppFace )
|
||||
{
|
||||
clipFaces[clipFaceCount] = (FaceType) faceCand;
|
||||
clipFaces[clipFaceCount] = (FaceType)faceCand;
|
||||
clipFaceCount++;
|
||||
}
|
||||
}
|
||||
@@ -219,13 +224,12 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
cvf::Mat4d m_origin;
|
||||
cvf::Vec3d m_size;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimIntersectionBox* RivIntersectionBoxGeometryGenerator::intersectionBox() const
|
||||
{
|
||||
@@ -233,32 +237,33 @@ RimIntersectionBox* RivIntersectionBoxGeometryGenerator::intersectionBox() const
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivIntersectionBoxGeometryGenerator::calculateArrays()
|
||||
{
|
||||
if(m_triangleVxes->size()) return;
|
||||
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();
|
||||
cvf::Vec3d displayOffset = m_hexGrid->displayOffset();
|
||||
cvf::BoundingBox gridBBox = m_hexGrid->boundingBox();
|
||||
|
||||
Box box(m_intersectionBoxDefinition->boxOrigin(), m_intersectionBoxDefinition->boxSize());
|
||||
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;
|
||||
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)
|
||||
for ( int faceIdx = startFace; faceIdx <= endFace; ++faceIdx )
|
||||
{
|
||||
cvf::Plane plane = boxPlanes[faceIdx];
|
||||
|
||||
std::array<Box::FaceType, 4> clipFaces = box.adjacentFaces((Box::FaceType)faceIdx);
|
||||
|
||||
std::array<Box::FaceType, 4> clipFaces = box.adjacentFaces( (Box::FaceType)faceIdx );
|
||||
|
||||
cvf::Plane p1Plane = boxPlanes[clipFaces[1]];
|
||||
cvf::Plane p2Plane = boxPlanes[clipFaces[0]];
|
||||
@@ -270,130 +275,145 @@ void RivIntersectionBoxGeometryGenerator::calculateArrays()
|
||||
p3Plane.flip();
|
||||
p4Plane.flip();
|
||||
|
||||
std::array<cvf::Vec3d, 4> faceCorners = box.faceCorners((Box::FaceType)faceIdx);
|
||||
std::array<cvf::Vec3d, 4> faceCorners = box.faceCorners( (Box::FaceType)faceIdx );
|
||||
|
||||
cvf::BoundingBox sectionBBox;
|
||||
|
||||
for (cvf::Vec3d& corner : faceCorners) sectionBBox.add(corner);
|
||||
|
||||
for ( cvf::Vec3d& corner : faceCorners )
|
||||
sectionBBox.add( corner );
|
||||
|
||||
// Similar code as IntersectionGenerator :
|
||||
|
||||
std::vector<size_t> columnCellCandidates;
|
||||
m_hexGrid->findIntersectingCells(sectionBBox, &columnCellCandidates);
|
||||
m_hexGrid->findIntersectingCells( sectionBBox, &columnCellCandidates );
|
||||
|
||||
std::vector<caf::HexGridIntersectionTools::ClipVx> hexPlaneCutTriangleVxes;
|
||||
hexPlaneCutTriangleVxes.reserve(5*3);
|
||||
hexPlaneCutTriangleVxes.reserve( 5 * 3 );
|
||||
std::vector<int> cellFaceForEachTriangleEdge;
|
||||
cellFaceForEachTriangleEdge.reserve(5*3);
|
||||
cellFaceForEachTriangleEdge.reserve( 5 * 3 );
|
||||
cvf::Vec3d cellCorners[8];
|
||||
size_t cornerIndices[8];
|
||||
size_t cornerIndices[8];
|
||||
|
||||
for(size_t cccIdx = 0; cccIdx < columnCellCandidates.size(); ++cccIdx)
|
||||
for ( size_t cccIdx = 0; cccIdx < columnCellCandidates.size(); ++cccIdx )
|
||||
{
|
||||
size_t globalCellIdx = columnCellCandidates[cccIdx];
|
||||
|
||||
if(!m_hexGrid->useCell(globalCellIdx)) continue;
|
||||
if ( !m_hexGrid->useCell( globalCellIdx ) ) continue;
|
||||
|
||||
hexPlaneCutTriangleVxes.clear();
|
||||
m_hexGrid->cellCornerVertices(globalCellIdx, cellCorners);
|
||||
m_hexGrid->cellCornerIndices(globalCellIdx, cornerIndices);
|
||||
m_hexGrid->cellCornerVertices( globalCellIdx, cellCorners );
|
||||
m_hexGrid->cellCornerIndices( globalCellIdx, cornerIndices );
|
||||
|
||||
caf::HexGridIntersectionTools::planeHexIntersectionMC(plane,
|
||||
cellCorners,
|
||||
cornerIndices,
|
||||
&hexPlaneCutTriangleVxes,
|
||||
&cellFaceForEachTriangleEdge);
|
||||
caf::HexGridIntersectionTools::planeHexIntersectionMC( plane,
|
||||
cellCorners,
|
||||
cornerIndices,
|
||||
&hexPlaneCutTriangleVxes,
|
||||
&cellFaceForEachTriangleEdge );
|
||||
|
||||
std::vector<caf::HexGridIntersectionTools::ClipVx> clippedTriangleVxes_once;
|
||||
std::vector<int> cellFaceForEachClippedTriangleEdge_once;
|
||||
caf::HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(hexPlaneCutTriangleVxes, cellFaceForEachTriangleEdge, p1Plane, p2Plane,
|
||||
&clippedTriangleVxes_once, &cellFaceForEachClippedTriangleEdge_once);
|
||||
std::vector<int> cellFaceForEachClippedTriangleEdge_once;
|
||||
caf::HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes( hexPlaneCutTriangleVxes,
|
||||
cellFaceForEachTriangleEdge,
|
||||
p1Plane,
|
||||
p2Plane,
|
||||
&clippedTriangleVxes_once,
|
||||
&cellFaceForEachClippedTriangleEdge_once );
|
||||
|
||||
for (caf::HexGridIntersectionTools::ClipVx& clvx : clippedTriangleVxes_once) if (!clvx.isVxIdsNative) clvx.derivedVxLevel = 0;
|
||||
for ( caf::HexGridIntersectionTools::ClipVx& clvx : clippedTriangleVxes_once )
|
||||
if ( !clvx.isVxIdsNative ) clvx.derivedVxLevel = 0;
|
||||
|
||||
std::vector<caf::HexGridIntersectionTools::ClipVx> clippedTriangleVxes;
|
||||
std::vector<int> cellFaceForEachClippedTriangleEdge;
|
||||
std::vector<int> cellFaceForEachClippedTriangleEdge;
|
||||
|
||||
caf::HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(clippedTriangleVxes_once, cellFaceForEachClippedTriangleEdge_once, p3Plane, p4Plane,
|
||||
&clippedTriangleVxes, &cellFaceForEachClippedTriangleEdge);
|
||||
for (caf::HexGridIntersectionTools::ClipVx& clvx : clippedTriangleVxes) if (!clvx.isVxIdsNative && clvx.derivedVxLevel == -1) clvx.derivedVxLevel = 1;
|
||||
caf::HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes( clippedTriangleVxes_once,
|
||||
cellFaceForEachClippedTriangleEdge_once,
|
||||
p3Plane,
|
||||
p4Plane,
|
||||
&clippedTriangleVxes,
|
||||
&cellFaceForEachClippedTriangleEdge );
|
||||
for ( caf::HexGridIntersectionTools::ClipVx& clvx : clippedTriangleVxes )
|
||||
if ( !clvx.isVxIdsNative && clvx.derivedVxLevel == -1 ) clvx.derivedVxLevel = 1;
|
||||
|
||||
size_t clippedTriangleCount = clippedTriangleVxes.size()/3;
|
||||
size_t clippedTriangleCount = clippedTriangleVxes.size() / 3;
|
||||
|
||||
for(uint tIdx = 0; tIdx < clippedTriangleCount; ++tIdx)
|
||||
for ( uint tIdx = 0; tIdx < clippedTriangleCount; ++tIdx )
|
||||
{
|
||||
uint triVxIdx = tIdx*3;
|
||||
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);
|
||||
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
|
||||
|
||||
#define isFace( faceEnum ) (0 <= faceEnum && faceEnum <= 5 )
|
||||
|
||||
if(isFace(cellFaceForEachClippedTriangleEdge[triVxIdx]))
|
||||
#define isFace( faceEnum ) ( 0 <= faceEnum && faceEnum <= 5 )
|
||||
|
||||
if ( isFace( cellFaceForEachClippedTriangleEdge[triVxIdx] ) )
|
||||
{
|
||||
cellBorderLineVxes.push_back(p0);
|
||||
cellBorderLineVxes.push_back(p1);
|
||||
cellBorderLineVxes.push_back( p0 );
|
||||
cellBorderLineVxes.push_back( p1 );
|
||||
}
|
||||
if(isFace(cellFaceForEachClippedTriangleEdge[triVxIdx+1]))
|
||||
if ( isFace( cellFaceForEachClippedTriangleEdge[triVxIdx + 1] ) )
|
||||
{
|
||||
cellBorderLineVxes.push_back(p1);
|
||||
cellBorderLineVxes.push_back(p2);
|
||||
cellBorderLineVxes.push_back( p1 );
|
||||
cellBorderLineVxes.push_back( p2 );
|
||||
}
|
||||
if(isFace(cellFaceForEachClippedTriangleEdge[triVxIdx+2]))
|
||||
if ( isFace( cellFaceForEachClippedTriangleEdge[triVxIdx + 2] ) )
|
||||
{
|
||||
cellBorderLineVxes.push_back(p2);
|
||||
cellBorderLineVxes.push_back(p0);
|
||||
cellBorderLineVxes.push_back( p2 );
|
||||
cellBorderLineVxes.push_back( p0 );
|
||||
}
|
||||
|
||||
// Mapping to cell index
|
||||
|
||||
m_triangleToCellIdxMap.push_back(globalCellIdx);
|
||||
m_triangleToCellIdxMap.push_back( globalCellIdx );
|
||||
|
||||
// Interpolation from nodes
|
||||
for(int i = 0; i < 3; ++i)
|
||||
for ( int i = 0; i < 3; ++i )
|
||||
{
|
||||
caf::HexGridIntersectionTools::ClipVx cvx = clippedTriangleVxes[triVxIdx + i];
|
||||
if(cvx.isVxIdsNative)
|
||||
if ( cvx.isVxIdsNative )
|
||||
{
|
||||
m_triVxToCellCornerWeights.push_back(
|
||||
RivIntersectionVertexWeights(cvx.clippedEdgeVx1Id, cvx.clippedEdgeVx2Id, cvx.normDistFromEdgeVx1));
|
||||
m_triVxToCellCornerWeights.push_back( RivIntersectionVertexWeights( cvx.clippedEdgeVx1Id,
|
||||
cvx.clippedEdgeVx2Id,
|
||||
cvx.normDistFromEdgeVx1 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
caf::HexGridIntersectionTools::ClipVx cvx1;
|
||||
caf::HexGridIntersectionTools::ClipVx cvx2;
|
||||
|
||||
if (cvx.derivedVxLevel == 0)
|
||||
|
||||
if ( cvx.derivedVxLevel == 0 )
|
||||
{
|
||||
cvx1 = hexPlaneCutTriangleVxes[cvx.clippedEdgeVx1Id];
|
||||
cvx2 = hexPlaneCutTriangleVxes[cvx.clippedEdgeVx2Id];
|
||||
}
|
||||
else if(cvx.derivedVxLevel == 1)
|
||||
else if ( cvx.derivedVxLevel == 1 )
|
||||
{
|
||||
cvx1 = clippedTriangleVxes_once[cvx.clippedEdgeVx1Id];
|
||||
cvx2 = clippedTriangleVxes_once[cvx.clippedEdgeVx2Id];
|
||||
}
|
||||
else
|
||||
{
|
||||
CVF_ASSERT(false);
|
||||
CVF_ASSERT( false );
|
||||
}
|
||||
|
||||
if(cvx1.isVxIdsNative && cvx2.isVxIdsNative)
|
||||
if ( cvx1.isVxIdsNative && cvx2.isVxIdsNative )
|
||||
{
|
||||
m_triVxToCellCornerWeights.push_back(
|
||||
RivIntersectionVertexWeights(cvx1.clippedEdgeVx1Id, cvx1.clippedEdgeVx2Id, cvx1.normDistFromEdgeVx1,
|
||||
cvx2.clippedEdgeVx1Id, cvx2.clippedEdgeVx2Id, cvx2.normDistFromEdgeVx1,
|
||||
cvx.normDistFromEdgeVx1));
|
||||
RivIntersectionVertexWeights( cvx1.clippedEdgeVx1Id,
|
||||
cvx1.clippedEdgeVx2Id,
|
||||
cvx1.normDistFromEdgeVx1,
|
||||
cvx2.clippedEdgeVx1Id,
|
||||
cvx2.clippedEdgeVx2Id,
|
||||
cvx2.normDistFromEdgeVx1,
|
||||
cvx.normDistFromEdgeVx1 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -402,68 +422,71 @@ void RivIntersectionBoxGeometryGenerator::calculateArrays()
|
||||
caf::HexGridIntersectionTools::ClipVx cvx21;
|
||||
caf::HexGridIntersectionTools::ClipVx cvx22;
|
||||
|
||||
if(cvx1.isVxIdsNative)
|
||||
if ( cvx1.isVxIdsNative )
|
||||
{
|
||||
cvx11 = cvx1;
|
||||
cvx12 = cvx1;
|
||||
}
|
||||
else if(cvx1.derivedVxLevel == 0)
|
||||
else if ( cvx1.derivedVxLevel == 0 )
|
||||
{
|
||||
cvx11 = hexPlaneCutTriangleVxes[cvx1.clippedEdgeVx1Id];
|
||||
cvx12 = hexPlaneCutTriangleVxes[cvx1.clippedEdgeVx2Id];
|
||||
}
|
||||
else if(cvx2.derivedVxLevel == 1)
|
||||
else if ( cvx2.derivedVxLevel == 1 )
|
||||
{
|
||||
cvx11 = clippedTriangleVxes_once[cvx1.clippedEdgeVx1Id];
|
||||
cvx12 = clippedTriangleVxes_once[cvx1.clippedEdgeVx2Id];
|
||||
}
|
||||
else
|
||||
{
|
||||
CVF_ASSERT(false);
|
||||
CVF_ASSERT( false );
|
||||
}
|
||||
|
||||
|
||||
if(cvx2.isVxIdsNative)
|
||||
if ( cvx2.isVxIdsNative )
|
||||
{
|
||||
cvx21 = cvx2;
|
||||
cvx22 = cvx2;
|
||||
}
|
||||
else if(cvx2.derivedVxLevel == 0)
|
||||
else if ( cvx2.derivedVxLevel == 0 )
|
||||
{
|
||||
cvx21 = hexPlaneCutTriangleVxes[cvx2.clippedEdgeVx1Id];
|
||||
cvx22 = hexPlaneCutTriangleVxes[cvx2.clippedEdgeVx2Id];
|
||||
}
|
||||
else if(cvx2.derivedVxLevel == 1)
|
||||
else if ( cvx2.derivedVxLevel == 1 )
|
||||
{
|
||||
cvx21 = clippedTriangleVxes_once[cvx2.clippedEdgeVx1Id];
|
||||
cvx22 = clippedTriangleVxes_once[cvx2.clippedEdgeVx2Id];
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
CVF_ASSERT(false);
|
||||
CVF_ASSERT( false );
|
||||
}
|
||||
|
||||
CVF_TIGHT_ASSERT(cvx11.isVxIdsNative && cvx12.isVxIdsNative && cvx21.isVxIdsNative && cvx22.isVxIdsNative);
|
||||
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));
|
||||
|
||||
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);
|
||||
m_cellBorderLineVxes->assign( cellBorderLineVxes );
|
||||
m_triangleVxes->assign( triangleVertices );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -33,43 +33,41 @@ class RimIntersectionBox;
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class ScalarMapper;
|
||||
class DrawableGeo;
|
||||
}
|
||||
|
||||
class ScalarMapper;
|
||||
class DrawableGeo;
|
||||
} // namespace cvf
|
||||
|
||||
class RivIntersectionBoxGeometryGenerator : public cvf::Object
|
||||
{
|
||||
public:
|
||||
RivIntersectionBoxGeometryGenerator(RimIntersectionBox* intersectionBox,
|
||||
const RivIntersectionHexGridInterface* grid);
|
||||
RivIntersectionBoxGeometryGenerator( RimIntersectionBox* intersectionBox,
|
||||
const RivIntersectionHexGridInterface* grid );
|
||||
|
||||
~RivIntersectionBoxGeometryGenerator() override;
|
||||
|
||||
bool isAnyGeometryPresent() const;
|
||||
|
||||
// Generate geometry
|
||||
cvf::ref<cvf::DrawableGeo> generateSurface();
|
||||
cvf::ref<cvf::DrawableGeo> createMeshDrawable();
|
||||
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 cvf::Vec3fArray* triangleVxes() const;
|
||||
|
||||
RimIntersectionBox* intersectionBox() const;
|
||||
RimIntersectionBox* intersectionBox() const;
|
||||
|
||||
private:
|
||||
void calculateArrays();
|
||||
void calculateArrays();
|
||||
|
||||
cvf::cref<RivIntersectionHexGridInterface> m_hexGrid;
|
||||
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;
|
||||
cvf::ref<cvf::Vec3fArray> m_triangleVxes;
|
||||
cvf::ref<cvf::Vec3fArray> m_cellBorderLineVxes;
|
||||
std::vector<size_t> m_triangleToCellIdxMap;
|
||||
std::vector<RivIntersectionVertexWeights> m_triVxToCellCornerWeights;
|
||||
|
||||
RimIntersectionBox* m_intersectionBoxDefinition;
|
||||
RimIntersectionBox* m_intersectionBoxDefinition;
|
||||
};
|
||||
|
||||
|
||||
@@ -56,16 +56,16 @@
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivIntersectionBoxPartMgr::RivIntersectionBoxPartMgr(RimIntersectionBox* intersectionBox)
|
||||
: m_rimIntersectionBox(intersectionBox)
|
||||
, m_defaultColor(cvf::Color3::WHITE)
|
||||
RivIntersectionBoxPartMgr::RivIntersectionBoxPartMgr( RimIntersectionBox* intersectionBox )
|
||||
: m_rimIntersectionBox( intersectionBox )
|
||||
, m_defaultColor( cvf::Color3::WHITE )
|
||||
{
|
||||
CVF_ASSERT(m_rimIntersectionBox);
|
||||
CVF_ASSERT( m_rimIntersectionBox );
|
||||
|
||||
m_intersectionBoxFacesTextureCoords = new cvf::Vec2fArray;
|
||||
|
||||
cvf::ref<RivIntersectionHexGridInterface> hexGrid = createHexGridInterface();
|
||||
m_intersectionBoxGenerator = new RivIntersectionBoxGeometryGenerator(m_rimIntersectionBox, hexGrid.p());
|
||||
m_intersectionBoxGenerator = new RivIntersectionBoxGeometryGenerator( m_rimIntersectionBox, hexGrid.p() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -80,139 +80,156 @@ void RivIntersectionBoxPartMgr::applySingleColorEffect()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivIntersectionBoxPartMgr::updateCellResultColor(size_t timeStepIndex)
|
||||
void RivIntersectionBoxPartMgr::updateCellResultColor( size_t timeStepIndex )
|
||||
{
|
||||
if (!m_intersectionBoxGenerator->isAnyGeometryPresent()) return;
|
||||
if ( !m_intersectionBoxGenerator->isAnyGeometryPresent() ) return;
|
||||
|
||||
RimEclipseView* eclipseView;
|
||||
m_rimIntersectionBox->firstAncestorOrThisOfType(eclipseView);
|
||||
m_rimIntersectionBox->firstAncestorOrThisOfType( eclipseView );
|
||||
|
||||
if (eclipseView)
|
||||
if ( eclipseView )
|
||||
{
|
||||
RimEclipseCellColors* cellResultColors = eclipseView->cellResult();
|
||||
CVF_ASSERT(cellResultColors);
|
||||
CVF_ASSERT( cellResultColors );
|
||||
|
||||
// CrossSections
|
||||
if (m_intersectionBoxFaces.notNull())
|
||||
if ( m_intersectionBoxFaces.notNull() )
|
||||
{
|
||||
if (cellResultColors->isTernarySaturationSelected())
|
||||
if ( cellResultColors->isTernarySaturationSelected() )
|
||||
{
|
||||
RivTernaryTextureCoordsCreator texturer(
|
||||
cellResultColors, cellResultColors->ternaryLegendConfig()->scalarMapper(), timeStepIndex);
|
||||
RivTernaryTextureCoordsCreator texturer( cellResultColors,
|
||||
cellResultColors->ternaryLegendConfig()->scalarMapper(),
|
||||
timeStepIndex );
|
||||
|
||||
texturer.createTextureCoords(m_intersectionBoxFacesTextureCoords.p(),
|
||||
m_intersectionBoxGenerator->triangleToCellIndex());
|
||||
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());
|
||||
RivScalarMapperUtils::applyTernaryTextureResultsToPart( m_intersectionBoxFaces.p(),
|
||||
m_intersectionBoxFacesTextureCoords.p(),
|
||||
mapper,
|
||||
1.0,
|
||||
caf::FC_NONE,
|
||||
eclipseView->isLightingDisabled() );
|
||||
}
|
||||
else
|
||||
{
|
||||
CVF_ASSERT(m_intersectionBoxGenerator.notNull());
|
||||
CVF_ASSERT( m_intersectionBoxGenerator.notNull() );
|
||||
|
||||
const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper();
|
||||
cvf::ref<RigResultAccessor> resultAccessor;
|
||||
|
||||
if (RiaDefines::isPerCellFaceResult(cellResultColors->resultVariable()))
|
||||
if ( RiaDefines::isPerCellFaceResult( cellResultColors->resultVariable() ) )
|
||||
{
|
||||
resultAccessor = new RigHugeValResultAccessor;
|
||||
}
|
||||
else
|
||||
{
|
||||
resultAccessor = RigResultAccessorFactory::createFromResultDefinition(
|
||||
cellResultColors->reservoirView()->eclipseCase()->eclipseCaseData(), 0, timeStepIndex, cellResultColors);
|
||||
resultAccessor = RigResultAccessorFactory::createFromResultDefinition( cellResultColors
|
||||
->reservoirView()
|
||||
->eclipseCase()
|
||||
->eclipseCaseData(),
|
||||
0,
|
||||
timeStepIndex,
|
||||
cellResultColors );
|
||||
}
|
||||
|
||||
RivIntersectionPartMgr::calculateEclipseTextureCoordinates(m_intersectionBoxFacesTextureCoords.p(),
|
||||
m_intersectionBoxGenerator->triangleToCellIndex(),
|
||||
resultAccessor.p(),
|
||||
mapper);
|
||||
RivIntersectionPartMgr::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());
|
||||
RivScalarMapperUtils::applyTextureResultsToPart( m_intersectionBoxFaces.p(),
|
||||
m_intersectionBoxFacesTextureCoords.p(),
|
||||
mapper,
|
||||
1.0,
|
||||
caf::FC_NONE,
|
||||
eclipseView->isLightingDisabled() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RimGeoMechView* geoView;
|
||||
m_rimIntersectionBox->firstAncestorOrThisOfType(geoView);
|
||||
m_rimIntersectionBox->firstAncestorOrThisOfType( geoView );
|
||||
|
||||
if (geoView)
|
||||
if ( geoView )
|
||||
{
|
||||
RimGeoMechCellColors* cellResultColors = geoView->cellResult();
|
||||
RigGeoMechCaseData* caseData = cellResultColors->ownerCaseData();
|
||||
|
||||
if (!caseData) return;
|
||||
if ( !caseData ) return;
|
||||
|
||||
RigFemResultAddress resVarAddress = cellResultColors->resultAddress();
|
||||
|
||||
const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper();
|
||||
|
||||
if (resVarAddress.resultPosType == RIG_ELEMENT)
|
||||
if ( resVarAddress.resultPosType == RIG_ELEMENT )
|
||||
{
|
||||
const std::vector<float>& resultValues =
|
||||
caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex);
|
||||
const std::vector<float>& resultValues = caseData->femPartResults()->resultValues( resVarAddress,
|
||||
0,
|
||||
(int)timeStepIndex );
|
||||
const std::vector<size_t>& triangleToCellIdx = m_intersectionBoxGenerator->triangleToCellIndex();
|
||||
|
||||
RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords(
|
||||
m_intersectionBoxFacesTextureCoords.p(), resultValues, triangleToCellIdx, mapper);
|
||||
RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords( m_intersectionBoxFacesTextureCoords.p(),
|
||||
resultValues,
|
||||
triangleToCellIdx,
|
||||
mapper );
|
||||
}
|
||||
else if (resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE)
|
||||
else if ( resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE )
|
||||
{
|
||||
// Special direction sensitive result calculation
|
||||
const cvf::Vec3fArray* triangelVxes = m_intersectionBoxGenerator->triangleVxes();
|
||||
|
||||
if (resVarAddress.componentName == "Pazi" || resVarAddress.componentName == "Pinc")
|
||||
if ( resVarAddress.componentName == "Pazi" || resVarAddress.componentName == "Pinc" )
|
||||
{
|
||||
RivIntersectionPartMgr::calculatePlaneAngleTextureCoords(
|
||||
m_intersectionBoxFacesTextureCoords.p(), triangelVxes, resVarAddress, mapper);
|
||||
RivIntersectionPartMgr::calculatePlaneAngleTextureCoords( m_intersectionBoxFacesTextureCoords.p(),
|
||||
triangelVxes,
|
||||
resVarAddress,
|
||||
mapper );
|
||||
}
|
||||
else
|
||||
{
|
||||
const std::vector<RivIntersectionVertexWeights>& vertexWeights =
|
||||
m_intersectionBoxGenerator->triangleVxToCellCornerInterpolationWeights();
|
||||
|
||||
RivIntersectionPartMgr::calculateGeoMechTensorXfTextureCoords(m_intersectionBoxFacesTextureCoords.p(),
|
||||
triangelVxes,
|
||||
vertexWeights,
|
||||
caseData,
|
||||
resVarAddress,
|
||||
(int)timeStepIndex,
|
||||
mapper);
|
||||
RivIntersectionPartMgr::calculateGeoMechTensorXfTextureCoords( m_intersectionBoxFacesTextureCoords.p(),
|
||||
triangelVxes,
|
||||
vertexWeights,
|
||||
caseData,
|
||||
resVarAddress,
|
||||
(int)timeStepIndex,
|
||||
mapper );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Do a "Hack" to show elm nodal and not nodal POR results
|
||||
if (resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar")
|
||||
if ( resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar" )
|
||||
resVarAddress.resultPosType = RIG_ELEMENT_NODAL;
|
||||
|
||||
const std::vector<float>& resultValues =
|
||||
caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex);
|
||||
RigFemPart* femPart = caseData->femParts()->part(0);
|
||||
bool isElementNodalResult = !(resVarAddress.resultPosType == RIG_NODAL);
|
||||
const std::vector<float>& resultValues = caseData->femPartResults()->resultValues( resVarAddress,
|
||||
0,
|
||||
(int)timeStepIndex );
|
||||
RigFemPart* femPart = caseData->femParts()->part( 0 );
|
||||
bool isElementNodalResult = !( resVarAddress.resultPosType == RIG_NODAL );
|
||||
const std::vector<RivIntersectionVertexWeights>& vertexWeights =
|
||||
m_intersectionBoxGenerator->triangleVxToCellCornerInterpolationWeights();
|
||||
|
||||
RivIntersectionPartMgr::calculateNodeOrElementNodeBasedGeoMechTextureCoords(
|
||||
m_intersectionBoxFacesTextureCoords.p(), vertexWeights, resultValues, isElementNodalResult, femPart, mapper);
|
||||
RivIntersectionPartMgr::calculateNodeOrElementNodeBasedGeoMechTextureCoords( m_intersectionBoxFacesTextureCoords
|
||||
.p(),
|
||||
vertexWeights,
|
||||
resultValues,
|
||||
isElementNodalResult,
|
||||
femPart,
|
||||
mapper );
|
||||
}
|
||||
|
||||
RivScalarMapperUtils::applyTextureResultsToPart(m_intersectionBoxFaces.p(),
|
||||
m_intersectionBoxFacesTextureCoords.p(),
|
||||
mapper,
|
||||
1.0,
|
||||
caf::FC_NONE,
|
||||
geoView->isLightingDisabled());
|
||||
RivScalarMapperUtils::applyTextureResultsToPart( m_intersectionBoxFaces.p(),
|
||||
m_intersectionBoxFacesTextureCoords.p(),
|
||||
mapper,
|
||||
1.0,
|
||||
caf::FC_NONE,
|
||||
geoView->isLightingDisabled() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,26 +242,26 @@ void RivIntersectionBoxPartMgr::generatePartGeometry()
|
||||
// Surface geometry
|
||||
{
|
||||
cvf::ref<cvf::DrawableGeo> geo = m_intersectionBoxGenerator->generateSurface();
|
||||
if (geo.notNull())
|
||||
if ( geo.notNull() )
|
||||
{
|
||||
geo->computeNormals();
|
||||
|
||||
if (useBufferObjects)
|
||||
if ( useBufferObjects )
|
||||
{
|
||||
geo->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT);
|
||||
geo->setRenderMode( cvf::DrawableGeo::BUFFER_OBJECT );
|
||||
}
|
||||
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
part->setName("Intersection Box");
|
||||
part->setDrawable(geo.p());
|
||||
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());
|
||||
cvf::ref<RivIntersectionBoxSourceInfo> si = new RivIntersectionBoxSourceInfo( m_intersectionBoxGenerator.p() );
|
||||
part->setSourceInfo( si.p() );
|
||||
|
||||
part->updateBoundingBox();
|
||||
part->setEnableMask(intersectionCellFaceBit);
|
||||
part->setPriority(RivPartPriority::PartType::Intersection);
|
||||
part->setEnableMask( intersectionCellFaceBit );
|
||||
part->setPriority( RivPartPriority::PartType::Intersection );
|
||||
|
||||
m_intersectionBoxFaces = part;
|
||||
}
|
||||
@@ -253,22 +270,22 @@ void RivIntersectionBoxPartMgr::generatePartGeometry()
|
||||
// Mesh geometry
|
||||
{
|
||||
cvf::ref<cvf::DrawableGeo> geoMesh = m_intersectionBoxGenerator->createMeshDrawable();
|
||||
if (geoMesh.notNull())
|
||||
if ( geoMesh.notNull() )
|
||||
{
|
||||
if (useBufferObjects)
|
||||
if ( useBufferObjects )
|
||||
{
|
||||
geoMesh->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT);
|
||||
geoMesh->setRenderMode( cvf::DrawableGeo::BUFFER_OBJECT );
|
||||
}
|
||||
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
part->setName("Intersection box mesh");
|
||||
part->setDrawable(geoMesh.p());
|
||||
part->setName( "Intersection box mesh" );
|
||||
part->setDrawable( geoMesh.p() );
|
||||
|
||||
part->updateBoundingBox();
|
||||
part->setEnableMask(intersectionCellMeshBit);
|
||||
part->setPriority(RivPartPriority::PartType::MeshLines);
|
||||
part->setEnableMask( intersectionCellMeshBit );
|
||||
part->setPriority( RivPartPriority::PartType::MeshLines );
|
||||
|
||||
part->setSourceInfo(new RivMeshLinesSourceInfo(m_rimIntersectionBox));
|
||||
part->setSourceInfo( new RivMeshLinesSourceInfo( m_rimIntersectionBox ) );
|
||||
|
||||
m_intersectionBoxGridLines = part;
|
||||
}
|
||||
@@ -283,59 +300,60 @@ void RivIntersectionBoxPartMgr::generatePartGeometry()
|
||||
void RivIntersectionBoxPartMgr::updatePartEffect()
|
||||
{
|
||||
// Set deCrossSection effect
|
||||
caf::SurfaceEffectGenerator geometryEffgen(m_defaultColor, caf::PO_1);
|
||||
caf::SurfaceEffectGenerator geometryEffgen( m_defaultColor, caf::PO_1 );
|
||||
|
||||
cvf::ref<cvf::Effect> geometryOnlyEffect = geometryEffgen.generateCachedEffect();
|
||||
|
||||
if (m_intersectionBoxFaces.notNull())
|
||||
if ( m_intersectionBoxFaces.notNull() )
|
||||
{
|
||||
m_intersectionBoxFaces->setEffect(geometryOnlyEffect.p());
|
||||
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());
|
||||
caf::MeshEffectGenerator CrossSectionEffGen( cvf::Color3::WHITE ); // prefs->defaultCrossSectionGridLineColors());
|
||||
eff = CrossSectionEffGen.generateCachedEffect();
|
||||
|
||||
if (m_intersectionBoxGridLines.notNull())
|
||||
if ( m_intersectionBoxGridLines.notNull() )
|
||||
{
|
||||
m_intersectionBoxGridLines->setEffect(eff.p());
|
||||
m_intersectionBoxGridLines->setEffect( eff.p() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivIntersectionBoxPartMgr::appendNativeCrossSectionFacesToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform)
|
||||
void RivIntersectionBoxPartMgr::appendNativeCrossSectionFacesToModel( cvf::ModelBasicList* model,
|
||||
cvf::Transform* scaleTransform )
|
||||
{
|
||||
if (m_intersectionBoxFaces.isNull() && m_intersectionBoxGridLines.isNull())
|
||||
if ( m_intersectionBoxFaces.isNull() && m_intersectionBoxGridLines.isNull() )
|
||||
{
|
||||
generatePartGeometry();
|
||||
}
|
||||
|
||||
if (m_intersectionBoxFaces.notNull())
|
||||
if ( m_intersectionBoxFaces.notNull() )
|
||||
{
|
||||
m_intersectionBoxFaces->setTransform(scaleTransform);
|
||||
model->addPart(m_intersectionBoxFaces.p());
|
||||
m_intersectionBoxFaces->setTransform( scaleTransform );
|
||||
model->addPart( m_intersectionBoxFaces.p() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivIntersectionBoxPartMgr::appendMeshLinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform)
|
||||
void RivIntersectionBoxPartMgr::appendMeshLinePartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform )
|
||||
{
|
||||
if (m_intersectionBoxFaces.isNull() && m_intersectionBoxGridLines.isNull())
|
||||
if ( m_intersectionBoxFaces.isNull() && m_intersectionBoxGridLines.isNull() )
|
||||
{
|
||||
generatePartGeometry();
|
||||
}
|
||||
|
||||
if (m_intersectionBoxGridLines.notNull())
|
||||
if ( m_intersectionBoxGridLines.notNull() )
|
||||
{
|
||||
m_intersectionBoxGridLines->setTransform(scaleTransform);
|
||||
model->addPart(m_intersectionBoxGridLines.p());
|
||||
m_intersectionBoxGridLines->setTransform( scaleTransform );
|
||||
model->addPart( m_intersectionBoxGridLines.p() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,21 +363,22 @@ void RivIntersectionBoxPartMgr::appendMeshLinePartsToModel(cvf::ModelBasicList*
|
||||
cvf::ref<RivIntersectionHexGridInterface> RivIntersectionBoxPartMgr::createHexGridInterface()
|
||||
{
|
||||
RimEclipseView* eclipseView;
|
||||
m_rimIntersectionBox->firstAncestorOrThisOfType(eclipseView);
|
||||
if (eclipseView)
|
||||
m_rimIntersectionBox->firstAncestorOrThisOfType( eclipseView );
|
||||
if ( eclipseView )
|
||||
{
|
||||
RigMainGrid* grid = eclipseView->mainGrid();
|
||||
|
||||
return new RivEclipseIntersectionGrid(
|
||||
grid, eclipseView->currentActiveCellInfo(), m_rimIntersectionBox->showInactiveCells());
|
||||
return new RivEclipseIntersectionGrid( grid,
|
||||
eclipseView->currentActiveCellInfo(),
|
||||
m_rimIntersectionBox->showInactiveCells() );
|
||||
}
|
||||
|
||||
RimGeoMechView* geoView;
|
||||
m_rimIntersectionBox->firstAncestorOrThisOfType(geoView);
|
||||
if (geoView)
|
||||
m_rimIntersectionBox->firstAncestorOrThisOfType( geoView );
|
||||
if ( geoView )
|
||||
{
|
||||
RigFemPart* femPart = geoView->femParts()->part(0);
|
||||
return new RivFemIntersectionGrid(femPart);
|
||||
RigFemPart* femPart = geoView->femParts()->part( 0 );
|
||||
return new RivFemIntersectionGrid( femPart );
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
#include "RivIntersectionBoxGeometryGenerator.h"
|
||||
|
||||
|
||||
#include "cvfObject.h"
|
||||
|
||||
namespace cvf
|
||||
@@ -44,13 +43,13 @@ class RimIntersectionBox;
|
||||
class RivIntersectionBoxPartMgr : public cvf::Object
|
||||
{
|
||||
public:
|
||||
explicit RivIntersectionBoxPartMgr(RimIntersectionBox* intersectionBox);
|
||||
explicit RivIntersectionBoxPartMgr( RimIntersectionBox* intersectionBox );
|
||||
|
||||
void applySingleColorEffect();
|
||||
void updateCellResultColor(size_t timeStepIndex);
|
||||
void updateCellResultColor( size_t timeStepIndex );
|
||||
|
||||
void appendNativeCrossSectionFacesToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform);
|
||||
void appendMeshLinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform);
|
||||
void appendNativeCrossSectionFacesToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform );
|
||||
void appendMeshLinePartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform );
|
||||
|
||||
private:
|
||||
void updatePartEffect();
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -20,44 +20,42 @@
|
||||
|
||||
#include "RivIntersectionBoxGeometryGenerator.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivIntersectionBoxSourceInfo::RivIntersectionBoxSourceInfo(RivIntersectionBoxGeometryGenerator* geometryGenerator)
|
||||
: m_intersectionBoxGeometryGenerator(geometryGenerator)
|
||||
RivIntersectionBoxSourceInfo::RivIntersectionBoxSourceInfo( RivIntersectionBoxGeometryGenerator* geometryGenerator )
|
||||
: m_intersectionBoxGeometryGenerator( geometryGenerator )
|
||||
{
|
||||
CVF_ASSERT(m_intersectionBoxGeometryGenerator.notNull());
|
||||
CVF_ASSERT( m_intersectionBoxGeometryGenerator.notNull() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<size_t>& RivIntersectionBoxSourceInfo::triangleToCellIndex() const
|
||||
{
|
||||
CVF_ASSERT(m_intersectionBoxGeometryGenerator.notNull());
|
||||
CVF_ASSERT( m_intersectionBoxGeometryGenerator.notNull() );
|
||||
|
||||
return m_intersectionBoxGeometryGenerator->triangleToCellIndex();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::array<cvf::Vec3f, 3> RivIntersectionBoxSourceInfo::triangle(int triangleIdx) const
|
||||
std::array<cvf::Vec3f, 3> RivIntersectionBoxSourceInfo::triangle( int triangleIdx ) const
|
||||
{
|
||||
std::array<cvf::Vec3f, 3> tri;
|
||||
tri[0] = (*m_intersectionBoxGeometryGenerator->triangleVxes())[triangleIdx*3];
|
||||
tri[1] = (*m_intersectionBoxGeometryGenerator->triangleVxes())[triangleIdx*3+1];
|
||||
tri[2] = (*m_intersectionBoxGeometryGenerator->triangleVxes())[triangleIdx*3+2];
|
||||
tri[0] = ( *m_intersectionBoxGeometryGenerator->triangleVxes() )[triangleIdx * 3];
|
||||
tri[1] = ( *m_intersectionBoxGeometryGenerator->triangleVxes() )[triangleIdx * 3 + 1];
|
||||
tri[2] = ( *m_intersectionBoxGeometryGenerator->triangleVxes() )[triangleIdx * 3 + 2];
|
||||
|
||||
return tri;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimIntersectionBox* RivIntersectionBoxSourceInfo::intersectionBox() const
|
||||
{
|
||||
return m_intersectionBoxGeometryGenerator->intersectionBox();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +1,25 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "cvfObject.h"
|
||||
#include "cvfArray.h"
|
||||
#include "cvfObject.h"
|
||||
#include <array>
|
||||
|
||||
class RivIntersectionBoxGeometryGenerator;
|
||||
@@ -29,12 +28,12 @@ class RimIntersectionBox;
|
||||
class RivIntersectionBoxSourceInfo : public cvf::Object
|
||||
{
|
||||
public:
|
||||
explicit RivIntersectionBoxSourceInfo(RivIntersectionBoxGeometryGenerator* geometryGenerator);
|
||||
explicit RivIntersectionBoxSourceInfo( RivIntersectionBoxGeometryGenerator* geometryGenerator );
|
||||
|
||||
const std::vector<size_t>& triangleToCellIndex() const;
|
||||
|
||||
std::array<cvf::Vec3f, 3> triangle(int triangleIdx) const;
|
||||
RimIntersectionBox* intersectionBox() const;
|
||||
std::array<cvf::Vec3f, 3> triangle( int triangleIdx ) const;
|
||||
RimIntersectionBox* intersectionBox() const;
|
||||
|
||||
private:
|
||||
cvf::cref<RivIntersectionBoxGeometryGenerator> m_intersectionBoxGeometryGenerator;
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -22,32 +22,31 @@
|
||||
#include "RigMainGrid.h"
|
||||
#include "RigResultAccessor.h"
|
||||
|
||||
#include "RimIntersection.h"
|
||||
#include "Rim3dView.h"
|
||||
#include "RimIntersection.h"
|
||||
|
||||
#include "RivHexGridIntersectionTools.h"
|
||||
#include "RivIntersectionPartMgr.h"
|
||||
#include "RivPolylineGenerator.h"
|
||||
|
||||
#include "cafHexGridIntersectionTools/cafHexGridIntersectionTools.h"
|
||||
#include "cafDisplayCoordTransform.h"
|
||||
#include "cafHexGridIntersectionTools/cafHexGridIntersectionTools.h"
|
||||
|
||||
#include "cvfDrawableGeo.h"
|
||||
#include "cvfGeometryTools.h"
|
||||
#include "cvfPlane.h"
|
||||
#include "cvfPrimitiveSetDirect.h"
|
||||
#include "cvfPrimitiveSetIndexedUInt.h"
|
||||
#include "cvfScalarMapper.h"
|
||||
#include "cvfRay.h"
|
||||
#include "cvfScalarMapper.h"
|
||||
|
||||
#include "RivSectionFlattner.h"
|
||||
|
||||
|
||||
cvf::ref<caf::DisplayCoordTransform> displayCoordTransform(const RimIntersection* intersection)
|
||||
cvf::ref<caf::DisplayCoordTransform> displayCoordTransform( const RimIntersection* intersection )
|
||||
{
|
||||
Rim3dView* rimView = nullptr;
|
||||
intersection->firstAncestorOrThisOfType(rimView);
|
||||
CVF_ASSERT(rimView);
|
||||
intersection->firstAncestorOrThisOfType( rimView );
|
||||
CVF_ASSERT( rimView );
|
||||
|
||||
cvf::ref<caf::DisplayCoordTransform> transForm = rimView->displayCoordTransform();
|
||||
return transForm;
|
||||
@@ -55,274 +54,271 @@ cvf::ref<caf::DisplayCoordTransform> displayCoordTransform(const RimIntersection
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// isFlattened means to transform each flat section of the intersection onto the XZ plane
|
||||
/// placed adjacent to each other as if they were rotated around the common extrusion line like a hinge
|
||||
/// placed adjacent to each other as if they were rotated around the common extrusion line like a hinge
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivIntersectionGeometryGenerator::RivIntersectionGeometryGenerator( RimIntersection* crossSection,
|
||||
std::vector<std::vector<cvf::Vec3d> > &polylines,
|
||||
const cvf::Vec3d& extrusionDirection,
|
||||
RivIntersectionGeometryGenerator::RivIntersectionGeometryGenerator( RimIntersection* crossSection,
|
||||
std::vector<std::vector<cvf::Vec3d>>& polylines,
|
||||
const cvf::Vec3d& extrusionDirection,
|
||||
const RivIntersectionHexGridInterface* grid,
|
||||
bool isFlattened,
|
||||
const cvf::Vec3d& flattenedPolylineStartPoint)
|
||||
: m_crossSection(crossSection),
|
||||
m_polyLines(polylines),
|
||||
m_extrusionDirection(extrusionDirection),
|
||||
m_hexGrid(grid),
|
||||
m_isFlattened(isFlattened),
|
||||
m_flattenedPolylineStartPoint(flattenedPolylineStartPoint)
|
||||
bool isFlattened,
|
||||
const cvf::Vec3d& flattenedPolylineStartPoint )
|
||||
: m_crossSection( crossSection )
|
||||
, m_polyLines( polylines )
|
||||
, m_extrusionDirection( extrusionDirection )
|
||||
, m_hexGrid( grid )
|
||||
, m_isFlattened( isFlattened )
|
||||
, m_flattenedPolylineStartPoint( flattenedPolylineStartPoint )
|
||||
{
|
||||
m_triangleVxes = new cvf::Vec3fArray;
|
||||
m_cellBorderLineVxes = new cvf::Vec3fArray;
|
||||
m_triangleVxes = new cvf::Vec3fArray;
|
||||
m_cellBorderLineVxes = new cvf::Vec3fArray;
|
||||
m_faultCellBorderLineVxes = new cvf::Vec3fArray;
|
||||
|
||||
if (m_isFlattened) m_extrusionDirection = -cvf::Vec3d::Z_AXIS;
|
||||
if ( m_isFlattened ) m_extrusionDirection = -cvf::Vec3d::Z_AXIS;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivIntersectionGeometryGenerator::~RivIntersectionGeometryGenerator()
|
||||
{
|
||||
|
||||
}
|
||||
RivIntersectionGeometryGenerator::~RivIntersectionGeometryGenerator() {}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivIntersectionGeometryGenerator::calculateSegementTransformPrLinePoint()
|
||||
{
|
||||
if ( m_isFlattened )
|
||||
{
|
||||
if ( !(m_polyLines.size() && m_polyLines.back().size()) ) return;
|
||||
if ( !( m_polyLines.size() && m_polyLines.back().size() ) ) return;
|
||||
|
||||
cvf::Vec3d startOffset = m_flattenedPolylineStartPoint;
|
||||
|
||||
for ( size_t pLineIdx = 0; pLineIdx < m_polyLines.size(); ++pLineIdx )
|
||||
{
|
||||
const std::vector<cvf::Vec3d>& polyLine = m_polyLines[pLineIdx];
|
||||
startOffset.z() = polyLine[0].z();
|
||||
m_segementTransformPrLinePoint.emplace_back(RivSectionFlattner::calculateFlatteningCSsForPolyline(polyLine,
|
||||
m_extrusionDirection,
|
||||
startOffset,
|
||||
&startOffset));
|
||||
startOffset.z() = polyLine[0].z();
|
||||
m_segementTransformPrLinePoint.emplace_back(
|
||||
RivSectionFlattner::calculateFlatteningCSsForPolyline( polyLine,
|
||||
m_extrusionDirection,
|
||||
startOffset,
|
||||
&startOffset ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_segementTransformPrLinePoint.clear();
|
||||
|
||||
cvf::Mat4d invSectionCS = cvf::Mat4d::fromTranslation(-m_hexGrid->displayOffset());
|
||||
cvf::Mat4d invSectionCS = cvf::Mat4d::fromTranslation( -m_hexGrid->displayOffset() );
|
||||
|
||||
for ( const auto & polyLine : m_polyLines )
|
||||
for ( const auto& polyLine : m_polyLines )
|
||||
{
|
||||
m_segementTransformPrLinePoint.emplace_back();
|
||||
std::vector<cvf::Mat4d>& segmentTransforms = m_segementTransformPrLinePoint.back();
|
||||
for ( size_t lIdx = 0; lIdx < polyLine.size(); ++lIdx )
|
||||
{
|
||||
segmentTransforms.push_back(invSectionCS);
|
||||
segmentTransforms.push_back( invSectionCS );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivIntersectionGeometryGenerator::calculateFlattenedOrOffsetedPolyline()
|
||||
{
|
||||
CVF_ASSERT(m_segementTransformPrLinePoint.size() == m_polyLines.size());
|
||||
CVF_ASSERT( m_segementTransformPrLinePoint.size() == m_polyLines.size() );
|
||||
|
||||
for ( size_t pLineIdx = 0; pLineIdx < m_polyLines.size(); ++pLineIdx )
|
||||
{
|
||||
m_flattenedOrOffsettedPolyLines.emplace_back();
|
||||
const std::vector<cvf::Vec3d>& polyLine = m_polyLines[pLineIdx];
|
||||
|
||||
CVF_ASSERT(polyLine.size() == m_polyLines[pLineIdx].size());
|
||||
CVF_ASSERT( polyLine.size() == m_polyLines[pLineIdx].size() );
|
||||
|
||||
for ( size_t pIdx = 0; pIdx < polyLine.size(); ++pIdx )
|
||||
{
|
||||
m_flattenedOrOffsettedPolyLines.back().push_back(polyLine[pIdx].getTransformedPoint(m_segementTransformPrLinePoint[pLineIdx][pIdx]));
|
||||
m_flattenedOrOffsettedPolyLines.back().push_back(
|
||||
polyLine[pIdx].getTransformedPoint( m_segementTransformPrLinePoint[pLineIdx][pIdx] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class MeshLinesAccumulator
|
||||
{
|
||||
public:
|
||||
MeshLinesAccumulator(const RivIntersectionHexGridInterface* hexGrid)
|
||||
: m_hexGrid(hexGrid)
|
||||
{}
|
||||
MeshLinesAccumulator( const RivIntersectionHexGridInterface* hexGrid )
|
||||
: m_hexGrid( hexGrid )
|
||||
{
|
||||
}
|
||||
|
||||
std::vector<cvf::Vec3f> cellBorderLineVxes;
|
||||
std::vector<cvf::Vec3f> faultCellBorderLineVxes;
|
||||
std::vector<cvf::Vec3f> cellBorderLineVxes;
|
||||
std::vector<cvf::Vec3f> faultCellBorderLineVxes;
|
||||
std::map<const RigFault*, cvf::Vec3d> faultToHighestFaultMeshVxMap;
|
||||
|
||||
void accumulateMeshLines(const std::vector<int>& cellFaceForEachClippedTriangleEdge,
|
||||
uint triVxIdx,
|
||||
size_t globalCellIdx,
|
||||
const cvf::Vec3d& p0,
|
||||
const cvf::Vec3d& p1)
|
||||
void accumulateMeshLines( const std::vector<int>& cellFaceForEachClippedTriangleEdge,
|
||||
uint triVxIdx,
|
||||
size_t globalCellIdx,
|
||||
const cvf::Vec3d& p0,
|
||||
const cvf::Vec3d& p1 )
|
||||
{
|
||||
#define isFace( faceEnum ) (0 <= faceEnum && faceEnum <= 5 )
|
||||
#define isFace( faceEnum ) ( 0 <= faceEnum && faceEnum <= 5 )
|
||||
using FaceType = cvf::StructGridInterface::FaceType;
|
||||
|
||||
if ( isFace(cellFaceForEachClippedTriangleEdge[triVxIdx]) )
|
||||
if ( isFace( cellFaceForEachClippedTriangleEdge[triVxIdx] ) )
|
||||
{
|
||||
const RigFault * fault = m_hexGrid->findFaultFromCellIndexAndCellFace(globalCellIdx,
|
||||
(FaceType)cellFaceForEachClippedTriangleEdge[triVxIdx]);
|
||||
const RigFault* fault =
|
||||
m_hexGrid->findFaultFromCellIndexAndCellFace( globalCellIdx,
|
||||
(FaceType)cellFaceForEachClippedTriangleEdge[triVxIdx] );
|
||||
if ( fault )
|
||||
{
|
||||
cvf::Vec3d highestVx = p0.z() > p1.z() ? p0 : p1;
|
||||
cvf::Vec3d highestVx = p0.z() > p1.z() ? p0 : p1;
|
||||
|
||||
auto itIsInsertedPair = faultToHighestFaultMeshVxMap.insert({fault, highestVx});
|
||||
if (!itIsInsertedPair.second)
|
||||
auto itIsInsertedPair = faultToHighestFaultMeshVxMap.insert( {fault, highestVx} );
|
||||
if ( !itIsInsertedPair.second )
|
||||
{
|
||||
if (itIsInsertedPair.first->second.z() < highestVx.z())
|
||||
if ( itIsInsertedPair.first->second.z() < highestVx.z() )
|
||||
{
|
||||
itIsInsertedPair.first->second = highestVx;
|
||||
}
|
||||
}
|
||||
|
||||
faultCellBorderLineVxes.emplace_back(p0);
|
||||
faultCellBorderLineVxes.emplace_back(p1);
|
||||
faultCellBorderLineVxes.emplace_back( p0 );
|
||||
faultCellBorderLineVxes.emplace_back( p1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
cellBorderLineVxes.emplace_back(p0);
|
||||
cellBorderLineVxes.emplace_back(p1);
|
||||
cellBorderLineVxes.emplace_back( p0 );
|
||||
cellBorderLineVxes.emplace_back( p1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
cvf::cref<RivIntersectionHexGridInterface> m_hexGrid;
|
||||
cvf::cref<RivIntersectionHexGridInterface> m_hexGrid;
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivIntersectionGeometryGenerator::calculateArrays()
|
||||
{
|
||||
if (m_triangleVxes->size()) return;
|
||||
if ( m_triangleVxes->size() ) return;
|
||||
|
||||
if (m_hexGrid.isNull()) return;
|
||||
if ( m_hexGrid.isNull() ) return;
|
||||
|
||||
m_extrusionDirection.normalize();
|
||||
std::vector<cvf::Vec3f> triangleVertices;
|
||||
|
||||
MeshLinesAccumulator meshAcc(m_hexGrid.p());
|
||||
|
||||
cvf::Vec3d displayOffset = m_hexGrid->displayOffset();
|
||||
cvf::BoundingBox gridBBox = m_hexGrid->boundingBox();
|
||||
|
||||
MeshLinesAccumulator meshAcc( m_hexGrid.p() );
|
||||
|
||||
cvf::Vec3d displayOffset = m_hexGrid->displayOffset();
|
||||
cvf::BoundingBox gridBBox = m_hexGrid->boundingBox();
|
||||
|
||||
calculateSegementTransformPrLinePoint();
|
||||
calculateFlattenedOrOffsetedPolyline();
|
||||
|
||||
for (size_t pLineIdx = 0; pLineIdx < m_polyLines.size(); ++pLineIdx)
|
||||
for ( size_t pLineIdx = 0; pLineIdx < m_polyLines.size(); ++pLineIdx )
|
||||
{
|
||||
const std::vector<cvf::Vec3d>& polyLine = m_polyLines[pLineIdx];
|
||||
|
||||
if (polyLine.size() < 2) continue;
|
||||
if ( polyLine.size() < 2 ) continue;
|
||||
|
||||
size_t lineCount = polyLine.size();
|
||||
size_t lIdx = 0;
|
||||
while ( lIdx < lineCount - 1)
|
||||
size_t lIdx = 0;
|
||||
while ( lIdx < lineCount - 1 )
|
||||
{
|
||||
size_t idxToNextP = RivSectionFlattner::indexToNextValidPoint(polyLine, m_extrusionDirection, lIdx);
|
||||
|
||||
if (idxToNextP == size_t(-1)) break;
|
||||
size_t idxToNextP = RivSectionFlattner::indexToNextValidPoint( polyLine, m_extrusionDirection, lIdx );
|
||||
|
||||
if ( idxToNextP == size_t( -1 ) ) break;
|
||||
|
||||
cvf::Vec3d p1 = polyLine[lIdx];
|
||||
cvf::Vec3d p2 = polyLine[idxToNextP];
|
||||
|
||||
|
||||
cvf::BoundingBox sectionBBox;
|
||||
sectionBBox.add(p1);
|
||||
sectionBBox.add(p2);
|
||||
sectionBBox.add( p1 );
|
||||
sectionBBox.add( p2 );
|
||||
|
||||
cvf::Vec3d maxHeightVec;
|
||||
|
||||
double maxSectionHeightUp = 0;
|
||||
double maxSectionHeightUp = 0;
|
||||
double maxSectionHeightDown = 0;
|
||||
|
||||
if (m_crossSection->type == RimIntersection::CS_AZIMUTHLINE)
|
||||
if ( m_crossSection->type == RimIntersection::CS_AZIMUTHLINE )
|
||||
{
|
||||
maxSectionHeightUp = m_crossSection->lengthUp();
|
||||
maxSectionHeightUp = m_crossSection->lengthUp();
|
||||
maxSectionHeightDown = m_crossSection->lengthDown();
|
||||
|
||||
if (maxSectionHeightUp + maxSectionHeightDown == 0)
|
||||
if ( maxSectionHeightUp + maxSectionHeightDown == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cvf::Vec3d maxHeightVecDown = m_extrusionDirection*maxSectionHeightUp;
|
||||
cvf::Vec3d maxHeightVecUp = m_extrusionDirection*maxSectionHeightDown;
|
||||
cvf::Vec3d maxHeightVecDown = m_extrusionDirection * maxSectionHeightUp;
|
||||
cvf::Vec3d maxHeightVecUp = m_extrusionDirection * maxSectionHeightDown;
|
||||
|
||||
sectionBBox.add(p1 + maxHeightVecUp);
|
||||
sectionBBox.add(p1 - maxHeightVecDown);
|
||||
sectionBBox.add(p2 + maxHeightVecUp);
|
||||
sectionBBox.add(p2 - maxHeightVecDown);
|
||||
sectionBBox.add( p1 + maxHeightVecUp );
|
||||
sectionBBox.add( p1 - maxHeightVecDown );
|
||||
sectionBBox.add( p2 + maxHeightVecUp );
|
||||
sectionBBox.add( p2 - maxHeightVecDown );
|
||||
|
||||
maxHeightVec = maxHeightVecUp + maxHeightVecDown;
|
||||
}
|
||||
else
|
||||
{
|
||||
maxHeightVec = m_extrusionDirection*gridBBox.radius();
|
||||
maxHeightVec = m_extrusionDirection * gridBBox.radius();
|
||||
|
||||
sectionBBox.add(p1 + maxHeightVec);
|
||||
sectionBBox.add(p1 - maxHeightVec);
|
||||
sectionBBox.add(p2 + maxHeightVec);
|
||||
sectionBBox.add(p2 - maxHeightVec);
|
||||
sectionBBox.add( p1 + maxHeightVec );
|
||||
sectionBBox.add( p1 - maxHeightVec );
|
||||
sectionBBox.add( p2 + maxHeightVec );
|
||||
sectionBBox.add( p2 - maxHeightVec );
|
||||
}
|
||||
|
||||
|
||||
std::vector<size_t> columnCellCandidates;
|
||||
m_hexGrid->findIntersectingCells(sectionBBox, &columnCellCandidates);
|
||||
m_hexGrid->findIntersectingCells( sectionBBox, &columnCellCandidates );
|
||||
|
||||
cvf::Plane plane;
|
||||
plane.setFromPoints(p1, p2, p2 + maxHeightVec);
|
||||
plane.setFromPoints( p1, p2, p2 + maxHeightVec );
|
||||
|
||||
cvf::Plane p1Plane;
|
||||
p1Plane.setFromPoints(p1, p1 + maxHeightVec, p1 + plane.normal());
|
||||
p1Plane.setFromPoints( p1, p1 + maxHeightVec, p1 + plane.normal() );
|
||||
cvf::Plane p2Plane;
|
||||
p2Plane.setFromPoints(p2, p2 + maxHeightVec, p2 - plane.normal());
|
||||
p2Plane.setFromPoints( p2, p2 + maxHeightVec, p2 - plane.normal() );
|
||||
|
||||
std::vector<caf::HexGridIntersectionTools::ClipVx> hexPlaneCutTriangleVxes;
|
||||
hexPlaneCutTriangleVxes.reserve(5*3);
|
||||
hexPlaneCutTriangleVxes.reserve( 5 * 3 );
|
||||
std::vector<int> cellFaceForEachTriangleEdge;
|
||||
cellFaceForEachTriangleEdge.reserve(5*3);
|
||||
cellFaceForEachTriangleEdge.reserve( 5 * 3 );
|
||||
cvf::Vec3d cellCorners[8];
|
||||
size_t cornerIndices[8];
|
||||
size_t cornerIndices[8];
|
||||
|
||||
cvf::Mat4d invSectionCS = m_segementTransformPrLinePoint[pLineIdx][lIdx];
|
||||
|
||||
for (size_t cccIdx = 0; cccIdx < columnCellCandidates.size(); ++cccIdx)
|
||||
for ( size_t cccIdx = 0; cccIdx < columnCellCandidates.size(); ++cccIdx )
|
||||
{
|
||||
size_t globalCellIdx = columnCellCandidates[cccIdx];
|
||||
|
||||
if (!m_hexGrid->useCell(globalCellIdx)) continue;
|
||||
if ( !m_hexGrid->useCell( globalCellIdx ) ) continue;
|
||||
|
||||
hexPlaneCutTriangleVxes.clear();
|
||||
m_hexGrid->cellCornerVertices(globalCellIdx, cellCorners);
|
||||
m_hexGrid->cellCornerIndices(globalCellIdx, cornerIndices);
|
||||
m_hexGrid->cellCornerVertices( globalCellIdx, cellCorners );
|
||||
m_hexGrid->cellCornerIndices( globalCellIdx, cornerIndices );
|
||||
|
||||
caf::HexGridIntersectionTools::planeHexIntersectionMC(plane,
|
||||
cellCorners,
|
||||
cornerIndices,
|
||||
&hexPlaneCutTriangleVxes,
|
||||
&cellFaceForEachTriangleEdge);
|
||||
caf::HexGridIntersectionTools::planeHexIntersectionMC( plane,
|
||||
cellCorners,
|
||||
cornerIndices,
|
||||
&hexPlaneCutTriangleVxes,
|
||||
&cellFaceForEachTriangleEdge );
|
||||
|
||||
if (m_crossSection->type == RimIntersection::CS_AZIMUTHLINE)
|
||||
if ( m_crossSection->type == RimIntersection::CS_AZIMUTHLINE )
|
||||
{
|
||||
bool hasAnyPointsOnSurface = false;
|
||||
for (caf::HexGridIntersectionTools::ClipVx vertex : hexPlaneCutTriangleVxes)
|
||||
for ( caf::HexGridIntersectionTools::ClipVx vertex : hexPlaneCutTriangleVxes )
|
||||
{
|
||||
cvf::Vec3d temp = vertex.vx - p1;
|
||||
double dot = temp.dot(m_extrusionDirection);
|
||||
double lengthCheck = 0;
|
||||
|
||||
if (dot < 0)
|
||||
cvf::Vec3d temp = vertex.vx - p1;
|
||||
double dot = temp.dot( m_extrusionDirection );
|
||||
double lengthCheck = 0;
|
||||
|
||||
if ( dot < 0 )
|
||||
{
|
||||
lengthCheck = maxSectionHeightUp;
|
||||
}
|
||||
@@ -331,69 +327,81 @@ void RivIntersectionGeometryGenerator::calculateArrays()
|
||||
lengthCheck = maxSectionHeightDown;
|
||||
}
|
||||
|
||||
double distance = cvf::Math::sqrt(cvf::GeometryTools::linePointSquareDist(p1, p2, vertex.vx));
|
||||
if (distance < lengthCheck)
|
||||
double distance = cvf::Math::sqrt( cvf::GeometryTools::linePointSquareDist( p1, p2, vertex.vx ) );
|
||||
if ( distance < lengthCheck )
|
||||
{
|
||||
hasAnyPointsOnSurface = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasAnyPointsOnSurface)
|
||||
if ( !hasAnyPointsOnSurface )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<caf::HexGridIntersectionTools::ClipVx> clippedTriangleVxes;
|
||||
std::vector<int> cellFaceForEachClippedTriangleEdge;
|
||||
std::vector<int> cellFaceForEachClippedTriangleEdge;
|
||||
|
||||
caf::HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(hexPlaneCutTriangleVxes,
|
||||
cellFaceForEachTriangleEdge,
|
||||
p1Plane,
|
||||
p2Plane,
|
||||
&clippedTriangleVxes,
|
||||
&cellFaceForEachClippedTriangleEdge);
|
||||
caf::HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes( hexPlaneCutTriangleVxes,
|
||||
cellFaceForEachTriangleEdge,
|
||||
p1Plane,
|
||||
p2Plane,
|
||||
&clippedTriangleVxes,
|
||||
&cellFaceForEachClippedTriangleEdge );
|
||||
|
||||
size_t clippedTriangleCount = clippedTriangleVxes.size()/3;
|
||||
size_t clippedTriangleCount = clippedTriangleVxes.size() / 3;
|
||||
|
||||
for (uint tIdx = 0; tIdx < clippedTriangleCount; ++tIdx)
|
||||
for ( uint tIdx = 0; tIdx < clippedTriangleCount; ++tIdx )
|
||||
{
|
||||
uint triVxIdx = tIdx*3;
|
||||
uint triVxIdx = tIdx * 3;
|
||||
|
||||
// Accumulate triangle vertices
|
||||
|
||||
cvf::Vec3d point0(clippedTriangleVxes[triVxIdx+0].vx);
|
||||
cvf::Vec3d point1(clippedTriangleVxes[triVxIdx+1].vx);
|
||||
cvf::Vec3d point2(clippedTriangleVxes[triVxIdx+2].vx);
|
||||
cvf::Vec3d point0( clippedTriangleVxes[triVxIdx + 0].vx );
|
||||
cvf::Vec3d point1( clippedTriangleVxes[triVxIdx + 1].vx );
|
||||
cvf::Vec3d point2( clippedTriangleVxes[triVxIdx + 2].vx );
|
||||
|
||||
point0 = point0.getTransformedPoint(invSectionCS);
|
||||
point1 = point1.getTransformedPoint(invSectionCS);
|
||||
point2 = point2.getTransformedPoint(invSectionCS);
|
||||
|
||||
triangleVertices.emplace_back(point0);
|
||||
triangleVertices.emplace_back(point1);
|
||||
triangleVertices.emplace_back(point2);
|
||||
point0 = point0.getTransformedPoint( invSectionCS );
|
||||
point1 = point1.getTransformedPoint( invSectionCS );
|
||||
point2 = point2.getTransformedPoint( invSectionCS );
|
||||
|
||||
triangleVertices.emplace_back( point0 );
|
||||
triangleVertices.emplace_back( point1 );
|
||||
triangleVertices.emplace_back( point2 );
|
||||
|
||||
// Accumulate mesh lines
|
||||
|
||||
meshAcc.accumulateMeshLines(cellFaceForEachClippedTriangleEdge, triVxIdx + 0, globalCellIdx, point0, point1);
|
||||
meshAcc.accumulateMeshLines(cellFaceForEachClippedTriangleEdge, triVxIdx + 1, globalCellIdx, point1, point2);
|
||||
meshAcc.accumulateMeshLines(cellFaceForEachClippedTriangleEdge, triVxIdx + 2, globalCellIdx, point2, point0);
|
||||
|
||||
|
||||
meshAcc.accumulateMeshLines( cellFaceForEachClippedTriangleEdge,
|
||||
triVxIdx + 0,
|
||||
globalCellIdx,
|
||||
point0,
|
||||
point1 );
|
||||
meshAcc.accumulateMeshLines( cellFaceForEachClippedTriangleEdge,
|
||||
triVxIdx + 1,
|
||||
globalCellIdx,
|
||||
point1,
|
||||
point2 );
|
||||
meshAcc.accumulateMeshLines( cellFaceForEachClippedTriangleEdge,
|
||||
triVxIdx + 2,
|
||||
globalCellIdx,
|
||||
point2,
|
||||
point0 );
|
||||
|
||||
// Mapping to cell index
|
||||
|
||||
m_triangleToCellIdxMap.push_back(globalCellIdx);
|
||||
m_triangleToCellIdxMap.push_back( globalCellIdx );
|
||||
|
||||
// Interpolation from nodes
|
||||
for (int i = 0; i < 3; ++i)
|
||||
for ( int i = 0; i < 3; ++i )
|
||||
{
|
||||
caf::HexGridIntersectionTools::ClipVx cvx = clippedTriangleVxes[triVxIdx + i];
|
||||
if (cvx.isVxIdsNative)
|
||||
if ( cvx.isVxIdsNative )
|
||||
{
|
||||
m_triVxToCellCornerWeights.push_back(
|
||||
RivIntersectionVertexWeights(cvx.clippedEdgeVx1Id, cvx.clippedEdgeVx2Id, cvx.normDistFromEdgeVx1));
|
||||
RivIntersectionVertexWeights( cvx.clippedEdgeVx1Id,
|
||||
cvx.clippedEdgeVx2Id,
|
||||
cvx.normDistFromEdgeVx1 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -401,9 +409,13 @@ void RivIntersectionGeometryGenerator::calculateArrays()
|
||||
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));
|
||||
RivIntersectionVertexWeights( cvx1.clippedEdgeVx1Id,
|
||||
cvx1.clippedEdgeVx2Id,
|
||||
cvx1.normDistFromEdgeVx1,
|
||||
cvx2.clippedEdgeVx1Id,
|
||||
cvx2.clippedEdgeVx2Id,
|
||||
cvx2.normDistFromEdgeVx1,
|
||||
cvx.normDistFromEdgeVx1 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -412,150 +424,150 @@ void RivIntersectionGeometryGenerator::calculateArrays()
|
||||
}
|
||||
}
|
||||
|
||||
m_triangleVxes->assign(triangleVertices);
|
||||
m_cellBorderLineVxes->assign(meshAcc.cellBorderLineVxes);
|
||||
m_faultCellBorderLineVxes->assign(meshAcc.faultCellBorderLineVxes);
|
||||
m_triangleVxes->assign( triangleVertices );
|
||||
m_cellBorderLineVxes->assign( meshAcc.cellBorderLineVxes );
|
||||
m_faultCellBorderLineVxes->assign( meshAcc.faultCellBorderLineVxes );
|
||||
|
||||
for (const auto& it : meshAcc.faultToHighestFaultMeshVxMap)
|
||||
for ( const auto& it : meshAcc.faultToHighestFaultMeshVxMap )
|
||||
{
|
||||
m_faultMeshLabelAndAnchorPositions.push_back( { it.first->name(), it.second } );
|
||||
m_faultMeshLabelAndAnchorPositions.push_back( {it.first->name(), it.second} );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Generate surface drawable geo from the specified region
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo> RivIntersectionGeometryGenerator::generateSurface()
|
||||
{
|
||||
calculateArrays();
|
||||
|
||||
CVF_ASSERT(m_triangleVxes.notNull());
|
||||
CVF_ASSERT( m_triangleVxes.notNull() );
|
||||
|
||||
if (m_triangleVxes->size() == 0) return nullptr;
|
||||
if ( m_triangleVxes->size() == 0 ) return nullptr;
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
|
||||
geo->setFromTriangleVertexArray(m_triangleVxes.p());
|
||||
geo->setFromTriangleVertexArray( m_triangleVxes.p() );
|
||||
|
||||
return geo;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo> RivIntersectionGeometryGenerator::createMeshDrawable()
|
||||
{
|
||||
if (!(m_cellBorderLineVxes.notNull() && m_cellBorderLineVxes->size() != 0)) return nullptr;
|
||||
if ( !( m_cellBorderLineVxes.notNull() && m_cellBorderLineVxes->size() != 0 ) ) return nullptr;
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
|
||||
geo->setVertexArray(m_cellBorderLineVxes.p());
|
||||
geo->setVertexArray( m_cellBorderLineVxes.p() );
|
||||
|
||||
|
||||
cvf::ref<cvf::PrimitiveSetDirect> prim = new cvf::PrimitiveSetDirect(cvf::PT_LINES);
|
||||
prim->setIndexCount(m_cellBorderLineVxes->size());
|
||||
cvf::ref<cvf::PrimitiveSetDirect> prim = new cvf::PrimitiveSetDirect( cvf::PT_LINES );
|
||||
prim->setIndexCount( m_cellBorderLineVxes->size() );
|
||||
|
||||
geo->addPrimitiveSet(prim.p());
|
||||
geo->addPrimitiveSet( prim.p() );
|
||||
return geo;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo> RivIntersectionGeometryGenerator::createFaultMeshDrawable()
|
||||
{
|
||||
if (!(m_faultCellBorderLineVxes.notNull() && m_faultCellBorderLineVxes->size() != 0)) return nullptr;
|
||||
if ( !( m_faultCellBorderLineVxes.notNull() && m_faultCellBorderLineVxes->size() != 0 ) ) return nullptr;
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
|
||||
geo->setVertexArray(m_faultCellBorderLineVxes.p());
|
||||
geo->setVertexArray( m_faultCellBorderLineVxes.p() );
|
||||
|
||||
cvf::ref<cvf::PrimitiveSetDirect> prim = new cvf::PrimitiveSetDirect( cvf::PT_LINES );
|
||||
prim->setIndexCount( m_faultCellBorderLineVxes->size() );
|
||||
|
||||
cvf::ref<cvf::PrimitiveSetDirect> prim = new cvf::PrimitiveSetDirect(cvf::PT_LINES);
|
||||
prim->setIndexCount(m_faultCellBorderLineVxes->size());
|
||||
|
||||
geo->addPrimitiveSet(prim.p());
|
||||
geo->addPrimitiveSet( prim.p() );
|
||||
return geo;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo> RivIntersectionGeometryGenerator::createLineAlongPolylineDrawable()
|
||||
{
|
||||
return RivPolylineGenerator::createLineAlongPolylineDrawable(m_flattenedOrOffsettedPolyLines);
|
||||
return RivPolylineGenerator::createLineAlongPolylineDrawable( m_flattenedOrOffsettedPolyLines );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo> RivIntersectionGeometryGenerator::createLineAlongExtrusionLineDrawable(const std::vector<cvf::Vec3d>& extrusionLine)
|
||||
cvf::ref<cvf::DrawableGeo>
|
||||
RivIntersectionGeometryGenerator::createLineAlongExtrusionLineDrawable( const std::vector<cvf::Vec3d>& extrusionLine )
|
||||
{
|
||||
cvf::ref<caf::DisplayCoordTransform> transform = displayCoordTransform(crossSection());
|
||||
std::vector<cvf::Vec3d> displayCoords;
|
||||
cvf::ref<caf::DisplayCoordTransform> transform = displayCoordTransform( crossSection() );
|
||||
std::vector<cvf::Vec3d> displayCoords;
|
||||
|
||||
for (const auto& pt : extrusionLine)
|
||||
for ( const auto& pt : extrusionLine )
|
||||
{
|
||||
displayCoords.push_back(transform->translateToDisplayCoord(pt));
|
||||
displayCoords.push_back( transform->translateToDisplayCoord( pt ) );
|
||||
}
|
||||
|
||||
return RivPolylineGenerator::createLineAlongPolylineDrawable(std::vector<std::vector<cvf::Vec3d>>({ displayCoords }));
|
||||
|
||||
return RivPolylineGenerator::createLineAlongPolylineDrawable(
|
||||
std::vector<std::vector<cvf::Vec3d>>( {displayCoords} ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo> RivIntersectionGeometryGenerator::createPointsFromPolylineDrawable()
|
||||
{
|
||||
return RivPolylineGenerator::createPointsFromPolylineDrawable(m_flattenedOrOffsettedPolyLines);
|
||||
return RivPolylineGenerator::createPointsFromPolylineDrawable( m_flattenedOrOffsettedPolyLines );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::DrawableGeo> RivIntersectionGeometryGenerator::createPointsFromExtrusionLineDrawable(const std::vector<cvf::Vec3d>& extrusionLine)
|
||||
cvf::ref<cvf::DrawableGeo>
|
||||
RivIntersectionGeometryGenerator::createPointsFromExtrusionLineDrawable( const std::vector<cvf::Vec3d>& extrusionLine )
|
||||
{
|
||||
cvf::ref<caf::DisplayCoordTransform> transform = displayCoordTransform(crossSection());
|
||||
std::vector<cvf::Vec3d> displayCoords;
|
||||
|
||||
for (const auto& pt : extrusionLine)
|
||||
cvf::ref<caf::DisplayCoordTransform> transform = displayCoordTransform( crossSection() );
|
||||
std::vector<cvf::Vec3d> displayCoords;
|
||||
|
||||
for ( const auto& pt : extrusionLine )
|
||||
{
|
||||
displayCoords.push_back(transform->translateToDisplayCoord(pt));
|
||||
displayCoords.push_back( transform->translateToDisplayCoord( pt ) );
|
||||
}
|
||||
|
||||
return RivPolylineGenerator::createPointsFromPolylineDrawable(std::vector<std::vector<cvf::Vec3d>>({displayCoords}));
|
||||
|
||||
return RivPolylineGenerator::createPointsFromPolylineDrawable(
|
||||
std::vector<std::vector<cvf::Vec3d>>( {displayCoords} ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<size_t>& RivIntersectionGeometryGenerator::triangleToCellIndex() const
|
||||
{
|
||||
CVF_ASSERT(m_triangleVxes->size());
|
||||
CVF_ASSERT( m_triangleVxes->size() );
|
||||
return m_triangleToCellIdxMap;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<RivIntersectionVertexWeights>& RivIntersectionGeometryGenerator::triangleVxToCellCornerInterpolationWeights() const
|
||||
const std::vector<RivIntersectionVertexWeights>&
|
||||
RivIntersectionGeometryGenerator::triangleVxToCellCornerInterpolationWeights() const
|
||||
{
|
||||
CVF_ASSERT(m_triangleVxes->size());
|
||||
CVF_ASSERT( m_triangleVxes->size() );
|
||||
return m_triVxToCellCornerWeights;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const cvf::Vec3fArray* RivIntersectionGeometryGenerator::triangleVxes() const
|
||||
{
|
||||
CVF_ASSERT(m_triangleVxes->size());
|
||||
CVF_ASSERT( m_triangleVxes->size() );
|
||||
return m_triangleVxes.p();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimIntersection* RivIntersectionGeometryGenerator::crossSection() const
|
||||
{
|
||||
@@ -563,24 +575,24 @@ RimIntersection* RivIntersectionGeometryGenerator::crossSection() const
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Mat4d RivIntersectionGeometryGenerator::unflattenTransformMatrix(const cvf::Vec3d& intersectionPointFlat)
|
||||
cvf::Mat4d RivIntersectionGeometryGenerator::unflattenTransformMatrix( const cvf::Vec3d& intersectionPointFlat )
|
||||
{
|
||||
cvf::Mat4d flattenMx = cvf::Mat4d::IDENTITY;
|
||||
cvf::Mat4d flattenMx = cvf::Mat4d::IDENTITY;
|
||||
|
||||
for ( size_t pLineIdx = 0; pLineIdx < m_flattenedOrOffsettedPolyLines.size(); pLineIdx++ )
|
||||
{
|
||||
const std::vector<cvf::Vec3d>& polyLine = m_flattenedOrOffsettedPolyLines[pLineIdx];
|
||||
for(size_t pIdx = 0; pIdx < polyLine.size(); pIdx++)
|
||||
for ( size_t pIdx = 0; pIdx < polyLine.size(); pIdx++ )
|
||||
{
|
||||
if (polyLine[pIdx].x() >= intersectionPointFlat.x() )
|
||||
if ( polyLine[pIdx].x() >= intersectionPointFlat.x() )
|
||||
{
|
||||
size_t csIdx = pIdx > 0 ? pIdx - 1: 0;
|
||||
flattenMx = m_segementTransformPrLinePoint[pLineIdx][csIdx];
|
||||
size_t csIdx = pIdx > 0 ? pIdx - 1 : 0;
|
||||
flattenMx = m_segementTransformPrLinePoint[pLineIdx][csIdx];
|
||||
break;
|
||||
}
|
||||
else if (pIdx == polyLine.size() - 1)
|
||||
else if ( pIdx == polyLine.size() - 1 )
|
||||
{
|
||||
flattenMx = m_segementTransformPrLinePoint[pLineIdx][pIdx];
|
||||
}
|
||||
@@ -591,11 +603,11 @@ cvf::Mat4d RivIntersectionGeometryGenerator::unflattenTransformMatrix(const cvf:
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RivIntersectionGeometryGenerator::isAnyGeometryPresent() const
|
||||
{
|
||||
if (m_triangleVxes->size() == 0)
|
||||
if ( m_triangleVxes->size() == 0 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -604,4 +616,3 @@ bool RivIntersectionGeometryGenerator::isAnyGeometryPresent() const
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -40,73 +40,76 @@ class RivIntersectionVertexWeights;
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class ScalarMapper;
|
||||
class DrawableGeo;
|
||||
}
|
||||
|
||||
class ScalarMapper;
|
||||
class DrawableGeo;
|
||||
} // namespace cvf
|
||||
|
||||
class RivIntersectionGeometryGenerator : public cvf::Object
|
||||
{
|
||||
public:
|
||||
RivIntersectionGeometryGenerator(RimIntersection* crossSection,
|
||||
std::vector<std::vector<cvf::Vec3d> > &polylines,
|
||||
const cvf::Vec3d& extrusionDirection,
|
||||
const RivIntersectionHexGridInterface* grid,
|
||||
bool isFlattened,
|
||||
const cvf::Vec3d& flattenedPolylineStartPoint);
|
||||
RivIntersectionGeometryGenerator( RimIntersection* crossSection,
|
||||
std::vector<std::vector<cvf::Vec3d>>& polylines,
|
||||
const cvf::Vec3d& extrusionDirection,
|
||||
const RivIntersectionHexGridInterface* grid,
|
||||
bool isFlattened,
|
||||
const cvf::Vec3d& flattenedPolylineStartPoint );
|
||||
|
||||
~RivIntersectionGeometryGenerator() override;
|
||||
|
||||
bool isAnyGeometryPresent() const;
|
||||
|
||||
bool isAnyGeometryPresent() const;
|
||||
|
||||
// Generate geometry
|
||||
cvf::ref<cvf::DrawableGeo> generateSurface();
|
||||
cvf::ref<cvf::DrawableGeo> createMeshDrawable();
|
||||
cvf::ref<cvf::DrawableGeo> createFaultMeshDrawable();
|
||||
cvf::ref<cvf::DrawableGeo> generateSurface();
|
||||
cvf::ref<cvf::DrawableGeo> createMeshDrawable();
|
||||
cvf::ref<cvf::DrawableGeo> createFaultMeshDrawable();
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> createLineAlongPolylineDrawable();
|
||||
cvf::ref<cvf::DrawableGeo> createLineAlongExtrusionLineDrawable(const std::vector<cvf::Vec3d>& extrusionLine);
|
||||
cvf::ref<cvf::DrawableGeo> createPointsFromPolylineDrawable();
|
||||
cvf::ref<cvf::DrawableGeo> createPointsFromExtrusionLineDrawable(const std::vector<cvf::Vec3d>& extrusionLine);
|
||||
cvf::ref<cvf::DrawableGeo> createLineAlongPolylineDrawable();
|
||||
cvf::ref<cvf::DrawableGeo> createLineAlongExtrusionLineDrawable( const std::vector<cvf::Vec3d>& extrusionLine );
|
||||
cvf::ref<cvf::DrawableGeo> createPointsFromPolylineDrawable();
|
||||
cvf::ref<cvf::DrawableGeo> createPointsFromExtrusionLineDrawable( const std::vector<cvf::Vec3d>& extrusionLine );
|
||||
|
||||
const std::vector<std::vector<cvf::Vec3d> >& flattenedOrOffsettedPolyLines() { return m_flattenedOrOffsettedPolyLines; }
|
||||
const std::vector<std::pair<QString, cvf::Vec3d> > & faultMeshLabelAndAnchorPositions() { return m_faultMeshLabelAndAnchorPositions; }
|
||||
|
||||
const std::vector<std::vector<cvf::Vec3d>>& flattenedOrOffsettedPolyLines()
|
||||
{
|
||||
return m_flattenedOrOffsettedPolyLines;
|
||||
}
|
||||
const std::vector<std::pair<QString, cvf::Vec3d>>& faultMeshLabelAndAnchorPositions()
|
||||
{
|
||||
return m_faultMeshLabelAndAnchorPositions;
|
||||
}
|
||||
|
||||
// Mapping between cells and geometry
|
||||
const std::vector<size_t>& triangleToCellIndex() const;
|
||||
const std::vector<RivIntersectionVertexWeights>& triangleVxToCellCornerInterpolationWeights() const;
|
||||
const cvf::Vec3fArray* triangleVxes() const;
|
||||
|
||||
RimIntersection* crossSection() const;
|
||||
RimIntersection* crossSection() const;
|
||||
|
||||
cvf::Mat4d unflattenTransformMatrix(const cvf::Vec3d& intersectionPointFlat);
|
||||
cvf::Mat4d unflattenTransformMatrix( const cvf::Vec3d& intersectionPointFlat );
|
||||
|
||||
private:
|
||||
void calculateArrays();
|
||||
void calculateSegementTransformPrLinePoint();
|
||||
void calculateFlattenedOrOffsetedPolyline();
|
||||
void calculateArrays();
|
||||
void calculateSegementTransformPrLinePoint();
|
||||
void calculateFlattenedOrOffsetedPolyline();
|
||||
|
||||
//static size_t indexToNextValidPoint(const std::vector<cvf::Vec3d>& polyLine,
|
||||
// static size_t indexToNextValidPoint(const std::vector<cvf::Vec3d>& polyLine,
|
||||
// const cvf::Vec3d extrDir,
|
||||
// size_t idxToStartOfLineSegment);
|
||||
|
||||
RimIntersection* m_crossSection;
|
||||
cvf::cref<RivIntersectionHexGridInterface> m_hexGrid;
|
||||
const std::vector<std::vector<cvf::Vec3d> > m_polyLines;
|
||||
cvf::Vec3d m_extrusionDirection;
|
||||
bool m_isFlattened;
|
||||
cvf::Vec3d m_flattenedPolylineStartPoint;
|
||||
|
||||
// Output arrays
|
||||
cvf::ref<cvf::Vec3fArray> m_triangleVxes;
|
||||
cvf::ref<cvf::Vec3fArray> m_cellBorderLineVxes;
|
||||
cvf::ref<cvf::Vec3fArray> m_faultCellBorderLineVxes;
|
||||
std::vector<size_t> m_triangleToCellIdxMap;
|
||||
std::vector<RivIntersectionVertexWeights> m_triVxToCellCornerWeights;
|
||||
std::vector<std::vector<cvf::Vec3d> > m_flattenedOrOffsettedPolyLines;
|
||||
std::vector<std::vector<cvf::Mat4d> > m_segementTransformPrLinePoint;
|
||||
RimIntersection* m_crossSection;
|
||||
cvf::cref<RivIntersectionHexGridInterface> m_hexGrid;
|
||||
const std::vector<std::vector<cvf::Vec3d>> m_polyLines;
|
||||
cvf::Vec3d m_extrusionDirection;
|
||||
bool m_isFlattened;
|
||||
cvf::Vec3d m_flattenedPolylineStartPoint;
|
||||
|
||||
std::vector<std::pair<QString, cvf::Vec3d> > m_faultMeshLabelAndAnchorPositions;
|
||||
// Output arrays
|
||||
cvf::ref<cvf::Vec3fArray> m_triangleVxes;
|
||||
cvf::ref<cvf::Vec3fArray> m_cellBorderLineVxes;
|
||||
cvf::ref<cvf::Vec3fArray> m_faultCellBorderLineVxes;
|
||||
std::vector<size_t> m_triangleToCellIdxMap;
|
||||
std::vector<RivIntersectionVertexWeights> m_triVxToCellCornerWeights;
|
||||
std::vector<std::vector<cvf::Vec3d>> m_flattenedOrOffsettedPolyLines;
|
||||
std::vector<std::vector<cvf::Mat4d>> m_segementTransformPrLinePoint;
|
||||
|
||||
std::vector<std::pair<QString, cvf::Vec3d>> m_faultMeshLabelAndAnchorPositions;
|
||||
};
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,7 +19,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "cvfArray.h"
|
||||
#include "cvfColor4.h"
|
||||
#include "cvfMatrix4.h"
|
||||
@@ -65,58 +64,58 @@ class RivPipeGeometryGenerator;
|
||||
class RivIntersectionPartMgr : public cvf::Object
|
||||
{
|
||||
public:
|
||||
explicit RivIntersectionPartMgr(RimIntersection* rimCrossSection, bool isFlattened = false);
|
||||
explicit RivIntersectionPartMgr( RimIntersection* rimCrossSection, bool isFlattened = false );
|
||||
|
||||
void applySingleColorEffect();
|
||||
void updateCellResultColor(size_t timeStepIndex,
|
||||
const cvf::ScalarMapper* scalarColorMapper,
|
||||
const RivTernaryScalarMapper* ternaryColorMapper);
|
||||
void updateCellResultColor( size_t timeStepIndex,
|
||||
const cvf::ScalarMapper* scalarColorMapper,
|
||||
const RivTernaryScalarMapper* ternaryColorMapper );
|
||||
|
||||
void appendNativeCrossSectionFacesToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform);
|
||||
void appendMeshLinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform);
|
||||
void appendPolylinePartsToModel(Rim3dView& view, cvf::ModelBasicList* model, cvf::Transform* scaleTransform);
|
||||
void appendNativeCrossSectionFacesToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform );
|
||||
void appendMeshLinePartsToModel( cvf::ModelBasicList* model, cvf::Transform* scaleTransform );
|
||||
void appendPolylinePartsToModel( Rim3dView& view, cvf::ModelBasicList* model, cvf::Transform* scaleTransform );
|
||||
|
||||
const RimIntersection* intersection() const;
|
||||
|
||||
cvf::Mat4d unflattenTransformMatrix(const cvf::Vec3d& intersectionPointFlat);
|
||||
cvf::Mat4d unflattenTransformMatrix( const cvf::Vec3d& intersectionPointFlat );
|
||||
|
||||
public:
|
||||
static void calculateEclipseTextureCoordinates(cvf::Vec2fArray* textureCoords,
|
||||
const std::vector<size_t>& triangleToCellIdxMap,
|
||||
const RigResultAccessor* resultAccessor,
|
||||
const cvf::ScalarMapper* mapper);
|
||||
static void calculateEclipseTextureCoordinates( cvf::Vec2fArray* textureCoords,
|
||||
const std::vector<size_t>& triangleToCellIdxMap,
|
||||
const RigResultAccessor* resultAccessor,
|
||||
const cvf::ScalarMapper* mapper );
|
||||
|
||||
static void
|
||||
calculateNodeOrElementNodeBasedGeoMechTextureCoords(cvf::Vec2fArray* textureCoords,
|
||||
const std::vector<RivIntersectionVertexWeights>& vertexWeights,
|
||||
const std::vector<float>& resultValues,
|
||||
bool isElementNodalResult,
|
||||
const RigFemPart* femPart,
|
||||
const cvf::ScalarMapper* mapper);
|
||||
static void calculateNodeOrElementNodeBasedGeoMechTextureCoords(
|
||||
cvf::Vec2fArray* textureCoords,
|
||||
const std::vector<RivIntersectionVertexWeights>& vertexWeights,
|
||||
const std::vector<float>& resultValues,
|
||||
bool isElementNodalResult,
|
||||
const RigFemPart* femPart,
|
||||
const cvf::ScalarMapper* mapper );
|
||||
|
||||
static void calculateElementBasedGeoMechTextureCoords(cvf::Vec2fArray* textureCoords,
|
||||
const std::vector<float>& resultValues,
|
||||
const std::vector<size_t>& triangleToCellIdx,
|
||||
const cvf::ScalarMapper* mapper);
|
||||
static void calculateElementBasedGeoMechTextureCoords( cvf::Vec2fArray* textureCoords,
|
||||
const std::vector<float>& resultValues,
|
||||
const std::vector<size_t>& triangleToCellIdx,
|
||||
const cvf::ScalarMapper* mapper );
|
||||
|
||||
static void calculateGeoMechTensorXfTextureCoords(cvf::Vec2fArray* textureCoords,
|
||||
const cvf::Vec3fArray* triangelVertices,
|
||||
const std::vector<RivIntersectionVertexWeights>& vertexWeights,
|
||||
RigGeoMechCaseData* caseData,
|
||||
const RigFemResultAddress& resVarAddress,
|
||||
int timeStepIdx,
|
||||
const cvf::ScalarMapper* mapper);
|
||||
static void calculateGeoMechTensorXfTextureCoords( cvf::Vec2fArray* textureCoords,
|
||||
const cvf::Vec3fArray* triangelVertices,
|
||||
const std::vector<RivIntersectionVertexWeights>& vertexWeights,
|
||||
RigGeoMechCaseData* caseData,
|
||||
const RigFemResultAddress& resVarAddress,
|
||||
int timeStepIdx,
|
||||
const cvf::ScalarMapper* mapper );
|
||||
|
||||
static void calculatePlaneAngleTextureCoords(cvf::Vec2fArray* textureCoords,
|
||||
const cvf::Vec3fArray* triangelVertices,
|
||||
const RigFemResultAddress& resVarAddress,
|
||||
const cvf::ScalarMapper* mapper);
|
||||
static void calculatePlaneAngleTextureCoords( cvf::Vec2fArray* textureCoords,
|
||||
const cvf::Vec3fArray* triangelVertices,
|
||||
const RigFemResultAddress& resVarAddress,
|
||||
const cvf::ScalarMapper* mapper );
|
||||
|
||||
private:
|
||||
void generatePartGeometry();
|
||||
void createFaultLabelParts(const std::vector<std::pair<QString, cvf::Vec3d>>& labelAndAnchors);
|
||||
void createPolyLineParts(bool useBufferObjects);
|
||||
void createExtrusionDirParts(bool useBufferObjects);
|
||||
void createFaultLabelParts( const std::vector<std::pair<QString, cvf::Vec3d>>& labelAndAnchors );
|
||||
void createPolyLineParts( bool useBufferObjects );
|
||||
void createExtrusionDirParts( bool useBufferObjects );
|
||||
|
||||
cvf::ref<RivIntersectionHexGridInterface> createHexGridInterface();
|
||||
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -21,41 +21,40 @@
|
||||
|
||||
#include "RivIntersectionGeometryGenerator.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivIntersectionSourceInfo::RivIntersectionSourceInfo(RivIntersectionGeometryGenerator* geometryGenerator)
|
||||
: m_crossSectionGeometryGenerator(geometryGenerator)
|
||||
RivIntersectionSourceInfo::RivIntersectionSourceInfo( RivIntersectionGeometryGenerator* geometryGenerator )
|
||||
: m_crossSectionGeometryGenerator( geometryGenerator )
|
||||
{
|
||||
CVF_ASSERT(m_crossSectionGeometryGenerator.notNull());
|
||||
CVF_ASSERT( m_crossSectionGeometryGenerator.notNull() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<size_t>& RivIntersectionSourceInfo::triangleToCellIndex() const
|
||||
{
|
||||
CVF_ASSERT(m_crossSectionGeometryGenerator.notNull());
|
||||
CVF_ASSERT( m_crossSectionGeometryGenerator.notNull() );
|
||||
|
||||
return m_crossSectionGeometryGenerator->triangleToCellIndex();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::array<cvf::Vec3f, 3> RivIntersectionSourceInfo::triangle(int triangleIdx) const
|
||||
std::array<cvf::Vec3f, 3> RivIntersectionSourceInfo::triangle( int triangleIdx ) const
|
||||
{
|
||||
std::array<cvf::Vec3f, 3> tri;
|
||||
tri[0] = (*m_crossSectionGeometryGenerator->triangleVxes())[triangleIdx*3];
|
||||
tri[1] = (*m_crossSectionGeometryGenerator->triangleVxes())[triangleIdx*3+1];
|
||||
tri[2] = (*m_crossSectionGeometryGenerator->triangleVxes())[triangleIdx*3+2];
|
||||
tri[0] = ( *m_crossSectionGeometryGenerator->triangleVxes() )[triangleIdx * 3];
|
||||
tri[1] = ( *m_crossSectionGeometryGenerator->triangleVxes() )[triangleIdx * 3 + 1];
|
||||
tri[2] = ( *m_crossSectionGeometryGenerator->triangleVxes() )[triangleIdx * 3 + 2];
|
||||
|
||||
return tri;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimIntersection* RivIntersectionSourceInfo::crossSection() const
|
||||
{
|
||||
|
||||
@@ -2,26 +2,25 @@
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "cvfObject.h"
|
||||
#include "cvfArray.h"
|
||||
#include "cvfObject.h"
|
||||
#include <array>
|
||||
|
||||
class RivIntersectionGeometryGenerator;
|
||||
@@ -30,11 +29,11 @@ class RimIntersection;
|
||||
class RivIntersectionSourceInfo : public cvf::Object
|
||||
{
|
||||
public:
|
||||
explicit RivIntersectionSourceInfo(RivIntersectionGeometryGenerator* geometryGenerator);
|
||||
explicit RivIntersectionSourceInfo( RivIntersectionGeometryGenerator* geometryGenerator );
|
||||
|
||||
const std::vector<size_t>& triangleToCellIndex() const;
|
||||
std::array<cvf::Vec3f, 3> triangle(int triangleIdx) const;
|
||||
RimIntersection* crossSection() const;
|
||||
std::array<cvf::Vec3f, 3> triangle( int triangleIdx ) const;
|
||||
RimIntersection* crossSection() const;
|
||||
|
||||
private:
|
||||
cvf::cref<RivIntersectionGeometryGenerator> m_crossSectionGeometryGenerator;
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -19,29 +19,27 @@
|
||||
#include "RivSectionFlattner.h"
|
||||
#include "cvfGeometryTools.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Returns the next index higher than idxToStartOfLineSegment that makes the line
|
||||
// polyline[idxToStartOfLineSegment] .. polyline[nextIdx] not parallel to extrDir
|
||||
///
|
||||
/// Returns the next index higher than idxToStartOfLineSegment that makes the line
|
||||
// polyline[idxToStartOfLineSegment] .. polyline[nextIdx] not parallel to extrDir
|
||||
///
|
||||
/// Returns size_t(-1) if no point is found
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t RivSectionFlattner::indexToNextValidPoint(const std::vector<cvf::Vec3d>& polyLine,
|
||||
const cvf::Vec3d extrDir,
|
||||
size_t idxToStartOfLineSegment)
|
||||
size_t RivSectionFlattner::indexToNextValidPoint( const std::vector<cvf::Vec3d>& polyLine,
|
||||
const cvf::Vec3d extrDir,
|
||||
size_t idxToStartOfLineSegment )
|
||||
{
|
||||
size_t lineCount = polyLine.size();
|
||||
if ( !(idxToStartOfLineSegment + 1 < lineCount) ) return -1;
|
||||
|
||||
if ( !( idxToStartOfLineSegment + 1 < lineCount ) ) return -1;
|
||||
|
||||
cvf::Vec3d p1 = polyLine[idxToStartOfLineSegment];
|
||||
|
||||
for ( size_t lIdx = idxToStartOfLineSegment+1; lIdx < lineCount; ++lIdx )
|
||||
for ( size_t lIdx = idxToStartOfLineSegment + 1; lIdx < lineCount; ++lIdx )
|
||||
{
|
||||
cvf::Vec3d p2 = polyLine[lIdx];
|
||||
cvf::Vec3d p2 = polyLine[lIdx];
|
||||
cvf::Vec3d p1p2 = p2 - p1;
|
||||
|
||||
if ( (p1p2 - (p1p2 * extrDir)*extrDir).length() > 0.1 )
|
||||
if ( ( p1p2 - ( p1p2 * extrDir ) * extrDir ).length() > 0.1 )
|
||||
{
|
||||
return lIdx;
|
||||
}
|
||||
@@ -53,17 +51,17 @@ size_t RivSectionFlattner::indexToNextValidPoint(const std::vector<cvf::Vec3d>&
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Returns one CS pr point, valid for the next segment
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<cvf::Mat4d> RivSectionFlattner::calculateFlatteningCSsForPolyline(const std::vector<cvf::Vec3d> & polyLine,
|
||||
const cvf::Vec3d& extrusionDir,
|
||||
const cvf::Vec3d& startOffset,
|
||||
cvf::Vec3d* endOffset)
|
||||
std::vector<cvf::Mat4d> RivSectionFlattner::calculateFlatteningCSsForPolyline( const std::vector<cvf::Vec3d>& polyLine,
|
||||
const cvf::Vec3d& extrusionDir,
|
||||
const cvf::Vec3d& startOffset,
|
||||
cvf::Vec3d* endOffset )
|
||||
{
|
||||
CVF_ASSERT(endOffset);
|
||||
CVF_ASSERT( endOffset );
|
||||
size_t pointCount = polyLine.size();
|
||||
CVF_ASSERT(pointCount > 1);
|
||||
CVF_ASSERT( pointCount > 1 );
|
||||
|
||||
std::vector<cvf::Mat4d> segmentTransforms;
|
||||
segmentTransforms.reserve(pointCount);
|
||||
segmentTransforms.reserve( pointCount );
|
||||
|
||||
// Find initial transform, used if all is vertical
|
||||
|
||||
@@ -72,9 +70,9 @@ std::vector<cvf::Mat4d> RivSectionFlattner::calculateFlatteningCSsForPolyline(co
|
||||
cvf::Vec3d p1 = polyLine[0];
|
||||
cvf::Vec3d p2 = polyLine[1];
|
||||
|
||||
cvf::Mat4d sectionLocalCS = calculateSectionLocalFlatteningCS(p1, p2, extrusionDir);
|
||||
invSectionCS = sectionLocalCS.getInverted();
|
||||
invSectionCS.setTranslation(invSectionCS.translation() + startOffset);
|
||||
cvf::Mat4d sectionLocalCS = calculateSectionLocalFlatteningCS( p1, p2, extrusionDir );
|
||||
invSectionCS = sectionLocalCS.getInverted();
|
||||
invSectionCS.setTranslation( invSectionCS.translation() + startOffset );
|
||||
}
|
||||
|
||||
cvf::Vec3d previousFlattenedSectionEndPoint = startOffset;
|
||||
@@ -82,16 +80,16 @@ std::vector<cvf::Mat4d> RivSectionFlattner::calculateFlatteningCSsForPolyline(co
|
||||
size_t lIdx = 0;
|
||||
while ( lIdx < pointCount )
|
||||
{
|
||||
size_t idxToNextP = indexToNextValidPoint(polyLine, extrusionDir, lIdx);
|
||||
size_t idxToNextP = indexToNextValidPoint( polyLine, extrusionDir, lIdx );
|
||||
|
||||
// If the rest is nearly parallel to extrusionDir, use the current inverse matrix for the rest of the points
|
||||
|
||||
if ( idxToNextP == size_t(-1) )
|
||||
if ( idxToNextP == size_t( -1 ) )
|
||||
{
|
||||
size_t inc = 0;
|
||||
while ( (lIdx + inc) < pointCount )
|
||||
while ( ( lIdx + inc ) < pointCount )
|
||||
{
|
||||
segmentTransforms.push_back(invSectionCS);
|
||||
segmentTransforms.push_back( invSectionCS );
|
||||
++inc;
|
||||
}
|
||||
break;
|
||||
@@ -100,20 +98,20 @@ std::vector<cvf::Mat4d> RivSectionFlattner::calculateFlatteningCSsForPolyline(co
|
||||
cvf::Vec3d p1 = polyLine[lIdx];
|
||||
cvf::Vec3d p2 = polyLine[idxToNextP];
|
||||
|
||||
cvf::Mat4d sectionLocalCS = calculateSectionLocalFlatteningCS(p1, p2, extrusionDir);
|
||||
invSectionCS = sectionLocalCS.getInverted();
|
||||
cvf::Vec3d flattenedSectionEndPoint = p2.getTransformedPoint(invSectionCS);
|
||||
cvf::Mat4d sectionLocalCS = calculateSectionLocalFlatteningCS( p1, p2, extrusionDir );
|
||||
invSectionCS = sectionLocalCS.getInverted();
|
||||
cvf::Vec3d flattenedSectionEndPoint = p2.getTransformedPoint( invSectionCS );
|
||||
|
||||
invSectionCS.setTranslation(invSectionCS.translation() + previousFlattenedSectionEndPoint);
|
||||
invSectionCS.setTranslation( invSectionCS.translation() + previousFlattenedSectionEndPoint );
|
||||
|
||||
previousFlattenedSectionEndPoint += flattenedSectionEndPoint;
|
||||
|
||||
// Assign the matrix to the points in between
|
||||
|
||||
size_t inc = 0;
|
||||
while ( (lIdx + inc) < idxToNextP )
|
||||
while ( ( lIdx + inc ) < idxToNextP )
|
||||
{
|
||||
segmentTransforms.push_back(invSectionCS);
|
||||
segmentTransforms.push_back( invSectionCS );
|
||||
inc++;
|
||||
}
|
||||
|
||||
@@ -130,15 +128,17 @@ std::vector<cvf::Mat4d> RivSectionFlattner::calculateFlatteningCSsForPolyline(co
|
||||
/// Ey normal to the section plane
|
||||
/// Ex in plane along p1-p2
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Mat4d RivSectionFlattner::calculateSectionLocalFlatteningCS(const cvf::Vec3d& p1, const cvf::Vec3d& p2, const cvf::Vec3d& extrusionDir)
|
||||
cvf::Mat4d RivSectionFlattner::calculateSectionLocalFlatteningCS( const cvf::Vec3d& p1,
|
||||
const cvf::Vec3d& p2,
|
||||
const cvf::Vec3d& extrusionDir )
|
||||
{
|
||||
using namespace cvf;
|
||||
|
||||
Vec3d Ez = extrusionDir.z() > 0.0 ? extrusionDir: -extrusionDir;
|
||||
Vec3d Ez = extrusionDir.z() > 0.0 ? extrusionDir : -extrusionDir;
|
||||
|
||||
Vec3d sectionLineDir = p2 - p1;
|
||||
|
||||
if ( cvf::GeometryTools::getAngle(sectionLineDir, extrusionDir) < 0.01 )
|
||||
if ( cvf::GeometryTools::getAngle( sectionLineDir, extrusionDir ) < 0.01 )
|
||||
{
|
||||
sectionLineDir = Ez.perpendicularVector();
|
||||
}
|
||||
@@ -148,8 +148,5 @@ cvf::Mat4d RivSectionFlattner::calculateSectionLocalFlatteningCS(const cvf::Vec3
|
||||
Vec3d Ex = Ey ^ Ez;
|
||||
Ex.normalize();
|
||||
|
||||
return Mat4d(Ex[0], Ey[0], Ez[0], p1[0],
|
||||
Ex[1], Ey[1], Ez[1], p1[1],
|
||||
Ex[2], Ey[2], Ez[2], p1[2],
|
||||
0.0, 0.0, 0.0, 1.0);
|
||||
return Mat4d( Ex[0], Ey[0], Ez[0], p1[0], Ex[1], Ey[1], Ez[1], p1[1], Ex[2], Ey[2], Ez[2], p1[2], 0.0, 0.0, 0.0, 1.0 );
|
||||
}
|
||||
|
||||
@@ -1,48 +1,40 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "cvfMatrix4.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
||||
class RivSectionFlattner
|
||||
{
|
||||
public:
|
||||
static size_t indexToNextValidPoint(const std::vector<cvf::Vec3d>& polyLine,
|
||||
const cvf::Vec3d extrDir,
|
||||
size_t idxToStartOfLineSegment);
|
||||
static size_t indexToNextValidPoint( const std::vector<cvf::Vec3d>& polyLine,
|
||||
const cvf::Vec3d extrDir,
|
||||
size_t idxToStartOfLineSegment );
|
||||
|
||||
static std::vector<cvf::Mat4d> calculateFlatteningCSsForPolyline(const std::vector<cvf::Vec3d> & polyLine,
|
||||
const cvf::Vec3d& extrusionDir,
|
||||
const cvf::Vec3d& startOffset,
|
||||
cvf::Vec3d* endOffset);
|
||||
static std::vector<cvf::Mat4d> calculateFlatteningCSsForPolyline( const std::vector<cvf::Vec3d>& polyLine,
|
||||
const cvf::Vec3d& extrusionDir,
|
||||
const cvf::Vec3d& startOffset,
|
||||
cvf::Vec3d* endOffset );
|
||||
|
||||
private:
|
||||
|
||||
static cvf::Mat4d calculateSectionLocalFlatteningCS(const cvf::Vec3d& p1,
|
||||
const cvf::Vec3d& p2,
|
||||
const cvf::Vec3d& extrusionDir);
|
||||
|
||||
|
||||
static cvf::Mat4d
|
||||
calculateSectionLocalFlatteningCS( const cvf::Vec3d& p1, const cvf::Vec3d& p2, const cvf::Vec3d& extrusionDir );
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user