1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

Algorithm of check, if wire is closed in 2D-space, was changed.

This commit is contained in:
nbv
2014-12-16 10:12:43 +03:00
parent 1621454f40
commit a8f7adb4d4

View File

@@ -382,12 +382,18 @@ Standard_Boolean IsDistanceIn3DTolerance (const gp_Pnt& thePnt_f,
#ifdef OCCT_DEBUG #ifdef OCCT_DEBUG
cout << endl; cout << endl;
cout << "--------Function IsDistanceIn3DTolerance(...)----------" << endl; cout << "--------Function IsDistanceIn3DTolerance(...)----------"
cout << "--- BRepCheck Wire: Closed3d -> Error" << endl; << endl;
cout << "--- Dist (" << Dist << ") > Tol3d (" << aTol3d << ")" << endl; cout << "--- BRepCheck Wire: Closed3d -> Error"
cout << "Pnt1(" << thePnt_f.X() << "; " << thePnt_f.Y() << "; " << thePnt_f.Z() << ")" << endl; << endl;
cout << "Pnt2(" << thePnt_l.X() << "; " << thePnt_l.Y() << "; " << thePnt_l.Z() << ")" << endl; cout << "--- Dist (" << Dist << ") > Tol3d (" << aTol3d << ")"
cout << "------------------------------------------------------" << endl; << endl;
cout << "Pnt1(" << thePnt_f.X() << "; " << thePnt_f.Y() << "; " << thePnt_f.Z() << ")"
<< endl;
cout << "Pnt2(" << thePnt_l.X() << "; " << thePnt_l.Y() << "; " << thePnt_l.Z() << ")"
<< endl;
cout << "------------------------------------------------------"
<< endl;
#endif #endif
return Standard_False; return Standard_False;
@@ -414,9 +420,6 @@ Standard_Boolean IsDistanceIn2DTolerance (const BRepAdaptor_Surface& aFaceSurfac
if((aDist2dU < (aFactor*aDeltaUPar)) && (aDist2dV < (aFactor*aDeltaVPar))) if((aDist2dU < (aFactor*aDeltaUPar)) && (aDist2dV < (aFactor*aDeltaVPar)))
return Standard_True; return Standard_True;
Standard_Real aUTol = aFaceSurface.UResolution(aTol3d);
Standard_Real aVTol = aFaceSurface.VResolution(aTol3d);
#ifdef OCCT_DEBUG #ifdef OCCT_DEBUG
cout << endl; cout << endl;
cout << "--------Function IsDistanceIn2DTolerance(...)----------" << endl; cout << "--------Function IsDistanceIn2DTolerance(...)----------" << endl;
@@ -432,10 +435,13 @@ Standard_Boolean IsDistanceIn2DTolerance (const BRepAdaptor_Surface& aFaceSurfac
cout << "VFirst = " << aFaceSurface.FirstVParameter(); cout << "VFirst = " << aFaceSurface.FirstVParameter();
cout << "; VLast = " << aFaceSurface.LastVParameter() << endl; cout << "; VLast = " << aFaceSurface.LastVParameter() << endl;
cout << "aTol3d = " << aTol3d <<"; URes = " << aUTol << "; VRes = " << aVTol << endl;
cout << "thePnt(" << thePnt.X() << "; " << thePnt.Y() << ")" << endl; cout << "thePnt(" << thePnt.X() << "; " << thePnt.Y() << ")" << endl;
cout << "thePntRef(" << thePntRef.X() << "; " << thePntRef.Y() << ")" << endl; cout << "thePntRef(" << thePntRef.X() << "; " << thePntRef.Y() << ")" << endl;
#else #endif
Standard_Real aUTol = aFaceSurface.UResolution(aTol3d);
Standard_Real aVTol = aFaceSurface.VResolution(aTol3d);
if(aUTol >= aDeltaUPar) if(aUTol >= aDeltaUPar)
{//Singular case {//Singular case
aUTol = 0.0; aUTol = 0.0;
@@ -445,39 +451,41 @@ Standard_Boolean IsDistanceIn2DTolerance (const BRepAdaptor_Surface& aFaceSurfac
{//Singular case {//Singular case
aVTol = 0.0; aVTol = 0.0;
} }
#endif
Standard_Real aTol2d = 2*Max(aUTol, aVTol);
#ifdef OCCT_DEBUG #ifdef OCCT_DEBUG
if(aTol2d <= 0.0) if(IsEqual(aUTol, 0.0) || IsEqual(aVTol, 0.0))
{ {
cout<<"BRepCheck_Wire : UResolution and VResolution = 0.0 (Face too small ?)"<<endl; cout << "BRepCheck_Wire: UResolution and VResolution = 0.0."
cout.flush(); " Is face too small?" << endl;
} }
#endif
//Standard_Real aDist = thePntRef.Distance(thePnt);
Standard_Real aDist = Max(aDist2dU, aDist2dV);
if (aDist < aTol2d)
return Standard_True;
#ifdef OCCT_DEBUG
cout << endl;
cout << "--------Function IsDistanceIn2DTolerance(...)----------" << endl;
cout << "--- BRepCheck Wire: Not closed in 2d" << endl;
cout << "*****************************************************" << endl;
cout << "* Dist = " << aDist << " > Tol2d = " << aTol2d << endl;
cout << "*****************************************************" << endl; cout << "*****************************************************" << endl;
cout << "aTol3d = " << aTol3d <<"; URes = " << aUTol << "; VRes = " << aVTol << endl; cout << "aTol3d = " << aTol3d <<"; URes = " << aUTol << "; VRes = " << aVTol << endl;
cout << "thePnt(" << thePnt.X() << "; " << thePnt.Y() << ")" << endl; cout << "*****************************************************" << endl;
cout << "thePntRef(" << thePntRef.X() << "; " << thePntRef.Y() << ")" << endl; #endif
if(aDist2dU > aUTol)
{
#ifdef OCCT_DEBUG
cout << "(aDist2dU > URes)" << endl;
#endif #endif
return Standard_False; return Standard_False;
} }
if(aDist2dV > aVTol)
{
#ifdef OCCT_DEBUG
cout << "(aDist2dV > VRes)" << endl;
#endif
return Standard_False;
}
return Standard_True;
}
//======================================================================= //=======================================================================
//function : Closed2d //function : Closed2d
//purpose : for periodic faces //purpose : for periodic faces
@@ -560,14 +568,18 @@ BRepCheck_Status BRepCheck_Wire::Closed2d(const TopoDS_Face& theFace,
BRep_Tool::Range(aFirstEdge, aF, aL); BRep_Tool::Range(aFirstEdge, aF, aL);
if ((anOri == TopAbs_FORWARD && Precision::IsNegativeInfinite( aF )) || if ((anOri == TopAbs_FORWARD && Precision::IsNegativeInfinite( aF )) ||
(anOri == TopAbs_REVERSED && Precision::IsPositiveInfinite( aL ))) (anOri == TopAbs_REVERSED && Precision::IsPositiveInfinite( aL )))
{
isFirstInfinite = Standard_True; isFirstInfinite = Standard_True;
}
anOri = aLastEdge.Orientation(); anOri = aLastEdge.Orientation();
BRep_Tool::Range(aLastEdge, aF, aL); BRep_Tool::Range(aLastEdge, aF, aL);
if ((anOri == TopAbs_FORWARD && Precision::IsPositiveInfinite( aL )) || if ((anOri == TopAbs_FORWARD && Precision::IsPositiveInfinite( aL )) ||
(anOri == TopAbs_REVERSED && Precision::IsNegativeInfinite( aF ))) (anOri == TopAbs_REVERSED && Precision::IsNegativeInfinite( aF )))
{
isLastInfinite = Standard_True; isLastInfinite = Standard_True;
}
if (isFirstInfinite && isLastInfinite) if (isFirstInfinite && isLastInfinite)
{ {
@@ -604,19 +616,6 @@ BRepCheck_Status BRepCheck_Wire::Closed2d(const TopoDS_Face& theFace,
Standard_Real aTol3d = Max(BRep_Tool::Tolerance(aFirstVertex),BRep_Tool::Tolerance(aWireExp.CurrentVertex())); Standard_Real aTol3d = Max(BRep_Tool::Tolerance(aFirstVertex),BRep_Tool::Tolerance(aWireExp.CurrentVertex()));
// get first point // get first point
if(aNbFoundEdges == 1)
{
BRep_Tool::UVPoints(aFirstEdge, theFace, aP_first, aP_last);
if(!IsDistanceIn2DTolerance(aFaceSurface, aP_first, aP_last, aTol3d))
{
aClosedStat = BRepCheck_NotClosed;
if (Update)
BRepCheck::Add(myMap(myShape),aClosedStat);
return aClosedStat;
}
}
if (aFirstEdge.Orientation() == TopAbs_REVERSED) if (aFirstEdge.Orientation() == TopAbs_REVERSED)
BRep_Tool::UVPoints(aFirstEdge, theFace, aP_temp, aP_first); BRep_Tool::UVPoints(aFirstEdge, theFace, aP_temp, aP_first);
else else
@@ -654,6 +653,7 @@ BRepCheck_Status BRepCheck_Wire::Closed2d(const TopoDS_Face& theFace,
return aClosedStat; return aClosedStat;
} }
//======================================================================= //=======================================================================
//function : Orientation //function : Orientation
//purpose : //purpose :