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 const Standard_Integer aNbSeg=23;
226 const Standard_Real aTresh=0.5;
227 const Standard_Integer aTreshIdxF = RealToInt((aNbSeg+1)*0.25),
228 aTreshIdxL = RealToInt((aNbSeg+1)*0.75);
229 const Handle(Geom_Surface) aSurf = BRep_Tool::Surface(myFace);
235 Standard_Boolean isClassified = Standard_False;
237 for(i=0; i <= aNbSeg; ++i) {
241 aProjector.Perform(aP);
242 if (!aProjector.IsDone()) {
247 aD=aProjector.LowerDistance();
255 //We classify only three points: in the begin, in the
256 //end and in the middle of the edge.
257 //However, exact middle point (when i == (aNbSeg + 1)/2)
258 //can be unprojectable. Therefore, it will not be able to
259 //be classified. Therefore, points with indexes in
260 //[aTreshIdxF, aTreshIdxL] range are made available
261 //for classification.
262 //isClassified == TRUE if MIDDLE point has been choosen and
263 //classified correctly.
265 if(((0 < i) && (i < aTreshIdxF)) || ((aTreshIdxL < i ) && (i < aNbSeg)))
268 if(isClassified && (i != aNbSeg))
271 aProjector.LowerDistanceParameters(aU, aV);
275 IntTools_FClass2d& aClass2d=myContext->FClass2d(myFace);
276 aState = aClass2d.Perform(aP2d);
278 if(aState == TopAbs_OUT)
279 return Standard_False;
282 isClassified = Standard_True;
285 const Standard_Real aCoeff=(Standard_Real)iCnt/((Standard_Real)aNbSeg+1);
286 return (aCoeff > aTresh);
288 //=======================================================================
289 //function : CheckData
291 //=======================================================================
292 void IntTools_EdgeFace::CheckData()
294 if (BRep_Tool::Degenerated(myEdge)) {
297 if (!BRep_Tool::IsGeometric(myEdge)) {
302 //=======================================================================
303 //function : IsProjectable
305 //=======================================================================
306 Standard_Boolean IntTools_EdgeFace::IsProjectable
307 (const Standard_Real aT) const
309 Standard_Boolean bFlag;
313 bFlag=myContext->IsValidPointForFace(aPC, myFace, myCriteria);
317 //=======================================================================
318 //function : DistanceFunction
320 //=======================================================================
321 Standard_Real IntTools_EdgeFace::DistanceFunction
322 (const Standard_Real t)
330 Standard_Boolean bIsEqDistance;
332 bIsEqDistance= IntTools_EdgeFace::IsEqDistance(P, myS, 1.e-7, aD);
339 Standard_Boolean bFlag = Standard_False;
341 GeomAPI_ProjectPointOnSurf& aLocProj = myContext->ProjPS(myFace);
343 bFlag = aLocProj.IsDone();
346 aD = aLocProj.LowerDistance();
356 // aD=aProjector.LowerDistance();
362 //=======================================================================
363 //function : IsEqDistance
365 //=======================================================================
366 Standard_Boolean IntTools_EdgeFace::IsEqDistance
368 const BRepAdaptor_Surface& aBAS,
369 const Standard_Real aTol,
372 Standard_Boolean bRetFlag=Standard_True;
374 GeomAbs_SurfaceType aSurfType=aBAS.GetType();
376 if (aSurfType==GeomAbs_Cylinder) {
377 gp_Cylinder aCyl=aBAS.Cylinder();
378 const gp_Ax1& anAx1 =aCyl.Axis();
379 gp_Lin aLinAxis(anAx1);
380 Standard_Real aDC, aRadius=aCyl.Radius();
381 aDC=aLinAxis.Distance(aP);
388 if (aSurfType==GeomAbs_Cone) {
389 gp_Cone aCone=aBAS.Cone();
390 const gp_Ax1& anAx1 =aCone.Axis();
391 gp_Lin aLinAxis(anAx1);
392 Standard_Real aDC, aRadius, aDS, aSemiAngle;
393 aDC=aLinAxis.Distance(aP);
395 gp_Pnt anApex=aCone.Apex();
396 aSemiAngle=aCone.SemiAngle();
397 aDS=aP.Distance(anApex);
399 aRadius=aDS*tan(aSemiAngle);
405 if (aSurfType==GeomAbs_Torus) {
406 Standard_Real aMajorRadius, aMinorRadius, aDC;
408 gp_Torus aTorus=aBAS.Torus();
409 gp_Pnt aPLoc=aTorus.Location();
410 aMajorRadius=aTorus.MajorRadius();
412 aDC=fabs(aPLoc.Distance(aP)-aMajorRadius);
414 aMinorRadius=aTorus.MinorRadius();
422 //=======================================================================
423 //function : MakeType
425 //=======================================================================
426 Standard_Integer IntTools_EdgeFace::MakeType
427 (IntTools_CommonPrt& aCommonPrt)
429 Standard_Real af1, al1;
430 Standard_Real df1, tm;
431 Standard_Boolean bAllNullFlag;
433 bAllNullFlag=aCommonPrt.AllNullFlag();
435 aCommonPrt.SetType(TopAbs_EDGE);
439 aCommonPrt.Range1(af1, al1);
445 df1=aPF.Distance(aPL);
446 Standard_Boolean isWholeRange = Standard_False;
448 if((Abs(af1 - myRange.First()) < myC.Resolution(myCriteria)) &&
449 (Abs(al1 - myRange.Last()) < myC.Resolution(myCriteria)))
450 isWholeRange = Standard_True;
453 if ((df1 > myCriteria * 2.) && isWholeRange) {
454 aCommonPrt.SetType(TopAbs_EDGE);
458 tm = (af1 + al1) * 0.5;
460 if(aPF.Distance(myC.Value(tm)) > myCriteria * 2.) {
461 aCommonPrt.SetType(TopAbs_EDGE);
466 if(!CheckTouch(aCommonPrt, tm)) {
467 tm = (af1 + al1) * 0.5;
469 aCommonPrt.SetType(TopAbs_VERTEX);
470 aCommonPrt.SetVertexParameter1(tm);
471 aCommonPrt.SetRange1 (af1, al1);
478 //=======================================================================
479 //function : CheckTouch
481 //=======================================================================
482 Standard_Boolean IntTools_EdgeFace::CheckTouch
483 (const IntTools_CommonPrt& aCP,
486 if (myC.GetType() == GeomAbs_Line &&
487 myS.GetType() == GeomAbs_Plane) {
488 return Standard_False;
491 Standard_Real aTF, aTL, Tol, U1f, U1l, V1f, V1l, af, al,aDist2, aMinDist2;
492 Standard_Boolean theflag=Standard_False;
493 Standard_Integer aNbExt, iLower;
495 aCP.Range1(aTF, aTL);
499 aCR=myC.Resolution(myCriteria);
500 if((Abs(aTF - myRange.First()) < aCR) &&
501 (Abs(aTL - myRange.Last()) < aCR)) {
502 return theflag; // EDGE
506 Tol = Precision::PConfusion();
508 const Handle(Geom_Curve)& Curve =BRep_Tool::Curve (myC.Edge(), af, al);
509 const Handle(Geom_Surface)& Surface=BRep_Tool::Surface(myS.Face());
510 // Surface->Bounds(U1f,U1l,V1f,V1l);
511 U1f = myS.FirstUParameter();
512 U1l = myS.LastUParameter();
513 V1f = myS.FirstVParameter();
514 V1l = myS.LastVParameter();
516 GeomAdaptor_Curve TheCurve (Curve,aTF, aTL);
517 GeomAdaptor_Surface TheSurface (Surface, U1f, U1l, V1f, V1l);
519 Extrema_ExtCS anExtrema (TheCurve, TheSurface, Tol, Tol);
523 if(anExtrema.IsDone()) {
526 if(!anExtrema.IsParallel()) {
527 aNbExt=anExtrema.NbExt();
531 for (Standard_Integer i=1; i<=aNbExt; i++) {
532 aDist2=anExtrema.SquareDistance(i);
533 if (aDist2 < aMinDist2) {
538 aDist2=anExtrema.SquareDistance(iLower);
539 Extrema_POnCurv aPOnC;
540 Extrema_POnSurf aPOnS;
541 anExtrema.Points(iLower, aPOnC, aPOnS);
542 aTx=aPOnC.Parameter();
545 // modified by NIZHNY-MKK Thu Jul 21 11:35:32 2005.BEGIN
546 IntCurveSurface_HInter anExactIntersector;
548 Handle(GeomAdaptor_HCurve) aCurve = new GeomAdaptor_HCurve(TheCurve);
549 Handle(GeomAdaptor_HSurface) aSurface = new GeomAdaptor_HSurface(TheSurface);
551 anExactIntersector.Perform(aCurve, aSurface);
553 if(anExactIntersector.IsDone()) {
554 for(Standard_Integer i = 1; i <= anExactIntersector.NbPoints(); i++) {
555 const IntCurveSurface_IntersectionPoint& aPoint = anExactIntersector.Point(i);
557 if((aPoint.W() >= aTF) && (aPoint.W() <= aTL)) {
563 // modified by NIZHNY-MKK Thu Jul 21 11:35:40 2005.END
571 Standard_Real aBoundaryDist;
573 aBoundaryDist = DistanceFunction(aTF) + myCriteria;
574 if(aBoundaryDist * aBoundaryDist < aDist2) {
575 aDist2 = aBoundaryDist * aBoundaryDist;
579 aBoundaryDist = DistanceFunction(aTL) + myCriteria;
580 if(aBoundaryDist * aBoundaryDist < aDist2) {
581 aDist2 = aBoundaryDist * aBoundaryDist;
585 Standard_Real aParameter = (aTF + aTL) * 0.5;
586 aBoundaryDist = DistanceFunction(aParameter) + myCriteria;
587 if(aBoundaryDist * aBoundaryDist < aDist2) {
588 aDist2 = aBoundaryDist * aBoundaryDist;
592 if(aDist2 > myCriteria * myCriteria) {
596 if (fabs (aTx-aTF) < myEpsT) {
600 if (fabs (aTx-aTL) < myEpsT) {
604 if (aTx>aTF && aTx<aTL) {
611 //=======================================================================
614 //=======================================================================
615 void IntTools_EdgeFace::Perform()
617 Standard_Integer i, aNb;
618 IntTools_CommonPrt aCommonPrt;
620 aCommonPrt.SetEdge1(myEdge);
628 if (myContext.IsNull()) {
629 myContext=new IntTools_Context;
632 myIsDone = Standard_False;
633 myC.Initialize(myEdge);
634 GeomAbs_CurveType aCurveType;
635 aCurveType=myC.GetType();
637 // Prepare myCriteria
638 Standard_Real aFuzz = myFuzzyValue / 2.;
639 Standard_Real aTolF = BRep_Tool::Tolerance(myFace) + aFuzz;
640 Standard_Real aTolE = BRep_Tool::Tolerance(myEdge) + aFuzz;
641 if (aCurveType == GeomAbs_BSplineCurve ||
642 aCurveType==GeomAbs_BezierCurve) {
644 Standard_Real diff1 = (aTolE/aTolF);
645 Standard_Real diff2 = (aTolF/aTolE);
646 if( diff1 > 100 || diff2 > 100 ) {
647 myCriteria = Max(aTolE,aTolF);
650 myCriteria = 1.5*aTolE + aTolF;
653 myCriteria = aTolE + aTolF;
656 myS = myContext->SurfaceAdaptor(myFace);
658 if (myQuickCoincidenceCheck) {
659 if (IsCoincident()) {
660 aCommonPrt.SetType(TopAbs_EDGE);
661 aCommonPrt.SetRange1(myRange.First(), myRange.Last());
662 mySeqOfCommonPrts.Append(aCommonPrt);
663 myIsDone=Standard_True;
668 IntTools_BeanFaceIntersector anIntersector(myC, myS, aTolE, aTolF);
669 anIntersector.SetBeanParameters(myRange.First(), myRange.Last());
671 anIntersector.SetContext(myContext);
673 anIntersector.Perform();
675 if(!anIntersector.IsDone()) {
679 for(Standard_Integer r = 1; r <= anIntersector.Result().Length(); r++) {
680 const IntTools_Range& aRange = anIntersector.Result().Value(r);
682 if(IsProjectable(IntTools_Tools::IntermediatePoint(aRange.First(), aRange.Last()))) {
683 aCommonPrt.SetRange1(aRange.First(), aRange.Last());
684 mySeqOfCommonPrts.Append(aCommonPrt);
688 aNb = mySeqOfCommonPrts.Length();
690 for (i=1; i<=aNb; i++) {
691 IntTools_CommonPrt& aCP=mySeqOfCommonPrts.ChangeValue(i);
693 Standard_Real aTx1, aTx2;
696 aCP.Range1(aTx1, aTx2);
699 aCP.SetBoundingPoints(aPx1, aPx2);
704 // Line\Cylinder's Common Parts treatement
705 GeomAbs_CurveType aCType;
706 GeomAbs_SurfaceType aSType;
707 TopAbs_ShapeEnum aType;
708 Standard_Boolean bIsTouch;
711 aCType=myC.GetType();
712 aSType=myS.GetType();
714 if (aCType==GeomAbs_Line && aSType==GeomAbs_Cylinder) {
715 for (i=1; i<=aNb; i++) {
716 IntTools_CommonPrt& aCP=mySeqOfCommonPrts(i);
718 if (aType==TopAbs_EDGE) {
719 bIsTouch=CheckTouch (aCP, aTx);
721 aCP.SetType(TopAbs_VERTEX);
722 aCP.SetVertexParameter1(aTx);
723 //aCP.SetRange1 (aTx, aTx);
726 else if (aType==TopAbs_VERTEX) {
727 bIsTouch=CheckTouchVertex (aCP, aTx);
729 aCP.SetVertexParameter1(aTx);
730 //aCP.SetRange1 (aTx, aTx);
736 // Circle\Plane's Common Parts treatement
738 if (aCType==GeomAbs_Circle && aSType==GeomAbs_Plane) {
739 Standard_Boolean bIsCoplanar, bIsRadius;
740 bIsCoplanar=IsCoplanar(myC, myS);
741 bIsRadius=IsRadius(myC, myS, myCriteria);
742 if (!bIsCoplanar && !bIsRadius) {
743 for (i=1; i<=aNb; i++) {
744 IntTools_CommonPrt& aCP=mySeqOfCommonPrts(i);
746 if (aType==TopAbs_EDGE) {
747 bIsTouch=CheckTouch (aCP, aTx);
749 aCP.SetType(TopAbs_VERTEX);
750 aCP.SetVertexParameter1(aTx);
751 //aCP.SetRange1 (aTx, aTx);
754 else if (aType==TopAbs_VERTEX) {
755 bIsTouch=CheckTouchVertex (aCP, aTx);
757 aCP.SetVertexParameter1(aTx);
758 //aCP.SetRange1 (aTx, aTx);
765 myIsDone=Standard_True;
770 // 1 - the method Perform() is not invoked
771 // 2,3,4,5 -the method CheckData() fails
772 // 6 - PrepareArgs() problems
773 // 7 - No Projectable ranges
774 // 8,9 - PrepareArgs() problems occured inside projectable Ranges
775 // 11 - can't fill array aFunc(i) in PrepareArgsFuncArrays
778 //=======================================================================
779 //function : CheckTouch
781 //=======================================================================
782 Standard_Boolean IntTools_EdgeFace::CheckTouchVertex
783 (const IntTools_CommonPrt& aCP,
786 Standard_Real aTF, aTL, Tol, U1f,U1l,V1f,V1l;
787 Standard_Real aEpsT, af, al,aDist2, aMinDist2, aTm, aDist2New;
788 Standard_Boolean theflag=Standard_False;
789 Standard_Integer aNbExt, i, iLower ;
790 GeomAbs_CurveType aType;
792 aCP.Range1(aTF, aTL);
796 if (aType==GeomAbs_Line) {
801 aDist2=DistanceFunction(aTm);
804 Tol = Precision::PConfusion();
806 const Handle(Geom_Curve)& Curve =BRep_Tool::Curve (myC.Edge(), af, al);
807 const Handle(Geom_Surface)& Surface=BRep_Tool::Surface(myS.Face());
809 Surface->Bounds(U1f,U1l,V1f,V1l);
811 GeomAdaptor_Curve TheCurve (Curve,aTF, aTL);
812 GeomAdaptor_Surface TheSurface (Surface, U1f, U1l, V1f, V1l);
814 Extrema_ExtCS anExtrema (TheCurve, TheSurface, Tol, Tol);
816 if(!anExtrema.IsDone()) {
819 if (anExtrema.IsParallel()) {
823 aNbExt=anExtrema.NbExt() ;
830 for (i=1; i<=aNbExt; ++i) {
831 aDist2=anExtrema.SquareDistance(i);
832 if (aDist2 < aMinDist2) {
838 aDist2New=anExtrema.SquareDistance(iLower);
840 if (aDist2New > aDist2) {
845 if (aDist2New > myCriteria * myCriteria) {
849 Extrema_POnCurv aPOnC;
850 Extrema_POnSurf aPOnS;
851 anExtrema.Points(iLower, aPOnC, aPOnS);
854 aTx=aPOnC.Parameter();
856 if (fabs (aTx-aTF) < aEpsT) {
860 if (fabs (aTx-aTL) < aEpsT) {
864 if (aTx>aTF && aTx<aTL) {
872 //=======================================================================
873 //function : IsCoplanar
875 //=======================================================================
876 Standard_Boolean IsCoplanar (const BRepAdaptor_Curve& aCurve ,
877 const BRepAdaptor_Surface& aSurface)
879 Standard_Boolean bFlag=Standard_False;
881 GeomAbs_CurveType aCType;
882 GeomAbs_SurfaceType aSType;
884 aCType=aCurve.GetType();
885 aSType=aSurface.GetType();
887 if (aCType==GeomAbs_Circle && aSType==GeomAbs_Plane) {
888 gp_Circ aCirc=aCurve.Circle();
889 const gp_Ax1& anAx1=aCirc.Axis();
890 const gp_Dir& aDirAx1=anAx1.Direction();
892 gp_Pln aPln=aSurface.Plane();
893 const gp_Ax1& anAx=aPln.Axis();
894 const gp_Dir& aDirPln=anAx.Direction();
896 bFlag=IntTools_Tools::IsDirsCoinside(aDirAx1, aDirPln);
900 //=======================================================================
901 //function : IsRadius
903 //=======================================================================
904 Standard_Boolean IsRadius (const BRepAdaptor_Curve& aCurve,
905 const BRepAdaptor_Surface& aSurface,
906 const Standard_Real aCriteria)
908 Standard_Boolean bFlag=Standard_False;
910 GeomAbs_CurveType aCType;
911 GeomAbs_SurfaceType aSType;
913 aCType=aCurve.GetType();
914 aSType=aSurface.GetType();
916 if (aCType==GeomAbs_Circle && aSType==GeomAbs_Plane) {
917 gp_Circ aCirc=aCurve.Circle();
918 const gp_Pnt aCenter=aCirc.Location();
919 Standard_Real aR=aCirc.Radius();
920 gp_Pln aPln=aSurface.Plane();
921 Standard_Real aD=aPln.Distance(aCenter);
922 if (fabs (aD-aR) < aCriteria) {
929 //=======================================================================
930 //function : AdaptiveDiscret
932 //=======================================================================
933 Standard_Integer AdaptiveDiscret (const Standard_Integer iDiscret,
934 const BRepAdaptor_Curve& aCurve ,
935 const BRepAdaptor_Surface& aSurface)
937 Standard_Integer iDiscretNew;
939 iDiscretNew=iDiscret;
941 GeomAbs_SurfaceType aSType;
943 aSType=aSurface.GetType();
945 if (aSType==GeomAbs_Cylinder) {
946 Standard_Real aELength, aRadius, dLR;
948 aELength=IntTools::Length(aCurve.Edge());
950 gp_Cylinder aCylinder=aSurface.Cylinder();
951 aRadius=aCylinder.Radius();
954 iDiscretNew=(Standard_Integer)(aELength/dLR);
956 if (iDiscretNew<iDiscret) {
957 iDiscretNew=iDiscret;