0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / ShapeAnalysis / ShapeAnalysis_ShapeTolerance.hxx
1 // Created on: 1998-06-03
2 // Created by: data exchange team
3 // Copyright (c) 1998-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 _ShapeAnalysis_ShapeTolerance_HeaderFile
18 #define _ShapeAnalysis_ShapeTolerance_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <Standard_Real.hxx>
25 #include <Standard_Integer.hxx>
26 #include <TopAbs_ShapeEnum.hxx>
27 #include <TopTools_HSequenceOfShape.hxx>
28 class TopoDS_Shape;
29
30
31 //! Tool for computing shape tolerances (minimal, maximal, average),
32 //! finding shape with tolerance matching given criteria,
33 //! setting or limitating tolerances.
34 class ShapeAnalysis_ShapeTolerance 
35 {
36 public:
37
38   DEFINE_STANDARD_ALLOC
39
40   
41   //! Empty constructor
42   Standard_EXPORT ShapeAnalysis_ShapeTolerance();
43   
44   //! Determines a tolerance from the ones stored in a shape
45   //! Remark : calls InitTolerance and AddTolerance,
46   //! hence, can be used to start a series for cumulating tolerance
47   //! <mode> = 0 : returns the average value between sub-shapes,
48   //! <mode> > 0 : returns the maximal found,
49   //! <mode> < 0 : returns the minimal found.
50   //! <type> defines what kinds of sub-shapes to consider:
51   //! SHAPE (default) : all : VERTEX, EDGE, FACE,
52   //! VERTEX : only vertices,
53   //! EDGE   : only edges,
54   //! FACE   : only faces,
55   //! SHELL  : combined SHELL + FACE, for each face (and containing
56   //! shell), also checks EDGE and VERTEX
57   Standard_EXPORT Standard_Real Tolerance (const TopoDS_Shape& shape, const Standard_Integer mode, const TopAbs_ShapeEnum type = TopAbs_SHAPE);
58   
59   //! Determines which shapes have a tolerance over the given value
60   //! <type> is interpreted as in the method Tolerance
61   Standard_EXPORT Handle(TopTools_HSequenceOfShape) OverTolerance (const TopoDS_Shape& shape, const Standard_Real value, const TopAbs_ShapeEnum type = TopAbs_SHAPE) const;
62   
63   //! Determines which shapes have a tolerance within a given interval
64   //! <type> is interpreted as in the method Tolerance
65   Standard_EXPORT Handle(TopTools_HSequenceOfShape) InTolerance (const TopoDS_Shape& shape, const Standard_Real valmin, const Standard_Real valmax, const TopAbs_ShapeEnum type = TopAbs_SHAPE) const;
66   
67   //! Initializes computation of cumulated tolerance
68   Standard_EXPORT void InitTolerance();
69   
70   //! Adds data on new Shape to compute Cumulated Tolerance
71   //! (prepares three computations : maximal, average, minimal)
72   Standard_EXPORT void AddTolerance (const TopoDS_Shape& shape, const TopAbs_ShapeEnum type = TopAbs_SHAPE);
73   
74   //! Returns the computed tolerance according to the <mode>
75   //! <mode> = 0 : average
76   //! <mode> > 0 : maximal
77   //! <mode> < 0 : minimal
78   Standard_EXPORT Standard_Real GlobalTolerance (const Standard_Integer mode) const;
79
80
81
82
83 protected:
84
85
86
87
88
89 private:
90
91
92
93   Standard_Real myTols[3];
94   Standard_Integer myNbTol;
95
96
97 };
98
99
100
101
102
103
104
105 #endif // _ShapeAnalysis_ShapeTolerance_HeaderFile