Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-09 09:16:40

0001 // Created on: 1993-08-25
0002 // Created by: Bruno DUMORTIER
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 _ProjLib_ProjectedCurve_HeaderFile
0018 #define _ProjLib_ProjectedCurve_HeaderFile
0019 
0020 #include <Adaptor2d_Curve2d.hxx>
0021 #include <Adaptor3d_Surface.hxx>
0022 #include <AppParCurves_Constraint.hxx>
0023 #include <GeomAbs_CurveType.hxx>
0024 #include <GeomAbs_Shape.hxx>
0025 #include <ProjLib_Projector.hxx>
0026 #include <TColStd_Array1OfReal.hxx>
0027 
0028 class gp_Pnt2d;
0029 class gp_Vec2d;
0030 class gp_Lin2d;
0031 class gp_Circ2d;
0032 class gp_Elips2d;
0033 class gp_Hypr2d;
0034 class gp_Parab2d;
0035 class Geom2d_BezierCurve;
0036 class Geom2d_BSplineCurve;
0037 
0038 DEFINE_STANDARD_HANDLE(ProjLib_ProjectedCurve, Adaptor2d_Curve2d)
0039 
0040 //! Compute the 2d-curve.  Try to solve the particular
0041 //! case if possible.  Otherwise, an approximation  is
0042 //! done. For approximation some parameters are used, including
0043 //! required tolerance of approximation.
0044 //! Tolerance is maximal possible value of 3d deviation of 3d projection of projected curve from
0045 //! "exact" 3d projection. Since algorithm searches 2d curve on surface, required 2d tolerance is
0046 //! computed from 3d tolerance with help of U,V resolutions of surface. 3d and 2d tolerances have
0047 //! sense only for curves on surface, it defines precision of projecting and approximation and have
0048 //! nothing to do with distance between the projected curve and the surface.
0049 class ProjLib_ProjectedCurve : public Adaptor2d_Curve2d
0050 {
0051   DEFINE_STANDARD_RTTIEXT(ProjLib_ProjectedCurve, Adaptor2d_Curve2d)
0052 public:
0053   //! Empty constructor, it only sets some initial values for class fields.
0054   Standard_EXPORT ProjLib_ProjectedCurve();
0055 
0056   //! Constructor with initialisation field mySurface
0057   Standard_EXPORT ProjLib_ProjectedCurve(const Handle(Adaptor3d_Surface)& S);
0058 
0059   //! Constructor, which performs projecting.
0060   //! If projecting uses approximation, default parameters are used, in particular, 3d tolerance of
0061   //! approximation is Precision::Confusion()
0062   Standard_EXPORT ProjLib_ProjectedCurve(const Handle(Adaptor3d_Surface)& S,
0063                                          const Handle(Adaptor3d_Curve)&   C);
0064 
0065   //! Constructor, which performs projecting.
0066   //! If projecting uses approximation, 3d tolerance is Tol, default parameters are used,
0067   Standard_EXPORT ProjLib_ProjectedCurve(const Handle(Adaptor3d_Surface)& S,
0068                                          const Handle(Adaptor3d_Curve)&   C,
0069                                          const Standard_Real              Tol);
0070 
0071   //! Shallow copy of adaptor
0072   Standard_EXPORT virtual Handle(Adaptor2d_Curve2d) ShallowCopy() const Standard_OVERRIDE;
0073 
0074   //! Changes the tolerance used to project
0075   //! the curve on the surface
0076   Standard_EXPORT void Load(const Standard_Real Tolerance);
0077 
0078   //! Changes the Surface.
0079   Standard_EXPORT void Load(const Handle(Adaptor3d_Surface)& S);
0080 
0081   //! Performs projecting for given curve.
0082   //! If projecting uses approximation,
0083   //! approximation parameters can be set before by corresponding methods
0084   //! SetDegree(...), SetMaxSegmets(...), SetBndPnt(...), SetMaxDist(...)
0085   Standard_EXPORT void Perform(const Handle(Adaptor3d_Curve)& C);
0086 
0087   //! Set min and max possible degree of result BSpline curve2d, which is got by approximation.
0088   //! If theDegMin/Max < 0, algorithm uses values that are chosen depending of types curve 3d
0089   //! and surface.
0090   Standard_EXPORT void SetDegree(const Standard_Integer theDegMin,
0091                                  const Standard_Integer theDegMax);
0092 
0093   //! Set the parameter, which defines maximal value of parametric intervals the projected
0094   //! curve can be cut for approximation. If theMaxSegments < 0, algorithm uses default
0095   //! value = 1000.
0096   Standard_EXPORT void SetMaxSegments(const Standard_Integer theMaxSegments);
0097 
0098   //! Set the parameter, which defines type of boundary condition between segments during
0099   //! approximation. It can be AppParCurves_PassPoint or AppParCurves_TangencyPoint. Default value
0100   //! is AppParCurves_TangencyPoint;
0101   Standard_EXPORT void SetBndPnt(const AppParCurves_Constraint theBndPnt);
0102 
0103   //! Set the parameter, which degines maximal possible distance between projected curve and
0104   //! surface. It uses only for projecting on not analytical surfaces. If theMaxDist < 0, algorithm
0105   //! uses default value 100.*Tolerance. If real distance between curve and surface more then
0106   //! theMaxDist, algorithm stops working.
0107   Standard_EXPORT void SetMaxDist(const Standard_Real theMaxDist);
0108 
0109   Standard_EXPORT const Handle(Adaptor3d_Surface)& GetSurface() const;
0110 
0111   Standard_EXPORT const Handle(Adaptor3d_Curve)& GetCurve() const;
0112 
0113   //! returns the tolerance reached if an approximation
0114   //! is Done.
0115   Standard_EXPORT Standard_Real GetTolerance() const;
0116 
0117   Standard_EXPORT Standard_Real FirstParameter() const Standard_OVERRIDE;
0118 
0119   Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE;
0120 
0121   Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE;
0122 
0123   //! If necessary,  breaks the  curve in  intervals  of
0124   //! continuity  <S>.    And  returns   the number   of
0125   //! intervals.
0126   Standard_EXPORT Standard_Integer NbIntervals(const GeomAbs_Shape S) const Standard_OVERRIDE;
0127 
0128   //! Stores in <T> the  parameters bounding the intervals
0129   //! of continuity <S>.
0130   //!
0131   //! The array must provide enough room to accommodate
0132   //! for the parameters. i.e. T.Length() > NbIntervals()
0133   Standard_EXPORT void Intervals(TColStd_Array1OfReal& T,
0134                                  const GeomAbs_Shape   S) const Standard_OVERRIDE;
0135 
0136   //! Returns    a  curve equivalent   of  <me>  between
0137   //! parameters <First>  and <Last>. <Tol>  is used  to
0138   //! test for 3d points confusion.
0139   //! If <First> >= <Last>
0140   Standard_EXPORT Handle(Adaptor2d_Curve2d) Trim(const Standard_Real First,
0141                                                  const Standard_Real Last,
0142                                                  const Standard_Real Tol) const Standard_OVERRIDE;
0143 
0144   Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE;
0145 
0146   Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE;
0147 
0148   Standard_EXPORT Standard_Real Period() const Standard_OVERRIDE;
0149 
0150   //! Computes the point of parameter U on the curve.
0151   Standard_EXPORT gp_Pnt2d Value(const Standard_Real U) const Standard_OVERRIDE;
0152 
0153   //! Computes the point of parameter U on the curve.
0154   Standard_EXPORT void D0(const Standard_Real U, gp_Pnt2d& P) const Standard_OVERRIDE;
0155 
0156   //! Computes the point of parameter U on the curve with its
0157   //! first derivative.
0158   //! Raised if the continuity of the current interval
0159   //! is not C1.
0160   Standard_EXPORT void D1(const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V) const Standard_OVERRIDE;
0161 
0162   //! Returns the point P of parameter U, the first and second
0163   //! derivatives V1 and V2.
0164   //! Raised if the continuity of the current interval
0165   //! is not C2.
0166   Standard_EXPORT void D2(const Standard_Real U,
0167                           gp_Pnt2d&           P,
0168                           gp_Vec2d&           V1,
0169                           gp_Vec2d&           V2) const Standard_OVERRIDE;
0170 
0171   //! Returns the point P of parameter U, the first, the second
0172   //! and the third derivative.
0173   //! Raised if the continuity of the current interval
0174   //! is not C3.
0175   Standard_EXPORT void D3(const Standard_Real U,
0176                           gp_Pnt2d&           P,
0177                           gp_Vec2d&           V1,
0178                           gp_Vec2d&           V2,
0179                           gp_Vec2d&           V3) const Standard_OVERRIDE;
0180 
0181   //! The returned vector gives the value of the derivative for the
0182   //! order of derivation N.
0183   //! Raised if the continuity of the current interval
0184   //! is not CN.
0185   //! Raised if N < 1.
0186   Standard_EXPORT gp_Vec2d DN(const Standard_Real    U,
0187                               const Standard_Integer N) const Standard_OVERRIDE;
0188 
0189   //! Returns the parametric  resolution corresponding
0190   //! to the real space resolution <R3d>.
0191   Standard_EXPORT Standard_Real Resolution(const Standard_Real R3d) const Standard_OVERRIDE;
0192 
0193   //! Returns  the  type of the   curve  in the  current
0194   //! interval :   Line,   Circle,   Ellipse, Hyperbola,
0195   //! Parabola, BezierCurve, BSplineCurve, OtherCurve.
0196   Standard_EXPORT GeomAbs_CurveType GetType() const Standard_OVERRIDE;
0197 
0198   Standard_EXPORT gp_Lin2d Line() const Standard_OVERRIDE;
0199 
0200   Standard_EXPORT gp_Circ2d Circle() const Standard_OVERRIDE;
0201 
0202   Standard_EXPORT gp_Elips2d Ellipse() const Standard_OVERRIDE;
0203 
0204   Standard_EXPORT gp_Hypr2d Hyperbola() const Standard_OVERRIDE;
0205 
0206   Standard_EXPORT gp_Parab2d Parabola() const Standard_OVERRIDE;
0207 
0208   Standard_EXPORT Standard_Integer Degree() const Standard_OVERRIDE;
0209 
0210   Standard_EXPORT Standard_Boolean IsRational() const Standard_OVERRIDE;
0211 
0212   Standard_EXPORT Standard_Integer NbPoles() const Standard_OVERRIDE;
0213 
0214   Standard_EXPORT Standard_Integer NbKnots() const Standard_OVERRIDE;
0215 
0216   //! Warning ! This will  NOT make a copy  of the -- Bezier Curve -
0217   //! If you want to modify -- the Curve  please make a copy
0218   //! yourself --  Also it will  NOT trim the surface  to --
0219   //! myFirst/Last.
0220   Standard_EXPORT Handle(Geom2d_BezierCurve) Bezier() const Standard_OVERRIDE;
0221 
0222   //! Warning ! This will NOT make a copy of the BSpline Curve - If
0223   //! you want to  modify the   Curve  please make a   copy
0224   //! yourself Also it   will  NOT  trim   the surface   to
0225   //! myFirst/Last.
0226   Standard_EXPORT Handle(Geom2d_BSplineCurve) BSpline() const Standard_OVERRIDE;
0227 
0228 private:
0229   Standard_Real             myTolerance;
0230   Handle(Adaptor3d_Surface) mySurface;
0231   Handle(Adaptor3d_Curve)   myCurve;
0232   ProjLib_Projector         myResult;
0233   Standard_Integer          myDegMin;
0234   Standard_Integer          myDegMax;
0235   Standard_Integer          myMaxSegments;
0236   Standard_Real             myMaxDist;
0237   AppParCurves_Constraint   myBndPnt;
0238 };
0239 
0240 #endif // _ProjLib_ProjectedCurve_HeaderFile