diff --git a/src/ifcgeom/IfcGeomRepresentation.h b/src/ifcgeom/IfcGeomRepresentation.h index 0ca0717e1f..b20c646cf3 100644 --- a/src/ifcgeom/IfcGeomRepresentation.h +++ b/src/ifcgeom/IfcGeomRepresentation.h @@ -117,6 +117,7 @@ namespace IfcGeom { std::vector

uvs_; std::vector _material_ids; std::vector _materials; + size_t weld_offset_; VertexKeyMap welds; public: @@ -130,10 +131,15 @@ namespace IfcGeom { const std::vector& materials() const { return _materials; } Triangulation(const BRep& shape_model) - : Representation(shape_model.settings()) - , id_(shape_model.id()) + : Representation(shape_model.settings()) + , id_(shape_model.id()) + , weld_offset_(0) { for ( IfcGeom::IfcRepresentationShapeItems::const_iterator iit = shape_model.begin(); iit != shape_model.end(); ++ iit ) { + + // Don't weld vertices that belong to different items to prevent non-manifold situations. + weld_offset_ += welds.size(); + welds.clear(); int surface_style_id = -1; if (iit->hasStyle()) { @@ -386,7 +392,7 @@ namespace IfcGeom { const VertexKey key = std::make_pair(material_index, std::make_pair(X, std::make_pair(Y, Z))); typename VertexKeyMap::const_iterator it = welds.find(key); if ( it != welds.end() ) return it->second; - i = (int) welds.size(); + i = (int) welds.size() + weld_offset_; welds[key] = i; } _verts.push_back(X);