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

Compare commits

...

4 Commits

Author SHA1 Message Date
nbv
e07a610c22 Resolution computing as the length of isoline segment 2015-01-16 10:50:45 +03:00
nbv
a8f7adb4d4 Algorithm of check, if wire is closed in 2D-space, was changed. 2014-12-29 12:42:19 +03:00
nbv
1621454f40 Variables names were changed according to their meaning. 2014-12-29 12:42:18 +03:00
nbv
1dc7891a20 0025583: Wrong solid is considered as valid by checkshape
Limitation tolerance value for checking if wire is closed in 2D-space of its face.

Some test cases were updated according to their new behavior.
2014-12-29 12:42:17 +03:00
3 changed files with 178 additions and 106 deletions

View File

@@ -76,6 +76,8 @@
#include <TopTools_IndexedMapOfOrientedShape.hxx>
#include <ElCLib.hxx>
#include <GCPnts_AbscissaPoint.hxx>
static void Propagate(const TopTools_IndexedDataMapOfShapeListOfShape&,
const TopoDS_Shape&, // edge
@@ -374,114 +376,177 @@ BRepCheck_Status BRepCheck_Wire::Closed(const Standard_Boolean Update)
Standard_Boolean IsDistanceIn3DTolerance (const gp_Pnt& thePnt_f,
const gp_Pnt& thePnt_l,
const Standard_Real aTol3d)
{
Standard_Real Dist = thePnt_f.Distance(thePnt_l);
{
Standard_Real Dist = thePnt_f.Distance(thePnt_l);
if (Dist < aTol3d)
return Standard_True;
#ifdef OCCT_DEBUG
cout << endl;
cout << "--------Function IsDistanceIn3DTolerance(...)----------" << endl;
cout << "--- BRepCheck Wire: Closed3d -> Error" << endl;
cout << "--- Dist (" << Dist << ") > Tol3d (" << aTol3d << ")" << 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;
cout << "--------Function IsDistanceIn3DTolerance(...)----------"
<< endl;
cout << "--- BRepCheck Wire: Closed3d -> Error"
<< endl;
cout << "--- Dist (" << Dist << ") > Tol3d (" << aTol3d << ")"
<< 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
return Standard_False;
}
}
//=======================================================================
//function : IsDistanceIn3DTolerance
//function : IsDistanceIn2DTolerance
//purpose :
//=======================================================================
static
Standard_Boolean IsDistanceIn2DTolerance (const BRepAdaptor_Surface& aFaceSurface,
const gp_Pnt2d& thePnt,
const gp_Pnt2d& thePntRef,
const Standard_Real aTol3d,
#ifdef OCCT_DEBUG
const Standard_Boolean PrintWarnings = Standard_True)
#else
const Standard_Boolean = Standard_True)
#endif
const Standard_Real aTol3d)
{
Standard_Real dumax = 0.01 * (aFaceSurface.LastUParameter() - aFaceSurface.FirstUParameter());
Standard_Real dvmax = 0.01 * (aFaceSurface.LastVParameter() - aFaceSurface.FirstVParameter());
Standard_Real dumin = Abs(thePnt.X() - thePntRef.X());
Standard_Real dvmin = Abs(thePnt.Y() - thePntRef.Y());
const Standard_Real aLengthTol = Precision::Confusion();
const Standard_Real aFactor = 0.01;
const Standard_Real aDeltaUPar = (aFaceSurface.LastUParameter() -
aFaceSurface.FirstUParameter());
const Standard_Real aDeltaVPar = (aFaceSurface.LastVParameter() -
aFaceSurface.FirstVParameter());
const Standard_Real aDist2dU = Abs(thePnt.X() - thePntRef.X());
const Standard_Real aDist2dV = Abs(thePnt.Y() - thePntRef.Y());
if((dumin < dumax) && (dvmin < dvmax))
if((aDist2dU < (aFactor*aDeltaUPar)) && (aDist2dV < (aFactor*aDeltaVPar)))
return Standard_True;
#ifdef OCCT_DEBUG
if(PrintWarnings)
{
cout << endl;
cout << "--------Function IsDistanceIn2DTolerance(...)----------" << endl;
cout << "--- BRepCheck Wire: Not closed in 2D" << endl;
cout << "*****************************************************" << endl;
cout << "*dumin = " << dumin << "; dumax = " << dumax << endl;
cout << "* dvmin = " << dvmin << "; dvmax = " << dvmax << endl;
cout << "* (dumin > dumax) or (dvmin > dvmax)." << endl;
cout << "*****************************************************" << endl;
cout << endl;
cout << "UFirst = " << aFaceSurface.FirstUParameter();
cout << "; ULast = " << aFaceSurface.LastUParameter() << endl;
cout << "VFirst = " << aFaceSurface.FirstVParameter();
cout << "; VLast = " << aFaceSurface.LastVParameter() << endl;
}
cout << endl;
cout << "--------Function IsDistanceIn2DTolerance(...)----------" << endl;
cout << "--- BRepCheck Wire: Not closed in 2D" << endl;
cout << "*****************************************************" << endl;
cout << "* aDist2dU = " << aDist2dU << "; aDeltaUPar = " << aFactor*aDeltaUPar<< endl;
cout << "* aDist2dV = " << aDist2dV << "; aDeltaVPar = " << aFactor*aDeltaVPar<< endl;
cout << "* (aDist2dU > aDeltaUPar) or (aDist2dV > aDeltaVPar)." << endl;
cout << "*****************************************************" << endl;
cout << endl;
cout << "UFirst = " << aFaceSurface.FirstUParameter();
cout << "; ULast = " << aFaceSurface.LastUParameter() << endl;
cout << "VFirst = " << aFaceSurface.FirstVParameter();
cout << "; VLast = " << aFaceSurface.LastVParameter() << endl;
dumax = aFaceSurface.UResolution(aTol3d);
dvmax = aFaceSurface.VResolution(aTol3d);
if(PrintWarnings)
{
cout << "aTol3d = " << aTol3d <<"; URes = " << dumax << "; VRes = " << dvmax << endl;
cout << "thePnt(" << thePnt.X() << "; " << thePnt.Y() << ")" << endl;
cout << "thePntRef(" << thePntRef.X() << "; " << thePntRef.Y() << ")" << endl;
}
#else
dumax = aFaceSurface.UResolution(aTol3d);
dvmax = aFaceSurface.VResolution(aTol3d);
cout << "thePnt(" << thePnt.X() << "; " << thePnt.Y() << ")" << endl;
cout << "thePntRef(" << thePntRef.X() << "; " << thePntRef.Y() << ")" << endl;
#endif
Standard_Real aTol2d = 2*Max( dumax, dvmax);
const Standard_Real aU0 = thePntRef.X(), aV0 = thePntRef.Y();
Adaptor3d_Curve* aCu = new GeomAdaptor_Curve(aFaceSurface.Surface().Surface()->UIso(aU0));
Adaptor3d_Curve* aCv = new GeomAdaptor_Curve(aFaceSurface.Surface().Surface()->VIso(aV0));
#ifdef OCCT_DEBUG
if((aTol2d <= 0.0) && (PrintWarnings))
//For line and circle the resolution is independent of the point on curve
const Standard_Boolean isUAnalitic = ((aCu->GetType() == GeomAbs_Line) ||
(aCu->GetType() == GeomAbs_Circle));
const Standard_Boolean isVAnalitic = ((aCv->GetType() == GeomAbs_Line) ||
(aCv->GetType() == GeomAbs_Circle));
Standard_Real aUTol = 0.0;
Standard_Real aVTol = 0.0;
if(!isUAnalitic)
{
Standard_Real aLR = aTol3d;
if(2.0*aU0 > (aFaceSurface.LastUParameter() +
aFaceSurface.FirstUParameter()))
{
cout<<"BRepCheck_Wire : UResolution and VResolution = 0.0 (Face too small ?)"<<endl;
cout.flush();
aLR = -aLR;
}
#endif
//Standard_Real Dist = thePntRef.Distance(thePnt);
Standard_Real Dist = Max(dumin, dvmin);
if (Dist < aTol2d)
return Standard_True;
#ifdef OCCT_DEBUG
if(PrintWarnings)
GCPnts_AbscissaPoint aGAu(aLengthTol, *aCu, aLR, aU0);
if(aGAu.IsDone())
{
cout << endl;
cout << "--------Function IsDistanceIn2DTolerance(...)----------" << endl;
cout << "--- BRepCheck Wire: Not closed in 2d" << endl;
cout << "*****************************************************" << endl;
cout << "* Dist = " << Dist << " > Tol2d = " << aTol2d << endl;
cout << "*****************************************************" << endl;
cout << "aTol3d = " << aTol3d <<"; URes = " << dumax << "; VRes = " << dvmax << endl;
cout << "thePnt(" << thePnt.X() << "; " << thePnt.Y() << ")" << endl;
cout << "thePntRef(" << thePntRef.X() << "; " << thePntRef.Y() << ")" << endl;
aUTol = Abs(aGAu.Parameter() - aU0);
}
else
{
aUTol = aFaceSurface.UResolution(aTol3d);
}
#endif
return Standard_False;
}
else
{
aUTol = aFaceSurface.UResolution(aTol3d);
}
if(!isVAnalitic)
{
Standard_Real aLR = aTol3d;
if(2.0*aV0 > (aFaceSurface.LastVParameter() +
aFaceSurface.FirstVParameter()))
{
aLR = -aLR;
}
GCPnts_AbscissaPoint aGAv(aLengthTol, *aCv, aLR, aV0);
if(aGAv.IsDone())
{
aVTol = Abs(aGAv.Parameter() - aV0);
}
else
{
aVTol = aFaceSurface.VResolution(aTol3d);
}
}
else
{
aVTol = aFaceSurface.VResolution(aTol3d);
}
if(aUTol - aDeltaUPar >= aLengthTol)
{//Singular case
aUTol = 0.0;
}
if(aVTol - aDeltaVPar >= aLengthTol)
{//Singular case
aVTol = 0.0;
}
#ifdef OCCT_DEBUG
if(IsEqual(aUTol, 0.0) || IsEqual(aVTol, 0.0))
{
cout << "BRepCheck_Wire: UResolution and VResolution = 0.0."
" Is face too small?" << endl;
}
cout << "*****************************************************" << endl;
cout << "aTol3d = " << aTol3d <<"; URes = " << aUTol << "; VRes = " << aVTol << endl;
cout << "*****************************************************" << endl;
#endif
if(aDist2dU > aUTol)
{
#ifdef OCCT_DEBUG
cout << "(aDist2dU > URes)" << endl;
#endif
return Standard_False;
}
if(aDist2dV > aVTol)
{
#ifdef OCCT_DEBUG
cout << "(aDist2dV > VRes)" << endl;
#endif
return Standard_False;
}
return Standard_True;
}
//=======================================================================
//function : Closed2d
@@ -489,16 +554,16 @@ Standard_Boolean IsDistanceIn2DTolerance (const BRepAdaptor_Surface& aFaceSurfac
//=======================================================================
BRepCheck_Status BRepCheck_Wire::Closed2d(const TopoDS_Face& theFace,
const Standard_Boolean Update)
{
{
// 3d closure checked too
BRepCheck_Status aClosedStat = Closed();
if (aClosedStat != BRepCheck_NoError)
{
{
if (Update)
BRepCheck::Add(myMap(myShape),aClosedStat);
return aClosedStat;
}
}
// 20/03/02 akm vvv : (OCC234) Hence this method will be used to check
// both periodic and non-periodic faces
@@ -516,18 +581,18 @@ BRepCheck_Status BRepCheck_Wire::Closed2d(const TopoDS_Face& theFace,
Standard_Integer aNbOrirntedEdges = 0;
TopExp_Explorer anEdgeExp(myShape,TopAbs_EDGE);
for (;anEdgeExp.More(); anEdgeExp.Next())
{
{
if (IsOriented(anEdgeExp.Current()))
aNbOrirntedEdges++;
}
}
if (aNbOrirntedEdges==0)
{
{
if (Update)
BRepCheck::Add(myMap(myShape),aClosedStat);
return aClosedStat;
}
}
// all those edges must form a closed 2d contour and be found by WireExplorer
@@ -538,19 +603,19 @@ BRepCheck_Status BRepCheck_Wire::Closed2d(const TopoDS_Face& theFace,
TopoDS_Edge aLastEdge;
for (;aWireExp.More(); aWireExp.Next())
{
{
aNbFoundEdges++;
aLastEdge = aWireExp.Current();
}
}
if (aNbFoundEdges != aNbOrirntedEdges)
{
{
aClosedStat = BRepCheck_NotClosed;
if (Update)
BRepCheck::Add(myMap(myShape),aClosedStat);
return aClosedStat;
}
}
// Check distance between 2d ends of first and last edges
// Modified by Sergey KHROMOV - Mon May 13 12:42:10 2002 Begin
@@ -564,32 +629,36 @@ BRepCheck_Status BRepCheck_Wire::Closed2d(const TopoDS_Face& theFace,
anOri = aFirstEdge.Orientation();
BRep_Tool::Range(aFirstEdge, aF, aL);
if ((anOri == TopAbs_FORWARD && Precision::IsNegativeInfinite( aF )) ||
(anOri == TopAbs_REVERSED && Precision::IsPositiveInfinite( aL )))
(anOri == TopAbs_REVERSED && Precision::IsPositiveInfinite( aL )))
{
isFirstInfinite = Standard_True;
}
anOri = aLastEdge.Orientation();
BRep_Tool::Range(aLastEdge, aF, aL);
if ((anOri == TopAbs_FORWARD && Precision::IsPositiveInfinite( aL )) ||
(anOri == TopAbs_REVERSED && Precision::IsNegativeInfinite( aF )))
(anOri == TopAbs_REVERSED && Precision::IsNegativeInfinite( aF )))
{
isLastInfinite = Standard_True;
}
if (isFirstInfinite && isLastInfinite)
{
{
if (Update)
BRepCheck::Add(myMap(myShape),aClosedStat);
return aClosedStat;
}
}
else if (aFirstVertex.IsNull())
{
{
aClosedStat = BRepCheck_NotClosed;
if (Update)
BRepCheck::Add(myMap(myShape),aClosedStat);
return aClosedStat;
}
}
// Modified by Sergey KHROMOV - Mon May 13 12:42:10 2002 End
gp_Pnt2d aP_first, aP_last, aP_temp; // ends of prev edge, next edge, bidon
@@ -606,6 +675,8 @@ BRepCheck_Status BRepCheck_Wire::Closed2d(const TopoDS_Face& theFace,
// aUResol = 2*aFaceSurface.UResolution(aTol);
// aVResol = 2*aFaceSurface.VResolution(aTol);
Standard_Real aTol3d = Max(BRep_Tool::Tolerance(aFirstVertex),BRep_Tool::Tolerance(aWireExp.CurrentVertex()));
// get first point
if (aFirstEdge.Orientation() == TopAbs_REVERSED)
BRep_Tool::UVPoints(aFirstEdge, theFace, aP_temp, aP_first);
@@ -615,13 +686,13 @@ BRepCheck_Status BRepCheck_Wire::Closed2d(const TopoDS_Face& theFace,
// Modified by Sergey KHROMOV - Thu Jun 20 10:55:42 2002 OCC325 Begin
// Check 2d distance for periodic faces with seam edge
if (!IsClosed2dForPeriodicFace(theFace, aP_first, aP_last, aFirstVertex))
{
{
aClosedStat = BRepCheck_NotClosed;
if (Update)
BRepCheck::Add(myMap(myShape),aClosedStat);
return aClosedStat;
}
}
// Modified by Sergey KHROMOV - Thu Jun 20 10:58:05 2002 End
// check distance
@@ -630,8 +701,6 @@ BRepCheck_Status BRepCheck_Wire::Closed2d(const TopoDS_Face& theFace,
// if (dfUDist > aUResol || dfVDist > aVResol)
// {
Standard_Real aTol3d = Max(BRep_Tool::Tolerance(aFirstVertex),BRep_Tool::Tolerance(aWireExp.CurrentVertex()));
gp_Pnt aPntRef = BRep_Tool::Pnt(aFirstVertex);
gp_Pnt aPnt = BRep_Tool::Pnt(aWireExp.CurrentVertex());
@@ -645,7 +714,8 @@ BRepCheck_Status BRepCheck_Wire::Closed2d(const TopoDS_Face& theFace,
BRepCheck::Add(myMap(myShape),aClosedStat);
return aClosedStat;
}
}
//=======================================================================
//function : Orientation
//purpose :
@@ -1653,7 +1723,7 @@ void ChoixUV(const TopoDS_Vertex& theVertex,
aParam =(aVOrientation != anE.Orientation()) ? aFirstParam : aLastParam;
aPnt = C2d->Value(aParam);
if(!IsDistanceIn2DTolerance(aFaceSurface, aPnt, aPntRef, aTol3d, Standard_False))
if(!IsDistanceIn2DTolerance(aFaceSurface, aPnt, aPntRef, aTol3d))
continue;
CurveDirForParameter(C2d, aParam, aPnt, aDer);

View File

@@ -1,5 +1,7 @@
# !!!! This file is generated automatically, do not edit manually! See end script
puts "TODO CR23096 ALL: STATSHAPE : Faulty"
puts "TODO CR12345 ALL: CHECKSHAPE : Faulty"
set LinuxDiff 2
set LinuxFaulties {STATSHAPE}
@@ -8,7 +10,7 @@ set filename bm1_pe_t4.stp
set ref_data {
DATA : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 )
TPSTAT : Faulties = 0 ( 2 ) Warnings = 19 ( 27 ) Summary = 19 ( 29 )
CHECKSHAPE : Wires = 2 ( 3 ) Faces = 2 ( 3 ) Shells = 0 ( 0 ) Solids = 0 ( 0 )
CHECKSHAPE : Wires = 4 ( 3 ) Faces = 4 ( 3 ) Shells = 0 ( 0 ) Solids = 0 ( 0 )
NBSHAPES : Solid = 0 ( 0 ) Shell = 13 ( 12 ) Face = 16 ( 15 ) Summary = 154 ( 151 )
STATSHAPE : Solid = 0 ( 0 ) Shell = 13 ( 12 ) Face = 16 ( 15 ) FreeWire = 0 ( 0 ) FreeEdge = 0 ( 0 ) SharedEdge = 59 ( 60 )
TOLERANCE : MaxTol = 1562.051497 ( 1562.051497 ) AvgTol = 192.5735494 ( 206.7634854 )

View File

@@ -4,7 +4,7 @@ set filename bm1_pe_fuel.stp
set ref_data {
DATA : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 )
TPSTAT : Faulties = 0 ( 0 ) Warnings = 8 ( 8 ) Summary = 8 ( 8 )
CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 )
CHECKSHAPE : Wires = 4 ( 4 ) Faces = 4 ( 4 ) Shells = 0 ( 0 ) Solids = 0 ( 0 )
NBSHAPES : Solid = 0 ( 0 ) Shell = 6 ( 6 ) Face = 10 ( 10 ) Summary = 89 ( 89 )
STATSHAPE : Solid = 0 ( 0 ) Shell = 6 ( 6 ) Face = 10 ( 10 ) FreeWire = 0 ( 0 ) FreeEdge = 0 ( 0 ) SharedEdge = 34 ( 34 )
TOLERANCE : MaxTol = 112.7632273 ( 112.7632273 ) AvgTol = 20.07582429 ( 20.07582429 )