mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4549 Extract duplicate methods.
This commit is contained in:
parent
26c8da692a
commit
0365440b31
@ -2,6 +2,7 @@ cmake_minimum_required (VERSION 2.8.12)
|
|||||||
|
|
||||||
set ( SOURCE_GROUP_HEADER_FILES
|
set ( SOURCE_GROUP_HEADER_FILES
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiaGrpcServer.h
|
${CMAKE_CURRENT_LIST_DIR}/RiaGrpcServer.h
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RiaGrpcHelper.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiaGrpcCallbacks.h
|
${CMAKE_CURRENT_LIST_DIR}/RiaGrpcCallbacks.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiaGrpcCallbacks.inl
|
${CMAKE_CURRENT_LIST_DIR}/RiaGrpcCallbacks.inl
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiaGrpcServiceInterface.h
|
${CMAKE_CURRENT_LIST_DIR}/RiaGrpcServiceInterface.h
|
||||||
@ -17,6 +18,7 @@ set ( SOURCE_GROUP_HEADER_FILES
|
|||||||
|
|
||||||
set ( SOURCE_GROUP_SOURCE_FILES
|
set ( SOURCE_GROUP_SOURCE_FILES
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiaGrpcServer.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RiaGrpcServer.cpp
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RiaGrpcHelper.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiaGrpcServiceInterface.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RiaGrpcServiceInterface.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiaGrpcCaseService.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RiaGrpcCaseService.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RiaGrpcSimulationWellService.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RiaGrpcSimulationWellService.cpp
|
||||||
|
@ -16,7 +16,9 @@
|
|||||||
//
|
//
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
#include "RiaGrpcCaseService.h"
|
#include "RiaGrpcCaseService.h"
|
||||||
|
|
||||||
#include "RiaGrpcCallbacks.h"
|
#include "RiaGrpcCallbacks.h"
|
||||||
|
#include "RiaGrpcHelper.h"
|
||||||
#include "RiaSocketTools.h"
|
#include "RiaSocketTools.h"
|
||||||
|
|
||||||
#include "RigActiveCellInfo.h"
|
#include "RigActiveCellInfo.h"
|
||||||
@ -32,15 +34,6 @@
|
|||||||
|
|
||||||
using namespace rips;
|
using namespace rips;
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
/// Convert internal ResInsight representation of cells with negative depth to positive depth.
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
static inline void convertVec3dToPositiveDepth( cvf::Vec3d* vec )
|
|
||||||
{
|
|
||||||
double& z = vec->z();
|
|
||||||
z *= -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -254,7 +247,7 @@ void RiaActiveCellInfoStateHandler::assignCellCenter( rips::Vec3d*
|
|||||||
{
|
{
|
||||||
cvf::Vec3d center = reservoirCells[cellIdx].center();
|
cvf::Vec3d center = reservoirCells[cellIdx].center();
|
||||||
|
|
||||||
convertVec3dToPositiveDepth( ¢er );
|
RiaGrpcHelper::convertVec3dToPositiveDepth( ¢er );
|
||||||
|
|
||||||
cellCenter->set_x( center.x() );
|
cellCenter->set_x( center.x() );
|
||||||
cellCenter->set_y( center.y() );
|
cellCenter->set_y( center.y() );
|
||||||
@ -309,17 +302,6 @@ Status RiaActiveCellInfoStateHandler::assignNextActiveCellCorners( rips::CellCor
|
|||||||
return Status( grpc::OUT_OF_RANGE, "We've reached the end. This is not an error but means transmission is finished" );
|
return Status( grpc::OUT_OF_RANGE, "We've reached the end. This is not an error but means transmission is finished" );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
// TODO: duped with TestGrpcGridService
|
|
||||||
void setCornerValues2( rips::Vec3d* out, const cvf::Vec3d& in )
|
|
||||||
{
|
|
||||||
out->set_x( in.x() );
|
|
||||||
out->set_y( in.y() );
|
|
||||||
out->set_z( in.z() );
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -332,17 +314,17 @@ void RiaActiveCellInfoStateHandler::assignCellCorners( rips::CellCorners*
|
|||||||
grid->cellCornerVertices( cellIdx, cornerVerts );
|
grid->cellCornerVertices( cellIdx, cornerVerts );
|
||||||
for ( cvf::Vec3d& corner : cornerVerts )
|
for ( cvf::Vec3d& corner : cornerVerts )
|
||||||
{
|
{
|
||||||
convertVec3dToPositiveDepth( &corner );
|
RiaGrpcHelper::convertVec3dToPositiveDepth( &corner );
|
||||||
}
|
}
|
||||||
|
|
||||||
setCornerValues2( corners->mutable_c0(), cornerVerts[0] );
|
RiaGrpcHelper::setCornerValues( corners->mutable_c0(), cornerVerts[0] );
|
||||||
setCornerValues2( corners->mutable_c1(), cornerVerts[1] );
|
RiaGrpcHelper::setCornerValues( corners->mutable_c1(), cornerVerts[1] );
|
||||||
setCornerValues2( corners->mutable_c2(), cornerVerts[2] );
|
RiaGrpcHelper::setCornerValues( corners->mutable_c2(), cornerVerts[2] );
|
||||||
setCornerValues2( corners->mutable_c3(), cornerVerts[3] );
|
RiaGrpcHelper::setCornerValues( corners->mutable_c3(), cornerVerts[3] );
|
||||||
setCornerValues2( corners->mutable_c4(), cornerVerts[4] );
|
RiaGrpcHelper::setCornerValues( corners->mutable_c4(), cornerVerts[4] );
|
||||||
setCornerValues2( corners->mutable_c5(), cornerVerts[5] );
|
RiaGrpcHelper::setCornerValues( corners->mutable_c5(), cornerVerts[5] );
|
||||||
setCornerValues2( corners->mutable_c6(), cornerVerts[6] );
|
RiaGrpcHelper::setCornerValues( corners->mutable_c6(), cornerVerts[6] );
|
||||||
setCornerValues2( corners->mutable_c7(), cornerVerts[7] );
|
RiaGrpcHelper::setCornerValues( corners->mutable_c7(), cornerVerts[7] );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "RiaGrpcGridService.h"
|
#include "RiaGrpcGridService.h"
|
||||||
|
|
||||||
#include "RiaGrpcCallbacks.h"
|
#include "RiaGrpcCallbacks.h"
|
||||||
|
#include "RiaGrpcHelper.h"
|
||||||
|
|
||||||
#include "RigCell.h"
|
#include "RigCell.h"
|
||||||
#include "RigEclipseCaseData.h"
|
#include "RigEclipseCaseData.h"
|
||||||
@ -27,15 +28,6 @@
|
|||||||
|
|
||||||
using namespace rips;
|
using namespace rips;
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
/// Convert internal ResInsight representation of cells with negative depth to positive depth.
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
static inline void convertVec3dToPositiveDepth( cvf::Vec3d* vec )
|
|
||||||
{
|
|
||||||
double& z = vec->z();
|
|
||||||
z *= -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -86,7 +78,7 @@ grpc::Status RiaCellCenterStateHandler::assignReply( rips::CellCenters* reply )
|
|||||||
{
|
{
|
||||||
cvf::Vec3d center = m_grid->cell( m_currentCellIdx ).center();
|
cvf::Vec3d center = m_grid->cell( m_currentCellIdx ).center();
|
||||||
|
|
||||||
convertVec3dToPositiveDepth( ¢er );
|
RiaGrpcHelper::convertVec3dToPositiveDepth( ¢er );
|
||||||
|
|
||||||
Vec3d* cellCenter = reply->add_centers();
|
Vec3d* cellCenter = reply->add_centers();
|
||||||
cellCenter->set_x( center.x() );
|
cellCenter->set_x( center.x() );
|
||||||
@ -101,13 +93,6 @@ grpc::Status RiaCellCenterStateHandler::assignReply( rips::CellCenters* reply )
|
|||||||
return Status( grpc::OUT_OF_RANGE, "We've reached the end. This is not an error but means transmission is finished" );
|
return Status( grpc::OUT_OF_RANGE, "We've reached the end. This is not an error but means transmission is finished" );
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCornerValues( rips::Vec3d* out, const cvf::Vec3d& in )
|
|
||||||
{
|
|
||||||
out->set_x( in.x() );
|
|
||||||
out->set_y( in.y() );
|
|
||||||
out->set_z( in.z() );
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -123,18 +108,18 @@ grpc::Status RiaCellCenterStateHandler::assignCornersReply( rips::CellCornersArr
|
|||||||
m_grid->cellCornerVertices( m_currentCellIdx, cornerVerts );
|
m_grid->cellCornerVertices( m_currentCellIdx, cornerVerts );
|
||||||
for ( cvf::Vec3d& corner : cornerVerts )
|
for ( cvf::Vec3d& corner : cornerVerts )
|
||||||
{
|
{
|
||||||
convertVec3dToPositiveDepth( &corner );
|
RiaGrpcHelper::convertVec3dToPositiveDepth( &corner );
|
||||||
}
|
}
|
||||||
|
|
||||||
rips::CellCorners* corners = reply->add_cells();
|
rips::CellCorners* corners = reply->add_cells();
|
||||||
setCornerValues( corners->mutable_c0(), cornerVerts[0] );
|
RiaGrpcHelper::setCornerValues( corners->mutable_c0(), cornerVerts[0] );
|
||||||
setCornerValues( corners->mutable_c1(), cornerVerts[1] );
|
RiaGrpcHelper::setCornerValues( corners->mutable_c1(), cornerVerts[1] );
|
||||||
setCornerValues( corners->mutable_c2(), cornerVerts[2] );
|
RiaGrpcHelper::setCornerValues( corners->mutable_c2(), cornerVerts[2] );
|
||||||
setCornerValues( corners->mutable_c3(), cornerVerts[3] );
|
RiaGrpcHelper::setCornerValues( corners->mutable_c3(), cornerVerts[3] );
|
||||||
setCornerValues( corners->mutable_c4(), cornerVerts[4] );
|
RiaGrpcHelper::setCornerValues( corners->mutable_c4(), cornerVerts[4] );
|
||||||
setCornerValues( corners->mutable_c5(), cornerVerts[5] );
|
RiaGrpcHelper::setCornerValues( corners->mutable_c5(), cornerVerts[5] );
|
||||||
setCornerValues( corners->mutable_c6(), cornerVerts[6] );
|
RiaGrpcHelper::setCornerValues( corners->mutable_c6(), cornerVerts[6] );
|
||||||
setCornerValues( corners->mutable_c7(), cornerVerts[7] );
|
RiaGrpcHelper::setCornerValues( corners->mutable_c7(), cornerVerts[7] );
|
||||||
|
|
||||||
m_currentCellIdx++;
|
m_currentCellIdx++;
|
||||||
}
|
}
|
||||||
|
37
ApplicationCode/GrpcInterface/RiaGrpcHelper.cpp
Normal file
37
ApplicationCode/GrpcInterface/RiaGrpcHelper.cpp
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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 <http://www.gnu.org/licenses/gpl.html>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
|
#include "RiaGrpcHelper.h"
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
/// Convert internal ResInsight representation of cells with negative depth to positive depth.
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RiaGrpcHelper::convertVec3dToPositiveDepth( cvf::Vec3d* vec )
|
||||||
|
{
|
||||||
|
double& z = vec->z();
|
||||||
|
z *= -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RiaGrpcHelper::setCornerValues( rips::Vec3d* out, const cvf::Vec3d& in )
|
||||||
|
{
|
||||||
|
out->set_x( in.x() );
|
||||||
|
out->set_y( in.y() );
|
||||||
|
out->set_z( in.z() );
|
||||||
|
}
|
34
ApplicationCode/GrpcInterface/RiaGrpcHelper.h
Normal file
34
ApplicationCode/GrpcInterface/RiaGrpcHelper.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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 <http://www.gnu.org/licenses/gpl.html>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Definitions.grpc.pb.h"
|
||||||
|
|
||||||
|
#include "cvfVector3.h"
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
//
|
||||||
|
// Various gRPC helper methods
|
||||||
|
//
|
||||||
|
//==================================================================================================
|
||||||
|
class RiaGrpcHelper
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void convertVec3dToPositiveDepth( cvf::Vec3d* vec );
|
||||||
|
static void setCornerValues( rips::Vec3d* out, const cvf::Vec3d& in );
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user