b311480e |
1 | // Created by: CKY / Contract Toubro-Larsen |
2 | // Copyright (c) 1993-1999 Matra Datavision |
3 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
4 | // |
5 | // The content of this file is subject to the Open CASCADE Technology Public |
6 | // License Version 6.5 (the "License"). You may not use the content of this file |
7 | // except in compliance with the License. Please obtain a copy of the License |
8 | // at http://www.opencascade.org and read it completely before using this file. |
7fd59977 |
9 | // |
b311480e |
10 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
11 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
7fd59977 |
12 | // |
b311480e |
13 | // The Original Code and all software distributed under the License is |
14 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
15 | // Initial Developer hereby disclaims all such warranties, including without |
16 | // limitation, any warranties of merchantability, fitness for a particular |
17 | // purpose or non-infringement. Please see the License for the specific terms |
18 | // and conditions governing the rights and limitations under the License. |
19 | |
20 | //-------------------------------------------------------------------- |
7fd59977 |
21 | //-------------------------------------------------------------------- |
22 | |
23 | #include <IGESGraph_LineFontDefPattern.ixx> |
24 | #include <Standard_DimensionMismatch.hxx> |
25 | |
26 | |
b311480e |
27 | IGESGraph_LineFontDefPattern::IGESGraph_LineFontDefPattern () { } |
7fd59977 |
28 | |
29 | |
30 | // This class inherits from IGESData_LineFontEntity |
31 | |
32 | void IGESGraph_LineFontDefPattern::Init |
33 | (const Handle(TColStd_HArray1OfReal)& allSegLength, |
34 | const Handle(TCollection_HAsciiString)& aPattern) |
35 | { |
36 | if (allSegLength->Lower() != 1) |
37 | Standard_DimensionMismatch::Raise("IGESGraph_LineFontDefPattern : Init"); |
38 | theSegmentLengths = allSegLength; |
39 | theDisplayPattern = aPattern; |
40 | InitTypeAndForm(304,2); |
41 | } |
42 | |
43 | Standard_Integer IGESGraph_LineFontDefPattern::NbSegments () const |
44 | { |
45 | return theSegmentLengths->Length(); |
46 | } |
47 | |
48 | Standard_Real IGESGraph_LineFontDefPattern::Length |
49 | (const Standard_Integer Index) const |
50 | { |
51 | return theSegmentLengths->Value(Index); |
52 | // if Index is out of bound HArray1 will raise OutOfRange exception |
53 | } |
54 | |
55 | Handle(TCollection_HAsciiString) IGESGraph_LineFontDefPattern::DisplayPattern |
56 | () const |
57 | { |
58 | return theDisplayPattern; |
59 | } |
60 | |
61 | Standard_Boolean IGESGraph_LineFontDefPattern::IsVisible |
62 | (const Standard_Integer Index) const |
63 | { |
64 | Standard_Integer nbSegs = theSegmentLengths->Length(); |
65 | if (Index <= 0 || Index > nbSegs) return Standard_False; |
66 | |
67 | // Get the Character out of String, which contains the required BIT |
68 | char tempStr[2]; |
69 | Standard_Integer length = theDisplayPattern->Length(); |
70 | tempStr[0] = theDisplayPattern->Value(length - ((nbSegs - Index) / 4)); |
71 | tempStr[1] = 0; |
72 | Standard_Integer tempVal = |
73 | (Standard_Integer) strtol(tempStr, (char **)NULL, 16); |
74 | // Now get the BIT out of tempVal |
75 | Standard_Integer mask = 0x01; |
76 | mask <<= ((nbSegs - Index) % 4); |
77 | return ((tempVal & mask) != 0); |
78 | } |