Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created on: 1997-09-22
0002 // Created by: Roman BORISOV
0003 // Copyright (c) 1997-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_CompProjectedCurve_HeaderFile
0018 #define _ProjLib_CompProjectedCurve_HeaderFile
0019 
0020 #include <Adaptor2d_Curve2d.hxx>
0021 #include <Adaptor3d_Surface.hxx>
0022 #include <ProjLib_HSequenceOfHSequenceOfPnt.hxx>
0023 #include <ProjLib_Projector.hxx>
0024 #include <TColGeom_HArray1OfCurve.hxx>
0025 #include <TColGeom2d_HArray1OfCurve.hxx>
0026 #include <TColgp_HArray1OfPnt.hxx>
0027 #include <TColgp_HArray1OfPnt2d.hxx>
0028 #include <TColStd_HArray1OfBoolean.hxx>
0029 #include <TColStd_HArray1OfReal.hxx>
0030 #include <Geom_Curve.hxx>
0031 #include <Geom2d_Curve.hxx>
0032 #include <GeomAbs_Shape.hxx>
0033 #include <TColStd_Array1OfReal.hxx>
0034 #include <GeomAbs_CurveType.hxx>
0035 
0036 class gp_Pnt2d;
0037 class gp_Vec2d;
0038 
0039 class ProjLib_CompProjectedCurve  : public Adaptor2d_Curve2d
0040 {
0041   DEFINE_STANDARD_RTTIEXT(ProjLib_CompProjectedCurve, Adaptor2d_Curve2d)
0042 public:
0043 
0044   Standard_EXPORT ProjLib_CompProjectedCurve();
0045   
0046   //! try to find all solutions
0047   Standard_EXPORT ProjLib_CompProjectedCurve(const Handle(Adaptor3d_Surface)& S, const Handle(Adaptor3d_Curve)& C, const Standard_Real TolU, const Standard_Real TolV);
0048   
0049   //! this constructor tries to optimize the search using the
0050   //! assumption that maximum distance between surface and curve less or
0051   //! equal then MaxDist.
0052   //! if MaxDist < 0 then algorithm works as above.
0053   Standard_EXPORT ProjLib_CompProjectedCurve(const Handle(Adaptor3d_Surface)& S, const Handle(Adaptor3d_Curve)& C, const Standard_Real TolU, const Standard_Real TolV, const Standard_Real MaxDist);
0054 
0055   //! this constructor tries to optimize the search using the
0056   //! assumption that maximum distance between surface and curve less or
0057   //! equal then MaxDist.
0058   //! if MaxDist < 0 then algorithm try to find all solutions
0059   //! Tolerances of parameters are calculated automatically.
0060   Standard_EXPORT ProjLib_CompProjectedCurve(const Standard_Real Tol3d, const Handle(Adaptor3d_Surface)& S, const Handle(Adaptor3d_Curve)& C, const Standard_Real MaxDist = -1.0);
0061   
0062   //! Shallow copy of adaptor
0063   Standard_EXPORT virtual Handle(Adaptor2d_Curve2d) ShallowCopy() const Standard_OVERRIDE;
0064 
0065   //! computes a set of projected point and determine the
0066   //! continuous parts of the projected  curves. The  points
0067   //! corresponding to a projection on the bounds of the surface are
0068   //! included  in this set of points.
0069   Standard_EXPORT void Init();
0070   
0071   //! Performs projecting for given curve.
0072   //! If projecting uses approximation, 
0073   //! approximation parameters can be set before by corresponding methods 
0074   //! SetTol3d(...), SeContinuity(...), SetMaxDegree(...), SetMaxSeg(...)
0075   Standard_EXPORT void Perform();
0076 
0077   //! Set the parameter, which defines 3d tolerance of approximation.
0078   Standard_EXPORT void SetTol3d(const Standard_Real theTol3d);
0079 
0080   //! Set the parameter, which defines curve continuity.
0081   //! Default value is GeomAbs_C2;
0082   Standard_EXPORT void SetContinuity(const GeomAbs_Shape theContinuity);
0083 
0084   //! Set max possible degree of result BSpline curve2d, which is got by approximation.
0085   //! If MaxDegree < 0, algorithm uses values that are chosen depending of types curve 3d
0086   //! and surface.
0087   Standard_EXPORT void SetMaxDegree(const Standard_Integer theMaxDegree);
0088 
0089   //! Set the parameter, which defines maximal value of parametric intervals the projected
0090   //! curve can be cut for approximation. If MaxSeg < 0, algorithm uses default 
0091   //! value = 16.
0092   Standard_EXPORT void SetMaxSeg(const Standard_Integer theMaxSeg);
0093 
0094   //! Set the parameter, which defines necessity of 2d results.
0095   Standard_EXPORT void SetProj2d(const Standard_Boolean theProj2d);
0096 
0097   //! Set the parameter, which defines necessity of 3d results.
0098   Standard_EXPORT void SetProj3d(const Standard_Boolean theProj3d);
0099 
0100   //! Changes the surface.
0101   Standard_EXPORT void Load (const Handle(Adaptor3d_Surface)& S);
0102   
0103   //! Changes the  curve.
0104   Standard_EXPORT void Load (const Handle(Adaptor3d_Curve)& C);
0105   
0106   Standard_EXPORT const Handle(Adaptor3d_Surface)& GetSurface() const;
0107   
0108   Standard_EXPORT const Handle(Adaptor3d_Curve)& GetCurve() const;
0109   
0110   Standard_EXPORT void GetTolerance (Standard_Real& TolU, Standard_Real& TolV) const;
0111   
0112   //! returns the number of continuous part of the projected curve
0113   Standard_EXPORT Standard_Integer NbCurves() const;
0114   
0115   //! returns the bounds of the continuous part corresponding to Index
0116   Standard_EXPORT void Bounds (const Standard_Integer Index, Standard_Real& Udeb, Standard_Real& Ufin) const;
0117   
0118   //! returns  True  if  part  of  projection with  number  Index is  a  single  point  and  writes  its  coordinates in  P
0119   Standard_EXPORT Standard_Boolean IsSinglePnt (const Standard_Integer Index, gp_Pnt2d& P) const;
0120   
0121   //! returns  True  if  part  of  projection with  number  Index is  an  u-isoparametric curve  of  input  surface
0122   Standard_EXPORT Standard_Boolean IsUIso (const Standard_Integer Index, Standard_Real& U) const;
0123   
0124   //! returns  True  if  part  of  projection with  number  Index is  an  v-isoparametric curve  of  input  surface
0125   Standard_EXPORT Standard_Boolean IsVIso (const Standard_Integer Index, Standard_Real& V) const;
0126   
0127   //! Computes the point of parameter U on the curve.
0128   Standard_EXPORT gp_Pnt2d Value (const Standard_Real U) const Standard_OVERRIDE;
0129   
0130   //! Computes the point of parameter U on the curve.
0131   Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt2d& P) const Standard_OVERRIDE;
0132   
0133   //! Computes the point of parameter U on the curve with its
0134   //! first derivative.
0135   //! Raised if the continuity of the current interval
0136   //! is not C1.
0137   Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V) const Standard_OVERRIDE;
0138   
0139 
0140   //! Returns the point P of parameter U, the first and second
0141   //! derivatives V1 and V2.
0142   //! Raised if the continuity of the current interval
0143   //! is not C2.
0144   Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const Standard_OVERRIDE;
0145   
0146 
0147   //! The returned vector gives the value of the derivative for the
0148   //! order of derivation N.
0149   //! Raised if N < 1.
0150   //! Raised if N > 2.
0151   Standard_EXPORT gp_Vec2d DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE;
0152   
0153   //! Returns  the  first  parameter of  the  curve  C
0154   //! which  has  a  projection  on  S.
0155   Standard_EXPORT Standard_Real FirstParameter() const Standard_OVERRIDE;
0156   
0157   //! Returns  the  last  parameter of  the  curve  C
0158   //! which  has  a  projection  on  S.
0159   Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE;
0160   
0161   //! Returns the Continuity used in the approximation.
0162   Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE;
0163 
0164   //! Returns  the number  of  intervals which  define
0165   //! an  S  continuous  part  of  the  projected  curve
0166   Standard_EXPORT Standard_Integer NbIntervals (const GeomAbs_Shape S) const Standard_OVERRIDE;
0167   
0168   //! Returns    a  curve equivalent   of  <me>  between
0169   //! parameters <First>  and <Last>. <Tol>  is used  to
0170   //! test for 2d points confusion.
0171   //! If <First> >= <Last>
0172   Standard_EXPORT Handle(Adaptor2d_Curve2d) Trim (const Standard_Real FirstParam, const Standard_Real LastParam, const Standard_Real Tol) const Standard_OVERRIDE;
0173   
0174   //! Returns  the  parameters  corresponding  to
0175   //! S  discontinuities.
0176   //!
0177   //! The array must provide  enough room to  accommodate
0178   //! for the parameters. i.e. T.Length() > NbIntervals()
0179   Standard_EXPORT void Intervals (TColStd_Array1OfReal& T, const GeomAbs_Shape S) const Standard_OVERRIDE;
0180   
0181   //! returns  the  maximum  distance  between
0182   //! curve  to  project  and  surface
0183   Standard_EXPORT Standard_Real MaxDistance (const Standard_Integer Index) const;
0184   
0185   Standard_EXPORT const Handle(ProjLib_HSequenceOfHSequenceOfPnt)& GetSequence() const;
0186   
0187   //! Returns  the  type of the   curve  in the  current
0188   //! interval :   Line,   Circle,   Ellipse, Hyperbola,
0189   //! Parabola, BezierCurve, BSplineCurve, OtherCurve.
0190   Standard_EXPORT GeomAbs_CurveType GetType() const Standard_OVERRIDE;
0191 
0192   //! Returns true if result of projecting of the curve interval
0193   //! with number Index is point.
0194   Standard_EXPORT Standard_Boolean ResultIsPoint(const Standard_Integer theIndex) const;
0195 
0196   //! Returns the error of approximation of U parameter 2d-curve as a result
0197   //! projecting of the curve interval with number Index.
0198   Standard_EXPORT Standard_Real GetResult2dUApproxError(const Standard_Integer theIndex) const;
0199 
0200   //! Returns the error of approximation of V parameter 2d-curve as a result
0201   //! projecting of the curve interval with number Index.
0202   Standard_EXPORT Standard_Real GetResult2dVApproxError(const Standard_Integer theIndex) const;
0203 
0204   //! Returns the error of approximation of 3d-curve as a result
0205   //! projecting of the curve interval with number Index.
0206   Standard_EXPORT Standard_Real GetResult3dApproxError(const Standard_Integer theIndex) const;
0207 
0208   //! Returns the resulting 2d-curve of projecting
0209   //! of the curve interval with number Index.
0210   Standard_EXPORT Handle(Geom2d_Curve) GetResult2dC(const Standard_Integer theIndex) const;
0211 
0212   //! Returns the resulting 3d-curve of projecting
0213   //! of the curve interval with number Index.
0214   Standard_EXPORT Handle(Geom_Curve) GetResult3dC(const Standard_Integer theIndex) const;
0215 
0216   //! Returns the resulting 2d-point of projecting
0217   //! of the curve interval with number Index.
0218   Standard_EXPORT gp_Pnt2d GetResult2dP(const Standard_Integer theIndex) const;
0219 
0220   //! Returns the resulting 3d-point of projecting
0221   //! of the curve interval with number Index.
0222   Standard_EXPORT gp_Pnt GetResult3dP(const Standard_Integer theIndex) const;
0223 
0224   //! Returns the parameter, which defines necessity of only 2d results.
0225   Standard_Boolean GetProj2d() const { return myProj2d; }
0226 
0227   //! Returns the parameter, which defines necessity of only 3d results.
0228   Standard_Boolean GetProj3d() const { return myProj3d; }
0229 
0230 private:
0231 
0232   //! This method performs check possibility of optimization traps and tries to go out from them.
0233   //@return thePoint - input / corrected point.
0234   Standard_EXPORT void UpdateTripleByTrapCriteria(gp_Pnt &thePoint) const;
0235 
0236   Standard_EXPORT void BuildIntervals (const GeomAbs_Shape S) const;
0237 
0238 private:
0239 
0240   Handle(Adaptor3d_Surface) mySurface;
0241   Handle(Adaptor3d_Curve) myCurve;
0242   Standard_Integer myNbCurves;
0243   Handle(ProjLib_HSequenceOfHSequenceOfPnt) mySequence;
0244   Handle(TColStd_HArray1OfBoolean) myUIso;
0245   Handle(TColStd_HArray1OfBoolean) myVIso;
0246   Handle(TColStd_HArray1OfBoolean) mySnglPnts;
0247   Handle(TColStd_HArray1OfReal) myMaxDistance;
0248   Handle(TColStd_HArray1OfReal) myTabInt;
0249   Standard_Real    myTol3d;
0250   GeomAbs_Shape    myContinuity;
0251   Standard_Integer myMaxDegree;
0252   Standard_Integer myMaxSeg;
0253   Standard_Boolean myProj2d;
0254   Standard_Boolean myProj3d;
0255   Standard_Real myMaxDist;
0256   Standard_Real myTolU;
0257   Standard_Real myTolV;
0258 
0259   Handle(TColStd_HArray1OfBoolean)  myResultIsPoint;
0260   Handle(TColStd_HArray1OfReal)     myResult2dUApproxError;
0261   Handle(TColStd_HArray1OfReal)     myResult2dVApproxError;
0262   Handle(TColStd_HArray1OfReal)     myResult3dApproxError;
0263   Handle(TColgp_HArray1OfPnt)       myResult3dPoint;
0264   Handle(TColgp_HArray1OfPnt2d)     myResult2dPoint;
0265   Handle(TColGeom_HArray1OfCurve)   myResult3dCurve;
0266   Handle(TColGeom2d_HArray1OfCurve) myResult2dCurve;
0267 };
0268 
0269 DEFINE_STANDARD_HANDLE(ProjLib_CompProjectedCurve, Adaptor2d_Curve2d)
0270 
0271 #endif // _ProjLib_CompProjectedCurve_HeaderFile