Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created on: 1993-06-03
0002 // Created by: Bruno DUMORTIER
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 _Geom2dAdaptor_Curve_HeaderFile
0018 #define _Geom2dAdaptor_Curve_HeaderFile
0019 
0020 #include <Adaptor2d_Curve2d.hxx>
0021 #include <BSplCLib_Cache.hxx>
0022 #include <Geom2d_Curve.hxx>
0023 #include <Geom2dEvaluator_Curve.hxx>
0024 #include <GeomAbs_CurveType.hxx>
0025 #include <GeomAbs_Shape.hxx>
0026 #include <gp_Pnt2d.hxx>
0027 #include <Standard_NullObject.hxx>
0028 #include <TColStd_Array1OfReal.hxx>
0029 
0030 class gp_Vec2d;
0031 class gp_Lin2d;
0032 class gp_Circ2d;
0033 class gp_Elips2d;
0034 class gp_Hypr2d;
0035 class gp_Parab2d;
0036 class Geom2d_BezierCurve;
0037 class Geom2d_BSplineCurve;
0038 
0039 //! An interface between the services provided by any
0040 //! curve from the package Geom2d and those required
0041 //! of the curve by algorithms which use it.
0042 //!
0043 //! Polynomial coefficients of BSpline curves used for their evaluation are
0044 //! cached for better performance. Therefore these evaluations are not
0045 //! thread-safe and parallel evaluations need to be prevented.
0046 class Geom2dAdaptor_Curve  : public Adaptor2d_Curve2d
0047 {
0048   DEFINE_STANDARD_RTTIEXT(Geom2dAdaptor_Curve, Adaptor2d_Curve2d)
0049 public:
0050 
0051   Standard_EXPORT Geom2dAdaptor_Curve();
0052   
0053   Standard_EXPORT Geom2dAdaptor_Curve(const Handle(Geom2d_Curve)& C);
0054   
0055   //! Standard_ConstructionError is raised if Ufirst>Ulast
0056   Standard_EXPORT Geom2dAdaptor_Curve(const Handle(Geom2d_Curve)& C, const Standard_Real UFirst, const Standard_Real ULast);
0057 
0058   //! Shallow copy of adaptor
0059   Standard_EXPORT virtual Handle(Adaptor2d_Curve2d) ShallowCopy() const Standard_OVERRIDE;
0060 
0061   //! Reset currently loaded curve (undone Load()).
0062   Standard_EXPORT void Reset();
0063 
0064   void Load (const Handle(Geom2d_Curve)& theCurve)
0065   {
0066     if (theCurve.IsNull()) { throw Standard_NullObject(); } 
0067     load (theCurve, theCurve->FirstParameter(), theCurve->LastParameter());
0068   }
0069 
0070   //! Standard_ConstructionError is raised if theUFirst>theULast
0071   void Load (const Handle(Geom2d_Curve)& theCurve, const Standard_Real theUFirst, const Standard_Real theULast)
0072   {
0073     if (theCurve.IsNull()) { throw Standard_NullObject(); }
0074     if (theUFirst > theULast) { throw Standard_ConstructionError(); }
0075     load (theCurve, theUFirst, theULast);
0076   }
0077 
0078   const Handle(Geom2d_Curve)& Curve() const { return myCurve; }
0079 
0080   virtual Standard_Real FirstParameter() const Standard_OVERRIDE { return myFirst; }
0081 
0082   virtual Standard_Real LastParameter() const Standard_OVERRIDE { return myLast; }
0083 
0084   Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE;
0085   
0086   //! If necessary,  breaks the  curve in  intervals  of
0087   //! continuity  <S>.    And  returns   the number   of
0088   //! intervals.
0089   Standard_EXPORT Standard_Integer NbIntervals (const GeomAbs_Shape S) const Standard_OVERRIDE;
0090   
0091   //! Stores in <T> the  parameters bounding the intervals
0092   //! of continuity <S>.
0093   //!
0094   //! The array must provide  enough room to  accommodate
0095   //! for the parameters. i.e. T.Length() > NbIntervals()
0096   Standard_EXPORT void Intervals (TColStd_Array1OfReal& T, const GeomAbs_Shape S) const Standard_OVERRIDE;
0097   
0098   //! Returns    a  curve equivalent   of  <me>  between
0099   //! parameters <First>  and <Last>. <Tol>  is used  to
0100   //! test for 3d points confusion.
0101   //! If <First> >= <Last>
0102   Standard_EXPORT Handle(Adaptor2d_Curve2d) Trim (const Standard_Real First, const Standard_Real Last, const Standard_Real Tol) const Standard_OVERRIDE;
0103   
0104   Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE;
0105   
0106   Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE;
0107   
0108   Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE;
0109   
0110   //! Computes the point of parameter U on the curve
0111   Standard_EXPORT gp_Pnt2d Value (const Standard_Real U) const Standard_OVERRIDE;
0112   
0113   //! Computes the point of parameter U.
0114   Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt2d& P) const Standard_OVERRIDE;
0115   
0116   //! Computes the point of parameter U on the curve with its
0117   //! first derivative.
0118   //! Raised if the continuity of the current interval
0119   //! is not C1.
0120   Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V) const Standard_OVERRIDE;
0121   
0122 
0123   //! Returns the point P of parameter U, the first and second
0124   //! derivatives V1 and V2.
0125   //! Raised if the continuity of the current interval
0126   //! is not C2.
0127   Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const Standard_OVERRIDE;
0128   
0129 
0130   //! Returns the point P of parameter U, the first, the second
0131   //! and the third derivative.
0132   //! Raised if the continuity of the current interval
0133   //! is not C3.
0134   Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2, gp_Vec2d& V3) const Standard_OVERRIDE;
0135   
0136 
0137   //! The returned vector gives the value of the derivative for the
0138   //! order of derivation N.
0139   //! Raised if the continuity of the current interval
0140   //! is not CN.
0141   //! Raised if N < 1.
0142   Standard_EXPORT gp_Vec2d DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE;
0143   
0144   //! returns the parametric resolution
0145   Standard_EXPORT Standard_Real Resolution (const Standard_Real Ruv) const Standard_OVERRIDE;
0146 
0147   virtual GeomAbs_CurveType GetType() const Standard_OVERRIDE { return myTypeCurve; }
0148 
0149   Standard_EXPORT gp_Lin2d Line() const Standard_OVERRIDE;
0150   
0151   Standard_EXPORT gp_Circ2d Circle() const Standard_OVERRIDE;
0152   
0153   Standard_EXPORT gp_Elips2d Ellipse() const Standard_OVERRIDE;
0154   
0155   Standard_EXPORT gp_Hypr2d Hyperbola() const Standard_OVERRIDE;
0156   
0157   Standard_EXPORT gp_Parab2d Parabola() const Standard_OVERRIDE;
0158   
0159   Standard_EXPORT Standard_Integer Degree() const Standard_OVERRIDE;
0160   
0161   Standard_EXPORT Standard_Boolean IsRational() const Standard_OVERRIDE;
0162   
0163   Standard_EXPORT Standard_Integer NbPoles() const Standard_OVERRIDE;
0164   
0165   Standard_EXPORT Standard_Integer NbKnots() const Standard_OVERRIDE;
0166   
0167   Standard_EXPORT virtual Standard_Integer NbSamples() const Standard_OVERRIDE;
0168   
0169   Standard_EXPORT Handle(Geom2d_BezierCurve) Bezier() const Standard_OVERRIDE;
0170   
0171   Standard_EXPORT Handle(Geom2d_BSplineCurve) BSpline() const Standard_OVERRIDE;
0172 
0173 private:
0174 
0175   Standard_EXPORT GeomAbs_Shape LocalContinuity (const Standard_Real U1, const Standard_Real U2) const;
0176   
0177   Standard_EXPORT void load (const Handle(Geom2d_Curve)& C, const Standard_Real UFirst, const Standard_Real ULast);
0178 
0179   //! Check theU relates to start or finish point of B-spline curve and return indices of span the point is located
0180   Standard_Boolean IsBoundary(const Standard_Real theU, Standard_Integer& theSpanStart, Standard_Integer& theSpanFinish) const;
0181 
0182   //! Rebuilds B-spline cache
0183   //! \param theParameter the value on the knot axis which identifies the caching span
0184   void RebuildCache (const Standard_Real theParameter) const;
0185 
0186 protected:
0187 
0188   Handle(Geom2d_Curve) myCurve;
0189   GeomAbs_CurveType myTypeCurve;
0190   Standard_Real myFirst;
0191   Standard_Real myLast;
0192 
0193   Handle(Geom2d_BSplineCurve) myBSplineCurve; ///< B-spline representation to prevent castings
0194   mutable Handle(BSplCLib_Cache) myCurveCache; ///< Cached data for B-spline or Bezier curve
0195   Handle(Geom2dEvaluator_Curve) myNestedEvaluator; ///< Calculates value of offset curve
0196 
0197 };
0198 
0199 DEFINE_STANDARD_HANDLE(Geom2dAdaptor_Curve, Adaptor2d_Curve2d)
0200 
0201 #endif // _Geom2dAdaptor_Curve_HeaderFile