From 2bfe59b69cc83748491893e8478d8422215670dc Mon Sep 17 00:00:00 2001 From: akz Date: Thu, 12 Feb 2015 12:08:05 +0300 Subject: [PATCH] 0024881: Wrong status returned by ShapeFix_Wire::FixGaps3d () operation The reason of FAIL status of FixGaps3d is that the trying to convert curves to BSplines on valid edges (both adjacent points saticfy a precision) leads to skipping of the convertation and gives wrong status. Check of the gap on adjacent points before try ro convert curves was added. Test-case for issue #24881 --- src/QABugs/QABugs_19.cxx | 163 +++++++++++++++++++++++++++++++ src/ShapeFix/ShapeFix_Wire_1.cxx | 3 + tests/bugs/heal/bug24881 | 17 ++++ 3 files changed, 183 insertions(+) create mode 100644 tests/bugs/heal/bug24881 diff --git a/src/QABugs/QABugs_19.cxx b/src/QABugs/QABugs_19.cxx index fad3bc0325..54f2ff569d 100755 --- a/src/QABugs/QABugs_19.cxx +++ b/src/QABugs/QABugs_19.cxx @@ -3389,6 +3389,168 @@ static Standard_Integer OCC25547( return 0; } +#include +#include +#include +#include +#include +#ifdef WNT +#define EXCEPTION ... +#else +#define EXCEPTION Standard_Failure +#endif + +static ShapeExtend_Status getStatusGap(const Handle(ShapeFix_Wire)& theFix, + const Standard_Boolean theIs3d) +{ + for (Standard_Integer i=ShapeExtend_OK; i<=ShapeExtend_FAIL; i++) + { + Standard_Boolean isFound; + if (theIs3d) + isFound = theFix->StatusGaps3d( (ShapeExtend_Status) i ); + else + isFound = theFix->StatusGaps2d( (ShapeExtend_Status) i ); + if (isFound) return ShapeExtend_Status(i); + } + return ShapeExtend_OK; +} + +//=================== +//function : OCC24881 +//purpose : +//=================== +static Standard_Integer OCC24881 (Draw_Interpretor& di, Standard_Integer narg , const char** a) +{ + if (narg < 2) { + di<<"Usage: "<Load (aSrcWire); + aWireFix->SetFace (TopoDS::Face(aFace)); + aWireFix->FixReorder(); //correct order is a prerequisite + // fix 3d + if (!aWireFix->FixGaps3d()) + { + // not fixed, why? + aStatus = getStatusGap(aWireFix, Standard_True); + if (aStatus == ShapeExtend_OK) + wasOk = Standard_True; + else + { + // keep 3d fail status + if (aStatusNbDMap.IsBound (aStatus)) + aStatusNbDMap(aStatus)++; + else + aStatusNbDMap.Bind(aStatus,1); + continue; + } + } + + // fix 2d + if (aWireFix->FixGaps2d()) + nbFixed++; + else + { + aStatus = getStatusGap(aWireFix, Standard_False); + if (aStatus == ShapeExtend_OK) + { + if (wasOk) + { + nbOk++; + continue; + } + else + nbFixed++; + } + else + { + // keep 2d fail status + Standard_Integer aStatus2d = aStatus + ShapeExtend_FAIL; + if (aStatusNbDMap.IsBound (aStatus2d)) + aStatusNbDMap(aStatus2d)++; + else + aStatusNbDMap.Bind(aStatus2d,1); + continue; + } + } + } + } +//End: STEP 7 + } catch (EXCEPTION) { + di << "Exception is raised = " <