File indexing completed on 2026-09-16 09:17:03
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
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 <GeomAbs_CurveType.hxx>
0024 #include <GeomAbs_Shape.hxx>
0025 #include <gp_Circ2d.hxx>
0026 #include <gp_Elips2d.hxx>
0027 #include <gp_Hypr2d.hxx>
0028 #include <gp_Lin2d.hxx>
0029 #include <gp_Parab2d.hxx>
0030 #include <gp_Pnt2d.hxx>
0031 #include <Precision.hxx>
0032 #include <Standard_NullObject.hxx>
0033 #include <NCollection_Array1.hxx>
0034
0035 #include <variant>
0036
0037 class gp_Vec2d;
0038 class Geom2d_BezierCurve;
0039 class Geom2d_BSplineCurve;
0040
0041 namespace Geom2dEval_RepCurveDesc
0042 {
0043 class Base;
0044 }
0045
0046
0047
0048
0049
0050
0051
0052
0053 class Geom2dAdaptor_Curve : public Adaptor2d_Curve2d
0054 {
0055 DEFINE_STANDARD_RTTIEXT(Geom2dAdaptor_Curve, Adaptor2d_Curve2d)
0056 public:
0057
0058 struct OffsetData
0059 {
0060 occ::handle<Geom2dAdaptor_Curve> BasisAdaptor;
0061 double Offset = 0.0;
0062 occ::handle<Geom2dEval_RepCurveDesc::Base> EvalRep;
0063 };
0064
0065
0066 struct BezierData
0067 {
0068 occ::handle<Geom2d_BezierCurve> Curve;
0069 mutable occ::handle<BSplCLib_Cache> Cache;
0070 occ::handle<Geom2dEval_RepCurveDesc::Base> EvalRep;
0071 };
0072
0073
0074 struct BSplineData
0075 {
0076 occ::handle<Geom2d_BSplineCurve> Curve;
0077 mutable occ::handle<BSplCLib_Cache> Cache;
0078 occ::handle<Geom2dEval_RepCurveDesc::Base> EvalRep;
0079 };
0080
0081
0082 using CurveDataVariant = std::variant<std::monostate,
0083 gp_Lin2d,
0084 gp_Circ2d,
0085 gp_Elips2d,
0086 gp_Hypr2d,
0087 gp_Parab2d,
0088 OffsetData,
0089 BezierData,
0090 BSplineData>;
0091
0092 public:
0093 Standard_EXPORT Geom2dAdaptor_Curve();
0094
0095 Standard_EXPORT Geom2dAdaptor_Curve(const occ::handle<Geom2d_Curve>& C);
0096
0097
0098 Standard_EXPORT Geom2dAdaptor_Curve(const occ::handle<Geom2d_Curve>& C,
0099 const double UFirst,
0100 const double ULast);
0101
0102
0103 Standard_EXPORT occ::handle<Adaptor2d_Curve2d> ShallowCopy() const override;
0104
0105
0106 Standard_EXPORT void Reset();
0107
0108 void Load(const occ::handle<Geom2d_Curve>& theCurve)
0109 {
0110 if (theCurve.IsNull())
0111 {
0112 throw Standard_NullObject();
0113 }
0114 load(theCurve, theCurve->FirstParameter(), theCurve->LastParameter());
0115 }
0116
0117
0118 void Load(const occ::handle<Geom2d_Curve>& theCurve,
0119 const double theUFirst,
0120 const double theULast)
0121 {
0122 if (theCurve.IsNull())
0123 {
0124 throw Standard_NullObject();
0125 }
0126 if (theUFirst > theULast + Precision::Confusion())
0127 {
0128 throw Standard_ConstructionError();
0129 }
0130 load(theCurve, theUFirst, theULast);
0131 }
0132
0133
0134 bool IsInitialized() const { return !myCurve.IsNull(); }
0135
0136 const occ::handle<Geom2d_Curve>& Curve() const { return myCurve; }
0137
0138 double FirstParameter() const override { return myFirst; }
0139
0140 double LastParameter() const override { return myLast; }
0141
0142 Standard_EXPORT GeomAbs_Shape Continuity() const override;
0143
0144
0145
0146
0147 Standard_EXPORT int NbIntervals(const GeomAbs_Shape S) const override;
0148
0149
0150
0151
0152
0153
0154 Standard_EXPORT void Intervals(NCollection_Array1<double>& T,
0155 const GeomAbs_Shape S) const override;
0156
0157
0158
0159
0160
0161 Standard_EXPORT occ::handle<Adaptor2d_Curve2d> Trim(const double First,
0162 const double Last,
0163 const double Tol) const override;
0164
0165 Standard_EXPORT bool IsClosed() const override;
0166
0167 Standard_EXPORT bool IsPeriodic() const override;
0168
0169 Standard_EXPORT double Period() const override;
0170
0171
0172 Standard_EXPORT gp_Pnt2d Value(const double U) const final;
0173
0174
0175 Standard_EXPORT void D0(const double U, gp_Pnt2d& P) const final;
0176
0177
0178
0179
0180
0181 Standard_EXPORT void D1(const double U, gp_Pnt2d& P, gp_Vec2d& V) const final;
0182
0183
0184
0185
0186
0187 Standard_EXPORT void D2(const double U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const final;
0188
0189
0190
0191
0192
0193 Standard_EXPORT void D3(const double U,
0194 gp_Pnt2d& P,
0195 gp_Vec2d& V1,
0196 gp_Vec2d& V2,
0197 gp_Vec2d& V3) const final;
0198
0199
0200
0201
0202
0203
0204 Standard_EXPORT gp_Vec2d DN(const double U, const int N) const final;
0205
0206
0207 Standard_EXPORT double Resolution(const double Ruv) const override;
0208
0209 GeomAbs_CurveType GetType() const override { return myTypeCurve; }
0210
0211 Standard_EXPORT gp_Lin2d Line() const override;
0212
0213 Standard_EXPORT gp_Circ2d Circle() const override;
0214
0215 Standard_EXPORT gp_Elips2d Ellipse() const override;
0216
0217 Standard_EXPORT gp_Hypr2d Hyperbola() const override;
0218
0219 Standard_EXPORT gp_Parab2d Parabola() const override;
0220
0221 Standard_EXPORT int Degree() const override;
0222
0223 Standard_EXPORT bool IsRational() const override;
0224
0225 Standard_EXPORT int NbPoles() const override;
0226
0227 Standard_EXPORT int NbKnots() const override;
0228
0229 Standard_EXPORT int NbSamples() const override;
0230
0231 Standard_EXPORT occ::handle<Geom2d_BezierCurve> Bezier() const override;
0232
0233 Standard_EXPORT occ::handle<Geom2d_BSplineCurve> BSpline() const override;
0234
0235
0236 [[nodiscard]] Standard_EXPORT gp_Pnt2d EvalD0(const double theU) const final;
0237
0238
0239 [[nodiscard]] Standard_EXPORT Geom2d_Curve::ResD1 EvalD1(const double theU) const final;
0240
0241
0242 [[nodiscard]] Standard_EXPORT Geom2d_Curve::ResD2 EvalD2(const double theU) const final;
0243
0244
0245 [[nodiscard]] Standard_EXPORT Geom2d_Curve::ResD3 EvalD3(const double theU) const final;
0246
0247
0248 [[nodiscard]] Standard_EXPORT gp_Vec2d EvalDN(const double theU, const int theN) const final;
0249
0250 private:
0251 Standard_EXPORT GeomAbs_Shape LocalContinuity(const double U1, const double U2) const;
0252
0253 Standard_EXPORT void load(const occ::handle<Geom2d_Curve>& C,
0254 const double UFirst,
0255 const double ULast);
0256
0257
0258
0259 bool IsBoundary(const double theU, int& theSpanStart, int& theSpanFinish) const;
0260
0261
0262
0263 void RebuildCache(const double theParameter) const;
0264
0265 protected:
0266 occ::handle<Geom2d_Curve> myCurve;
0267 GeomAbs_CurveType myTypeCurve;
0268 double myFirst;
0269 double myLast;
0270 CurveDataVariant myCurveData;
0271 };
0272
0273 #endif