///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2020 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 // for more details. // ///////////////////////////////////////////////////////////////////////////////// #include "RigNncConnection.h" #include "cafAssert.h" //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RigConnection::RigConnection() : m_c1GlobIdx( cvf::UNDEFINED_UINT ) , m_c2GlobIdx( cvf::UNDEFINED_UINT ) , m_c1Face( static_cast( cvf::StructGridInterface::NO_FACE ) ) { } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RigConnection::RigConnection( unsigned c1GlobIdx, unsigned c2GlobIdx, cvf::StructGridInterface::FaceType c1Face, std::vector polygon ) : m_c1GlobIdx( c1GlobIdx ) , m_c2GlobIdx( c2GlobIdx ) , m_c1Face( static_cast( c1Face ) ) , m_polygon( std::move( polygon ) ) { if ( c1GlobIdx >= c2GlobIdx ) { // Ensure the smallest cell index is the first index m_c1GlobIdx = c2GlobIdx; m_c2GlobIdx = c1GlobIdx; if ( c1Face != cvf::StructGridInterface::FaceType::NO_FACE ) { // The face type is related to cell 1, so use opposite face m_c1Face = cvf::StructGridInterface::oppositeFace( c1Face ); } } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RigConnection::RigConnection( size_t c1GlobIdx, size_t c2GlobIdx, cvf::StructGridInterface::FaceType c1Face, std::vector polygon ) : m_c1GlobIdx( static_cast( c1GlobIdx ) ) , m_c2GlobIdx( static_cast( c2GlobIdx ) ) , m_c1Face( static_cast( c1Face ) ) , m_polygon( std::move( polygon ) ) { CAF_ASSERT( c1GlobIdx < std::numeric_limits::max() && c2GlobIdx < std::numeric_limits::max() ); if ( c1GlobIdx >= c2GlobIdx ) { // Ensure the smallest cell index is the first index m_c1GlobIdx = static_cast( c2GlobIdx ); m_c2GlobIdx = static_cast( c1GlobIdx ); if ( c1Face != cvf::StructGridInterface::FaceType::NO_FACE ) { // The face type is related to cell 1, so use opposite face m_c1Face = cvf::StructGridInterface::oppositeFace( c1Face ); } } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- bool RigConnection::hasCommonArea() const { return !m_polygon.empty(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- bool RigConnection::operator==( const RigConnection& rhs ) const { return m_c1GlobIdx == rhs.m_c1GlobIdx && m_c2GlobIdx == rhs.m_c2GlobIdx; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- bool RigConnection::operator<( const RigConnection& other ) const { if ( m_c1GlobIdx != other.m_c1GlobIdx ) { return m_c1GlobIdx < other.m_c1GlobIdx; } return ( m_c2GlobIdx < other.m_c2GlobIdx ); }