1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
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
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.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #include <Aspect_WidthMap.ixx>
17 Aspect_WidthMap::Aspect_WidthMap( ) {
18 Aspect_WidthMapEntry theDefaultEntry;
20 AddEntry(theDefaultEntry);
23 void Aspect_WidthMap::AddEntry (const Aspect_WidthMapEntry& AnEntry) {
24 Standard_Integer i,index = AnEntry.Index();
25 Aspect_WidthMapEntry theEntry;
27 for( i=1 ; i<=mydata.Length() ; i++ ) {
28 theEntry = mydata.Value(i);
29 if( index == theEntry.Index() ) break;
32 if( i > mydata.Length() ) {
33 mydata.Append( AnEntry );
35 mydata.SetValue(i,AnEntry);
39 Standard_Integer Aspect_WidthMap::AddEntry (const Aspect_WidthOfLine aStyle) {
40 Aspect_WidthMapEntry theEntry ;
41 Standard_Integer i,maxindex = 0 ;
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() ;
50 theEntry.SetValue(maxindex,aStyle) ;
51 mydata.Append( theEntry ) ;
55 Standard_Integer Aspect_WidthMap::AddEntry (const Quantity_Length aStyle) {
56 Aspect_WidthMapEntry theEntry ;
57 Standard_Integer i,maxindex = 0 ;
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() ;
66 theEntry.SetValue(maxindex,aStyle) ;
67 mydata.Append( theEntry ) ;
71 Standard_Integer Aspect_WidthMap::Size() const {
73 return mydata.Length() ;
76 Standard_Integer Aspect_WidthMap::Index(const Standard_Integer anIndex) const {
78 if( anIndex < 1 || anIndex > Size() ) {
79 Aspect_BadAccess::Raise ("Undefined widthmap Index");
82 Aspect_WidthMapEntry theEntry = mydata.Value(anIndex) ;
84 return theEntry.Index() ;
87 Aspect_WidthMapEntry Aspect_WidthMap::Entry (const Standard_Integer AnIndex) const {
89 if( AnIndex < 1 || AnIndex > mydata.Length() )
90 Aspect_BadAccess::Raise ("Aspect_WidthMap::Entry Bad Index");
92 return mydata.Value(AnIndex);
95 void Aspect_WidthMap::Dump () const {
99 cout << "Widthmap Dump-->\n" ;
101 for ( i = 1 ; i <= Size() ; i++ ) (Entry(i)).Dump() ;
103 cout << "<--End Widthmap Dump\n" ;