if ( !GEOMUtils::CheckShape(aShape, true) && !GEOMUtils::FixShapeTolerance(aShape) )
Standard_ConstructionError::Raise("Boolean operation aborted : non valid shape result");
- // BEGIN: Mantis issue 0021060: always limit tolerance of BOP result
- // 1. Get shape parameters for comparison
- int nbTypes [TopAbs_SHAPE];
- {
- for (int iType = 0; iType < TopAbs_SHAPE; ++iType)
- nbTypes[iType] = 0;
- nbTypes[aShape.ShapeType()]++;
-
- TopTools_MapOfShape aMapOfShape;
- aMapOfShape.Add(aShape);
- TopTools_ListOfShape aListOfShape;
- aListOfShape.Append(aShape);
-
- TopTools_ListIteratorOfListOfShape itL (aListOfShape);
- for (; itL.More(); itL.Next()) {
- TopoDS_Iterator it (itL.Value());
- for (; it.More(); it.Next()) {
- TopoDS_Shape s = it.Value();
- if (aMapOfShape.Add(s)) {
- aListOfShape.Append(s);
- nbTypes[s.ShapeType()]++;
- }
- }
- }
- }
-
- // 2. Limit tolerance
- TopoDS_Shape aShapeCopy;
- TColStd_IndexedDataMapOfTransientTransient aMapTShapes;
- TNaming_CopyShape::CopyTool(aShape, aMapTShapes, aShapeCopy);
-
- if ( GEOMUtils::FixShapeTolerance(aShapeCopy, true) ) {
- int iType, nbTypesCopy [TopAbs_SHAPE];
-
- for (iType = 0; iType < TopAbs_SHAPE; ++iType)
- nbTypesCopy[iType] = 0;
- nbTypesCopy[aShapeCopy.ShapeType()]++;
-
- TopTools_MapOfShape aMapOfShape;
- aMapOfShape.Add(aShapeCopy);
- TopTools_ListOfShape aListOfShape;
- aListOfShape.Append(aShapeCopy);
-
- TopTools_ListIteratorOfListOfShape itL (aListOfShape);
- for (; itL.More(); itL.Next()) {
- TopoDS_Iterator it (itL.Value());
- for (; it.More(); it.Next()) {
- TopoDS_Shape s = it.Value();
- if (aMapOfShape.Add(s)) {
- aListOfShape.Append(s);
- nbTypesCopy[s.ShapeType()]++;
- }
- }
- }
-
- bool isEqual = true;
- for (iType = 0; iType < TopAbs_SHAPE && isEqual; ++iType) {
- if (nbTypes[iType] != nbTypesCopy[iType])
- isEqual = false;
- }
- if (isEqual)
- aShape = aShapeCopy;
- }
- // END: Mantis issue 0021060
-
return aShape;
}