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

0025410: Tool for extended check of validity of the curve on the surface

Modifications:
1. class BOPTools_AlgoTools
1.1. method
 Standard_Boolean BOPTools_AlgoTools::ComputeTolerance
  (const Handle(Geom_Curve)& theCurve3D,
   const Handle(Geom2d_Curve)& theCurve2D,
   const Handle(Geom_Surface)& theSurf,
   const Standard_Real theFirst,
   const Standard_Real theLast,
   Standard_Real& theMaxDist,
   Standard_Real& theMaxPar)
  It computes the max distance between points taken from 3D and 2D curves by the same parameter

1.2. method
 Standard_Boolean BOPTools_AlgoTools::ComputeTolerance
  (const TopoDS_Face& theFace,
   const TopoDS_Edge& theEdge,
   Standard_Real& theMaxDist,
   Standard_Real& theParameter)
  Computes the valid value of the tolerance for the edge using the function above.

2.  Added possibility to check shape on the validity of the curves on the surfaces.
2.1. New status BOPAlgo_InvalidCurveOnSurface has been added to the enumeration BOPAlgo_CheckStatus
2.2. class BOPAlgo_ArgumentAnalyzer
 method
   void BOPAlgo_ArgumentAnalyzer::TestCurveOnSurface()
 It checks each edge/face pair in the shape using the method ComputeTolerance from BOPTools_AlgoTools and stores invalid pairs to myResults.
 Invalid pairs are those which contain the edge with tolerance value less then the value computed by the ComputeTolerance method.

2.3. class BOPAlgo_CheckResult
 Added new fields:
    myMaxDist1 : Real from Standard;
    myMaxDist2 : Real from Standard;
    myMaxPar1  : Real from Standard;
    myMaxPar2  : Real from Standard;
 and corresponding setters and getters.
 These fields are used to store the results of the TestCurveOnSurface() check.

3. Added new option to the bopargcheck command and two new commands.
class BOPTest_CheckCommands
3.1. command bopargcheck
 As it is using the BOPAlgo_ArgumentAnalyzer class to check the shapes
 it checks also the validity of the curves on the surfaces.
 The output for the invalid shapes is following:

Draw[]> bopargcheck b2 /ic #f
Made faulty shape: s1COnS_1 (MaxDist = 0.0013334343378738308, MaxPar = 0.02884285498274167)
Made faulty shape: s1COnS_2 (MaxDist = 0.0013334340648766174, MaxPar = 0.02884285497934707)
Made faulty shape: s1COnS_3 (MaxDist = 0.0013335086668628978, MaxPar = 1.4133051942712607)
Made faulty shape: s1COnS_4 (MaxDist = 0.0013335086525838983, MaxPar = 1.4133051942713901)
Faulties for FIRST  shape found : 4
---------------------------------
Shapes are not suppotrted by BOP: NO
Self-Intersections              : NO
Check for SI has been aborted   : NO
Too small edges                 : NO
Bad faces                       : NO
Too close vertices              : NO
Too close edges                 : NO
Shapes with Continuity C0       : NO
Invalid Curve on Surface        : YES  Cases(4)  Total shapes(8)

Faulties for SECOND  shape found : 0

 The compounds s1COnS_* contain pair of edge and face.
 MaxDist is maximal distance between points taken from 3D curve of the edge and 2D curve of that edge on the face.
 MaxPar is a parameter in which the MaxDist is reached.

 To disable this check it is necessary to use option /S (bopargcheck shape /S).

3.2. command xdistef
 Usage of the command:
   xdistef edge face
 It computes distance between points taken from 3D curve of the edge and 2D curve of that edge on the face.
 Example:
Draw[]> explode s1COnS_1
s1COnS_1_1 s1COnS_1_2
Draw[]> whatis s1COnS_1_1
s1COnS_1_1 is a shape EDGE FORWARD Modified Orientable
Draw[]> whatis s1COnS_1_2
s1COnS_1_2 is a shape FACE FORWARD Modified Orientable
Draw[]> xdistef s1COnS_1_1 s1COnS_1_2
Max Distance = 0.0013334343378738308; Parameter on curve = 0.02884285498274167

3.3. command checkcurveonsurf
 Usage of the command:
  checkcurveonsurf shape.
 It checks each edge/face pair in the shape using the method ComputeTolerance from BOPTools_AlgoTools.
Example:
Draw[]> checkcurveonsurf b2
Invalid curves on surface:
edge e_0 on face f_0 (max dist: 0.0013334343378738, parameter on curve: 0.0288428549827417)
edge e_1 on face f_0 (max dist: 0.0013334340648766, parameter on curve: 0.0288428549793471)
edge e_2 on face f_1 (max dist: 0.0013335086668629, parameter on curve: 1.4133051942712607)
edge e_3 on face f_1 (max dist: 0.0013335086525839, parameter on curve: 1.4133051942713901)

Sugestions to fix the shape:
explode b2 e;
settolerance b2_6 0.0013335086668629;
settolerance b2_7 0.0013334343378738;
settolerance b2_8 0.0013334340648766;
settolerance b2_10 0.0013335086525839;

The command gives suggestions to fix the shape by increasing tolerance values of the invalid edges.
In some cases the tolerance values suggested by the tool can be very large.
Such values should be used very carefully, because setting large tolerance values to the sub-shapes
of the shape can make it non valid (self-interfered) or lead to unexpected result when using
such shapes in some operations (boolean for example).

Test case for issue CR25410
This commit is contained in:
nbv
2014-10-30 14:26:16 +03:00
committed by bugmaster
parent 05e2200bbf
commit e98e39903b
10 changed files with 877 additions and 92 deletions

View File

@@ -52,6 +52,7 @@ is
IncompatibilityOfFace,
OperationAborted,
GeomAbs_C0,
InvalidCurveOnSurface,
NotValid
end CheckStatus;

View File

@@ -115,6 +115,13 @@ is
---Purpose: Returns (modifiable) mode that means
-- checking of problem of continuity of the shape.
CurveOnSurfaceMode(me: in out)
returns Boolean from Standard;
---C++: return &
---C++: inline
---Purpose: Returns (modifiable) mode that means
-- checking of problem of invalid curve on surface.
---
Perform(me: out);
---Purpose: performs analysis
@@ -154,6 +161,9 @@ is
is protected;
TestContinuity(me: out)
is protected;
TestCurveOnSurface(me: out)
is protected;
-- TestMergeFace(me: out)
@@ -162,20 +172,20 @@ is
fields
myShape1 : Shape from TopoDS;
myShape2 : Shape from TopoDS;
myStopOnFirst : Boolean from Standard;
myOperation : Operation from BOPAlgo;
myArgumentTypeMode : Boolean from Standard;
mySelfInterMode : Boolean from Standard;
mySmallEdgeMode : Boolean from Standard;
myRebuildFaceMode : Boolean from Standard;
myTangentMode : Boolean from Standard;
myMergeVertexMode : Boolean from Standard;
myMergeEdgeMode : Boolean from Standard;
myContinuityMode : Boolean from Standard;
myEmpty1,myEmpty2 : Boolean from Standard;
myResult : ListOfCheckResult from BOPAlgo;
myShape1 : Shape from TopoDS;
myShape2 : Shape from TopoDS;
myStopOnFirst : Boolean from Standard;
myOperation : Operation from BOPAlgo;
myArgumentTypeMode : Boolean from Standard;
mySelfInterMode : Boolean from Standard;
mySmallEdgeMode : Boolean from Standard;
myRebuildFaceMode : Boolean from Standard;
myTangentMode : Boolean from Standard;
myMergeVertexMode : Boolean from Standard;
myMergeEdgeMode : Boolean from Standard;
myContinuityMode : Boolean from Standard;
myCurveOnSurfaceMode : Boolean from Standard;
myEmpty1, myEmpty2 : Boolean from Standard;
myResult : ListOfCheckResult from BOPAlgo;
end ArgumentAnalyzer;

View File

@@ -74,6 +74,7 @@ myTangentMode(Standard_False),
myMergeVertexMode(Standard_False),
myMergeEdgeMode(Standard_False),
myContinuityMode(Standard_False),
myCurveOnSurfaceMode(Standard_False),
myEmpty1(Standard_False),
myEmpty2(Standard_False)
{
@@ -196,6 +197,11 @@ void BOPAlgo_ArgumentAnalyzer::Perform()
if(!(!myResult.IsEmpty() && myStopOnFirst))
TestContinuity();
}
if(myCurveOnSurfaceMode) {
if(!(!myResult.IsEmpty() && myStopOnFirst))
TestCurveOnSurface();
}
}
catch(Standard_Failure) {
BOPAlgo_CheckResult aResult;
@@ -816,3 +822,55 @@ void BOPAlgo_ArgumentAnalyzer::TestContinuity()
}
}
}
// ================================================================================
// function: TestCurveOnSurface
// purpose:
// ================================================================================
void BOPAlgo_ArgumentAnalyzer::TestCurveOnSurface()
{
Standard_Integer i;
Standard_Real aT, aD, aTolE;
TopExp_Explorer aExpF, aExpE;
//
for(i = 0; i < 2; i++) {
const TopoDS_Shape& aS = (i == 0) ? myShape1 : myShape2;
if(aS.IsNull()) {
continue;
}
//
aExpF.Init(aS, TopAbs_FACE);
for (; aExpF.More(); aExpF.Next()) {
const TopoDS_Face& aF = *(TopoDS_Face*)&aExpF.Current();
//
aExpE.Init(aF, TopAbs_EDGE);
for (; aExpE.More(); aExpE.Next()) {
const TopoDS_Edge& aE = *(TopoDS_Edge*)&aExpE.Current();
//
if (BOPTools_AlgoTools::ComputeTolerance(aF, aE, aD, aT)) {
aTolE = BRep_Tool::Tolerance(aE);
if (aD > aTolE) {
BOPAlgo_CheckResult aResult;
aResult.SetCheckStatus(BOPAlgo_InvalidCurveOnSurface);
if(i == 0) {
aResult.SetShape1(myShape1);
aResult.AddFaultyShape1(aE);
aResult.AddFaultyShape1(aF);
aResult.SetMaxDistance1(aD);
aResult.SetMaxParameter1(aT);
}
else {
aResult.SetShape2(myShape2);
aResult.AddFaultyShape2(aE);
aResult.AddFaultyShape2(aF);
aResult.SetMaxDistance2(aD);
aResult.SetMaxParameter2(aT);
}
myResult.Append(aResult);
}
}
}
}
}
}

View File

@@ -57,6 +57,10 @@ inline Standard_Boolean& BOPAlgo_ArgumentAnalyzer::ContinuityMode()
return myContinuityMode;
}
inline Standard_Boolean& BOPAlgo_ArgumentAnalyzer::CurveOnSurfaceMode()
{
return myCurveOnSurfaceMode;
}
// inline Standard_Boolean& BOPAlgo_ArgumentAnalyzer::MergeFaceMode()
// {
// return myMergeFaceMode;

View File

@@ -39,7 +39,7 @@ is
---Purpose: sets ancestor shape (tool) for faulty sub-shapes
AddFaultyShape2(me: in out; TheShape: Shape from TopoDS);
---Purpose: adds faulty sub-shapes from tool to a list
---Purpose: adds faulty sub-shapes from tool to a list
GetShape1(me)
returns Shape from TopoDS;
@@ -66,7 +66,39 @@ is
GetCheckStatus(me)
returns CheckStatus from BOPAlgo;
---Purpose: gets status of faulty
---Purpose: gets status of faulty
SetMaxDistance1(me:out;
theDist : Real from Standard);
---Purpose: Sets max distance for the first shape
SetMaxDistance2(me:out;
theDist : Real from Standard);
---Purpose: Sets max distance for the second shape
SetMaxParameter1(me:out;
thePar : Real from Standard);
---Purpose: Sets the parameter for the first shape
SetMaxParameter2(me:out;
thePar : Real from Standard);
---Purpose: Sets the parameter for the second shape
GetMaxDistance1(me)
returns Real from Standard;
---Purpose: Returns the distance for the first shape
GetMaxDistance2(me)
returns Real from Standard;
---Purpose: Returns the distance for the second shape
GetMaxParameter1(me)
returns Real from Standard;
---Purpose: Returns the parameter for the fircst shape
GetMaxParameter2(me)
returns Real from Standard;
---Purpose: Returns the parameter for the second shape
fields
@@ -74,6 +106,10 @@ fields
myShape2 : Shape from TopoDS;
myStatus : CheckStatus from BOPAlgo;
myFaulty1 : ListOfShape from BOPCol;
myFaulty2 : ListOfShape from BOPCol;
myFaulty2 : ListOfShape from BOPCol;
myMaxDist1 : Real from Standard;
myMaxDist2 : Real from Standard;
myMaxPar1 : Real from Standard;
myMaxPar2 : Real from Standard;
end CheckResult;

View File

@@ -19,7 +19,13 @@
// function: BOPAlgo_CheckResult()
// purpose:
//=======================================================================
BOPAlgo_CheckResult::BOPAlgo_CheckResult() : myStatus(BOPAlgo_CheckUnknown)
BOPAlgo_CheckResult::BOPAlgo_CheckResult()
:
myStatus(BOPAlgo_CheckUnknown),
myMaxDist1(0.),
myMaxDist2(0.),
myMaxPar1(0.),
myMaxPar2(0.)
{
}
@@ -72,3 +78,43 @@ BOPAlgo_CheckStatus BOPAlgo_CheckResult::GetCheckStatus() const
{
return myStatus;
}
void BOPAlgo_CheckResult::SetMaxDistance1(const Standard_Real theDist)
{
myMaxDist1 = theDist;
}
void BOPAlgo_CheckResult::SetMaxDistance2(const Standard_Real theDist)
{
myMaxDist2 = theDist;
}
void BOPAlgo_CheckResult::SetMaxParameter1(const Standard_Real thePar)
{
myMaxPar1 = thePar;
}
void BOPAlgo_CheckResult::SetMaxParameter2(const Standard_Real thePar)
{
myMaxPar2 = thePar;
}
Standard_Real BOPAlgo_CheckResult::GetMaxDistance1() const
{
return myMaxDist1;
}
Standard_Real BOPAlgo_CheckResult::GetMaxDistance2() const
{
return myMaxDist2;
}
Standard_Real BOPAlgo_CheckResult::GetMaxParameter1() const
{
return myMaxPar1;
}
Standard_Real BOPAlgo_CheckResult::GetMaxParameter2() const
{
return myMaxPar2;
}