|
|
|||
File indexing completed on 2026-06-26 08:28:32
0001 // Created on: 1993-03-24 0002 // Created by: Philippe DAUTRY 0003 // Copyright (c) 1993-1999 Matra Datavision 0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS 0005 // 0006 // This file is part of Open CASCADE Technology software library. 0007 // 0008 // This library is free software; you can redistribute it and/or modify it under 0009 // the terms of the GNU Lesser General Public License version 2.1 as published 0010 // by the Free Software Foundation, with special exception defined in the file 0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0012 // distribution for complete text of the license and disclaimer of any warranty. 0013 // 0014 // Alternatively, this file may be used under the terms of Open CASCADE 0015 // commercial license or contractual agreement. 0016 0017 #ifndef _Geom2d_OffsetCurve_HeaderFile 0018 #define _Geom2d_OffsetCurve_HeaderFile 0019 0020 #include <Standard.hxx> 0021 #include <Standard_Type.hxx> 0022 0023 #include <GeomAbs_Shape.hxx> 0024 #include <Geom2d_Curve.hxx> 0025 #include <Standard_Integer.hxx> 0026 #include <Geom2dEvaluator_OffsetCurve.hxx> 0027 0028 class gp_Pnt2d; 0029 class gp_Vec2d; 0030 class gp_Trsf2d; 0031 class Geom2d_Geometry; 0032 0033 class Geom2d_OffsetCurve; 0034 DEFINE_STANDARD_HANDLE(Geom2d_OffsetCurve, Geom2d_Curve) 0035 0036 //! This class implements the basis services for the creation, 0037 //! edition, modification and evaluation of planar offset curve. 0038 //! The offset curve is obtained by offsetting by distance along 0039 //! the normal to a basis curve defined in 2D space. 0040 //! The offset curve in this package can be a self intersecting 0041 //! curve even if the basis curve does not self-intersect. 0042 //! The self intersecting portions are not deleted at the 0043 //! construction time. 0044 //! An offset curve is a curve at constant distance (Offset) from a 0045 //! basis curve and the offset curve takes its parametrization from 0046 //! the basis curve. The Offset curve is in the direction of the 0047 //! normal to the basis curve N. 0048 //! The distance offset may be positive or negative to indicate the 0049 //! preferred side of the curve : 0050 //! . distance offset >0 => the curve is in the direction of N 0051 //! . distance offset >0 => the curve is in the direction of - N 0052 //! On the Offset curve : 0053 //! Value(u) = BasisCurve.Value(U) + (Offset * (T ^ Z)) / ||T ^ Z|| 0054 //! where T is the tangent vector to the basis curve and Z the 0055 //! direction of the normal vector to the plane of the curve, 0056 //! N = T ^ Z defines the offset direction and should not have 0057 //! null length. 0058 //! 0059 //! Warnings : 0060 //! In this package we suppose that the continuity of the offset 0061 //! curve is one degree less than the continuity of the 0062 //! basis curve and we don't check that at any point ||T^Z|| != 0.0 0063 //! 0064 //! So to evaluate the curve it is better to check that the offset 0065 //! curve is well defined at any point because an exception could 0066 //! be raised. The check is not done in this package at the creation 0067 //! of the offset curve because the control needs the use of an 0068 //! algorithm which cannot be implemented in this package. 0069 //! The OffsetCurve is closed if the first point and the last point 0070 //! are the same (The distance between these two points is lower or 0071 //! equal to the Resolution sea package gp) . The OffsetCurve can be 0072 //! closed even if the basis curve is not closed. 0073 class Geom2d_OffsetCurve : public Geom2d_Curve 0074 { 0075 0076 public: 0077 //! Constructs a curve offset from the basis curve C, 0078 //! where Offset is the distance between the offset 0079 //! curve and the basis curve at any point. 0080 //! A point on the offset curve is built by measuring the 0081 //! offset value along a normal vector at a point on C. 0082 //! This normal vector is obtained by rotating the 0083 //! vector tangential to C at 90 degrees in the 0084 //! anti-trigonometric sense. The side of C on which 0085 //! the offset value is measured is indicated by this 0086 //! normal vector if Offset is positive, or in the inverse 0087 //! sense if Offset is negative. 0088 //! If isNotCheckC0 = TRUE checking if basis curve has C0-continuity 0089 //! is not made. 0090 //! Warnings : 0091 //! In this package the entities are not shared. The OffsetCurve is 0092 //! built with a copy of the curve C. So when C is modified the 0093 //! OffsetCurve is not modified 0094 //! Warning! if isNotCheckC0 = false, 0095 //! ConstructionError raised if the basis curve C is not at least C1. 0096 //! No check is done to know if ||V^Z|| != 0.0 at any point. 0097 Standard_EXPORT Geom2d_OffsetCurve(const Handle(Geom2d_Curve)& C, 0098 const Standard_Real Offset, 0099 const Standard_Boolean isNotCheckC0 = Standard_False); 0100 0101 //! Changes the direction of parametrization of <me>. 0102 //! As a result: 0103 //! - the basis curve is reversed, 0104 //! - the start point of the initial curve becomes the end 0105 //! point of the reversed curve, 0106 //! - the end point of the initial curve becomes the start 0107 //! point of the reversed curve, and 0108 //! - the first and last parameters are recomputed. 0109 Standard_EXPORT void Reverse() Standard_OVERRIDE; 0110 0111 //! Computes the parameter on the reversed curve for 0112 //! the point of parameter U on this offset curve. 0113 Standard_EXPORT Standard_Real ReversedParameter(const Standard_Real U) const Standard_OVERRIDE; 0114 0115 //! Changes this offset curve by assigning C as the 0116 //! basis curve from which it is built. 0117 //! If isNotCheckC0 = TRUE checking if basis curve has C0-continuity 0118 //! is not made. 0119 //! Exceptions 0120 //! if isNotCheckC0 = false, 0121 //! Standard_ConstructionError if the curve C is not at least "C1" continuous. 0122 Standard_EXPORT void SetBasisCurve(const Handle(Geom2d_Curve)& C, 0123 const Standard_Boolean isNotCheckC0 = Standard_False); 0124 0125 //! Changes this offset curve by assigning D as the offset value. 0126 Standard_EXPORT void SetOffsetValue(const Standard_Real D); 0127 0128 //! Returns the basis curve of this offset curve. The basis curve can be an offset curve. 0129 Standard_EXPORT Handle(Geom2d_Curve) BasisCurve() const; 0130 0131 //! Continuity of the Offset curve : 0132 //! C0 : only geometric continuity, 0133 //! C1 : continuity of the first derivative all along the Curve, 0134 //! C2 : continuity of the second derivative all along the Curve, 0135 //! C3 : continuity of the third derivative all along the Curve, 0136 //! G1 : tangency continuity all along the Curve, 0137 //! G2 : curvature continuity all along the Curve, 0138 //! CN : the order of continuity is infinite. 0139 //! Warnings : 0140 //! Returns the continuity of the basis curve - 1. 0141 //! The offset curve must have a unique normal direction defined 0142 //! at any point. 0143 //! Value and derivatives 0144 //! 0145 //! Warnings : 0146 //! The exception UndefinedValue or UndefinedDerivative is 0147 //! raised if it is not possible to compute a unique offset 0148 //! direction. 0149 //! If T is the first derivative with not null length and 0150 //! Z the direction normal to the plane of the curve, the 0151 //! relation ||T(U) ^ Z|| != 0 must be satisfied to evaluate 0152 //! the offset curve. 0153 //! No check is done at the creation time and we suppose 0154 //! in this package that the offset curve is well defined. 0155 Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE; 0156 0157 //! Warning! this should not be called 0158 //! if the basis curve is not at least C1. Nevertheless 0159 //! if used on portion where the curve is C1, it is OK 0160 Standard_EXPORT void D0(const Standard_Real U, gp_Pnt2d& P) const Standard_OVERRIDE; 0161 0162 //! Warning! this should not be called 0163 //! if the continuity of the basis curve is not C2. 0164 //! Nevertheless, it's OK to use it on portion 0165 //! where the curve is C2 0166 Standard_EXPORT void D1(const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1) const Standard_OVERRIDE; 0167 0168 //! Warning! This should not be called 0169 //! if the continuity of the basis curve is not C3. 0170 //! Nevertheless, it's OK to use it on portion 0171 //! where the curve is C3 0172 Standard_EXPORT void D2(const Standard_Real U, 0173 gp_Pnt2d& P, 0174 gp_Vec2d& V1, 0175 gp_Vec2d& V2) const Standard_OVERRIDE; 0176 0177 //! Warning! This should not be called 0178 //! if the continuity of the basis curve is not C4. 0179 //! Nevertheless, it's OK to use it on portion 0180 //! where the curve is C4 0181 Standard_EXPORT void D3(const Standard_Real U, 0182 gp_Pnt2d& P, 0183 gp_Vec2d& V1, 0184 gp_Vec2d& V2, 0185 gp_Vec2d& V3) const Standard_OVERRIDE; 0186 0187 //! The returned vector gives the value of the derivative 0188 //! for the order of derivation N. 0189 //! Warning! this should not be called 0190 //! raises UndefunedDerivative if the continuity of the basis curve is not CN+1. 0191 //! Nevertheless, it's OK to use it on portion 0192 //! where the curve is CN+1 0193 //! raises RangeError if N < 1. 0194 //! raises NotImplemented if N > 3. 0195 //! The following functions compute the value and derivatives 0196 //! on the offset curve and returns the derivatives on the 0197 //! basis curve too. 0198 //! The computation of the value and derivatives on the basis 0199 //! curve are used to evaluate the offset curve 0200 //! Warnings : 0201 //! The exception UndefinedValue or UndefinedDerivative is 0202 //! raised if it is not possible to compute a unique offset direction. 0203 Standard_EXPORT gp_Vec2d DN(const Standard_Real U, 0204 const Standard_Integer N) const Standard_OVERRIDE; 0205 0206 //! Returns the value of the first parameter of this 0207 //! offset curve. The first parameter corresponds to the 0208 //! start point of the curve. 0209 //! Note: the first and last parameters of this offset curve 0210 //! are also the ones of its basis curve. 0211 Standard_EXPORT Standard_Real FirstParameter() const Standard_OVERRIDE; 0212 0213 //! Returns the value of the last parameter of this 0214 //! offset curve. The last parameter 0215 //! corresponds to the end point. 0216 //! Note: the first and last parameters of this offset curve 0217 //! are also the ones of its basis curve. 0218 Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE; 0219 0220 //! Returns the offset value of this offset curve. 0221 Standard_EXPORT Standard_Real Offset() const; 0222 0223 //! Returns True if the distance between the start point 0224 //! and the end point of the curve is lower or equal to 0225 //! Resolution from package gp. 0226 Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; 0227 0228 //! Is the order of continuity of the curve N ? 0229 //! Warnings : 0230 //! This method answer True if the continuity of the basis curve 0231 //! is N + 1. We suppose in this class that a normal direction 0232 //! to the basis curve (used to compute the offset curve) is 0233 //! defined at any point on the basis curve. 0234 //! Raised if N < 0. 0235 Standard_EXPORT Standard_Boolean IsCN(const Standard_Integer N) const Standard_OVERRIDE; 0236 0237 //! Is the parametrization of a curve is periodic ? 0238 //! If the basis curve is a circle or an ellipse the corresponding 0239 //! OffsetCurve is periodic. If the basis curve can't be periodic 0240 //! (for example BezierCurve) the OffsetCurve can't be periodic. 0241 Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; 0242 0243 //! Returns the period of this offset curve, i.e. the period 0244 //! of the basis curve of this offset curve. 0245 //! Exceptions 0246 //! Standard_NoSuchObject if the basis curve is not periodic. 0247 Standard_EXPORT virtual Standard_Real Period() const Standard_OVERRIDE; 0248 0249 //! Applies the transformation T to this offset curve. 0250 //! Note: the basis curve is also modified. 0251 Standard_EXPORT void Transform(const gp_Trsf2d& T) Standard_OVERRIDE; 0252 0253 //! Returns the parameter on the transformed curve for 0254 //! the transform of the point of parameter U on <me>. 0255 //! 0256 //! me->Transformed(T)->Value(me->TransformedParameter(U,T)) 0257 //! 0258 //! is the same point as 0259 //! 0260 //! me->Value(U).Transformed(T) 0261 //! 0262 //! This methods calls the basis curve method. 0263 Standard_EXPORT virtual Standard_Real TransformedParameter(const Standard_Real U, 0264 const gp_Trsf2d& T) const 0265 Standard_OVERRIDE; 0266 0267 //! Returns a coefficient to compute the parameter on 0268 //! the transformed curve for the transform of the 0269 //! point on <me>. 0270 //! 0271 //! Transformed(T)->Value(U * ParametricTransformation(T)) 0272 //! 0273 //! is the same point as 0274 //! 0275 //! Value(U).Transformed(T) 0276 //! 0277 //! This methods calls the basis curve method. 0278 Standard_EXPORT virtual Standard_Real ParametricTransformation(const gp_Trsf2d& T) const 0279 Standard_OVERRIDE; 0280 0281 //! Creates a new object, which is a copy of this offset curve. 0282 Standard_EXPORT Handle(Geom2d_Geometry) Copy() const Standard_OVERRIDE; 0283 0284 //! Returns continuity of the basis curve. 0285 Standard_EXPORT GeomAbs_Shape GetBasisCurveContinuity() const; 0286 0287 //! Dumps the content of me into the stream 0288 Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream, 0289 Standard_Integer theDepth = -1) const Standard_OVERRIDE; 0290 0291 DEFINE_STANDARD_RTTIEXT(Geom2d_OffsetCurve, Geom2d_Curve) 0292 0293 protected: 0294 private: 0295 Handle(Geom2d_Curve) basisCurve; 0296 Standard_Real offsetValue; 0297 GeomAbs_Shape myBasisCurveContinuity; 0298 Handle(Geom2dEvaluator_OffsetCurve) myEvaluator; 0299 }; 0300 0301 #endif // _Geom2d_OffsetCurve_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|