Salome HOME
c83e1a9ddde3eacbfb8f664161ffcc2439e44020
[modules/shaper.git] / src / SketchSolver / PlaneGCSSolver / PlaneGCSSolver_GeoExtensions.h
1 // Copyright (C) 2019-2020  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef PlaneGCSSolver_GeomExtensions_H_
21 #define PlaneGCSSolver_GeomExtensions_H_
22
23 #include <PlaneGCSSolver_Defs.h>
24
25 #include <list>
26 #include <memory>
27
28 class GeomAPI_BSpline2d;
29 class GeomAPI_Pnt2d;
30
31 namespace GCS {
32   /// \brife SHAPER's implementation of B-spline curves in PlaneGCS solver
33   class BSplineImpl : public BSpline
34   {
35   public:
36     virtual DeriVector2 Value(double u, double du, double* derivparam = 0);
37     virtual DeriVector2 CalculateNormal(Point &p, double* derivparam = 0);
38
39     virtual BSplineImpl* Copy();
40
41   private:
42     /// Verify the cached curve satisfies to the parameters
43     bool isCacheValid() const;
44     /// Poles or weights are changed, cache curve has to be rebuilt
45     void rebuildCache();
46
47   private:
48     std::shared_ptr<GeomAPI_BSpline2d> myCurve; /// cached B-spline curve
49     std::list<std::shared_ptr<GeomAPI_Pnt2d> > myCachedPoles; /// cached B-spline poles
50     std::list<double> myCachedWeights; /// cached B-spline weights
51     std::list<double> myCachedKnots; /// cached B-spline knots
52     std::list<int> myCachedMultiplicities; /// cached B-spline multiplicities
53   };
54 }
55
56 #endif