7fd59977 |
1 | |
2 | #include <Aspect_WidthMap.ixx> |
3 | |
4 | Aspect_WidthMap::Aspect_WidthMap( ) { |
5 | Aspect_WidthMapEntry theDefaultEntry; |
6 | |
7 | AddEntry(theDefaultEntry); |
8 | } |
9 | |
10 | void Aspect_WidthMap::AddEntry (const Aspect_WidthMapEntry& AnEntry) { |
11 | Standard_Integer i,index = AnEntry.Index(); |
12 | Aspect_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 | |
26 | Standard_Integer Aspect_WidthMap::AddEntry (const Aspect_WidthOfLine aStyle) { |
27 | Aspect_WidthMapEntry theEntry ; |
28 | Standard_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 | |
42 | Standard_Integer Aspect_WidthMap::AddEntry (const Quantity_Length aStyle) { |
43 | Aspect_WidthMapEntry theEntry ; |
44 | Standard_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 | |
58 | Standard_Integer Aspect_WidthMap::Size() const { |
59 | |
60 | return mydata.Length() ; |
61 | } |
62 | |
63 | Standard_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 | |
74 | Aspect_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 | |
82 | void 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 | } |