b311480e |
1 | // Created on: 1998-08-25 |
2 | // Created by: Pavel DURANDIN |
3 | // Copyright (c) 1998-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
42cf5bc1 |
17 | |
18 | #include <ShapeAnalysis_FreeBoundData.hxx> |
19 | #include <Standard_Type.hxx> |
7fd59977 |
20 | #include <TopoDS.hxx> |
42cf5bc1 |
21 | #include <TopoDS_Wire.hxx> |
22 | #include <TopTools_HSequenceOfShape.hxx> |
7fd59977 |
23 | |
25e59720 |
24 | IMPLEMENT_STANDARD_RTTIEXT(ShapeAnalysis_FreeBoundData,Standard_Transient) |
92efcf78 |
25 | |
7fd59977 |
26 | //======================================================================= |
27 | //function : ShapeAnalysis_FreeBoundData |
28 | //purpose : Empty constructor |
29 | //======================================================================= |
7fd59977 |
30 | ShapeAnalysis_FreeBoundData::ShapeAnalysis_FreeBoundData() |
31 | { |
32 | myNotches = new TopTools_HSequenceOfShape(); |
33 | Clear(); |
34 | } |
35 | |
36 | //======================================================================= |
37 | //function : ShapeAnalysis_FreeBoundData |
38 | //purpose : Creates object with contour given in the form of TopoDS_Wire |
39 | //======================================================================= |
40 | |
41 | ShapeAnalysis_FreeBoundData::ShapeAnalysis_FreeBoundData(const TopoDS_Wire& freebound) |
42 | { |
43 | myNotches = new TopTools_HSequenceOfShape(); |
44 | Clear(); |
45 | SetFreeBound(freebound); |
46 | } |
47 | |
48 | //======================================================================= |
49 | //function : Clear |
50 | //purpose : Clears all properties of the contour. Contour bound itself is not cleared. |
51 | //======================================================================= |
52 | |
53 | void ShapeAnalysis_FreeBoundData::Clear() |
54 | { |
55 | myArea = -1; |
56 | myPerimeter = -1; |
57 | myRatio = -1; |
58 | myWidth = -1; |
59 | myNotches->Clear(); |
60 | myNotchesParams.Clear(); |
61 | } |
62 | |
63 | //======================================================================= |
64 | //function : AddNotch |
65 | //purpose : Adds notch on free bound with its maximum width |
66 | //======================================================================= |
67 | |
68 | void ShapeAnalysis_FreeBoundData::AddNotch(const TopoDS_Wire& notch,const Standard_Real width) |
69 | { |
70 | if (myNotchesParams.IsBound(notch)) return; |
71 | myNotches->Append(notch); |
72 | myNotchesParams.Bind(notch, width); |
73 | } |
74 | |
75 | |
76 | //======================================================================= |
77 | //function : NotchWidth |
78 | //purpose : Returns maximum width of notch specified by its rank number |
79 | // on the contour |
80 | //======================================================================= |
81 | |
82 | Standard_Real ShapeAnalysis_FreeBoundData::NotchWidth(const Standard_Integer index) const |
83 | { |
84 | TopoDS_Wire wire = TopoDS::Wire(myNotches -> Value(index)); |
85 | return myNotchesParams.Find(wire); |
86 | } |
87 | |
88 | //======================================================================= |
89 | //function : NotchWidth |
90 | //purpose : Returns maximum width of notch specified as TopoDS_Wire |
91 | // on the contour |
92 | //======================================================================= |
93 | |
94 | Standard_Real ShapeAnalysis_FreeBoundData::NotchWidth(const TopoDS_Wire& notch) const |
95 | { |
96 | return myNotchesParams.Find(notch); |
97 | } |