mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2569 Fracture containment. Fix fracture border polygon calculation
This commit is contained in:
@@ -455,6 +455,43 @@ double RigCellGeometryTools::getLengthOfPolygonAlongLine(const std::pair<cvf::Ve
|
||||
return length;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<cvf::Vec3d> RigCellGeometryTools::unionOfPolygons(std::vector<std::vector<cvf::Vec3d>> polygons)
|
||||
{
|
||||
// Convert to int for clipper library and store as clipper "path"
|
||||
std::vector<ClipperLib::Path> polygonPaths;
|
||||
for (const std::vector<cvf::Vec3d>& polygon : polygons)
|
||||
{
|
||||
polygonPaths.emplace_back();
|
||||
auto& p = polygonPaths.back();
|
||||
for (const cvf::Vec3d& pp : polygon)
|
||||
{
|
||||
p.push_back(toClipperPoint(pp));
|
||||
}
|
||||
}
|
||||
|
||||
ClipperLib::Clipper clpr;
|
||||
clpr.AddPaths(polygonPaths, ClipperLib::ptSubject, true);
|
||||
|
||||
ClipperLib::Paths solution;
|
||||
clpr.Execute(ClipperLib::ctUnion, solution, ClipperLib::pftEvenOdd, ClipperLib::pftEvenOdd);
|
||||
|
||||
// Convert back to std::vector<std::vector<cvf::Vec3d> >
|
||||
std::vector<cvf::Vec3d> unionPolygon;
|
||||
for (ClipperLib::Path pathInSol : solution)
|
||||
{
|
||||
std::vector<cvf::Vec3d> clippedPolygon;
|
||||
for (ClipperLib::IntPoint IntPosition : pathInSol)
|
||||
{
|
||||
unionPolygon.push_back(fromClipperPoint(IntPosition));
|
||||
}
|
||||
}
|
||||
|
||||
return unionPolygon;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user