Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-21 09:17:10

0001 // Created on: 1993-07-07
0002 // Created by: Jean Claude VAUTHIER
0003 // Copyright (c) 1993-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 _GeomLib_HeaderFile
0018 #define _GeomLib_HeaderFile
0019 
0020 #include <Adaptor3d_Surface.hxx>
0021 #include <GeomAbs_Shape.hxx>
0022 #include <gp_Pnt.hxx>
0023 #include <NCollection_Array1.hxx>
0024 #include <NCollection_HArray1.hxx>
0025 #include <NCollection_Sequence.hxx>
0026 
0027 class Geom_Curve;
0028 class gp_Ax2;
0029 class Geom2d_Curve;
0030 class gp_GTrsf2d;
0031 class Adaptor3d_CurveOnSurface;
0032 class Geom_BoundedCurve;
0033 class gp_Pnt;
0034 class gp_Vec;
0035 class Geom_BoundedSurface;
0036 class gp_Dir;
0037 class Adaptor3d_Curve;
0038 class Geom_BSplineSurface;
0039 class Geom_BezierSurface;
0040 class Geom_Surface;
0041 
0042 typedef class Adaptor2d_Curve2d Adaptor2d_Curve2d;
0043 
0044 //! Geom Library. This package provides an
0045 //! implementation of functions for basic computation
0046 //! on geometric entity from packages Geom and Geom2d.
0047 class GeomLib
0048 {
0049 public:
0050   DEFINE_STANDARD_ALLOC
0051 
0052   //! Computes the curve 3d from package Geom
0053   //! corresponding to curve 2d from package Geom2d, on
0054   //! the plan defined with the local coordinate system
0055   //! Position.
0056   Standard_EXPORT static occ::handle<Geom_Curve> To3d(const gp_Ax2&                    Position,
0057                                                       const occ::handle<Geom2d_Curve>& Curve2d);
0058 
0059   //! Computes the curve 3d from package Geom
0060   //! corresponding to the curve 3d from package Geom,
0061   //! transformed with the transformation <GTrsf>
0062   //! WARNING : this method may return a null Handle if
0063   //! it's impossible to compute the transformation of
0064   //! a curve. It's not implemented when :
0065   //! 1) the curve is an infinite parabola or hyperbola
0066   //! 2) the curve is an offsetcurve
0067   Standard_EXPORT static occ::handle<Geom2d_Curve> GTransform(
0068     const occ::handle<Geom2d_Curve>& Curve,
0069     const gp_GTrsf2d&                GTrsf);
0070 
0071   //! Make the curve Curve2dPtr have the imposed
0072   //! range First to List the most economic way,
0073   //! that is if it can change the range without
0074   //! changing the nature of the curve it will try
0075   //! to do that. Otherwise it will produce a Bspline
0076   //! curve that has the required range
0077   Standard_EXPORT static void SameRange(const double                     Tolerance,
0078                                         const occ::handle<Geom2d_Curve>& Curve2dPtr,
0079                                         const double                     First,
0080                                         const double                     Last,
0081                                         const double                     RequestedFirst,
0082                                         const double                     RequestedLast,
0083                                         occ::handle<Geom2d_Curve>&       NewCurve2dPtr);
0084 
0085   Standard_EXPORT static void BuildCurve3d(const double              Tolerance,
0086                                            Adaptor3d_CurveOnSurface& CurvePtr,
0087                                            const double              FirstParameter,
0088                                            const double              LastParameter,
0089                                            occ::handle<Geom_Curve>&  NewCurvePtr,
0090                                            double&                   MaxDeviation,
0091                                            double&                   AverageDeviation,
0092                                            const GeomAbs_Shape       Continuity = GeomAbs_C1,
0093                                            const int                 MaxDegree  = 14,
0094                                            const int                 MaxSegment = 30);
0095 
0096   Standard_EXPORT static void AdjustExtremity(occ::handle<Geom_BoundedCurve>& Curve,
0097                                               const gp_Pnt&                   P1,
0098                                               const gp_Pnt&                   P2,
0099                                               const gp_Vec&                   T1,
0100                                               const gp_Vec&                   T2);
0101 
0102   //! Extends the bounded curve Curve to the point Point.
0103   //! The extension is built:
0104   //! -      at the end of the curve if After equals true, or
0105   //! -      at the beginning of the curve if After equals false.
0106   //! The extension is performed according to a degree of
0107   //! continuity equal to Cont, which in its turn must be equal to 1, 2 or 3.
0108   //! This function converts the bounded curve Curve into a BSpline curve.
0109   //! Warning
0110   //! -   Nothing is done, and Curve is not modified if Cont is
0111   //! not equal to 1, 2 or 3.
0112   //! -   It is recommended that the extension should not be
0113   //! too large with respect to the size of the bounded
0114   //! curve Curve: Point must not be located too far from
0115   //! one of the extremities of Curve.
0116   Standard_EXPORT static void ExtendCurveToPoint(occ::handle<Geom_BoundedCurve>& Curve,
0117                                                  const gp_Pnt&                   Point,
0118                                                  const int                       Cont,
0119                                                  const bool                      After);
0120 
0121   //! Extends the bounded surface Surf along one of its
0122   //! boundaries. The chord length of the extension is equal to Length.
0123   //! The direction of the extension is given as:
0124   //! -   the u parametric direction of Surf, if InU equals true, or
0125   //! -   the v parametric direction of Surf, if InU equals false.
0126   //! In this parametric direction, the extension is built on the side of:
0127   //! -   the last parameter of Surf, if After equals true, or
0128   //! -   the first parameter of Surf, if After equals false.
0129   //! The extension is performed according to a degree of
0130   //! continuity equal to Cont, which in its turn must be equal to 1, 2 or 3.
0131   //! This function converts the bounded surface Surf into a BSpline surface.
0132   //! Warning
0133   //! -   Nothing is done, and Surf is not modified if Cont is
0134   //! not equal to 1, 2 or 3.
0135   //! -   It is recommended that Length, the size of the
0136   //! extension should not be too large with respect to the
0137   //! size of the bounded surface Surf.
0138   //! -   Surf must not be a periodic BSpline surface in the
0139   //! parametric direction corresponding to the direction of extension.
0140   Standard_EXPORT static void ExtendSurfByLength(occ::handle<Geom_BoundedSurface>& Surf,
0141                                                  const double                      Length,
0142                                                  const int                         Cont,
0143                                                  const bool                        InU,
0144                                                  const bool                        After);
0145 
0146   //! Compute axes of inertia, of some points
0147   //! <Axe>.Location() is the BaryCentre
0148   //! <Axe>.XDirection is the axe of upper inertia
0149   //! <Axe>.Direction is the Normal to the average plane
0150   //! IsSingular is True if points are on line
0151   //! Tol is used to determine singular cases.
0152   Standard_EXPORT static void AxeOfInertia(const NCollection_Array1<gp_Pnt>& Points,
0153                                            gp_Ax2&                           Axe,
0154                                            bool&                             IsSingular,
0155                                            const double                      Tol = 1.0e-7);
0156 
0157   //! Compute principale axes of inertia, and dispersion
0158   //! value of some points.
0159   Standard_EXPORT static void Inertia(const NCollection_Array1<gp_Pnt>& Points,
0160                                       gp_Pnt&                           Bary,
0161                                       gp_Dir&                           XDir,
0162                                       gp_Dir&                           YDir,
0163                                       double&                           Xgap,
0164                                       double&                           YGap,
0165                                       double&                           ZGap);
0166 
0167   //! Warning! This assume that the InParameter is an increasing sequence
0168   //! of real number and it will not check for that : Unpredictable
0169   //! result can happen if this is not satisfied. It is the caller
0170   //! responsibility to check for that property.
0171   //!
0172   //! This method makes uniform NumPoints segments S1,...SNumPoints out
0173   //! of the segment defined by the first parameter and the
0174   //! last parameter of the InParameter ; keeps only one
0175   //! point of the InParameters set of parameter in each of
0176   //! the uniform segments taking care of the first and the
0177   //! last parameters. For the ith segment the element of
0178   //! the InParameter is the one that is the first to exceed
0179   //! the midpoint of the segment and to fall before the
0180   //! midpoint of the next segment
0181   //! There will be at the end at most NumPoints + 1
0182   //! if NumPoints > 2 in the OutParameters Array
0183   Standard_EXPORT static void RemovePointsFromArray(
0184     const int                                 NumPoints,
0185     const NCollection_Array1<double>&         InParameters,
0186     occ::handle<NCollection_HArray1<double>>& OutParameters);
0187 
0188   //! this makes sure that there is at least MinNumPoints
0189   //! in OutParameters taking into account the parameters in
0190   //! the InParameters array provided those are in order,
0191   //! that is the sequence of real in the InParameter is strictly
0192   //! non decreasing
0193   Standard_EXPORT static void DensifyArray1OfReal(
0194     const int                                 MinNumPoints,
0195     const NCollection_Array1<double>&         InParameters,
0196     occ::handle<NCollection_HArray1<double>>& OutParameters);
0197 
0198   //! This method fuse intervals Interval1 and Interval2 with specified Confusion
0199   //! @param[in] Interval1  first interval to fuse
0200   //! @param[in] Interval2  second interval to fuse
0201   //! @param[in] Confision  tolerance to compare intervals
0202   //! @param[in] IsAdjustToFirstInterval  flag to set method of fusion, if intervals are close
0203   //!                               if false, intervals are fusing by half-division method
0204   //!                               if true, intervals are fusing by selecting value from Interval1
0205   //! @param[out] Fusion  output interval
0206   Standard_EXPORT static void FuseIntervals(const NCollection_Array1<double>& Interval1,
0207                                             const NCollection_Array1<double>& Interval2,
0208                                             NCollection_Sequence<double>&     Fusion,
0209                                             const double                      Confusion = 1.0e-9,
0210                                             const bool IsAdjustToFirstInterval          = false);
0211 
0212   //! this will compute the maximum distance at the
0213   //! parameters given in the Parameters array by
0214   //! evaluating each parameter the two curves and taking
0215   //! the maximum of the evaluated distance
0216   Standard_EXPORT static void EvalMaxParametricDistance(
0217     const Adaptor3d_Curve&            Curve,
0218     const Adaptor3d_Curve&            AReferenceCurve,
0219     const double                      Tolerance,
0220     const NCollection_Array1<double>& Parameters,
0221     double&                           MaxDistance);
0222 
0223   //! this will compute the maximum distance at the parameters
0224   //! given in the Parameters array by projecting from the Curve
0225   //! to the reference curve and taking the minimum distance
0226   //! Than the maximum will be taken on those minimas.
0227   Standard_EXPORT static void EvalMaxDistanceAlongParameter(
0228     const Adaptor3d_Curve&            Curve,
0229     const Adaptor3d_Curve&            AReferenceCurve,
0230     const double                      Tolerance,
0231     const NCollection_Array1<double>& Parameters,
0232     double&                           MaxDistance);
0233 
0234   //! Cancel,on the boundaries,the denominator first derivative
0235   //! in the directions wished by the user and set its value to 1.
0236   Standard_EXPORT static void CancelDenominatorDerivative(occ::handle<Geom_BSplineSurface>& BSurf,
0237                                                           const bool UDirection,
0238                                                           const bool VDirection);
0239 
0240   //! Estimate surface normal at the given (U, V) point.
0241   //! @param[in]  theSurf input surface
0242   //! @param[in]  theUV   (U, V) point coordinates on the surface
0243   //! @param[in]  theTol  estimation tolerance
0244   //! @param[out] theNorm computed normal
0245   //! @return 0 if normal estimated from D1,
0246   //!         1 if estimated from D2 (quasysingular),
0247   //!       >=2 in case of failure (undefined or infinite solutions)
0248   Standard_EXPORT static int NormEstim(const occ::handle<Geom_Surface>& theSurf,
0249                                        const gp_Pnt2d&                  theUV,
0250                                        const double                     theTol,
0251                                        gp_Dir&                          theNorm);
0252 
0253   //! This method defines if opposite boundaries of surface
0254   //! coincide with given tolerance
0255   Standard_EXPORT static void IsClosed(const occ::handle<Geom_Surface>& S,
0256                                        const double                     Tol,
0257                                        bool&                            isUClosed,
0258                                        bool&                            isVClosed);
0259 
0260   //! Returns true if the poles of U1 isoline and the poles of
0261   //! U2 isoline of surface are identical according to tolerance criterion.
0262   //! For rational surfaces Weights(i)*Poles(i) are checked.
0263   Standard_EXPORT static bool IsBSplUClosed(const occ::handle<Geom_BSplineSurface>& S,
0264                                             const double                            U1,
0265                                             const double                            U2,
0266                                             const double                            Tol);
0267 
0268   //! Returns true if the poles of V1 isoline and the poles of
0269   //! V2 isoline of surface are identical according to tolerance criterion.
0270   //! For rational surfaces Weights(i)*Poles(i) are checked.
0271   Standard_EXPORT static bool IsBSplVClosed(const occ::handle<Geom_BSplineSurface>& S,
0272                                             const double                            V1,
0273                                             const double                            V2,
0274                                             const double                            Tol);
0275 
0276   //! Returns true if the poles of U1 isoline and the poles of
0277   //! U2 isoline of surface are identical according to tolerance criterion.
0278   Standard_EXPORT static bool IsBzUClosed(const occ::handle<Geom_BezierSurface>& S,
0279                                           const double                           U1,
0280                                           const double                           U2,
0281                                           const double                           Tol);
0282 
0283   //! Returns true if the poles of V1 isoline and the poles of
0284   //! V2 isoline of surface are identical according to tolerance criterion.
0285   Standard_EXPORT static bool IsBzVClosed(const occ::handle<Geom_BezierSurface>& S,
0286                                           const double                           V1,
0287                                           const double                           V2,
0288                                           const double                           Tol);
0289 
0290   //! Checks whether the 2d curve is a isoline. It can be represented by b-spline, bezier,
0291   //! or geometric line. This line should have natural parameterization.
0292   //! @param theC2D       Trimmed curve to be checked.
0293   //! @param theIsU       Flag indicating that line is u const.
0294   //! @param theParam     Line parameter.
0295   //! @param theIsForward Flag indicating forward parameterization on a isoline.
0296   //! @return true when 2d curve is a line and false otherwise.
0297   Standard_EXPORT static bool isIsoLine(const occ::handle<Adaptor2d_Curve2d>& theC2D,
0298                                         bool&                                 theIsU,
0299                                         double&                               theParam,
0300                                         bool&                                 theIsForward);
0301 
0302   //! Builds 3D curve for a isoline. This method takes corresponding isoline from
0303   //! the input surface.
0304   //! @param theC2D   Trimmed curve to be approximated.
0305   //! @param theIsU   Flag indicating that line is u const.
0306   //! @param theParam Line parameter.
0307   //! @param theIsForward Flag indicating forward parameterization on a isoline.
0308   //! @return true when 3d curve is built and false otherwise.
0309   Standard_EXPORT static occ::handle<Geom_Curve> buildC3dOnIsoLine(
0310     const occ::handle<Adaptor2d_Curve2d>& theC2D,
0311     const occ::handle<Adaptor3d_Surface>& theSurf,
0312     const double                          theFirst,
0313     const double                          theLast,
0314     const double                          theTolerance,
0315     const bool                            theIsU,
0316     const double                          theParam,
0317     const bool                            theIsForward);
0318 };
0319 
0320 #endif // _GeomLib_HeaderFile