0023948: Wrong intersection between a surface of revolution and a plane.
[occt.git] / src / ShapeAnalysis / ShapeAnalysis_FreeBoundData.cxx
1 // Created on: 1998-08-25
2 // Created by: Pavel DURANDIN
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 #include <ShapeAnalysis_FreeBoundData.ixx>
18 #include <TopTools_HSequenceOfShape.hxx>
19 #include <TopoDS.hxx>
20
21 //=======================================================================
22 //function : ShapeAnalysis_FreeBoundData
23 //purpose  : Empty constructor
24 //=======================================================================
25
26 ShapeAnalysis_FreeBoundData::ShapeAnalysis_FreeBoundData()
27 {
28   myNotches = new TopTools_HSequenceOfShape();
29   Clear();
30 }
31
32 //=======================================================================
33 //function : ShapeAnalysis_FreeBoundData
34 //purpose  : Creates object with contour given in the form of TopoDS_Wire
35 //=======================================================================
36
37 ShapeAnalysis_FreeBoundData::ShapeAnalysis_FreeBoundData(const TopoDS_Wire& freebound)
38 {
39   myNotches = new TopTools_HSequenceOfShape();
40   Clear();
41   SetFreeBound(freebound);
42 }
43
44 //=======================================================================
45 //function : Clear
46 //purpose  : Clears all properties of the contour. Contour bound itself is not cleared.
47 //=======================================================================
48
49 void ShapeAnalysis_FreeBoundData::Clear()
50 {
51   myArea = -1;
52   myPerimeter = -1;
53   myRatio = -1;
54   myWidth = -1;
55   myNotches->Clear();
56   myNotchesParams.Clear();
57 }
58
59 //=======================================================================
60 //function : AddNotch
61 //purpose  : Adds notch on free bound with its maximum width
62 //=======================================================================
63
64 void ShapeAnalysis_FreeBoundData::AddNotch(const TopoDS_Wire& notch,const Standard_Real width)
65 {
66   if (myNotchesParams.IsBound(notch)) return;
67   myNotches->Append(notch);
68   myNotchesParams.Bind(notch, width);
69 }
70
71
72 //=======================================================================
73 //function : NotchWidth
74 //purpose  : Returns maximum width of notch specified by its rank number
75 //           on the contour
76 //=======================================================================
77
78 Standard_Real ShapeAnalysis_FreeBoundData::NotchWidth(const Standard_Integer index) const
79 {
80   TopoDS_Wire wire = TopoDS::Wire(myNotches -> Value(index));
81   return myNotchesParams.Find(wire);
82 }
83
84 //=======================================================================
85 //function : NotchWidth
86 //purpose  : Returns maximum width of notch specified as TopoDS_Wire
87 //           on the contour
88 //=======================================================================
89
90 Standard_Real ShapeAnalysis_FreeBoundData::NotchWidth(const TopoDS_Wire& notch) const
91 {
92   return myNotchesParams.Find(notch);
93 }