Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-28 09:20:06

0001 // Copyright (c) 2025 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _GeomAdaptor_TransformedCurve_HeaderFile
0015 #define _GeomAdaptor_TransformedCurve_HeaderFile
0016 
0017 #include <Adaptor3d_Curve.hxx>
0018 #include <Adaptor3d_CurveOnSurface.hxx>
0019 #include <GeomAdaptor_Curve.hxx>
0020 #include <gp_Trsf.hxx>
0021 
0022 //! An adaptor for curves with an applied transformation.
0023 //!
0024 //! This class wraps a GeomAdaptor_Curve (or an Adaptor3d_CurveOnSurface) and
0025 //! applies a gp_Trsf transformation to all point and derivative evaluations.
0026 //! It serves as a base class for BRepAdaptor_Curve and allows batch evaluation
0027 //! with transformations in GeomGridEval_Curve.
0028 //!
0029 //! The evaluation methods (Value, D0, D1, D2, D3, DN) are marked final
0030 //! to enable optimizations in grid evaluation.
0031 class GeomAdaptor_TransformedCurve : public Adaptor3d_Curve
0032 {
0033   DEFINE_STANDARD_RTTIEXT(GeomAdaptor_TransformedCurve, Adaptor3d_Curve)
0034 public:
0035   //! Creates an undefined curve with identity transformation.
0036   Standard_EXPORT GeomAdaptor_TransformedCurve();
0037 
0038   //! Creates a curve adaptor with transformation.
0039   //! @param theCurve underlying geometry
0040   //! @param theTrsf transformation to apply
0041   Standard_EXPORT GeomAdaptor_TransformedCurve(const occ::handle<Geom_Curve>& theCurve,
0042                                                const gp_Trsf&                 theTrsf);
0043 
0044   //! Creates a curve adaptor with transformation and parameter bounds.
0045   //! @param theCurve underlying geometry
0046   //! @param theFirst minimum parameter
0047   //! @param theLast maximum parameter
0048   //! @param theTrsf transformation to apply
0049   Standard_EXPORT GeomAdaptor_TransformedCurve(const occ::handle<Geom_Curve>& theCurve,
0050                                                const double                   theFirst,
0051                                                const double                   theLast,
0052                                                const gp_Trsf&                 theTrsf);
0053 
0054   //! Shallow copy of adaptor.
0055   Standard_EXPORT occ::handle<Adaptor3d_Curve> ShallowCopy() const override;
0056 
0057   //! Loads the curve geometry.
0058   //! @param theCurve underlying geometry
0059   void Load(const occ::handle<Geom_Curve>& theCurve) { myCurve.Load(theCurve); }
0060 
0061   //! Loads the curve geometry with parameter bounds.
0062   //! @param theCurve underlying geometry
0063   //! @param theFirst minimum parameter
0064   //! @param theLast maximum parameter
0065   void Load(const occ::handle<Geom_Curve>& theCurve, const double theFirst, const double theLast)
0066   {
0067     myCurve.Load(theCurve, theFirst, theLast);
0068   }
0069 
0070   //! Sets the curve on surface adaptor.
0071   //! @param theConSurf curve on surface adaptor
0072   void LoadCurveOnSurface(const occ::handle<Adaptor3d_CurveOnSurface>& theConSurf)
0073   {
0074     myConSurf = theConSurf;
0075   }
0076 
0077   //! Sets the transformation.
0078   //! @param theTrsf transformation to apply
0079   void SetTrsf(const gp_Trsf& theTrsf) { myTrsf = theTrsf; }
0080 
0081   //! Returns the transformation.
0082   const gp_Trsf& Trsf() const { return myTrsf; }
0083 
0084   //! Returns true if the geometry is a 3D curve (not curve on surface).
0085   bool Is3DCurve() const { return myConSurf.IsNull(); }
0086 
0087   //! Returns true if the geometry is a curve on surface.
0088   bool IsCurveOnSurface() const { return !myConSurf.IsNull(); }
0089 
0090   //! Returns the underlying GeomAdaptor_Curve.
0091   const GeomAdaptor_Curve& Curve() const { return myCurve; }
0092 
0093   //! Returns the underlying GeomAdaptor_Curve for modification.
0094   GeomAdaptor_Curve& ChangeCurve() { return myCurve; }
0095 
0096   //! Returns the CurveOnSurface adaptor.
0097   const Adaptor3d_CurveOnSurface& CurveOnSurface() const { return *myConSurf; }
0098 
0099   //! Returns the underlying Geom_Curve.
0100   const occ::handle<Geom_Curve>& GeomCurve() const { return myCurve.Curve(); }
0101 
0102   // Parameter range methods - delegate to underlying curve or COS
0103   double FirstParameter() const override
0104   {
0105     return myConSurf.IsNull() ? myCurve.FirstParameter() : myConSurf->FirstParameter();
0106   }
0107 
0108   double LastParameter() const override
0109   {
0110     return myConSurf.IsNull() ? myCurve.LastParameter() : myConSurf->LastParameter();
0111   }
0112 
0113   GeomAbs_Shape Continuity() const override
0114   {
0115     return myConSurf.IsNull() ? myCurve.Continuity() : myConSurf->Continuity();
0116   }
0117 
0118   int NbIntervals(const GeomAbs_Shape theS) const override
0119   {
0120     return myConSurf.IsNull() ? myCurve.NbIntervals(theS) : myConSurf->NbIntervals(theS);
0121   }
0122 
0123   Standard_EXPORT void Intervals(NCollection_Array1<double>& theT,
0124                                  const GeomAbs_Shape         theS) const override;
0125 
0126   Standard_EXPORT occ::handle<Adaptor3d_Curve> Trim(const double theFirst,
0127                                                     const double theLast,
0128                                                     const double theTol) const override;
0129 
0130   bool IsClosed() const override
0131   {
0132     return myConSurf.IsNull() ? myCurve.IsClosed() : myConSurf->IsClosed();
0133   }
0134 
0135   bool IsPeriodic() const override
0136   {
0137     return myConSurf.IsNull() ? myCurve.IsPeriodic() : myConSurf->IsPeriodic();
0138   }
0139 
0140   double Period() const override
0141   {
0142     return myConSurf.IsNull() ? myCurve.Period() : myConSurf->Period();
0143   }
0144 
0145   //! Point evaluation. Applies transformation after evaluation.
0146   [[nodiscard]] Standard_EXPORT gp_Pnt EvalD0(const double theU) const final;
0147 
0148   //! D1 evaluation. Applies transformation after evaluation.
0149   [[nodiscard]] Standard_EXPORT Geom_Curve::ResD1 EvalD1(const double theU) const final;
0150 
0151   //! D2 evaluation. Applies transformation after evaluation.
0152   [[nodiscard]] Standard_EXPORT Geom_Curve::ResD2 EvalD2(const double theU) const final;
0153 
0154   //! D3 evaluation. Applies transformation after evaluation.
0155   [[nodiscard]] Standard_EXPORT Geom_Curve::ResD3 EvalD3(const double theU) const final;
0156 
0157   //! DN evaluation. Applies transformation after evaluation.
0158   [[nodiscard]] Standard_EXPORT gp_Vec EvalDN(const double theU, const int theN) const final;
0159 
0160   double Resolution(const double theR3d) const override
0161   {
0162     return myConSurf.IsNull() ? myCurve.Resolution(theR3d) : myConSurf->Resolution(theR3d);
0163   }
0164 
0165   GeomAbs_CurveType GetType() const override
0166   {
0167     return myConSurf.IsNull() ? myCurve.GetType() : myConSurf->GetType();
0168   }
0169 
0170   Standard_EXPORT gp_Lin Line() const override;
0171 
0172   Standard_EXPORT gp_Circ Circle() const override;
0173 
0174   Standard_EXPORT gp_Elips Ellipse() const override;
0175 
0176   Standard_EXPORT gp_Hypr Hyperbola() const override;
0177 
0178   Standard_EXPORT gp_Parab Parabola() const override;
0179 
0180   int Degree() const override
0181   {
0182     return myConSurf.IsNull() ? myCurve.Degree() : myConSurf->Degree();
0183   }
0184 
0185   bool IsRational() const override
0186   {
0187     return myConSurf.IsNull() ? myCurve.IsRational() : myConSurf->IsRational();
0188   }
0189 
0190   int NbPoles() const override
0191   {
0192     return myConSurf.IsNull() ? myCurve.NbPoles() : myConSurf->NbPoles();
0193   }
0194 
0195   int NbKnots() const override
0196   {
0197     return myConSurf.IsNull() ? myCurve.NbKnots() : myConSurf->NbKnots();
0198   }
0199 
0200   Standard_EXPORT occ::handle<Geom_BezierCurve> Bezier() const override;
0201 
0202   Standard_EXPORT occ::handle<Geom_BSplineCurve> BSpline() const override;
0203 
0204   Standard_EXPORT occ::handle<Geom_OffsetCurve> OffsetCurve() const override;
0205 
0206 protected:
0207   GeomAdaptor_Curve                     myCurve;
0208   occ::handle<Adaptor3d_CurveOnSurface> myConSurf;
0209   gp_Trsf                               myTrsf;
0210 };
0211 
0212 #endif // _GeomAdaptor_TransformedCurve_HeaderFile