0022627: Change OCCT memory management defaults
[occt.git] / src / Aspect / Aspect_WidthMap.cxx
CommitLineData
7fd59977 1
2#include <Aspect_WidthMap.ixx>
3
4Aspect_WidthMap::Aspect_WidthMap( ) {
5Aspect_WidthMapEntry theDefaultEntry;
6
7 AddEntry(theDefaultEntry);
8}
9
10void Aspect_WidthMap::AddEntry (const Aspect_WidthMapEntry& AnEntry) {
11Standard_Integer i,index = AnEntry.Index();
12Aspect_WidthMapEntry theEntry;
13
14 for( i=1 ; i<=mydata.Length() ; i++ ) {
15 theEntry = mydata.Value(i);
16 if( index == theEntry.Index() ) break;
17 }
18
19 if( i > mydata.Length() ) {
20 mydata.Append( AnEntry );
21 } else {
22 mydata.SetValue(i,AnEntry);
23 }
24}
25
26Standard_Integer Aspect_WidthMap::AddEntry (const Aspect_WidthOfLine aStyle) {
27Aspect_WidthMapEntry theEntry ;
28Standard_Integer i,maxindex = 0 ;
29
30 for( i=1 ; i<=mydata.Length() ; i++ ) {
31 theEntry = mydata.Value(i) ;
32 maxindex = Max(maxindex,theEntry.Index()) ;
33 if( theEntry.Type() == aStyle ) return theEntry.Index() ;
34 }
35
36 maxindex++ ;
37 theEntry.SetValue(maxindex,aStyle) ;
38 mydata.Append( theEntry ) ;
39 return maxindex ;
40}
41
42Standard_Integer Aspect_WidthMap::AddEntry (const Quantity_Length aStyle) {
43Aspect_WidthMapEntry theEntry ;
44Standard_Integer i,maxindex = 0 ;
45
46 for( i=1 ; i<=mydata.Length() ; i++ ) {
47 theEntry = mydata.Value(i) ;
48 maxindex = Max(maxindex,theEntry.Index()) ;
49 if( theEntry.Width() == aStyle ) return theEntry.Index() ;
50 }
51
52 maxindex++ ;
53 theEntry.SetValue(maxindex,aStyle) ;
54 mydata.Append( theEntry ) ;
55 return maxindex ;
56}
57
58Standard_Integer Aspect_WidthMap::Size() const {
59
60 return mydata.Length() ;
61}
62
63Standard_Integer Aspect_WidthMap::Index(const Standard_Integer anIndex) const {
64
65 if( anIndex < 1 || anIndex > Size() ) {
66 Aspect_BadAccess::Raise ("Undefined widthmap Index");
67 }
68
69 Aspect_WidthMapEntry theEntry = mydata.Value(anIndex) ;
70
71 return theEntry.Index() ;
72}
73
74Aspect_WidthMapEntry Aspect_WidthMap::Entry (const Standard_Integer AnIndex) const {
75
76 if( AnIndex < 1 || AnIndex > mydata.Length() )
77 Aspect_BadAccess::Raise ("Aspect_WidthMap::Entry Bad Index");
78
79 return mydata.Value(AnIndex);
80}
81
82void Aspect_WidthMap::Dump () const {
83
84 Standard_Integer i ;
85
86 cout << "Widthmap Dump-->\n" ;
87
88 for ( i = 1 ; i <= Size() ; i++ ) (Entry(i)).Dump() ;
89
90 cout << "<--End Widthmap Dump\n" ;
91}