Fix triangulated face set #5020

This commit is contained in:
Thomas Krijnen
2024-07-17 03:26:23 +02:00
parent 70336f179d
commit 669b0b8c83
@@ -49,17 +49,22 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTriangulatedFaceSet* inst) {
auto loop = taxonomy::make<taxonomy::loop>(); auto loop = taxonomy::make<taxonomy::loop>();
fa->children = { loop }; fa->children = { loop };
loop->external = true; loop->external = true;
taxonomy::point3::ptr previous; taxonomy::point3::ptr first, previous;
for (std::vector<int>::const_iterator jt = indices.begin(); jt != indices.end(); ++jt) { for (std::vector<int>::const_iterator jt = indices.begin(); jt != indices.end(); ++jt) {
if (*jt < 1 || *jt > max_index) { if (*jt < 1 || *jt > max_index) {
throw IfcParse::IfcException("IfcTriangulatedFaceSet index out of bounds for index " + boost::lexical_cast<std::string>(*jt)); throw IfcParse::IfcException("IfcTriangulatedFaceSet index out of bounds for index " + boost::lexical_cast<std::string>(*jt));
} }
const taxonomy::point3::ptr& current = points[(*jt) - 1]; 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<taxonomy::edge>(previous, current)); loop->children.push_back(taxonomy::make<taxonomy::edge>(previous, current));
} }
previous = current; previous = current;
} }
if (first && previous != first) {
loop->children.push_back(taxonomy::make<taxonomy::edge>(previous, first));
}
} }
} }