From fefeb483e511919af31b7e6e5c4719deb95fd748 Mon Sep 17 00:00:00 2001 From: Prokhorov Kirill Date: Tue, 9 Dec 2025 12:56:53 +0300 Subject: [PATCH] Fix bug 78932 --- DesktopEditor/graphics/BooleanOperations.cpp | 20 +++++++++++++------- DesktopEditor/graphics/BooleanOperations.h | 3 ++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/DesktopEditor/graphics/BooleanOperations.cpp b/DesktopEditor/graphics/BooleanOperations.cpp index 2695a638f8..3e59f42b75 100644 --- a/DesktopEditor/graphics/BooleanOperations.cpp +++ b/DesktopEditor/graphics/BooleanOperations.cpp @@ -737,11 +737,13 @@ CBooleanOperations::CBooleanOperations(const CGraphicsPath& path1, const CGraphicsPath& path2, BooleanOpType op, long fillType, - bool isLuminosity) : + bool isLuminosity, + bool isSelf) : Op(op), Close1(path1.Is_poly_closed()), Close2(path2.Is_poly_closed()), IsLuminosity(isLuminosity), + IsSelf(isSelf), FillType(fillType), Path1(path1), Path2(path2) @@ -784,10 +786,9 @@ bool CBooleanOperations::IsSelfInters(const CGraphicsPath& p) void CBooleanOperations::TraceBoolean() { bool reverse = false; - bool self = Path1 == Path2; if (((Op == Subtraction || Op == Exclusion) ^ Path1.IsClockwise() ^ - Path2.IsClockwise()) && !self) + Path2.IsClockwise()) && !IsSelf) reverse = true; PreparePath(Path1, 1, Segments1, Curves1); @@ -798,7 +799,7 @@ void CBooleanOperations::TraceBoolean() GetIntersection(); - if (self) + if (IsSelf) { if (Op == Subtraction) return; @@ -823,6 +824,11 @@ void CBooleanOperations::TraceBoolean() CreateNewPath(adj_matr); return; } + else if (Path1 == Path2) + { + Result = std::move(Path1); + return; + } if (!Locations.empty()) { @@ -2355,7 +2361,7 @@ CGraphicsPath CalcBooleanOperation(const CGraphicsPath& path1, CBooleanOperations o; if (i > skip_end2 && o.IsSelfInters(paths2[i])) { - CBooleanOperations operation(paths2[i], paths2[i], Intersection, fillType, isLuminosity); + CBooleanOperations operation(paths2[i], paths2[i], Intersection, fillType, isLuminosity, true); CGraphicsPath p = std::move(operation.GetResult()); std::vector tmp_paths = p.GetSubPaths(); @@ -2370,7 +2376,7 @@ CGraphicsPath CalcBooleanOperation(const CGraphicsPath& path1, CBooleanOperations o2; if (j > skip_end1 && o2.IsSelfInters(paths1[j])) { - CBooleanOperations operation(paths1[j], paths1[j], Intersection, fillType, isLuminosity); + CBooleanOperations operation(paths1[j], paths1[j], Intersection, fillType, isLuminosity, true); CGraphicsPath p = std::move(operation.GetResult()); std::vector tmp_paths = p.GetSubPaths(); @@ -2380,7 +2386,7 @@ CGraphicsPath CalcBooleanOperation(const CGraphicsPath& path1, paths1.insert(paths1.begin() + i + k, tmp_paths[k]); } - CBooleanOperations operation(paths1[j], paths2[i], op, fillType, isLuminosity); + CBooleanOperations operation(paths1[j], paths2[i], op, fillType, isLuminosity, false); paths.push_back(operation.GetResult()); } diff --git a/DesktopEditor/graphics/BooleanOperations.h b/DesktopEditor/graphics/BooleanOperations.h index 8420f538da..c18fc2fe20 100644 --- a/DesktopEditor/graphics/BooleanOperations.h +++ b/DesktopEditor/graphics/BooleanOperations.h @@ -108,7 +108,7 @@ namespace Aggplus { public: CBooleanOperations() {}; - CBooleanOperations(const CGraphicsPath& path1, const CGraphicsPath& path2, BooleanOpType op, long fillType, bool isLuminosity); + CBooleanOperations(const CGraphicsPath& path1, const CGraphicsPath& path2, BooleanOpType op, long fillType, bool isLuminosity, bool isSelf); ~CBooleanOperations(); CGraphicsPath&& GetResult(); bool IsSelfInters(const CGraphicsPath& p); @@ -166,6 +166,7 @@ namespace Aggplus bool Close1 = true; bool Close2 = true; bool IsLuminosity = false; + bool IsSelf = false; // c_nStroke, c_nWindingFillMode, c_nEvenOddFillMode long FillType = c_nWindingFillMode;