summaryrefslogtreecommitdiff
path: root/src/ShapeAnalysis/ShapeAnalysis_FreeBoundData.cxx
blob: 37986e43083b00d9ce1204de8dff718edd783b16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// File:	ShapeAnalysis_FreeBoundData.cxx
// Created:	Tue Aug 25 12:42:28 1998
// Author:	Pavel DURANDIN
//		<pdn@nnov.matra-dtv.fr>


#include <ShapeAnalysis_FreeBoundData.ixx>
#include <TopTools_HSequenceOfShape.hxx>
#include <TopoDS.hxx>

//=======================================================================
//function : ShapeAnalysis_FreeBoundData
//purpose  : Empty constructor
//=======================================================================

ShapeAnalysis_FreeBoundData::ShapeAnalysis_FreeBoundData()
{
  myNotches = new TopTools_HSequenceOfShape();
  Clear();
}

//=======================================================================
//function : ShapeAnalysis_FreeBoundData
//purpose  : Creates object with contour given in the form of TopoDS_Wire
//=======================================================================

ShapeAnalysis_FreeBoundData::ShapeAnalysis_FreeBoundData(const TopoDS_Wire& freebound)
{
  myNotches = new TopTools_HSequenceOfShape();
  Clear();
  SetFreeBound(freebound);
}

//=======================================================================
//function : Clear
//purpose  : Clears all properties of the contour. Contour bound itself is not cleared.
//=======================================================================

void ShapeAnalysis_FreeBoundData::Clear()
{
  myArea = -1;
  myPerimeter = -1;
  myRatio = -1;
  myWidth = -1;
  myNotches->Clear();
  myNotchesParams.Clear();
}

//=======================================================================
//function : AddNotch
//purpose  : Adds notch on free bound with its maximum width
//=======================================================================

void ShapeAnalysis_FreeBoundData::AddNotch(const TopoDS_Wire& notch,const Standard_Real width)
{
  if (myNotchesParams.IsBound(notch)) return;
  myNotches->Append(notch);
  myNotchesParams.Bind(notch, width);
}


//=======================================================================
//function : NotchWidth
//purpose  : Returns maximum width of notch specified by its rank number
//    	     on the contour
//=======================================================================

Standard_Real ShapeAnalysis_FreeBoundData::NotchWidth(const Standard_Integer index) const
{
  TopoDS_Wire wire = TopoDS::Wire(myNotches -> Value(index));
  return myNotchesParams.Find(wire);
}

//=======================================================================
//function : NotchWidth
//purpose  : Returns maximum width of notch specified as TopoDS_Wire
//    	     on the contour
//=======================================================================

Standard_Real ShapeAnalysis_FreeBoundData::NotchWidth(const TopoDS_Wire& notch) const
{
  return myNotchesParams.Find(notch);
}