1 // Created on: 2001-02-26
2 // Created by: Peter KURNEV
3 // Copyright (c) 2001-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
17 #include <Bnd_Box.hxx>
18 #include <BndLib_AddSurface.hxx>
19 #include <BRep_Tool.hxx>
20 #include <BRepAdaptor_Surface.hxx>
21 #include <Extrema_ExtCS.hxx>
22 #include <Extrema_POnCurv.hxx>
23 #include <Extrema_POnSurf.hxx>
24 #include <Geom_Curve.hxx>
25 #include <Geom_Surface.hxx>
26 #include <GeomAdaptor_Curve.hxx>
27 #include <GeomAdaptor_HCurve.hxx>
28 #include <GeomAdaptor_HSurface.hxx>
29 #include <GeomAdaptor_Surface.hxx>
30 #include <GeomAPI_ProjectPointOnSurf.hxx>
32 #include <gp_Circ.hxx>
33 #include <gp_Cone.hxx>
34 #include <gp_Cylinder.hxx>
38 #include <gp_Torus.hxx>
39 #include <IntCurveSurface_HInter.hxx>
40 #include <IntCurveSurface_IntersectionPoint.hxx>
41 #include <IntTools.hxx>
42 #include <IntTools_BeanFaceIntersector.hxx>
43 #include <IntTools_CArray1OfInteger.hxx>
44 #include <IntTools_CommonPrt.hxx>
45 #include <IntTools_Context.hxx>
46 #include <IntTools_EdgeFace.hxx>
47 #include <IntTools_FClass2d.hxx>
48 #include <IntTools_Range.hxx>
49 #include <IntTools_Root.hxx>
50 #include <IntTools_Tools.hxx>
51 #include <Precision.hxx>
52 #include <TopoDS_Edge.hxx>
53 #include <TopoDS_Face.hxx>
57 Standard_Boolean IsCoplanar (const BRepAdaptor_Curve& ,
58 const BRepAdaptor_Surface& );
60 Standard_Boolean IsRadius (const BRepAdaptor_Curve& aCurve ,
61 const BRepAdaptor_Surface& aSurface,
62 const Standard_Real aCriteria);
64 //=======================================================================
65 //function : IntTools_EdgeFace::IntTools_EdgeFace
67 //=======================================================================
68 IntTools_EdgeFace::IntTools_EdgeFace()
70 myFuzzyValue = Precision::Confusion();
74 myIsDone=Standard_False;
76 myQuickCoincidenceCheck=Standard_False;
78 //=======================================================================
79 //function : SetContext
81 //=======================================================================
82 void IntTools_EdgeFace::SetContext(const Handle(IntTools_Context)& theContext)
84 myContext = theContext;
87 //=======================================================================
90 //=======================================================================
91 const Handle(IntTools_Context)& IntTools_EdgeFace::Context()const
95 //=======================================================================
98 //=======================================================================
99 void IntTools_EdgeFace::SetEdge(const TopoDS_Edge& anEdge)
103 //=======================================================================
106 //=======================================================================
107 void IntTools_EdgeFace::SetFace(const TopoDS_Face& aFace)
111 //=======================================================================
114 //=======================================================================
115 const TopoDS_Edge& IntTools_EdgeFace::Edge()const
119 //=======================================================================
122 //=======================================================================
123 const TopoDS_Face& IntTools_EdgeFace::Face()const
127 //=======================================================================
128 //function : SetFuzzyValue
130 //=======================================================================
131 void IntTools_EdgeFace::SetFuzzyValue(const Standard_Real theFuzz)
133 myFuzzyValue = Max(theFuzz, Precision::Confusion());
135 //=======================================================================
136 //function : SetDiscretize
138 //=======================================================================
139 void IntTools_EdgeFace::SetDiscretize(const Standard_Integer aDiscret)
143 //=======================================================================
144 //function : SetDeflection
146 //=======================================================================
147 void IntTools_EdgeFace::SetDeflection(const Standard_Real aDefl)
151 //=======================================================================
152 //function : SetEpsilonT
154 //=======================================================================
155 void IntTools_EdgeFace::SetEpsilonT(const Standard_Real anEpsT)
159 //=======================================================================
160 //function : SetRange
162 //=======================================================================
163 void IntTools_EdgeFace::SetRange(const Standard_Real aFirst,
164 const Standard_Real aLast)
166 myRange.SetFirst (aFirst);
167 myRange.SetLast (aLast);
170 //=======================================================================
171 //function : SetRange
173 //=======================================================================
174 void IntTools_EdgeFace::SetRange(const IntTools_Range& aRange)
176 SetRange(aRange.First(), aRange.Last());
178 //=======================================================================
181 //=======================================================================
182 Standard_Boolean IntTools_EdgeFace::IsDone()const
186 //=======================================================================
187 //function : ErrorStatus
189 //=======================================================================
190 Standard_Integer IntTools_EdgeFace::ErrorStatus()const
192 return myErrorStatus;
194 //=======================================================================
195 //function : CommonParts
197 //=======================================================================
198 const IntTools_SequenceOfCommonPrts& IntTools_EdgeFace::CommonParts() const
200 return mySeqOfCommonPrts;
202 //=======================================================================
205 //=======================================================================
206 const IntTools_Range& IntTools_EdgeFace::Range() const
210 //=======================================================================
211 //function : IsCoincident
213 //=======================================================================
214 Standard_Boolean IntTools_EdgeFace::IsCoincident()
216 Standard_Integer i, iCnt;
217 Standard_Real dT, aT, aD, aT1, aT2, aU, aV;
223 GeomAPI_ProjectPointOnSurf& aProjector=myContext->ProjPS(myFace);
225 Standard_Integer aNbSeg=23;
226 if (myC.GetType() == GeomAbs_Line &&
227 myS.GetType() == GeomAbs_Plane)
228 aNbSeg = 2; // Check only three points for Line/Plane intersection
230 const Standard_Real aTresh=0.5;
231 const Standard_Integer aTreshIdxF = RealToInt((aNbSeg+1)*0.25),
232 aTreshIdxL = RealToInt((aNbSeg+1)*0.75);
233 const Handle(Geom_Surface) aSurf = BRep_Tool::Surface(myFace);
239 Standard_Boolean isClassified = Standard_False;
241 for(i=0; i <= aNbSeg; ++i) {
245 aProjector.Perform(aP);
246 if (!aProjector.IsDone()) {
251 aD=aProjector.LowerDistance();
259 //We classify only three points: in the begin, in the
260 //end and in the middle of the edge.
261 //However, exact middle point (when i == (aNbSeg + 1)/2)
262 //can be unprojectable. Therefore, it will not be able to
263 //be classified. Therefore, points with indexes in
264 //[aTreshIdxF, aTreshIdxL] range are made available
265 //for classification.
266 //isClassified == TRUE if MIDDLE point has been choosen and
267 //classified correctly.
269 if(((0 < i) && (i < aTreshIdxF)) || ((aTreshIdxL < i ) && (i < aNbSeg)))
272 if(isClassified && (i != aNbSeg))
275 aProjector.LowerDistanceParameters(aU, aV);
279 IntTools_FClass2d& aClass2d=myContext->FClass2d(myFace);
280 aState = aClass2d.Perform(aP2d);
282 if(aState == TopAbs_OUT)
283 return Standard_False;
286 isClassified = Standard_True;
289 const Standard_Real aCoeff=(Standard_Real)iCnt/((Standard_Real)aNbSeg+1);
290 return (aCoeff > aTresh);
292 //=======================================================================
293 //function : CheckData
295 //=======================================================================
296 void IntTools_EdgeFace::CheckData()
298 if (BRep_Tool::Degenerated(myEdge)) {
301 if (!BRep_Tool::IsGeometric(myEdge)) {
306 //=======================================================================
307 //function : IsProjectable
309 //=======================================================================
310 Standard_Boolean IntTools_EdgeFace::IsProjectable
311 (const Standard_Real aT) const
313 Standard_Boolean bFlag;
317 bFlag=myContext->IsValidPointForFace(aPC, myFace, myCriteria);
321 //=======================================================================
322 //function : DistanceFunction
324 //=======================================================================
325 Standard_Real IntTools_EdgeFace::DistanceFunction
326 (const Standard_Real t)
334 Standard_Boolean bIsEqDistance;
336 bIsEqDistance= IntTools_EdgeFace::IsEqDistance(P, myS, 1.e-7, aD);
343 Standard_Boolean bFlag = Standard_False;
345 GeomAPI_ProjectPointOnSurf& aLocProj = myContext->ProjPS(myFace);
347 bFlag = aLocProj.IsDone();
350 aD = aLocProj.LowerDistance();
360 // aD=aProjector.LowerDistance();
366 //=======================================================================
367 //function : IsEqDistance
369 //=======================================================================
370 Standard_Boolean IntTools_EdgeFace::IsEqDistance
372 const BRepAdaptor_Surface& aBAS,
373 const Standard_Real aTol,
376 Standard_Boolean bRetFlag=Standard_True;
378 GeomAbs_SurfaceType aSurfType=aBAS.GetType();
380 if (aSurfType==GeomAbs_Cylinder) {
381 gp_Cylinder aCyl=aBAS.Cylinder();
382 const gp_Ax1& anAx1 =aCyl.Axis();
383 gp_Lin aLinAxis(anAx1);
384 Standard_Real aDC, aRadius=aCyl.Radius();
385 aDC=aLinAxis.Distance(aP);
392 if (aSurfType==GeomAbs_Cone) {
393 gp_Cone aCone=aBAS.Cone();
394 const gp_Ax1& anAx1 =aCone.Axis();
395 gp_Lin aLinAxis(anAx1);
396 Standard_Real aDC, aRadius, aDS, aSemiAngle;
397 aDC=aLinAxis.Distance(aP);
399 gp_Pnt anApex=aCone.Apex();
400 aSemiAngle=aCone.SemiAngle();
401 aDS=aP.Distance(anApex);
403 aRadius=aDS*tan(aSemiAngle);
409 if (aSurfType==GeomAbs_Torus) {
410 Standard_Real aMajorRadius, aMinorRadius, aDC;
412 gp_Torus aTorus=aBAS.Torus();
413 gp_Pnt aPLoc=aTorus.Location();
414 aMajorRadius=aTorus.MajorRadius();
416 aDC=fabs(aPLoc.Distance(aP)-aMajorRadius);
418 aMinorRadius=aTorus.MinorRadius();
426 //=======================================================================
427 //function : MakeType
429 //=======================================================================
430 Standard_Integer IntTools_EdgeFace::MakeType
431 (IntTools_CommonPrt& aCommonPrt)
433 Standard_Real af1, al1;
434 Standard_Real df1, tm;
435 Standard_Boolean bAllNullFlag;
437 bAllNullFlag=aCommonPrt.AllNullFlag();
439 aCommonPrt.SetType(TopAbs_EDGE);
443 aCommonPrt.Range1(af1, al1);
449 df1=aPF.Distance(aPL);
450 Standard_Boolean isWholeRange = Standard_False;
452 if((Abs(af1 - myRange.First()) < myC.Resolution(myCriteria)) &&
453 (Abs(al1 - myRange.Last()) < myC.Resolution(myCriteria)))
454 isWholeRange = Standard_True;
457 if ((df1 > myCriteria * 2.) && isWholeRange) {
458 aCommonPrt.SetType(TopAbs_EDGE);
462 tm = (af1 + al1) * 0.5;
464 if(aPF.Distance(myC.Value(tm)) > myCriteria * 2.) {
465 aCommonPrt.SetType(TopAbs_EDGE);
470 if(!CheckTouch(aCommonPrt, tm)) {
471 tm = (af1 + al1) * 0.5;
473 aCommonPrt.SetType(TopAbs_VERTEX);
474 aCommonPrt.SetVertexParameter1(tm);
475 aCommonPrt.SetRange1 (af1, al1);
482 //=======================================================================
483 //function : CheckTouch
485 //=======================================================================
486 Standard_Boolean IntTools_EdgeFace::CheckTouch
487 (const IntTools_CommonPrt& aCP,
490 if (myC.GetType() == GeomAbs_Line &&
491 myS.GetType() == GeomAbs_Plane) {
492 return Standard_False;
495 Standard_Real aTF, aTL, Tol, U1f, U1l, V1f, V1l, af, al,aDist2, aMinDist2;
496 Standard_Boolean theflag=Standard_False;
497 Standard_Integer aNbExt, iLower;
499 aCP.Range1(aTF, aTL);
503 aCR=myC.Resolution(myCriteria);
504 if((Abs(aTF - myRange.First()) < aCR) &&
505 (Abs(aTL - myRange.Last()) < aCR)) {
506 return theflag; // EDGE
510 Tol = Precision::PConfusion();
512 const Handle(Geom_Curve)& Curve =BRep_Tool::Curve (myC.Edge(), af, al);
513 const Handle(Geom_Surface)& Surface=BRep_Tool::Surface(myS.Face());
514 // Surface->Bounds(U1f,U1l,V1f,V1l);
515 U1f = myS.FirstUParameter();
516 U1l = myS.LastUParameter();
517 V1f = myS.FirstVParameter();
518 V1l = myS.LastVParameter();
520 GeomAdaptor_Curve TheCurve (Curve,aTF, aTL);
521 GeomAdaptor_Surface TheSurface (Surface, U1f, U1l, V1f, V1l);
523 Extrema_ExtCS anExtrema (TheCurve, TheSurface, Tol, Tol);
527 if(anExtrema.IsDone()) {
530 if(!anExtrema.IsParallel()) {
531 aNbExt=anExtrema.NbExt();
535 for (Standard_Integer i=1; i<=aNbExt; i++) {
536 aDist2=anExtrema.SquareDistance(i);
537 if (aDist2 < aMinDist2) {
542 aDist2=anExtrema.SquareDistance(iLower);
543 Extrema_POnCurv aPOnC;
544 Extrema_POnSurf aPOnS;
545 anExtrema.Points(iLower, aPOnC, aPOnS);
546 aTx=aPOnC.Parameter();
549 // modified by NIZHNY-MKK Thu Jul 21 11:35:32 2005.BEGIN
550 IntCurveSurface_HInter anExactIntersector;
552 Handle(GeomAdaptor_HCurve) aCurve = new GeomAdaptor_HCurve(TheCurve);
553 Handle(GeomAdaptor_HSurface) aSurface = new GeomAdaptor_HSurface(TheSurface);
555 anExactIntersector.Perform(aCurve, aSurface);
557 if(anExactIntersector.IsDone()) {
558 for(Standard_Integer i = 1; i <= anExactIntersector.NbPoints(); i++) {
559 const IntCurveSurface_IntersectionPoint& aPoint = anExactIntersector.Point(i);
561 if((aPoint.W() >= aTF) && (aPoint.W() <= aTL)) {
567 // modified by NIZHNY-MKK Thu Jul 21 11:35:40 2005.END
575 Standard_Real aBoundaryDist;
577 aBoundaryDist = DistanceFunction(aTF) + myCriteria;
578 if(aBoundaryDist * aBoundaryDist < aDist2) {
579 aDist2 = aBoundaryDist * aBoundaryDist;
583 aBoundaryDist = DistanceFunction(aTL) + myCriteria;
584 if(aBoundaryDist * aBoundaryDist < aDist2) {
585 aDist2 = aBoundaryDist * aBoundaryDist;
589 Standard_Real aParameter = (aTF + aTL) * 0.5;
590 aBoundaryDist = DistanceFunction(aParameter) + myCriteria;
591 if(aBoundaryDist * aBoundaryDist < aDist2) {
592 aDist2 = aBoundaryDist * aBoundaryDist;
596 if(aDist2 > myCriteria * myCriteria) {
600 if (fabs (aTx-aTF) < myEpsT) {
604 if (fabs (aTx-aTL) < myEpsT) {
608 if (aTx>aTF && aTx<aTL) {
615 //=======================================================================
618 //=======================================================================
619 void IntTools_EdgeFace::Perform()
621 Standard_Integer i, aNb;
622 IntTools_CommonPrt aCommonPrt;
624 aCommonPrt.SetEdge1(myEdge);
632 if (myContext.IsNull()) {
633 myContext=new IntTools_Context;
636 myIsDone = Standard_False;
637 myC.Initialize(myEdge);
638 GeomAbs_CurveType aCurveType;
639 aCurveType=myC.GetType();
641 // Prepare myCriteria
642 Standard_Real aFuzz = myFuzzyValue / 2.;
643 Standard_Real aTolF = BRep_Tool::Tolerance(myFace) + aFuzz;
644 Standard_Real aTolE = BRep_Tool::Tolerance(myEdge) + aFuzz;
645 if (aCurveType == GeomAbs_BSplineCurve ||
646 aCurveType==GeomAbs_BezierCurve) {
648 Standard_Real diff1 = (aTolE/aTolF);
649 Standard_Real diff2 = (aTolF/aTolE);
650 if( diff1 > 100 || diff2 > 100 ) {
651 myCriteria = Max(aTolE,aTolF);
654 myCriteria = 1.5*aTolE + aTolF;
657 myCriteria = aTolE + aTolF;
660 myS = myContext->SurfaceAdaptor(myFace);
662 if (myQuickCoincidenceCheck) {
663 if (IsCoincident()) {
664 aCommonPrt.SetType(TopAbs_EDGE);
665 aCommonPrt.SetRange1(myRange.First(), myRange.Last());
666 mySeqOfCommonPrts.Append(aCommonPrt);
667 myIsDone=Standard_True;
672 IntTools_BeanFaceIntersector anIntersector(myC, myS, aTolE, aTolF);
673 anIntersector.SetBeanParameters(myRange.First(), myRange.Last());
675 anIntersector.SetContext(myContext);
677 anIntersector.Perform();
679 if(!anIntersector.IsDone()) {
683 for(Standard_Integer r = 1; r <= anIntersector.Result().Length(); r++) {
684 const IntTools_Range& aRange = anIntersector.Result().Value(r);
686 if(IsProjectable(IntTools_Tools::IntermediatePoint(aRange.First(), aRange.Last()))) {
687 aCommonPrt.SetRange1(aRange.First(), aRange.Last());
688 mySeqOfCommonPrts.Append(aCommonPrt);
692 aNb = mySeqOfCommonPrts.Length();
694 for (i=1; i<=aNb; i++) {
695 IntTools_CommonPrt& aCP=mySeqOfCommonPrts.ChangeValue(i);
697 Standard_Real aTx1, aTx2;
700 aCP.Range1(aTx1, aTx2);
703 aCP.SetBoundingPoints(aPx1, aPx2);
708 // Line\Cylinder's Common Parts treatement
709 GeomAbs_CurveType aCType;
710 GeomAbs_SurfaceType aSType;
711 TopAbs_ShapeEnum aType;
712 Standard_Boolean bIsTouch;
715 aCType=myC.GetType();
716 aSType=myS.GetType();
718 if (aCType==GeomAbs_Line && aSType==GeomAbs_Cylinder) {
719 for (i=1; i<=aNb; i++) {
720 IntTools_CommonPrt& aCP=mySeqOfCommonPrts(i);
722 if (aType==TopAbs_EDGE) {
723 bIsTouch=CheckTouch (aCP, aTx);
725 aCP.SetType(TopAbs_VERTEX);
726 aCP.SetVertexParameter1(aTx);
727 //aCP.SetRange1 (aTx, aTx);
730 else if (aType==TopAbs_VERTEX) {
731 bIsTouch=CheckTouchVertex (aCP, aTx);
733 aCP.SetVertexParameter1(aTx);
734 //aCP.SetRange1 (aTx, aTx);
740 // Circle\Plane's Common Parts treatement
742 if (aCType==GeomAbs_Circle && aSType==GeomAbs_Plane) {
743 Standard_Boolean bIsCoplanar, bIsRadius;
744 bIsCoplanar=IsCoplanar(myC, myS);
745 bIsRadius=IsRadius(myC, myS, myCriteria);
746 if (!bIsCoplanar && !bIsRadius) {
747 for (i=1; i<=aNb; i++) {
748 IntTools_CommonPrt& aCP=mySeqOfCommonPrts(i);
750 if (aType==TopAbs_EDGE) {
751 bIsTouch=CheckTouch (aCP, aTx);
753 aCP.SetType(TopAbs_VERTEX);
754 aCP.SetVertexParameter1(aTx);
755 //aCP.SetRange1 (aTx, aTx);
758 else if (aType==TopAbs_VERTEX) {
759 bIsTouch=CheckTouchVertex (aCP, aTx);
761 aCP.SetVertexParameter1(aTx);
762 //aCP.SetRange1 (aTx, aTx);
769 myIsDone=Standard_True;
774 // 1 - the method Perform() is not invoked
775 // 2,3,4,5 -the method CheckData() fails
776 // 6 - PrepareArgs() problems
777 // 7 - No Projectable ranges
778 // 8,9 - PrepareArgs() problems occured inside projectable Ranges
779 // 11 - can't fill array aFunc(i) in PrepareArgsFuncArrays
782 //=======================================================================
783 //function : CheckTouch
785 //=======================================================================
786 Standard_Boolean IntTools_EdgeFace::CheckTouchVertex
787 (const IntTools_CommonPrt& aCP,
790 Standard_Real aTF, aTL, Tol, U1f,U1l,V1f,V1l;
791 Standard_Real aEpsT, af, al,aDist2, aMinDist2, aTm, aDist2New;
792 Standard_Boolean theflag=Standard_False;
793 Standard_Integer aNbExt, i, iLower ;
794 GeomAbs_CurveType aType;
796 aCP.Range1(aTF, aTL);
800 if (aType==GeomAbs_Line) {
805 aDist2=DistanceFunction(aTm);
808 Tol = Precision::PConfusion();
810 const Handle(Geom_Curve)& Curve =BRep_Tool::Curve (myC.Edge(), af, al);
811 const Handle(Geom_Surface)& Surface=BRep_Tool::Surface(myS.Face());
813 Surface->Bounds(U1f,U1l,V1f,V1l);
815 GeomAdaptor_Curve TheCurve (Curve,aTF, aTL);
816 GeomAdaptor_Surface TheSurface (Surface, U1f, U1l, V1f, V1l);
818 Extrema_ExtCS anExtrema (TheCurve, TheSurface, Tol, Tol);
820 if(!anExtrema.IsDone()) {
823 if (anExtrema.IsParallel()) {
827 aNbExt=anExtrema.NbExt() ;
834 for (i=1; i<=aNbExt; ++i) {
835 aDist2=anExtrema.SquareDistance(i);
836 if (aDist2 < aMinDist2) {
842 aDist2New=anExtrema.SquareDistance(iLower);
844 if (aDist2New > aDist2) {
849 if (aDist2New > myCriteria * myCriteria) {
853 Extrema_POnCurv aPOnC;
854 Extrema_POnSurf aPOnS;
855 anExtrema.Points(iLower, aPOnC, aPOnS);
858 aTx=aPOnC.Parameter();
860 if (fabs (aTx-aTF) < aEpsT) {
864 if (fabs (aTx-aTL) < aEpsT) {
868 if (aTx>aTF && aTx<aTL) {
876 //=======================================================================
877 //function : IsCoplanar
879 //=======================================================================
880 Standard_Boolean IsCoplanar (const BRepAdaptor_Curve& aCurve ,
881 const BRepAdaptor_Surface& aSurface)
883 Standard_Boolean bFlag=Standard_False;
885 GeomAbs_CurveType aCType;
886 GeomAbs_SurfaceType aSType;
888 aCType=aCurve.GetType();
889 aSType=aSurface.GetType();
891 if (aCType==GeomAbs_Circle && aSType==GeomAbs_Plane) {
892 gp_Circ aCirc=aCurve.Circle();
893 const gp_Ax1& anAx1=aCirc.Axis();
894 const gp_Dir& aDirAx1=anAx1.Direction();
896 gp_Pln aPln=aSurface.Plane();
897 const gp_Ax1& anAx=aPln.Axis();
898 const gp_Dir& aDirPln=anAx.Direction();
900 bFlag=IntTools_Tools::IsDirsCoinside(aDirAx1, aDirPln);
904 //=======================================================================
905 //function : IsRadius
907 //=======================================================================
908 Standard_Boolean IsRadius (const BRepAdaptor_Curve& aCurve,
909 const BRepAdaptor_Surface& aSurface,
910 const Standard_Real aCriteria)
912 Standard_Boolean bFlag=Standard_False;
914 GeomAbs_CurveType aCType;
915 GeomAbs_SurfaceType aSType;
917 aCType=aCurve.GetType();
918 aSType=aSurface.GetType();
920 if (aCType==GeomAbs_Circle && aSType==GeomAbs_Plane) {
921 gp_Circ aCirc=aCurve.Circle();
922 const gp_Pnt aCenter=aCirc.Location();
923 Standard_Real aR=aCirc.Radius();
924 gp_Pln aPln=aSurface.Plane();
925 Standard_Real aD=aPln.Distance(aCenter);
926 if (fabs (aD-aR) < aCriteria) {
933 //=======================================================================
934 //function : AdaptiveDiscret
936 //=======================================================================
937 Standard_Integer AdaptiveDiscret (const Standard_Integer iDiscret,
938 const BRepAdaptor_Curve& aCurve ,
939 const BRepAdaptor_Surface& aSurface)
941 Standard_Integer iDiscretNew;
943 iDiscretNew=iDiscret;
945 GeomAbs_SurfaceType aSType;
947 aSType=aSurface.GetType();
949 if (aSType==GeomAbs_Cylinder) {
950 Standard_Real aELength, aRadius, dLR;
952 aELength=IntTools::Length(aCurve.Edge());
954 gp_Cylinder aCylinder=aSurface.Cylinder();
955 aRadius=aCylinder.Radius();
958 iDiscretNew=(Standard_Integer)(aELength/dLR);
960 if (iDiscretNew<iDiscret) {
961 iDiscretNew=iDiscret;