+/**
+ * This function performs extra edges removal.
+ *
+ * \param theShape the shape to be processed.
+ * \return the modified shape or null shape in case of failure.
+ */
+static TopoDS_Shape RemoveExtraEdges(const TopoDS_Shape &theShape)
+{
+ TopoDS_Shape aResult;
+
+ if (theShape.IsNull() == Standard_False) {
+ BlockFix_BlockFixAPI aTool;
+
+ aTool.OptimumNbFaces() = 0;
+ aTool.SetShape(theShape);
+ aTool.Perform();
+ aResult = aTool.Shape();
+
+ // Repair result
+ BRepCheck_Analyzer anAna (aResult, false);
+ Standard_Boolean isValid = anAna.IsValid();
+
+ if (!isValid) {
+ TopoDS_Shape aFixed;
+ ShHealOper_ShapeProcess aHealer;
+
+ aHealer.Perform(aResult, aFixed);
+
+ if (aHealer.isDone()) {
+ aResult = aFixed;
+ anAna.Init(aResult, false);
+ isValid = anAna.IsValid();
+ }
+ }
+
+ if (!isValid) {
+ aResult.Nullify();
+ }
+ }
+
+ return aResult;
+}
+