0023024: Update headers of OCCT files
[occt.git] / src / Aspect / Aspect_WidthMap.cxx
CommitLineData
b311480e 1// Copyright (c) 1995-1999 Matra Datavision
2// Copyright (c) 1999-2012 OPEN CASCADE SAS
3//
4// The content of this file is subject to the Open CASCADE Technology Public
5// License Version 6.5 (the "License"). You may not use the content of this file
6// except in compliance with the License. Please obtain a copy of the License
7// at http://www.opencascade.org and read it completely before using this file.
8//
9// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11//
12// The Original Code and all software distributed under the License is
13// distributed on an "AS IS" basis, without warranty of any kind, and the
14// Initial Developer hereby disclaims all such warranties, including without
15// limitation, any warranties of merchantability, fitness for a particular
16// purpose or non-infringement. Please see the License for the specific terms
17// and conditions governing the rights and limitations under the License.
18
7fd59977 19
20#include <Aspect_WidthMap.ixx>
21
22Aspect_WidthMap::Aspect_WidthMap( ) {
23Aspect_WidthMapEntry theDefaultEntry;
24
25 AddEntry(theDefaultEntry);
26}
27
28void Aspect_WidthMap::AddEntry (const Aspect_WidthMapEntry& AnEntry) {
29Standard_Integer i,index = AnEntry.Index();
30Aspect_WidthMapEntry theEntry;
31
32 for( i=1 ; i<=mydata.Length() ; i++ ) {
33 theEntry = mydata.Value(i);
34 if( index == theEntry.Index() ) break;
35 }
36
37 if( i > mydata.Length() ) {
38 mydata.Append( AnEntry );
39 } else {
40 mydata.SetValue(i,AnEntry);
41 }
42}
43
44Standard_Integer Aspect_WidthMap::AddEntry (const Aspect_WidthOfLine aStyle) {
45Aspect_WidthMapEntry theEntry ;
46Standard_Integer i,maxindex = 0 ;
47
48 for( i=1 ; i<=mydata.Length() ; i++ ) {
49 theEntry = mydata.Value(i) ;
50 maxindex = Max(maxindex,theEntry.Index()) ;
51 if( theEntry.Type() == aStyle ) return theEntry.Index() ;
52 }
53
54 maxindex++ ;
55 theEntry.SetValue(maxindex,aStyle) ;
56 mydata.Append( theEntry ) ;
57 return maxindex ;
58}
59
60Standard_Integer Aspect_WidthMap::AddEntry (const Quantity_Length aStyle) {
61Aspect_WidthMapEntry theEntry ;
62Standard_Integer i,maxindex = 0 ;
63
64 for( i=1 ; i<=mydata.Length() ; i++ ) {
65 theEntry = mydata.Value(i) ;
66 maxindex = Max(maxindex,theEntry.Index()) ;
67 if( theEntry.Width() == aStyle ) return theEntry.Index() ;
68 }
69
70 maxindex++ ;
71 theEntry.SetValue(maxindex,aStyle) ;
72 mydata.Append( theEntry ) ;
73 return maxindex ;
74}
75
76Standard_Integer Aspect_WidthMap::Size() const {
77
78 return mydata.Length() ;
79}
80
81Standard_Integer Aspect_WidthMap::Index(const Standard_Integer anIndex) const {
82
83 if( anIndex < 1 || anIndex > Size() ) {
84 Aspect_BadAccess::Raise ("Undefined widthmap Index");
85 }
86
87 Aspect_WidthMapEntry theEntry = mydata.Value(anIndex) ;
88
89 return theEntry.Index() ;
90}
91
92Aspect_WidthMapEntry Aspect_WidthMap::Entry (const Standard_Integer AnIndex) const {
93
94 if( AnIndex < 1 || AnIndex > mydata.Length() )
95 Aspect_BadAccess::Raise ("Aspect_WidthMap::Entry Bad Index");
96
97 return mydata.Value(AnIndex);
98}
99
100void Aspect_WidthMap::Dump () const {
101
102 Standard_Integer i ;
103
104 cout << "Widthmap Dump-->\n" ;
105
106 for ( i = 1 ; i <= Size() ; i++ ) (Entry(i)).Dump() ;
107
108 cout << "<--End Widthmap Dump\n" ;
109}