1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-09 18:50:54 +03:00

0032450: Modeling Algorithms - change BRepLib_CheckCurveOnSurface & GeomLib_CheckCurveOnSurface interfaces to adapters

This commit is contained in:
asuraven 2021-07-13 17:17:51 +03:00 committed by bugmaster
parent 8019a482b5
commit 9ae883970d
7 changed files with 164 additions and 213 deletions

View File

@ -2264,17 +2264,6 @@ Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(di, 1);
BRepAlgoApi_Cut(S1, S2, aProgress->Start()); // method Start() creates range for usage in cut algorithm BRepAlgoApi_Cut(S1, S2, aProgress->Start()); // method Start() creates range for usage in cut algorithm
~~~~ ~~~~
@subsection upgrade_occt760_old_bop_removed Removal of old Boolean operations algorithm (BRepAlgo_BooleanOperation)
* The method *BRepAlgo_Tool::Deboucle3D* has been removed as duplicating. The corresponding method from *BRepOffset_Tool* class has to be used instead.
* The API classes from *BRepAlgo* package performing old Boolean operations algorithm have been removed:
- *BRepAlgo_BooleanOperation*
- *BRepAlgo_Fuse*
- *BRepAlgo_Common*
- *BRepAlgo_Cut*
- *BRepAlgo_Section*
The corresponding classes from the *BRepAlgoAPI* package have to be used instead.
@subsection upgrade_occt760_change_check_to_adaptors Changes in BRepLib_CheckCurveOnSurface & GeomLib_CheckCurveOnSurface interfaces @subsection upgrade_occt760_change_check_to_adaptors Changes in BRepLib_CheckCurveOnSurface & GeomLib_CheckCurveOnSurface interfaces
Now the classes accept adaptors instead objects as input parameters. Now the classes accept adaptors instead objects as input parameters.
@ -2292,4 +2281,15 @@ void Init (const Handle(Adaptor3d_Curve)& theCurve, const Standard_Real theTolRa
void Perform(const Handle(Adaptor3d_CurveOnSurface)& theCurveOnSurface, void Perform(const Handle(Adaptor3d_CurveOnSurface)& theCurveOnSurface,
const Standard_Boolean isMultiThread); const Standard_Boolean isMultiThread);
~~~~ ~~~~
@subsection upgrade_occt760_old_bop_removed Removal of old Boolean operations algorithm (BRepAlgo_BooleanOperation)
* The method *BRepAlgo_Tool::Deboucle3D* has been removed as duplicating. The corresponding method from *BRepOffset_Tool* class has to be used instead.
* The API classes from *BRepAlgo* package performing old Boolean operations algorithm have been removed:
- *BRepAlgo_BooleanOperation*
- *BRepAlgo_Fuse*
- *BRepAlgo_Common*
- *BRepAlgo_Cut*
- *BRepAlgo_Section*
The corresponding classes from the *BRepAlgoAPI* package have to be used instead.

View File

@ -12,8 +12,12 @@
// Alternatively, this file may be used under the terms of Open CASCADE // Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement. // commercial license or contractual agreement.
#include <Adaptor3d_CurveOnSurface.hxx>
#include <BRep_Tool.hxx> #include <BRep_Tool.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepLib_CheckCurveOnSurface.hxx> #include <BRepLib_CheckCurveOnSurface.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <Geom2dAdaptor_Curve.hxx>
#include <Geom_Surface.hxx> #include <Geom_Surface.hxx>
#include <Standard_ErrorHandler.hxx> #include <Standard_ErrorHandler.hxx>
#include <TopoDS.hxx> #include <TopoDS.hxx>
@ -36,9 +40,7 @@ BRepLib_CheckCurveOnSurface::BRepLib_CheckCurveOnSurface
//function : Init //function : Init
//purpose : //purpose :
//======================================================================= //=======================================================================
void BRepLib_CheckCurveOnSurface::Init void BRepLib_CheckCurveOnSurface::Init(const TopoDS_Edge& theEdge, const TopoDS_Face& theFace)
(const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace)
{ {
myCOnSurfGeom.Init(); myCOnSurfGeom.Init();
@ -53,26 +55,34 @@ void BRepLib_CheckCurveOnSurface::Init
return; return;
} }
//
TopLoc_Location aLocE, aLocF, aLocC2D;
Standard_Real aFirst = 0.0, aLast = 0.0;
//
// 3D curve initialization // 3D curve initialization
const Handle(Geom_Curve)& aC3dTmp = BRep_Tool::Curve(theEdge, aLocE, aFirst, aLast); const Handle(Adaptor3d_Curve) anAdaptor3dCurve = new BRepAdaptor_Curve(theEdge);
const Handle(Geom_Curve) aC3d(Handle(Geom_Curve)::DownCast(aC3dTmp->Transformed(aLocE.Transformation())));
// Surface initialization // Surface initialization
const Handle(Geom_Surface)& aSTmp = BRep_Tool::Surface(theFace, aLocF);
const Handle(Geom_Surface) aS(Handle(Geom_Surface)::DownCast(aSTmp->Transformed(aLocF.Transformation()))); TopLoc_Location aLocation;
// Standard_Real aFirstParam, aLastParam;
Handle(Geom2d_Curve) aGeom2dCurve = BRep_Tool::CurveOnSurface(theEdge, theFace, aFirstParam, aLastParam);
Handle(Geom_Surface) aGeomSurface = BRep_Tool::Surface(theFace);
// 2D curves initialization // 2D curves initialization
myPCurve = BRep_Tool::CurveOnSurface(theEdge, theFace, aFirst, aLast); Handle(Adaptor2d_Curve2d) anAdaptorCurve =
new Geom2dAdaptor_Curve(aGeom2dCurve, aFirstParam, aLastParam);
Handle(GeomAdaptor_Surface) aGeomAdaptorSurface = new GeomAdaptor_Surface(aGeomSurface);
myAdaptorCurveOnSurface = new Adaptor3d_CurveOnSurface(anAdaptorCurve, aGeomAdaptorSurface);
if(BRep_Tool::IsClosed(theEdge, theFace)) if(BRep_Tool::IsClosed(theEdge, theFace))
myPCurve2 = BRep_Tool::CurveOnSurface(TopoDS::Edge(theEdge.Reversed()), {
theFace, aFirst, aLast); Handle(Geom2d_Curve) aGeom2dReversedCurve =
BRep_Tool::CurveOnSurface(TopoDS::Edge(theEdge.Reversed()), theFace, aFirstParam, aLastParam);
Handle(Adaptor2d_Curve2d) anAdaptorReversedCurve =
new Geom2dAdaptor_Curve(aGeom2dReversedCurve, aFirstParam, aLastParam);
myAdaptorCurveOnSurface2 = new Adaptor3d_CurveOnSurface(anAdaptorReversedCurve, aGeomAdaptorSurface);
}
myCOnSurfGeom.Init(aC3d, aS, aFirst, aLast); myCOnSurfGeom.Init(anAdaptor3dCurve);
} }
//======================================================================= //=======================================================================
@ -82,17 +92,17 @@ void BRepLib_CheckCurveOnSurface::Init
void BRepLib_CheckCurveOnSurface::Perform(const Standard_Boolean isMultiThread) void BRepLib_CheckCurveOnSurface::Perform(const Standard_Boolean isMultiThread)
{ {
// Compute the max distance // Compute the max distance
Compute(myPCurve, isMultiThread); Compute(myAdaptorCurveOnSurface, isMultiThread);
if (ErrorStatus()) if (ErrorStatus())
{ {
return; return;
} }
// //
if (!myPCurve2.IsNull()) if (!myAdaptorCurveOnSurface2.IsNull())
{ {
// compute max distance for myPCurve2 // compute max distance for myAdaptorCurveOnSurface2
// (for the second curve on closed surface) // (for the second curve on closed surface)
Compute(myPCurve2, isMultiThread); Compute(myAdaptorCurveOnSurface2, isMultiThread);
} }
} }
@ -100,8 +110,8 @@ void BRepLib_CheckCurveOnSurface::Perform(const Standard_Boolean isMultiThread)
//function : Compute //function : Compute
//purpose : if isTheMTDisabled == TRUE parallelization is not used //purpose : if isTheMTDisabled == TRUE parallelization is not used
//======================================================================= //=======================================================================
void BRepLib_CheckCurveOnSurface::Compute(const Handle(Geom2d_Curve)& thePCurve, void BRepLib_CheckCurveOnSurface::Compute(const Handle(Adaptor3d_CurveOnSurface)& theCurveOnSurface,
const Standard_Boolean isMultiThread) const Standard_Boolean isMultiThread)
{ {
myCOnSurfGeom.Perform(thePCurve, isMultiThread); myCOnSurfGeom.Perform(theCurveOnSurface, isMultiThread);
} }

View File

@ -38,38 +38,7 @@ public:
//! Performs the calculation //! Performs the calculation
//! If isMultiThread == Standard_True then computation will be performed in parallel. //! If isMultiThread == Standard_True then computation will be performed in parallel.
Standard_EXPORT void Perform(const Standard_Boolean isMultiThread = Standard_True); Standard_EXPORT void Perform(const Standard_Boolean isMultiThread = Standard_False);
//! Returns source 3D-Curve
const Handle(Geom_Curve)& Curve() const
{
return myCOnSurfGeom.Curve();
}
//! Returns mine 2D-Curve
const Handle(Geom2d_Curve)& PCurve() const
{
return myPCurve;
}
//! Returns 2nd 2D-Curve (if it exists, e.g. for seam-edge)
const Handle(Geom2d_Curve)& PCurve2() const
{
return myPCurve2;
}
//! Returns source surface
const Handle(Geom_Surface)& Surface() const
{
return myCOnSurfGeom.Surface();
}
//! Returns first and last parameter of the curves
//! (2D- and 3D-curves are considered to have same range)
void Range (Standard_Real& theFirst, Standard_Real& theLast)
{
myCOnSurfGeom.Range(theFirst, theLast);
}
//! Returns true if the max distance has been found //! Returns true if the max distance has been found
Standard_Boolean IsDone() const Standard_Boolean IsDone() const
@ -103,16 +72,16 @@ public:
protected: protected:
//! Computes the max distance for the 3d curve of <myCOnSurfGeom> //! Computes the max distance for the 3d curve of <myCOnSurfGeom>
//! and 2d curve <thePCurve> //! and 2d curve <theCurveOnSurface>
//! If isMultiThread == Standard_True then computation will be performed in parallel. //! If isMultiThread == Standard_True then computation will be performed in parallel.
Standard_EXPORT void Compute (const Handle(Geom2d_Curve)& thePCurve, Standard_EXPORT void Compute (const Handle(Adaptor3d_CurveOnSurface)& theCurveOnSurface,
const Standard_Boolean isMultiThread); const Standard_Boolean isMultiThread);
private: private:
GeomLib_CheckCurveOnSurface myCOnSurfGeom; GeomLib_CheckCurveOnSurface myCOnSurfGeom;
Handle(Geom2d_Curve) myPCurve; Handle(Adaptor3d_CurveOnSurface) myAdaptorCurveOnSurface;
Handle(Geom2d_Curve) myPCurve2; Handle(Adaptor3d_CurveOnSurface) myAdaptorCurveOnSurface2;
}; };
#endif // _BRepLib_CheckCurveOnSurface_HeaderFile #endif // _BRepLib_CheckCurveOnSurface_HeaderFile

View File

@ -15,6 +15,7 @@
// commercial license or contractual agreement. // commercial license or contractual agreement.
#include <Adaptor3d_CurveOnSurface.hxx>
#include <Bnd_Box2d.hxx> #include <Bnd_Box2d.hxx>
#include <BndLib_Add2dCurve.hxx> #include <BndLib_Add2dCurve.hxx>
#include <BRep_Builder.hxx> #include <BRep_Builder.hxx>
@ -30,6 +31,7 @@
#include <ElCLib.hxx> #include <ElCLib.hxx>
#include <Geom2d_Curve.hxx> #include <Geom2d_Curve.hxx>
#include <Geom2dAdaptor_Curve.hxx> #include <Geom2dAdaptor_Curve.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <Geom_BSplineSurface.hxx> #include <Geom_BSplineSurface.hxx>
#include <Geom_Curve.hxx> #include <Geom_Curve.hxx>
#include <Geom_RectangularTrimmedSurface.hxx> #include <Geom_RectangularTrimmedSurface.hxx>
@ -1333,9 +1335,16 @@ Standard_Real BRepTools::EvalAndUpdateTol(const TopoDS_Edge& theE,
first = Max(first, C2d->FirstParameter()); first = Max(first, C2d->FirstParameter());
last = Min(last, C2d->LastParameter()); last = Min(last, C2d->LastParameter());
} }
const Handle(Adaptor3d_Curve) aGeomAdaptorCurve = new GeomAdaptor_Curve(C3d, first, last);
GeomLib_CheckCurveOnSurface CT(C3d, S, first, last); Handle(Adaptor2d_Curve2d) aGeom2dAdaptorCurve = new Geom2dAdaptor_Curve(C2d, first, last);
CT.Perform(C2d); Handle(GeomAdaptor_Surface) aGeomAdaptorSurface = new GeomAdaptor_Surface(S);
Handle(Adaptor3d_CurveOnSurface) anAdaptor3dCurveOnSurface =
new Adaptor3d_CurveOnSurface(aGeom2dAdaptorCurve, aGeomAdaptorSurface);
GeomLib_CheckCurveOnSurface CT(aGeomAdaptorCurve);
CT.Perform(anAdaptor3dCurveOnSurface);
if(CT.IsDone()) if(CT.IsDone())
{ {
newtol = CT.MaxDistance(); newtol = CT.MaxDistance();

View File

@ -36,6 +36,8 @@
#include <TColStd_Array1OfReal.hxx> #include <TColStd_Array1OfReal.hxx>
#include <TColStd_HArray1OfReal.hxx> #include <TColStd_HArray1OfReal.hxx>
typedef NCollection_Array1<Handle(Adaptor3d_Curve)> Array1OfHCurve;
class GeomLib_CheckCurveOnSurface_TargetFunc; class GeomLib_CheckCurveOnSurface_TargetFunc;
static static
@ -46,11 +48,11 @@ Standard_Boolean MinComputing(
Standard_Real& theBestValue, Standard_Real& theBestValue,
Standard_Real& theBestParameter); Standard_Real& theBestParameter);
static Standard_Integer FillSubIntervals( const Handle(Geom_Curve)& theCurve3d, static Standard_Integer FillSubIntervals( const Handle(Adaptor3d_Curve)& theCurve3d,
const Handle(Geom2d_Curve)& theCurve2d, const Handle(Adaptor2d_Curve2d)& theCurve2d,
const Standard_Real theFirst, const Standard_Real theFirst,
const Standard_Real theLast, const Standard_Real theLast,
Standard_Integer &theNbParticles, Standard_Integer& theNbParticles,
TColStd_Array1OfReal* const theSubIntervals = 0); TColStd_Array1OfReal* const theSubIntervals = 0);
//======================================================================= //=======================================================================
@ -62,11 +64,11 @@ class GeomLib_CheckCurveOnSurface_TargetFunc :
{ {
public: public:
GeomLib_CheckCurveOnSurface_TargetFunc( const Adaptor3d_Curve& theC3D, GeomLib_CheckCurveOnSurface_TargetFunc( const Adaptor3d_Curve& theC3D,
const Adaptor3d_Curve& theAdCS, const Adaptor3d_Curve& theCurveOnSurface,
const Standard_Real theFirst, const Standard_Real theFirst,
const Standard_Real theLast): const Standard_Real theLast):
myCurve1(theC3D), myCurve1(theC3D),
myCurve2(theAdCS), myCurve2(theCurveOnSurface),
myFirst(theFirst), myFirst(theFirst),
myLast(theLast) myLast(theLast)
{ {
@ -214,7 +216,7 @@ class GeomLib_CheckCurveOnSurface_TargetFunc :
} }
private: private:
GeomLib_CheckCurveOnSurface_TargetFunc operator=(GeomLib_CheckCurveOnSurface_TargetFunc&); GeomLib_CheckCurveOnSurface_TargetFunc operator=(GeomLib_CheckCurveOnSurface_TargetFunc&) Standard_DELETE;
//checks if the function can be computed when its parameter is //checks if the function can be computed when its parameter is
//equal to theParam //equal to theParam
@ -237,50 +239,43 @@ class GeomLib_CheckCurveOnSurface_Local
{ {
public: public:
GeomLib_CheckCurveOnSurface_Local( GeomLib_CheckCurveOnSurface_Local(
const Handle(Geom_Curve)& theCurve3D, const Array1OfHCurve& theCurveArray,
const Handle(Geom2d_Curve)& theCurve2D, const Array1OfHCurve& theCurveOnSurfaceArray,
const Handle(Geom_Surface)& theSurface, const TColStd_Array1OfReal& theIntervalsArr,
const TColStd_Array1OfReal& theIntervalsArr, const Standard_Real theEpsilonRange,
const Standard_Real theEpsilonRange, const Standard_Integer theNbParticles):
const Standard_Integer theNbParticles): myCurveArray(theCurveArray),
myCurve3D(theCurve3D), myCurveOnSurfaceArray(theCurveOnSurfaceArray),
myCurve2D(theCurve2D), mySubIntervals(theIntervalsArr),
mySurface(theSurface), myEpsilonRange(theEpsilonRange),
mySubIntervals(theIntervalsArr), myNbParticles(theNbParticles),
myEpsilonRange(theEpsilonRange), myArrOfDist(theIntervalsArr.Lower(), theIntervalsArr.Upper() - 1),
myNbParticles(theNbParticles), myArrOfParam(theIntervalsArr.Lower(), theIntervalsArr.Upper() - 1)
myArrOfDist(theIntervalsArr.Lower(), theIntervalsArr.Upper()-1),
myArrOfParam(theIntervalsArr.Lower(), theIntervalsArr.Upper()-1)
{ {
} }
void operator()(const Standard_Integer& theIndex) const void operator()(Standard_Integer theThreadIndex, Standard_Integer theElemIndex) const
{ {
//For every sub-interval (which is set by mySubIntervals array) this method //For every sub-interval (which is set by mySubIntervals array) this method
//computes optimal value of GeomLib_CheckCurveOnSurface_TargetFunc function. //computes optimal value of GeomLib_CheckCurveOnSurface_TargetFunc function.
//This optimal value will be put in corresponding (depending on theIndex - the //This optimal value will be put in corresponding (depending on theIndex - the
//identificator of the current interval in mySubIntervals array) cell of //identificator of the current interval in mySubIntervals array) cell of
//myArrOfDist and myArrOfParam arrays. //myArrOfDist and myArrOfParam arrays.
const GeomAdaptor_Curve anAC(myCurve3D); GeomLib_CheckCurveOnSurface_TargetFunc aFunc(*(myCurveArray.Value(theThreadIndex).get()),
const Handle(Adaptor2d_Curve2d) anAd2dC = new Geom2dAdaptor_Curve(myCurve2D); *(myCurveOnSurfaceArray.Value(theThreadIndex).get()),
const Handle(Adaptor3d_Surface) anAdS = new GeomAdaptor_Surface(mySurface); mySubIntervals.Value(theElemIndex),
mySubIntervals.Value(theElemIndex + 1));
const Adaptor3d_CurveOnSurface anACS(anAd2dC, anAdS);
GeomLib_CheckCurveOnSurface_TargetFunc aFunc( anAC, anACS,
mySubIntervals.Value(theIndex),
mySubIntervals.Value(theIndex+1));
Standard_Real aMinDist = RealLast(), aPar = 0.0; Standard_Real aMinDist = RealLast(), aPar = 0.0;
if(!MinComputing(aFunc, myEpsilonRange, myNbParticles, aMinDist, aPar)) if (!MinComputing(aFunc, myEpsilonRange, myNbParticles, aMinDist, aPar))
{ {
myArrOfDist(theIndex) = RealLast(); myArrOfDist(theElemIndex) = RealLast();
myArrOfParam(theIndex) = aFunc.FirstParameter(); myArrOfParam(theElemIndex) = aFunc.FirstParameter();
return; return;
} }
myArrOfDist(theIndex) = aMinDist; myArrOfDist(theElemIndex) = aMinDist;
myArrOfParam(theIndex) = aPar; myArrOfParam(theElemIndex) = aPar;
} }
//Returns optimal value (inverse of square of maximal distance) //Returns optimal value (inverse of square of maximal distance)
@ -302,10 +297,11 @@ public:
} }
private: private:
GeomLib_CheckCurveOnSurface_Local operator=(GeomLib_CheckCurveOnSurface_Local&); GeomLib_CheckCurveOnSurface_Local operator=(const GeomLib_CheckCurveOnSurface_Local&) Standard_DELETE;
const Handle(Geom_Curve)& myCurve3D;
const Handle(Geom2d_Curve)& myCurve2D; private:
const Handle(Geom_Surface)& mySurface; const Array1OfHCurve& myCurveArray;
const Array1OfHCurve& myCurveOnSurfaceArray;
const TColStd_Array1OfReal& mySubIntervals; const TColStd_Array1OfReal& mySubIntervals;
const Standard_Real myEpsilonRange; const Standard_Real myEpsilonRange;
@ -320,8 +316,6 @@ private:
//======================================================================= //=======================================================================
GeomLib_CheckCurveOnSurface::GeomLib_CheckCurveOnSurface() GeomLib_CheckCurveOnSurface::GeomLib_CheckCurveOnSurface()
: :
myFirst(0.),
myLast(0.),
myErrorStatus(0), myErrorStatus(0),
myMaxDistance(RealLast()), myMaxDistance(RealLast()),
myMaxParameter(0.), myMaxParameter(0.),
@ -334,15 +328,9 @@ GeomLib_CheckCurveOnSurface::GeomLib_CheckCurveOnSurface()
//purpose : //purpose :
//======================================================================= //=======================================================================
GeomLib_CheckCurveOnSurface:: GeomLib_CheckCurveOnSurface::
GeomLib_CheckCurveOnSurface(const Handle(Geom_Curve)& theCurve, GeomLib_CheckCurveOnSurface(const Handle(Adaptor3d_Curve)& theCurve,
const Handle(Geom_Surface)& theSurface,
const Standard_Real theFirst,
const Standard_Real theLast,
const Standard_Real theTolRange): const Standard_Real theTolRange):
myCurve(theCurve), myCurve(theCurve),
mySurface(theSurface),
myFirst(theFirst),
myLast(theLast),
myErrorStatus(0), myErrorStatus(0),
myMaxDistance(RealLast()), myMaxDistance(RealLast()),
myMaxParameter(0.), myMaxParameter(0.),
@ -357,9 +345,6 @@ GeomLib_CheckCurveOnSurface::
void GeomLib_CheckCurveOnSurface::Init() void GeomLib_CheckCurveOnSurface::Init()
{ {
myCurve.Nullify(); myCurve.Nullify();
mySurface.Nullify();
myFirst = 0.0;
myLast = 0.0;
myErrorStatus = 0; myErrorStatus = 0;
myMaxDistance = RealLast(); myMaxDistance = RealLast();
myMaxParameter = 0.0; myMaxParameter = 0.0;
@ -370,16 +355,10 @@ void GeomLib_CheckCurveOnSurface::Init()
//function : Init //function : Init
//purpose : //purpose :
//======================================================================= //=======================================================================
void GeomLib_CheckCurveOnSurface::Init( const Handle(Geom_Curve)& theCurve, void GeomLib_CheckCurveOnSurface::Init( const Handle(Adaptor3d_Curve)& theCurve,
const Handle(Geom_Surface)& theSurface,
const Standard_Real theFirst,
const Standard_Real theLast,
const Standard_Real theTolRange) const Standard_Real theTolRange)
{ {
myCurve = theCurve; myCurve = theCurve;
mySurface = theSurface;
myFirst = theFirst;
myLast = theLast;
myErrorStatus = 0; myErrorStatus = 0;
myMaxDistance = RealLast(); myMaxDistance = RealLast();
myMaxParameter = 0.0; myMaxParameter = 0.0;
@ -390,21 +369,18 @@ void GeomLib_CheckCurveOnSurface::Init( const Handle(Geom_Curve)& theCurve,
//function : Perform //function : Perform
//purpose : //purpose :
//======================================================================= //=======================================================================
void GeomLib_CheckCurveOnSurface::Perform(const Handle(Geom2d_Curve)& thePCurve, void GeomLib_CheckCurveOnSurface::Perform(const Handle(Adaptor3d_CurveOnSurface)& theCurveOnSurface,
const Standard_Boolean isMultiThread) const Standard_Boolean isMultiThread)
{ {
if( myCurve.IsNull() || if( myCurve.IsNull() ||
mySurface.IsNull() || theCurveOnSurface.IsNull())
thePCurve.IsNull())
{ {
myErrorStatus = 1; myErrorStatus = 1;
return; return;
} }
if(((myCurve->FirstParameter() - myFirst) > myTolRange) || if ((myCurve->FirstParameter() - theCurveOnSurface->FirstParameter() > myTolRange) ||
((myCurve->LastParameter() - myLast) < -myTolRange) || (myCurve->LastParameter() - theCurveOnSurface->LastParameter() < -myTolRange))
((thePCurve->FirstParameter() - myFirst) > myTolRange) ||
((thePCurve->LastParameter() - myLast) < -myTolRange))
{ {
myErrorStatus = 2; myErrorStatus = 2;
return; return;
@ -421,9 +397,9 @@ void GeomLib_CheckCurveOnSurface::Perform(const Handle(Geom2d_Curve)& thePCurve,
//at least one particle in every monotonicity interval. Therefore, //at least one particle in every monotonicity interval. Therefore,
//number of particles should be equal to n. //number of particles should be equal to n.
const Standard_Integer aNbSubIntervals = const Standard_Integer aNbSubIntervals =
FillSubIntervals( myCurve, thePCurve, FillSubIntervals(myCurve, theCurveOnSurface->GetCurve(),
myFirst, myLast, aNbParticles); myCurve->FirstParameter(), myCurve->LastParameter(), aNbParticles);
if(!aNbSubIntervals) if(!aNbSubIntervals)
{ {
@ -431,22 +407,45 @@ void GeomLib_CheckCurveOnSurface::Perform(const Handle(Geom2d_Curve)& thePCurve,
return; return;
} }
try { try
{
OCC_CATCH_SIGNALS OCC_CATCH_SIGNALS
TColStd_Array1OfReal anIntervals(1, aNbSubIntervals+1); TColStd_Array1OfReal anIntervals(1, aNbSubIntervals + 1);
FillSubIntervals(myCurve, thePCurve, myFirst, myLast, aNbParticles, &anIntervals); FillSubIntervals(myCurve, theCurveOnSurface->GetCurve(),
myCurve->FirstParameter(), myCurve->LastParameter(), aNbParticles, &anIntervals);
GeomLib_CheckCurveOnSurface_Local aComp(myCurve, thePCurve,
mySurface, anIntervals, anEpsilonRange, aNbParticles);
OSD_Parallel::For(anIntervals.Lower(), anIntervals.Upper(), aComp, !isMultiThread);
const Standard_Integer aNbThreads = isMultiThread ? Min(anIntervals.Size(), OSD_ThreadPool::DefaultPool()->NbDefaultThreadsToLaunch()) : 1;
Array1OfHCurve aCurveArray(0, aNbThreads - 1);
Array1OfHCurve aCurveOnSurfaceArray(0, aNbThreads - 1);
for (Standard_Integer anI = 0; anI < aNbThreads; ++anI)
{
aCurveArray.SetValue(anI, aNbThreads > 1 ? myCurve->ShallowCopy() : myCurve);
aCurveOnSurfaceArray.SetValue(anI, aNbThreads > 1
? theCurveOnSurface->ShallowCopy()
: static_cast<const Handle(Adaptor3d_Curve)&> (theCurveOnSurface));
}
GeomLib_CheckCurveOnSurface_Local aComp(aCurveArray, aCurveOnSurfaceArray, anIntervals,
anEpsilonRange, aNbParticles);
if (aNbThreads > 1)
{
const Handle(OSD_ThreadPool)& aThreadPool = OSD_ThreadPool::DefaultPool();
OSD_ThreadPool::Launcher aLauncher(*aThreadPool, aNbThreads);
aLauncher.Perform(anIntervals.Lower(), anIntervals.Upper(), aComp);
}
else
{
for (Standard_Integer anI = anIntervals.Lower(); anI < anIntervals.Upper(); ++anI)
{
aComp(0, anI);
}
}
aComp.OptimalValues(myMaxDistance, myMaxParameter); aComp.OptimalValues(myMaxDistance, myMaxParameter);
myMaxDistance = sqrt(Abs(myMaxDistance)); myMaxDistance = sqrt(Abs(myMaxDistance));
} }
catch (Standard_Failure const&) { catch (Standard_Failure const&)
{
myErrorStatus = 3; myErrorStatus = 3;
} }
} }
@ -458,11 +457,11 @@ void GeomLib_CheckCurveOnSurface::Perform(const Handle(Geom2d_Curve)& thePCurve,
// (fills theSubIntervals array). // (fills theSubIntervals array).
// Returns number of subintervals. // Returns number of subintervals.
//======================================================================= //=======================================================================
Standard_Integer FillSubIntervals(const Handle(Geom_Curve)& theCurve3d, Standard_Integer FillSubIntervals(const Handle(Adaptor3d_Curve)& theCurve3d,
const Handle(Geom2d_Curve)& theCurve2d, const Handle(Adaptor2d_Curve2d)& theCurve2d,
const Standard_Real theFirst, const Standard_Real theFirst,
const Standard_Real theLast, const Standard_Real theLast,
Standard_Integer &theNbParticles, Standard_Integer& theNbParticles,
TColStd_Array1OfReal* const theSubIntervals) TColStd_Array1OfReal* const theSubIntervals)
{ {
const Standard_Integer aMaxKnots = 101; const Standard_Integer aMaxKnots = 101;
@ -475,33 +474,18 @@ Standard_Integer FillSubIntervals(const Handle(Geom_Curve)& theCurve3d,
Standard_Boolean isTrimmed3D = Standard_False, isTrimmed2D = Standard_False; Standard_Boolean isTrimmed3D = Standard_False, isTrimmed2D = Standard_False;
// //
if (theCurve3d->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) if (theCurve3d->GetType() == GeomAbs_BSplineCurve)
{ {
aBS3DCurv = Handle(Geom_BSplineCurve):: aBS3DCurv = theCurve3d->BSpline();
DownCast(Handle(Geom_TrimmedCurve)::
DownCast(theCurve3d)->BasisCurve());
isTrimmed3D = Standard_True;
} }
else if (theCurve2d->GetType() == GeomAbs_BSplineCurve)
{ {
aBS3DCurv = Handle(Geom_BSplineCurve)::DownCast(theCurve3d); aBS2DCurv = theCurve2d->BSpline();
} }
if (theCurve2d->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve))) Handle(TColStd_HArray1OfReal) anArrKnots3D, anArrKnots2D;
{
aBS2DCurv = Handle(Geom2d_BSplineCurve)::
DownCast(Handle(Geom2d_TrimmedCurve)::
DownCast(theCurve2d)->BasisCurve());
isTrimmed2D = Standard_True;
}
else
{
aBS2DCurv = Handle(Geom2d_BSplineCurve)::DownCast(theCurve2d);
}
Handle(TColStd_HArray1OfReal) anArrKnots3D, anArrKnots2D; if (!aBS3DCurv.IsNull())
if(!aBS3DCurv.IsNull())
{ {
if(aBS3DCurv->NbKnots() <= aMaxKnots) if(aBS3DCurv->NbKnots() <= aMaxKnots)
{ {

View File

@ -15,12 +15,11 @@
#ifndef _GeomLib_CheckCurveOnSurface_HeaderFile #ifndef _GeomLib_CheckCurveOnSurface_HeaderFile
#define _GeomLib_CheckCurveOnSurface_HeaderFile #define _GeomLib_CheckCurveOnSurface_HeaderFile
#include <Geom_Curve.hxx> #include <Adaptor3d_Curve.hxx>
#include <Precision.hxx> #include <Precision.hxx>
#include <Standard.hxx> #include <Standard.hxx>
class Geom_Surface; class Adaptor3d_CurveOnSurface;
class Geom2d_Curve;
//! Computes the max distance between 3D-curve and 2D-curve //! Computes the max distance between 3D-curve and 2D-curve
//! in some surface. //! in some surface.
@ -35,48 +34,22 @@ public:
//! Constructor //! Constructor
Standard_EXPORT Standard_EXPORT
GeomLib_CheckCurveOnSurface(const Handle(Geom_Curve)& theCurve, GeomLib_CheckCurveOnSurface(const Handle(Adaptor3d_Curve)& theCurve,
const Handle(Geom_Surface)& theSurface,
const Standard_Real theFirst,
const Standard_Real theLast,
const Standard_Real theTolRange = const Standard_Real theTolRange =
Precision::PConfusion()); Precision::PConfusion());
//! Sets the data for the algorithm //! Sets the data for the algorithm
Standard_EXPORT void Init (const Handle(Geom_Curve)& theCurve, Standard_EXPORT void Init (const Handle(Adaptor3d_Curve)& theCurve,
const Handle(Geom_Surface)& theSurface,
const Standard_Real theFirst,
const Standard_Real theLast,
const Standard_Real theTolRange = Precision::PConfusion()); const Standard_Real theTolRange = Precision::PConfusion());
//! Initializes all members by default values //! Initializes all members by default values
Standard_EXPORT void Init(); Standard_EXPORT void Init();
//! Computes the max distance for the 3d curve <myCurve> //! Computes the max distance for the 3d curve <myCurve>
//! and 2d curve <thePCurve> //! and 2d curve <theCurveOnSurface>
//! If isMultiThread == Standard_True then computation will be performed in parallel. //! If isMultiThread == Standard_True then computation will be performed in parallel.
Standard_EXPORT void Perform(const Handle(Geom2d_Curve)& thePCurve, Standard_EXPORT void Perform(const Handle(Adaptor3d_CurveOnSurface)& theCurveOnSurface,
const Standard_Boolean isMultiThread = Standard_True); const Standard_Boolean isMultiThread = Standard_False);
//! Returns my3DCurve
const Handle(Geom_Curve)& Curve() const
{
return myCurve;
}
//! Returns mySurface
const Handle(Geom_Surface)& Surface() const
{
return mySurface;
}
//! Returns first and last parameter of the curves
//! (2D- and 3D-curves are considered to have same range)
void Range (Standard_Real& theFirst, Standard_Real& theLast)
{
theFirst = myFirst;
theLast = myLast;
}
//! Returns true if the max distance has been found //! Returns true if the max distance has been found
Standard_Boolean IsDone() const Standard_Boolean IsDone() const
@ -109,10 +82,7 @@ public:
private: private:
Handle(Geom_Curve) myCurve; Handle(Adaptor3d_Curve) myCurve;
Handle(Geom_Surface) mySurface;
Standard_Real myFirst;
Standard_Real myLast;
Standard_Integer myErrorStatus; Standard_Integer myErrorStatus;
Standard_Real myMaxDistance; Standard_Real myMaxDistance;
Standard_Real myMaxParameter; Standard_Real myMaxParameter;

View File

@ -21,6 +21,7 @@
#include <BRepAdaptor_Surface.hxx> #include <BRepAdaptor_Surface.hxx>
#include <Geom2d_Curve.hxx> #include <Geom2d_Curve.hxx>
#include <Geom2d_TrimmedCurve.hxx> #include <Geom2d_TrimmedCurve.hxx>
#include <Geom2dAdaptor_Curve.hxx>
#include <Geom_BoundedCurve.hxx> #include <Geom_BoundedCurve.hxx>
#include <Geom_Curve.hxx> #include <Geom_Curve.hxx>
#include <Geom_Geometry.hxx> #include <Geom_Geometry.hxx>
@ -797,8 +798,16 @@ Standard_Boolean IntTools_Tools::ComputeTolerance
{ {
GeomLib_CheckCurveOnSurface aCS; GeomLib_CheckCurveOnSurface aCS;
// //
aCS.Init(theCurve3D, theSurf, theFirst, theLast, theTolRange); const Handle(Adaptor3d_Curve) aGeomAdaptorCurve = new GeomAdaptor_Curve(theCurve3D, theFirst, theLast);
aCS.Perform (theCurve2D, theToRunParallel);
Handle(Adaptor2d_Curve2d) aGeom2dAdaptorCurve = new Geom2dAdaptor_Curve(theCurve2D, theFirst, theLast);
Handle(GeomAdaptor_Surface) aGeomAdaptorSurface = new GeomAdaptor_Surface(theSurf);
Handle(Adaptor3d_CurveOnSurface) anAdaptor3dCurveOnSurface =
new Adaptor3d_CurveOnSurface(aGeom2dAdaptorCurve, aGeomAdaptorSurface);
aCS.Init(aGeomAdaptorCurve, theTolRange);
aCS.Perform(anAdaptor3dCurveOnSurface, theToRunParallel);
if (!aCS.IsDone()) { if (!aCS.IsDone()) {
return Standard_False; return Standard_False;
} }