diff --git a/CPP/CMakeLists.txt b/CPP/CMakeLists.txt index f95dd295..df30921e 100644 --- a/CPP/CMakeLists.txt +++ b/CPP/CMakeLists.txt @@ -31,7 +31,8 @@ endif () include(GNUInstallDirs) set(CLIPPER2_INC_FOLDER ${PROJECT_SOURCE_DIR}/Clipper2Lib/include/clipper2) -configure_file(clipper.version.in ${CLIPPER2_INC_FOLDER}/clipper.version.h) +configure_file(clipper.version.in + ${CLIPPER2_INC_FOLDER}/clipper.version.h NEWLINE_STYLE UNIX) set(CLIPPER2_INC ${CLIPPER2_INC_FOLDER}/clipper.h diff --git a/CPP/Clipper2Lib/include/clipper2/clipper.core.h b/CPP/Clipper2Lib/include/clipper2/clipper.core.h index 75075cb1..0368d4b4 100644 --- a/CPP/Clipper2Lib/include/clipper2/clipper.core.h +++ b/CPP/Clipper2Lib/include/clipper2/clipper.core.h @@ -730,7 +730,7 @@ namespace Clipper2Lib return Area(poly) >= 0; } -#if CLIPPER2_HI_PRECISION +#if CLIPPER2_HI_PRECISION // caution: this will compromise performance // https://github.com/AngusJohnson/Clipper2/issues/317#issuecomment-1314023253 // See also CPP/BenchMark/GetIntersectPtBenchmark.cpp @@ -756,9 +756,9 @@ namespace Clipper2Lib T bb1maxy = CC_MAX(ln2a.y, ln2b.y); T originx = (CC_MIN(bb0maxx, bb1maxx) + CC_MAX(bb0minx, bb1minx)) >> 1; T originy = (CC_MIN(bb0maxy, bb1maxy) + CC_MAX(bb0miny, bb1miny)) >> 1; - double ln0c = (ln1dy * static_cast(ln1a.x - originx)) + + double ln0c = (ln1dy * static_cast(ln1a.x - originx)) + (ln1dx * static_cast(ln1a.y - originy)); - double ln1c = (ln2dy * static_cast(ln2a.x - originx)) + + double ln1c = (ln2dy * static_cast(ln2a.x - originx)) + (ln2dx * static_cast(ln2a.y - originy)); double hitx = ((ln1dx * ln1c) - (ln2dx * ln0c)) / det; double hity = ((ln2dy * ln0c) - (ln1dy * ln1c)) / det; @@ -774,7 +774,7 @@ namespace Clipper2Lib } return true; } -#else +#else template inline bool GetIntersectPoint(const Point& ln1a, const Point& ln1b, const Point& ln2a, const Point& ln2b, Point& ip) @@ -788,7 +788,7 @@ namespace Clipper2Lib double det = dy1 * dx2 - dy2 * dx1; if (det == 0.0) return false; double t = ((ln1a.x - ln2a.x) * dy2 - (ln1a.y - ln2a.y) * dx2) / det; - if (t <= 0.0) ip = ln1a; + if (t <= 0.0) ip = ln1a; else if (t >= 1.0) ip = ln1b; else { diff --git a/CPP/Clipper2Lib/include/clipper2/clipper.engine.h b/CPP/Clipper2Lib/include/clipper2/clipper.engine.h index 9dd55db7..4ff62cb2 100644 --- a/CPP/Clipper2Lib/include/clipper2/clipper.engine.h +++ b/CPP/Clipper2Lib/include/clipper2/clipper.engine.h @@ -33,7 +33,7 @@ namespace Clipper2Lib { //Note: all clipping operations except for Difference are commutative. enum class ClipType { None, Intersection, Union, Difference, Xor }; - + enum class PathType { Subject, Clip }; enum class JoinWith { None, Left, Right }; @@ -106,7 +106,7 @@ namespace Clipper2Lib { //Important: UP and DOWN here are premised on Y-axis positive down //displays, which is the orientation used in Clipper's development. /////////////////////////////////////////////////////////////////// - + struct Active { Point64 bot; Point64 top; @@ -251,7 +251,7 @@ namespace Clipper2Lib { void JoinOutrecPaths(Active &e1, Active &e2); void FixSelfIntersects(OutRec* outrec); void DoSplitOp(OutRec* outRec, OutPt* splitOp); - + inline void AddTrialHorzJoin(OutPt* op); void ConvertHorzSegsToJoins(); void ProcessHorzJoins(); @@ -331,7 +331,7 @@ namespace Clipper2Lib { unsigned lvl = Level(); //Even levels except level 0 return lvl && !(lvl & 1); - } + } }; typedef typename std::vector> PolyPath64List; @@ -420,7 +420,7 @@ namespace Clipper2Lib { void SetScale(double value) { scale_ = value; } double Scale() const { return scale_; } - + PolyPathD* AddChild(const Path64& path) override { int error_code = 0; diff --git a/CPP/Clipper2Lib/src/clipper.offset.cpp b/CPP/Clipper2Lib/src/clipper.offset.cpp index 2b05409f..70189087 100644 --- a/CPP/Clipper2Lib/src/clipper.offset.cpp +++ b/CPP/Clipper2Lib/src/clipper.offset.cpp @@ -67,7 +67,7 @@ int GetLowestClosedPathIdx(std::vector& boundsList) int i = -1, result = -1; Point64 botPt = Point64(INT64_MAX, INT64_MIN); for (const Rect64& r : boundsList) - { + { ++i; if (!r.IsValid()) continue; // ignore invalid paths else if (r.bottom > botPt.y || (r.bottom == botPt.y && r.left < botPt.x)) @@ -103,7 +103,7 @@ inline double Hypot(double x, double y) } inline PointD NormalizeVector(const PointD& vec) -{ +{ double h = Hypot(vec.x, vec.y); if (AlmostZero(h)) return PointD(0,0); double inverseHypot = 1 / h; @@ -358,7 +358,7 @@ void ClipperOffset::OffsetPoint(Group& group, const Path64& path, size_t j, size // is concave path_out.push_back(GetPerpendic(path[j], norms[k], group_delta_)); // this extra point is the only (simple) way to ensure that - // path reversals are fully cleaned with the trailing clipper + // path reversals are fully cleaned with the trailing clipper path_out.push_back(path[j]); // (#405) path_out.push_back(GetPerpendic(path[j], norms[j], group_delta_)); } @@ -394,7 +394,7 @@ void ClipperOffset::OffsetOpenJoined(Group& group, const Path64& path) OffsetPolygon(group, path); Path64 reverse_path(path); std::reverse(reverse_path.begin(), reverse_path.end()); - + //rebuild normals // BuildNormals(path); std::reverse(norms.begin(), norms.end()); norms.push_back(norms[0]); @@ -408,7 +408,7 @@ void ClipperOffset::OffsetOpenPath(Group& group, const Path64& path) { // do the line start cap if (deltaCallback64_) group_delta_ = deltaCallback64_(path, norms, 0, 0); - + if (std::fabs(group_delta_) <= floating_point_tolerance) path_out.push_back(path[0]); else @@ -426,7 +426,7 @@ void ClipperOffset::OffsetOpenPath(Group& group, const Path64& path) break; } } - + size_t highI = path.size() - 1; // offset the left side going forward for (Path64::size_type j = 1, k = 0; j < highI; k = j, ++j)