2 #include <Aspect_WidthMap.ixx>
4 Aspect_WidthMap::Aspect_WidthMap( ) {
5 Aspect_WidthMapEntry theDefaultEntry;
7 AddEntry(theDefaultEntry);
10 void Aspect_WidthMap::AddEntry (const Aspect_WidthMapEntry& AnEntry) {
11 Standard_Integer i,index = AnEntry.Index();
12 Aspect_WidthMapEntry theEntry;
14 for( i=1 ; i<=mydata.Length() ; i++ ) {
15 theEntry = mydata.Value(i);
16 if( index == theEntry.Index() ) break;
19 if( i > mydata.Length() ) {
20 mydata.Append( AnEntry );
22 mydata.SetValue(i,AnEntry);
26 Standard_Integer Aspect_WidthMap::AddEntry (const Aspect_WidthOfLine aStyle) {
27 Aspect_WidthMapEntry theEntry ;
28 Standard_Integer i,maxindex = 0 ;
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() ;
37 theEntry.SetValue(maxindex,aStyle) ;
38 mydata.Append( theEntry ) ;
42 Standard_Integer Aspect_WidthMap::AddEntry (const Quantity_Length aStyle) {
43 Aspect_WidthMapEntry theEntry ;
44 Standard_Integer i,maxindex = 0 ;
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() ;
53 theEntry.SetValue(maxindex,aStyle) ;
54 mydata.Append( theEntry ) ;
58 Standard_Integer Aspect_WidthMap::Size() const {
60 return mydata.Length() ;
63 Standard_Integer Aspect_WidthMap::Index(const Standard_Integer anIndex) const {
65 if( anIndex < 1 || anIndex > Size() ) {
66 Aspect_BadAccess::Raise ("Undefined widthmap Index");
69 Aspect_WidthMapEntry theEntry = mydata.Value(anIndex) ;
71 return theEntry.Index() ;
74 Aspect_WidthMapEntry Aspect_WidthMap::Entry (const Standard_Integer AnIndex) const {
76 if( AnIndex < 1 || AnIndex > mydata.Length() )
77 Aspect_BadAccess::Raise ("Aspect_WidthMap::Entry Bad Index");
79 return mydata.Value(AnIndex);
82 void Aspect_WidthMap::Dump () const {
86 cout << "Widthmap Dump-->\n" ;
88 for ( i = 1 ; i <= Size() ; i++ ) (Entry(i)).Dump() ;
90 cout << "<--End Widthmap Dump\n" ;