Modeling - Fix thickness operation regression on circle-to-polygon lofts (#889)

- Fixed CheckMixedContinuity to detect actual mixed concavity
  (both convex and concave regions) instead of any G1/non-G1 transitions
- Added null edge and PCurve checks in RefEdgeInter to prevent crashes
- Added GTests for BRepOffset_MakeOffset covering various loft scenarios
This commit is contained in:
Pasukhin Dmitry
2025-12-07 11:12:27 +00:00
committed by GitHub
parent a873c1c83c
commit b9f46ada4c
10 changed files with 1061 additions and 73 deletions

View File

@@ -152,7 +152,7 @@ Standard_Boolean CheckMixedContinuity(const TopoDS_Edge& theEdge,
// so, if aCurrOrder > C0 it means that faces are tangent along whole edge.
return aMixedCont;
}
// But we caqnnot trust result, if it is C0. because this value set by default.
// But we cannot trust result, if it is C0, because this value is set by default.
Standard_Real TolC0 = std::max(0.001, 1.5 * BRep_Tool::Tolerance(theEdge));
Standard_Real aFirst;
@@ -217,45 +217,15 @@ Standard_Boolean CheckMixedContinuity(const TopoDS_Edge& theEdge,
Standard_Integer aNbSamples = 23;
// Computation of the continuity.
Standard_Real aPar;
Standard_Real aDelta = (aLast - aFirst) / (aNbSamples - 1);
Standard_Integer i, istart = 1;
Standard_Boolean isG1 = Standard_False;
// Check for mixed concavity: convex in some regions, concave in others.
const Standard_Real aDelta = (aLast - aFirst) / (aNbSamples - 1);
bool aHasConvex = false;
bool aHasConcave = false;
Standard_Integer aNbValid = 0;
for (i = 1, aPar = aFirst; i <= aNbSamples; i++, aPar += aDelta)
for (Standard_Integer i = 1; i <= aNbSamples; i++)
{
if (i == aNbSamples)
aPar = aLast;
LocalAnalysis_SurfaceContinuity aCont(aC2d1,
aC2d2,
aPar,
aSurf1,
aSurf2,
GeomAbs_G1,
0.001,
TolC0,
theAngTol,
theAngTol,
theAngTol);
if (aCont.IsDone())
{
istart = i + 1;
isG1 = aCont.IsG1();
break;
}
}
if (istart > aNbSamples / 2)
{
return aMixedCont;
}
for (i = istart, aPar = aFirst; i <= aNbSamples; i++, aPar += aDelta)
{
if (i == aNbSamples)
aPar = aLast;
const Standard_Real aPar = (i == aNbSamples) ? aLast : aFirst + (i - 1) * aDelta;
LocalAnalysis_SurfaceContinuity aCont(aC2d1,
aC2d2,
@@ -273,17 +243,24 @@ Standard_Boolean CheckMixedContinuity(const TopoDS_Edge& theEdge,
continue;
}
if (aCont.IsG1() == isG1)
aNbValid++;
if (!aCont.IsG1() && (!aHasConvex || !aHasConcave))
{
continue;
}
else
{
aMixedCont = Standard_True;
break;
const Standard_Real anAngle = aCont.C0Value();
aHasConvex = aHasConvex || (anAngle > M_PI_2 + theAngTol);
aHasConcave = aHasConcave || (anAngle < M_PI_2 - theAngTol);
}
}
if (aNbValid < aNbSamples / 2)
{
return aMixedCont;
}
// Mixed connectivity: both convex and concave regions exist.
aMixedCont = aHasConvex && aHasConcave;
return aMixedCont;
}

View File

@@ -702,13 +702,17 @@ static void RefEdgeInter(const TopoDS_Face& F,
//
if (E1.IsSame(E2))
return;
if (E1.IsNull() || E2.IsNull())
return;
Standard_Real f[3], l[3];
Standard_Real TolDub = 1.e-7, TolLL = 0.0;
Standard_Integer i;
// BRep_Tool::Range(E1, f[1], l[1]);
// BRep_Tool::Range(E2, f[2], l[2]);
Handle(Geom2d_Curve) pcurve1 = BRep_Tool::CurveOnSurface(E1, F, f[1], l[1]);
Handle(Geom2d_Curve) pcurve2 = BRep_Tool::CurveOnSurface(E2, F, f[2], l[2]);
if (pcurve1.IsNull() || pcurve2.IsNull())
return;
BRepAdaptor_Curve CE1(E1, F);
BRepAdaptor_Curve CE2(E2, F);
@@ -744,10 +748,8 @@ static void RefEdgeInter(const TopoDS_Face& F,
}
}
//
Handle(Geom2d_Curve) pcurve1 = BRep_Tool::CurveOnSurface(E1, F, f[1], l[1]);
Handle(Geom2d_Curve) pcurve2 = BRep_Tool::CurveOnSurface(E2, F, f[2], l[2]);
Geom2dAdaptor_Curve GAC1(pcurve1, f[1], l[1]);
Geom2dAdaptor_Curve GAC2(pcurve2, f[2], l[2]);
Geom2dAdaptor_Curve GAC1(pcurve1, f[1], l[1]);
Geom2dAdaptor_Curve GAC2(pcurve2, f[2], l[2]);
if ((GAC1.GetType() == GeomAbs_Line) && (GAC2.GetType() == GeomAbs_Line))
{
// Just quickly check if lines coincide

File diff suppressed because it is too large Load Diff

View File

@@ -2,4 +2,5 @@
set(OCCT_TKOffset_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
set(OCCT_TKOffset_GTests_FILES
BRepOffset_MakeOffset_Test.cxx
)