File indexing completed on 2026-09-28 09:20:09
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef _GeomEval_RepSurfaceDesc_HeaderFile
0015 #define _GeomEval_RepSurfaceDesc_HeaderFile
0016
0017 #include <Geom_Surface.hxx>
0018 #include <Precision.hxx>
0019 #include <Standard_Transient.hxx>
0020
0021 #include <cmath>
0022 #include <cstddef>
0023 #include <optional>
0024
0025 namespace GeomEval_RepSurfaceDesc
0026 {
0027
0028
0029
0030 struct Map2d
0031 {
0032 double ScaleU = 1.0;
0033 double OffsetU = 0.0;
0034 double ScaleV = 1.0;
0035 double OffsetV = 0.0;
0036 bool SwapUV = false;
0037
0038 bool IsIdentity() const
0039 {
0040 return std::abs(ScaleU - 1.0) < Precision::Confusion()
0041 && std::abs(ScaleV - 1.0) < Precision::Confusion()
0042 && std::abs(OffsetU) < Precision::Confusion()
0043 && std::abs(OffsetV) < Precision::Confusion() && !SwapUV;
0044 }
0045
0046 bool IsValid() const
0047 {
0048 return std::abs(ScaleU) > Precision::Confusion() && std::abs(ScaleV) > Precision::Confusion();
0049 }
0050
0051 void Map(const double theU, const double theV, double& theURep, double& theVRep) const
0052 {
0053 if (SwapUV)
0054 {
0055 theURep = ScaleU * theV + OffsetU;
0056 theVRep = ScaleV * theU + OffsetV;
0057 }
0058 else
0059 {
0060 theURep = ScaleU * theU + OffsetU;
0061 theVRep = ScaleV * theV + OffsetV;
0062 }
0063 }
0064 };
0065
0066
0067 struct Domain2d
0068 {
0069 double UFirst = 0.0;
0070 double ULast = 1.0;
0071 double VFirst = 0.0;
0072 double VLast = 1.0;
0073
0074 bool Contains(const double theU, const double theV) const
0075 {
0076 return (theU >= UFirst - Precision::Confusion()) && (theU <= ULast + Precision::Confusion())
0077 && (theV >= VFirst - Precision::Confusion()) && (theV <= VLast + Precision::Confusion());
0078 }
0079 };
0080
0081
0082
0083 class Base : public Standard_Transient
0084 {
0085 public:
0086
0087 enum class Kind
0088 {
0089 Full,
0090 DerivBounded,
0091 Mapped
0092 };
0093
0094 occ::handle<Geom_Surface> Representation;
0095
0096
0097 virtual Kind GetKind() const = 0;
0098
0099 DEFINE_STANDARD_RTTI_INLINE(Base, Standard_Transient)
0100
0101 protected:
0102 Base() = default;
0103 };
0104
0105
0106
0107 class Full : public Base
0108 {
0109 public:
0110 Kind GetKind() const override { return Kind::Full; }
0111
0112 DEFINE_STANDARD_RTTI_INLINE(Full, Base)
0113 };
0114
0115
0116 class DerivBounded : public Base
0117 {
0118 public:
0119 std::size_t MaxDerivOrder = 3;
0120
0121 Kind GetKind() const override { return Kind::DerivBounded; }
0122
0123 DEFINE_STANDARD_RTTI_INLINE(DerivBounded, Base)
0124 };
0125
0126
0127
0128
0129
0130 class Mapped : public Base
0131 {
0132 public:
0133 std::size_t MaxDerivOrder = 3;
0134 std::optional<Domain2d> Domain;
0135 Map2d ParamMap;
0136
0137 Kind GetKind() const override { return Kind::Mapped; }
0138
0139 DEFINE_STANDARD_RTTI_INLINE(Mapped, Base)
0140 };
0141 }
0142
0143 #endif