Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/opencascade/CSLib.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Created on: 1991-09-09
0002 // Created by: Michel Chauvat
0003 // Copyright (c) 1991-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 _CSLib_HeaderFile
0018 #define _CSLib_HeaderFile
0019 
0020 #include <CSLib_DerivativeStatus.hxx>
0021 #include <CSLib_NormalStatus.hxx>
0022 #include <Standard.hxx>
0023 #include <Standard_DefineAlloc.hxx>
0024 #include <gp_Vec.hxx>
0025 #include <NCollection_Array2.hxx>
0026 
0027 class gp_Dir;
0028 class gp_Vec;
0029 
0030 //! Provides functions for basic geometric computation on curves and surfaces.
0031 //!
0032 //! This package implements functions for computing surface normals
0033 //! and their derivatives at parametric points. The tolerance criteria
0034 //! used are Resolution from gp and RealEpsilon from double.
0035 //!
0036 //! Key functionality:
0037 //! - Normal computation from surface first derivatives (D1U, D1V)
0038 //! - Approximate normal in singular cases using second derivatives
0039 //! - Derivatives of the non-normalized and normalized normal vectors
0040 class CSLib
0041 {
0042 public:
0043   DEFINE_STANDARD_ALLOC
0044 
0045   //! Computes the normal direction of a surface as the cross product D1U ^ D1V.
0046   //!
0047   //! The normal is undefined if:
0048   //! - D1U has null length, or
0049   //! - D1V has null length, or
0050   //! - D1U and D1V are parallel.
0051   //!
0052   //! To check parallelism, the sine of the angle between D1U and D1V
0053   //! is computed and compared with theSinTol.
0054   //!
0055   //! @param[in]  theD1U    First derivative in U direction
0056   //! @param[in]  theD1V    First derivative in V direction
0057   //! @param[in]  theSinTol Sine tolerance for parallelism check
0058   //! @param[out] theStatus Result status indicating success or failure reason
0059   //! @param[out] theNormal Computed normal direction (valid only if theStatus == CSLib_Done)
0060   Standard_EXPORT static void Normal(const gp_Vec&           theD1U,
0061                                      const gp_Vec&           theD1V,
0062                                      double                  theSinTol,
0063                                      CSLib_DerivativeStatus& theStatus,
0064                                      gp_Dir&                 theNormal);
0065 
0066   //! Computes an approximate normal direction at a singular point using second derivatives.
0067   //!
0068   //! When the standard method cannot compute the normal (D1U ^ D1V is null or too small),
0069   //! this method uses a limited Taylor expansion:
0070   //!   N(u0+du, v0+dv) = N0 + dN/du * du + dN/dv * dv + O(du^2, dv^2)
0071   //!
0072   //! The normal is approximated from dN/du and dN/dv where N = D1U ^ D1V.
0073   //!
0074   //! @param[in]  theD1U    First derivative in U direction
0075   //! @param[in]  theD1V    First derivative in V direction
0076   //! @param[in]  theD2U    Second derivative in U direction (d^2S/du^2)
0077   //! @param[in]  theD2V    Second derivative in V direction (d^2S/dv^2)
0078   //! @param[in]  theD2UV   Mixed second derivative (d^2S/dudv)
0079   //! @param[in]  theSinTol Sine tolerance for parallelism check
0080   //! @param[out] theDone   True if normal was successfully computed
0081   //! @param[out] theStatus Result status with detailed information
0082   //! @param[out] theNormal Computed normal direction (valid only if theDone is true)
0083   Standard_EXPORT static void Normal(const gp_Vec&       theD1U,
0084                                      const gp_Vec&       theD1V,
0085                                      const gp_Vec&       theD2U,
0086                                      const gp_Vec&       theD2V,
0087                                      const gp_Vec&       theD2UV,
0088                                      double              theSinTol,
0089                                      bool&               theDone,
0090                                      CSLib_NormalStatus& theStatus,
0091                                      gp_Dir&             theNormal);
0092 
0093   //! Computes the normal direction using magnitude tolerance.
0094   //!
0095   //! A simpler version that checks if the cross product magnitude
0096   //! and derivative magnitudes exceed the given tolerance.
0097   //!
0098   //! @param[in]  theD1U    First derivative in U direction
0099   //! @param[in]  theD1V    First derivative in V direction
0100   //! @param[in]  theMagTol Magnitude tolerance for singularity detection
0101   //! @param[out] theStatus Result status (CSLib_Defined or CSLib_Singular)
0102   //! @param[out] theNormal Computed normal direction (valid only if theStatus == CSLib_Defined)
0103   Standard_EXPORT static void Normal(const gp_Vec&       theD1U,
0104                                      const gp_Vec&       theD1V,
0105                                      double              theMagTol,
0106                                      CSLib_NormalStatus& theStatus,
0107                                      gp_Dir&             theNormal);
0108 
0109   //! Computes the normal at a singular point using higher-order derivatives.
0110   //!
0111   //! Finds the first order k0 where the derivatives of N = D1U ^ D1V become non-null
0112   //! and collinear, ensuring a unique normal direction.
0113   //!
0114   //! @param[in]  theMaxOrder Maximum derivative order to examine
0115   //! @param[in]  theDerNUV   Array of derivatives of N (indices correspond to derivative orders)
0116   //! @param[in]  theMagTol   Magnitude tolerance
0117   //! @param[in]  theU, theV  Current parameter values
0118   //! @param[in]  theUmin, theUmax, theVmin, theVmax  Parameter bounds
0119   //! @param[out] theStatus   Result status
0120   //! @param[out] theNormal   Computed normal direction
0121   //! @param[out] theOrderU, theOrderV  Orders of the first non-null derivative used
0122   Standard_EXPORT static void Normal(int                               theMaxOrder,
0123                                      const NCollection_Array2<gp_Vec>& theDerNUV,
0124                                      double                            theMagTol,
0125                                      double                            theU,
0126                                      double                            theV,
0127                                      double                            theUmin,
0128                                      double                            theUmax,
0129                                      double                            theVmin,
0130                                      double                            theVmax,
0131                                      CSLib_NormalStatus&               theStatus,
0132                                      gp_Dir&                           theNormal,
0133                                      int&                              theOrderU,
0134                                      int&                              theOrderV);
0135 
0136   //! Computes the derivative of order (theNu, theNv) of the non-normalized normal vector.
0137   //!
0138   //! The non-normalized normal is N = dS/du ^ dS/dv.
0139   //! This function computes d^(Nu+Nv)N / (du^Nu * dv^Nv).
0140   //!
0141   //! @param[in] theNu      Derivative order in U direction
0142   //! @param[in] theNv      Derivative order in V direction
0143   //! @param[in] theDerSurf Surface derivatives array where theDerSurf(i,j) = d^(i+j)S/(du^i * dv^j)
0144   //!                       for i = 0..theNu+1, j = 0..theNv+1
0145   //! @return The derivative vector d^(Nu+Nv)N / (du^Nu * dv^Nv)
0146   Standard_EXPORT static gp_Vec DNNUV(int                               theNu,
0147                                       int                               theNv,
0148                                       const NCollection_Array2<gp_Vec>& theDerSurf);
0149 
0150   //! Computes the derivative of the non-normalized vector N = dS1/du ^ dS2/dv.
0151   //!
0152   //! This variant is used for osculating surfaces where the normal
0153   //! is computed from derivatives of two different surfaces.
0154   //!
0155   //! @param[in] theNu       Derivative order in U direction
0156   //! @param[in] theNv       Derivative order in V direction
0157   //! @param[in] theDerSurf1 Derivatives of the first surface S1
0158   //! @param[in] theDerSurf2 Derivatives of the second surface S2
0159   //! @return The derivative vector
0160   Standard_EXPORT static gp_Vec DNNUV(int                               theNu,
0161                                       int                               theNv,
0162                                       const NCollection_Array2<gp_Vec>& theDerSurf1,
0163                                       const NCollection_Array2<gp_Vec>& theDerSurf2);
0164 
0165   //! Computes the derivative of order (theNu, theNv) of the normalized normal vector.
0166   //!
0167   //! @param[in] theNu     Derivative order in U direction
0168   //! @param[in] theNv     Derivative order in V direction
0169   //! @param[in] theDerNUV Array of derivatives of the non-normalized normal.
0170   //!                      Contains derivatives d^(i+j)(D1U^D1V)/(du^i * dv^j)
0171   //!                      for i = theIduref..theNu+theIduref, j = theIdvref..theNv+theIdvref
0172   //! @param[in] theIduref Reference index offset in U (default 0 for regular cases)
0173   //! @param[in] theIdvref Reference index offset in V (default 0 for regular cases)
0174   //! @return The derivative of the normalized normal vector
0175   Standard_EXPORT static gp_Vec DNNormal(int                               theNu,
0176                                          int                               theNv,
0177                                          const NCollection_Array2<gp_Vec>& theDerNUV,
0178                                          int                               theIduref = 0,
0179                                          int                               theIdvref = 0);
0180 };
0181 
0182 #endif // _CSLib_HeaderFile