| 1 | // Created on: 1993-02-19 |
| 2 | // Created by: Remi LEQUETTE |
| 3 | // Copyright (c) 1993-1999 Matra Datavision |
| 4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
| 5 | // |
| 6 | // This file is part of Open CASCADE Technology software library. |
| 7 | // |
| 8 | // This library is free software; you can redistribute it and/or modify it under |
| 9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
| 10 | // by the Free Software Foundation, with special exception defined in the file |
| 11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
| 12 | // distribution for complete text of the license and disclaimer of any warranty. |
| 13 | // |
| 14 | // Alternatively, this file may be used under the terms of Open CASCADE |
| 15 | // commercial license or contractual agreement. |
| 16 | |
| 17 | #ifndef _BRepAdaptor_Curve_HeaderFile |
| 18 | #define _BRepAdaptor_Curve_HeaderFile |
| 19 | |
| 20 | #include <Standard.hxx> |
| 21 | #include <Standard_DefineAlloc.hxx> |
| 22 | #include <Standard_Handle.hxx> |
| 23 | |
| 24 | #include <gp_Trsf.hxx> |
| 25 | #include <GeomAdaptor_Curve.hxx> |
| 26 | #include <TopoDS_Edge.hxx> |
| 27 | #include <Adaptor3d_Curve.hxx> |
| 28 | #include <Standard_Boolean.hxx> |
| 29 | #include <Standard_Real.hxx> |
| 30 | #include <GeomAbs_Shape.hxx> |
| 31 | #include <Standard_Integer.hxx> |
| 32 | #include <TColStd_Array1OfReal.hxx> |
| 33 | #include <GeomAbs_CurveType.hxx> |
| 34 | class Adaptor3d_HCurveOnSurface; |
| 35 | class Standard_NullObject; |
| 36 | class Standard_DomainError; |
| 37 | class Standard_OutOfRange; |
| 38 | class Standard_NoSuchObject; |
| 39 | class TopoDS_Edge; |
| 40 | class TopoDS_Face; |
| 41 | class gp_Trsf; |
| 42 | class GeomAdaptor_Curve; |
| 43 | class Adaptor3d_CurveOnSurface; |
| 44 | class Adaptor3d_HCurve; |
| 45 | class gp_Pnt; |
| 46 | class gp_Vec; |
| 47 | class gp_Lin; |
| 48 | class gp_Circ; |
| 49 | class gp_Elips; |
| 50 | class gp_Hypr; |
| 51 | class gp_Parab; |
| 52 | class Geom_BezierCurve; |
| 53 | class Geom_BSplineCurve; |
| 54 | |
| 55 | |
| 56 | //! The Curve from BRepAdaptor allows to use an Edge |
| 57 | //! of the BRep topology like a 3D curve. |
| 58 | //! |
| 59 | //! It has the methods the class Curve from Adaptor3d. |
| 60 | //! |
| 61 | //! It is created or Initialized with an Edge. It |
| 62 | //! takes into account local coordinate systems. If |
| 63 | //! the Edge has a 3D curve it is use with priority. |
| 64 | //! If the edge has no 3D curve one of the curves on |
| 65 | //! surface is used. It is possible to enforce using a |
| 66 | //! curve on surface by creating or initialising with |
| 67 | //! an Edge and a Face. |
| 68 | class BRepAdaptor_Curve : public Adaptor3d_Curve |
| 69 | { |
| 70 | public: |
| 71 | |
| 72 | DEFINE_STANDARD_ALLOC |
| 73 | |
| 74 | |
| 75 | //! Creates an undefined Curve with no Edge loaded. |
| 76 | Standard_EXPORT BRepAdaptor_Curve(); |
| 77 | |
| 78 | //! Creates a Curve to acces to the geometry of edge |
| 79 | //! <E>. |
| 80 | Standard_EXPORT BRepAdaptor_Curve(const TopoDS_Edge& E); |
| 81 | |
| 82 | //! Creates a Curve to acces to the geometry of edge |
| 83 | //! <E>. The geometry will be computed using the |
| 84 | //! parametric curve of <E> on the face <F>. An Error |
| 85 | //! is raised if the edge does not have a pcurve on |
| 86 | //! the face. |
| 87 | Standard_EXPORT BRepAdaptor_Curve(const TopoDS_Edge& E, const TopoDS_Face& F); |
| 88 | |
| 89 | //! Sets the Curve <me> to acces to the geometry of |
| 90 | //! edge <E>. |
| 91 | Standard_EXPORT void Initialize (const TopoDS_Edge& E); |
| 92 | |
| 93 | //! Sets the Curve <me> to acces to the geometry of |
| 94 | //! edge <E>. The geometry will be computed using the |
| 95 | //! parametric curve of <E> on the face <F>. An Error |
| 96 | //! is raised if the edge does not have a pcurve on |
| 97 | //! the face. |
| 98 | Standard_EXPORT void Initialize (const TopoDS_Edge& E, const TopoDS_Face& F); |
| 99 | |
| 100 | //! Returns the coordinate system of the curve. |
| 101 | Standard_EXPORT const gp_Trsf& Trsf() const; |
| 102 | |
| 103 | //! Returns True if the edge geometry is computed from |
| 104 | //! a 3D curve. |
| 105 | Standard_EXPORT Standard_Boolean Is3DCurve() const; |
| 106 | |
| 107 | //! Returns True if the edge geometry is computed from |
| 108 | //! a pcurve on a surface. |
| 109 | Standard_EXPORT Standard_Boolean IsCurveOnSurface() const; |
| 110 | |
| 111 | //! Returns the Curve of the edge. |
| 112 | Standard_EXPORT const GeomAdaptor_Curve& Curve() const; |
| 113 | |
| 114 | //! Returns the CurveOnSurface of the edge. |
| 115 | Standard_EXPORT const Adaptor3d_CurveOnSurface& CurveOnSurface() const; |
| 116 | |
| 117 | //! Returns the edge. |
| 118 | Standard_EXPORT const TopoDS_Edge& Edge() const; |
| 119 | |
| 120 | //! Returns the edge tolerance. |
| 121 | Standard_EXPORT Standard_Real Tolerance() const; |
| 122 | |
| 123 | Standard_EXPORT Standard_Real FirstParameter() const Standard_OVERRIDE; |
| 124 | |
| 125 | Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE; |
| 126 | |
| 127 | Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE; |
| 128 | |
| 129 | //! Returns the number of intervals for continuity |
| 130 | //! <S>. May be one if Continuity(me) >= <S> |
| 131 | Standard_EXPORT Standard_Integer NbIntervals (const GeomAbs_Shape S) const Standard_OVERRIDE; |
| 132 | |
| 133 | //! Stores in <T> the parameters bounding the intervals |
| 134 | //! of continuity <S>. |
| 135 | //! |
| 136 | //! The array must provide enough room to accomodate |
| 137 | //! for the parameters. i.e. T.Length() > NbIntervals() |
| 138 | Standard_EXPORT void Intervals (TColStd_Array1OfReal& T, const GeomAbs_Shape S) const Standard_OVERRIDE; |
| 139 | |
| 140 | //! Returns a curve equivalent of <me> between |
| 141 | //! parameters <First> and <Last>. <Tol> is used to |
| 142 | //! test for 3d points confusion. |
| 143 | //! If <First> >= <Last> |
| 144 | Standard_EXPORT Handle(Adaptor3d_HCurve) Trim (const Standard_Real First, const Standard_Real Last, const Standard_Real Tol) const Standard_OVERRIDE; |
| 145 | |
| 146 | Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; |
| 147 | |
| 148 | Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; |
| 149 | |
| 150 | Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE; |
| 151 | |
| 152 | //! Computes the point of parameter U on the curve |
| 153 | Standard_EXPORT gp_Pnt Value (const Standard_Real U) const Standard_OVERRIDE; |
| 154 | |
| 155 | //! Computes the point of parameter U. |
| 156 | Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt& P) const Standard_OVERRIDE; |
| 157 | |
| 158 | //! Computes the point of parameter U on the curve |
| 159 | //! with its first derivative. |
| 160 | //! Raised if the continuity of the current interval |
| 161 | //! is not C1. |
| 162 | Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt& P, gp_Vec& V) const Standard_OVERRIDE; |
| 163 | |
| 164 | |
| 165 | //! Returns the point P of parameter U, the first and second |
| 166 | //! derivatives V1 and V2. |
| 167 | //! Raised if the continuity of the current interval |
| 168 | //! is not C2. |
| 169 | Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const Standard_OVERRIDE; |
| 170 | |
| 171 | |
| 172 | //! Returns the point P of parameter U, the first, the second |
| 173 | //! and the third derivative. |
| 174 | //! Raised if the continuity of the current interval |
| 175 | //! is not C3. |
| 176 | Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt& P, gp_Vec& V1, gp_Vec& V2, gp_Vec& V3) const Standard_OVERRIDE; |
| 177 | |
| 178 | |
| 179 | //! The returned vector gives the value of the derivative for the |
| 180 | //! order of derivation N. |
| 181 | //! Raised if the continuity of the current interval |
| 182 | //! is not CN. |
| 183 | //! Raised if N < 1. |
| 184 | Standard_EXPORT gp_Vec DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE; |
| 185 | |
| 186 | //! returns the parametric resolution |
| 187 | Standard_EXPORT Standard_Real Resolution (const Standard_Real R3d) const Standard_OVERRIDE; |
| 188 | |
| 189 | Standard_EXPORT GeomAbs_CurveType GetType() const Standard_OVERRIDE; |
| 190 | |
| 191 | Standard_EXPORT gp_Lin Line() const Standard_OVERRIDE; |
| 192 | |
| 193 | Standard_EXPORT gp_Circ Circle() const Standard_OVERRIDE; |
| 194 | |
| 195 | Standard_EXPORT gp_Elips Ellipse() const Standard_OVERRIDE; |
| 196 | |
| 197 | Standard_EXPORT gp_Hypr Hyperbola() const Standard_OVERRIDE; |
| 198 | |
| 199 | Standard_EXPORT gp_Parab Parabola() const Standard_OVERRIDE; |
| 200 | |
| 201 | Standard_EXPORT Standard_Integer Degree() const Standard_OVERRIDE; |
| 202 | |
| 203 | Standard_EXPORT Standard_Boolean IsRational() const Standard_OVERRIDE; |
| 204 | |
| 205 | Standard_EXPORT Standard_Integer NbPoles() const Standard_OVERRIDE; |
| 206 | |
| 207 | Standard_EXPORT Standard_Integer NbKnots() const Standard_OVERRIDE; |
| 208 | |
| 209 | |
| 210 | //! Warning : |
| 211 | //! This will make a copy of the Bezier Curve |
| 212 | //! since it applies to it myTsrf . Be carefull when |
| 213 | //! using this method |
| 214 | Standard_EXPORT Handle(Geom_BezierCurve) Bezier() const Standard_OVERRIDE; |
| 215 | |
| 216 | |
| 217 | //! Warning : |
| 218 | //! This will make a copy of the BSpline Curve |
| 219 | //! since it applies to it myTsrf . Be carefull when |
| 220 | //! using this method |
| 221 | Standard_EXPORT Handle(Geom_BSplineCurve) BSpline() const Standard_OVERRIDE; |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | protected: |
| 227 | |
| 228 | |
| 229 | |
| 230 | |
| 231 | |
| 232 | private: |
| 233 | |
| 234 | |
| 235 | |
| 236 | gp_Trsf myTrsf; |
| 237 | GeomAdaptor_Curve myCurve; |
| 238 | Handle(Adaptor3d_HCurveOnSurface) myConSurf; |
| 239 | TopoDS_Edge myEdge; |
| 240 | |
| 241 | |
| 242 | }; |
| 243 | |
| 244 | |
| 245 | |
| 246 | |
| 247 | |
| 248 | |
| 249 | |
| 250 | #endif // _BRepAdaptor_Curve_HeaderFile |