Back to home page

EIC code displayed by LXR

 
 

    


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

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