1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-08 18:40:55 +03:00

0028771: BRepOffset_MakeOffset incorrect result

Correction of tolerance of new edges, which belongs planar faces is improved
Test case added.
This commit is contained in:
ifv 2017-05-23 15:43:23 +03:00 committed by bugmaster
parent 354c94b724
commit 4560c05480
2 changed files with 91 additions and 23 deletions
src/BRepOffset
tests/bugs/modalg_6

@ -314,6 +314,10 @@ static BRepOffset_Error checkSinglePoint(const Standard_Real theUParam,
//--------------------------------------------------------------------- //---------------------------------------------------------------------
static void UpdateTolerance ( TopoDS_Shape& myShape, static void UpdateTolerance ( TopoDS_Shape& myShape,
const TopTools_IndexedMapOfShape& myFaces); const TopTools_IndexedMapOfShape& myFaces);
static Standard_Real ComputeMaxDist(const gp_Pln& thePlane,
const Handle(Geom_Curve)& theCrv,
const Standard_Real theFirst,
const Standard_Real theLast);
static void CorrectSolid(TopoDS_Solid& theSol, TopTools_ListOfShape& theSolList); static void CorrectSolid(TopoDS_Solid& theSol, TopTools_ListOfShape& theSolList);
//--------------------------------------------------------------------- //---------------------------------------------------------------------
@ -3342,8 +3346,32 @@ void BRepOffset_MakeOffset::EncodeRegularity ()
#endif #endif
} }
//=======================================================================
//function : ComputeMaxDist
//purpose :
//=======================================================================
Standard_Real ComputeMaxDist(const gp_Pln& thePlane,
const Handle(Geom_Curve)& theCrv,
const Standard_Real theFirst,
const Standard_Real theLast)
{
Standard_Real aMaxDist = 0.;
Standard_Integer i, NCONTROL = 23;
Standard_Real aPrm, aDist2;
gp_Pnt aP;
for (i = 0; i< NCONTROL; i++) {
aPrm = ((NCONTROL - 1 - i)*theFirst + i*theLast) / (NCONTROL - 1);
aP = theCrv->Value(aPrm);
if (Precision::IsInfinite(aP.X()) || Precision::IsInfinite(aP.Y())
|| Precision::IsInfinite(aP.Z()))
{
return Precision::Infinite();
}
aDist2 = thePlane.SquareDistance(aP);
if (aDist2 > aMaxDist) aMaxDist = aDist2;
}
return sqrt(aMaxDist)*1.05;
}
//======================================================================= //=======================================================================
//function : UpDateTolerance //function : UpDateTolerance
//purpose : //purpose :
@ -3366,14 +3394,41 @@ void UpdateTolerance (TopoDS_Shape& S,
} }
} }
Standard_Real Tol;
TopExp_Explorer ExpF;
for (ExpF.Init(S, TopAbs_FACE); ExpF.More(); ExpF.Next())
{
const TopoDS_Shape& F = ExpF.Current();
if (Faces.Contains(F))
{
continue;
}
BRepAdaptor_Surface aBAS(TopoDS::Face(F), Standard_False);
TopExp_Explorer Exp; TopExp_Explorer Exp;
for (Exp.Init(S,TopAbs_EDGE); Exp.More(); Exp.Next()) { for (Exp.Init(F, TopAbs_EDGE); Exp.More(); Exp.Next()) {
TopoDS_Edge E = TopoDS::Edge(Exp.Current()); TopoDS_Edge E = TopoDS::Edge(Exp.Current());
if (View.Add(E)) { Standard_Boolean isUpdated = Standard_False;
Handle(BRepCheck_Edge) EdgeCorrector = new BRepCheck_Edge(E); if (aBAS.GetType() == GeomAbs_Plane)
Standard_Real Tol = EdgeCorrector->Tolerance(); {
B.UpdateEdge (E,Tol); //Edge does not seem to have pcurve on plane,
//so EdgeCorrector does not include it in tolerance calculation
Standard_Real aFirst, aLast;
Handle(Geom_Curve) aCrv = BRep_Tool::Curve(E, aFirst, aLast);
Standard_Real aMaxDist = ComputeMaxDist(aBAS.Plane(), aCrv, aFirst, aLast);
B.UpdateEdge(E, aMaxDist);
isUpdated = Standard_True;
}
if (View.Add(E))
{
BRepCheck_Edge EdgeCorrector(E);
Tol = EdgeCorrector.Tolerance();
B.UpdateEdge(E, Tol);
isUpdated = Standard_True;
}
if (isUpdated)
{
Tol = BRep_Tool::Tolerance(E);
// Update the vertices. // Update the vertices.
TopExp::Vertices(E, V[0], V[1]); TopExp::Vertices(E, V[0], V[1]);
@ -3381,8 +3436,8 @@ void UpdateTolerance (TopoDS_Shape& S,
if (View.Add(V[i])) { if (View.Add(V[i])) {
Handle(BRep_TVertex) TV = Handle(BRep_TVertex)::DownCast(V[i].TShape()); Handle(BRep_TVertex) TV = Handle(BRep_TVertex)::DownCast(V[i].TShape());
TV->Tolerance(0.); TV->Tolerance(0.);
Handle(BRepCheck_Vertex) VertexCorrector = new BRepCheck_Vertex(V[i]); BRepCheck_Vertex VertexCorrector(V[i]);
B.UpdateVertex (V[i],VertexCorrector->Tolerance()); B.UpdateVertex(V[i], VertexCorrector.Tolerance());
// use the occasion to clean the vertices. // use the occasion to clean the vertices.
(TV->ChangePoints()).Clear(); (TV->ChangePoints()).Clear();
} }
@ -3391,6 +3446,7 @@ void UpdateTolerance (TopoDS_Shape& S,
} }
} }
} }
}
//======================================================================= //=======================================================================
//function : CorrectSolid //function : CorrectSolid

@ -0,0 +1,12 @@
puts "========"
puts "OCC28771"
puts "========"
puts ""
##############################################
# BRepOffset_MakeOffset incorrect result
##############################################
restore [locate_data_file bug28771_shell.brep] s
encoderegularity s 1
thickshell r s .12
checkshape r