0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / GeomConvert / GeomConvert_ApproxSurface.hxx
1 // Created on: 1997-08-26
2 // Created by: Stepan MISHIN
3 // Copyright (c) 1997-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 _GeomConvert_ApproxSurface_HeaderFile
18 #define _GeomConvert_ApproxSurface_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 <GeomAbs_Shape.hxx>
27 #include <Standard_Integer.hxx>
28 #include <Standard_OStream.hxx>
29 class Geom_BSplineSurface;
30 class Standard_OutOfRange;
31 class Geom_Surface;
32 class Adaptor3d_HSurface;
33
34
35 //! A framework to convert a surface to a BSpline
36 //! surface. This is done by approximation to a BSpline
37 //! surface within a given tolerance.
38 class GeomConvert_ApproxSurface 
39 {
40 public:
41
42   DEFINE_STANDARD_ALLOC
43
44   
45   //! Constructs a surface approximation framework defined by
46   //! -   the conic Surf
47   //! -   the tolerance value Tol3d
48   //! -   the degree of continuity UContinuity, VContinuity
49   //! in the directions of the U and V parameters
50   //! -   the highest degree MaxDegU, MaxDegV which
51   //! the polynomial defining the BSpline curve may
52   //! have in the directions of the U and V parameters
53   //! -   the maximum number of segments MaxSegments
54   //! allowed in the resulting BSpline curve
55   //! -   the index of precision PrecisCode.
56   Standard_EXPORT GeomConvert_ApproxSurface(const Handle(Geom_Surface)& Surf, const Standard_Real Tol3d, const GeomAbs_Shape UContinuity, const GeomAbs_Shape VContinuity, const Standard_Integer MaxDegU, const Standard_Integer MaxDegV, const Standard_Integer MaxSegments, const Standard_Integer PrecisCode);
57   
58   //! Constructs a surface approximation framework defined by
59   //! -   the Surf
60   //! -   the tolerance value Tol3d
61   //! -   the degree of continuity UContinuity, VContinuity
62   //! in the directions of the U and V parameters
63   //! -   the highest degree MaxDegU, MaxDegV which
64   //! the polynomial defining the BSpline curve may
65   //! have in the directions of the U and V parameters
66   //! -   the maximum number of segments MaxSegments
67   //! allowed in the resulting BSpline curve
68   //! -   the index of precision PrecisCode.
69   Standard_EXPORT GeomConvert_ApproxSurface(const Handle(Adaptor3d_HSurface)& Surf, const Standard_Real Tol3d, const GeomAbs_Shape UContinuity, const GeomAbs_Shape VContinuity, const Standard_Integer MaxDegU, const Standard_Integer MaxDegV, const Standard_Integer MaxSegments, const Standard_Integer PrecisCode);
70   
71   //! Returns the BSpline surface resulting from the approximation algorithm.
72   Standard_EXPORT Handle(Geom_BSplineSurface) Surface() const;
73   
74   //! Returns Standard_True if the approximation has be done
75   Standard_EXPORT Standard_Boolean IsDone() const;
76   
77   //! Returns true if the approximation did come out with a result that
78   //! is not NECESSARILY within the required tolerance or a result
79   //! that is not recognized with the wished continuities.
80   Standard_EXPORT Standard_Boolean HasResult() const;
81   
82   //! Returns the greatest distance between a point on the
83   //! source conic surface and the BSpline surface
84   //! resulting from the approximation (>0 when an approximation
85   //! has been done, 0 if no  approximation )
86   Standard_EXPORT Standard_Real MaxError() const;
87   
88   //! Prints on the stream o informations on the current state of the object.
89   Standard_EXPORT void Dump (Standard_OStream& o) const;
90
91
92
93
94 protected:
95
96
97
98
99
100 private:
101
102   
103   //! Converts a surface to B-spline
104   Standard_EXPORT void Approximate (const Handle(Adaptor3d_HSurface)& theSurf, const Standard_Real theTol3d, const GeomAbs_Shape theUContinuity, const GeomAbs_Shape theVContinuity, const Standard_Integer theMaxDegU, const Standard_Integer theMaxDegV, const Standard_Integer theMaxSegments, const Standard_Integer thePrecisCode);
105
106
107   Standard_Boolean myIsDone;
108   Standard_Boolean myHasResult;
109   Handle(Geom_BSplineSurface) myBSplSurf;
110   Standard_Real myMaxError;
111
112
113 };
114
115
116
117
118
119
120
121 #endif // _GeomConvert_ApproxSurface_HeaderFile