File indexing completed on 2026-09-18 09:20:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef _GeomAdaptor_Surface_HeaderFile
0018 #define _GeomAdaptor_Surface_HeaderFile
0019
0020 #include <Adaptor3d_Curve.hxx>
0021 #include <Adaptor3d_Surface.hxx>
0022 #include <BSplSLib_Cache.hxx>
0023 #include <GeomAbs_Shape.hxx>
0024 #include <Geom_Surface.hxx>
0025 #include <gp_Ax1.hxx>
0026 #include <gp_Cone.hxx>
0027 #include <gp_Cylinder.hxx>
0028 #include <gp_Dir.hxx>
0029 #include <gp_Pln.hxx>
0030 #include <gp_Sphere.hxx>
0031 #include <gp_Torus.hxx>
0032 #include <gp_XYZ.hxx>
0033 #include <Standard_NullObject.hxx>
0034 #include <NCollection_Array1.hxx>
0035
0036 #include <variant>
0037
0038 class GeomAdaptor_Curve;
0039 class Geom_OffsetSurface;
0040 class Geom_BezierSurface;
0041
0042 namespace GeomEval_RepSurfaceDesc
0043 {
0044 class Base;
0045 }
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055 class GeomAdaptor_Surface : public Adaptor3d_Surface
0056 {
0057 DEFINE_STANDARD_RTTIEXT(GeomAdaptor_Surface, Adaptor3d_Surface)
0058 public:
0059
0060 struct ExtrusionData
0061 {
0062 occ::handle<Adaptor3d_Curve> BasisCurve;
0063 gp_XYZ Direction;
0064 occ::handle<GeomEval_RepSurfaceDesc::Base> EvalRep;
0065 };
0066
0067
0068 struct RevolutionData
0069 {
0070 occ::handle<Adaptor3d_Curve> BasisCurve;
0071 gp_Ax1 Axis;
0072 occ::handle<GeomEval_RepSurfaceDesc::Base> EvalRep;
0073 };
0074
0075
0076 struct OffsetData
0077 {
0078 occ::handle<GeomAdaptor_Surface> BasisAdaptor;
0079 occ::handle<GeomAdaptor_Surface>
0080 EquivalentAdaptor;
0081 occ::handle<Geom_OffsetSurface>
0082 OffsetSurface;
0083 double Offset = 0.0;
0084 occ::handle<GeomEval_RepSurfaceDesc::Base> EvalRep;
0085 };
0086
0087
0088 struct BezierData
0089 {
0090 occ::handle<Geom_BezierSurface> Surface;
0091 mutable occ::handle<BSplSLib_Cache> Cache;
0092 occ::handle<GeomEval_RepSurfaceDesc::Base> EvalRep;
0093 };
0094
0095
0096 struct BSplineData
0097 {
0098 occ::handle<Geom_BSplineSurface> Surface;
0099 mutable occ::handle<BSplSLib_Cache> Cache;
0100 occ::handle<GeomEval_RepSurfaceDesc::Base> EvalRep;
0101 };
0102
0103
0104 using SurfaceDataVariant = std::variant<std::monostate,
0105 gp_Pln,
0106 gp_Cylinder,
0107 gp_Cone,
0108 gp_Sphere,
0109 gp_Torus,
0110 ExtrusionData,
0111 RevolutionData,
0112 OffsetData,
0113 BezierData,
0114 BSplineData>;
0115
0116 public:
0117 GeomAdaptor_Surface()
0118 : myUFirst(0.),
0119 myULast(0.),
0120 myVFirst(0.),
0121 myVLast(0.),
0122 myTolU(0.),
0123 myTolV(0.),
0124 mySurfaceType(GeomAbs_OtherSurface)
0125 {
0126 }
0127
0128 GeomAdaptor_Surface(const occ::handle<Geom_Surface>& theSurf)
0129 : myTolU(0.),
0130 myTolV(0.)
0131 {
0132 Load(theSurf);
0133 }
0134
0135
0136 GeomAdaptor_Surface(const occ::handle<Geom_Surface>& theSurf,
0137 const double theUFirst,
0138 const double theULast,
0139 const double theVFirst,
0140 const double theVLast,
0141 const double theTolU = 0.0,
0142 const double theTolV = 0.0)
0143 {
0144 Load(theSurf, theUFirst, theULast, theVFirst, theVLast, theTolU, theTolV);
0145 }
0146
0147
0148 Standard_EXPORT occ::handle<Adaptor3d_Surface> ShallowCopy() const override;
0149
0150 void Load(const occ::handle<Geom_Surface>& theSurf)
0151 {
0152 if (theSurf.IsNull())
0153 {
0154 throw Standard_NullObject("GeomAdaptor_Surface::Load");
0155 }
0156
0157 double aU1, aU2, aV1, aV2;
0158 theSurf->Bounds(aU1, aU2, aV1, aV2);
0159 load(theSurf, aU1, aU2, aV1, aV2);
0160 }
0161
0162
0163 void Load(const occ::handle<Geom_Surface>& theSurf,
0164 const double theUFirst,
0165 const double theULast,
0166 const double theVFirst,
0167 const double theVLast,
0168 const double theTolU = 0.0,
0169 const double theTolV = 0.0)
0170 {
0171 if (theSurf.IsNull())
0172 {
0173 throw Standard_NullObject("GeomAdaptor_Surface::Load");
0174 }
0175 if (theUFirst > theULast || theVFirst > theVLast)
0176 {
0177 throw Standard_ConstructionError("GeomAdaptor_Surface::Load");
0178 }
0179
0180 load(theSurf, theUFirst, theULast, theVFirst, theVLast, theTolU, theTolV);
0181 }
0182
0183 const occ::handle<Geom_Surface>& Surface() const { return mySurface; }
0184
0185 double FirstUParameter() const override { return myUFirst; }
0186
0187 double LastUParameter() const override { return myULast; }
0188
0189 double FirstVParameter() const override { return myVFirst; }
0190
0191 double LastVParameter() const override { return myVLast; }
0192
0193
0194
0195
0196
0197
0198 void Bounds(double& theU1, double& theU2, double& theV1, double& theV2) const
0199 {
0200 theU1 = FirstUParameter();
0201 theU2 = LastUParameter();
0202 theV1 = FirstVParameter();
0203 theV2 = LastVParameter();
0204 }
0205
0206
0207 double ToleranceU() const { return myTolU; }
0208
0209
0210 double ToleranceV() const { return myTolV; }
0211
0212 Standard_EXPORT GeomAbs_Shape UContinuity() const override;
0213
0214 Standard_EXPORT GeomAbs_Shape VContinuity() const override;
0215
0216
0217
0218 Standard_EXPORT int NbUIntervals(const GeomAbs_Shape S) const override;
0219
0220
0221
0222 Standard_EXPORT int NbVIntervals(const GeomAbs_Shape S) const override;
0223
0224
0225
0226 Standard_EXPORT void UIntervals(NCollection_Array1<double>& T,
0227 const GeomAbs_Shape S) const override;
0228
0229
0230
0231 Standard_EXPORT void VIntervals(NCollection_Array1<double>& T,
0232 const GeomAbs_Shape S) const override;
0233
0234
0235
0236
0237
0238
0239 Standard_EXPORT occ::handle<Adaptor3d_Surface> UTrim(const double First,
0240 const double Last,
0241 const double Tol) const override;
0242
0243
0244
0245
0246
0247 Standard_EXPORT occ::handle<Adaptor3d_Surface> VTrim(const double First,
0248 const double Last,
0249 const double Tol) const override;
0250
0251 Standard_EXPORT bool IsUClosed() const override;
0252
0253 Standard_EXPORT bool IsVClosed() const override;
0254
0255 Standard_EXPORT bool IsUPeriodic() const override;
0256
0257 Standard_EXPORT double UPeriod() const override;
0258
0259 Standard_EXPORT bool IsVPeriodic() const override;
0260
0261 Standard_EXPORT double VPeriod() const override;
0262
0263
0264 [[nodiscard]] Standard_EXPORT gp_Pnt EvalD0(const double theU, const double theV) const final;
0265
0266
0267 [[nodiscard]] Standard_EXPORT Geom_Surface::ResD1 EvalD1(const double theU,
0268 const double theV) const final;
0269
0270
0271 [[nodiscard]] Standard_EXPORT Geom_Surface::ResD2 EvalD2(const double theU,
0272 const double theV) const final;
0273
0274
0275 [[nodiscard]] Standard_EXPORT Geom_Surface::ResD3 EvalD3(const double theU,
0276 const double theV) const final;
0277
0278
0279 [[nodiscard]] Standard_EXPORT gp_Vec EvalDN(const double theU,
0280 const double theV,
0281 const int theNu,
0282 const int theNv) const final;
0283
0284
0285
0286 Standard_EXPORT double UResolution(const double R3d) const override;
0287
0288
0289
0290 Standard_EXPORT double VResolution(const double R3d) const override;
0291
0292
0293
0294
0295
0296 GeomAbs_SurfaceType GetType() const override { return mySurfaceType; }
0297
0298 Standard_EXPORT gp_Pln Plane() const override;
0299
0300 Standard_EXPORT gp_Cylinder Cylinder() const override;
0301
0302 Standard_EXPORT gp_Cone Cone() const override;
0303
0304 Standard_EXPORT gp_Sphere Sphere() const override;
0305
0306 Standard_EXPORT gp_Torus Torus() const override;
0307
0308 Standard_EXPORT int UDegree() const override;
0309
0310 Standard_EXPORT int NbUPoles() const override;
0311
0312 Standard_EXPORT int VDegree() const override;
0313
0314 Standard_EXPORT int NbVPoles() const override;
0315
0316 Standard_EXPORT int NbUKnots() const override;
0317
0318 Standard_EXPORT int NbVKnots() const override;
0319
0320 Standard_EXPORT bool IsURational() const override;
0321
0322 Standard_EXPORT bool IsVRational() const override;
0323
0324
0325
0326
0327
0328
0329 Standard_EXPORT occ::handle<Geom_BezierSurface> Bezier() const override;
0330
0331
0332
0333
0334
0335
0336 Standard_EXPORT occ::handle<Geom_BSplineSurface> BSpline() const override;
0337
0338 Standard_EXPORT gp_Ax1 AxeOfRevolution() const override;
0339
0340 Standard_EXPORT gp_Dir Direction() const override;
0341
0342 Standard_EXPORT occ::handle<Adaptor3d_Curve> BasisCurve() const override;
0343
0344 Standard_EXPORT occ::handle<Adaptor3d_Surface> BasisSurface() const override;
0345
0346 Standard_EXPORT double OffsetValue() const override;
0347
0348 private:
0349 Standard_EXPORT void Span(const int Side,
0350 const int Ideb,
0351 const int Ifin,
0352 int& OutIdeb,
0353 int& OutIfin,
0354 const int FKIndx,
0355 const int LKIndx) const;
0356
0357 Standard_EXPORT bool IfUVBound(const double U,
0358 const double V,
0359 int& Ideb,
0360 int& Ifin,
0361 int& IVdeb,
0362 int& IVfin,
0363 const int USide,
0364 const int VSide) const;
0365
0366 Standard_EXPORT void load(const occ::handle<Geom_Surface>& S,
0367 const double UFirst,
0368 const double ULast,
0369 const double VFirst,
0370 const double VLast,
0371 const double TolU = 0.0,
0372 const double TolV = 0.0);
0373
0374
0375
0376
0377 Standard_EXPORT void RebuildCache(const double theU, const double theV) const;
0378
0379 protected:
0380 occ::handle<Geom_Surface> mySurface;
0381 double myUFirst;
0382 double myULast;
0383 double myVFirst;
0384 double myVLast;
0385 double myTolU;
0386 double myTolV;
0387 GeomAbs_SurfaceType mySurfaceType;
0388 SurfaceDataVariant mySurfaceData;
0389 };
0390
0391 #endif