0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / BRepApprox / BRepApprox_Approx.hxx
1 // Created on: 1995-06-06
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1995-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 _BRepApprox_Approx_HeaderFile
18 #define _BRepApprox_Approx_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <NCollection_Vector.hxx>
25 #include <BRepApprox_TheComputeLineOfApprox.hxx>
26 #include <BRepApprox_TheComputeLineBezierOfApprox.hxx>
27 #include <Approx_MCurvesToBSpCurve.hxx>
28 #include <Standard_Boolean.hxx>
29 #include <Standard_Real.hxx>
30 #include <Standard_Integer.hxx>
31 #include <Approx_ParametrizationType.hxx>
32 class Standard_OutOfRange;
33 class StdFail_NotDone;
34 class BRepAdaptor_Surface;
35 class BRepApprox_SurfaceTool;
36 class IntSurf_Quadric;
37 class IntSurf_QuadricTool;
38 class BRepApprox_ApproxLine;
39 class BRepApprox_ThePrmPrmSvSurfacesOfApprox;
40 class BRepApprox_TheInt2SOfThePrmPrmSvSurfacesOfApprox;
41 class BRepApprox_TheImpPrmSvSurfacesOfApprox;
42 class BRepApprox_TheZerImpFuncOfTheImpPrmSvSurfacesOfApprox;
43 class BRepApprox_TheMultiLineOfApprox;
44 class BRepApprox_TheMultiLineToolOfApprox;
45 class BRepApprox_TheComputeLineOfApprox;
46 class BRepApprox_MyBSplGradientOfTheComputeLineOfApprox;
47 class BRepApprox_MyGradientbisOfTheComputeLineOfApprox;
48 class BRepApprox_TheComputeLineBezierOfApprox;
49 class BRepApprox_MyGradientOfTheComputeLineBezierOfApprox;
50 class AppParCurves_MultiBSpCurve;
51
52 struct Approx_Data 
53 {
54   Approx_Data() : myBezierApprox(Standard_True),
55                   Xo(0.0), Yo(0.0), Zo(0.0),
56                   U1o(0.0), V1o(0.0), U2o(0.0), V2o(0.0),
57                   ApproxXYZ(Standard_True),
58                   ApproxU1V1(Standard_True),
59                   ApproxU2V2(Standard_True),
60                   indicemin(0), indicemax(0),
61                   myNbPntMax(30), parametrization(Approx_ChordLength)
62   {
63   }
64
65   Standard_Boolean myBezierApprox;
66   Standard_Real  Xo, Yo, Zo, U1o, V1o, U2o, V2o;
67   Standard_Boolean ApproxXYZ, ApproxU1V1, ApproxU2V2;
68   Standard_Integer indicemin, indicemax, myNbPntMax;
69   Approx_ParametrizationType parametrization;
70 };
71
72 class BRepApprox_Approx 
73 {
74 public:
75
76   DEFINE_STANDARD_ALLOC
77
78   
79   Standard_EXPORT BRepApprox_Approx();
80   
81   Standard_EXPORT void Perform (const BRepAdaptor_Surface& Surf1, const BRepAdaptor_Surface& Surf2, const Handle(BRepApprox_ApproxLine)& aLine, const Standard_Boolean ApproxXYZ = Standard_True, const Standard_Boolean ApproxU1V1 = Standard_True, const Standard_Boolean ApproxU2V2 = Standard_True, const Standard_Integer indicemin = 0, const Standard_Integer indicemax = 0);
82   
83   Standard_EXPORT void Perform (const Handle(BRepApprox_ApproxLine)& aLine, const Standard_Boolean ApproxXYZ = Standard_True, const Standard_Boolean ApproxU1V1 = Standard_True, const Standard_Boolean ApproxU2V2 = Standard_True, const Standard_Integer indicemin = 0, const Standard_Integer indicemax = 0);
84   
85   Standard_EXPORT 
86       void SetParameters (const Standard_Real Tol3d, const Standard_Real Tol2d,
87                           const Standard_Integer DegMin, 
88                           const Standard_Integer DegMax,
89                           const Standard_Integer NbIterMax,
90                           const Standard_Integer NbPntMax = 30,
91                           const Standard_Boolean ApproxWithTangency = Standard_True,
92                           const Approx_ParametrizationType
93                                           Parametrization = Approx_ChordLength);
94
95   Standard_EXPORT void Perform();
96   
97   Standard_EXPORT Standard_Real TolReached3d() const;
98   
99   Standard_EXPORT Standard_Real TolReached2d() const;
100   
101   Standard_EXPORT Standard_Boolean IsDone() const;
102   
103   Standard_EXPORT Standard_Integer NbMultiCurves() const;
104   
105   Standard_EXPORT const AppParCurves_MultiBSpCurve& Value (const Standard_Integer Index) const;
106
107
108
109
110 protected:
111
112
113
114
115
116 private:
117   Standard_EXPORT void Perform (const IntSurf_Quadric& Surf1, const BRepAdaptor_Surface& Surf2, const Handle(BRepApprox_ApproxLine)& aLine, const Standard_Boolean ApproxXYZ, const Standard_Boolean ApproxU1V1, const Standard_Boolean ApproxU2V2, const Standard_Integer indicemin, const Standard_Integer indicemax, const Standard_Boolean isTheQuadFirst);
118   
119   Standard_EXPORT void UpdateTolReached();
120
121   //! Fill data structure for intersection approximation.
122   Standard_EXPORT void fillData(const Handle(BRepApprox_ApproxLine)& theLine);
123
124   //! Prepare data structure for further computations.
125   Standard_EXPORT void prepareDS(const Standard_Boolean theApproxXYZ,
126                                  const Standard_Boolean theApproxU1V1,
127                                  const Standard_Boolean theApproxU2V2,
128                                  const Standard_Integer indicemin,
129                                  const Standard_Integer indicemax);
130
131   //! Build knot sequence.
132   Standard_EXPORT void buildKnots(const Handle(BRepApprox_ApproxLine)& theline,
133                                   const Standard_Address thePtrSVSurf);
134
135   //! Build curve.
136   Standard_EXPORT void buildCurve(const Handle(BRepApprox_ApproxLine)& theline,
137                                   const Standard_Address thePtrSVSurf);
138
139   BRepApprox_TheComputeLineOfApprox myComputeLine;
140   BRepApprox_TheComputeLineBezierOfApprox myComputeLineBezier;
141   Approx_MCurvesToBSpCurve myBezToBSpl;
142   Standard_Boolean myWithTangency;
143   Standard_Real myTol3d;
144   Standard_Real myTol2d;
145   Standard_Integer myDegMin;
146   Standard_Integer myDegMax;
147   Standard_Integer myNbIterMax;
148   Standard_Real myTolReached3d;
149   Standard_Real myTolReached2d;
150   Approx_Data myData;
151   NCollection_Vector<Standard_Integer> myKnots;
152
153 };
154
155
156
157
158
159
160
161 #endif // _BRepApprox_Approx_HeaderFile