mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 14:02:27 +00:00
- Check the validity of solids created from sewed shells and potentially revert to a shell or compound of faces
- Flag shape representations, for which no item succeeds, as failed
This commit is contained in:
@@ -91,6 +91,7 @@
|
|||||||
#include <TopLoc_Location.hxx>
|
#include <TopLoc_Location.hxx>
|
||||||
|
|
||||||
#include <BRepCheck_Analyzer.hxx>
|
#include <BRepCheck_Analyzer.hxx>
|
||||||
|
#include <BRepClass3d_SolidClassifier.hxx>
|
||||||
|
|
||||||
#include "../ifcgeom/IfcGeom.h"
|
#include "../ifcgeom/IfcGeom.h"
|
||||||
|
|
||||||
@@ -341,6 +342,7 @@ bool IfcGeom::convert(const IfcSchema::IfcConnectedFaceSet* l, TopoDS_Shape& sha
|
|||||||
IfcSchema::IfcFace::list::ptr faces = l->CfsFaces();
|
IfcSchema::IfcFace::list::ptr faces = l->CfsFaces();
|
||||||
bool facesAdded = false;
|
bool facesAdded = false;
|
||||||
const unsigned int num_faces = faces->Size();
|
const unsigned int num_faces = faces->Size();
|
||||||
|
bool valid_shell = false;
|
||||||
if ( num_faces < GetValue(GV_MAX_FACES_TO_SEW) ) {
|
if ( num_faces < GetValue(GV_MAX_FACES_TO_SEW) ) {
|
||||||
BRepOffsetAPI_Sewing builder;
|
BRepOffsetAPI_Sewing builder;
|
||||||
builder.SetTolerance(GetValue(GV_POINT_EQUALITY_TOLERANCE));
|
builder.SetTolerance(GetValue(GV_POINT_EQUALITY_TOLERANCE));
|
||||||
@@ -358,12 +360,22 @@ bool IfcGeom::convert(const IfcSchema::IfcConnectedFaceSet* l, TopoDS_Shape& sha
|
|||||||
if ( ! facesAdded ) return false;
|
if ( ! facesAdded ) return false;
|
||||||
builder.Perform();
|
builder.Perform();
|
||||||
shape = builder.SewedShape();
|
shape = builder.SewedShape();
|
||||||
try {
|
valid_shell = BRepCheck_Analyzer(shape).IsValid();
|
||||||
ShapeFix_Solid solid;
|
if (valid_shell) {
|
||||||
solid.LimitTolerance(GetValue(GV_POINT_EQUALITY_TOLERANCE));
|
try {
|
||||||
shape = solid.SolidFromShell(TopoDS::Shell(shape));
|
ShapeFix_Solid solid;
|
||||||
} catch(...) {}
|
solid.LimitTolerance(GetValue(GV_POINT_EQUALITY_TOLERANCE));
|
||||||
} else {
|
TopoDS_Solid solid_shape = solid.SolidFromShell(TopoDS::Shell(shape));
|
||||||
|
if (!solid_shape.IsNull()) {
|
||||||
|
try {
|
||||||
|
BRepClass3d_SolidClassifier classifier(solid_shape);
|
||||||
|
shape = solid_shape;
|
||||||
|
} catch (...) {}
|
||||||
|
}
|
||||||
|
} catch(...) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!valid_shell) {
|
||||||
TopoDS_Compound compound;
|
TopoDS_Compound compound;
|
||||||
BRep_Builder builder;
|
BRep_Builder builder;
|
||||||
builder.MakeCompound(compound);
|
builder.MakeCompound(compound);
|
||||||
@@ -418,20 +430,24 @@ bool IfcGeom::convert(const IfcSchema::IfcMappedItem* l, IfcRepresentationShapeI
|
|||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IfcGeom::convert(const IfcSchema::IfcShapeRepresentation* l, IfcRepresentationShapeItems& shapes) {
|
bool IfcGeom::convert(const IfcSchema::IfcShapeRepresentation::ptr l, IfcRepresentationShapeItems& shapes) {
|
||||||
IfcSchema::IfcRepresentationItem::list::ptr items = l->Items();
|
IfcSchema::IfcRepresentationItem::list items = l->Items();
|
||||||
if ( ! items->Size() ) return false;
|
bool part_succes = false;
|
||||||
for ( IfcSchema::IfcRepresentationItem::list::it it = items->begin(); it != items->end(); ++ it ) {
|
if ( items->Size() ) {
|
||||||
IfcSchema::IfcRepresentationItem* representation_item = *it;
|
for ( IfcSchema::IfcRepresentationItem::it it = items->begin(); it != items->end(); ++ it ) {
|
||||||
if ( IfcGeom::is_shape_collection(representation_item) ) IfcGeom::convert_shapes(*it,shapes);
|
IfcSchema::IfcRepresentationItem* representation_item = *it;
|
||||||
else {
|
if ( IfcGeom::is_shape_collection(representation_item) ) {
|
||||||
TopoDS_Shape s;
|
part_succes |= IfcGeom::convert_shapes(*it, shapes);
|
||||||
if (IfcGeom::convert_shape(representation_item,s)) {
|
} else {
|
||||||
shapes.push_back(IfcRepresentationShapeItem(s, get_style(representation_item)));
|
TopoDS_Shape s;
|
||||||
|
if (IfcGeom::convert_shape(representation_item,s)) {
|
||||||
|
shapes.push_back(IfcRepresentationShapeItem(s, get_style(representation_item)));
|
||||||
|
part_succes |= true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return part_succes;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IfcGeom::convert(const IfcSchema::IfcGeometricSet* l, IfcRepresentationShapeItems& shapes) {
|
bool IfcGeom::convert(const IfcSchema::IfcGeometricSet* l, IfcRepresentationShapeItems& shapes) {
|
||||||
|
|||||||
Reference in New Issue
Block a user