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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _ShapeAnalysis_FreeBoundsProperties_HeaderFile
18 #define _ShapeAnalysis_FreeBoundsProperties_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <TopoDS_Shape.hxx>
25 #include <ShapeAnalysis_HSequenceOfFreeBounds.hxx>
26 #include <Standard_Integer.hxx>
27 class ShapeAnalysis_FreeBoundData;
31 //! This class is intended to calculate shape free bounds
33 //! This class provides the following functionalities:
34 //! - calculates area of the contour,
35 //! - calculates perimeter of the contour,
36 //! - calculates ratio of average length to average width of the
38 //! - estimates average width of contour,
39 //! - finds the notches (narrow 'V'-like sub-contour) on the
42 //! For getting free bounds this class uses
43 //! ShapeAnalysis_FreeBounds class.
45 //! For description of parameters used for initializing this
46 //! class refer to CDL of ShapeAnalysis_FreeBounds.
48 //! Properties of each contour are stored in the data structure
49 //! ShapeAnalysis_FreeBoundData.
50 class ShapeAnalysis_FreeBoundsProperties
58 Standard_EXPORT ShapeAnalysis_FreeBoundsProperties();
60 //! Creates the object and calls corresponding Init.
61 //! <shape> should be a compound of faces.
62 Standard_EXPORT ShapeAnalysis_FreeBoundsProperties(const TopoDS_Shape& shape, const Standard_Real tolerance, const Standard_Boolean splitclosed = Standard_False, const Standard_Boolean splitopen = Standard_False);
64 //! Creates the object and calls corresponding Init.
65 //! <shape> should be a compound of shells.
66 Standard_EXPORT ShapeAnalysis_FreeBoundsProperties(const TopoDS_Shape& shape, const Standard_Boolean splitclosed = Standard_False, const Standard_Boolean splitopen = Standard_False);
68 //! Initializes the object with given parameters.
69 //! <shape> should be a compound of faces.
70 Standard_EXPORT void Init (const TopoDS_Shape& shape, const Standard_Real tolerance, const Standard_Boolean splitclosed = Standard_False, const Standard_Boolean splitopen = Standard_False);
72 //! Initializes the object with given parameters.
73 //! <shape> should be a compound of shells.
74 Standard_EXPORT void Init (const TopoDS_Shape& shape, const Standard_Boolean splitclosed = Standard_False, const Standard_Boolean splitopen = Standard_False);
76 //! Builds and analyzes free bounds of the shape.
77 //! First calls ShapeAnalysis_FreeBounds for building free
79 //! Then on each free bound computes its properties:
80 //! - area of the contour,
81 //! - perimeter of the contour,
82 //! - ratio of average length to average width of the contour,
83 //! - average width of contour,
84 //! - notches on the contour and for each notch
85 //! - maximum width of the notch.
86 Standard_EXPORT Standard_Boolean Perform();
88 //! Returns True if shape is loaded
89 Standard_Boolean IsLoaded() const;
92 TopoDS_Shape Shape() const;
95 Standard_Real Tolerance() const;
97 //! Returns number of free bounds
98 Standard_Integer NbFreeBounds() const;
100 //! Returns number of closed free bounds
101 Standard_Integer NbClosedFreeBounds() const;
103 //! Returns number of open free bounds
104 Standard_Integer NbOpenFreeBounds() const;
106 //! Returns all closed free bounds
107 Handle(ShapeAnalysis_HSequenceOfFreeBounds) ClosedFreeBounds() const;
109 //! Returns all open free bounds
110 Handle(ShapeAnalysis_HSequenceOfFreeBounds) OpenFreeBounds() const;
112 //! Returns properties of closed free bound specified by its rank
114 Handle(ShapeAnalysis_FreeBoundData) ClosedFreeBound (const Standard_Integer index) const;
116 //! Returns properties of open free bound specified by its rank
118 Handle(ShapeAnalysis_FreeBoundData) OpenFreeBound (const Standard_Integer index) const;
120 Standard_EXPORT Standard_Boolean DispatchBounds();
122 Standard_EXPORT Standard_Boolean CheckContours (const Standard_Real prec = 0.0);
124 Standard_EXPORT Standard_Boolean CheckNotches (const Standard_Real prec = 0.0);
126 Standard_EXPORT Standard_Boolean CheckNotches (Handle(ShapeAnalysis_FreeBoundData)& fbData, const Standard_Real prec = 0.0);
128 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);
130 Standard_EXPORT Standard_Boolean FillProperties (Handle(ShapeAnalysis_FreeBoundData)& fbData, const Standard_Real prec = 0.0);
145 TopoDS_Shape myShape;
146 Standard_Real myTolerance;
147 Standard_Boolean mySplitClosed;
148 Standard_Boolean mySplitOpen;
149 Handle(ShapeAnalysis_HSequenceOfFreeBounds) myClosedFreeBounds;
150 Handle(ShapeAnalysis_HSequenceOfFreeBounds) myOpenFreeBounds;
156 #include <ShapeAnalysis_FreeBoundsProperties.lxx>
162 #endif // _ShapeAnalysis_FreeBoundsProperties_HeaderFile