0031939: Coding - correction of spelling errors in comments
[occt.git] / src / GeomFill / GeomFill_Pipe.hxx
1 // Created on: 1994-04-13
2 // Created by: Eric BONNARDEL
3 // Copyright (c) 1994-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_Pipe_HeaderFile
18 #define _GeomFill_Pipe_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <Standard_Real.hxx>
25 #include <Standard_Integer.hxx>
26 #include <Standard_Boolean.hxx>
27 #include <GeomFill_Trihedron.hxx>
28 #include <TColGeom_SequenceOfCurve.hxx>
29 #include <GeomAbs_Shape.hxx>
30 class Adaptor3d_HCurve;
31 class Geom_Surface;
32 class GeomFill_LocationLaw;
33 class GeomFill_SectionLaw;
34 class Standard_ConstructionError;
35 class Geom_Curve;
36 class Geom2d_Curve;
37 class gp_Dir;
38
39
40 //! Describes functions to construct pipes. A pipe is built by
41 //! sweeping a curve (the section) along another curve (the path).
42 //! The Pipe class provides the following types of construction:
43 //! -   pipes with a circular section of constant radius,
44 //! -   pipes with a constant section,
45 //! -   pipes with a section evolving between two given curves.
46 //! All standard specific cases are detected in order to build,
47 //! where required, a plane, cylinder, cone, sphere, torus,
48 //! surface of linear extrusion or surface of revolution.
49 //! Generally speaking, the result is a BSpline surface (NURBS).
50 //! A Pipe object provides a framework for:
51 //! -   defining the pipe to be built,
52 //! -   implementing the construction algorithm, and
53 //! -   consulting the resulting surface.
54 //! There are several methods to instantiate a Pipe:
55 //! 1) give a path and  a radius : the section is
56 //! a circle.  This location  is the first  point
57 //! of the path,  and this direction is the first
58 //! derivate (calculate at  the  first point ) of
59 //! the path.
60 //!
61 //! 2) give a path and a section.
62 //! Differtent options are available
63 //! 2.a) Use the classical Frenet trihedron
64 //! - or the CorrectedFrenet trihedron
65 //! (To avoid twisted surface)
66 //! - or a constant trihedron to have all the sections
67 //! in a same plane
68 //! 2.b) Define a ConstantBinormal Direction to keep the
69 //! same angle between the Direction and the sections
70 //! along the sweep surface.
71 //! 2.c) Define the path by a surface and a 2dcurve,
72 //! the surface is used to define the trihedron's normal.
73 //! It is usefull to keep a constant angle between
74 //! input surface and the pipe.                           --
75 //! 3) give a  path and two sections. The section
76 //! evoluate from First to Last Section.
77 //!
78 //! 3) give a  path and N sections. The section
79 //! evoluate from First to Last Section.
80 //!
81 //! In general case the result is a NURBS. But we
82 //! can  generate plane,  cylindrical, spherical,
83 //! conical, toroidal surface in some particular case.
84 //!
85 //! The natural parametrization of the result is:
86 //!
87 //! U-Direction along the section.
88 //! V-Direction along the path.
89 //!
90 //! But, in some particular case, the surface must
91 //! be construct otherwise.
92 //! The method "EchangeUV" return false in such cases.
93 class GeomFill_Pipe 
94 {
95 public:
96
97   DEFINE_STANDARD_ALLOC
98
99   
100
101   //! Constructs an empty algorithm for building pipes. Use
102   //! the function Init to initialize it.
103   Standard_EXPORT GeomFill_Pipe();
104   
105   Standard_EXPORT GeomFill_Pipe(const Handle(Geom_Curve)& Path, const Standard_Real Radius);
106   
107   //! Create  a  pipe  with  a  constant  section
108   //! (<FirstSection>)  and a path (<Path>)
109   //! Option can be  - GeomFill_IsCorrectedFrenet
110   //! - GeomFill_IsFrenet
111   //! - GeomFill_IsConstant
112   Standard_EXPORT GeomFill_Pipe(const Handle(Geom_Curve)& Path, const Handle(Geom_Curve)& FirstSect, const GeomFill_Trihedron Option = GeomFill_IsCorrectedFrenet);
113   
114   //! Create  a  pipe  with  a  constant  section
115   //! (<FirstSection>)  and a path defined by <Path> and <Support>
116   Standard_EXPORT GeomFill_Pipe(const Handle(Geom2d_Curve)& Path, const Handle(Geom_Surface)& Support, const Handle(Geom_Curve)& FirstSect);
117   
118   //! Create  a  pipe with  a  constant section
119   //! (<FirstSection>) and a   path <Path>  and a fixed
120   //! binormal direction <Dir>
121   Standard_EXPORT GeomFill_Pipe(const Handle(Geom_Curve)& Path, const Handle(Geom_Curve)& FirstSect, const gp_Dir& Dir);
122   
123   //! Create a pipe with an evolving section
124   //! The section evoluate from First to Last Section
125   Standard_EXPORT GeomFill_Pipe(const Handle(Geom_Curve)& Path, const Handle(Geom_Curve)& FirstSect, const Handle(Geom_Curve)& LastSect);
126   
127   //! Create a pipe with N  sections
128   //! The section evoluate from First to Last Section
129   Standard_EXPORT GeomFill_Pipe(const Handle(Geom_Curve)& Path, const TColGeom_SequenceOfCurve& NSections);
130   
131   //! Create  a pipe  with  a constant  radius with  2
132   //! guide-line.
133   Standard_EXPORT GeomFill_Pipe(const Handle(Geom_Curve)& Path, const Handle(Geom_Curve)& Curve1, const Handle(Geom_Curve)& Curve2, const Standard_Real Radius);
134   
135   //! Create  a pipe  with  a constant  radius with  2
136   //! guide-line.
137   Standard_EXPORT GeomFill_Pipe(const Handle(Adaptor3d_HCurve)& Path, const Handle(Adaptor3d_HCurve)& Curve1, const Handle(Adaptor3d_HCurve)& Curve2, const Standard_Real Radius);
138   
139   //! Create a pipe with a constant section and  with 1
140   //! guide-line.
141   //! Use the function Perform to build the surface.
142   //! All standard specific cases are detected in order to
143   //! construct, according to the respective geometric
144   //! nature of Path and the sections, a planar, cylindrical,
145   //! conical, spherical or toroidal surface, a surface of
146   //! linear extrusion or a surface of revolution.
147   //! In the general case, the result is a BSpline surface
148   //! (NURBS) built by approximation of a series of sections where:
149   //! -   the number of sections N is chosen automatically
150   //! by the algorithm according to the respective
151   //! geometries of Path and the sections. N is greater than or equal to 2;
152   //! -   N points Pi (with i in the range [ 1,N ]) are
153   //! defined at regular intervals along the curve Path
154   //! from its first point to its end point. At each point Pi,
155   //! a coordinate system Ti is computed with Pi as
156   //! origin, and with the tangential and normal vectors
157   //! to Path defining two of its coordinate axes.
158   //! In the case of a pipe with a constant circular section,
159   //! the first section is a circle of radius Radius centered
160   //! on the origin of Path and whose "Z Axis" is aligned
161   //! along the vector tangential to the origin of Path. In the
162   //! case of a pipe with a constant section, the first section
163   //! is the curve FirstSect. In these two cases, the ith
164   //! section (for values of i greater than 1) is obtained by
165   //! applying to a copy of this first section the geometric
166   //! transformation which transforms coordinate system
167   //! T1 into coordinate system Ti.
168   //! In the case of an evolving section, N-2 intermediate
169   //! curves Si are first computed (if N is greater than 2,
170   //! and with i in the range [ 2,N-1 ]) whose geometry
171   //! evolves regularly from the curve S1=FirstSect to the
172   //! curve SN=LastSect. The first section is FirstSect,
173   //! and the ith section (for values of i greater than 1) is
174   //! obtained by applying to the curve Si the geometric
175   //! transformation which transforms coordinate system
176   //! T1 into coordinate system Ti.
177   Standard_EXPORT GeomFill_Pipe(const Handle(Geom_Curve)& Path, const Handle(Adaptor3d_HCurve)& Guide, const Handle(Geom_Curve)& FirstSect, const Standard_Boolean ByACR, const Standard_Boolean rotat);
178   
179   Standard_EXPORT void Init (const Handle(Geom_Curve)& Path, const Standard_Real Radius);
180   
181   Standard_EXPORT void Init (const Handle(Geom_Curve)& Path, const Handle(Geom_Curve)& FirstSect, const GeomFill_Trihedron Option = GeomFill_IsCorrectedFrenet);
182   
183   Standard_EXPORT void Init (const Handle(Geom2d_Curve)& Path, const Handle(Geom_Surface)& Support, const Handle(Geom_Curve)& FirstSect);
184   
185   Standard_EXPORT void Init (const Handle(Geom_Curve)& Path, const Handle(Geom_Curve)& FirstSect, const gp_Dir& Dir);
186   
187   Standard_EXPORT void Init (const Handle(Geom_Curve)& Path, const Handle(Geom_Curve)& FirstSect, const Handle(Geom_Curve)& LastSect);
188   
189   Standard_EXPORT void Init (const Handle(Geom_Curve)& Path, const TColGeom_SequenceOfCurve& NSections);
190   
191   //! Create  a pipe  with  a constant  radius with  2
192   //! guide-line.
193   Standard_EXPORT void Init (const Handle(Adaptor3d_HCurve)& Path, const Handle(Adaptor3d_HCurve)& Curve1, const Handle(Adaptor3d_HCurve)& Curve2, const Standard_Real Radius);
194   
195
196   //! Initializes this pipe algorithm to build the following surface:
197   //! -   a pipe with a constant circular section of radius
198   //! Radius along the path Path, or
199   //! -   a pipe with constant section FirstSect along the path Path, or
200   //! -   a pipe where the section evolves from FirstSect to
201   //! LastSect along the path Path.
202   //! Use the function Perform to build the surface.
203   //! Note: a description of the resulting surface is given under Constructors.
204   Standard_EXPORT void Init (const Handle(Geom_Curve)& Path, const Handle(Adaptor3d_HCurve)& Guide, const Handle(Geom_Curve)& FirstSect, const Standard_Boolean ByACR, const Standard_Boolean rotat);
205   
206   //! Builds the pipe defined at the time of initialization of this
207   //! algorithm. A description of the resulting surface is given under Constructors.
208   //! If WithParameters (defaulted to false) is set to true, the
209   //! approximation algorithm (used only in the general case
210   //! of construction of a BSpline surface) builds the surface
211   //! with a u parameter corresponding to the one of the path.
212   //! Exceptions
213   //! Standard_ConstructionError if a surface cannot be constructed from the data.
214   //! Warning: It is the old Perform method, the next methode is recommended.
215   Standard_EXPORT void Perform (const Standard_Boolean WithParameters = Standard_False, const Standard_Boolean myPolynomial = Standard_False);
216   
217   //! detects the  particular cases.  And compute the surface.
218   //! if  none   particular  case  is  detected we make an approximation
219   //! with respect of the Tolerance <Tol>, the continuty <Conti>, the
220   //! maximum degree <MaxDegree>, the maximum number of span <NbMaxSegment>
221   //! and the spine parametrization.
222   //! If we can't create a surface with the data
223   Standard_EXPORT void Perform (const Standard_Real Tol, const Standard_Boolean Polynomial, const GeomAbs_Shape Conti = GeomAbs_C1, const Standard_Integer MaxDegree = 11, const Standard_Integer NbMaxSegment = 30);
224   
225   //! Returns the surface built by this algorithm.
226   //! Warning
227   //! Do not use this function before the surface is built (in this
228   //! case the function will return a null handle).
229     const Handle(Geom_Surface)& Surface() const;
230   
231   //! The u parametric direction of the surface constructed by
232   //! this algorithm usually corresponds to the evolution
233   //! along the path and the v parametric direction
234   //! corresponds to the evolution along the section(s).
235   //! However, this rule is not respected when constructing
236   //! certain specific Geom surfaces (typically cylindrical
237   //! surfaces, surfaces of revolution, etc.) for which the
238   //! parameterization is inversed.
239   //! The ExchangeUV function checks for this, and returns
240   //! true in all these specific cases.
241   //! Warning
242   //! Do not use this function before the surface is built.
243   Standard_Boolean ExchangeUV() const;
244   
245   //! Sets a flag  to  try to   create as many   planes,
246   //! cylinder,...    as  possible.  Default  value   is
247   //! <Standard_False>.
248     void GenerateParticularCase (const Standard_Boolean B);
249   
250   //! Returns the flag.
251     Standard_Boolean GenerateParticularCase() const;
252   
253   //! Returns the approximation's error.  if the Surface
254   //! is plane, cylinder ... this error can be 0.
255     Standard_Real ErrorOnSurf() const;
256
257   //! Returns whether approximation was done.
258     Standard_Boolean IsDone() const;
259
260
261
262 protected:
263
264
265
266
267
268 private:
269
270   
271   Standard_EXPORT void Init();
272   
273   //! The result  (<mySurface>)  is an approximation.  Using
274   //! <SweepSectionGenerator>  to      do    that.        If
275   //! <WithParameters>    is   set  to <Standard_True>,  the
276   //! apprxoximation will be   done in respect to  the spine
277   //! parametrization.
278   Standard_EXPORT void ApproxSurf (const Standard_Boolean WithParameters);
279   
280   Standard_EXPORT Standard_Boolean KPartT4();
281
282
283   Standard_Boolean myIsDone;
284   Standard_Real myRadius;
285   Standard_Real myError;
286   Handle(Adaptor3d_HCurve) myAdpPath;
287   Handle(Adaptor3d_HCurve) myAdpFirstSect;
288   Handle(Adaptor3d_HCurve) myAdpLastSect;
289   Handle(Geom_Surface) mySurface;
290   Handle(GeomFill_LocationLaw) myLoc;
291   Handle(GeomFill_SectionLaw) mySec;
292   Standard_Integer myType;
293   Standard_Boolean myExchUV;
294   Standard_Boolean myKPart;
295   Standard_Boolean myPolynomial;
296
297
298 };
299
300
301 #include <GeomFill_Pipe.lxx>
302
303
304
305
306
307 #endif // _GeomFill_Pipe_HeaderFile