Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-01 08:59:52

0001 // Created on: 1997-06-24
0002 // Created by: Philippe MANGIN
0003 // Copyright (c) 1997-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 _Approx_SweepApproximation_HeaderFile
0018 #define _Approx_SweepApproximation_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <AdvApprox_EvaluatorFunction.hxx>
0025 #include <NCollection_Array1.hxx>
0026 #include <gp_GTrsf2d.hxx>
0027 #include <NCollection_HArray1.hxx>
0028 #include <GeomAbs_Shape.hxx>
0029 #include <Standard_Integer.hxx>
0030 #include <Standard_OStream.hxx>
0031 #include <NCollection_Array2.hxx>
0032 #include <NCollection_HArray2.hxx>
0033 #include <gp_Pnt2d.hxx>
0034 #include <gp_Pnt.hxx>
0035 #include <gp_Vec.hxx>
0036 #include <gp_Vec2d.hxx>
0037 #include <NCollection_Sequence.hxx>
0038 class Approx_SweepFunction;
0039 class AdvApprox_Cutting;
0040 
0041 //! Approximation of an Surface S(u,v)
0042 //! (and eventually associate 2d Curves) defined
0043 //! by section's law.
0044 //!
0045 //! This surface is defined by a function F(u, v)
0046 //! where Ft(u) = F(u, t) is a bspline curve.
0047 //! To use this algorithm, you have to implement Ft(u)
0048 //! as a derivative class of Approx_SweepFunction.
0049 //! This algorithm can be used by blending, sweeping...
0050 class Approx_SweepApproximation
0051 {
0052 public:
0053   DEFINE_STANDARD_ALLOC
0054 
0055   Standard_EXPORT Approx_SweepApproximation(const occ::handle<Approx_SweepFunction>& Func);
0056 
0057   //! Perform the Approximation
0058   //! [First, Last] : Approx_SweepApproximation.cdl
0059   //! Tol3d : Tolerance to surface approximation
0060   //! Tol2d : Tolerance used to perform curve approximation
0061   //! Normally the 2d curve are approximated with a
0062   //! tolerance given by the resolution on support surfaces,
0063   //! but if this tolerance is too large Tol2d is used.
0064   //! TolAngular : Tolerance (in radian) to control the angle
0065   //! between tangents on the section law and
0066   //! tangent of iso-v on approximated surface
0067   //! Continuity : The continuity in v waiting on the surface
0068   //! Degmax     : The maximum degree in v required on the surface
0069   //! Segmax     : The maximum number of span in v required on
0070   //! the surface
0071   //! Warning : The continuity ci can be obtained only if Ft is Ci
0072   Standard_EXPORT void Perform(const double        First,
0073                                const double        Last,
0074                                const double        Tol3d,
0075                                const double        BoundTol,
0076                                const double        Tol2d,
0077                                const double        TolAngular,
0078                                const GeomAbs_Shape Continuity = GeomAbs_C0,
0079                                const int           Degmax     = 11,
0080                                const int           Segmax     = 50);
0081 
0082   //! The EvaluatorFunction from AdvApprox;
0083   Standard_EXPORT int Eval(const double Parameter,
0084                            const int    DerivativeRequest,
0085                            const double First,
0086                            const double Last,
0087                            double&      Result);
0088 
0089   //! returns if we have an result
0090   bool IsDone() const;
0091 
0092   Standard_EXPORT void SurfShape(int& UDegree,
0093                                  int& VDegree,
0094                                  int& NbUPoles,
0095                                  int& NbVPoles,
0096                                  int& NbUKnots,
0097                                  int& NbVKnots) const;
0098 
0099   Standard_EXPORT void Surface(NCollection_Array2<gp_Pnt>& TPoles,
0100                                NCollection_Array2<double>& TWeights,
0101                                NCollection_Array1<double>& TUKnots,
0102                                NCollection_Array1<double>& TVKnots,
0103                                NCollection_Array1<int>&    TUMults,
0104                                NCollection_Array1<int>&    TVMults) const;
0105 
0106   int UDegree() const;
0107 
0108   int VDegree() const;
0109 
0110   const NCollection_Array2<gp_Pnt>& SurfPoles() const;
0111 
0112   const NCollection_Array2<double>& SurfWeights() const;
0113 
0114   const NCollection_Array1<double>& SurfUKnots() const;
0115 
0116   const NCollection_Array1<double>& SurfVKnots() const;
0117 
0118   const NCollection_Array1<int>& SurfUMults() const;
0119 
0120   const NCollection_Array1<int>& SurfVMults() const;
0121 
0122   //! returns the maximum error in the surface approximation.
0123   Standard_EXPORT double MaxErrorOnSurf() const;
0124 
0125   //! returns the average error in the surface approximation.
0126   Standard_EXPORT double AverageErrorOnSurf() const;
0127 
0128   int NbCurves2d() const;
0129 
0130   Standard_EXPORT void Curves2dShape(int& Degree, int& NbPoles, int& NbKnots) const;
0131 
0132   Standard_EXPORT void Curve2d(const int                     Index,
0133                                NCollection_Array1<gp_Pnt2d>& TPoles,
0134                                NCollection_Array1<double>&   TKnots,
0135                                NCollection_Array1<int>&      TMults) const;
0136 
0137   int Curves2dDegree() const;
0138 
0139   const NCollection_Array1<gp_Pnt2d>& Curve2dPoles(const int Index) const;
0140 
0141   const NCollection_Array1<double>& Curves2dKnots() const;
0142 
0143   const NCollection_Array1<int>& Curves2dMults() const;
0144 
0145   //! returns the maximum error of the <Index>
0146   //! 2d curve approximation.
0147   Standard_EXPORT double Max2dError(const int Index) const;
0148 
0149   //! returns the average error of the <Index>
0150   //! 2d curve approximation.
0151   Standard_EXPORT double Average2dError(const int Index) const;
0152 
0153   //! returns the maximum 3d error of the <Index>
0154   //! 2d curve approximation on the Surface.
0155   Standard_EXPORT double TolCurveOnSurf(const int Index) const;
0156 
0157   //! display information on approximation.
0158   Standard_EXPORT void Dump(Standard_OStream& o) const;
0159 
0160 private:
0161   Standard_EXPORT void Approximation(const occ::handle<NCollection_HArray1<double>>& OneDTol,
0162                                      const occ::handle<NCollection_HArray1<double>>& TwoDTol,
0163                                      const occ::handle<NCollection_HArray1<double>>& ThreeDTol,
0164                                      const double                                    BounTol,
0165                                      const double                                    First,
0166                                      const double                                    Last,
0167                                      const GeomAbs_Shape                             Continuity,
0168                                      const int                                       Degmax,
0169                                      const int                                       Segmax,
0170                                      const AdvApprox_EvaluatorFunction& TheApproxFunction,
0171                                      const AdvApprox_Cutting&           TheCuttingTool);
0172 
0173   Standard_EXPORT bool D0(const double Param,
0174                           const double First,
0175                           const double Last,
0176                           double&      Result);
0177 
0178   Standard_EXPORT bool D1(const double Param,
0179                           const double First,
0180                           const double Last,
0181                           double&      Result);
0182 
0183   Standard_EXPORT bool D2(const double Param,
0184                           const double First,
0185                           const double Last,
0186                           double&      Result);
0187 
0188   occ::handle<Approx_SweepFunction>                                myFunc;
0189   bool                                                             done;
0190   int                                                              Num1DSS;
0191   int                                                              Num2DSS;
0192   int                                                              Num3DSS;
0193   int                                                              udeg;
0194   int                                                              vdeg;
0195   int                                                              deg2d;
0196   occ::handle<NCollection_HArray2<gp_Pnt>>                         tabPoles;
0197   occ::handle<NCollection_HArray2<double>>                         tabWeights;
0198   occ::handle<NCollection_HArray1<double>>                         tabUKnots;
0199   occ::handle<NCollection_HArray1<double>>                         tabVKnots;
0200   occ::handle<NCollection_HArray1<double>>                         tab2dKnots;
0201   occ::handle<NCollection_HArray1<int>>                            tabUMults;
0202   occ::handle<NCollection_HArray1<int>>                            tabVMults;
0203   occ::handle<NCollection_HArray1<int>>                            tab2dMults;
0204   NCollection_Sequence<occ::handle<NCollection_HArray1<gp_Pnt2d>>> seqPoles2d;
0205   occ::handle<NCollection_HArray1<double>>                         MError1d;
0206   occ::handle<NCollection_HArray1<double>>                         tab2dError;
0207   occ::handle<NCollection_HArray1<double>>                         MError3d;
0208   occ::handle<NCollection_HArray1<double>>                         AError1d;
0209   occ::handle<NCollection_HArray1<double>>                         Ave2dError;
0210   occ::handle<NCollection_HArray1<double>>                         AError3d;
0211   occ::handle<NCollection_HArray1<gp_GTrsf2d>>                     AAffin;
0212   occ::handle<NCollection_HArray1<double>>                         COnSurfErr;
0213   gp_Vec                                                           Translation;
0214   occ::handle<NCollection_HArray1<gp_Pnt>>                         myPoles;
0215   occ::handle<NCollection_HArray1<gp_Pnt2d>>                       myPoles2d;
0216   occ::handle<NCollection_HArray1<double>>                         myWeigths;
0217   occ::handle<NCollection_HArray1<gp_Vec>>                         myDPoles;
0218   occ::handle<NCollection_HArray1<gp_Vec>>                         myD2Poles;
0219   occ::handle<NCollection_HArray1<gp_Vec2d>>                       myDPoles2d;
0220   occ::handle<NCollection_HArray1<gp_Vec2d>>                       myD2Poles2d;
0221   occ::handle<NCollection_HArray1<double>>                         myDWeigths;
0222   occ::handle<NCollection_HArray1<double>>                         myD2Weigths;
0223   int                                                              myOrder;
0224   double                                                           myParam;
0225   double                                                           first;
0226   double                                                           last;
0227 };
0228 
0229 #include <Approx_SweepApproximation.lxx>
0230 
0231 #endif // _Approx_SweepApproximation_HeaderFile