0028909: Algorithm of BO is stuck while fusing shell and edges
[occt.git] / src / ProjLib / ProjLib_ComputeApproxOnPolarSurface.hxx
1 // Created on: 1994-10-07
2 // Created by: Bruno DUMORTIER
3 // Copyright (c) 1994-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 _ProjLib_ComputeApproxOnPolarSurface_HeaderFile
18 #define _ProjLib_ComputeApproxOnPolarSurface_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <Standard_Boolean.hxx>
25 #include <Standard_Real.hxx>
26 #include <AppParCurves_Constraint.hxx>
27 class Geom2d_BSplineCurve;
28 class Geom2d_Curve;
29 class Adaptor3d_HCurve;
30 class Adaptor3d_HSurface;
31 class Adaptor2d_HCurve2d;
32
33
34 //! Approximate the  projection  of a  3d curve  on an
35 //! polar  surface  and  stores the result  in  Approx.
36 //! The result is a  2d curve.  The evaluation of  the
37 //! current  point of the  2d  curve is done with  the
38 //! evaluation of the extrema  P3d - Surface.
39 //! For approximation some parameters are used, including 
40 //! required tolerance of approximation.
41 //! Tolerance is maximal possible value of 3d deviation of 3d projection of projected curve from
42 //! "exact" 3d projection. Since algorithm searches 2d curve on surface, required 2d tolerance is computed
43 //! from 3d tolerance with help of U,V resolutions of surface.
44 //! 3d and 2d tolerances have sence only for curves on surface, it defines precision of projecting and approximation
45 //! and have nothing to do with distance between the projected curve and the surface.
46 class ProjLib_ComputeApproxOnPolarSurface 
47 {
48 public:
49
50   DEFINE_STANDARD_ALLOC
51
52   //! Empty constructor, it only sets some initial values for class fields.
53   Standard_EXPORT ProjLib_ComputeApproxOnPolarSurface();
54
55   //! Constructor, which performs projecting.
56   Standard_EXPORT ProjLib_ComputeApproxOnPolarSurface(const Handle(Adaptor3d_HCurve)& C, const Handle(Adaptor3d_HSurface)& S, const Standard_Real Tol = 1.0e-4);
57
58
59   //! Constructor, which performs projecting, using initial curve 2d InitCurve2d, which is any rough approximation of result curve. 
60   //! Parameter Tol is 3d tolerance of approximation.
61   Standard_EXPORT ProjLib_ComputeApproxOnPolarSurface(const Handle(Adaptor2d_HCurve2d)& InitCurve2d, const Handle(Adaptor3d_HCurve)& C, const Handle(Adaptor3d_HSurface)& S, const Standard_Real Tol);
62  
63   //! Constructor, which performs projecting, using two initial curves 2d: InitCurve2d and InitCurve2dBis that are any rough approximations of result curves.
64   //! This constructor is used to get two pcurves for seem edge.
65   //! Parameter Tol is 3d tolerance of approximation.
66   Standard_EXPORT ProjLib_ComputeApproxOnPolarSurface(const Handle(Adaptor2d_HCurve2d)& InitCurve2d, const Handle(Adaptor2d_HCurve2d)& InitCurve2dBis, const Handle(Adaptor3d_HCurve)& C, 
67                                                       const Handle(Adaptor3d_HSurface)& S, const Standard_Real Tol);
68
69   
70   //! Set min and max possible degree of result BSpline curve2d, which is got by approximation.
71   //! If theDegMin/Max < 0, algorithm uses values min = 2, max = 8.
72   Standard_EXPORT void SetDegree(const Standard_Integer theDegMin, const Standard_Integer theDegMax);
73
74   //! Set the parameter, which defines maximal value of parametric intervals the projected
75   //! curve can be cut for approximation. If theMaxSegments < 0, algorithm uses default 
76   //! value = 1000.
77   Standard_EXPORT void SetMaxSegments(const Standard_Integer theMaxSegments);
78
79   //! Set the parameter, which defines type of boundary condition between segments during approximation.
80   //! It can be AppParCurves_PassPoint or AppParCurves_TangencyPoint.
81   //! Default value is AppParCurves_TangencyPoint.
82   Standard_EXPORT void SetBndPnt(const AppParCurves_Constraint theBndPnt);
83
84   //! Set the parameter, which defines maximal possible distance between projected curve and surface.
85   //! It is used only for projecting on not analytical surfaces.
86   //! If theMaxDist < 0, algoritm uses default value 100.*Tolerance. 
87   //! If real distance between curve and surface more then theMaxDist, algorithm stops working.
88   Standard_EXPORT void SetMaxDist(const Standard_Real theMaxDist);
89
90   //! Set the tolerance used to project
91   //! the curve on the surface.
92   //! Default value is Precision::Approximation().
93   Standard_EXPORT void SetTolerance (const Standard_Real theTolerance);
94
95   //! Method, which performs projecting, using default values of parameters or
96   //! they must be set by corresponding methods before using.
97   Standard_EXPORT void Perform (const Handle(Adaptor3d_HCurve)& C, const Handle(Adaptor3d_HSurface)& S);
98
99   //! Method, which performs projecting, using default values of parameters or
100   //! they must be set by corresponding methods before using.
101   //! Parameter InitCurve2d is any rough estimation of 2d result curve.
102   Standard_EXPORT Handle(Geom2d_BSplineCurve) Perform (const Handle(Adaptor2d_HCurve2d)& InitCurve2d, const Handle(Adaptor3d_HCurve)& C, const Handle(Adaptor3d_HSurface)& S);
103
104   //! Builds initial 2d curve as BSpline with degree = 1 using Extrema algoritm.
105   //! Method is used in method Perform(...).
106   Standard_EXPORT Handle(Adaptor2d_HCurve2d) BuildInitialCurve2d (const Handle(Adaptor3d_HCurve)& Curve, const Handle(Adaptor3d_HSurface)& S);
107
108
109   //! Method, which performs projecting.
110   //! Method is used in method Perform(...).
111   Standard_EXPORT Handle(Geom2d_BSplineCurve) ProjectUsingInitialCurve2d (const Handle(Adaptor3d_HCurve)& Curve, const Handle(Adaptor3d_HSurface)& S, const Handle(Adaptor2d_HCurve2d)& InitCurve2d);
112
113   //! Returns result curve 2d.
114   Standard_EXPORT Handle(Geom2d_BSplineCurve) BSpline() const;
115   //! Returns second 2d curve.
116   Standard_EXPORT Handle(Geom2d_Curve) Curve2d() const;
117   
118   Standard_EXPORT Standard_Boolean IsDone() const;
119
120   //! returns the reached Tolerance.
121   Standard_EXPORT Standard_Real Tolerance() const;
122
123
124
125 protected:
126
127
128
129
130
131 private:
132
133
134
135   Standard_Boolean myProjIsDone;
136   Standard_Real myTolerance;
137   Handle(Geom2d_BSplineCurve) myBSpline;
138   Handle(Geom2d_Curve) my2ndCurve;
139   Standard_Real myTolReached;
140   Standard_Integer myDegMin;
141   Standard_Integer myDegMax;
142   Standard_Integer myMaxSegments;
143   Standard_Real myMaxDist;
144   AppParCurves_Constraint myBndPnt;
145
146
147 };
148
149
150
151
152
153
154
155 #endif // _ProjLib_ComputeApproxOnPolarSurface_HeaderFile