mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3035 Fault Truncation: Add polygon subtraction
This commit is contained in:
@@ -288,6 +288,56 @@ std::vector<std::vector<cvf::Vec3d> > RigCellGeometryTools::intersectPolygons(st
|
|||||||
return clippedPolygons;
|
return clippedPolygons;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
std::vector<std::vector<cvf::Vec3d>>
|
||||||
|
RigCellGeometryTools::subtractPolygons(const std::vector<cvf::Vec3d>& sourcePolygon,
|
||||||
|
const std::vector<std::vector<cvf::Vec3d>>& polygonsToSubtract)
|
||||||
|
{
|
||||||
|
ClipperLib::Clipper clpr;
|
||||||
|
|
||||||
|
{
|
||||||
|
// Convert to int for clipper library and store as clipper "path"
|
||||||
|
ClipperLib::Path polygon1path;
|
||||||
|
for (const auto& v : sourcePolygon)
|
||||||
|
{
|
||||||
|
polygon1path.push_back(toClipperPoint(v));
|
||||||
|
}
|
||||||
|
clpr.AddPath(polygon1path, ClipperLib::ptSubject, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto& path : polygonsToSubtract)
|
||||||
|
{
|
||||||
|
ClipperLib::Path polygon2path;
|
||||||
|
for (const auto& v : path)
|
||||||
|
{
|
||||||
|
polygon2path.push_back(toClipperPoint(v));
|
||||||
|
}
|
||||||
|
|
||||||
|
clpr.AddPath(polygon2path, ClipperLib::ptClip, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
ClipperLib::Paths solution;
|
||||||
|
clpr.Execute(ClipperLib::ctDifference, solution, ClipperLib::pftEvenOdd, ClipperLib::pftEvenOdd);
|
||||||
|
|
||||||
|
std::vector<std::vector<cvf::Vec3d>> clippedPolygons;
|
||||||
|
|
||||||
|
// Convert back to std::vector<std::vector<cvf::Vec3d> >
|
||||||
|
for (ClipperLib::Path pathInSol : solution)
|
||||||
|
{
|
||||||
|
std::vector<cvf::Vec3d> clippedPolygon;
|
||||||
|
for (ClipperLib::IntPoint IntPosition : pathInSol)
|
||||||
|
{
|
||||||
|
clippedPolygon.push_back(fromClipperPoint(IntPosition));
|
||||||
|
}
|
||||||
|
|
||||||
|
clippedPolygons.push_back(clippedPolygon);
|
||||||
|
}
|
||||||
|
|
||||||
|
return clippedPolygons;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -39,8 +39,12 @@ public:
|
|||||||
static void findCellLocalXYZ(const std::array<cvf::Vec3d, 8>& hexCorners, cvf::Vec3d &localXdirection, cvf::Vec3d &localYdirection, cvf::Vec3d &localZdirection);
|
static void findCellLocalXYZ(const std::array<cvf::Vec3d, 8>& hexCorners, cvf::Vec3d &localXdirection, cvf::Vec3d &localYdirection, cvf::Vec3d &localZdirection);
|
||||||
|
|
||||||
static double polygonLengthInLocalXdirWeightedByArea(std::vector<cvf::Vec3d> polygon2d);
|
static double polygonLengthInLocalXdirWeightedByArea(std::vector<cvf::Vec3d> polygon2d);
|
||||||
|
|
||||||
static std::vector<std::vector<cvf::Vec3d> > intersectPolygons(std::vector<cvf::Vec3d> polygon1, std::vector<cvf::Vec3d> polygon2);
|
static std::vector<std::vector<cvf::Vec3d>> intersectPolygons(std::vector<cvf::Vec3d> polygon1,
|
||||||
|
std::vector<cvf::Vec3d> polygon2);
|
||||||
|
|
||||||
|
static std::vector<std::vector<cvf::Vec3d>> subtractPolygons(const std::vector<cvf::Vec3d>& sourcePolygon,
|
||||||
|
const std::vector<std::vector<cvf::Vec3d>>& polygonToSubtract);
|
||||||
|
|
||||||
enum ZInterpolationType { INTERPOLATE_LINE_Z, USE_HUGEVAL, USE_ZERO};
|
enum ZInterpolationType { INTERPOLATE_LINE_Z, USE_HUGEVAL, USE_ZERO};
|
||||||
static std::vector<std::vector<cvf::Vec3d> > clipPolylineByPolygon(const std::vector<cvf::Vec3d>& polyLine,
|
static std::vector<std::vector<cvf::Vec3d> > clipPolylineByPolygon(const std::vector<cvf::Vec3d>& polyLine,
|
||||||
|
|||||||
Reference in New Issue
Block a user