Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-26 09:02:55

0001 // Created on: 1995-05-30
0002 // Created by: Xavier BENVENISTE
0003 // Copyright (c) 1995-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 _Convert_CompPolynomialToPoles_HeaderFile
0018 #define _Convert_CompPolynomialToPoles_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 #include <Standard_Macro.hxx>
0024 
0025 #include <NCollection_Array1.hxx>
0026 #include <NCollection_HArray1.hxx>
0027 #include <NCollection_Array2.hxx>
0028 #include <NCollection_HArray2.hxx>
0029 
0030 //! Convert a serie of Polynomial N-Dimensional Curves
0031 //! that are have continuity CM to an N-Dimensional Bspline Curve
0032 //! that has continuity CM.
0033 //! (to convert an function (curve) polynomial by span in a BSpline)
0034 //! This class uses the following arguments :
0035 //! NumCurves :  the number of Polynomial Curves
0036 //! Continuity:  the requested continuity for the n-dimensional Spline
0037 //! Dimension :  the dimension of the Spline
0038 //! MaxDegree :  maximum allowed degree for each composite
0039 //! polynomial segment.
0040 //! NumCoeffPerCurve : the number of coefficient per segments = degree - 1
0041 //! Coefficients  :  the coefficients organized in the following way
0042 //! [1..<myNumPolynomials>][1..myMaxDegree +1][1..myDimension]
0043 //! that is : index [n,d,i] is at slot
0044 //! (n-1) * (myMaxDegree + 1) * myDimension + (d-1) * myDimension + i
0045 //! PolynomialIntervals :  nth polynomial represents a polynomial between
0046 //! myPolynomialIntervals->Value(n,0) and
0047 //! myPolynomialIntervals->Value(n,1)
0048 //! TrueIntervals : the nth polynomial has to be mapped linearly to be
0049 //! defined on the following interval :
0050 //! myTrueIntervals->Value(n) and myTrueIntervals->Value(n+1)
0051 //! so that it adequately represents the function with the
0052 //! required continuity
0053 class Convert_CompPolynomialToPoles
0054 {
0055 public:
0056   DEFINE_STANDARD_ALLOC
0057 
0058   //! Warning!
0059   //! Continuity can be at MOST the maximum degree of
0060   //! the polynomial functions
0061   //! TrueIntervals :
0062   //! this is the true parameterisation for the composite curve
0063   //! that is : the curve has myContinuity if the nth curve
0064   //! is parameterized between myTrueIntervals(n) and myTrueIntervals(n+1)
0065   //!
0066   //! Coefficients have to be the implicit "c form":
0067   //! Coefficients[Numcurves][MaxDegree+1][Dimension]
0068   //!
0069   //! Warning!
0070   //! The NumberOfCoefficient of an polynome is his degree + 1
0071   //! Example: To convert the linear function f(x) = 2*x + 1 on the
0072   //! domaine [2,5] to BSpline with the bound [-1,1]. Arguments are :
0073   //! NumCurves  = 1;
0074   //! Continuity = 1;
0075   //! Dimension  = 1;
0076   //! MaxDegree  = 1;
0077   //! NumCoeffPerCurve [1] = {2};
0078   //! Coefficients[2] = {1, 2};
0079   //! PolynomialIntervals[1,2] = {{2,5}}
0080   //! TrueIntervals[2] = {-1, 1}
0081   Standard_EXPORT Convert_CompPolynomialToPoles(
0082     const int                                       NumCurves,
0083     const int                                       Continuity,
0084     const int                                       Dimension,
0085     const int                                       MaxDegree,
0086     const occ::handle<NCollection_HArray1<int>>&    NumCoeffPerCurve,
0087     const occ::handle<NCollection_HArray1<double>>& Coefficients,
0088     const occ::handle<NCollection_HArray2<double>>& PolynomialIntervals,
0089     const occ::handle<NCollection_HArray1<double>>& TrueIntervals);
0090 
0091   //! To Convert several span with different order of Continuity.
0092   //! Warning: The Length of Continuity have to be NumCurves-1
0093   Standard_EXPORT Convert_CompPolynomialToPoles(
0094     const int                         NumCurves,
0095     const int                         Dimension,
0096     const int                         MaxDegree,
0097     const NCollection_Array1<int>&    Continuity,
0098     const NCollection_Array1<int>&    NumCoeffPerCurve,
0099     const NCollection_Array1<double>& Coefficients,
0100     const NCollection_Array2<double>& PolynomialIntervals,
0101     const NCollection_Array1<double>& TrueIntervals);
0102 
0103   //! To Convert only one span.
0104   Standard_EXPORT Convert_CompPolynomialToPoles(
0105     const int                         Dimension,
0106     const int                         MaxDegree,
0107     const int                         Degree,
0108     const NCollection_Array1<double>& Coefficients,
0109     const NCollection_Array1<double>& PolynomialIntervals,
0110     const NCollection_Array1<double>& TrueIntervals);
0111 
0112   //! Returns the number of poles of the n-dimensional BSpline.
0113   [[nodiscard]] Standard_EXPORT int NbPoles() const;
0114 
0115   //! Returns the poles of the n-dimensional BSpline
0116   //! in the following format:
0117   //! [1..NumPoles][1..Dimension]
0118   [[nodiscard]] Standard_EXPORT const NCollection_Array2<double>& Poles() const;
0119 
0120   //! Returns the poles of the n-dimensional BSpline via output parameter.
0121   Standard_DEPRECATED("Use Poles() returning const reference instead")
0122   Standard_EXPORT void Poles(occ::handle<NCollection_HArray2<double>>& thePoles) const;
0123 
0124   //! Returns the degree of the n-dimensional BSpline.
0125   [[nodiscard]] Standard_EXPORT int Degree() const;
0126 
0127   //! Returns the number of knots of the n-dimensional BSpline.
0128   [[nodiscard]] Standard_EXPORT int NbKnots() const;
0129 
0130   //! Returns the knots of the n-dimensional BSpline.
0131   [[nodiscard]] Standard_EXPORT const NCollection_Array1<double>& Knots() const;
0132 
0133   //! Returns the knots of the n-dimensional BSpline via output parameter.
0134   Standard_DEPRECATED("Use Knots() returning const reference instead")
0135   Standard_EXPORT void Knots(occ::handle<NCollection_HArray1<double>>& theKnots) const;
0136 
0137   //! Returns the multiplicities of the knots in the BSpline.
0138   [[nodiscard]] Standard_EXPORT const NCollection_Array1<int>& Multiplicities() const;
0139 
0140   //! Returns the multiplicities of the knots via output parameter.
0141   Standard_DEPRECATED("Use Multiplicities() returning const reference instead")
0142   Standard_EXPORT void Multiplicities(occ::handle<NCollection_HArray1<int>>& theMults) const;
0143 
0144   //! Returns true if the conversion was successful.
0145   [[nodiscard]] Standard_EXPORT bool IsDone() const;
0146 
0147 private:
0148   Standard_EXPORT void Perform(const int                         NumCurves,
0149                                const int                         MaxDegree,
0150                                const int                         Dimension,
0151                                const NCollection_Array1<int>&    NumCoeffPerCurve,
0152                                const NCollection_Array1<double>& Coefficients,
0153                                const NCollection_Array2<double>& PolynomialIntervals,
0154                                const NCollection_Array1<double>& TrueIntervals);
0155 
0156   NCollection_Array1<double> myFlatKnots;
0157   NCollection_Array1<double> myKnots;
0158   NCollection_Array1<int>    myMults;
0159   NCollection_Array2<double> myPoles;
0160   int                        myDegree;
0161   bool                       myDone;
0162 };
0163 
0164 #endif // _Convert_CompPolynomialToPoles_HeaderFile