Project wires onto a plane if non-planar. Fixes #57.

This commit is contained in:
Thomas Krijnen
2016-04-16 14:47:09 +02:00
parent 81ee60079e
commit 884b3fe850
3 changed files with 89 additions and 2 deletions
+13 -2
View File
@@ -202,7 +202,11 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcFace* l, TopoDS_Shape& face) {
ShapeFix_ShapeTolerance FTol;
FTol.SetTolerance(wire, getValue(GV_PRECISION), TopAbs_WIRE);
bool flattened_wire = false;
if (!mf) {
process_wire:
if (face_surface.IsNull()) {
mf = new BRepBuilderAPI_MakeFace(wire);
} else {
@@ -264,9 +268,16 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcFace* l, TopoDS_Shape& face) {
success = true;
}
} else {
Logger::Message(Logger::LOG_ERROR, "Failed to process face boundary", bound->entity);
const bool non_planar = mf->Error() == BRepBuilderAPI_NotPlanar;
delete mf;
return false;
if (!non_planar || flattened_wire || !flatten_wire(wire)) {
Logger::Message(Logger::LOG_ERROR, "Failed to process face boundary", bound->entity);
return false;
} else {
Logger::Message(Logger::LOG_ERROR, "Flattening face boundary", bound->entity);
flattened_wire = true;
goto process_wire;
}
}
} else {