// File: IntCurveSurface_Polygon.gxx // Created: Mon Oct 12 17:17:30 1992 // Author: Laurent BUCHARD // #include #include #include #include #include #include //====================================================================== //== On echantillonne sur le Domain de la Curve NbPts Points //== a parametres constants. //== //== On estime la fleche maximum en prenant la distance maxi entre la //== droite Curve.Value(X(i))-->Curve.Value(X(i+1)) //== et le point Curve.Value(X(i+1/2)) //====================================================================== IntCurveSurface_Polygon::IntCurveSurface_Polygon(const TheCurve& C, const Standard_Integer tNbPts): ThePnts(1,(tNbPts<5)? 5 : tNbPts) { Standard_Integer NbPts = (tNbPts<5)? 5 : tNbPts; NbPntIn = NbPts; Binf = TheCurveTool::FirstParameter(C); Bsup = TheCurveTool::LastParameter(C); Init(C); } IntCurveSurface_Polygon::IntCurveSurface_Polygon(const TheCurve& C, const Standard_Real U1, const Standard_Real U2, const Standard_Integer tNbPts): ThePnts(1,(tNbPts<5)? 5 : tNbPts) , Binf(U1) , Bsup(U2) { Standard_Integer NbPts = (tNbPts<5)? 5 : tNbPts; NbPntIn = NbPts; Init(C); } //======================================================================= //function : IntCurveSurface_Polygon //purpose : //======================================================================= IntCurveSurface_Polygon::IntCurveSurface_Polygon(const TheCurve& C, const TColStd_Array1OfReal& Upars): ThePnts(1,Upars.Length()) , Binf(Upars(Upars.Lower())) , Bsup(Upars(Upars.Upper())) { //ddout << "IntCurveSurface_Polygon::IntCurveSurface_Polygon" << endl; Standard_Integer NbPts = Upars.Length(); //ddout << "NbPts :" << NbPts << endl; NbPntIn = NbPts; Init(C, Upars); } void IntCurveSurface_Polygon::Init(const TheCurve& C) { Standard_Real u=Binf; Standard_Real u1=Bsup; Standard_Real du=(u1-u)/(Standard_Real)(NbPntIn-1); Standard_Integer i=1; gp_Pnt P; do { TheCurveTool::D0(C,u,P); TheBnd.Add(P); ThePnts.SetValue(i,P); u+=du; i++; } while(i<=NbPntIn); //----------------------------------------------------- //--- Calcul d un majorant de fleche approche //--- TheDeflection = 0.0; if(NbPntIn>3) { i=1; u=Binf; u+=du * 0.5; do { gp_Pnt Pm=TheCurveTool::Value(C,u); gp_Pnt P1=ThePnts.Value(i); gp_Pnt P2=ThePnts.Value(i+1); gp_Lin L(P1,gp_Dir(gp_Vec(P1,P2))); Standard_Real t=L.Distance(Pm); if(t>TheDeflection) { TheDeflection = t; } u+=du; i++; } while(iSetValue(i, Upars(i+i0)); TheCurveTool::D0(C,Upars(i+i0),P); //ddout << "P : " << P.X() << " " << P.Y() << " " << P.Z() << endl; TheBnd.Add(P); ThePnts.SetValue(i,P); i++; } while(i<=NbPntIn); //----------------------------------------------------- //--- Calcul d un majorant de fleche approche //--- TheDeflection = 0.0; if(NbPntIn>3) { i=1; //ddout << "Deflection estimation" << endl; do { u = 0.5*(Upars(i0+i)+Upars(i0+i+1)); //ddout << "===========Parameter : " << i << " " << u << endl; gp_Pnt Pm=TheCurveTool::Value(C,u); //ddout << "Pm : " << Pm.X() << " " << Pm.Y() << " " << Pm.Z() << endl; gp_Pnt P1=ThePnts.Value(i); //ddout << "P1 : " << P1.X() << " " << P1.Y() << " " << P1.Z() << endl; gp_Pnt P2=ThePnts.Value(i+1); //ddout << "P2 : " << P2.X() << " " << P2.Y() << " " << P2.Z() << endl; gp_Lin L(P1,gp_Dir(gp_Vec(P1,P2))); Standard_Real t=L.Distance(Pm); //ddout << "Distance " << t << endl; if(t>TheDeflection) { TheDeflection = t; } i++; } while(i1.0) { cout<<" ParamOnLine = "< NbPntIn) { cout << "OutOfRange Polygon::ApproxParamOnCurve " <Value(Index+1) - myParams->Value(Index); u = myParams->Value(Index); } u += du * ParamOnLine; return (u); } //====================================================================== void IntCurveSurface_Polygon::Dump(void) const { #if 0 static Standard_Integer Compteur=0; char tamp[100]; Compteur++; sprintf(tamp,"Poly%d",Compteur); cout<<" @@@@@@@@@@@ F i c h i e r : "< %f \n",Binf,Bsup); fprintf(fp,"\npol %d %d %f",Compteur,NbPntIn,TheDeflection); gp_Pnt p1,p2; for (Standard_Integer iObje=1; iObje<=NbSegments(); iObje++) { p1=BeginOfSeg(iObje); fprintf(fp,"\npnt %d %f %f",Compteur,p1.X(),p1.Y()); } p1=EndOfSeg(NbSegments()); fprintf(fp,"\npnt %d %f %f",Compteur,p1.X(),p1.Y()); fprintf(fp,"\ndispol %d\n#\n",Compteur); fclose(fp); #endif } //====================================================================== //======================================================================