diff --git a/src/ifcgeom/mapping/IfcTriangulatedFaceSet.cpp b/src/ifcgeom/mapping/IfcTriangulatedFaceSet.cpp index 62886fdffd..776ea59605 100644 --- a/src/ifcgeom/mapping/IfcTriangulatedFaceSet.cpp +++ b/src/ifcgeom/mapping/IfcTriangulatedFaceSet.cpp @@ -49,17 +49,22 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTriangulatedFaceSet* inst) { auto loop = taxonomy::make(); fa->children = { loop }; loop->external = true; - taxonomy::point3::ptr previous; + taxonomy::point3::ptr first, previous; for (std::vector::const_iterator jt = indices.begin(); jt != indices.end(); ++jt) { if (*jt < 1 || *jt > max_index) { throw IfcParse::IfcException("IfcTriangulatedFaceSet index out of bounds for index " + boost::lexical_cast(*jt)); } const taxonomy::point3::ptr& current = points[(*jt) - 1]; - if (jt != indices.begin()) { + if (jt == indices.begin()) { + first = current; + } else { loop->children.push_back(taxonomy::make(previous, current)); } previous = current; } + if (first && previous != first) { + loop->children.push_back(taxonomy::make(previous, first)); + } } }