0024624: Lost word in license statement in source files
[occt.git] / src / Aspect / Aspect_WidthMap.cxx
CommitLineData
b311480e 1// Copyright (c) 1995-1999 Matra Datavision
973c2be1 2// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
b311480e 5//
d5f74e42 6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 8// by the Free Software Foundation, with special exception defined in the file
9// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10// distribution for complete text of the license and disclaimer of any warranty.
b311480e 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
7fd59977 14
15#include <Aspect_WidthMap.ixx>
16
17Aspect_WidthMap::Aspect_WidthMap( ) {
18Aspect_WidthMapEntry theDefaultEntry;
19
20 AddEntry(theDefaultEntry);
21}
22
23void Aspect_WidthMap::AddEntry (const Aspect_WidthMapEntry& AnEntry) {
24Standard_Integer i,index = AnEntry.Index();
25Aspect_WidthMapEntry theEntry;
26
27 for( i=1 ; i<=mydata.Length() ; i++ ) {
28 theEntry = mydata.Value(i);
29 if( index == theEntry.Index() ) break;
30 }
31
32 if( i > mydata.Length() ) {
33 mydata.Append( AnEntry );
34 } else {
35 mydata.SetValue(i,AnEntry);
36 }
37}
38
39Standard_Integer Aspect_WidthMap::AddEntry (const Aspect_WidthOfLine aStyle) {
40Aspect_WidthMapEntry theEntry ;
41Standard_Integer i,maxindex = 0 ;
42
43 for( i=1 ; i<=mydata.Length() ; i++ ) {
44 theEntry = mydata.Value(i) ;
45 maxindex = Max(maxindex,theEntry.Index()) ;
46 if( theEntry.Type() == aStyle ) return theEntry.Index() ;
47 }
48
49 maxindex++ ;
50 theEntry.SetValue(maxindex,aStyle) ;
51 mydata.Append( theEntry ) ;
52 return maxindex ;
53}
54
55Standard_Integer Aspect_WidthMap::AddEntry (const Quantity_Length aStyle) {
56Aspect_WidthMapEntry theEntry ;
57Standard_Integer i,maxindex = 0 ;
58
59 for( i=1 ; i<=mydata.Length() ; i++ ) {
60 theEntry = mydata.Value(i) ;
61 maxindex = Max(maxindex,theEntry.Index()) ;
62 if( theEntry.Width() == aStyle ) return theEntry.Index() ;
63 }
64
65 maxindex++ ;
66 theEntry.SetValue(maxindex,aStyle) ;
67 mydata.Append( theEntry ) ;
68 return maxindex ;
69}
70
71Standard_Integer Aspect_WidthMap::Size() const {
72
73 return mydata.Length() ;
74}
75
76Standard_Integer Aspect_WidthMap::Index(const Standard_Integer anIndex) const {
77
78 if( anIndex < 1 || anIndex > Size() ) {
79 Aspect_BadAccess::Raise ("Undefined widthmap Index");
80 }
81
82 Aspect_WidthMapEntry theEntry = mydata.Value(anIndex) ;
83
84 return theEntry.Index() ;
85}
86
87Aspect_WidthMapEntry Aspect_WidthMap::Entry (const Standard_Integer AnIndex) const {
88
89 if( AnIndex < 1 || AnIndex > mydata.Length() )
90 Aspect_BadAccess::Raise ("Aspect_WidthMap::Entry Bad Index");
91
92 return mydata.Value(AnIndex);
93}
94
95void Aspect_WidthMap::Dump () const {
96
97 Standard_Integer i ;
98
99 cout << "Widthmap Dump-->\n" ;
100
101 for ( i = 1 ; i <= Size() ; i++ ) (Entry(i)).Dump() ;
102
103 cout << "<--End Widthmap Dump\n" ;
104}