From de6e6858faf17f9418f686931e91057eb5c6d145 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 21 Aug 2017 22:05:15 +0200 Subject: [PATCH] #1794 Include Clipper library inside ifdef USE_PROTOTYPE_FEATURE_FRACTURES --- .../RigCellGeometryTools.cpp | 16 +++++++++++--- CMakeLists.txt | 22 +++++++++---------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigCellGeometryTools.cpp b/ApplicationCode/ReservoirDataModel/RigCellGeometryTools.cpp index 4aed46d7c6..ece607293d 100644 --- a/ApplicationCode/ReservoirDataModel/RigCellGeometryTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCellGeometryTools.cpp @@ -24,7 +24,9 @@ #include "cafHexGridIntersectionTools/cafHexGridIntersectionTools.h" #include "cvfBoundingBox.h" +#ifdef USE_PROTOTYPE_FEATURE_FRACTURES #include "clipper/clipper.hpp" +#endif // USE_PROTOTYPE_FEATURE_FRACTURES #include @@ -213,6 +215,8 @@ double RigCellGeometryTools::polygonAreaWeightedLength(cvf::Vec3d directionOfLen return areaWeightedLength; } +#ifdef USE_PROTOTYPE_FEATURE_FRACTURES + double clipperConversionFactor = 10000; //For transform to clipper int ClipperLib::IntPoint toClipperPoint(const cvf::Vec3d& cvfPoint) @@ -238,13 +242,16 @@ cvf::Vec3d fromClipperPoint(const ClipperLib::IntPoint& clipPoint) return cvf::Vec3d (clipPoint.X, clipPoint.Y, zDValue ) /clipperConversionFactor; } +#endif // USE_PROTOTYPE_FEATURE_FRACTURES //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- std::vector > RigCellGeometryTools::intersectPolygons(std::vector polygon1, std::vector polygon2) { + std::vector > clippedPolygons; +#ifdef USE_PROTOTYPE_FEATURE_FRACTURES // Convert to int for clipper library and store as clipper "path" ClipperLib::Path polygon1path; for (cvf::Vec3d& v : polygon1) @@ -266,7 +273,6 @@ std::vector > RigCellGeometryTools::intersectPolygons(st clpr.Execute(ClipperLib::ctIntersection, solution, ClipperLib::pftEvenOdd, ClipperLib::pftEvenOdd); // Convert back to std::vector > - std::vector > clippedPolygons; for (ClipperLib::Path pathInSol : solution) { std::vector clippedPolygon; @@ -276,14 +282,15 @@ std::vector > RigCellGeometryTools::intersectPolygons(st } clippedPolygons.push_back(clippedPolygon); } +#endif // USE_PROTOTYPE_FEATURE_FRACTURES return clippedPolygons; - } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- +#ifdef USE_PROTOTYPE_FEATURE_FRACTURES void fillInterpolatedSubjectZ(ClipperLib::IntPoint& e1bot, ClipperLib::IntPoint& e1top, ClipperLib::IntPoint& e2bot, @@ -336,6 +343,7 @@ void fillUndefinedZ(ClipperLib::IntPoint& e1bot, { pt.Z = std::numeric_limits::max(); } +#endif // USE_PROTOTYPE_FEATURE_FRACTURES //-------------------------------------------------------------------------------------------------- /// Assumes x.y plane polygon. Polyline might have a Z, and the returned Z is the polyline Z, interpolated if it is clipped. @@ -344,7 +352,9 @@ std::vector > RigCellGeometryTools::clipPolylineByPolygo const std::vector& polygon, ZInterpolationType interpolType) { + std::vector > clippedPolyline; +#ifdef USE_PROTOTYPE_FEATURE_FRACTURES //Adjusting polygon to avoid clipper issue with interpolating z-values when lines crosses though polygon vertecies std::vector adjustedPolygon = ajustPolygonToAvoidIntersectionsAtVertex(polyLine, polygon); @@ -386,7 +396,6 @@ std::vector > RigCellGeometryTools::clipPolylineByPolygo ClipperLib::OpenPathsFromPolyTree(solution, solutionPaths); //Convert back to std::vector > - std::vector > clippedPolyline; for (ClipperLib::Path pathInSol : solutionPaths) { std::vector clippedPolygon; @@ -396,6 +405,7 @@ std::vector > RigCellGeometryTools::clipPolylineByPolygo } clippedPolyline.push_back(clippedPolygon); } +#endif // USE_PROTOTYPE_FEATURE_FRACTURES return clippedPolyline; } diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f970ac087..87a25d34a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -228,18 +228,6 @@ list(APPEND THIRD_PARTY_LIBRARIES NRLib ) - -################################################################################ -# clipper -################################################################################ - -add_subdirectory(ThirdParty/clipper) - -list(APPEND THIRD_PARTY_LIBRARIES - clipper -) - - ################################################################################ # Qt ################################################################################ @@ -291,6 +279,16 @@ if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) ################################################################################ include_directories(SYSTEM ThirdParty/Eigen-Subset) + ################################################################################ + # clipper + ################################################################################ + + add_subdirectory(ThirdParty/clipper) + + list(APPEND THIRD_PARTY_LIBRARIES + clipper + ) + endif() # RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES