Some more checks and fixes in the IfcBooleanResult code. Most notably set the result to FirstOperand in case healing the result fails.

This commit is contained in:
Thomas Krijnen
2015-02-06 17:14:05 +00:00
parent a7c0c08725
commit def1328a91
2 changed files with 27 additions and 12 deletions
+9 -1
View File
@@ -765,6 +765,8 @@ bool IfcGeom::Kernel::flatten_shape_list(const IfcGeom::IfcRepresentationShapeIt
if (shapes.size() == 1) { if (shapes.size() == 1) {
result = moved_shape; result = moved_shape;
const double precision = getValue(GV_PRECISION);
apply_tolerance(result, precision);
return true; return true;
} }
@@ -791,7 +793,13 @@ bool IfcGeom::Kernel::flatten_shape_list(const IfcGeom::IfcRepresentationShapeIt
} }
} }
return !result.IsNull(); const bool success = !result.IsNull();
if (success) {
const double precision = getValue(GV_PRECISION);
apply_tolerance(result, precision);
}
return success;
} }
void IfcGeom::Kernel::remove_redundant_points_from_loop(TColgp_SequenceOfPnt& polygon, bool closed, double tol) { void IfcGeom::Kernel::remove_redundant_points_from_loop(TColgp_SequenceOfPnt& polygon, bool closed, double tol) {
+16 -9
View File
@@ -286,6 +286,8 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcBooleanResult* l, TopoDS_Shape
if ( ! convert_shape(operand1, s1) ) { if ( ! convert_shape(operand1, s1) ) {
return false; return false;
} }
{ TopoDS_Solid temp_solid;
s1 = ensure_fit_for_subtraction(s1, temp_solid); }
} }
const double first_operand_volume = shape_volume(s1); const double first_operand_volume = shape_volume(s1);
@@ -297,6 +299,10 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcBooleanResult* l, TopoDS_Shape
shape2_processed = convert_shapes(operand2, items2) && flatten_shape_list(items2, s2, true); shape2_processed = convert_shapes(operand2, items2) && flatten_shape_list(items2, s2, true);
} else { } else {
shape2_processed = convert_shape(operand2,s2); shape2_processed = convert_shape(operand2,s2);
if (shape2_processed && !is_halfspace) {
TopoDS_Solid temp_solid;
s2 = ensure_fit_for_subtraction(s2, temp_solid);
}
} }
if (!shape2_processed) { if (!shape2_processed) {
@@ -321,8 +327,12 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcBooleanResult* l, TopoDS_Shape
TopoDS_Shape result = brep_cut; TopoDS_Shape result = brep_cut;
ShapeFix_Shape fix(result); ShapeFix_Shape fix(result);
try {
fix.Perform(); fix.Perform();
result = fix.Shape(); result = fix.Shape();
} catch (...) {
Logger::Message(Logger::LOG_WARNING, "Shape healing failed on boolean result", l->entity);
}
bool is_valid = BRepCheck_Analyzer(result).IsValid() != 0; bool is_valid = BRepCheck_Analyzer(result).IsValid() != 0;
if ( is_valid ) { if ( is_valid ) {
@@ -355,10 +365,9 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcBooleanResult* l, TopoDS_Shape
bool is_valid = BRepCheck_Analyzer(result).IsValid() != 0; bool is_valid = BRepCheck_Analyzer(result).IsValid() != 0;
if ( is_valid ) { if ( is_valid ) {
shape = result; shape = result;
}
}
return true; return true;
}
}
} else if (op == IfcSchema::IfcBooleanOperator::IfcBooleanOperator_INTERSECTION) { } else if (op == IfcSchema::IfcBooleanOperator::IfcBooleanOperator_INTERSECTION) {
@@ -373,16 +382,14 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcBooleanResult* l, TopoDS_Shape
bool is_valid = BRepCheck_Analyzer(result).IsValid() != 0; bool is_valid = BRepCheck_Analyzer(result).IsValid() != 0;
if ( is_valid ) { if ( is_valid ) {
shape = result; shape = result;
}
}
return true; return true;
} else {
return false;
} }
} }
}
return false;
}
bool IfcGeom::Kernel::convert(const IfcSchema::IfcConnectedFaceSet* l, TopoDS_Shape& shape) { bool IfcGeom::Kernel::convert(const IfcSchema::IfcConnectedFaceSet* l, TopoDS_Shape& shape) {
IfcSchema::IfcFace::list::ptr faces = l->CfsFaces(); IfcSchema::IfcFace::list::ptr faces = l->CfsFaces();
bool facesAdded = false; bool facesAdded = false;