Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created on: 1992-09-01
0002 // Created by: Modelistation
0003 // Copyright (c) 1992-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 _GeomAdaptor_Curve_HeaderFile
0018 #define _GeomAdaptor_Curve_HeaderFile
0019 
0020 #include <Adaptor3d_Curve.hxx>
0021 #include <BSplCLib_Cache.hxx>
0022 #include <Geom_Curve.hxx>
0023 #include <GeomAbs_Shape.hxx>
0024 #include <GeomEvaluator_Curve.hxx>
0025 #include <Standard_NullObject.hxx>
0026 #include <Standard_ConstructionError.hxx>
0027 
0028 DEFINE_STANDARD_HANDLE(GeomAdaptor_Curve, Adaptor3d_Curve)
0029 
0030 //! This class provides an interface between the services provided by any
0031 //! curve from the package Geom and those required of the curve by algorithms which use it.
0032 //! Creation of the loaded curve the curve is C1 by piece.
0033 //!
0034 //! Polynomial coefficients of BSpline curves used for their evaluation are
0035 //! cached for better performance. Therefore these evaluations are not
0036 //! thread-safe and parallel evaluations need to be prevented.
0037 class GeomAdaptor_Curve  : public Adaptor3d_Curve
0038 {
0039   DEFINE_STANDARD_RTTIEXT(GeomAdaptor_Curve, Adaptor3d_Curve)
0040 public:
0041 
0042   GeomAdaptor_Curve() : myTypeCurve (GeomAbs_OtherCurve), myFirst (0.0), myLast (0.0) {}
0043 
0044   GeomAdaptor_Curve (const Handle(Geom_Curve)& theCurve)
0045   {
0046     Load (theCurve);
0047   }
0048 
0049   //! Standard_ConstructionError is raised if theUFirst>theULast
0050   GeomAdaptor_Curve (const Handle(Geom_Curve)& theCurve,
0051                      const Standard_Real theUFirst,
0052                      const Standard_Real theULast)
0053   {
0054     Load (theCurve, theUFirst, theULast);
0055   }
0056 
0057   //! Shallow copy of adaptor
0058   Standard_EXPORT virtual Handle(Adaptor3d_Curve) ShallowCopy() const Standard_OVERRIDE;
0059 
0060   //! Reset currently loaded curve (undone Load()).
0061   Standard_EXPORT void Reset();
0062 
0063   void Load (const Handle(Geom_Curve)& theCurve)
0064   {
0065     if (theCurve.IsNull()) { throw Standard_NullObject(); }
0066     load (theCurve, theCurve->FirstParameter(), theCurve->LastParameter());
0067   }
0068 
0069   //! Standard_ConstructionError is raised if theUFirst>theULast
0070   void Load (const Handle(Geom_Curve)& theCurve,
0071              const Standard_Real theUFirst,
0072              const Standard_Real theULast)
0073   {
0074     if (theCurve.IsNull()) { throw Standard_NullObject(); }
0075     if (theUFirst > theULast) { throw Standard_ConstructionError(); }
0076     load (theCurve, theUFirst, theULast);
0077   }
0078 
0079   //! Provides a curve inherited from Hcurve from Adaptor.
0080   //! This is inherited to provide easy to use constructors.
0081   const Handle(Geom_Curve)& Curve() const { return myCurve; }
0082 
0083   virtual Standard_Real FirstParameter() const Standard_OVERRIDE { return myFirst; }
0084 
0085   virtual Standard_Real LastParameter() const Standard_OVERRIDE { return myLast; }
0086 
0087   Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE;
0088   
0089   //! Returns  the number  of  intervals for  continuity
0090   //! <S>. May be one if Continuity(me) >= <S>
0091   Standard_EXPORT Standard_Integer NbIntervals (const GeomAbs_Shape S) const Standard_OVERRIDE;
0092   
0093   //! Stores in <T> the  parameters bounding the intervals
0094   //! of continuity <S>.
0095   //!
0096   //! The array must provide  enough room to  accommodate
0097   //! for the parameters. i.e. T.Length() > NbIntervals()
0098   Standard_EXPORT void Intervals (TColStd_Array1OfReal& T, const GeomAbs_Shape S) const Standard_OVERRIDE;
0099   
0100   //! Returns    a  curve equivalent   of  <me>  between
0101   //! parameters <First>  and <Last>. <Tol>  is used  to
0102   //! test for 3d points confusion.
0103   //! If <First> >= <Last>
0104   Standard_EXPORT Handle(Adaptor3d_Curve) Trim (const Standard_Real First, const Standard_Real Last, const Standard_Real Tol) const Standard_OVERRIDE;
0105   
0106   Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE;
0107   
0108   Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE;
0109   
0110   Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE;
0111   
0112   //! Computes the point of parameter U on the curve
0113   Standard_EXPORT gp_Pnt Value (const Standard_Real U) const Standard_OVERRIDE;
0114   
0115   //! Computes the point of parameter U.
0116   Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt& P) const Standard_OVERRIDE;
0117   
0118   //! Computes the point of parameter U on the curve
0119   //! with its first derivative.
0120   //!
0121   //! Warning : On the specific case of BSplineCurve:
0122   //! if the curve is cut in interval of continuity at least C1, the
0123   //! derivatives are computed on the current interval.
0124   //! else the derivatives are computed on the basis curve.
0125   Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt& P, gp_Vec& V) const Standard_OVERRIDE;
0126   
0127 
0128   //! Returns the point P of parameter U, the first and second
0129   //! derivatives V1 and V2.
0130   //!
0131   //! Warning : On the specific case of BSplineCurve:
0132   //! if the curve is cut in interval of continuity at least C2, the
0133   //! derivatives are computed on the current interval.
0134   //! else the derivatives are computed on the basis curve.
0135   Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const Standard_OVERRIDE;
0136   
0137 
0138   //! Returns the point P of parameter U, the first, the second
0139   //! and the third derivative.
0140   //!
0141   //! Warning : On the specific case of BSplineCurve:
0142   //! if the curve is cut in interval of continuity at least C3, the
0143   //! derivatives are computed on the current interval.
0144   //! else the derivatives are computed on the basis curve.
0145   Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const Standard_OVERRIDE;
0146   
0147 
0148   //! The returned vector gives the value of the derivative for the
0149   //! order of derivation N.
0150   //! Warning : On the specific case of BSplineCurve:
0151   //! if the curve is cut in interval of continuity CN, the
0152   //! derivatives are computed on the current interval.
0153   //! else the derivatives are computed on the basis curve.
0154   //! Raised if N < 1.
0155   Standard_EXPORT gp_Vec DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE;
0156   
0157   //! returns the parametric resolution
0158   Standard_EXPORT Standard_Real Resolution (const Standard_Real R3d) const Standard_OVERRIDE;
0159 
0160   virtual GeomAbs_CurveType GetType() const Standard_OVERRIDE { return myTypeCurve; }
0161 
0162   Standard_EXPORT gp_Lin Line() const Standard_OVERRIDE;
0163   
0164   Standard_EXPORT gp_Circ Circle() const Standard_OVERRIDE;
0165   
0166   Standard_EXPORT gp_Elips Ellipse() const Standard_OVERRIDE;
0167   
0168   Standard_EXPORT gp_Hypr Hyperbola() const Standard_OVERRIDE;
0169   
0170   Standard_EXPORT gp_Parab Parabola() const Standard_OVERRIDE;
0171   
0172 
0173   //! this should NEVER make a copy
0174   //! of the underlying curve to read
0175   //! the relevant information
0176   Standard_EXPORT Standard_Integer Degree() const Standard_OVERRIDE;
0177   
0178 
0179   //! this should NEVER make a copy
0180   //! of the underlying curve to read
0181   //! the relevant information
0182   Standard_EXPORT Standard_Boolean IsRational() const Standard_OVERRIDE;
0183   
0184 
0185   //! this should NEVER make a copy
0186   //! of the underlying curve to read
0187   //! the relevant information
0188   Standard_EXPORT Standard_Integer NbPoles() const Standard_OVERRIDE;
0189   
0190 
0191   //! this should NEVER make a copy
0192   //! of the underlying curve to read
0193   //! the relevant information
0194   Standard_EXPORT Standard_Integer NbKnots() const Standard_OVERRIDE;
0195   
0196   //! this will NOT make a copy of the
0197   //! Bezier Curve : If you want to modify
0198   //! the Curve please make a copy yourself
0199   //! Also it will NOT trim the surface to
0200   //! myFirst/Last.
0201   Standard_EXPORT Handle(Geom_BezierCurve) Bezier() const Standard_OVERRIDE;
0202   
0203   //! this will NOT make a copy of the
0204   //! BSpline Curve : If you want to modify
0205   //! the Curve please make a copy yourself
0206   //! Also it will NOT trim the surface to
0207   //! myFirst/Last.
0208   Standard_EXPORT Handle(Geom_BSplineCurve) BSpline() const Standard_OVERRIDE;
0209 
0210   Standard_EXPORT Handle(Geom_OffsetCurve) OffsetCurve() const Standard_OVERRIDE;
0211 
0212 friend class GeomAdaptor_Surface;
0213 
0214 private:
0215 
0216   Standard_EXPORT GeomAbs_Shape LocalContinuity (const Standard_Real U1, const Standard_Real U2) const;
0217   
0218   Standard_EXPORT void load (const Handle(Geom_Curve)& C, const Standard_Real UFirst, const Standard_Real ULast);
0219   
0220   //! Check theU relates to start or finish point of B-spline curve and return indices of span the point is located
0221   Standard_Boolean IsBoundary(const Standard_Real theU, Standard_Integer& theSpanStart, Standard_Integer& theSpanFinish) const;
0222 
0223   //! Rebuilds B-spline cache
0224   //! \param theParameter the value on the knot axis which identifies the caching span
0225   void RebuildCache (const Standard_Real theParameter) const;
0226 
0227 private:
0228 
0229   Handle(Geom_Curve) myCurve;
0230   GeomAbs_CurveType myTypeCurve;
0231   Standard_Real myFirst;
0232   Standard_Real myLast;
0233   
0234   Handle(Geom_BSplineCurve) myBSplineCurve; ///< B-spline representation to prevent castings
0235   mutable Handle(BSplCLib_Cache) myCurveCache; ///< Cached data for B-spline or Bezier curve
0236   Handle(GeomEvaluator_Curve) myNestedEvaluator; ///< Calculates value of offset curve
0237 
0238 };
0239 
0240 #endif // _GeomAdaptor_Curve_HeaderFile