0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / ShapeAnalysis / ShapeAnalysis_FreeBoundData.hxx
1 // Created on: 1998-08-25
2 // Created by: Pavel DURANDIN <pdn@nnov.matra-dtv.fr>
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_FreeBoundData_HeaderFile
18 #define _ShapeAnalysis_FreeBoundData_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
22
23 #include <TopoDS_Wire.hxx>
24 #include <Standard_Real.hxx>
25 #include <TopTools_HSequenceOfShape.hxx>
26 #include <TopTools_DataMapOfShapeReal.hxx>
27 #include <Standard_Transient.hxx>
28 #include <Standard_Integer.hxx>
29 class TopoDS_Wire;
30
31
32 class ShapeAnalysis_FreeBoundData;
33 DEFINE_STANDARD_HANDLE(ShapeAnalysis_FreeBoundData, Standard_Transient)
34
35 //! This class is intended to represent free bound and to store
36 //! its properties.
37 //!
38 //! This class is used by ShapeAnalysis_FreeBoundsProperties
39 //! class when storing each free bound and its properties.
40 //!
41 //! The properties stored in this class are the following:
42 //! - area of the contour,
43 //! - perimeter of the contour,
44 //! - ratio of average length to average width of the contour,
45 //! - average width of contour,
46 //! - notches (narrow 'V'-like sub-contours) on the contour and
47 //! their maximum width.
48 //!
49 //! This class provides methods for setting and getting fields
50 //! only.
51 class ShapeAnalysis_FreeBoundData : public Standard_Transient
52 {
53
54 public:
55
56   
57   //! Empty constructor
58   Standard_EXPORT ShapeAnalysis_FreeBoundData();
59   
60   //! Creates object with contour given in the form of TopoDS_Wire
61   Standard_EXPORT ShapeAnalysis_FreeBoundData(const TopoDS_Wire& freebound);
62   
63   //! Clears all properties of the contour.
64   //! Contour bound itself is not cleared.
65   Standard_EXPORT void Clear();
66   
67   //! Sets contour
68     void SetFreeBound (const TopoDS_Wire& freebound);
69   
70   //! Sets area of the contour
71     void SetArea (const Standard_Real area);
72   
73   //! Sets perimeter of the contour
74     void SetPerimeter (const Standard_Real perimeter);
75   
76   //! Sets ratio of average length to average width of the contour
77     void SetRatio (const Standard_Real ratio);
78   
79   //! Sets average width of the contour
80     void SetWidth (const Standard_Real width);
81   
82   //! Adds notch on the contour with its maximum width
83   Standard_EXPORT void AddNotch (const TopoDS_Wire& notch, const Standard_Real width);
84   
85   //! Returns contour
86     TopoDS_Wire FreeBound() const;
87   
88   //! Returns area of the contour
89     Standard_Real Area() const;
90   
91   //! Returns perimeter of the contour
92     Standard_Real Perimeter() const;
93   
94   //! Returns ratio of average length to average width of the contour
95     Standard_Real Ratio() const;
96   
97   //! Returns average width of the contour
98     Standard_Real Width() const;
99   
100   //! Returns number of notches on the contour
101     Standard_Integer NbNotches() const;
102   
103   //! Returns sequence of notches on the contour
104     Handle(TopTools_HSequenceOfShape) Notches() const;
105   
106   //! Returns notch on the contour
107     TopoDS_Wire Notch (const Standard_Integer index) const;
108   
109   //! Returns maximum width of notch specified by its rank number
110   //! on the contour
111   Standard_EXPORT Standard_Real NotchWidth (const Standard_Integer index) const;
112   
113   //! Returns maximum width of notch specified as TopoDS_Wire
114   //! on the contour
115   Standard_EXPORT Standard_Real NotchWidth (const TopoDS_Wire& notch) const;
116
117
118
119
120   DEFINE_STANDARD_RTTIEXT(ShapeAnalysis_FreeBoundData,Standard_Transient)
121
122 protected:
123
124
125
126
127 private:
128
129
130   TopoDS_Wire myBound;
131   Standard_Real myArea;
132   Standard_Real myPerimeter;
133   Standard_Real myRatio;
134   Standard_Real myWidth;
135   Handle(TopTools_HSequenceOfShape) myNotches;
136   TopTools_DataMapOfShapeReal myNotchesParams;
137
138
139 };
140
141
142 #include <ShapeAnalysis_FreeBoundData.lxx>
143
144
145
146
147
148 #endif // _ShapeAnalysis_FreeBoundData_HeaderFile