Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-23 09:16:50

0001 // Created on: 1998-08-20
0002 // Created by: Philippe MANGIN
0003 // Copyright (c) 1998-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 _BRepAdaptor_CompCurve_HeaderFile
0018 #define _BRepAdaptor_CompCurve_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <TopoDS_Wire.hxx>
0025 #include <Standard_Real.hxx>
0026 #include <BRepAdaptor_Curve.hxx>
0027 #include <NCollection_Array1.hxx>
0028 #include <NCollection_HArray1.hxx>
0029 #include <Standard_Integer.hxx>
0030 #include <Standard_Boolean.hxx>
0031 #include <Adaptor3d_Curve.hxx>
0032 #include <GeomAbs_Shape.hxx>
0033 #include <GeomAbs_CurveType.hxx>
0034 
0035 class TopoDS_Edge;
0036 class gp_Pnt;
0037 class gp_Vec;
0038 class gp_Lin;
0039 class gp_Circ;
0040 class gp_Elips;
0041 class gp_Hypr;
0042 class gp_Parab;
0043 class Geom_BezierCurve;
0044 class Geom_BSplineCurve;
0045 
0046 //! The Curve from BRepAdaptor allows to use a Wire
0047 //! of the BRep topology like a 3D curve.
0048 //! Warning: With this class of curve, C0 and C1 continuities
0049 //! are not assumed. So be careful with some algorithm!
0050 //! Please note that BRepAdaptor_CompCurve cannot be
0051 //! periodic curve at all (even if it contains single
0052 //! periodic edge).
0053 //!
0054 //! BRepAdaptor_CompCurve can only work on valid wires where all edges are
0055 //! connected to each other to make a chain.
0056 class BRepAdaptor_CompCurve : public Adaptor3d_Curve
0057 {
0058   DEFINE_STANDARD_RTTIEXT(BRepAdaptor_CompCurve, Adaptor3d_Curve)
0059 public:
0060   //! Creates an undefined Curve with no Wire loaded.
0061   Standard_EXPORT BRepAdaptor_CompCurve();
0062 
0063   Standard_EXPORT BRepAdaptor_CompCurve(const TopoDS_Wire& W,
0064                                         const bool         KnotByCurvilinearAbcissa = false);
0065 
0066   //! Creates a Curve to access the geometry of edge <W>.
0067   Standard_EXPORT BRepAdaptor_CompCurve(const TopoDS_Wire& W,
0068                                         const bool         KnotByCurvilinearAbcissa,
0069                                         const double       First,
0070                                         const double       Last,
0071                                         const double       Tol);
0072 
0073   //! Shallow copy of adaptor.
0074   Standard_EXPORT occ::handle<Adaptor3d_Curve> ShallowCopy() const override;
0075 
0076   //! Sets the wire <W>.
0077   Standard_EXPORT void Initialize(const TopoDS_Wire& W, const bool KnotByCurvilinearAbcissa);
0078 
0079   //! Sets wire <W> and trimmed parameter.
0080   Standard_EXPORT void Initialize(const TopoDS_Wire& W,
0081                                   const bool         KnotByCurvilinearAbcissa,
0082                                   const double       First,
0083                                   const double       Last,
0084                                   const double       Tol);
0085 
0086   //! Returns the wire.
0087   Standard_EXPORT const TopoDS_Wire& Wire() const;
0088 
0089   //! returns an edge and one parameter on them
0090   //! corresponding to the parameter U.
0091   Standard_EXPORT void Edge(const double U, TopoDS_Edge& E, double& UonE) const;
0092 
0093   Standard_EXPORT double FirstParameter() const override;
0094 
0095   Standard_EXPORT double LastParameter() const override;
0096 
0097   Standard_EXPORT GeomAbs_Shape Continuity() const override;
0098 
0099   //! Returns the number of intervals for continuity
0100   //! <S>. May be one if Continuity(me) >= <S>
0101   Standard_EXPORT int NbIntervals(const GeomAbs_Shape S) const override;
0102 
0103   //! Stores in <T> the parameters bounding the intervals
0104   //! of continuity <S>.
0105   //!
0106   //! The array must provide enough room to accommodate
0107   //! for the parameters. i.e. T.Length() > NbIntervals()
0108   Standard_EXPORT void Intervals(NCollection_Array1<double>& T,
0109                                  const GeomAbs_Shape         S) const override;
0110 
0111   //! Returns a curve equivalent of <me> between
0112   //! parameters <First> and <Last>. <Tol> is used to
0113   //! test for 3d points confusion.
0114   //! If <First> >= <Last>
0115   Standard_EXPORT occ::handle<Adaptor3d_Curve> Trim(const double First,
0116                                                     const double Last,
0117                                                     const double Tol) const override;
0118 
0119   Standard_EXPORT bool IsClosed() const override;
0120 
0121   Standard_EXPORT bool IsPeriodic() const override;
0122 
0123   Standard_EXPORT double Period() const override;
0124 
0125   //! Computes the point of parameter theU on the curve.
0126   [[nodiscard]] Standard_EXPORT gp_Pnt EvalD0(const double theU) const final;
0127 
0128   //! Computes the point of parameter theU on the curve with its first derivative.
0129   //! Raised if the continuity of the current interval is not C1.
0130   [[nodiscard]] Standard_EXPORT Geom_Curve::ResD1 EvalD1(const double theU) const final;
0131 
0132   //! Returns the point and the first and second derivatives at parameter theU.
0133   //! Raised if the continuity of the current interval is not C2.
0134   [[nodiscard]] Standard_EXPORT Geom_Curve::ResD2 EvalD2(const double theU) const final;
0135 
0136   //! Returns the point and the first, second and third derivatives at parameter theU.
0137   //! Raised if the continuity of the current interval is not C3.
0138   [[nodiscard]] Standard_EXPORT Geom_Curve::ResD3 EvalD3(const double theU) const final;
0139 
0140   //! Returns the derivative of order theN at parameter theU.
0141   //! Raised if the continuity of the current interval is not CN.
0142   //! Raised if theN < 1.
0143   [[nodiscard]] Standard_EXPORT gp_Vec EvalDN(const double theU, const int theN) const final;
0144 
0145   //! returns the parametric resolution
0146   Standard_EXPORT double Resolution(const double R3d) const override;
0147 
0148   Standard_EXPORT GeomAbs_CurveType GetType() const override;
0149 
0150   Standard_EXPORT gp_Lin Line() const override;
0151 
0152   Standard_EXPORT gp_Circ Circle() const override;
0153 
0154   Standard_EXPORT gp_Elips Ellipse() const override;
0155 
0156   Standard_EXPORT gp_Hypr Hyperbola() const override;
0157 
0158   Standard_EXPORT gp_Parab Parabola() const override;
0159 
0160   Standard_EXPORT int Degree() const override;
0161 
0162   Standard_EXPORT bool IsRational() const override;
0163 
0164   Standard_EXPORT int NbPoles() const override;
0165 
0166   Standard_EXPORT int NbKnots() const override;
0167 
0168   Standard_EXPORT occ::handle<Geom_BezierCurve> Bezier() const override;
0169 
0170   Standard_EXPORT occ::handle<Geom_BSplineCurve> BSpline() const override;
0171 
0172 private:
0173   Standard_EXPORT void Prepare(double& W, double& D, int& ind) const;
0174 
0175   Standard_EXPORT void InvPrepare(const int ind, double& F, double& D) const;
0176 
0177   TopoDS_Wire                                         myWire;
0178   double                                              TFirst;
0179   double                                              TLast;
0180   double                                              PTol;
0181   occ::handle<NCollection_HArray1<BRepAdaptor_Curve>> myCurves;
0182   occ::handle<NCollection_HArray1<double>>            myKnots;
0183   int                                                 CurIndex;
0184   bool                                                Forward;
0185   bool                                                IsbyAC;
0186 };
0187 
0188 #endif // _BRepAdaptor_CompCurve_HeaderFile