0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / GeomFill / GeomFill_LocationGuide.hxx
1 // Created on: 1998-07-08
2 // Created by: Stephanie HUMEAU
3 // Copyright (c) 1998-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 _GeomFill_LocationGuide_HeaderFile
18 #define _GeomFill_LocationGuide_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
22
23 #include <TColgp_HArray2OfPnt2d.hxx>
24 #include <Standard_Integer.hxx>
25 #include <Standard_Boolean.hxx>
26 #include <Standard_Real.hxx>
27 #include <gp_Mat.hxx>
28 #include <math_Vector.hxx>
29 #include <GeomFill_PipeError.hxx>
30 #include <GeomFill_LocationLaw.hxx>
31 #include <TColgp_Array1OfPnt2d.hxx>
32 #include <TColgp_Array1OfVec2d.hxx>
33 #include <GeomAbs_Shape.hxx>
34 #include <TColStd_Array1OfReal.hxx>
35 #include <TColgp_HArray1OfPnt2d.hxx>
36 class GeomFill_TrihedronWithGuide;
37 class GeomFill_SectionLaw;
38 class Adaptor3d_HCurve;
39 class Standard_NotImplemented;
40 class Standard_ConstructionError;
41 class Standard_OutOfRange;
42 class gp_Mat;
43 class GeomFill_LocationLaw;
44 class gp_Vec;
45 class gp_Pnt;
46 class Geom_Curve;
47
48
49 class GeomFill_LocationGuide;
50 DEFINE_STANDARD_HANDLE(GeomFill_LocationGuide, GeomFill_LocationLaw)
51
52
53 class GeomFill_LocationGuide : public GeomFill_LocationLaw
54 {
55
56 public:
57
58   
59   Standard_EXPORT GeomFill_LocationGuide(const Handle(GeomFill_TrihedronWithGuide)& Triedre);
60   
61   Standard_EXPORT void Set (const Handle(GeomFill_SectionLaw)& Section, const Standard_Boolean rotat, const Standard_Real SFirst, const Standard_Real SLast, const Standard_Real PrecAngle, Standard_Real& LastAngle);
62   
63   Standard_EXPORT void EraseRotation();
64   
65   Standard_EXPORT virtual void SetCurve (const Handle(Adaptor3d_HCurve)& C) Standard_OVERRIDE;
66   
67   Standard_EXPORT virtual const Handle(Adaptor3d_HCurve)& GetCurve() const Standard_OVERRIDE;
68   
69   Standard_EXPORT virtual void SetTrsf (const gp_Mat& Transfo) Standard_OVERRIDE;
70   
71   Standard_EXPORT virtual Handle(GeomFill_LocationLaw) Copy() const Standard_OVERRIDE;
72   
73   //! compute Location
74   Standard_EXPORT virtual Standard_Boolean D0 (const Standard_Real Param, gp_Mat& M, gp_Vec& V) Standard_OVERRIDE;
75   
76   //! compute Location and 2d points
77   Standard_EXPORT virtual Standard_Boolean D0 (const Standard_Real Param, gp_Mat& M, gp_Vec& V, TColgp_Array1OfPnt2d& Poles2d) Standard_OVERRIDE;
78   
79   //! compute location 2d  points and  associated
80   //! first derivatives.
81   //! Warning : It used only for C1 or C2 aproximation
82   Standard_EXPORT virtual Standard_Boolean D1 (const Standard_Real Param, gp_Mat& M, gp_Vec& V, gp_Mat& DM, gp_Vec& DV, TColgp_Array1OfPnt2d& Poles2d, TColgp_Array1OfVec2d& DPoles2d) Standard_OVERRIDE;
83   
84   //! compute location 2d  points and associated
85   //! first and seconde  derivatives.
86   //! Warning : It used only for C2 aproximation
87   Standard_EXPORT virtual Standard_Boolean D2 (const Standard_Real Param, gp_Mat& M, gp_Vec& V, gp_Mat& DM, gp_Vec& DV, gp_Mat& D2M, gp_Vec& D2V, TColgp_Array1OfPnt2d& Poles2d, TColgp_Array1OfVec2d& DPoles2d, TColgp_Array1OfVec2d& D2Poles2d) Standard_OVERRIDE;
88   
89   //! Say if the first restriction is defined in this class.
90   //! If it  is true the  first element  of poles array   in
91   //! D0,D1,D2... Correspond to this restriction.
92   //! Returns Standard_False (default implementation)
93   Standard_EXPORT virtual Standard_Boolean HasFirstRestriction() const Standard_OVERRIDE;
94   
95   //! Say if the last restriction is defined in this class.
96   //! If it is  true the  last element  of poles array in
97   //! D0,D1,D2... Correspond to this restriction.
98   //! Returns Standard_False (default implementation)
99   Standard_EXPORT virtual Standard_Boolean HasLastRestriction() const Standard_OVERRIDE;
100   
101   //! Give the number of trace (Curves 2d wich are not restriction)
102   //! Returns 1 (default implementation)
103   Standard_EXPORT virtual Standard_Integer TraceNumber() const Standard_OVERRIDE;
104   
105   //! Give a status to the Law
106   //! Returns PipeOk (default implementation)
107   Standard_EXPORT virtual GeomFill_PipeError ErrorStatus() const Standard_OVERRIDE;
108   
109   //! Returns  the number  of  intervals for  continuity
110   //! <S>.
111   //! May be one if Continuity(me) >= <S>
112   Standard_EXPORT virtual Standard_Integer NbIntervals (const GeomAbs_Shape S) const Standard_OVERRIDE;
113   
114   //! Stores in <T> the  parameters bounding the intervals
115   //! of continuity <S>.
116   //!
117   //! The array must provide  enough room to  accomodate
118   //! for the parameters. i.e. T.Length() > NbIntervals()
119   Standard_EXPORT virtual void Intervals (TColStd_Array1OfReal& T, const GeomAbs_Shape S) const Standard_OVERRIDE;
120   
121   //! Sets the bounds of the parametric interval on
122   //! the function
123   //! This determines the derivatives in these values if the
124   //! function is not Cn.
125   Standard_EXPORT virtual void SetInterval (const Standard_Real First, const Standard_Real Last) Standard_OVERRIDE;
126   
127   //! Gets the bounds of the parametric interval on
128   //! the function
129   Standard_EXPORT virtual void GetInterval (Standard_Real& First, Standard_Real& Last) const Standard_OVERRIDE;
130   
131   //! Gets the bounds of the function parametric domain.
132   //! Warning: This domain it is  not modified by the
133   //! SetValue method
134   Standard_EXPORT virtual void GetDomain (Standard_Real& First, Standard_Real& Last) const Standard_OVERRIDE;
135   
136   //! Is usefull, if (me) have to run numerical
137   //! algorithm to perform D0, D1 or D2
138   //! The default implementation make nothing.
139   Standard_EXPORT virtual void SetTolerance (const Standard_Real Tol3d, const Standard_Real Tol2d) Standard_OVERRIDE;
140   
141   //! Returns the resolutions in the  sub-space 2d <Index>
142   //! This information is usfull to find an good tolerance in
143   //! 2d approximation.
144   //! Warning: Used only if Nb2dCurve > 0
145   Standard_EXPORT virtual void Resolution (const Standard_Integer Index, const Standard_Real Tol, Standard_Real& TolU, Standard_Real& TolV) const Standard_OVERRIDE;
146   
147   //! Get the maximum Norm  of the matrix-location part.  It
148   //! is usful to find an good Tolerance to approx M(t).
149   Standard_EXPORT virtual Standard_Real GetMaximalNorm() Standard_OVERRIDE;
150   
151   //! Get average value of M(t) and V(t) it is usfull to
152   //! make fast approximation of rational  surfaces.
153   Standard_EXPORT virtual void GetAverageLaw (gp_Mat& AM, gp_Vec& AV) Standard_OVERRIDE;
154   
155   //! Say if the Location  Law, is an translation of  Location
156   //! The default implementation is " returns False ".
157   Standard_EXPORT virtual Standard_Boolean IsTranslation (Standard_Real& Error) const Standard_OVERRIDE;
158   
159   //! Say if the Location  Law, is a rotation of Location
160   //! The default implementation is " returns False ".
161   Standard_EXPORT virtual Standard_Boolean IsRotation (Standard_Real& Error) const Standard_OVERRIDE;
162   
163   Standard_EXPORT virtual void Rotation (gp_Pnt& Center) const Standard_OVERRIDE;
164   
165   Standard_EXPORT Handle(Geom_Curve) Section() const;
166   
167   Standard_EXPORT Handle(Adaptor3d_HCurve) Guide() const;
168   
169   Standard_EXPORT void SetOrigine (const Standard_Real Param1, const Standard_Real Param2);
170   
171   Standard_EXPORT GeomFill_PipeError ComputeAutomaticLaw (Handle(TColgp_HArray1OfPnt2d)& ParAndRad) const;
172
173
174
175
176   DEFINE_STANDARD_RTTIEXT(GeomFill_LocationGuide,GeomFill_LocationLaw)
177
178 protected:
179
180
181   Handle(TColgp_HArray2OfPnt2d) myPoles2d;
182
183
184 private:
185
186   
187   Standard_EXPORT void SetRotation (const Standard_Real PrecAngle, Standard_Real& LastAngle);
188   
189   Standard_EXPORT void InitX (const Standard_Real Param);
190
191   Handle(GeomFill_TrihedronWithGuide) myLaw;
192   Handle(GeomFill_SectionLaw) mySec;
193   Handle(Adaptor3d_HCurve) myCurve;
194   Handle(Adaptor3d_HCurve) myGuide;
195   Handle(Adaptor3d_HCurve) myTrimmed;
196   Standard_Integer myNbPts;
197   Standard_Boolean rotation;
198   Standard_Real OrigParam1;
199   Standard_Real OrigParam2;
200   Standard_Real Uf;
201   Standard_Real Ul;
202   Standard_Real myFirstS;
203   Standard_Real myLastS;
204   Standard_Real ratio;
205   Standard_Boolean WithTrans;
206   gp_Mat Trans;
207   math_Vector TolRes;
208   math_Vector Inf;
209   math_Vector Sup;
210   math_Vector X;
211   math_Vector R;
212   GeomFill_PipeError myStatus;
213
214
215 };
216
217
218
219
220
221
222
223 #endif // _GeomFill_LocationGuide_HeaderFile