1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0026620: Shape healing unreasonably downgrades tolerance of a face

Added face support in SameParameter in classes ShapeAnalysis_Edge, ShapeFix_Edge.

Test case for issue CR26620

Minor correction.
This commit is contained in:
aml
2015-10-22 14:54:59 +03:00
committed by bugmaster
parent 7636352267
commit 98a4340017
9 changed files with 174 additions and 28 deletions

View File

@@ -93,6 +93,9 @@ Standard_Boolean ShapeFix::SameParameter(const TopoDS_Shape& shape,
for ( TopExp_Explorer anEdgeExp(shape, TopAbs_FACE); anEdgeExp.More(); anEdgeExp.Next() )
++aNbFaces;
TopTools_IndexedDataMapOfShapeListOfShape aMapEF;
TopExp::MapShapesAndAncestors(shape, TopAbs_EDGE, TopAbs_FACE, aMapEF);
BRep_Builder B;
//Standard_Integer nbexcp = 0;
Standard_Integer nbfail = 0, numedge = 0;
@@ -129,7 +132,21 @@ Standard_Boolean ShapeFix::SameParameter(const TopoDS_Shape& shape,
B.SameParameter (E,Standard_False);
}
sfe->FixSameParameter (E); // K2-SEP97
TopTools_ListOfShape aListOfFaces;
aMapEF.FindFromKey(E, aListOfFaces);
if (aListOfFaces.Extent() != 0)
{
TopTools_ListOfShape::Iterator aListOfFacesIt(aListOfFaces);
for ( ; aListOfFacesIt.More() ; aListOfFacesIt.Next())
{
TopoDS_Face aF = TopoDS::Face( aListOfFacesIt.Value() );
sfe->FixSameParameter (E, aF);
}
}
else
{
sfe->FixSameParameter (E); // K2-SEP97
}
if (!BRep_Tool::SameParameter (E)) { ierr = 1; nbfail ++; }

View File

@@ -576,7 +576,7 @@ Standard_Boolean ShapeFix_Edge::FixAddPCurve (const TopoDS_Edge& edge,
//purpose :
//=======================================================================
Standard_Boolean ShapeFix_Edge::FixVertexTolerance(const TopoDS_Edge& edge,
Standard_Boolean ShapeFix_Edge::FixVertexTolerance(const TopoDS_Edge& edge,
const TopoDS_Face& face)
{
myStatus = ShapeExtend::EncodeStatus ( ShapeExtend_OK );
@@ -699,7 +699,6 @@ Standard_Boolean ShapeFix_Edge::FixReversed2d (const TopoDS_Edge& edge,
return Standard_True;
}
//=======================================================================
//function : FixSameParameter
//purpose :
@@ -708,8 +707,21 @@ Standard_Boolean ShapeFix_Edge::FixReversed2d (const TopoDS_Edge& edge,
Standard_Boolean ShapeFix_Edge::FixSameParameter(const TopoDS_Edge& edge,
const Standard_Real tolerance)
{
myStatus = ShapeExtend::EncodeStatus ( ShapeExtend_OK );
TopoDS_Face anEmptyFace;
return FixSameParameter(edge, anEmptyFace, tolerance);
}
//=======================================================================
//function : FixSameParameter
//purpose :
//=======================================================================
Standard_Boolean ShapeFix_Edge::FixSameParameter(const TopoDS_Edge& edge,
const TopoDS_Face& face,
const Standard_Real tolerance)
{
myStatus = ShapeExtend::EncodeStatus ( ShapeExtend_OK );
if ( BRep_Tool::Degenerated ( edge ) )
{
BRep_Builder B;
@@ -726,10 +738,10 @@ Standard_Boolean ShapeFix_Edge::FixSameParameter(const TopoDS_Edge& edge,
TopoDS_Edge copyedge;
TopoDS_Vertex V1 = sae.FirstVertex (edge);
TopoDS_Vertex V2 = sae.LastVertex (edge);
Standard_Real TolFV = ( V1.IsNull() ? 0. : BRep_Tool::Tolerance ( V1 ) );
Standard_Real TolLV = ( V2.IsNull() ? 0. : BRep_Tool::Tolerance ( V2 ) );
Standard_Real TolFV = ( V1.IsNull() ? 0.0 : BRep_Tool::Tolerance ( V1 ) );
Standard_Real TolLV = ( V2.IsNull() ? 0.0 : BRep_Tool::Tolerance ( V2 ) );
Standard_Real tol = BRep_Tool::Tolerance (edge);
Standard_Boolean wasSP = BRep_Tool::SameParameter ( edge ), SP = Standard_False;
{
try
@@ -764,14 +776,23 @@ Standard_Boolean ShapeFix_Edge::FixSameParameter(const TopoDS_Edge& edge,
myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_FAIL2 );
}
}
// compute deviation on the original pcurves
Standard_Real maxdev;
B.SameParameter ( edge, Standard_True );
sae.CheckSameParameter ( edge, maxdev );
// Should check all pcurves in case of non-sameparametrization input.
TopoDS_Face aFace = face;
if (!wasSP)
{
TopoDS_Face anEmptyFace;
aFace = anEmptyFace;
}
sae.CheckSameParameter ( edge, aFace, maxdev );
if ( sae.Status ( ShapeExtend_FAIL2 ) )
myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_FAIL1 );
// if BRepLib was OK, compare and select the best variant
if ( SP )
{
@@ -779,7 +800,7 @@ Standard_Boolean ShapeFix_Edge::FixSameParameter(const TopoDS_Edge& edge,
sae.CheckSameParameter ( copyedge, BRLDev );
myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE3 );
if ( BRLTol < BRLDev ) BRLTol = BRLDev;
//chose the best result
if ( BRLTol < maxdev )
{
@@ -796,7 +817,7 @@ Standard_Boolean ShapeFix_Edge::FixSameParameter(const TopoDS_Edge& edge,
//restore tolerances because they could be modified by BRepLib
if ( ! V1.IsNull() ) SFST.SetTolerance ( V1, Max (maxdev, TolFV), TopAbs_VERTEX);
if ( ! V2.IsNull() ) SFST.SetTolerance ( V2, Max (maxdev, TolLV), TopAbs_VERTEX);
if ( maxdev > tol )
{
myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE1 );

View File

@@ -173,6 +173,43 @@ public:
//! DONE5 - if the edge resulting from BRepLib has been chosen, i.e. variant b. above
//! (only for edges with not set SameParameter)
Standard_EXPORT Standard_Boolean FixSameParameter (const TopoDS_Edge& edge, const Standard_Real tolerance = 0.0);
//! Tries to make edge SameParameter and sets corresponding
//! tolerance and SameParameter flag.
//! First, it makes edge same range if SameRange flag is not set.
//!
//! If flag SameParameter is set, this method calls the
//! function ShapeAnalysis_Edge::CheckSameParameter() that
//! calculates the maximal deviation of pcurves of the edge from
//! its 3d curve. If deviation > tolerance, the tolerance of edge
//! is increased to a value of deviation. If deviation < tolerance
//! nothing happens.
//!
//! If flag SameParameter is not set, this method chooses the best
//! variant (one that has minimal tolerance), either
//! a. only after computing deviation (as above) or
//! b. after calling standard procedure BRepLib::SameParameter
//! and computing deviation (as above). If <tolerance> > 0, it is
//! used as parameter for BRepLib::SameParameter, otherwise,
//! tolerance of the edge is used.
//!
//! Use : Is to be called after all pcurves and 3d curve of the edge are
//! correctly computed
//! Remark : SameParameter flag is always set to True after this method
//! Returns: True, if something done, else False
//! Status : OK - edge was initially SameParameter, nothing is done
//! FAIL1 - computation of deviation of pcurves from 3d curve has failed
//! FAIL2 - BRepLib::SameParameter() has failed
//! DONE1 - tolerance of the edge was increased
//! DONE2 - flag SameParameter was set to True (only if
//! BRepLib::SameParameter() did not set it)
//! DONE3 - edge was modified by BRepLib::SameParameter() to SameParameter
//! DONE4 - not used anymore
//! DONE5 - if the edge resulting from BRepLib has been chosen, i.e. variant b. above
//! (only for edges with not set SameParameter)
Standard_EXPORT Standard_Boolean FixSameParameter (const TopoDS_Edge& edge,
const TopoDS_Face& face,
const Standard_Real tolerance = 0.0);
//! Returns the status (in the form of True/False) of last Fix
Standard_EXPORT Standard_Boolean Status (const ShapeExtend_Status status) const;

View File

@@ -842,7 +842,7 @@ Standard_Boolean ShapeFix_Face::FixAddNaturalBound()
Handle(ShapeFix_Edge) sfe = myFixWire->FixEdgeTool();
for (TopExp_Explorer Eed (myFace, TopAbs_EDGE); Eed.More(); Eed.Next()) {
TopoDS_Edge edg = TopoDS::Edge (Eed.Current());
sfe->FixVertexTolerance(edg);
sfe->FixVertexTolerance(edg, myFace);
}
// B.UpdateFace (myFace,myPrecision);

View File

@@ -257,11 +257,15 @@ Standard_Boolean ShapeFix_Shape::Perform(const Handle(Message_ProgressIndicator)
// for case when vertex belong to the different faces it is necessary to check vertices tolerances
//after all fixes.
//This fix it should be performed for example for case when cutting edge was performed.
Handle(ShapeFix_Edge) sfe = FixEdgeTool();
TopExp_Explorer anExpE (myResult, TopAbs_EDGE);
for ( ; anExpE.More(); anExpE.Next())
sfe->FixVertexTolerance( TopoDS::Edge (anExpE.Current()));
TopExp_Explorer anExpF (myResult, TopAbs_FACE);
for ( ; anExpF.More(); anExpF.Next())
{
TopoDS_Face aF = TopoDS::Face(anExpF.Current());
TopExp_Explorer anExpE (aF, TopAbs_EDGE);
for ( ; anExpE.More(); anExpE.Next())
sfe->FixVertexTolerance( TopoDS::Edge (anExpE.Current()), aF);
}
}
}
myResult = Context()->Apply(myResult);

View File

@@ -416,7 +416,7 @@ Standard_Boolean ShapeFix_Wire::Perform()
// TEMPORARILY without special mode !!!
Handle(ShapeExtend_WireData) sbwd = WireData();
for (Standard_Integer iedge = 1; iedge <= sbwd->NbEdges(); iedge++)
if ( myFixEdge->FixVertexTolerance (sbwd->Edge (iedge)) )
if ( myFixEdge->FixVertexTolerance (sbwd->Edge (iedge), Face()) )
{
Fixed = Standard_True;
}
@@ -800,7 +800,7 @@ Standard_Boolean ShapeFix_Wire::FixEdgeCurves()
}
}
}
myFixEdge->FixSameParameter ( sbwd->Edge(i) );
myFixEdge->FixSameParameter ( sbwd->Edge(i), Face());
if ( myFixEdge->Status ( ShapeExtend_DONE ) )
myStatusEdgeCurves |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE8 );
if ( myFixEdge->Status ( ShapeExtend_FAIL ) )
@@ -814,7 +814,7 @@ Standard_Boolean ShapeFix_Wire::FixEdgeCurves()
{
for ( i=1; i <= nb; i++)
{
myFixEdge->FixVertexTolerance (sbwd->Edge (i), face);
myFixEdge->FixVertexTolerance (sbwd->Edge (i), Face());
if ( myFixEdge->Status ( ShapeExtend_DONE ) )
myStatusEdgeCurves |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE8 );
if ( myFixEdge->Status ( ShapeExtend_FAIL ) )
@@ -1778,7 +1778,7 @@ static Standard_Boolean TryNewPCurve (const TopoDS_Edge &E, const TopoDS_Face &f
// no call to BRepLib: B.SameParameter ( edge, Standard_False );
Handle(ShapeFix_Edge) sfe = new ShapeFix_Edge;
sfe->FixSameParameter ( edge );
sfe->FixSameParameter ( edge, face );
c2d = BRep_Tool::CurveOnSurface ( edge, face, first, last );
tol = BRep_Tool::Tolerance ( edge );
return Standard_True;