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

0026619: Tolerances of operands are modified using bop

0026796: The result of General Fuse operation is self-intersecting shape

The fix forces creation of new sub-shapes (vertex, edge) when the tolerance of some sub-shape of an argument is to be increased.

This new behavior is turned off by default. It can be turned on using two ways:
1) Setting 'locking' flag of the arguments.
2) Calling the method SetNonDestructive(Standard_True) of the API classes.

Various bug fixes in the algorithm:
- Compute correct tolerance values for intersections of type Line/Line, Line/Plane, Plane/Plane.
- In case of Line/Plane intersection check if line's vertices lie on the plane.
- Do not allow decreasing of the tolerance value of the Line/Line intersection vertex.
- In IntTools_EdgeEdge, call the method FindParameters with proper 3D tolerance of the curve.
- Force making copy of a degenerated edge if its vertex is touched but no 2D intersection with other curves is found.
- Remove pave blocks both ends of which became referring to the same vertex after vertices substitution.
- Avoid exception in IntTools_Context::IsVertexOnLine if Extrema is not done.
- Reduce tolerance of vertex/edge using actual distances to interfered shapes if it was increased due to line/line, line/plane, or plane/plane small intersection angle.
- Update tolerance of edges to reach all representations in a common block.
- In V-E intersections, check if a vertex hits beyond shrunk range, in such case create V-V interference.
- Do not put a section edge to the result if it becomes to be a micro edge after updating its vertex.
- Correctly make vertices same-domain during the work of MakeBlocks.
- Decrease shrunk range at least on a Precision::Confusion() in addition to vertex tolerance.
- Add Confusion to bounding boxes of new shapes in DS
- Add tolerance Precision::Confusion() to compare distances of touching cases to fix regressions.

TODO marks have been removed from (or modified in) the following test cases (Improvements):
boolean bsection M3 N2 R2
boolean gdml_private B6 C2 C6 G7 I6 F6 J1 J4 M7 N1 N8 N9 O3 O4 O6 O8 O9 P1 P2 P5 Q1 Q3 Q5 S9 T2 U4 U5 U9 ZB5 ZB6 ZC1 ZC5 ZD3 ZD6 ZD7 ZH2 ZH5 ZI2 ZI5 ZI7 ZI9 ZJ3 ZJ4 ZJ7 F8 I6 G1
boolean volumemaker A5 A6 B3 B4 B7 B9 D3 D4 D7 F1
boolean bopcut_2d D5
bugs modalg_5 bug25043
bugs modalg_2 bug472_1 bug472_2 bug472_3

Test cases updated because they are still bad but can be accepted as non-regression:
boolean volumemaker C4 A3 A7 E6
bugs modalg_1 bug10232
boolean bsection N2

Put new TODO in the scripts:
bugs modalg_5 bug25232_9
bugs modalg_6 bug26619
bugs modalg_1 buc60462_2
bugs modalg_4 bug772

For the following tests the result in fix became better, so take fix result as the reference:
bugs modalg_5 bug24628
bugs modalg_6 bug26954_3
boolean volumemaker A4 B5 B6 C3 C8 D2 D5 F2
bugs modalg_2 bug472_2
bugs modalg_1 buc60776_1

- Add the method SetNonDestructive to API classes of user level
This commit is contained in:
msv
2015-10-21 12:36:03 +03:00
committed by bugmaster
parent 6435b9c7fa
commit 3510db6201
144 changed files with 2242 additions and 925 deletions

View File

@@ -200,7 +200,7 @@ IntTools_BeanFaceIntersector::IntTools_BeanFaceIntersector(const BRepAdaptor_Cur
{
myCurve = theCurve;
myCriteria = myBeanTolerance + myFaceTolerance;
myCriteria = myBeanTolerance + myFaceTolerance + Precision::Confusion();
myCurveResolution = myCurve.Resolution(myCriteria);
mySurface = theSurface;
@@ -220,7 +220,7 @@ void IntTools_BeanFaceIntersector::Init(const TopoDS_Edge& theEdge,
myBeanTolerance = BRep_Tool::Tolerance(theEdge);
myFaceTolerance = BRep_Tool::Tolerance(theFace);
myCriteria = myBeanTolerance + myFaceTolerance;
myCriteria = myBeanTolerance + myFaceTolerance + Precision::Confusion();
myCurveResolution = myCurve.Resolution(myCriteria);
SetSurfaceParameters(mySurface.FirstUParameter(), mySurface.LastUParameter(),
@@ -243,7 +243,7 @@ void IntTools_BeanFaceIntersector::Init(const BRepAdaptor_Curve& theCurve,
myBeanTolerance = theBeanTolerance;
myFaceTolerance = theFaceTolerance;
myCriteria = myBeanTolerance + myFaceTolerance;
myCriteria = myBeanTolerance + myFaceTolerance + Precision::Confusion();
myCurveResolution = myCurve.Resolution(myCriteria);
SetSurfaceParameters(mySurface.FirstUParameter(), mySurface.LastUParameter(),
@@ -1018,14 +1018,24 @@ void IntTools_BeanFaceIntersector::ComputeLinePlane()
if(myUMinParameter > u || u > myUMaxParameter || myVMinParameter > v || v > myVMaxParameter) {
return;
}
Standard_Real t1 = Max(myFirstParameter, t-myCriteria);
Standard_Real t2 = Min(myLastParameter, t+myCriteria);
//
// compute correct range on the edge
Standard_Real anAngle, aDt;
gp_Dir aDL, aDP;
//
aDL = L.Position().Direction();
aDP = P.Position().Direction();
anAngle = Abs(M_PI_2 - aDL.Angle(aDP));
//
aDt = IntTools_Tools::ComputeIntRange
(myBeanTolerance, myFaceTolerance, anAngle);
//
Standard_Real t1 = Max(myFirstParameter, t - aDt);
Standard_Real t2 = Min(myLastParameter, t + aDt);
IntTools_Range aRange(t1, t2);
myResults.Append(aRange);
return;
}

View File

@@ -500,7 +500,7 @@ Standard_Integer IntTools_Context::ComputePE
aDist=aProjector.LowerDistance();
//
aTolE2=BRep_Tool::Tolerance(aE2);
aTolSum=aTolP1+aTolE2;
aTolSum = aTolP1 + aTolE2 + Precision::Confusion();
//
aT=aProjector.LowerDistanceParameter();
if (aDist > aTolSum) {
@@ -515,7 +515,8 @@ Standard_Integer IntTools_Context::ComputePE
Standard_Integer IntTools_Context::ComputeVE
(const TopoDS_Vertex& aV1,
const TopoDS_Edge& aE2,
Standard_Real& aT)
Standard_Real& aParam,
Standard_Real& aTolVnew)
{
if (BRep_Tool::Degenerated(aE2)) {
return -1;
@@ -538,29 +539,29 @@ Standard_Integer IntTools_Context::ComputeVE
}
//
aDist=aProjector.LowerDistance();
// tolerance of check for coincidence is sum of tolerances of edge and vertex
// extended by additional Precision::Confusion() to allow for interference where
// it is very close but not fit to tolerance (see #24108)
//
aTolV1=BRep_Tool::Tolerance(aV1);
aTolE2=BRep_Tool::Tolerance(aE2);
aTolSum = aTolV1 + aTolE2 + Precision::Confusion();
//
aT=aProjector.LowerDistanceParameter();
aTolVnew=aDist+aTolE2;
//
aParam=aProjector.LowerDistanceParameter();
if (aDist > aTolSum) {
return -4;
}
return 0;
}
//=======================================================================
//function : ComputeVS
//function : ComputeVF
//purpose :
//=======================================================================
Standard_Integer IntTools_Context::ComputeVF
(const TopoDS_Vertex& aV1,
const TopoDS_Face& aF2,
Standard_Real& U,
Standard_Real& V)
Standard_Real& V,
Standard_Real& aTolVnew)
{
Standard_Real aTolV1, aTolF2, aTolSum, aDist;
gp_Pnt aP;
@@ -578,10 +579,13 @@ Standard_Integer IntTools_Context::ComputeVF
// 2. Check the distance between the projection point and
// the original point
aDist=aProjector.LowerDistance();
//
aTolV1=BRep_Tool::Tolerance(aV1);
aTolF2=BRep_Tool::Tolerance(aF2);
aTolSum=aTolV1+aTolF2;
//
aTolSum = aTolV1 + aTolF2 + Precision::Confusion();
aTolVnew = aDist + aTolF2;
//
if (aDist > aTolSum) {
// the distance is too large
return -2;
@@ -860,14 +864,16 @@ Standard_Boolean IntTools_Context::IsVertexOnLine
Extrema_ExtPC anExt2(aPv, aGAC, 1.e-10);
Standard_Real aMinDist = RealLast();
Standard_Integer aMinIdx = -1;
for (Standard_Integer anIdx = 1; anIdx <= anExt2.NbExt(); anIdx++)
{
if ( anExt2.IsMin(anIdx) &&
anExt2.SquareDistance(anIdx) < aMinDist )
if (anExt2.IsDone()) {
for (Standard_Integer anIdx = 1; anIdx <= anExt2.NbExt(); anIdx++)
{
if ( anExt2.IsMin(anIdx) &&
anExt2.SquareDistance(anIdx) < aMinDist )
{
aMinDist = anExt2.SquareDistance(anIdx);
aMinIdx = anIdx;
}
}
}
if (aMinIdx != -1)
{
@@ -912,14 +918,16 @@ Standard_Boolean IntTools_Context::IsVertexOnLine
Extrema_ExtPC anExt2(aPv, aGAC, 1.e-10);
Standard_Real aMinDist = RealLast();
Standard_Integer aMinIdx = -1;
for (Standard_Integer anIdx = 1; anIdx <= anExt2.NbExt(); anIdx++)
{
if ( anExt2.IsMin(anIdx) &&
anExt2.SquareDistance(anIdx) < aMinDist )
if (anExt2.IsDone()) {
for (Standard_Integer anIdx = 1; anIdx <= anExt2.NbExt(); anIdx++)
{
if ( anExt2.IsMin(anIdx) &&
anExt2.SquareDistance(anIdx) < aMinDist )
{
aMinDist = anExt2.SquareDistance(anIdx);
aMinIdx = anIdx;
}
}
}
if (aMinIdx != -1)
{

View File

@@ -112,27 +112,35 @@ Standard_EXPORT virtual ~IntTools_Context();
//! Computes parameter of the vertex aV on
//! the edge aE.
//! the edge aE and new increased value of vertex tolerance.
//! Returns zero if the distance between vertex
//! and edge is less than sum of tolerances,
//! otherwise and for following conditions returns
//! negative value
//! 1. the edge is degenerated (-1)
//! 2. the edge does not contain 3d curve and pcurves (-2)
//! negative value: <br>
//! 1. the edge is degenerated (-1) <br>
//! 2. the edge does not contain 3d curve and pcurves (-2) <br>
//! 3. projection algorithm failed (-3)
Standard_EXPORT Standard_Integer ComputeVE (const TopoDS_Vertex& aV, const TopoDS_Edge& aE, Standard_Real& aT);
Standard_EXPORT Standard_Integer ComputeVE (const TopoDS_Vertex& aV,
const TopoDS_Edge& aE,
Standard_Real& aParam,
Standard_Real& aTolVnew);
//! Computes UV parameters of the vertex aV on face aF
//! and new increased value of vertex tolerance.
//! Returns zero if the distance between vertex and face is
//! less than or equal the sum of tolerances and the projection
//! point lays inside boundaries of the face.
//! For following conditions returns negative value
//! 1. projection algorithm failed (-1)
//! 2. distance is more than sum of tolerances (-2)
//! For following conditions returns negative value <br>
//! 1. projection algorithm failed (-1) <br>
//! 2. distance is more than sum of tolerances (-2) <br>
//! 3. projection point out or on the boundaries of face (-3)
Standard_EXPORT Standard_Integer ComputeVF (const TopoDS_Vertex& aV, const TopoDS_Face& aF, Standard_Real& U, Standard_Real& V);
Standard_EXPORT Standard_Integer ComputeVF (const TopoDS_Vertex& aV,
const TopoDS_Face& aF,
Standard_Real& U,
Standard_Real& V,
Standard_Real& aTolVnew);
//! Returns the state of the point aP2D
//! relative to face aF

View File

@@ -30,6 +30,7 @@
#include <IntTools_CommonPrt.hxx>
#include <IntTools_EdgeEdge.hxx>
#include <IntTools_Range.hxx>
#include <IntTools_Tools.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Iterator.hxx>
@@ -157,8 +158,9 @@ void IntTools_EdgeEdge::Prepare()
mySwap = Standard_True;
}
//
myTol1 = myCurve1.Tolerance();
myTol2 = myCurve2.Tolerance();
Standard_Real aTolAdd = Precision::Confusion() / 2.;
myTol1 = myCurve1.Tolerance() + aTolAdd;
myTol2 = myCurve2.Tolerance() + aTolAdd;
myTol = myTol1 + myTol2;
//
if (iCT1 != 0 || iCT2 != 0) {
@@ -321,7 +323,7 @@ void IntTools_EdgeEdge::FindSolutions(const IntTools_Range& theR1,
bThin = ((aT12 - aT11) < myRes1) ||
(aB1.IsXThin(myTol) && aB1.IsYThin(myTol) && aB1.IsZThin(myTol));
//
bOut = !FindParameters(myCurve2, aTB21, aTB22, myRes2, myPTol2,
bOut = !FindParameters(myCurve2, aTB21, aTB22, myTol2, myRes2, myPTol2,
myResCoeff2, aB1, aT21, aT22);
if (bOut || bThin) {
break;
@@ -338,7 +340,7 @@ void IntTools_EdgeEdge::FindSolutions(const IntTools_Range& theR1,
bThin = ((aT22 - aT21) < myRes2) ||
(aB2.IsXThin(myTol) && aB2.IsYThin(myTol) && aB2.IsZThin(myTol));
//
bOut = !FindParameters(myCurve1, aTB11, aTB12, myRes1, myPTol1,
bOut = !FindParameters(myCurve1, aTB11, aTB12, myTol1, myRes1, myPTol1,
myResCoeff1, aB2, aT11, aT12);
//
if (bOut || bThin) {
@@ -439,7 +441,8 @@ void IntTools_EdgeEdge::FindSolutions(const IntTools_Range& theR1,
//=======================================================================
Standard_Boolean IntTools_EdgeEdge::FindParameters(const BRepAdaptor_Curve& theBAC,
const Standard_Real aT1,
const Standard_Real aT2,
const Standard_Real aT2,
const Standard_Real theTol,
const Standard_Real theRes,
const Standard_Real thePTol,
const Standard_Real theResCoeff,
@@ -450,18 +453,17 @@ Standard_Boolean IntTools_EdgeEdge::FindParameters(const BRepAdaptor_Curve& theB
Standard_Boolean bRet;
Standard_Integer aC, i, k;
Standard_Real aCf, aDiff, aDt, aT, aTB, aTOut, aTIn;
Standard_Real aDist, aDistP, aDistTol, aTol;
Standard_Real aDist, aDistP, aDistTol;
gp_Pnt aP;
Bnd_Box aCBx;
//
bRet = Standard_False;
aCf = 0.6180339887498948482045868343656;// =0.5*(1.+sqrt(5.))/2.;
aDt = theRes;
aTol = theBAC.Tolerance();
aDistP = 0.;
aDistTol = Precision::PConfusion();
aDistTol = 1e-9;
aCBx = theCBox;
aCBx.Enlarge(aTol);
aCBx.Enlarge(theTol);
//
const Handle(Geom_Curve)& aCurve = theBAC.Curve().Curve();
const GeomAbs_CurveType aCurveType = theBAC.GetType();
@@ -476,7 +478,7 @@ Standard_Boolean IntTools_EdgeEdge::FindParameters(const BRepAdaptor_Curve& theB
while (aC*(aT-aTB) >= 0) {
theBAC.D0(aTB, aP);
aDist = PointBoxDistance(theCBox, aP);
if (aDist > aTol) {
if (aDist > theTol) {
if (fabs(aDist - aDistP) < aDistTol) {
aDt = Resolution(aCurve, aCurveType, theResCoeff, (++k)*aDist);
} else {
@@ -867,8 +869,16 @@ void IntTools_EdgeEdge::ComputeLineLine()
return;
}
//
aCommonPrt.SetRange1(aT1 - myTol, aT1 + myTol);
aCommonPrt.AppendRange2(aT2 - myTol, aT2 + myTol);
// compute correct range on the edges
Standard_Real anAngle, aDt1, aDt2;
//
anAngle = aD1.Angle(aD2);
//
aDt1 = IntTools_Tools::ComputeIntRange(myTol1, myTol2, anAngle);
aDt2 = IntTools_Tools::ComputeIntRange(myTol2, myTol1, anAngle);
//
aCommonPrt.SetRange1(aT1 - aDt1, aT1 + aDt1);
aCommonPrt.AppendRange2(aT2 - aDt2, aT2 + aDt2);
aCommonPrt.SetType(TopAbs_VERTEX);
aCommonPrt.SetVertexParameter1(aT1);
aCommonPrt.SetVertexParameter2(aT2);

View File

@@ -47,48 +47,51 @@ public:
//! Empty contructor
IntTools_EdgeEdge();
~IntTools_EdgeEdge();
IntTools_EdgeEdge();
//! Destructor
~IntTools_EdgeEdge();
//! Contructor
IntTools_EdgeEdge(const TopoDS_Edge& theEdge1, const TopoDS_Edge& theEdge2);
//! Contructor
IntTools_EdgeEdge(const TopoDS_Edge& theEdge1, const TopoDS_Edge& theEdge2);
//! Contructor
IntTools_EdgeEdge(const TopoDS_Edge& theEdge1, const Standard_Real aT11, const Standard_Real aT12, const TopoDS_Edge& theEdge2, const Standard_Real aT21, const Standard_Real aT22);
IntTools_EdgeEdge(const TopoDS_Edge& theEdge1, const Standard_Real aT11,
const Standard_Real aT12, const TopoDS_Edge& theEdge2,
const Standard_Real aT21, const Standard_Real aT22);
//! Sets the first edge
void SetEdge1 (const TopoDS_Edge& theEdge);
void SetEdge1(const TopoDS_Edge& theEdge);
//! Sets the first edge and its range
void SetEdge1 (const TopoDS_Edge& theEdge, const Standard_Real aT1, const Standard_Real aT2);
void SetEdge1(const TopoDS_Edge& theEdge, const Standard_Real aT1, const Standard_Real aT2);
//! Sets the range for the first edge
void SetRange1 (const IntTools_Range& theRange1);
void SetRange1(const IntTools_Range& theRange1);
//! Sets the range for the first edge
void SetRange1 (const Standard_Real aT1, const Standard_Real aT2);
void SetRange1(const Standard_Real aT1, const Standard_Real aT2);
//! Sets the second edge
void SetEdge2 (const TopoDS_Edge& theEdge);
void SetEdge2(const TopoDS_Edge& theEdge);
//! Sets the first edge and its range
void SetEdge2 (const TopoDS_Edge& theEdge, const Standard_Real aT1, const Standard_Real aT2);
void SetEdge2(const TopoDS_Edge& theEdge, const Standard_Real aT1, const Standard_Real aT2);
//! Sets the range for the second edge
void SetRange2 (const IntTools_Range& theRange);
void SetRange2(const IntTools_Range& theRange);
//! Sets the range for the second edge
void SetRange2 (const Standard_Real aT1, const Standard_Real aT2);
void SetRange2(const Standard_Real aT1, const Standard_Real aT2);
//! Performs the intersection between edges
@@ -96,11 +99,11 @@ public:
//! Returns TRUE if common part(s) is(are) found
Standard_Boolean IsDone() const;
Standard_Boolean IsDone() const;
//! Returns common parts
const IntTools_SequenceOfCommonPrts& CommonParts() const;
const IntTools_SequenceOfCommonPrts& CommonParts() const;
@@ -110,7 +113,7 @@ protected:
//! Checks the data
void CheckData();
void CheckData();
//! Prepares the data
@@ -122,36 +125,50 @@ protected:
//! Intermediate function
Standard_EXPORT void FindSolutions (IntTools_SequenceOfRanges& theRanges1, IntTools_SequenceOfRanges& theRanges2, Standard_Boolean& bSplit2);
Standard_EXPORT void FindSolutions (IntTools_SequenceOfRanges& theRanges1,
IntTools_SequenceOfRanges& theRanges2, Standard_Boolean& bSplit2);
//! Looking for the exact intersection ranges
Standard_EXPORT void FindSolutions (const IntTools_Range& theR1, const IntTools_Range& theR2, const Bnd_Box& theBox2, IntTools_SequenceOfRanges& theRanges1, IntTools_SequenceOfRanges& theRanges2);
Standard_EXPORT void FindSolutions (const IntTools_Range& theR1,
const IntTools_Range& theR2, const Bnd_Box& theBox2,
IntTools_SequenceOfRanges& theRanges1, IntTools_SequenceOfRanges& theRanges2);
//! Merges found solutions
Standard_EXPORT void MergeSolutions (const IntTools_SequenceOfRanges& theRanges1, const IntTools_SequenceOfRanges& theRanges2, const Standard_Boolean bSplit2);
Standard_EXPORT void MergeSolutions (const IntTools_SequenceOfRanges& theRanges1,
const IntTools_SequenceOfRanges& theRanges2, const Standard_Boolean bSplit2);
//! Looking for the range of the edge whick is in the box
Standard_EXPORT static Standard_Boolean FindParameters (const BRepAdaptor_Curve& theBAC, const Standard_Real aT1, const Standard_Real aT2, const Standard_Real theRes, const Standard_Real thePTol, const Standard_Real theResCoeff, const Bnd_Box& theCBox, Standard_Real& aTB1, Standard_Real& aTB2);
Standard_EXPORT static Standard_Boolean FindParameters(const BRepAdaptor_Curve& theBAC,
const Standard_Real aT1, const Standard_Real aT2, const Standard_Real theTol,
const Standard_Real theRes, const Standard_Real thePTol,
const Standard_Real theResCoeff, const Bnd_Box& theCBox,
Standard_Real& aTB1, Standard_Real& aTB2);
//! Checks if edges coincide on the ranges
Standard_EXPORT Standard_Integer CheckCoincidence (const Standard_Real aT11, const Standard_Real aT12, const Standard_Real aT21, const Standard_Real aT22, const Standard_Real theCriteria, const Standard_Real theCurveRes1);
Standard_EXPORT Standard_Integer CheckCoincidence (const Standard_Real aT11,
const Standard_Real aT12, const Standard_Real aT21, const Standard_Real aT22,
const Standard_Real theCriteria, const Standard_Real theCurveRes1);
//! Adds common part of the given type to myCommonParts
Standard_EXPORT void AddSolution (const Standard_Real aT11, const Standard_Real aT12, const Standard_Real aT21, const Standard_Real aT22, const TopAbs_ShapeEnum theType);
Standard_EXPORT void AddSolution (const Standard_Real aT11, const Standard_Real aT12,
const Standard_Real aT21, const Standard_Real aT22, const TopAbs_ShapeEnum theType);
//! Looking for the minimal distance between edges on the ranges
Standard_EXPORT void FindBestSolution (const Standard_Real aT11, const Standard_Real aT12, const Standard_Real aT21, const Standard_Real aT22, Standard_Real& aT1, Standard_Real& aT2);
Standard_EXPORT void FindBestSolution (const Standard_Real aT11, const Standard_Real aT12,
const Standard_Real aT21, const Standard_Real aT22,
Standard_Real& aT1, Standard_Real& aT2);
//! Checks is there an intersection between edges on the given ranges
//! (for nearly conicident edges)
Standard_EXPORT Standard_Boolean IsIntersection (const Standard_Real aT11, const Standard_Real aT12, const Standard_Real aT21, const Standard_Real aT22);
Standard_EXPORT Standard_Boolean IsIntersection (const Standard_Real aT11,
const Standard_Real aT12, const Standard_Real aT21, const Standard_Real aT22);
TopoDS_Edge myEdge1;
@@ -175,20 +192,10 @@ protected:
Standard_Integer myErrorStatus;
IntTools_SequenceOfCommonPrts myCommonParts;
private:
};
#include <IntTools_EdgeEdge.lxx>
#endif // _IntTools_EdgeEdge_HeaderFile

View File

@@ -284,7 +284,7 @@ void IntTools_EdgeFace::Prepare()
myCriteria=1.5*myTolE+myTolF;
}
else {
myCriteria=myTolE+myTolF;
myCriteria = myTolE + myTolF + Precision::Confusion();
}
// 2.a myTmin, myTmax
myTmin=myRange.First();
@@ -1236,7 +1236,7 @@ void IntTools_EdgeFace::Perform()
myCriteria=1.5*myTolE+myTolF;
}
else {
myCriteria=myTolE+myTolF;
myCriteria = myTolE + myTolF + Precision::Confusion();
}
myTmin=myRange.First();

View File

@@ -151,12 +151,15 @@ static
static void PerformPlanes(const Handle(GeomAdaptor_HSurface)& theS1,
const Handle(GeomAdaptor_HSurface)& theS2,
const Standard_Real TolF1,
const Standard_Real TolF2,
const Standard_Real TolAng,
const Standard_Real TolTang,
const Standard_Boolean theApprox1,
const Standard_Boolean theApprox2,
IntTools_SequenceOfCurves& theSeqOfCurve,
Standard_Boolean& theTangentFaces);
Standard_Boolean& theTangentFaces,
Standard_Real& TolReached3d);
static Standard_Boolean ClassifyLin2d(const Handle(GeomAdaptor_HSurface)& theS,
const gp_Lin2d& theLin2d,
@@ -225,6 +228,7 @@ IntTools_FaceFace::IntTools_FaceFace()
myHS2 = new GeomAdaptor_HSurface ();
myTolReached2d=0.;
myTolReached3d=0.;
myTolReal = 0.;
SetParameters(Standard_True, Standard_True, Standard_True, 1.e-07);
}
@@ -293,6 +297,14 @@ Standard_Real IntTools_FaceFace::TolReached3d() const
return myTolReached3d;
}
//=======================================================================
//function : TolReal
//purpose :
//=======================================================================
Standard_Real IntTools_FaceFace::TolReal() const
{
return myTolReal;
}
//=======================================================================
//function : Lines
//purpose : return lines of intersection
//=======================================================================
@@ -341,7 +353,7 @@ static Standard_Boolean isTreatAnalityc(const TopoDS_Face& theF1,
const Standard_Real Tolang = 1.e-8;
const Standard_Real aTolF1=BRep_Tool::Tolerance(theF1);
const Standard_Real aTolF2=BRep_Tool::Tolerance(theF2);
const Standard_Real aTolSum = aTolF1 + aTolF2;
const Standard_Real aTolSum = aTolF1 + aTolF2 + Precision::Confusion();
Standard_Real aHigh = 0.0;
const BRepAdaptor_Surface aBAS1(theF1), aBAS2(theF2);
@@ -424,6 +436,7 @@ void IntTools_FaceFace::Perform(const TopoDS_Face& aF1,
mySeqOfCurve.Clear();
myTolReached2d=0.;
myTolReached3d=0.;
myTolReal = 0.;
myIsDone = Standard_False;
myNbrestr=0;//?
@@ -469,7 +482,7 @@ void IntTools_FaceFace::Perform(const TopoDS_Face& aF1,
const Standard_Real aTolF1=BRep_Tool::Tolerance(myFace1);
const Standard_Real aTolF2=BRep_Tool::Tolerance(myFace2);
Standard_Real TolArc = aTolF1 + aTolF2;
Standard_Real TolArc = aTolF1 + aTolF2 + Precision::Confusion();
Standard_Real TolTang = TolArc;
const Standard_Boolean isFace1Quad = (aType1 == GeomAbs_Cylinder ||
@@ -493,8 +506,10 @@ void IntTools_FaceFace::Perform(const TopoDS_Face& aF1,
//
Standard_Real TolAng = 1.e-8;
//
PerformPlanes(myHS1, myHS2, TolAng, TolTang, myApprox1, myApprox2,
mySeqOfCurve, myTangentFaces);
PerformPlanes(myHS1, myHS2,
aTolF1, aTolF2, TolAng, TolTang,
myApprox1, myApprox2,
mySeqOfCurve, myTangentFaces, myTolReached3d);
//
myIsDone = Standard_True;
@@ -502,13 +517,16 @@ void IntTools_FaceFace::Perform(const TopoDS_Face& aF1,
const Standard_Integer NbLinPP = mySeqOfCurve.Length();
if(NbLinPP) {
Standard_Real aTolFMax;
myTolReached3d = 1.e-7;
aTolFMax=Max(aTolF1, aTolF2);
if (aTolFMax>myTolReached3d) {
myTolReached3d=aTolFMax;
myTolReal = Precision::Confusion();
if (aTolFMax > myTolReal) {
myTolReal = aTolFMax;
}
if (aTolFMax > myTolReached3d) {
myTolReached3d = aTolFMax;
}
//
myTolReached2d = myTolReached3d;
myTolReached2d = myTolReal;
if (bReverse) {
Handle(Geom2d_Curve) aC2D1, aC2D2;
@@ -778,7 +796,7 @@ Standard_Real IntTools_FaceFace::ComputeTolerance()
//function :ComputeTolReached3d
//purpose :
//=======================================================================
void IntTools_FaceFace::ComputeTolReached3d()
void IntTools_FaceFace::ComputeTolReached3d()
{
Standard_Integer aNbLin;
GeomAbs_SurfaceType aType1, aType2;
@@ -825,9 +843,10 @@ Standard_Real IntTools_FaceFace::ComputeTolerance()
Standard_Real aDMax = ComputeTolerance();
if (aDMax > myTolReached3d)
{
myTolReached3d = aDMax;
}
myTolReached3d = aDMax;
}
myTolReal = myTolReached3d;
}
//=======================================================================
//function : MakeCurve
@@ -2686,12 +2705,15 @@ Standard_Boolean ApproxWithPCurves(const gp_Cylinder& theCyl,
//=======================================================================
void PerformPlanes(const Handle(GeomAdaptor_HSurface)& theS1,
const Handle(GeomAdaptor_HSurface)& theS2,
const Standard_Real TolF1,
const Standard_Real TolF2,
const Standard_Real TolAng,
const Standard_Real TolTang,
const Standard_Boolean theApprox1,
const Standard_Boolean theApprox2,
IntTools_SequenceOfCurves& theSeqOfCurve,
Standard_Boolean& theTangentFaces)
Standard_Boolean& theTangentFaces,
Standard_Real& TolReached3d)
{
gp_Pln aPln1 = theS1->Surface().Plane();
@@ -2774,7 +2796,17 @@ void PerformPlanes(const Handle(GeomAdaptor_HSurface)& theS1,
}
theSeqOfCurve.Append(aCurve);
//
// computation of the tolerance reached
Standard_Real anAngle, aDt;
gp_Dir aD1, aD2;
//
aD1 = aPln1.Position().Direction();
aD2 = aPln2.Position().Direction();
anAngle = aD1.Angle(aD2);
//
aDt = IntTools_Tools::ComputeIntRange(TolF1, TolF2, anAngle);
TolReached3d = sqrt(aDt*aDt + TolF1*TolF1);
}
//=======================================================================

View File

@@ -72,10 +72,14 @@ public:
Standard_EXPORT const IntTools_SequenceOfPntOn2Faces& Points() const;
//! Returns tolerance reached during approximation.
//! Returns tolerance reached during approximation,
//! and possibly increased to cover more area due to a small angle between surfaces.
//! If approximation was not done, returns zero.
Standard_EXPORT Standard_Real TolReached3d() const;
//! Returns tolerance reached during approximation, without any increase.
//! If approximation was not done, returns zero.
Standard_EXPORT Standard_Real TolReal() const;
//! Returns tolerance reached during approximation.
//! If approximation was not done, returns zero.
@@ -92,7 +96,7 @@ public:
//! Returns True if faces are tangent
Standard_EXPORT Standard_Boolean TangentFaces() const;
//! Provides post-processing the result lines.
//! <bToSplit> - the flag.
@@ -141,6 +145,7 @@ private:
Standard_Integer myNbrestr;
Standard_Real myTolReached2d;
Standard_Real myTolReached3d;
Standard_Real myTolReal;
Standard_Boolean myApprox;
Standard_Boolean myApprox1;
Standard_Boolean myApprox2;

View File

@@ -137,7 +137,7 @@ void IntTools_ShrunkRange::SetShrunkRange(const Standard_Real aT1,
void IntTools_ShrunkRange::Perform()
{
Standard_Real aCF, aCL, aTolE, aTolV1;
Standard_Real aTolV2, t1, t11, t1C, t2, t12, t2C;
Standard_Real aTolV2, t1, t11, t1C, t2, t12, t2C, dummy;
Standard_Real aCoeff1, aCoeff2, aTol1, aTol2, dt1, dt2, aR, anEps;
Standard_Integer pri;
Standard_Boolean bInf1, bInf2, bAppr;
@@ -187,8 +187,8 @@ void IntTools_ShrunkRange::Perform()
return;
}
//
aTol1 = aTolV1+aTolE;
aTol2 = aTolV2+aTolE;
aTol1 = Max(aTolV1, aTolE);
aTol2 = Max(aTolV2, aTolE);
//
aCoeff1 = (aTolE>0.05) ? 1. : 2.;
aCoeff2 = aCoeff1;
@@ -214,9 +214,11 @@ void IntTools_ShrunkRange::Perform()
//
if (fabs(aTV1-aCF)<aEps) {
aCoeff1=1.;
aTol1 += Precision::Confusion();
}
if (fabs(aTV2-aCL)<aEps) {
aCoeff2=1.;
aTol2 += Precision::Confusion();
}
}
//
@@ -346,7 +348,7 @@ void IntTools_ShrunkRange::Perform()
BRepBuilderAPI_MakeVertex aMV1(aP1L);
const TopoDS_Vertex& aV1L=aMV1.Vertex();
//
pri=myCtx->ComputeVE (aV1L, myEdge, t1C);
pri = myCtx->ComputeVE(aV1L, myEdge, t1C, dummy);
//
if (pri==-3) {
myErrorStatus=4;
@@ -446,7 +448,7 @@ void IntTools_ShrunkRange::Perform()
BRepBuilderAPI_MakeVertex aMV2(aP2L);
const TopoDS_Vertex& aV2L=aMV2.Vertex();
//
pri=myCtx->ComputeVE (aV2L, myEdge, t2C);
pri = myCtx->ComputeVE(aV2L, myEdge, t2C, dummy);
//
if (pri==-3) {
myErrorStatus=5;
@@ -474,7 +476,7 @@ void IntTools_ShrunkRange::Perform()
myTS2=t2C;
//
// BndBox
Standard_Real ddx=aTolE;//1.e-12;
Standard_Real ddx = aTolE + Precision::Confusion();
BndLib_Add3dCurve::Add (aBAC, t1C, t2C, ddx, myBndBox);
}
/////////////////////////////////////////////////////////////////////////

View File

@@ -676,7 +676,7 @@ Standard_Boolean IntTools_Tools::IsOnPave1(const Standard_Real aTR,
//
aT1=aCPRange.First();
aT2=aCPRange.Last();
bIsOnPave=(aTR>=aT1 && aTR<=aT1);
bIsOnPave=(aTR>=aT1 && aTR<=aT2);
if (bIsOnPave) {
return bIsOnPave;
}
@@ -802,3 +802,28 @@ Standard_Boolean IntTools_Tools::ComputeTolerance
//
return Standard_True;
}
//=======================================================================
// Function : ComputeIntRange
// purpose :
//=======================================================================
Standard_Real IntTools_Tools::ComputeIntRange(const Standard_Real theTol1,
const Standard_Real theTol2,
const Standard_Real theAngle)
{
Standard_Real aDt;
//
if (Abs(M_PI_2 - theAngle) < Precision::Angular()) {
aDt = theTol2;
}
else {
Standard_Real a1, a2, anAngle;
//
anAngle = (theAngle > M_PI_2) ? (M_PI - theAngle) : theAngle;
a1 = theTol1 * tan(M_PI_2 - anAngle);
a2 = theTol2 / sin(anAngle);
aDt = a1 + a2;
}
//
return aDt;
}

View File

@@ -163,6 +163,11 @@ public:
Standard_EXPORT static Standard_Boolean 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);
//! Computes the correct Intersection range for
//! Line/Line, Line/Plane and Plane/Plane intersections
Standard_EXPORT static Standard_Real ComputeIntRange(const Standard_Real theTol1,
const Standard_Real theTol2,
const Standard_Real theAngle);
protected: