Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-09 09:15:30

0001 // Created on: 1994-04-13
0002 // Created by: Eric BONNARDEL
0003 // Copyright (c) 1994-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _GeomFill_Pipe_HeaderFile
0018 #define _GeomFill_Pipe_HeaderFile
0019 
0020 #include <Adaptor3d_Curve.hxx>
0021 #include <GeomFill_Trihedron.hxx>
0022 #include <GeomAbs_Shape.hxx>
0023 #include <TColGeom_SequenceOfCurve.hxx>
0024 #include <GeomFill_PipeError.hxx>
0025 
0026 class Geom_Surface;
0027 class GeomFill_LocationLaw;
0028 class GeomFill_SectionLaw;
0029 class Geom_Curve;
0030 class Geom2d_Curve;
0031 class gp_Dir;
0032 
0033 //! Describes functions to construct pipes. A pipe is built by
0034 //! sweeping a curve (the section) along another curve (the path).
0035 //! The Pipe class provides the following types of construction:
0036 //! -   pipes with a circular section of constant radius,
0037 //! -   pipes with a constant section,
0038 //! -   pipes with a section evolving between two given curves.
0039 //! All standard specific cases are detected in order to build,
0040 //! where required, a plane, cylinder, cone, sphere, torus,
0041 //! surface of linear extrusion or surface of revolution.
0042 //! Generally speaking, the result is a BSpline surface (NURBS).
0043 //! A Pipe object provides a framework for:
0044 //! -   defining the pipe to be built,
0045 //! -   implementing the construction algorithm, and
0046 //! -   consulting the resulting surface.
0047 //! There are several methods to instantiate a Pipe:
0048 //! 1) give a path and  a radius : the section is
0049 //! a circle.  This location  is the first  point
0050 //! of the path,  and this direction is the first
0051 //! derivate (calculate at  the  first point ) of
0052 //! the path.
0053 //!
0054 //! 2) give a path and a section.
0055 //! Differtent options are available
0056 //! 2.a) Use the classical Frenet trihedron
0057 //! - or the CorrectedFrenet trihedron
0058 //! (To avoid twisted surface)
0059 //! - or a constant trihedron to have all the sections
0060 //! in a same plane
0061 //! 2.b) Define a ConstantBinormal Direction to keep the
0062 //! same angle between the Direction and the sections
0063 //! along the sweep surface.
0064 //! 2.c) Define the path by a surface and a 2dcurve,
0065 //! the surface is used to define the trihedron's normal.
0066 //! It is useful to keep a constant angle between
0067 //! input surface and the pipe.                           --
0068 //! 3) give a  path and two sections. The section
0069 //! evaluate from First to Last Section.
0070 //!
0071 //! 3) give a  path and N sections. The section
0072 //! evaluate from First to Last Section.
0073 //!
0074 //! In general case the result is a NURBS. But we
0075 //! can  generate plane,  cylindrical, spherical,
0076 //! conical, toroidal surface in some particular case.
0077 //!
0078 //! The natural parametrization of the result is:
0079 //!
0080 //! U-Direction along the section.
0081 //! V-Direction along the path.
0082 //!
0083 //! But, in some particular case, the surface must
0084 //! be construct otherwise.
0085 //! The method "EchangeUV" return false in such cases.
0086 class GeomFill_Pipe
0087 {
0088 public:
0089   DEFINE_STANDARD_ALLOC
0090 
0091   //! Constructs an empty algorithm for building pipes. Use
0092   //! the function Init to initialize it.
0093   Standard_EXPORT GeomFill_Pipe();
0094 
0095   Standard_EXPORT GeomFill_Pipe(const Handle(Geom_Curve)& Path, const Standard_Real Radius);
0096 
0097   //! Create  a  pipe  with  a  constant  section
0098   //! (<FirstSection>)  and a path (<Path>)
0099   //! Option can be  - GeomFill_IsCorrectedFrenet
0100   //! - GeomFill_IsFrenet
0101   //! - GeomFill_IsConstant
0102   Standard_EXPORT GeomFill_Pipe(const Handle(Geom_Curve)& Path,
0103                                 const Handle(Geom_Curve)& FirstSect,
0104                                 const GeomFill_Trihedron  Option = GeomFill_IsCorrectedFrenet);
0105 
0106   //! Create  a  pipe  with  a  constant  section
0107   //! (<FirstSection>)  and a path defined by <Path> and <Support>
0108   Standard_EXPORT GeomFill_Pipe(const Handle(Geom2d_Curve)& Path,
0109                                 const Handle(Geom_Surface)& Support,
0110                                 const Handle(Geom_Curve)&   FirstSect);
0111 
0112   //! Create  a  pipe with  a  constant section
0113   //! (<FirstSection>) and a   path <Path>  and a fixed
0114   //! binormal direction <Dir>
0115   Standard_EXPORT GeomFill_Pipe(const Handle(Geom_Curve)& Path,
0116                                 const Handle(Geom_Curve)& FirstSect,
0117                                 const gp_Dir&             Dir);
0118 
0119   //! Create a pipe with an evolving section
0120   //! The section evaluate from First to Last Section
0121   Standard_EXPORT GeomFill_Pipe(const Handle(Geom_Curve)& Path,
0122                                 const Handle(Geom_Curve)& FirstSect,
0123                                 const Handle(Geom_Curve)& LastSect);
0124 
0125   //! Create a pipe with N  sections
0126   //! The section evaluate from First to Last Section
0127   Standard_EXPORT GeomFill_Pipe(const Handle(Geom_Curve)&       Path,
0128                                 const TColGeom_SequenceOfCurve& NSections);
0129 
0130   //! Create  a pipe  with  a constant  radius with  2
0131   //! guide-line.
0132   Standard_EXPORT GeomFill_Pipe(const Handle(Geom_Curve)& Path,
0133                                 const Handle(Geom_Curve)& Curve1,
0134                                 const Handle(Geom_Curve)& Curve2,
0135                                 const Standard_Real       Radius);
0136 
0137   //! Create  a pipe  with  a constant  radius with  2
0138   //! guide-line.
0139   Standard_EXPORT GeomFill_Pipe(const Handle(Adaptor3d_Curve)& Path,
0140                                 const Handle(Adaptor3d_Curve)& Curve1,
0141                                 const Handle(Adaptor3d_Curve)& Curve2,
0142                                 const Standard_Real            Radius);
0143 
0144   //! Create a pipe with a constant section and  with 1
0145   //! guide-line.
0146   //! Use the function Perform to build the surface.
0147   //! All standard specific cases are detected in order to
0148   //! construct, according to the respective geometric
0149   //! nature of Path and the sections, a planar, cylindrical,
0150   //! conical, spherical or toroidal surface, a surface of
0151   //! linear extrusion or a surface of revolution.
0152   //! In the general case, the result is a BSpline surface
0153   //! (NURBS) built by approximation of a series of sections where:
0154   //! -   the number of sections N is chosen automatically
0155   //! by the algorithm according to the respective
0156   //! geometries of Path and the sections. N is greater than or equal to 2;
0157   //! -   N points Pi (with i in the range [ 1,N ]) are
0158   //! defined at regular intervals along the curve Path
0159   //! from its first point to its end point. At each point Pi,
0160   //! a coordinate system Ti is computed with Pi as
0161   //! origin, and with the tangential and normal vectors
0162   //! to Path defining two of its coordinate axes.
0163   //! In the case of a pipe with a constant circular section,
0164   //! the first section is a circle of radius Radius centered
0165   //! on the origin of Path and whose "Z Axis" is aligned
0166   //! along the vector tangential to the origin of Path. In the
0167   //! case of a pipe with a constant section, the first section
0168   //! is the curve FirstSect. In these two cases, the ith
0169   //! section (for values of i greater than 1) is obtained by
0170   //! applying to a copy of this first section the geometric
0171   //! transformation which transforms coordinate system
0172   //! T1 into coordinate system Ti.
0173   //! In the case of an evolving section, N-2 intermediate
0174   //! curves Si are first computed (if N is greater than 2,
0175   //! and with i in the range [ 2,N-1 ]) whose geometry
0176   //! evolves regularly from the curve S1=FirstSect to the
0177   //! curve SN=LastSect. The first section is FirstSect,
0178   //! and the ith section (for values of i greater than 1) is
0179   //! obtained by applying to the curve Si the geometric
0180   //! transformation which transforms coordinate system
0181   //! T1 into coordinate system Ti.
0182   Standard_EXPORT GeomFill_Pipe(const Handle(Geom_Curve)&      Path,
0183                                 const Handle(Adaptor3d_Curve)& Guide,
0184                                 const Handle(Geom_Curve)&      FirstSect,
0185                                 const Standard_Boolean         ByACR,
0186                                 const Standard_Boolean         rotat);
0187 
0188   Standard_EXPORT void Init(const Handle(Geom_Curve)& Path, const Standard_Real Radius);
0189 
0190   Standard_EXPORT void Init(const Handle(Geom_Curve)& Path,
0191                             const Handle(Geom_Curve)& FirstSect,
0192                             const GeomFill_Trihedron  Option = GeomFill_IsCorrectedFrenet);
0193 
0194   Standard_EXPORT void Init(const Handle(Geom2d_Curve)& Path,
0195                             const Handle(Geom_Surface)& Support,
0196                             const Handle(Geom_Curve)&   FirstSect);
0197 
0198   Standard_EXPORT void Init(const Handle(Geom_Curve)& Path,
0199                             const Handle(Geom_Curve)& FirstSect,
0200                             const gp_Dir&             Dir);
0201 
0202   Standard_EXPORT void Init(const Handle(Geom_Curve)& Path,
0203                             const Handle(Geom_Curve)& FirstSect,
0204                             const Handle(Geom_Curve)& LastSect);
0205 
0206   Standard_EXPORT void Init(const Handle(Geom_Curve)&       Path,
0207                             const TColGeom_SequenceOfCurve& NSections);
0208 
0209   //! Create  a pipe  with  a constant  radius with  2
0210   //! guide-line.
0211   Standard_EXPORT void Init(const Handle(Adaptor3d_Curve)& Path,
0212                             const Handle(Adaptor3d_Curve)& Curve1,
0213                             const Handle(Adaptor3d_Curve)& Curve2,
0214                             const Standard_Real            Radius);
0215 
0216   //! Initializes this pipe algorithm to build the following surface:
0217   //! -   a pipe with a constant circular section of radius
0218   //! Radius along the path Path, or
0219   //! -   a pipe with constant section FirstSect along the path Path, or
0220   //! -   a pipe where the section evolves from FirstSect to
0221   //! LastSect along the path Path.
0222   //! Use the function Perform to build the surface.
0223   //! Note: a description of the resulting surface is given under Constructors.
0224   Standard_EXPORT void Init(const Handle(Geom_Curve)&      Path,
0225                             const Handle(Adaptor3d_Curve)& Guide,
0226                             const Handle(Geom_Curve)&      FirstSect,
0227                             const Standard_Boolean         ByACR,
0228                             const Standard_Boolean         rotat);
0229 
0230   //! Builds the pipe defined at the time of initialization of this
0231   //! algorithm. A description of the resulting surface is given under Constructors.
0232   //! If WithParameters (defaulted to false) is set to true, the
0233   //! approximation algorithm (used only in the general case
0234   //! of construction of a BSpline surface) builds the surface
0235   //! with a u parameter corresponding to the one of the path.
0236   //! Exceptions
0237   //! Standard_ConstructionError if a surface cannot be constructed from the data.
0238   //! Warning: It is the old Perform method, the next methode is recommended.
0239   Standard_EXPORT void Perform(const Standard_Boolean WithParameters = Standard_False,
0240                                const Standard_Boolean myPolynomial   = Standard_False);
0241 
0242   //! detects the  particular cases.  And compute the surface.
0243   //! if  none   particular  case  is  detected we make an approximation
0244   //! with respect of the Tolerance <Tol>, the continuty <Conti>, the
0245   //! maximum degree <MaxDegree>, the maximum number of span <NbMaxSegment>
0246   //! and the spine parametrization.
0247   //! If we can't create a surface with the data
0248   Standard_EXPORT void Perform(const Standard_Real    Tol,
0249                                const Standard_Boolean Polynomial,
0250                                const GeomAbs_Shape    Conti        = GeomAbs_C1,
0251                                const Standard_Integer MaxDegree    = 11,
0252                                const Standard_Integer NbMaxSegment = 30);
0253 
0254   //! Returns the surface built by this algorithm.
0255   //! Warning
0256   //! Do not use this function before the surface is built (in this
0257   //! case the function will return a null handle).
0258   const Handle(Geom_Surface)& Surface() const;
0259 
0260   //! The u parametric direction of the surface constructed by
0261   //! this algorithm usually corresponds to the evolution
0262   //! along the path and the v parametric direction
0263   //! corresponds to the evolution along the section(s).
0264   //! However, this rule is not respected when constructing
0265   //! certain specific Geom surfaces (typically cylindrical
0266   //! surfaces, surfaces of revolution, etc.) for which the
0267   //! parameterization is inversed.
0268   //! The ExchangeUV function checks for this, and returns
0269   //! true in all these specific cases.
0270   //! Warning
0271   //! Do not use this function before the surface is built.
0272   Standard_Boolean ExchangeUV() const;
0273 
0274   //! Sets a flag  to  try to   create as many   planes,
0275   //! cylinder,...    as  possible.  Default  value   is
0276   //! <Standard_False>.
0277   void GenerateParticularCase(const Standard_Boolean B);
0278 
0279   //! Returns the flag.
0280   Standard_Boolean GenerateParticularCase() const;
0281 
0282   //! Returns the approximation's error.  if the Surface
0283   //! is plane, cylinder ... this error can be 0.
0284   Standard_Real ErrorOnSurf() const;
0285 
0286   //! Returns whether approximation was done.
0287   Standard_Boolean IsDone() const;
0288 
0289   //! Returns execution status
0290   GeomFill_PipeError GetStatus() const { return myStatus; }
0291 
0292 protected:
0293 private:
0294   Standard_EXPORT void Init();
0295 
0296   //! The result  (<mySurface>)  is an approximation.  Using
0297   //! <SweepSectionGenerator>  to      do    that.        If
0298   //! <WithParameters>    is   set  to <Standard_True>,  the
0299   //! apprxoximation will be   done in respect to  the spine
0300   //! parametrization.
0301   Standard_EXPORT void ApproxSurf(const Standard_Boolean WithParameters);
0302 
0303   Standard_EXPORT Standard_Boolean KPartT4();
0304 
0305   GeomFill_PipeError           myStatus; //!< Execution status
0306   Standard_Real                myRadius;
0307   Standard_Real                myError;
0308   Handle(Adaptor3d_Curve)      myAdpPath;
0309   Handle(Adaptor3d_Curve)      myAdpFirstSect;
0310   Handle(Adaptor3d_Curve)      myAdpLastSect;
0311   Handle(Geom_Surface)         mySurface;
0312   Handle(GeomFill_LocationLaw) myLoc;
0313   Handle(GeomFill_SectionLaw)  mySec;
0314   Standard_Integer             myType;
0315   Standard_Boolean             myExchUV;
0316   Standard_Boolean             myKPart;
0317   Standard_Boolean             myPolynomial;
0318 };
0319 
0320 #include <GeomFill_Pipe.lxx>
0321 
0322 #endif // _GeomFill_Pipe_HeaderFile