1 // Created on: 1995-05-29
2 // Created by: Xavier BENVENISTE
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 _AdvApprox_ApproxAFunction_HeaderFile
18 #define _AdvApprox_ApproxAFunction_HeaderFile
19 
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23 
24 #include <Standard_Integer.hxx>
25 #include <TColStd_HArray1OfReal.hxx>
26 #include <Standard_Real.hxx>
27 #include <GeomAbs_Shape.hxx>
28 #include <Standard_Boolean.hxx>
29 #include <TColStd_HArray2OfReal.hxx>
30 #include <TColgp_HArray2OfPnt2d.hxx>
31 #include <TColgp_HArray2OfPnt.hxx>
32 #include <TColStd_HArray1OfInteger.hxx>
33 #include <Standard_Address.hxx>
34 #include <AdvApprox_EvaluatorFunction.hxx>
35 #include <TColStd_Array1OfInteger.hxx>
36 #include <TColStd_Array1OfReal.hxx>
37 #include <TColgp_Array1OfPnt2d.hxx>
38 #include <TColgp_Array1OfPnt.hxx>
39 #include <Standard_OStream.hxx>
40 class Standard_OutOfRange;
41 class Standard_ConstructionError;
42 class AdvApprox_Cutting;
43 
44 
45 
46 //! this approximate a given function
47 class AdvApprox_ApproxAFunction
48 {
49 public:
50 
51   DEFINE_STANDARD_ALLOC
52 
53 
54   //! Constructs approximator tool.
55   //!
56   //! Warning:
57   //! the Func should be valid reference to object of type
58   //! inherited from class EvaluatorFunction from Approx
59   //! with life time longer than that of the approximator tool;
60   //!
61   //! the result should be formatted in the following way :
62   //! <--Num1DSS--> <--2 * Num2DSS--> <--3 * Num3DSS-->
63   //! R[0] ....     R[Num1DSS].....                   R[Dimension-1]
64   //!
65   //! the order in which each Subspace appears should be consistent
66   //! with the tolerances given in the create function and the
67   //! results will be given in that order as well that is :
68   //! Curve2d(n)  will correspond to the nth entry
69   //! described by Num2DSS, Curve(n) will correspond to
70   //! the nth entry described by Num3DSS
71   //! The same type of schema applies to the Poles1d, Poles2d and
72   //! Poles.
73   Standard_EXPORT AdvApprox_ApproxAFunction(const Standard_Integer Num1DSS, const Standard_Integer Num2DSS, const Standard_Integer Num3DSS, const Handle(TColStd_HArray1OfReal)& OneDTol, const Handle(TColStd_HArray1OfReal)& TwoDTol, const Handle(TColStd_HArray1OfReal)& ThreeDTol, const Standard_Real First, const Standard_Real Last, const GeomAbs_Shape Continuity, const Standard_Integer MaxDeg, const Standard_Integer MaxSeg, const AdvApprox_EvaluatorFunction& Func);
74 
75   //! Approximation with user methode of cutting
76   Standard_EXPORT AdvApprox_ApproxAFunction(const Standard_Integer Num1DSS, const Standard_Integer Num2DSS, const Standard_Integer Num3DSS, const Handle(TColStd_HArray1OfReal)& OneDTol, const Handle(TColStd_HArray1OfReal)& TwoDTol, const Handle(TColStd_HArray1OfReal)& ThreeDTol, const Standard_Real First, const Standard_Real Last, const GeomAbs_Shape Continuity, const Standard_Integer MaxDeg, const Standard_Integer MaxSeg, const AdvApprox_EvaluatorFunction& Func, const AdvApprox_Cutting& CutTool);
77 
78   Standard_EXPORT static void Approximation (const Standard_Integer TotalDimension, const Standard_Integer TotalNumSS, const TColStd_Array1OfInteger& LocalDimension, const Standard_Real First, const Standard_Real Last, AdvApprox_EvaluatorFunction& Evaluator, const AdvApprox_Cutting& CutTool, const Standard_Integer ContinuityOrder, const Standard_Integer NumMaxCoeffs, const Standard_Integer MaxSegments, const TColStd_Array1OfReal& TolerancesArray, const Standard_Integer code_precis, Standard_Integer& NumCurves, TColStd_Array1OfInteger& NumCoeffPerCurveArray, TColStd_Array1OfReal& LocalCoefficientArray, TColStd_Array1OfReal& IntervalsArray, TColStd_Array1OfReal& ErrorMaxArray, TColStd_Array1OfReal& AverageErrorArray, Standard_Integer& ErrorCode);
79 
80     Standard_Boolean IsDone() const;
81 
82     Standard_Boolean HasResult() const;
83 
84   //! returns the poles from the algorithms as is
85     Handle(TColStd_HArray2OfReal) Poles1d() const;
86 
87   //! returns the poles from the algorithms as is
88     Handle(TColgp_HArray2OfPnt2d) Poles2d() const;
89 
90   //! -- returns the poles from the algorithms as is
91     Handle(TColgp_HArray2OfPnt) Poles() const;
92 
93   //! as the name says
94   Standard_EXPORT Standard_Integer NbPoles() const;
95 
96   //! returns the poles at Index from the 1d subspace
97   Standard_EXPORT void Poles1d (const Standard_Integer Index, TColStd_Array1OfReal& P) const;
98 
99   //! returns the poles at Index from the 2d subspace
100   Standard_EXPORT void Poles2d (const Standard_Integer Index, TColgp_Array1OfPnt2d& P) const;
101 
102   //! returns the poles at Index from the 3d subspace
103   Standard_EXPORT void Poles (const Standard_Integer Index, TColgp_Array1OfPnt& P) const;
104 
105     Standard_Integer Degree() const;
106 
107     Standard_Integer NbKnots() const;
108 
109     Standard_Integer NumSubSpaces (const Standard_Integer Dimension) const;
110 
111     Handle(TColStd_HArray1OfReal) Knots() const;
112 
113     Handle(TColStd_HArray1OfInteger) Multiplicities() const;
114 
115   //! returns the error as is in the algorithms
116   Standard_EXPORT Handle(TColStd_HArray1OfReal) MaxError (const Standard_Integer Dimension) const;
117 
118   //! returns the error as is in the algorithms
119   Standard_EXPORT Handle(TColStd_HArray1OfReal) AverageError (const Standard_Integer Dimension) const;
120 
121   Standard_EXPORT Standard_Real MaxError (const Standard_Integer Dimension, const Standard_Integer Index) const;
122 
123   Standard_EXPORT Standard_Real AverageError (const Standard_Integer Dimension, const Standard_Integer Index) const;
124 
125   //! diplay information on approximation.
126   Standard_EXPORT void Dump (Standard_OStream& o) const;
127 
128 
129 
130 
131 protected:
132 
133 
134 
135 
136 
137 private:
138 
139 
140   Standard_EXPORT void Perform (const Standard_Integer Num1DSS, const Standard_Integer Num2DSS, const Standard_Integer Num3DSS, const AdvApprox_Cutting& CutTool);
141 
142 
143   Standard_Integer myNumSubSpaces[3];
144   Handle(TColStd_HArray1OfReal) my1DTolerances;
145   Handle(TColStd_HArray1OfReal) my2DTolerances;
146   Handle(TColStd_HArray1OfReal) my3DTolerances;
147   Standard_Real myFirst;
148   Standard_Real myLast;
149   GeomAbs_Shape myContinuity;
150   Standard_Integer myMaxDegree;
151   Standard_Integer myMaxSegments;
152   Standard_Boolean myDone;
153   Standard_Boolean myHasResult;
154   Handle(TColStd_HArray2OfReal) my1DPoles;
155   Handle(TColgp_HArray2OfPnt2d) my2DPoles;
156   Handle(TColgp_HArray2OfPnt) my3DPoles;
157   Handle(TColStd_HArray1OfReal) myKnots;
158   Handle(TColStd_HArray1OfInteger) myMults;
159   Standard_Integer myDegree;
160   Standard_Address myEvaluator;
161   Handle(TColStd_HArray1OfReal) my1DMaxError;
162   Handle(TColStd_HArray1OfReal) my1DAverageError;
163   Handle(TColStd_HArray1OfReal) my2DMaxError;
164   Handle(TColStd_HArray1OfReal) my2DAverageError;
165   Handle(TColStd_HArray1OfReal) my3DMaxError;
166   Handle(TColStd_HArray1OfReal) my3DAverageError;
167 
168 
169 };
170 
171 
172 #include <AdvApprox_ApproxAFunction.lxx>
173 
174 
175 
176 
177 
178 #endif // _AdvApprox_ApproxAFunction_HeaderFile
179