42cf5bc1 |
1 | // Created on: 1998-07-30 |
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_FreeBoundsProperties_HeaderFile |
18 | #define _ShapeAnalysis_FreeBoundsProperties_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <TopoDS_Shape.hxx> |
25 | #include <Standard_Real.hxx> |
26 | #include <Standard_Boolean.hxx> |
27 | #include <ShapeAnalysis_HSequenceOfFreeBounds.hxx> |
28 | #include <Standard_Integer.hxx> |
29 | class TopoDS_Shape; |
30 | class ShapeAnalysis_FreeBoundData; |
31 | class TopoDS_Wire; |
32 | |
33 | |
34 | //! This class is intended to calculate shape free bounds |
35 | //! properties. |
36 | //! This class provides the following functionalities: |
37 | //! - calculates area of the contour, |
38 | //! - calculates perimeter of the contour, |
39 | //! - calculates ratio of average length to average width of the |
40 | //! contour, |
41 | //! - estimates average width of contour, |
42 | //! - finds the notches (narrow 'V'-like sub-contour) on the |
43 | //! contour. |
44 | //! |
45 | //! For getting free bounds this class uses |
46 | //! ShapeAnalysis_FreeBounds class. |
47 | //! |
48 | //! For description of parameters used for initializing this |
49 | //! class refer to CDL of ShapeAnalysis_FreeBounds. |
50 | //! |
51 | //! Properties of each contour are stored in the data structure |
52 | //! ShapeAnalysis_FreeBoundData. |
53 | class ShapeAnalysis_FreeBoundsProperties |
54 | { |
55 | public: |
56 | |
57 | DEFINE_STANDARD_ALLOC |
58 | |
59 | |
60 | //! Empty constructor |
61 | Standard_EXPORT ShapeAnalysis_FreeBoundsProperties(); |
62 | |
63 | //! Creates the object and calls corresponding Init. |
64 | //! <shape> should be a compound of faces. |
65 | Standard_EXPORT ShapeAnalysis_FreeBoundsProperties(const TopoDS_Shape& shape, const Standard_Real tolerance, const Standard_Boolean splitclosed = Standard_False, const Standard_Boolean splitopen = Standard_False); |
66 | |
67 | //! Creates the object and calls corresponding Init. |
68 | //! <shape> should be a compound of shells. |
69 | Standard_EXPORT ShapeAnalysis_FreeBoundsProperties(const TopoDS_Shape& shape, const Standard_Boolean splitclosed = Standard_False, const Standard_Boolean splitopen = Standard_False); |
70 | |
71 | //! Initializes the object with given parameters. |
72 | //! <shape> should be a compound of faces. |
73 | Standard_EXPORT void Init (const TopoDS_Shape& shape, const Standard_Real tolerance, const Standard_Boolean splitclosed = Standard_False, const Standard_Boolean splitopen = Standard_False); |
74 | |
75 | //! Initializes the object with given parameters. |
76 | //! <shape> should be a compound of shells. |
77 | Standard_EXPORT void Init (const TopoDS_Shape& shape, const Standard_Boolean splitclosed = Standard_False, const Standard_Boolean splitopen = Standard_False); |
78 | |
79 | //! Builds and analyzes free bounds of the shape. |
80 | //! First calls ShapeAnalysis_FreeBounds for building free |
81 | //! bounds. |
82 | //! Then on each free bound computes its properties: |
83 | //! - area of the contour, |
84 | //! - perimeter of the contour, |
85 | //! - ratio of average length to average width of the contour, |
86 | //! - average width of contour, |
87 | //! - notches on the contour and for each notch |
88 | //! - maximum width of the notch. |
89 | Standard_EXPORT Standard_Boolean Perform(); |
90 | |
91 | //! Returns True if shape is loaded |
92 | Standard_Boolean IsLoaded() const; |
93 | |
94 | //! Returns shape |
95 | TopoDS_Shape Shape() const; |
96 | |
97 | //! Returns tolerance |
98 | Standard_Real Tolerance() const; |
99 | |
100 | //! Returns number of free bounds |
101 | Standard_Integer NbFreeBounds() const; |
102 | |
103 | //! Returns number of closed free bounds |
104 | Standard_Integer NbClosedFreeBounds() const; |
105 | |
106 | //! Returns number of open free bounds |
107 | Standard_Integer NbOpenFreeBounds() const; |
108 | |
109 | //! Returns all closed free bounds |
110 | Handle(ShapeAnalysis_HSequenceOfFreeBounds) ClosedFreeBounds() const; |
111 | |
112 | //! Returns all open free bounds |
113 | Handle(ShapeAnalysis_HSequenceOfFreeBounds) OpenFreeBounds() const; |
114 | |
115 | //! Returns properties of closed free bound specified by its rank |
116 | //! number |
117 | Handle(ShapeAnalysis_FreeBoundData) ClosedFreeBound (const Standard_Integer index) const; |
118 | |
119 | //! Returns properties of open free bound specified by its rank |
120 | //! number |
121 | Handle(ShapeAnalysis_FreeBoundData) OpenFreeBound (const Standard_Integer index) const; |
122 | |
123 | Standard_EXPORT Standard_Boolean DispatchBounds(); |
124 | |
125 | Standard_EXPORT Standard_Boolean CheckContours (const Standard_Real prec = 0.0); |
126 | |
127 | Standard_EXPORT Standard_Boolean CheckNotches (const Standard_Real prec = 0.0); |
128 | |
129 | Standard_EXPORT Standard_Boolean CheckNotches (Handle(ShapeAnalysis_FreeBoundData)& fbData, const Standard_Real prec = 0.0); |
130 | |
131 | Standard_EXPORT Standard_Boolean CheckNotches (const TopoDS_Wire& freebound, const Standard_Integer num, TopoDS_Wire& notch, Standard_Real& distMax, const Standard_Real prec = 0.0); |
132 | |
133 | Standard_EXPORT Standard_Boolean FillProperties (Handle(ShapeAnalysis_FreeBoundData)& fbData, const Standard_Real prec = 0.0); |
134 | |
135 | |
136 | |
137 | |
138 | protected: |
139 | |
140 | |
141 | |
142 | |
143 | |
144 | private: |
145 | |
146 | |
147 | |
148 | TopoDS_Shape myShape; |
149 | Standard_Real myTolerance; |
150 | Standard_Boolean mySplitClosed; |
151 | Standard_Boolean mySplitOpen; |
152 | Handle(ShapeAnalysis_HSequenceOfFreeBounds) myClosedFreeBounds; |
153 | Handle(ShapeAnalysis_HSequenceOfFreeBounds) myOpenFreeBounds; |
154 | |
155 | |
156 | }; |
157 | |
158 | |
159 | #include <ShapeAnalysis_FreeBoundsProperties.lxx> |
160 | |
161 | |
162 | |
163 | |
164 | |
165 | #endif // _ShapeAnalysis_FreeBoundsProperties_HeaderFile |