From 8b823bd63118f604a83d661c50e2266d0a484c38 Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Tue, 22 Jan 2013 16:08:44 +0100 Subject: [PATCH] - Ifc: improve heuristic to detect unwanted crossing lines by not running it when the window is not the result of arbitrary boolean ops on rectangles. --- code/IFCGeometry.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/code/IFCGeometry.cpp b/code/IFCGeometry.cpp index 563228556..7e3f06baf 100644 --- a/code/IFCGeometry.cpp +++ b/code/IFCGeometry.cpp @@ -963,11 +963,13 @@ struct ProjectedWindowContour Contour contour; BoundingBox bb; SkipList skiplist; + bool is_rectangular; - ProjectedWindowContour(const Contour& contour, const BoundingBox& bb) + ProjectedWindowContour(const Contour& contour, const BoundingBox& bb, bool is_rectangular) : contour(contour) , bb(bb) + , is_rectangular(is_rectangular) {} @@ -1662,7 +1664,15 @@ void CloseWindows(ContourVector& contours, FindAdjacentContours(it, contours); FindBorderContours(it); - FindLikelyCrossingLines(it); + + // if the window is the result of a finite union or intersection of rectangles, + // there shouldn't be any crossing or diagonal lines in it. Such lines would + // be artifacts caused by numerical inaccuracies or other bugs in polyclipper + // and our own code. Since rectangular openings are by far the most frequent + // case, it is worth filtering for this corner case. + if((*it).is_rectangular) { + FindLikelyCrossingLines(it); + } ai_assert((*it).skiplist.size() == (*it).contour.size()); @@ -2013,12 +2023,18 @@ bool GenerateOpenings(std::vector& openings, } std::vector joined_openings(1, &opening); + bool is_rectangle = temp_contour.size() == 4; + // See if this BB intersects or is in close adjacency to any other BB we have so far. for (ContourVector::iterator it = contours.begin(); it != contours.end(); ) { const BoundingBox& ibb = (*it).bb; if (BoundingBoxesOverlapping(ibb, bb)) { + if (!(*it).is_rectangular) { + is_rectangle = false; + } + const std::vector& other = (*it).contour; ClipperLib::ExPolygons poly; @@ -2086,7 +2102,7 @@ bool GenerateOpenings(std::vector& openings, joined_openings.end())); } - contours.push_back(ProjectedWindowContour(temp_contour, bb)); + contours.push_back(ProjectedWindowContour(temp_contour, bb, is_rectangle)); } }