+ }
+ //creation points for surfaces based on BSpline or Bezier curves
+ else if(theSurf.GetType() == GeomAbs_SurfaceOfRevolution ||
+ theSurf.GetType() == GeomAbs_SurfaceOfExtrusion)
+ {
+ Handle(TColStd_HArray1OfReal) anArrKnots;
+ Standard_Integer aDegree = 0;
+ GeomAbs_CurveType aType = theSurf.BasisCurve()->Curve().GetType();
+ if(theSurf.BasisCurve()->Curve().GetType() == GeomAbs_BSplineCurve)
+ {
+ Handle(Geom_BSplineCurve) aBspl = theSurf.BasisCurve()->Curve().BSpline();
+ if(!aBspl.IsNull())
+ {
+ anArrKnots = new TColStd_HArray1OfReal(1,aBspl->NbKnots());
+ aBspl->Knots( anArrKnots->ChangeArray1() );
+ aDegree = aBspl->Degree();
+
+ }
+
+ }
+ if(theSurf.BasisCurve()->Curve().GetType() == GeomAbs_BezierCurve)
+ {
+ Handle(Geom_BezierCurve) aBez = theSurf.BasisCurve()->Curve().Bezier();
+ if(!aBez.IsNull())
+ {
+ anArrKnots = new TColStd_HArray1OfReal(1,2);
+ anArrKnots->SetValue(1, aBez->FirstParameter());
+ anArrKnots->SetValue(2, aBez->LastParameter());
+ aDegree = aBez->Degree();
+
+ }
+ }
+ if(anArrKnots.IsNull())
+ return;
+ if( theSurf.GetType() == GeomAbs_SurfaceOfRevolution )
+ fillParams( anArrKnots->Array1(), aDegree, myvmin, myvsup, myVParams, myvsample);
+ else
+ fillParams( anArrKnots->Array1(), aDegree, myumin, myusup, myUParams, myusample);
+ }
+ //update the number of points in sample
+ if(!myUParams.IsNull())
+ myusample = myUParams->Length();
+ if( !myVParams.IsNull())
+ myvsample = myVParams->Length();
+
+}
+
+void Extrema_GenExtPS::BuildGrid()
+{
+ //if grid was already built do nothing
+ if(myInit)
+ return;
+
+ //build parametric grid in case of a complex surface geometry (BSpline and Bezier surfaces)
+ GetGridPoints(*myS);
+
+ //build grid in other cases
+ if( myUParams.IsNull() )
+ {
+ Standard_Real PasU = myusup - myumin;
+ Standard_Real U0 = PasU / myusample / 100.;
+ PasU = (PasU - U0) / (myusample - 1);
+ U0 = U0/2. + myumin;
+ myUParams = new TColStd_HArray1OfReal(1,myusample );
+ Standard_Integer NoU;
+ Standard_Real U = U0;
+ for ( NoU = 1 ; NoU <= myusample; NoU++, U += PasU)
+ myUParams->SetValue(NoU, U);
+
+ }
+
+ if( myVParams.IsNull())
+ {
+ Standard_Real PasV = myvsup - myvmin;
+ Standard_Real V0 = PasV / myvsample / 100.;
+ PasV = (PasV - V0) / (myvsample - 1);
+ V0 = V0/2. + myvmin;
+
+ myVParams = new TColStd_HArray1OfReal(1,myvsample );
+ Standard_Integer NoV;
+ Standard_Real V = V0;
+
+ for ( NoV = 1, V = V0; NoV <= myvsample; NoV++, V += PasV)
+ myVParams->SetValue(NoV, V);
+ }
+ //If flag was changed and extrema not reinitialized Extrema would fail
+ mypoints = new TColgp_HArray2OfPnt(0,myusample+1,0,myvsample+1);
+ // Calculation of distances