2017-01-23 08:22:51 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2017 Statoil ASA
|
2018-11-08 08:52:58 -06:00
|
|
|
//
|
2017-01-23 08:22:51 -06:00
|
|
|
// 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.
|
2018-11-08 08:52:58 -06:00
|
|
|
//
|
2017-01-23 08:22:51 -06:00
|
|
|
// 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.
|
2018-11-08 08:52:58 -06:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2017-01-23 08:22:51 -06:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "cvfVector3.h"
|
|
|
|
|
2017-01-26 02:06:18 -06:00
|
|
|
#include "cvfBoundingBox.h"
|
2017-01-23 08:22:51 -06:00
|
|
|
#include "cvfPlane.h"
|
|
|
|
|
2017-06-07 09:04:34 -05:00
|
|
|
#include <array>
|
2017-01-23 08:22:51 -06:00
|
|
|
#include <list>
|
2017-01-26 02:06:18 -06:00
|
|
|
#include <vector>
|
2017-01-23 08:22:51 -06:00
|
|
|
|
|
|
|
class RigCellGeometryTools
|
|
|
|
{
|
|
|
|
public:
|
2019-09-06 03:40:57 -05:00
|
|
|
static double calculateCellVolume( const std::array<cvf::Vec3d, 8>& hexCorners );
|
|
|
|
static bool estimateHexOverlapWithBoundingBox( const std::array<cvf::Vec3d, 8>& hexCorners,
|
|
|
|
const cvf::BoundingBox& boundingBox2dExtrusion,
|
|
|
|
std::array<cvf::Vec3d, 8>* overlapCorners,
|
|
|
|
cvf::BoundingBox* overlapBoundingBox );
|
2017-01-23 08:22:51 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
static void createPolygonFromLineSegments( std::list<std::pair<cvf::Vec3d, cvf::Vec3d>>& intersectionLineSegments,
|
|
|
|
std::vector<std::vector<cvf::Vec3d>>& polygons,
|
|
|
|
double tolerance = 1.0e-4 );
|
|
|
|
static void simplifyPolygon( std::vector<cvf::Vec3d>* vertices, double epsilon );
|
2017-01-23 08:22:51 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
static void findCellLocalXYZ( const std::array<cvf::Vec3d, 8>& hexCorners,
|
|
|
|
cvf::Vec3d& localXdirection,
|
|
|
|
cvf::Vec3d& localYdirection,
|
|
|
|
cvf::Vec3d& localZdirection );
|
2017-06-07 09:04:34 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
static double polygonLengthInLocalXdirWeightedByArea( const std::vector<cvf::Vec3d>& polygon2d );
|
2018-06-22 10:14:28 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
static std::vector<std::vector<cvf::Vec3d>> intersectPolygons( const std::vector<cvf::Vec3d>& polygon1,
|
|
|
|
const std::vector<cvf::Vec3d>& polygon2 );
|
2018-11-08 08:52:58 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
static std::vector<std::vector<cvf::Vec3d>>
|
|
|
|
subtractPolygons( const std::vector<cvf::Vec3d>& sourcePolygon,
|
2020-01-24 02:44:28 -06:00
|
|
|
const std::vector<std::vector<cvf::Vec3d>>& polygonsToSubtract );
|
2017-05-22 08:33:53 -05:00
|
|
|
|
2018-11-08 08:52:58 -06:00
|
|
|
enum ZInterpolationType
|
|
|
|
{
|
|
|
|
INTERPOLATE_LINE_Z,
|
|
|
|
USE_HUGEVAL,
|
|
|
|
USE_ZERO
|
|
|
|
};
|
2019-09-06 03:40:57 -05:00
|
|
|
static std::vector<std::vector<cvf::Vec3d>> clipPolylineByPolygon( const std::vector<cvf::Vec3d>& polyLine,
|
|
|
|
const std::vector<cvf::Vec3d>& polygon,
|
|
|
|
ZInterpolationType interpolType = USE_ZERO );
|
2017-01-26 02:06:18 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
static std::pair<cvf::Vec3d, cvf::Vec3d> getLineThroughBoundingBox( const cvf::Vec3d& lineDirection,
|
|
|
|
const cvf::BoundingBox& polygonBBox,
|
|
|
|
const cvf::Vec3d& pointOnLine );
|
2017-01-26 02:06:18 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
static double getLengthOfPolygonAlongLine( const std::pair<cvf::Vec3d, cvf::Vec3d>& line,
|
|
|
|
const std::vector<cvf::Vec3d>& polygon );
|
2017-08-07 06:14:01 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
static std::vector<cvf::Vec3d> unionOfPolygons( const std::vector<std::vector<cvf::Vec3d>>& polygons );
|
2018-03-08 04:01:04 -06:00
|
|
|
|
2017-08-07 06:14:01 -05:00
|
|
|
private:
|
2019-09-06 03:40:57 -05:00
|
|
|
static std::vector<cvf::Vec3d> ajustPolygonToAvoidIntersectionsAtVertex( const std::vector<cvf::Vec3d>& polyLine,
|
|
|
|
const std::vector<cvf::Vec3d>& polygon );
|
2017-01-23 08:22:51 -06:00
|
|
|
};
|