973c2be1 |
1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
2 | // |
973c2be1 |
3 | // This file is part of Open CASCADE Technology software library. |
b311480e |
4 | // |
d5f74e42 |
5 | // This library is free software; you can redistribute it and/or modify it under |
6 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
7 | // by the Free Software Foundation, with special exception defined in the file |
8 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
9 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
10 | // |
973c2be1 |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
b311480e |
13 | |
42cf5bc1 |
14 | |
15 | #include <IGESData_DirPart.hxx> |
16 | #include <IGESData_GlobalSection.hxx> |
7fd59977 |
17 | #include <IGESData_IGESEntity.hxx> |
42cf5bc1 |
18 | #include <IGESData_IGESModel.hxx> |
19 | #include <IGESData_IGESReaderData.hxx> |
20 | #include <IGESData_IGESType.hxx> |
7fd59977 |
21 | #include <IGESData_UndefinedEntity.hxx> |
42cf5bc1 |
22 | #include <Interface_Check.hxx> |
7fd59977 |
23 | #include <Interface_FileParameter.hxx> |
42cf5bc1 |
24 | #include <Interface_Macros.hxx> |
7fd59977 |
25 | #include <Interface_ParamList.hxx> |
42cf5bc1 |
26 | #include <Interface_ParamSet.hxx> |
7fd59977 |
27 | #include <Interface_ParamType.hxx> |
42cf5bc1 |
28 | #include <Standard_Type.hxx> |
7fd59977 |
29 | #include <TCollection_HAsciiString.hxx> |
7fd59977 |
30 | |
92efcf78 |
31 | IMPLEMENT_STANDARD_RTTIEXT(IGESData_IGESReaderData,Interface_FileReaderData) |
32 | |
b311480e |
33 | IGESData_IGESReaderData::IGESData_IGESReaderData |
7fd59977 |
34 | (const Standard_Integer nbe, const Standard_Integer nbp) |
35 | : Interface_FileReaderData (nbe,nbp) , thectyp (0,0) , thedirs(0,nbe) |
36 | { |
37 | thestep = IGESData_ReadDir; thedefw = 0.; |
38 | theparh = new Interface_ParamSet(30); |
39 | thestar = new TColStd_HSequenceOfHAsciiString(); |
40 | thechk = new Interface_Check; |
41 | } |
42 | |
43 | |
44 | void IGESData_IGESReaderData::AddStartLine |
45 | (const Standard_CString aval) |
46 | { |
47 | thestar->Append (new TCollection_HAsciiString(aval)); |
48 | } |
49 | |
50 | Handle(TColStd_HSequenceOfHAsciiString) IGESData_IGESReaderData::StartSection |
51 | () const |
52 | { return thestar; } |
53 | |
54 | void IGESData_IGESReaderData::AddGlobal |
55 | (const Interface_ParamType atype, const Standard_CString aval) |
56 | { |
7dc9e047 |
57 | theparh->Append(aval,(int)strlen(aval),atype,0); |
7fd59977 |
58 | } |
59 | |
60 | void IGESData_IGESReaderData::SetGlobalSection () |
61 | { thehead.Init(theparh,thechk); } |
62 | |
63 | const IGESData_GlobalSection& IGESData_IGESReaderData::GlobalSection () const |
64 | { return thehead; } |
65 | |
66 | void IGESData_IGESReaderData::SetDirPart |
67 | (const Standard_Integer num, |
68 | const Standard_Integer i1, const Standard_Integer i2, |
69 | const Standard_Integer i3, const Standard_Integer i4, |
70 | const Standard_Integer i5, const Standard_Integer i6, |
71 | const Standard_Integer i7, const Standard_Integer i8, |
72 | const Standard_Integer i9, const Standard_Integer i10, |
73 | const Standard_Integer i11, const Standard_Integer i12, |
74 | const Standard_Integer i13, const Standard_Integer i14, |
75 | const Standard_Integer i15, const Standard_Integer i16, |
76 | const Standard_Integer i17, |
77 | const Standard_CString res1, const Standard_CString res2, |
78 | const Standard_CString label, const Standard_CString subs) |
79 | { |
80 | IGESData_DirPart& DP = thedirs(num); |
81 | DP.Init(i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,i13,i14, |
82 | i15,i16,i17,res1,res2,label,subs); |
83 | //// thedirs(num) = DP; // verifier si utile |
84 | //InitParams(num); gka optimization memory |
85 | } |
86 | |
87 | |
88 | const IGESData_DirPart& IGESData_IGESReaderData::DirPart |
89 | (const Standard_Integer num) const |
90 | { return thedirs(num); } |
91 | |
92 | void IGESData_IGESReaderData::DirValues |
93 | (const Standard_Integer num, |
94 | Standard_Integer& i1, Standard_Integer& i2, Standard_Integer& i3, |
95 | Standard_Integer& i4, Standard_Integer& i5, Standard_Integer& i6, |
96 | Standard_Integer& i7, Standard_Integer& i8, Standard_Integer& i9, |
97 | Standard_Integer& i10, Standard_Integer& i11, Standard_Integer& i12, |
98 | Standard_Integer& i13, Standard_Integer& i14, Standard_Integer& i15, |
99 | Standard_Integer& i16, Standard_Integer& i17, |
100 | Standard_CString& res1, Standard_CString& res2, |
101 | Standard_CString& label, Standard_CString& subs) const |
102 | { |
103 | thedirs(num).Values(i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,i13,i14, |
104 | i15,i16,i17,res1,res2,label,subs); |
105 | } |
106 | |
107 | IGESData_IGESType IGESData_IGESReaderData::DirType |
108 | (const Standard_Integer num) const |
109 | { return thedirs(num).Type(); } |
110 | |
111 | Standard_Integer IGESData_IGESReaderData::NbEntities () const |
112 | { return thedirs.Upper(); } |
113 | |
114 | Standard_Integer IGESData_IGESReaderData::FindNextRecord |
115 | (const Standard_Integer num) const |
116 | { |
117 | if (num >= thedirs.Upper()) return 0; |
118 | else return (num + 1); |
119 | } |
120 | |
121 | |
122 | // Reference a d'autres entites : c'est a la fois tres simple et problematique |
123 | // Tres simple : une reference a une entite est un numero (dans directory list) |
124 | // qui vaut (2*N-1) si N est le rang vrai de l'entite |
125 | // Problematique : ce numero est un Entier ... rien ne le distingue d'un autre |
126 | // D'ou critere : tout entier impair inferieur a 2*NbRecords PEUT etre une |
127 | // reference ... C'est a chaque entite de faire ensuite son tri ... |
128 | // Attention, une reference peut etre donnee en "Pointeur Negatif" |
129 | // N.B.: DirPart non concernes (lecture specifique assuree par IGESEntity) |
130 | |
131 | void IGESData_IGESReaderData::SetEntityNumbers () |
132 | { |
133 | // On essaie de se baser uniquement sur calcul de IGESRead |
134 | /* |
135 | Standard_Integer nbd = thedirs.Upper(); |
136 | for (Standard_Integer i = 1; i <= nbd; i ++) { |
137 | Standard_Integer nbp = NbParams(i); |
138 | for (Standard_Integer j = 1; j <= nbp; j ++) { |
139 | Interface_FileParameter& FP = ChangeParam(i,j); |
140 | if (FP.ParamType() == Interface_ParamInteger) { |
141 | Standard_Integer val = atoi(FP.CValue()); |
142 | if (val > 0) { |
143 | if (val != ((val/2) *2) && val < 2*nbd) { // candidat possible |
144 | FP.SetEntityNumber((val+1)/2); |
145 | } |
146 | } else if (val < 0) { |
147 | Standard_Integer mval = -val; |
148 | if (mval != ((mval/2) *2) && mval < 2*nbd) { // candidat possible |
149 | FP.SetEntityNumber((mval+1)/2); |
150 | } |
151 | } |
152 | |
153 | } |
154 | } |
155 | } |
156 | */ |
157 | } |
158 | |
159 | |
160 | //======================================================================= |
161 | //function : GlobalCheck |
162 | //purpose : |
163 | //======================================================================= |
164 | |
165 | Handle(Interface_Check) IGESData_IGESReaderData::GlobalCheck () const |
166 | { |
167 | return thechk; |
168 | } |
169 | |
170 | |
171 | //======================================================================= |
172 | //function : SetDefaultLineWeight |
173 | //purpose : |
174 | //======================================================================= |
175 | |
176 | void IGESData_IGESReaderData::SetDefaultLineWeight (const Standard_Real defw) |
177 | { |
178 | thedefw = defw; |
179 | } |
180 | |
181 | |
182 | //======================================================================= |
183 | //function : DefaultLineWeight |
184 | //purpose : |
185 | //======================================================================= |
186 | |
187 | Standard_Real IGESData_IGESReaderData::DefaultLineWeight () const |
188 | { |
189 | return thedefw; |
190 | } |