From 47c319aa2d954c25774d61b0924bcaf87faa3a5c Mon Sep 17 00:00:00 2001 From: Richard Brice <37087370+RickBrice@users.noreply.github.com> Date: Fri, 29 Sep 2023 08:02:33 -0700 Subject: [PATCH] Adds a continuity check for IfcCurveSegment --- src/ifcgeom/mapping/IfcCompositeCurve.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/ifcgeom/mapping/IfcCompositeCurve.cpp b/src/ifcgeom/mapping/IfcCompositeCurve.cpp index 1124cd083e..9f5221fe9f 100644 --- a/src/ifcgeom/mapping/IfcCompositeCurve.cpp +++ b/src/ifcgeom/mapping/IfcCompositeCurve.cpp @@ -67,9 +67,22 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCompositeCurve* inst) { #ifdef SCHEMA_HAS_IfcCurveSegment else if (segment->as()) { auto crv = map(segment->as()); - for (auto& s : taxonomy::cast(crv)->children) { - loop->children.push_back(s); + auto crv_as_loop = taxonomy::cast(crv); + + // The end of the previous segment must be at the same location as the start of this segment + // @todo - need to apply some tolerancing + if (!loop->children.empty() and !crv_as_loop->children.empty() + and + boost::get(loop->children.back()->end)->components() != boost::get(crv_as_loop->children.front()->start)->components()) + { + std::ostringstream os; + auto& prev = boost::get(loop->children.back()->end)->components(); + auto& next = boost::get(crv_as_loop->children.front()->start)->components(); + os << "Common points are not continuous: (" << prev.x() << ", " << prev.y() << ", " << prev.z() << ")" << " " << "(" << next.x() << ", " << next.y() << ", " << next.z() << ")" << std::endl; + Logger::Notice(os.str()); } + + loop->children.insert(loop->children.end(), crv_as_loop->children.begin(), crv_as_loop->children.end()); } #endif }