Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:39

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 
0090   DEFINE_STANDARD_ALLOC
0091 
0092   
0093 
0094   //! Constructs an empty algorithm for building pipes. Use
0095   //! the function Init to initialize it.
0096   Standard_EXPORT GeomFill_Pipe();
0097   
0098   Standard_EXPORT GeomFill_Pipe(const Handle(Geom_Curve)& Path, const Standard_Real Radius);
0099   
0100   //! Create  a  pipe  with  a  constant  section
0101   //! (<FirstSection>)  and a path (<Path>)
0102   //! Option can be  - GeomFill_IsCorrectedFrenet
0103   //! - GeomFill_IsFrenet
0104   //! - GeomFill_IsConstant
0105   Standard_EXPORT GeomFill_Pipe(const Handle(Geom_Curve)& Path, const Handle(Geom_Curve)& FirstSect, const GeomFill_Trihedron Option = GeomFill_IsCorrectedFrenet);
0106   
0107   //! Create  a  pipe  with  a  constant  section
0108   //! (<FirstSection>)  and a path defined by <Path> and <Support>
0109   Standard_EXPORT GeomFill_Pipe(const Handle(Geom2d_Curve)& Path, const Handle(Geom_Surface)& Support, const Handle(Geom_Curve)& FirstSect);
0110   
0111   //! Create  a  pipe with  a  constant section
0112   //! (<FirstSection>) and a   path <Path>  and a fixed
0113   //! binormal direction <Dir>
0114   Standard_EXPORT GeomFill_Pipe(const Handle(Geom_Curve)& Path, const Handle(Geom_Curve)& FirstSect, const gp_Dir& Dir);
0115   
0116   //! Create a pipe with an evolving section
0117   //! The section evaluate from First to Last Section
0118   Standard_EXPORT GeomFill_Pipe(const Handle(Geom_Curve)& Path, const Handle(Geom_Curve)& FirstSect, const Handle(Geom_Curve)& LastSect);
0119   
0120   //! Create a pipe with N  sections
0121   //! The section evaluate from First to Last Section
0122   Standard_EXPORT GeomFill_Pipe(const Handle(Geom_Curve)& Path, const TColGeom_SequenceOfCurve& NSections);
0123   
0124   //! Create  a pipe  with  a constant  radius with  2
0125   //! guide-line.
0126   Standard_EXPORT GeomFill_Pipe(const Handle(Geom_Curve)& Path, const Handle(Geom_Curve)& Curve1, const Handle(Geom_Curve)& Curve2, const Standard_Real Radius);
0127   
0128   //! Create  a pipe  with  a constant  radius with  2
0129   //! guide-line.
0130   Standard_EXPORT GeomFill_Pipe(const Handle(Adaptor3d_Curve)& Path, const Handle(Adaptor3d_Curve)& Curve1, const Handle(Adaptor3d_Curve)& Curve2, const Standard_Real Radius);
0131   
0132   //! Create a pipe with a constant section and  with 1
0133   //! guide-line.
0134   //! Use the function Perform to build the surface.
0135   //! All standard specific cases are detected in order to
0136   //! construct, according to the respective geometric
0137   //! nature of Path and the sections, a planar, cylindrical,
0138   //! conical, spherical or toroidal surface, a surface of
0139   //! linear extrusion or a surface of revolution.
0140   //! In the general case, the result is a BSpline surface
0141   //! (NURBS) built by approximation of a series of sections where:
0142   //! -   the number of sections N is chosen automatically
0143   //! by the algorithm according to the respective
0144   //! geometries of Path and the sections. N is greater than or equal to 2;
0145   //! -   N points Pi (with i in the range [ 1,N ]) are
0146   //! defined at regular intervals along the curve Path
0147   //! from its first point to its end point. At each point Pi,
0148   //! a coordinate system Ti is computed with Pi as
0149   //! origin, and with the tangential and normal vectors
0150   //! to Path defining two of its coordinate axes.
0151   //! In the case of a pipe with a constant circular section,
0152   //! the first section is a circle of radius Radius centered
0153   //! on the origin of Path and whose "Z Axis" is aligned
0154   //! along the vector tangential to the origin of Path. In the
0155   //! case of a pipe with a constant section, the first section
0156   //! is the curve FirstSect. In these two cases, the ith
0157   //! section (for values of i greater than 1) is obtained by
0158   //! applying to a copy of this first section the geometric
0159   //! transformation which transforms coordinate system
0160   //! T1 into coordinate system Ti.
0161   //! In the case of an evolving section, N-2 intermediate
0162   //! curves Si are first computed (if N is greater than 2,
0163   //! and with i in the range [ 2,N-1 ]) whose geometry
0164   //! evolves regularly from the curve S1=FirstSect to the
0165   //! curve SN=LastSect. The first section is FirstSect,
0166   //! and the ith section (for values of i greater than 1) is
0167   //! obtained by applying to the curve Si the geometric
0168   //! transformation which transforms coordinate system
0169   //! T1 into coordinate system Ti.
0170   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);
0171   
0172   Standard_EXPORT void Init (const Handle(Geom_Curve)& Path, const Standard_Real Radius);
0173   
0174   Standard_EXPORT void Init (const Handle(Geom_Curve)& Path, const Handle(Geom_Curve)& FirstSect, const GeomFill_Trihedron Option = GeomFill_IsCorrectedFrenet);
0175   
0176   Standard_EXPORT void Init (const Handle(Geom2d_Curve)& Path, const Handle(Geom_Surface)& Support, const Handle(Geom_Curve)& FirstSect);
0177   
0178   Standard_EXPORT void Init (const Handle(Geom_Curve)& Path, const Handle(Geom_Curve)& FirstSect, const gp_Dir& Dir);
0179   
0180   Standard_EXPORT void Init (const Handle(Geom_Curve)& Path, const Handle(Geom_Curve)& FirstSect, const Handle(Geom_Curve)& LastSect);
0181   
0182   Standard_EXPORT void Init (const Handle(Geom_Curve)& Path, const TColGeom_SequenceOfCurve& NSections);
0183   
0184   //! Create  a pipe  with  a constant  radius with  2
0185   //! guide-line.
0186   Standard_EXPORT void Init (const Handle(Adaptor3d_Curve)& Path, const Handle(Adaptor3d_Curve)& Curve1, const Handle(Adaptor3d_Curve)& Curve2, const Standard_Real Radius);
0187   
0188 
0189   //! Initializes this pipe algorithm to build the following surface:
0190   //! -   a pipe with a constant circular section of radius
0191   //! Radius along the path Path, or
0192   //! -   a pipe with constant section FirstSect along the path Path, or
0193   //! -   a pipe where the section evolves from FirstSect to
0194   //! LastSect along the path Path.
0195   //! Use the function Perform to build the surface.
0196   //! Note: a description of the resulting surface is given under Constructors.
0197   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);
0198   
0199   //! Builds the pipe defined at the time of initialization of this
0200   //! algorithm. A description of the resulting surface is given under Constructors.
0201   //! If WithParameters (defaulted to false) is set to true, the
0202   //! approximation algorithm (used only in the general case
0203   //! of construction of a BSpline surface) builds the surface
0204   //! with a u parameter corresponding to the one of the path.
0205   //! Exceptions
0206   //! Standard_ConstructionError if a surface cannot be constructed from the data.
0207   //! Warning: It is the old Perform method, the next methode is recommended.
0208   Standard_EXPORT void Perform (const Standard_Boolean WithParameters = Standard_False, const Standard_Boolean myPolynomial = Standard_False);
0209   
0210   //! detects the  particular cases.  And compute the surface.
0211   //! if  none   particular  case  is  detected we make an approximation
0212   //! with respect of the Tolerance <Tol>, the continuty <Conti>, the
0213   //! maximum degree <MaxDegree>, the maximum number of span <NbMaxSegment>
0214   //! and the spine parametrization.
0215   //! If we can't create a surface with the data
0216   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);
0217   
0218   //! Returns the surface built by this algorithm.
0219   //! Warning
0220   //! Do not use this function before the surface is built (in this
0221   //! case the function will return a null handle).
0222     const Handle(Geom_Surface)& Surface() const;
0223   
0224   //! The u parametric direction of the surface constructed by
0225   //! this algorithm usually corresponds to the evolution
0226   //! along the path and the v parametric direction
0227   //! corresponds to the evolution along the section(s).
0228   //! However, this rule is not respected when constructing
0229   //! certain specific Geom surfaces (typically cylindrical
0230   //! surfaces, surfaces of revolution, etc.) for which the
0231   //! parameterization is inversed.
0232   //! The ExchangeUV function checks for this, and returns
0233   //! true in all these specific cases.
0234   //! Warning
0235   //! Do not use this function before the surface is built.
0236   Standard_Boolean ExchangeUV() const;
0237   
0238   //! Sets a flag  to  try to   create as many   planes,
0239   //! cylinder,...    as  possible.  Default  value   is
0240   //! <Standard_False>.
0241     void GenerateParticularCase (const Standard_Boolean B);
0242   
0243   //! Returns the flag.
0244     Standard_Boolean GenerateParticularCase() const;
0245   
0246   //! Returns the approximation's error.  if the Surface
0247   //! is plane, cylinder ... this error can be 0.
0248     Standard_Real ErrorOnSurf() const;
0249 
0250   //! Returns whether approximation was done.
0251     Standard_Boolean IsDone() const;
0252 
0253   //! Returns execution status
0254   GeomFill_PipeError GetStatus() const
0255   {
0256     return myStatus;
0257   }
0258 
0259 protected:
0260 
0261 
0262 
0263 
0264 
0265 private:
0266 
0267   
0268   Standard_EXPORT void Init();
0269   
0270   //! The result  (<mySurface>)  is an approximation.  Using
0271   //! <SweepSectionGenerator>  to      do    that.        If
0272   //! <WithParameters>    is   set  to <Standard_True>,  the
0273   //! apprxoximation will be   done in respect to  the spine
0274   //! parametrization.
0275   Standard_EXPORT void ApproxSurf (const Standard_Boolean WithParameters);
0276   
0277   Standard_EXPORT Standard_Boolean KPartT4();
0278 
0279   GeomFill_PipeError myStatus;//!< Execution status
0280   Standard_Real myRadius;
0281   Standard_Real myError;
0282   Handle(Adaptor3d_Curve) myAdpPath;
0283   Handle(Adaptor3d_Curve) myAdpFirstSect;
0284   Handle(Adaptor3d_Curve) myAdpLastSect;
0285   Handle(Geom_Surface) mySurface;
0286   Handle(GeomFill_LocationLaw) myLoc;
0287   Handle(GeomFill_SectionLaw) mySec;
0288   Standard_Integer myType;
0289   Standard_Boolean myExchUV;
0290   Standard_Boolean myKPart;
0291   Standard_Boolean myPolynomial;
0292 };
0293 
0294 
0295 #include <GeomFill_Pipe.lxx>
0296 
0297 
0298 
0299 
0300 
0301 #endif // _GeomFill_Pipe_HeaderFile