Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:39

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