0032721: Modeling Algorithms - BOP wrong results on a cone and an extrusion
[occt.git] / src / IntPatch / IntPatch_ALineToWLine.hxx
1 // Created on: 1993-11-26
2 // Created by: Modelistation
3 // Copyright (c) 1993-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 _IntPatch_ALineToWLine_HeaderFile
18 #define _IntPatch_ALineToWLine_HeaderFile
19
20 #include <Adaptor3d_Surface.hxx>
21 #include <IntPatch_SequenceOfLine.hxx>
22 #include <IntSurf_Quadric.hxx>
23 #include <IntSurf_LineOn2S.hxx>
24
25 class IntPatch_ALine;
26 class IntSurf_PntOn2S;
27
28 class IntPatch_ALineToWLine 
29 {
30 public:
31
32   DEFINE_STANDARD_ALLOC
33
34   //! Constructor
35   Standard_EXPORT IntPatch_ALineToWLine(const Handle(Adaptor3d_Surface)& theS1,
36                                         const Handle(Adaptor3d_Surface)& theS2,
37                                         const Standard_Integer theNbPoints = 200);
38   
39   Standard_EXPORT void SetTolOpenDomain (const Standard_Real aT);
40   
41   Standard_EXPORT Standard_Real TolOpenDomain() const;
42   
43   Standard_EXPORT void SetTolTransition (const Standard_Real aT);
44   
45   Standard_EXPORT Standard_Real TolTransition() const;
46   
47   Standard_EXPORT void SetTol3D (const Standard_Real aT);
48   
49   Standard_EXPORT Standard_Real Tol3D() const;
50   
51   //! Converts aline to the set of Walking-lines and adds
52   //! them in theLines.
53   Standard_EXPORT void MakeWLine (const Handle(IntPatch_ALine)& aline,
54                                   IntPatch_SequenceOfLine& theLines) const;
55   
56   //! Converts aline (limited by paraminf and paramsup) to the set of
57   //! Walking-lines and adds them in theLines.
58   Standard_EXPORT void MakeWLine (const Handle(IntPatch_ALine)& aline,
59                                   const Standard_Real paraminf,
60                                   const Standard_Real paramsup,
61                                   IntPatch_SequenceOfLine& theLines) const;
62
63 protected:
64   //! Computes step value to construct point-line. The step depends on
65   //! the local curvature of the intersection line computed in thePOn2S.
66   //! theTgMagnitude is the magnitude of tangent vector to the intersection
67   //! line (in the point thePOn2S).
68   //! Computed step is always in the range [theStepMin, theStepMax].
69   //! Returns FALSE if the step cannot be computed. In this case, its value
70   //! will not be changed.
71   Standard_EXPORT Standard_Boolean StepComputing(const Handle(IntPatch_ALine)& theALine,
72                                                  const IntSurf_PntOn2S& thePOn2S,
73                                                  const Standard_Real theLastParOfAline,
74                                                  const Standard_Real theCurParam,
75                                                  const Standard_Real theTgMagnitude,
76                                                  const Standard_Real theStepMin,
77                                                  const Standard_Real theStepMax,
78                                                  const Standard_Real theMaxDeflection,
79                                                  Standard_Real& theStep) const;
80
81   //! Compares distances from theMidPt to every quadrics with theMaxDeflection
82   //! (maximal distance of two ones is taken into account).
83   //! Returns the result of this comparison: -1 - small distance, +1 - big distance,
84   //! 0 - Dist == theMaxDeflection. Comparisons are done with internal tolerances.
85   Standard_EXPORT Standard_Integer CheckDeflection(const gp_XYZ& theMidPt,
86                                                    const Standard_Real theMaxDeflection) const;
87
88   //! Returns radius of a circle obtained by intersection the quadric with a plane
89   //! goes through thePnt3d perpendicular to the quadric axis. This radius is computed
90   //! for both quadrics and minimal value is returned.
91   //! This check is made for cone and sphere only.
92   Standard_EXPORT Standard_Real GetSectionRadius(const gp_Pnt& thePnt3d) const;
93
94   //! Corrects the U-parameter of an end point (first or last) of the line
95   //! if this end point is a pole.
96   //! The line must contain at least 3 points.
97   //! This is made for cone and sphere only.
98   Standard_EXPORT void CorrectEndPoint(Handle(IntSurf_LineOn2S)& theLine,
99                                        const Standard_Integer    theIndex) const;
100
101 private:
102
103
104   Handle(Adaptor3d_Surface) myS1;
105   Handle(Adaptor3d_Surface) myS2;
106   IntSurf_Quadric myQuad1;
107   IntSurf_Quadric myQuad2;
108
109   //! Approximate number of points in resulting
110   //! WLine (precise number of points is computed
111   //! by the algorithms)
112   Standard_Integer myNbPointsInWline;
113   Standard_Real myTolOpenDomain;
114   Standard_Real myTolTransition;
115   Standard_Real myTol3D;
116 };
117
118 #endif // _IntPatch_ALineToWLine_HeaderFile