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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _GeomFill_Pipe_HeaderFile
18 #define _GeomFill_Pipe_HeaderFile
20 #include <Adaptor3d_Curve.hxx>
21 #include <GeomFill_Trihedron.hxx>
22 #include <GeomAbs_Shape.hxx>
23 #include <TColGeom_SequenceOfCurve.hxx>
24 #include <GeomFill_PipeError.hxx>
27 class GeomFill_LocationLaw;
28 class GeomFill_SectionLaw;
33 //! Describes functions to construct pipes. A pipe is built by
34 //! sweeping a curve (the section) along another curve (the path).
35 //! The Pipe class provides the following types of construction:
36 //! - pipes with a circular section of constant radius,
37 //! - pipes with a constant section,
38 //! - pipes with a section evolving between two given curves.
39 //! All standard specific cases are detected in order to build,
40 //! where required, a plane, cylinder, cone, sphere, torus,
41 //! surface of linear extrusion or surface of revolution.
42 //! Generally speaking, the result is a BSpline surface (NURBS).
43 //! A Pipe object provides a framework for:
44 //! - defining the pipe to be built,
45 //! - implementing the construction algorithm, and
46 //! - consulting the resulting surface.
47 //! There are several methods to instantiate a Pipe:
48 //! 1) give a path and a radius : the section is
49 //! a circle. This location is the first point
50 //! of the path, and this direction is the first
51 //! derivate (calculate at the first point ) of
54 //! 2) give a path and a section.
55 //! Differtent options are available
56 //! 2.a) Use the classical Frenet trihedron
57 //! - or the CorrectedFrenet trihedron
58 //! (To avoid twisted surface)
59 //! - or a constant trihedron to have all the sections
61 //! 2.b) Define a ConstantBinormal Direction to keep the
62 //! same angle between the Direction and the sections
63 //! along the sweep surface.
64 //! 2.c) Define the path by a surface and a 2dcurve,
65 //! the surface is used to define the trihedron's normal.
66 //! It is useful to keep a constant angle between
67 //! input surface and the pipe. --
68 //! 3) give a path and two sections. The section
69 //! evaluate from First to Last Section.
71 //! 3) give a path and N sections. The section
72 //! evaluate from First to Last Section.
74 //! In general case the result is a NURBS. But we
75 //! can generate plane, cylindrical, spherical,
76 //! conical, toroidal surface in some particular case.
78 //! The natural parametrization of the result is:
80 //! U-Direction along the section.
81 //! V-Direction along the path.
83 //! But, in some particular case, the surface must
84 //! be construct otherwise.
85 //! The method "EchangeUV" return false in such cases.
94 //! Constructs an empty algorithm for building pipes. Use
95 //! the function Init to initialize it.
96 Standard_EXPORT GeomFill_Pipe();
98 Standard_EXPORT GeomFill_Pipe(const Handle(Geom_Curve)& Path, const Standard_Real Radius);
100 //! Create a pipe with a constant section
101 //! (<FirstSection>) and a path (<Path>)
102 //! Option can be - GeomFill_IsCorrectedFrenet
103 //! - GeomFill_IsFrenet
104 //! - GeomFill_IsConstant
105 Standard_EXPORT GeomFill_Pipe(const Handle(Geom_Curve)& Path, const Handle(Geom_Curve)& FirstSect, const GeomFill_Trihedron Option = GeomFill_IsCorrectedFrenet);
107 //! Create a pipe with a constant section
108 //! (<FirstSection>) and a path defined by <Path> and <Support>
109 Standard_EXPORT GeomFill_Pipe(const Handle(Geom2d_Curve)& Path, const Handle(Geom_Surface)& Support, const Handle(Geom_Curve)& FirstSect);
111 //! Create a pipe with a constant section
112 //! (<FirstSection>) and a path <Path> and a fixed
113 //! binormal direction <Dir>
114 Standard_EXPORT GeomFill_Pipe(const Handle(Geom_Curve)& Path, const Handle(Geom_Curve)& FirstSect, const gp_Dir& Dir);
116 //! Create a pipe with an evolving section
117 //! The section evaluate from First to Last Section
118 Standard_EXPORT GeomFill_Pipe(const Handle(Geom_Curve)& Path, const Handle(Geom_Curve)& FirstSect, const Handle(Geom_Curve)& LastSect);
120 //! Create a pipe with N sections
121 //! The section evaluate from First to Last Section
122 Standard_EXPORT GeomFill_Pipe(const Handle(Geom_Curve)& Path, const TColGeom_SequenceOfCurve& NSections);
124 //! Create a pipe with a constant radius with 2
126 Standard_EXPORT GeomFill_Pipe(const Handle(Geom_Curve)& Path, const Handle(Geom_Curve)& Curve1, const Handle(Geom_Curve)& Curve2, const Standard_Real Radius);
128 //! Create a pipe with a constant radius with 2
130 Standard_EXPORT GeomFill_Pipe(const Handle(Adaptor3d_Curve)& Path, const Handle(Adaptor3d_Curve)& Curve1, const Handle(Adaptor3d_Curve)& Curve2, const Standard_Real Radius);
132 //! Create a pipe with a constant section and with 1
134 //! Use the function Perform to build the surface.
135 //! All standard specific cases are detected in order to
136 //! construct, according to the respective geometric
137 //! nature of Path and the sections, a planar, cylindrical,
138 //! conical, spherical or toroidal surface, a surface of
139 //! linear extrusion or a surface of revolution.
140 //! In the general case, the result is a BSpline surface
141 //! (NURBS) built by approximation of a series of sections where:
142 //! - the number of sections N is chosen automatically
143 //! by the algorithm according to the respective
144 //! geometries of Path and the sections. N is greater than or equal to 2;
145 //! - N points Pi (with i in the range [ 1,N ]) are
146 //! defined at regular intervals along the curve Path
147 //! from its first point to its end point. At each point Pi,
148 //! a coordinate system Ti is computed with Pi as
149 //! origin, and with the tangential and normal vectors
150 //! to Path defining two of its coordinate axes.
151 //! In the case of a pipe with a constant circular section,
152 //! the first section is a circle of radius Radius centered
153 //! on the origin of Path and whose "Z Axis" is aligned
154 //! along the vector tangential to the origin of Path. In the
155 //! case of a pipe with a constant section, the first section
156 //! is the curve FirstSect. In these two cases, the ith
157 //! section (for values of i greater than 1) is obtained by
158 //! applying to a copy of this first section the geometric
159 //! transformation which transforms coordinate system
160 //! T1 into coordinate system Ti.
161 //! In the case of an evolving section, N-2 intermediate
162 //! curves Si are first computed (if N is greater than 2,
163 //! and with i in the range [ 2,N-1 ]) whose geometry
164 //! evolves regularly from the curve S1=FirstSect to the
165 //! curve SN=LastSect. The first section is FirstSect,
166 //! and the ith section (for values of i greater than 1) is
167 //! obtained by applying to the curve Si the geometric
168 //! transformation which transforms coordinate system
169 //! T1 into coordinate system Ti.
170 Standard_EXPORT GeomFill_Pipe(const Handle(Geom_Curve)& Path, const Handle(Adaptor3d_Curve)& Guide, const Handle(Geom_Curve)& FirstSect, const Standard_Boolean ByACR, const Standard_Boolean rotat);
172 Standard_EXPORT void Init (const Handle(Geom_Curve)& Path, const Standard_Real Radius);
174 Standard_EXPORT void Init (const Handle(Geom_Curve)& Path, const Handle(Geom_Curve)& FirstSect, const GeomFill_Trihedron Option = GeomFill_IsCorrectedFrenet);
176 Standard_EXPORT void Init (const Handle(Geom2d_Curve)& Path, const Handle(Geom_Surface)& Support, const Handle(Geom_Curve)& FirstSect);
178 Standard_EXPORT void Init (const Handle(Geom_Curve)& Path, const Handle(Geom_Curve)& FirstSect, const gp_Dir& Dir);
180 Standard_EXPORT void Init (const Handle(Geom_Curve)& Path, const Handle(Geom_Curve)& FirstSect, const Handle(Geom_Curve)& LastSect);
182 Standard_EXPORT void Init (const Handle(Geom_Curve)& Path, const TColGeom_SequenceOfCurve& NSections);
184 //! Create a pipe with a constant radius with 2
186 Standard_EXPORT void Init (const Handle(Adaptor3d_Curve)& Path, const Handle(Adaptor3d_Curve)& Curve1, const Handle(Adaptor3d_Curve)& Curve2, const Standard_Real Radius);
189 //! Initializes this pipe algorithm to build the following surface:
190 //! - a pipe with a constant circular section of radius
191 //! Radius along the path Path, or
192 //! - a pipe with constant section FirstSect along the path Path, or
193 //! - a pipe where the section evolves from FirstSect to
194 //! LastSect along the path Path.
195 //! Use the function Perform to build the surface.
196 //! Note: a description of the resulting surface is given under Constructors.
197 Standard_EXPORT void Init (const Handle(Geom_Curve)& Path, const Handle(Adaptor3d_Curve)& Guide, const Handle(Geom_Curve)& FirstSect, const Standard_Boolean ByACR, const Standard_Boolean rotat);
199 //! Builds the pipe defined at the time of initialization of this
200 //! algorithm. A description of the resulting surface is given under Constructors.
201 //! If WithParameters (defaulted to false) is set to true, the
202 //! approximation algorithm (used only in the general case
203 //! of construction of a BSpline surface) builds the surface
204 //! with a u parameter corresponding to the one of the path.
206 //! Standard_ConstructionError if a surface cannot be constructed from the data.
207 //! Warning: It is the old Perform method, the next methode is recommended.
208 Standard_EXPORT void Perform (const Standard_Boolean WithParameters = Standard_False, const Standard_Boolean myPolynomial = Standard_False);
210 //! detects the particular cases. And compute the surface.
211 //! if none particular case is detected we make an approximation
212 //! with respect of the Tolerance <Tol>, the continuty <Conti>, the
213 //! maximum degree <MaxDegree>, the maximum number of span <NbMaxSegment>
214 //! and the spine parametrization.
215 //! If we can't create a surface with the data
216 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);
218 //! Returns the surface built by this algorithm.
220 //! Do not use this function before the surface is built (in this
221 //! case the function will return a null handle).
222 const Handle(Geom_Surface)& Surface() const;
224 //! The u parametric direction of the surface constructed by
225 //! this algorithm usually corresponds to the evolution
226 //! along the path and the v parametric direction
227 //! corresponds to the evolution along the section(s).
228 //! However, this rule is not respected when constructing
229 //! certain specific Geom surfaces (typically cylindrical
230 //! surfaces, surfaces of revolution, etc.) for which the
231 //! parameterization is inversed.
232 //! The ExchangeUV function checks for this, and returns
233 //! true in all these specific cases.
235 //! Do not use this function before the surface is built.
236 Standard_Boolean ExchangeUV() const;
238 //! Sets a flag to try to create as many planes,
239 //! cylinder,... as possible. Default value is
240 //! <Standard_False>.
241 void GenerateParticularCase (const Standard_Boolean B);
243 //! Returns the flag.
244 Standard_Boolean GenerateParticularCase() const;
246 //! Returns the approximation's error. if the Surface
247 //! is plane, cylinder ... this error can be 0.
248 Standard_Real ErrorOnSurf() const;
250 //! Returns whether approximation was done.
251 Standard_Boolean IsDone() const;
253 //! Returns execution status
254 GeomFill_PipeError GetStatus() const
268 Standard_EXPORT void Init();
270 //! The result (<mySurface>) is an approximation. Using
271 //! <SweepSectionGenerator> to do that. If
272 //! <WithParameters> is set to <Standard_True>, the
273 //! apprxoximation will be done in respect to the spine
275 Standard_EXPORT void ApproxSurf (const Standard_Boolean WithParameters);
277 Standard_EXPORT Standard_Boolean KPartT4();
279 GeomFill_PipeError myStatus;//!< Execution status
280 Standard_Real myRadius;
281 Standard_Real myError;
282 Handle(Adaptor3d_Curve) myAdpPath;
283 Handle(Adaptor3d_Curve) myAdpFirstSect;
284 Handle(Adaptor3d_Curve) myAdpLastSect;
285 Handle(Geom_Surface) mySurface;
286 Handle(GeomFill_LocationLaw) myLoc;
287 Handle(GeomFill_SectionLaw) mySec;
288 Standard_Integer myType;
289 Standard_Boolean myExchUV;
290 Standard_Boolean myKPart;
291 Standard_Boolean myPolynomial;
295 #include <GeomFill_Pipe.lxx>
301 #endif // _GeomFill_Pipe_HeaderFile