mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 22:33:33 +00:00
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:
@@ -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) {
|
||||||
|
|||||||
@@ -283,9 +283,11 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcBooleanResult* l, TopoDS_Shape
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
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) {
|
||||||
@@ -305,7 +311,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcBooleanResult* l, TopoDS_Shape
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! is_halfspace ) {
|
if (!is_halfspace) {
|
||||||
const double second_operand_volume = shape_volume(s2);
|
const double second_operand_volume = shape_volume(s2);
|
||||||
if ( second_operand_volume <= ALMOST_ZERO )
|
if ( second_operand_volume <= ALMOST_ZERO )
|
||||||
Logger::Message(Logger::LOG_WARNING,"Empty solid for:",operand2->entity);
|
Logger::Message(Logger::LOG_WARNING,"Empty solid for:",operand2->entity);
|
||||||
@@ -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);
|
||||||
fix.Perform();
|
try {
|
||||||
result = fix.Shape();
|
fix.Perform();
|
||||||
|
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,11 +365,10 @@ 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) {
|
||||||
|
|
||||||
BRepAlgoAPI_Common brep_common(s1,s2);
|
BRepAlgoAPI_Common brep_common(s1,s2);
|
||||||
@@ -373,14 +382,12 @@ 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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user