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

0028591: BOP Cut creates wrong result

The Face/Face intersection procedure has been changed in Boolean Operations algorithm.
Previously, the intersection tolerance for all section curves between pair of faces has been calculated
as the maximal tolerance among all curves. Now, each curve has its own valid tolerance calculated
as the maximal deviation of the 3D curve from its 2D curves on faces or surfaces in case there are no 2D curves.

Thus, such methods of IntTools_FaceFace algorithm as TolReached3d(), TolReal() and TolReached2d() have been removed.
Now the tolerances of the curve can be obtained from the curve itself (IntTools_Curve - result of intersection):
- IntTools_Curve::Tolerance() - returns the valid tolerance for the curve;
- IntTools_Curve::TangentialTolerance() - returns the tangential tolerance, which depends on the size of the common
  between faces. Currently, this tolerance is computed for Plane/Plane cases only. For other case, the value
  of the tangential tolerance is the maximal tolerance of faces.

2D intersection tolerance (IntTools_FaceFace::TolReached2d()) has been completely removed from the algorithm as unused.
This commit is contained in:
emv
2017-03-29 08:46:31 +03:00
committed by bugmaster
parent 769a2e88e0
commit 5652dc6272
16 changed files with 512 additions and 861 deletions

View File

@@ -20,7 +20,6 @@ IntTools_Context.cxx
IntTools_Context.hxx
IntTools_Curve.cxx
IntTools_Curve.hxx
IntTools_Curve.lxx
IntTools_CurveRangeLocalizeData.cxx
IntTools_CurveRangeLocalizeData.hxx
IntTools_CurveRangeLocalizeData.lxx

View File

@@ -12,105 +12,91 @@
// commercial license or contractual agreement.
#include <IntTools_Curve.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom_BoundedCurve.hxx>
#include <Geom_Curve.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <gp_Pnt.hxx>
#include <IntTools_Curve.hxx>
//=======================================================================
//function : IntTools_Curve::IntTools_Curve
//purpose :
//=======================================================================
IntTools_Curve::IntTools_Curve()
:
myTolerance(0.0),
myTangentialTolerance(0.0)
{
}
//=======================================================================
//function : IntTools_Curve::IntTools_Curve
//purpose :
//=======================================================================
IntTools_Curve::IntTools_Curve(const Handle(Geom_Curve)& Curve3d,
const Handle(Geom2d_Curve)& FirstCurve2d,
const Handle(Geom2d_Curve)& SecondCurve2d)
IntTools_Curve::IntTools_Curve(const Handle(Geom_Curve)& the3dCurve,
const Handle(Geom2d_Curve)& the2dCurve1,
const Handle(Geom2d_Curve)& the2dCurve2,
const Standard_Real theTolerance,
const Standard_Real theTangentialTolerance)
:
myTolerance(theTolerance),
myTangentialTolerance(theTangentialTolerance)
{
SetCurves(Curve3d, FirstCurve2d, SecondCurve2d);
SetCurves(the3dCurve, the2dCurve1, the2dCurve2);
}
//=======================================================================
//function : SetCurves
//purpose :
//=======================================================================
void IntTools_Curve::SetCurves(const Handle(Geom_Curve)& Curve3d,
const Handle(Geom2d_Curve)& FirstCurve2d,
const Handle(Geom2d_Curve)& SecondCurve2d)
{
SetCurve(Curve3d);
SetFirstCurve2d(FirstCurve2d);
SetSecondCurve2d(SecondCurve2d);
}
//=======================================================================
//function : HasBounds
//purpose :
//=======================================================================
Standard_Boolean IntTools_Curve::HasBounds() const
{
Standard_Boolean bBounded;
Handle(Geom_BoundedCurve) aC3DBounded =
Handle(Geom_BoundedCurve)::DownCast(my3dCurve);
bBounded=!aC3DBounded.IsNull();
return bBounded ;
Standard_Boolean bIsBounded = !aC3DBounded.IsNull();
return bIsBounded;
}
//=======================================================================
//function : Bounds
//purpose :
//=======================================================================
void IntTools_Curve::Bounds(Standard_Real& aT1,
Standard_Real& aT2,
gp_Pnt& aP1,
gp_Pnt& aP2) const
Standard_Boolean IntTools_Curve::Bounds(Standard_Real& theFirst,
Standard_Real& theLast,
gp_Pnt& theFirstPnt,
gp_Pnt& theLastPnt) const
{
aT1=0.;
aT2=0.;
aP1.SetCoord(0.,0.,0.);
aP2.SetCoord(0.,0.,0.);
if (HasBounds()) {
aT1=my3dCurve->FirstParameter();
aT2=my3dCurve->LastParameter();
my3dCurve->D0(aT1, aP1);
my3dCurve->D0(aT2, aP2);
Standard_Boolean bIsBounded = HasBounds();
if (bIsBounded) {
theFirst = my3dCurve->FirstParameter();
theLast = my3dCurve->LastParameter();
my3dCurve->D0(theFirst, theFirstPnt);
my3dCurve->D0(theLast, theLastPnt);
}
return bIsBounded;
}
//=======================================================================
//function : D0
//purpose :
//=======================================================================
Standard_Boolean IntTools_Curve::D0(Standard_Real& aT,
gp_Pnt& aP) const
Standard_Boolean IntTools_Curve::D0(const Standard_Real& thePar,
gp_Pnt& thePnt) const
{
Standard_Real aF, aL;
aF=my3dCurve->FirstParameter();
aL=my3dCurve->LastParameter();
if (aT<aF || aT>aL) {
return Standard_False;
Standard_Boolean bInside = !(thePar < my3dCurve->FirstParameter() &&
thePar > my3dCurve->LastParameter());
if (bInside) {
my3dCurve->D0(thePar, thePnt);
}
my3dCurve->D0(aT, aP);
return Standard_True;
return bInside;
}
//=======================================================================
//function : D0
//function : Type
//purpose :
//=======================================================================
GeomAbs_CurveType IntTools_Curve::Type() const
GeomAbs_CurveType IntTools_Curve::Type() const
{
GeomAdaptor_Curve aGAC(my3dCurve);
GeomAbs_CurveType aType=aGAC.GetType();
GeomAbs_CurveType aType = aGAC.GetType();
return aType;
}

View File

@@ -27,103 +27,133 @@ class Geom_Curve;
class Geom2d_Curve;
class gp_Pnt;
//! class is a container of
//! one 3d curve
//! two 2d curves
class IntTools_Curve
//! The class is a container of one 3D curve, two 2D curves and two Tolerance values.<br>
//! It is used in the Face/Face intersection algorithm to store the results
//! of intersection. In this context:<br>
//! **the 3D curve** is the intersection curve;<br>
//! **the 2D curves** are the PCurves of the 3D curve on the intersecting faces;<br>
//! **the tolerance** is the valid tolerance for 3D curve computed as
//! maximal deviation between 3D curve and 2D curves (or surfaces in case there are no 2D curves);<br>
//! **the tangential tolerance** is the maximal distance from 3D curve to the
//! end of the tangential zone between faces in terms of their tolerance values.
class IntTools_Curve
{
public:
DEFINE_STANDARD_ALLOC
//! Empty constructor
Standard_EXPORT IntTools_Curve();
//! Initializes me by a 3d curve
//! and two 2d curves
Standard_EXPORT IntTools_Curve(const Handle(Geom_Curve)& Curve3d, const Handle(Geom2d_Curve)& FirstCurve2d, const Handle(Geom2d_Curve)& SecondCurve2d);
//! Constructor taking 3d curve, two 2d curves and two tolerance values
Standard_EXPORT IntTools_Curve(const Handle(Geom_Curve)& the3dCurve3d,
const Handle(Geom2d_Curve)& the2dCurve1,
const Handle(Geom2d_Curve)& the2dCurve2,
const Standard_Real theTolerance = 0.0,
const Standard_Real theTangentialTolerance = 0.0);
//! Modifier
Standard_EXPORT void SetCurves (const Handle(Geom_Curve)& Curve3d, const Handle(Geom2d_Curve)& FirstCurve2d, const Handle(Geom2d_Curve)& SecondCurve2d);
//! Sets the curves
void SetCurves(const Handle(Geom_Curve)& the3dCurve,
const Handle(Geom2d_Curve)& the2dCurve1,
const Handle(Geom2d_Curve)& the2dCurve2)
{
my3dCurve = the3dCurve;
my2dCurve1 = the2dCurve1;
my2dCurve2 = the2dCurve2;
}
//! Modifier
void SetCurve (const Handle(Geom_Curve)& Curve3d);
//! Sets the 3d curve
void SetCurve(const Handle(Geom_Curve)& the3dCurve)
{
my3dCurve = the3dCurve;
}
//! Modifier
void SetFirstCurve2d (const Handle(Geom2d_Curve)& FirstCurve2d);
//! Sets the first 2d curve
void SetFirstCurve2d(const Handle(Geom2d_Curve)& the2dCurve1)
{
my2dCurve1 = the2dCurve1;
}
//! Modifier
void SetSecondCurve2d (const Handle(Geom2d_Curve)& SecondCurve2d);
//! Sets the second 2d curve
void SetSecondCurve2d(const Handle(Geom2d_Curve)& the2dCurve2)
{
my2dCurve2 = the2dCurve2;
}
//! Selector
const Handle(Geom_Curve)& Curve() const;
//! Sets the tolerance for the curve
void SetTolerance(const Standard_Real theTolerance)
{
myTolerance = theTolerance;
}
//! Selector
const Handle(Geom2d_Curve)& FirstCurve2d() const;
//! Sets the tangential tolerance
void SetTangentialTolerance(const Standard_Real theTangentialTolerance)
{
myTangentialTolerance = theTangentialTolerance;
}
//! Selector
const Handle(Geom2d_Curve)& SecondCurve2d() const;
//! Returns 3d curve
const Handle(Geom_Curve)& Curve() const
{
return my3dCurve;
}
//! Returns true if 3d curve is BoundedCurve from Geom
//! Returns first 2d curve
const Handle(Geom2d_Curve)& FirstCurve2d() const
{
return my2dCurve1;
}
//! Returns second 2d curve
const Handle(Geom2d_Curve)& SecondCurve2d() const
{
return my2dCurve2;
}
//! Returns the tolerance
Standard_Real Tolerance() const
{
return myTolerance;
}
//! Returns the tangential tolerance
Standard_Real TangentialTolerance() const
{
return myTangentialTolerance;
}
//! Returns TRUE if 3d curve is BoundedCurve
Standard_EXPORT Standard_Boolean HasBounds() const;
//! Returns boundary parameters
//! and corresponded 3d point.
//!
//! Warning:
//! If HasBounds returns false
//! the returned parameters are equal
//! to zero.
Standard_EXPORT void Bounds (Standard_Real& aT1, Standard_Real& aT2, gp_Pnt& aP1, gp_Pnt& aP2) const;
//! If the 3d curve is bounded curve the method will return TRUE
//! and modify the output parameters with boundary parameters of
//! the curve and corresponded 3d points.<br>
//! If the curve does not have bounds, the method will return false
//! and the output parameters will stay untouched.
Standard_EXPORT Standard_Boolean Bounds(Standard_Real& theFirst,
Standard_Real& theLast,
gp_Pnt& theFirstPnt,
gp_Pnt& theLastPnt) const;
//! Computes 3d point corresponded to parameter aT1
//! Returns true if given parameter aT1
//! is inside the boundaries of the curve
Standard_EXPORT Standard_Boolean D0 (Standard_Real& aT1, gp_Pnt& aP1) const;
//! Computes 3d point corresponded to the given parameter if this
//! parameter is inside the boundaries of the curve.
//! Returns TRUE in this case. <br>
//! Otherwise, the point will not be computed and the method will return FALSE.
Standard_EXPORT Standard_Boolean D0(const Standard_Real& thePar,
gp_Pnt& thePnt) const;
//! Returns the type of 3d curve
//! Returns the type of the 3d curve
Standard_EXPORT GeomAbs_CurveType Type() const;
protected:
private:
Handle(Geom_Curve) my3dCurve;
Handle(Geom2d_Curve) my2dCurve1;
Handle(Geom2d_Curve) my2dCurve2;
Standard_Real myTolerance;
Standard_Real myTangentialTolerance;
};
#include <IntTools_Curve.lxx>
#endif // _IntTools_Curve_HeaderFile

View File

@@ -1,66 +0,0 @@
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
//=======================================================================
//function : SetCurve
//purpose :
//=======================================================================
inline void IntTools_Curve::SetCurve(const Handle(Geom_Curve)& Curve3d)
{
my3dCurve = Curve3d;
}
//=======================================================================
//function : SetFirstCurve2d
//purpose :
//=======================================================================
inline void IntTools_Curve::SetFirstCurve2d(const Handle(Geom2d_Curve)& FirstCurve2d)
{
my2dCurve1 = FirstCurve2d;
}
//=======================================================================
//function : SetSecondCurve2d
//purpose :
//=======================================================================
inline void IntTools_Curve::SetSecondCurve2d(const Handle(Geom2d_Curve)& SecondCurve2d)
{
my2dCurve2 = SecondCurve2d;
}
//=======================================================================
//function : Curve
//purpose :
//=======================================================================
inline const Handle(Geom_Curve)& IntTools_Curve::Curve() const
{
return my3dCurve;
}
//=======================================================================
//function : FirstCurve2d
//purpose :
//=======================================================================
inline const Handle(Geom2d_Curve)& IntTools_Curve::FirstCurve2d() const
{
return my2dCurve1;
}
//=======================================================================
//function : SecondCurve2d
//purpose :
//=======================================================================
inline const Handle(Geom2d_Curve)& IntTools_Curve::SecondCurve2d() const
{
return my2dCurve2;
}

View File

@@ -55,11 +55,6 @@
#include <TopoDS_Edge.hxx>
#include <gp_Elips.hxx>
static
void TolR3d(const Standard_Real aTolF1,
const Standard_Real aTolF2,
Standard_Real& myTolReached3d);
static
void Parameters(const Handle(GeomAdaptor_HSurface)&,
const Handle(GeomAdaptor_HSurface)&,
@@ -95,17 +90,16 @@ static
Standard_Boolean ApproxWithPCurves(const gp_Cylinder& theCyl,
const gp_Sphere& theSph);
static void PerformPlanes(const Handle(GeomAdaptor_HSurface)& theS1,
const Handle(GeomAdaptor_HSurface)& theS2,
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_Real TolAng,
const Standard_Real TolTang,
const Standard_Boolean theApprox1,
const Standard_Boolean theApprox2,
IntTools_SequenceOfCurves& theSeqOfCurve,
Standard_Boolean& theTangentFaces,
Standard_Real& TolReached3d);
IntTools_SequenceOfCurves& theSeqOfCurve,
Standard_Boolean& theTangentFaces);
static Standard_Boolean ClassifyLin2d(const Handle(GeomAdaptor_HSurface)& theS,
const gp_Lin2d& theLin2d,
@@ -173,9 +167,6 @@ IntTools_FaceFace::IntTools_FaceFace()
//
myHS1 = new GeomAdaptor_HSurface ();
myHS2 = new GeomAdaptor_HSurface ();
myTolReached2d=0.;
myTolReached3d=0.;
myTolReal = 0.;
myTolF1 = 0.;
myTolF2 = 0.;
myTol = 0.;
@@ -239,22 +230,6 @@ Standard_Boolean IntTools_FaceFace::IsDone() const
return myIsDone;
}
//=======================================================================
//function : TolReached3d
//purpose :
//=======================================================================
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
//=======================================================================
@@ -265,14 +240,6 @@ const IntTools_SequenceOfCurves& IntTools_FaceFace::Lines() const
"IntTools_FaceFace::Lines() => myIntersector NOT DONE");
return mySeqOfCurve;
}
//=======================================================================
//function : TolReached2d
//purpose :
//=======================================================================
Standard_Real IntTools_FaceFace::TolReached2d() const
{
return myTolReached2d;
}
// =======================================================================
// function: SetParameters
//
@@ -398,9 +365,6 @@ void IntTools_FaceFace::Perform(const TopoDS_Face& aF1,
}
mySeqOfCurve.Clear();
myTolReached2d=0.;
myTolReached3d=0.;
myTolReal = 0.;
myIsDone = Standard_False;
myNbrestr=0;//?
@@ -472,38 +436,24 @@ void IntTools_FaceFace::Perform(const TopoDS_Face& aF1,
//
Standard_Real TolAng = 1.e-8;
//
PerformPlanes(myHS1, myHS2,
myTolF1, myTolF2, TolAng, TolTang,
myApprox1, myApprox2,
mySeqOfCurve, myTangentFaces, myTolReached3d);
PerformPlanes(myHS1, myHS2,
myTolF1, myTolF2, TolAng, TolTang,
myApprox1, myApprox2,
mySeqOfCurve, myTangentFaces);
//
myIsDone = Standard_True;
if(!myTangentFaces) {
//
if (!myTangentFaces) {
const Standard_Integer NbLinPP = mySeqOfCurve.Length();
if(NbLinPP) {
Standard_Real aTolFMax;
aTolFMax=Max(myTolF1, myTolF2);
myTolReal = Precision::Confusion();
if (aTolFMax > myTolReal) {
myTolReal = aTolFMax;
}
if (aTolFMax > myTolReached3d) {
myTolReached3d = aTolFMax;
}
//
myTolReached2d = myTolReal;
if (bReverse) {
Handle(Geom2d_Curve) aC2D1, aC2D2;
const Standard_Integer aNbLin = mySeqOfCurve.Length();
for (Standard_Integer i = 1; i <= aNbLin; ++i) {
IntTools_Curve& aIC=mySeqOfCurve(i);
aC2D1=aIC.FirstCurve2d();
aC2D2=aIC.SecondCurve2d();
aIC.SetFirstCurve2d(aC2D2);
aIC.SetSecondCurve2d(aC2D1);
}
if (NbLinPP && bReverse) {
Handle(Geom2d_Curve) aC2D1, aC2D2;
const Standard_Integer aNbLin = mySeqOfCurve.Length();
for (Standard_Integer i = 1; i <= aNbLin; ++i) {
IntTools_Curve& aIC = mySeqOfCurve(i);
aC2D1 = aIC.FirstCurve2d();
aC2D2 = aIC.SecondCurve2d();
aIC.SetFirstCurve2d(aC2D2);
aIC.SetSecondCurve2d(aC2D1);
}
}
}
@@ -712,121 +662,78 @@ void IntTools_FaceFace::Perform(const TopoDS_Face& aF1,
}
//=======================================================================
//function : ComputeTolerance
//function :ComputeTolReached3d
//purpose :
//=======================================================================
Standard_Real IntTools_FaceFace::ComputeTolerance()
void IntTools_FaceFace::ComputeTolReached3d()
{
Standard_Integer i, j, aNbLin;
Standard_Real aFirst, aLast, aD, aDMax, aT;
Handle(Geom_Surface) aS1, aS2;
Standard_Integer i, j, aNbLin = mySeqOfCurve.Length();
if (!aNbLin) {
return;
}
//
aDMax = 0;
aNbLin = mySeqOfCurve.Length();
// Minimal tangential tolerance for the curve
Standard_Real aTolFMax = Max(myTolF1, myTolF2);
//
aS1 = myHS1->ChangeSurface().Surface();
aS2 = myHS2->ChangeSurface().Surface();
const Handle(Geom_Surface)& aS1 = myHS1->ChangeSurface().Surface();
const Handle(Geom_Surface)& aS2 = myHS2->ChangeSurface().Surface();
//
for (i = 1; i <= aNbLin; ++i)
{
const IntTools_Curve& aIC = mySeqOfCurve(i);
IntTools_Curve& aIC = mySeqOfCurve(i);
const Handle(Geom_Curve)& aC3D = aIC.Curve();
if (aC3D.IsNull())
{
continue;
}
//
aFirst = aC3D->FirstParameter();
aLast = aC3D->LastParameter();
Standard_Real aTolC = aIC.Tolerance();
Standard_Real aFirst = aC3D->FirstParameter();
Standard_Real aLast = aC3D->LastParameter();
//
// Compute the tolerance for the curve
const Handle(Geom2d_Curve)& aC2D1 = aIC.FirstCurve2d();
const Handle(Geom2d_Curve)& aC2D2 = aIC.SecondCurve2d();
//
for (j = 0; j < 2; ++j)
{
const Handle(Geom2d_Curve)& aC2D = !j ? aC2D1 : aC2D2;
const Handle(Geom_Surface)& aS = !j ? aS1 : aS2;
//
if (!aC2D.IsNull())
{
// Look for the maximal deviation between 3D and 2D curves
Standard_Real aD, aT;
const Handle(Geom_Surface)& aS = !j ? aS1 : aS2;
if (IntTools_Tools::ComputeTolerance
(aC3D, aC2D, aS, aFirst, aLast, aD, aT))
{
if (aD > aDMax)
if (aD > aTolC)
{
aDMax = aD;
aTolC = aD;
}
}
}
else
{
// Look for the maximal deviation between 3D curve and surface
const TopoDS_Face& aF = !j ? myFace1 : myFace2;
aD = FindMaxDistance(aC3D, aFirst, aLast, aF, myContext);
if (aD > aDMax)
Standard_Real aD = FindMaxDistance(aC3D, aFirst, aLast, aF, myContext);
if (aD > aTolC)
{
aDMax = aD;
aTolC = aD;
}
}
}
}
//
return aDMax;
}
//=======================================================================
//function :ComputeTolReached3d
//purpose :
//=======================================================================
void IntTools_FaceFace::ComputeTolReached3d()
{
Standard_Integer aNbLin;
GeomAbs_SurfaceType aType1, aType2;
//
aNbLin=myIntersector.NbLines();
if (!aNbLin) {
return;
}
//
aType1=myHS1->Surface().GetType();
aType2=myHS2->Surface().GetType();
//
if (aType1==GeomAbs_Cylinder && aType2==GeomAbs_Cylinder)
{
if (aNbLin==2)
{
Handle(IntPatch_Line) aIL1, aIL2;
IntPatch_IType aTL1, aTL2;
//
aIL1=myIntersector.Line(1);
aIL2=myIntersector.Line(2);
aTL1=aIL1->ArcType();
aTL2=aIL2->ArcType();
if (aTL1==IntPatch_Lin && aTL2==IntPatch_Lin) {
Standard_Real aD, aDTresh, dTol;
gp_Lin aL1, aL2;
//
dTol=1.e-8;
aDTresh=1.5e-6;
//
aL1=Handle(IntPatch_GLine)::DownCast(aIL1)->Line();
aL2=Handle(IntPatch_GLine)::DownCast(aIL2)->Line();
aD=aL1.Distance(aL2);
aD=0.5*aD;
if (aD<aDTresh)
{//In order to avoid creation too thin face
myTolReached3d=aD+dTol;
}
}
// Set the valid tolerance for the curve
aIC.SetTolerance(aTolC);
//
// Set the tangential tolerance for the curve.
// Note, that, currently, computation of the tangential tolerance is
// implemented for the Plane/Plane case only.
// Thus, set the tangential tolerance equal to maximal tolerance of faces.
if (aIC.TangentialTolerance() < aTolFMax) {
aIC.SetTangentialTolerance(aTolFMax);
}
}// if (aType1==GeomAbs_Cylinder && aType2==GeomAbs_Cylinder) {
//
Standard_Real aDMax = ComputeTolerance();
if (aDMax > myTolReached3d)
{
myTolReached3d = aDMax;
}
myTolReal = myTolReached3d;
}
//=======================================================================
@@ -931,11 +838,6 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
new Geom_Hyperbola (Handle(IntPatch_GLine)::DownCast(L)->Hyperbola());
}
//
// myTolReached3d
if (typl == IntPatch_Lin) {
TolR3d (myTolF1, myTolF2, myTolReached3d);
}
//
aNbParts=myLConstruct.NbParts();
for (i=1; i<=aNbParts; i++) {
Standard_Boolean bFNIt, bLPIt;
@@ -952,7 +854,8 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
Handle(Geom_TrimmedCurve) aCT3D=new Geom_TrimmedCurve(newc, fprm, lprm);
aCurve.SetCurve(aCT3D);
if (typl == IntPatch_Parabola) {
myTolReached3d=IntTools_Tools::CurveTolerance(aCT3D, myTol);
Standard_Real aTolC = IntTools_Tools::CurveTolerance(aCT3D, myTol);
aCurve.SetTolerance(aTolC);
}
//
aCurve.SetCurve(new Geom_TrimmedCurve(newc, fprm, lprm));
@@ -960,33 +863,16 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
Handle (Geom2d_Curve) C2d;
GeomInt_IntSS::BuildPCurves(fprm, lprm, Tolpc,
myHS1->ChangeSurface().Surface(), newc, C2d);
if(Tolpc>myTolReached2d || myTolReached2d==0.) {
myTolReached2d=Tolpc;
}
//
aCurve.SetFirstCurve2d(new Geom2d_TrimmedCurve(C2d,fprm,lprm));
}
else {
Handle(Geom2d_BSplineCurve) H1;
//
aCurve.SetFirstCurve2d(H1);
}
aCurve.SetFirstCurve2d(new Geom2d_TrimmedCurve(C2d, fprm, lprm));
}
//
if(myApprox2) {
Handle (Geom2d_Curve) C2d;
GeomInt_IntSS::BuildPCurves(fprm, lprm, Tolpc,
myHS2->ChangeSurface().Surface(), newc, C2d);
if(Tolpc>myTolReached2d || myTolReached2d==0.) {
myTolReached2d=Tolpc;
}
//
aCurve.SetSecondCurve2d(new Geom2d_TrimmedCurve(C2d,fprm,lprm));
}
else {
Handle(Geom2d_BSplineCurve) H1;
//
aCurve.SetSecondCurve2d(H1);
aCurve.SetSecondCurve2d(new Geom2d_TrimmedCurve(C2d, fprm, lprm));
}
//
mySeqOfCurve.Append(aCurve);
} //if (!bFNIt && !bLPIt) {
else {
@@ -1053,9 +939,6 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
(Handle(IntPatch_GLine)::DownCast(L)->Ellipse());
}
//
// myTolReached3d
TolR3d (myTolF1, myTolF2, myTolReached3d);
//
aNbParts=myLConstruct.NbParts();
//
Standard_Real aPeriod, aNul;
@@ -1079,10 +962,8 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
else {
gp_Pnt P1 = newc->Value(fprm);
gp_Pnt P2 = newc->Value(aPeriod);
Standard_Real aTolDist = myTol;
aTolDist = (myTolReached3d > aTolDist) ? myTolReached3d : aTolDist;
if(P1.Distance(P2) > aTolDist) {
if(P1.Distance(P2) > myTol) {
Standard_Real anewpar = fprm;
if(ParameterOutOfBoundary(fprm, newc, myFace1, myFace2,
@@ -1102,10 +983,8 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
else {
gp_Pnt P1 = newc->Value(aNul);
gp_Pnt P2 = newc->Value(lprm);
Standard_Real aTolDist = myTol;
aTolDist = (myTolReached3d > aTolDist) ? myTolReached3d : aTolDist;
if(P1.Distance(P2) > aTolDist) {
if(P1.Distance(P2) > myTol) {
Standard_Real anewpar = lprm;
if(ParameterOutOfBoundary(lprm, newc, myFace1, myFace2,
@@ -1123,7 +1002,6 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
aSeqLprm.Append(lprm);
}
}
//
aNbParts=aSeqFprm.Length();
for (i=1; i<=aNbParts; i++) {
@@ -1145,39 +1023,17 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
Handle (Geom2d_Curve) C2d;
GeomInt_IntSS::BuildPCurves(fprm, lprm, Tolpc,
myHS1->ChangeSurface().Surface(), newc, C2d);
if(Tolpc>myTolReached2d || myTolReached2d==0) {
myTolReached2d=Tolpc;
}
//
aCurve.SetFirstCurve2d(C2d);
}
else { ////
Handle(Geom2d_BSplineCurve) H1;
aCurve.SetFirstCurve2d(H1);
}
if(myApprox2) {
Handle (Geom2d_Curve) C2d;
GeomInt_IntSS::BuildPCurves(fprm,lprm,Tolpc,
myHS2->ChangeSurface().Surface(),newc,C2d);
if(Tolpc>myTolReached2d || myTolReached2d==0) {
myTolReached2d=Tolpc;
}
//
aCurve.SetSecondCurve2d(C2d);
}
else {
Handle(Geom2d_BSplineCurve) H1;
aCurve.SetSecondCurve2d(H1);
}
}
else {
Handle(Geom2d_BSplineCurve) H1;
aCurve.SetFirstCurve2d(H1);
aCurve.SetSecondCurve2d(H1);
}
//
mySeqOfCurve.Append(aCurve);
//==============================================
} //if (Abs(fprm) > RealEpsilon() || Abs(lprm-2.*M_PI) > RealEpsilon())
@@ -1198,31 +1054,16 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
Handle (Geom2d_Curve) C2d;
GeomInt_IntSS::BuildPCurves(fprm,lprm,Tolpc,
myHS1->ChangeSurface().Surface(),newc,C2d);
if(Tolpc>myTolReached2d || myTolReached2d==0) {
myTolReached2d=Tolpc;
}
//
aCurve.SetFirstCurve2d(C2d);
}
else { ////
Handle(Geom2d_BSplineCurve) H1;
aCurve.SetFirstCurve2d(H1);
}
if(myApprox2) {
Handle (Geom2d_Curve) C2d;
GeomInt_IntSS::BuildPCurves(fprm,lprm,Tolpc,
myHS2->ChangeSurface().Surface(),newc,C2d);
if(Tolpc>myTolReached2d || myTolReached2d==0) {
myTolReached2d=Tolpc;
}
//
aCurve.SetSecondCurve2d(C2d);
}
else {
Handle(Geom2d_BSplineCurve) H1;
aCurve.SetSecondCurve2d(H1);
}
//
mySeqOfCurve.Append(aCurve);
break;
}
@@ -1251,40 +1092,16 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
Handle (Geom2d_Curve) C2d;
GeomInt_IntSS::BuildPCurves(fprm, lprm, Tolpc,
myHS1->ChangeSurface().Surface(), newc, C2d);
if(Tolpc>myTolReached2d || myTolReached2d==0) {
myTolReached2d=Tolpc;
}
//
aCurve.SetFirstCurve2d(C2d);
}
else {
Handle(Geom2d_BSplineCurve) H1;
aCurve.SetFirstCurve2d(H1);
}
if(myApprox2) {
Handle (Geom2d_Curve) C2d;
GeomInt_IntSS::BuildPCurves(fprm, lprm, Tolpc,
myHS2->ChangeSurface().Surface(), newc, C2d);
if(Tolpc>myTolReached2d || myTolReached2d==0) {
myTolReached2d=Tolpc;
}
//
aCurve.SetSecondCurve2d(C2d);
}
else {
Handle(Geom2d_BSplineCurve) H1;
aCurve.SetSecondCurve2d(H1);
}
}// end of if (typl == IntPatch_Circle || typl == IntPatch_Ellipse)
else {
Handle(Geom2d_BSplineCurve) H1;
//
aCurve.SetFirstCurve2d(H1);
aCurve.SetSecondCurve2d(H1);
}
//==============================================
//
mySeqOfCurve.Append(aCurve);
@@ -1410,14 +1227,13 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
aSeqOfL,
aReachedTol,
myContext);
if ( bIsDecomposited && ( myTolReached3d < aReachedTol ) ) {
myTolReached3d = aReachedTol;
}
//
aNbSeqOfL=aSeqOfL.Length();
//
Standard_Real aTolC = 0.;
if (bIsDecomposited) {
nbiter=aNbSeqOfL;
aTolC = aReachedTol;
}
else {
nbiter=1;
@@ -1495,27 +1311,22 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
IntTools_Curve aIC(aBSp, H1, H2);
mySeqOfCurve.Append(aIC);
}
else {
if(myApprox1 || myApprox2 || (typs1==GeomAbs_Plane || typs2==GeomAbs_Plane)) {
if( theapp3d.TolReached2d()>myTolReached2d || myTolReached2d==0.) {
myTolReached2d = theapp3d.TolReached2d();
if (typs1 == GeomAbs_Plane || typs2 == GeomAbs_Plane) {
if (aTolC < theapp3d.TolReached2d()) {
aTolC = theapp3d.TolReached2d();
}
}
if(typs1==GeomAbs_Plane || typs2==GeomAbs_Plane) {
myTolReached3d = myTolReached2d;
//
if (typs1==GeomAbs_Torus || typs2==GeomAbs_Torus) {
if (myTolReached3d<1.e-6) {
myTolReached3d = theapp3d.TolReached3d();
myTolReached3d=1.e-6;
if (typs1 == GeomAbs_Torus || typs2 == GeomAbs_Torus) {
if (aTolC < 1.e-6) {
aTolC = 1.e-6;
}
}
}
else if( theapp3d.TolReached3d()>myTolReached3d || myTolReached3d==0.) {
myTolReached3d = theapp3d.TolReached3d();
else if (aTolC < theapp3d.TolReached3d()) {
aTolC = theapp3d.TolReached3d();
}
//
Standard_Integer aNbMultiCurves, nbpoles;
aNbMultiCurves=theapp3d.NbMultiCurves();
for (j=1; j<=aNbMultiCurves; j++) {
@@ -1568,10 +1379,6 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
// ############################################
aCurve.SetFirstCurve2d(BS1);
}
else {
Handle(Geom2d_BSplineCurve) H1;
aCurve.SetFirstCurve2d(H1);
}
if(myApprox2) {
mbspc.Curve(2, tpoles2d);
@@ -1595,11 +1402,8 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
//
aCurve.SetSecondCurve2d(BS2);
}
else {
Handle(Geom2d_BSplineCurve) H2;
//
aCurve.SetSecondCurve2d(H2);
}
//
aCurve.SetTolerance(aTolC);
//
mySeqOfCurve.Append(aCurve);
@@ -1633,6 +1437,7 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
//
IntTools_Curve aCurve;
aCurve.SetCurve(BS);
aCurve.SetTolerance(aTolC);
if(myApprox2) {
Handle(Geom2d_BSplineCurve) BS1=new Geom2d_BSplineCurve(tpoles2d,
@@ -1654,11 +1459,7 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
bPCurvesOk = CheckPCurve(BS1, myFace2, myContext);
aCurve.SetSecondCurve2d(BS1);
}
else {
Handle(Geom2d_BSplineCurve) H2;
aCurve.SetSecondCurve2d(H2);
}
if(myApprox1) {
mbspc.Curve(1,tpoles2d);
Handle(Geom2d_BSplineCurve) BS2=new Geom2d_BSplineCurve(tpoles2d,
@@ -1680,11 +1481,6 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
bPCurvesOk = bPCurvesOk && CheckPCurve(BS2, myFace1, myContext);
aCurve.SetFirstCurve2d(BS2);
}
else {
Handle(Geom2d_BSplineCurve) H1;
//
aCurve.SetFirstCurve2d(H1);
}
//
//if points of the pcurves are out of the faces bounds
//create 3d and 2d curves without approximation
@@ -1707,7 +1503,7 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
//if pcurves created without approximation are out of the
//faces bounds, use approximated 3d and 2d curves
if (bPCurvesOk) {
IntTools_Curve aIC(aBSp, H1, H2);
IntTools_Curve aIC(aBSp, H1, H2, aTolC);
mySeqOfCurve.Append(aIC);
} else {
mySeqOfCurve.Append(aCurve);
@@ -1721,8 +1517,7 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
else { //typs2 != GeomAbs_Plane && typs1 != GeomAbs_Plane
Standard_Boolean bIsValid1, bIsValid2;
Handle(Geom_BSplineCurve) BS;
Handle(Geom2d_BSplineCurve) aH2D;
IntTools_Curve aCurve;
IntTools_Curve aCurve;
//
bIsValid1=Standard_True;
bIsValid2=Standard_True;
@@ -1737,10 +1532,9 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
mbspc.Degree());
GeomLib_CheckBSplineCurve Check(BS,TOLCHECK,TOLANGCHECK);
Check.FixTangent(Standard_True,Standard_True);
//
//
aCurve.SetCurve(BS);
aCurve.SetFirstCurve2d(aH2D);
aCurve.SetSecondCurve2d(aH2D);
aCurve.SetTolerance(aTolC);
//
if(myApprox1) {
if(anApprox1) {
@@ -1749,9 +1543,9 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
mbspc.Curve(2,tpoles2d);
//
BS1=new Geom2d_BSplineCurve(tpoles2d,
mbspc.Knots(),
mbspc.Multiplicities(),
mbspc.Degree());
mbspc.Knots(),
mbspc.Multiplicities(),
mbspc.Degree());
GeomLib_Check2dBSplineCurve newCheck(BS1,TOLCHECK,TOLANGCHECK);
newCheck.FixTangent(Standard_True,Standard_True);
//
@@ -2241,24 +2035,6 @@ Handle(Geom_Curve) MakeBSpline (const Handle(IntPatch_WLine)& WL,
}
}
//=======================================================================
//function : TolR3d
//purpose :
//=======================================================================
void TolR3d(const Standard_Real aTolF1,
const Standard_Real aTolF2,
Standard_Real& myTolReached3d)
{
Standard_Real aTolFMax, aTolTresh;
aTolTresh=2.999999e-3;
aTolFMax=Max(aTolF1, aTolF2);
if (aTolFMax>aTolTresh) {
myTolReached3d=aTolFMax;
}
}
// ------------------------------------------------------------------------------------------------
// static function: ParameterOutOfBoundary
// purpose: Computes a new parameter for given curve. The corresponding 2d points
@@ -2443,17 +2219,16 @@ Standard_Boolean ApproxWithPCurves(const gp_Cylinder& theCyl,
//function : PerformPlanes
//purpose :
//=======================================================================
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,
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_Real& TolReached3d)
IntTools_SequenceOfCurves& theSeqOfCurve,
Standard_Boolean& theTangentFaces)
{
gp_Pln aPln1 = theS1->Surface().Plane();
@@ -2534,10 +2309,13 @@ void PerformPlanes(const Handle(GeomAdaptor_HSurface)& theS1,
Handle(Geom2d_Curve) H1;
aCurve.SetFirstCurve2d(H1);
}
theSeqOfCurve.Append(aCurve);
//
// computation of the tolerance reached
// Valid tolerance for the intersection curve between planar faces
// is the maximal tolerance between tolerances of faces
Standard_Real aTolC = Max(TolF1, TolF2);
aCurve.SetTolerance(aTolC);
//
// Computation of the tangential tolerance
Standard_Real anAngle, aDt;
gp_Dir aD1, aD2;
//
@@ -2546,7 +2324,11 @@ void PerformPlanes(const Handle(GeomAdaptor_HSurface)& theS1,
anAngle = aD1.Angle(aD2);
//
aDt = IntTools_Tools::ComputeIntRange(TolF1, TolF2, anAngle);
TolReached3d = sqrt(aDt*aDt + TolF1*TolF1);
Standard_Real aTangTol = sqrt(aDt*aDt + TolF1*TolF1);
//
aCurve.SetTangentialTolerance(aTangTol);
//
theSeqOfCurve.Append(aCurve);
}
//=======================================================================

View File

@@ -70,21 +70,6 @@ public:
//! Returns sequence of 3d curves as result of intersection
Standard_EXPORT const IntTools_SequenceOfPntOn2Faces& Points() const;
//! 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.
Standard_EXPORT Standard_Real TolReached2d() const;
//! Returns first of processed faces
Standard_EXPORT const TopoDS_Face& Face1() const;
@@ -121,37 +106,28 @@ public:
//! Gets the intersecton context
Standard_EXPORT const Handle(IntTools_Context)& Context() const;
protected:
//! Creates curves from the IntPatch_Line.
Standard_EXPORT void MakeCurve (const Standard_Integer Index,
const Handle(Adaptor3d_TopolTool)& D1,
const Handle(Adaptor3d_TopolTool)& D2,
const Standard_Real theToler);
//! Computes the valid tolerance for the intersection curves
//! as a maximal deviation between 3D curve and 2D curves on faces.<br>
//! If there are no 2D curves the maximal deviation between 3D curves
//! and surfaces is computed.
Standard_EXPORT void ComputeTolReached3d();
Standard_EXPORT Standard_Real ComputeTolerance();
private:
Standard_Boolean myIsDone;
IntPatch_Intersection myIntersector;
GeomInt_LineConstructor myLConstruct;
Handle(GeomAdaptor_HSurface) myHS1;
Handle(GeomAdaptor_HSurface) myHS2;
Standard_Integer myNbrestr;
Standard_Real myTolReached2d;
Standard_Real myTolReached3d;
Standard_Real myTolReal;
Standard_Boolean myApprox;
Standard_Boolean myApprox1;
Standard_Boolean myApprox2;
@@ -168,13 +144,6 @@ private:
IntSurf_ListOfPntOn2S myListOfPnts;
Handle(IntTools_Context) myContext;
};
#endif // _IntTools_FaceFace_HeaderFile

View File

@@ -252,10 +252,9 @@ static
aC2D2F=new Geom2d_TrimmedCurve (aC2D2, aF, aMid);
aC2D2L=new Geom2d_TrimmedCurve (aC2D2, aMid, aL);
}
//
IntTools_Curve aIC1(aC3DNewF, aC2D1F, aC2D2F);
IntTools_Curve aIC2(aC3DNewL, aC2D1L, aC2D2L);
//
IntTools_Curve aIC1(aC3DNewF, aC2D1F, aC2D2F, IC.Tolerance(), IC.TangentialTolerance());
IntTools_Curve aIC2(aC3DNewL, aC2D1L, aC2D2L, IC.Tolerance(), IC.TangentialTolerance());
//
aCvs.Append(aIC1);
//
@@ -587,27 +586,32 @@ void ParabolaTolerance(const Handle(Geom_Curve)& aC3D,
//function : CheckCurve
//purpose :
//=======================================================================
Standard_Boolean IntTools_Tools::CheckCurve(const Handle (Geom_Curve)& aC3D,
const Standard_Real aTolR3D,
Bnd_Box& aBox)
Standard_Boolean IntTools_Tools::CheckCurve(const IntTools_Curve& theCurve,
Bnd_Box& theBox)
{
Standard_Boolean bRet;
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax, dX, dY, dZ;
Standard_Real dS, aTol;
GeomAdaptor_Curve aGAC;
const Handle(Geom_Curve)& aC3D = theCurve.Curve();
Standard_Boolean bValid = !aC3D.IsNull();
if (!bValid) {
return bValid;
}
//
aGAC.Load(aC3D);
BndLib_Add3dCurve::Add(aGAC, aTolR3D, aBox);
// 910/B1
aBox.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
dX=aXmax-aXmin;
dY=aYmax-aYmin;
dZ=aZmax-aZmin;
dS=1.e-12;
aTol=2.*aTolR3D+dS;
bRet=(dX>aTol || dY>aTol || dZ>aTol);
// Build bounding box for the curve
BndLib_Add3dCurve::Add(GeomAdaptor_Curve(aC3D),
Max(theCurve.Tolerance(), theCurve.TangentialTolerance()),
theBox);
//
return bRet;
// Estimate the bounding box of the curve comparing it with the
// minimal length for the curve from which the valid edge can be built -
// 3*Precision::Confusion():
// - 2 vertices with the Precision::Confusion() tolerance;
// - plus Precision::Confusion() as the minimal distance between vertices.
Standard_Real aTolCmp = 3*Precision::Confusion();
//
// Check the size of the box using the Bnd_Box::IsThin() method
// which does not use the gap of the box.
bValid = !theBox.IsThin(aTolCmp);
//
return bValid;
}
//=======================================================================
//function : IsOnPave

View File

@@ -142,8 +142,11 @@ public:
//! if aC is trimmed curve and basis curve is parabola,
//! otherwise returns value of aTolBase
Standard_EXPORT static Standard_Real CurveTolerance (const Handle(Geom_Curve)& aC, const Standard_Real aTolBase);
Standard_EXPORT static Standard_Boolean CheckCurve (const Handle(Geom_Curve)& theC, const Standard_Real theTol, Bnd_Box& theBox);
//! Checks if the curve is not covered by the default tolerance (confusion).<br>
//! Builds bounding box for the curve and stores it into <theBox>.
Standard_EXPORT static Standard_Boolean CheckCurve(const IntTools_Curve& theCurve,
Bnd_Box& theBox);
Standard_EXPORT static Standard_Boolean IsOnPave (const Standard_Real theT, const IntTools_Range& theRange, const Standard_Real theTol);