1 // Created on: 1997-07-28
2 // Created by: Jerome LEMONIER
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16 
17 #ifndef _BRepBlend_SurfRstEvolRad_HeaderFile
18 #define _BRepBlend_SurfRstEvolRad_HeaderFile
19 
20 #include <Adaptor3d_CurveOnSurface.hxx>
21 #include <Adaptor3d_Surface.hxx>
22 #include <gp_Pnt.hxx>
23 #include <gp_Pnt2d.hxx>
24 #include <gp_Vec.hxx>
25 #include <gp_Vec2d.hxx>
26 #include <BlendFunc_SectionShape.hxx>
27 #include <Convert_ParameterisationType.hxx>
28 #include <Blend_SurfRstFunction.hxx>
29 #include <math_Vector.hxx>
30 #include <TColStd_Array1OfReal.hxx>
31 #include <GeomAbs_Shape.hxx>
32 #include <TColStd_Array1OfInteger.hxx>
33 #include <TColgp_Array1OfPnt.hxx>
34 #include <TColgp_Array1OfVec.hxx>
35 #include <TColgp_Array1OfPnt2d.hxx>
36 #include <TColgp_Array1OfVec2d.hxx>
37 
38 class Law_Function;
39 class math_Matrix;
40 class gp_Circ;
41 class Blend_Point;
42 
43 
44 //! Function  to approximate by AppSurface  for
45 //! Edge/Face  and  evolutif  radius
46 class BRepBlend_SurfRstEvolRad  : public Blend_SurfRstFunction
47 {
48 public:
49 
50   DEFINE_STANDARD_ALLOC
51 
52 
53   Standard_EXPORT BRepBlend_SurfRstEvolRad(const Handle(Adaptor3d_Surface)& Surf, const Handle(Adaptor3d_Surface)& SurfRst, const Handle(Adaptor2d_Curve2d)& Rst, const Handle(Adaptor3d_Curve)& CGuide, const Handle(Law_Function)& Evol);
54 
55   //! Returns 3.
56   Standard_EXPORT Standard_Integer NbVariables() const Standard_OVERRIDE;
57 
58   //! Returns 3.
59   Standard_EXPORT Standard_Integer NbEquations() const Standard_OVERRIDE;
60 
61   //! computes the values <F> of the Functions for the
62   //! variable <X>.
63   //! Returns True if the computation was done successfully,
64   //! False otherwise.
65   Standard_EXPORT Standard_Boolean Value (const math_Vector& X, math_Vector& F) Standard_OVERRIDE;
66 
67   //! returns the values <D> of the derivatives for the
68   //! variable <X>.
69   //! Returns True if the computation was done successfully,
70   //! False otherwise.
71   Standard_EXPORT Standard_Boolean Derivatives (const math_Vector& X, math_Matrix& D) Standard_OVERRIDE;
72 
73   //! returns the values <F> of the functions and the derivatives
74   //! <D> for the variable <X>.
75   //! Returns True if the computation was done successfully,
76   //! False otherwise.
77   Standard_EXPORT Standard_Boolean Values (const math_Vector& X, math_Vector& F, math_Matrix& D) Standard_OVERRIDE;
78 
79   Standard_EXPORT void Set (const Handle(Adaptor3d_Surface)& SurfRef, const Handle(Adaptor2d_Curve2d)& RstRef);
80 
81   Standard_EXPORT void Set (const Standard_Real Param) Standard_OVERRIDE;
82 
83   //! Sets the bounds of the parametric interval on
84   //! the guide line.
85   //! This determines the derivatives in these values if the
86   //! function is not Cn.
87   Standard_EXPORT void Set (const Standard_Real First, const Standard_Real Last) Standard_OVERRIDE;
88 
89   Standard_EXPORT void GetTolerance (math_Vector& Tolerance, const Standard_Real Tol) const Standard_OVERRIDE;
90 
91   Standard_EXPORT void GetBounds (math_Vector& InfBound, math_Vector& SupBound) const Standard_OVERRIDE;
92 
93   Standard_EXPORT Standard_Boolean IsSolution (const math_Vector& Sol, const Standard_Real Tol) Standard_OVERRIDE;
94 
95   //! Returns   the    minimal  Distance  between   two
96   //! extremities of calculated sections.
97   Standard_EXPORT virtual Standard_Real GetMinimalDistance() const Standard_OVERRIDE;
98 
99   Standard_EXPORT const gp_Pnt& PointOnS() const Standard_OVERRIDE;
100 
101   Standard_EXPORT const gp_Pnt& PointOnRst() const Standard_OVERRIDE;
102 
103   //! Returns U,V coordinates of the point on the surface.
104   Standard_EXPORT const gp_Pnt2d& Pnt2dOnS() const Standard_OVERRIDE;
105 
106   //! Returns  U,V coordinates of the point  on the curve on
107   //! surface.
108   Standard_EXPORT const gp_Pnt2d& Pnt2dOnRst() const Standard_OVERRIDE;
109 
110   //! Returns parameter of the point on the curve.
111   Standard_EXPORT Standard_Real ParameterOnRst() const Standard_OVERRIDE;
112 
113   Standard_EXPORT Standard_Boolean IsTangencyPoint() const Standard_OVERRIDE;
114 
115   Standard_EXPORT const gp_Vec& TangentOnS() const Standard_OVERRIDE;
116 
117   Standard_EXPORT const gp_Vec2d& Tangent2dOnS() const Standard_OVERRIDE;
118 
119   Standard_EXPORT const gp_Vec& TangentOnRst() const Standard_OVERRIDE;
120 
121   Standard_EXPORT const gp_Vec2d& Tangent2dOnRst() const Standard_OVERRIDE;
122 
123   //! Permet  d ' implementer   un   critere  de  decrochage
124   //! specifique a la fonction.
125   Standard_EXPORT Standard_Boolean Decroch (const math_Vector& Sol, gp_Vec& NS, gp_Vec& TgS) const Standard_OVERRIDE;
126 
127   Standard_EXPORT void Set (const Standard_Integer Choix);
128 
129   //! Sets  the  type  of   section generation   for the
130   //! approximations.
131   Standard_EXPORT void Set (const BlendFunc_SectionShape TypeSection);
132 
133   Standard_EXPORT void Section (const Standard_Real Param, const Standard_Real U, const Standard_Real V, const Standard_Real W, Standard_Real& Pdeb, Standard_Real& Pfin, gp_Circ& C);
134 
135   //! Returns  if the section is rationnal
136   Standard_EXPORT Standard_Boolean IsRational() const Standard_OVERRIDE;
137 
138   //! Returns the length of the maximum section
139   Standard_EXPORT Standard_Real GetSectionSize() const Standard_OVERRIDE;
140 
141   //! Compute the minimal value of weight for each poles
142   //! of all sections.
143   Standard_EXPORT void GetMinimalWeight (TColStd_Array1OfReal& Weigths) const Standard_OVERRIDE;
144 
145   //! Returns  the number  of  intervals for  continuity
146   //! <S>. May be one if Continuity(me) >= <S>
147   Standard_EXPORT Standard_Integer NbIntervals (const GeomAbs_Shape S) const Standard_OVERRIDE;
148 
149   //! Stores in <T> the  parameters bounding the intervals
150   //! of continuity <S>.
151   //! The array must provide  enough room to  accommodate
152   //! for the parameters. i.e. T.Length() > NbIntervals()
153   Standard_EXPORT void Intervals (TColStd_Array1OfReal& T, const GeomAbs_Shape S) const Standard_OVERRIDE;
154 
155   Standard_EXPORT void GetShape (Standard_Integer& NbPoles, Standard_Integer& NbKnots, Standard_Integer& Degree, Standard_Integer& NbPoles2d) Standard_OVERRIDE;
156 
157   //! Returns the tolerance to reach in approximation
158   //! to respecte
159   //! BoundTol error at the Boundary
160   //! AngleTol tangent error at the Boundary
161   //! SurfTol error inside the surface.
162   Standard_EXPORT void GetTolerance (const Standard_Real BoundTol, const Standard_Real SurfTol, const Standard_Real AngleTol, math_Vector& Tol3d, math_Vector& Tol1D) const Standard_OVERRIDE;
163 
164   Standard_EXPORT void Knots (TColStd_Array1OfReal& TKnots) Standard_OVERRIDE;
165 
166   Standard_EXPORT void Mults (TColStd_Array1OfInteger& TMults) Standard_OVERRIDE;
167 
168   //! Used for the first and last section
169   Standard_EXPORT Standard_Boolean Section (const Blend_Point& P, TColgp_Array1OfPnt& Poles, TColgp_Array1OfVec& DPoles, TColgp_Array1OfPnt2d& Poles2d, TColgp_Array1OfVec2d& DPoles2d, TColStd_Array1OfReal& Weigths, TColStd_Array1OfReal& DWeigths) Standard_OVERRIDE;
170 
171   //! Used for the first and last section
172   //! The method returns Standard_True if the derivatives
173   //! are computed, otherwise it returns Standard_False.
174   Standard_EXPORT Standard_Boolean Section (const Blend_Point& P, TColgp_Array1OfPnt& Poles, TColgp_Array1OfVec& DPoles, TColgp_Array1OfVec& D2Poles, TColgp_Array1OfPnt2d& Poles2d, TColgp_Array1OfVec2d& DPoles2d, TColgp_Array1OfVec2d& D2Poles2d, TColStd_Array1OfReal& Weigths, TColStd_Array1OfReal& DWeigths, TColStd_Array1OfReal& D2Weigths) Standard_OVERRIDE;
175 
176   Standard_EXPORT void Section (const Blend_Point& P, TColgp_Array1OfPnt& Poles, TColgp_Array1OfPnt2d& Poles2d, TColStd_Array1OfReal& Weigths) Standard_OVERRIDE;
177 
178   Standard_EXPORT void Resolution (const Standard_Integer IC2d, const Standard_Real Tol, Standard_Real& TolU, Standard_Real& TolV) const Standard_OVERRIDE;
179 
180 
181 
182 
183 protected:
184 
185 
186 
187 
188 
189 private:
190 
191 
192 
193   Handle(Adaptor3d_Surface) surf;
194   Handle(Adaptor3d_Surface) surfrst;
195   Handle(Adaptor2d_Curve2d) rst;
196   Adaptor3d_CurveOnSurface cons;
197   Handle(Adaptor3d_Curve) guide;
198   Handle(Adaptor3d_Curve) tguide;
199   gp_Pnt pts;
200   gp_Pnt ptrst;
201   gp_Pnt2d pt2ds;
202   gp_Pnt2d pt2drst;
203   Standard_Real prmrst;
204   Standard_Boolean istangent;
205   gp_Vec tgs;
206   gp_Vec2d tg2ds;
207   gp_Vec tgrst;
208   gp_Vec2d tg2drst;
209   Standard_Real ray;
210   Standard_Real dray;
211   Standard_Integer choix;
212   gp_Pnt ptgui;
213   gp_Vec d1gui;
214   gp_Vec d2gui;
215   gp_Vec nplan;
216   Standard_Real normtg;
217   Standard_Real theD;
218   Handle(Adaptor3d_Surface) surfref;
219   Handle(Adaptor2d_Curve2d) rstref;
220   Standard_Real maxang;
221   Standard_Real minang;
222   Standard_Real distmin;
223   BlendFunc_SectionShape mySShape;
224   Convert_ParameterisationType myTConv;
225   Handle(Law_Function) tevol;
226   Handle(Law_Function) fevol;
227   Standard_Real sg1;
228 
229 
230 };
231 
232 
233 
234 
235 
236 
237 
238 #endif // _BRepBlend_SurfRstEvolRad_HeaderFile
239