File indexing completed on 2026-09-19 09:28:00
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef _gp_Circ_HeaderFile
0016 #define _gp_Circ_HeaderFile
0017
0018 #include <gp_Ax1.hxx>
0019 #include <gp_Ax2.hxx>
0020 #include <gp_Pnt.hxx>
0021 #include <gp_Trsf.hxx>
0022 #include <gp_Vec.hxx>
0023 #include <Standard_ConstructionError.hxx>
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051 class gp_Circ
0052 {
0053 public:
0054 DEFINE_STANDARD_ALLOC
0055
0056
0057 constexpr gp_Circ() noexcept
0058 : radius(RealLast())
0059 {
0060 }
0061
0062
0063
0064
0065
0066 constexpr gp_Circ(const gp_Ax2& theA2, const double theRadius)
0067 : pos(theA2),
0068 radius(theRadius)
0069 {
0070 Standard_ConstructionError_Raise_if(theRadius < 0.0,
0071 "gp_Circ() - radius should be positive number");
0072 }
0073
0074
0075
0076
0077
0078 void SetAxis(const gp_Ax1& theA1) { pos.SetAxis(theA1); }
0079
0080
0081 constexpr void SetLocation(const gp_Pnt& theP) noexcept { pos.SetLocation(theP); }
0082
0083
0084 constexpr void SetPosition(const gp_Ax2& theA2) noexcept { pos = theA2; }
0085
0086
0087
0088
0089
0090 void SetRadius(const double theRadius)
0091 {
0092 Standard_ConstructionError_Raise_if(theRadius < 0.0,
0093 "gp_Circ::SetRadius() - radius should be positive number");
0094 radius = theRadius;
0095 }
0096
0097
0098 constexpr double Area() const noexcept { return M_PI * radius * radius; }
0099
0100
0101
0102
0103 constexpr const gp_Ax1& Axis() const noexcept { return pos.Axis(); }
0104
0105
0106 constexpr double Length() const noexcept { return 2. * M_PI * radius; }
0107
0108
0109
0110
0111 constexpr const gp_Pnt& Location() const noexcept { return pos.Location(); }
0112
0113
0114
0115 constexpr const gp_Ax2& Position() const noexcept { return pos; }
0116
0117
0118 constexpr double Radius() const noexcept { return radius; }
0119
0120
0121
0122
0123 constexpr gp_Ax1 XAxis() const noexcept { return gp_Ax1(pos.Location(), pos.XDirection()); }
0124
0125
0126
0127
0128 constexpr gp_Ax1 YAxis() const noexcept { return gp_Ax1(pos.Location(), pos.YDirection()); }
0129
0130
0131
0132 double Distance(const gp_Pnt& theP) const noexcept { return sqrt(SquareDistance(theP)); }
0133
0134
0135 double SquareDistance(const gp_Pnt& theP) const noexcept
0136 {
0137 gp_Vec aV(Location(), theP);
0138 double aX = aV.Dot(pos.XDirection());
0139 double anY = aV.Dot(pos.YDirection());
0140 double aZ = aV.Dot(pos.Direction());
0141 double aT = sqrt(aX * aX + anY * anY) - radius;
0142 return (aT * aT + aZ * aZ);
0143 }
0144
0145
0146
0147
0148 bool Contains(const gp_Pnt& theP, const double theLinearTolerance) const noexcept
0149 {
0150 return Distance(theP) <= theLinearTolerance;
0151 }
0152
0153 Standard_EXPORT void Mirror(const gp_Pnt& theP) noexcept;
0154
0155
0156
0157
0158 [[nodiscard]] Standard_EXPORT gp_Circ Mirrored(const gp_Pnt& theP) const noexcept;
0159
0160 Standard_EXPORT void Mirror(const gp_Ax1& theA1);
0161
0162
0163
0164
0165 [[nodiscard]] Standard_EXPORT gp_Circ Mirrored(const gp_Ax1& theA1) const;
0166
0167 Standard_EXPORT void Mirror(const gp_Ax2& theA2);
0168
0169
0170
0171
0172 [[nodiscard]] Standard_EXPORT gp_Circ Mirrored(const gp_Ax2& theA2) const;
0173
0174 void Rotate(const gp_Ax1& theA1, const double theAng) { pos.Rotate(theA1, theAng); }
0175
0176
0177
0178 [[nodiscard]] gp_Circ Rotated(const gp_Ax1& theA1, const double theAng) const
0179 {
0180 gp_Circ aC = *this;
0181 aC.pos.Rotate(theA1, theAng);
0182 return aC;
0183 }
0184
0185 void Scale(const gp_Pnt& theP, const double theS);
0186
0187
0188
0189
0190
0191
0192 [[nodiscard]] gp_Circ Scaled(const gp_Pnt& theP, const double theS) const;
0193
0194 void Transform(const gp_Trsf& theT);
0195
0196
0197 [[nodiscard]] gp_Circ Transformed(const gp_Trsf& theT) const;
0198
0199 constexpr void Translate(const gp_Vec& theV) noexcept { pos.Translate(theV); }
0200
0201
0202
0203 [[nodiscard]] constexpr gp_Circ Translated(const gp_Vec& theV) const noexcept
0204 {
0205 gp_Circ aC = *this;
0206 aC.pos.Translate(theV);
0207 return aC;
0208 }
0209
0210 constexpr void Translate(const gp_Pnt& theP1, const gp_Pnt& theP2) noexcept
0211 {
0212 pos.Translate(theP1, theP2);
0213 }
0214
0215
0216 [[nodiscard]] constexpr gp_Circ Translated(const gp_Pnt& theP1,
0217 const gp_Pnt& theP2) const noexcept
0218 {
0219 gp_Circ aC = *this;
0220 aC.pos.Translate(theP1, theP2);
0221 return aC;
0222 }
0223
0224 private:
0225 gp_Ax2 pos;
0226 double radius;
0227 };
0228
0229
0230
0231 inline void gp_Circ::Scale(const gp_Pnt& theP, const double theS)
0232 {
0233 radius *= theS;
0234 if (radius < 0)
0235 {
0236 radius = -radius;
0237 }
0238 pos.Scale(theP, theS);
0239 }
0240
0241
0242
0243 inline gp_Circ gp_Circ::Scaled(const gp_Pnt& theP, const double theS) const
0244 {
0245 gp_Circ aC = *this;
0246 aC.radius *= theS;
0247 if (aC.radius < 0)
0248 {
0249 aC.radius = -aC.radius;
0250 }
0251 aC.pos.Scale(theP, theS);
0252 return aC;
0253 }
0254
0255
0256
0257 inline void gp_Circ::Transform(const gp_Trsf& theT)
0258 {
0259 radius *= theT.ScaleFactor();
0260 if (radius < 0)
0261 {
0262 radius = -radius;
0263 }
0264 pos.Transform(theT);
0265 }
0266
0267
0268
0269 inline gp_Circ gp_Circ::Transformed(const gp_Trsf& theT) const
0270 {
0271 gp_Circ aC = *this;
0272 aC.radius *= theT.ScaleFactor();
0273 if (aC.radius < 0)
0274 {
0275 aC.radius = -aC.radius;
0276 }
0277 aC.pos.Transform(theT);
0278 return aC;
0279 }
0280
0281 #endif