b311480e |
1 | // Created by: CKY / Contract Toubro-Larsen |
2 | // Copyright (c) 1993-1999 Matra Datavision |
973c2be1 |
3 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
7fd59977 |
6 | // |
d5f74e42 |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
7fd59977 |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
b311480e |
15 | |
16 | //-------------------------------------------------------------------- |
7fd59977 |
17 | //-------------------------------------------------------------------- |
18 | |
42cf5bc1 |
19 | #include <gp_XY.hxx> |
20 | #include <IGESData_DirChecker.hxx> |
7fd59977 |
21 | #include <IGESData_Dump.hxx> |
42cf5bc1 |
22 | #include <IGESData_IGESDumper.hxx> |
23 | #include <IGESData_IGESReaderData.hxx> |
24 | #include <IGESData_IGESWriter.hxx> |
25 | #include <IGESData_ParamCursor.hxx> |
26 | #include <IGESData_ParamReader.hxx> |
27 | #include <IGESGeom_CopiousData.hxx> |
28 | #include <IGESGeom_ToolCopiousData.hxx> |
29 | #include <Interface_Check.hxx> |
30 | #include <Interface_CopyTool.hxx> |
31 | #include <Interface_EntityIterator.hxx> |
7fd59977 |
32 | #include <Interface_Macros.hxx> |
42cf5bc1 |
33 | #include <Interface_ShareTool.hxx> |
34 | #include <Message_Messenger.hxx> |
7fd59977 |
35 | #include <Message_Msg.hxx> |
42cf5bc1 |
36 | #include <Standard_DomainError.hxx> |
37 | #include <TColStd_HArray1OfReal.hxx> |
7fd59977 |
38 | |
42cf5bc1 |
39 | // MGE 28/07/98 |
7fd59977 |
40 | //======================================================================= |
41 | //function : IGESGeom_ToolCopiousData |
42 | //purpose : |
43 | //======================================================================= |
7fd59977 |
44 | IGESGeom_ToolCopiousData::IGESGeom_ToolCopiousData () |
45 | { |
46 | } |
47 | |
48 | |
49 | //======================================================================= |
50 | //function : ReadOwnParams |
51 | //purpose : |
52 | //======================================================================= |
53 | |
54 | void IGESGeom_ToolCopiousData::ReadOwnParams(const Handle(IGESGeom_CopiousData)& ent, |
55 | const Handle(IGESData_IGESReaderData)& /* IR */, |
56 | IGESData_ParamReader& PR) const |
57 | { |
58 | // MGE 28/07/98 |
59 | // Building of messages |
60 | |
61 | Standard_Integer aDataType, nbData; |
62 | Standard_Real aZPlane = 0; |
63 | Handle(TColStd_HArray1OfReal) allData; |
64 | |
65 | Standard_Integer upper; |
66 | //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down |
67 | Standard_Boolean data = Standard_False; |
68 | |
69 | if (!PR.ReadInteger(PR.Current(), aDataType)){ //szv#4:S4163:12Mar99 `st=` not needed |
70 | //st = PR.ReadInteger(PR.Current(), "Data Type", aDataType); |
71 | Message_Msg Msg85("XSTEP_85"); |
72 | PR.SendFail(Msg85); |
73 | } |
74 | |
75 | Standard_Boolean st = PR.ReadInteger(PR.Current(), nbData); |
76 | //st = PR.ReadInteger(PR.Current(), "Number of n-tuples", nbData); |
77 | if (st && (nbData > 0)) data = Standard_True; |
78 | else { |
79 | Message_Msg Msg86("XSTEP_86"); |
80 | PR.SendFail(Msg86); |
81 | } |
82 | |
83 | if (aDataType == 1){ |
84 | if (!PR.ReadReal(PR.Current(), aZPlane)){ //szv#4:S4163:12Mar99 `st=` not needed |
85 | Message_Msg Msg87("XSTEP_87"); |
86 | PR.SendFail(Msg87); |
87 | } |
88 | //if (aDataType == 1) st = PR.ReadReal(PR.Current(), "Z Plane", aZPlane); |
89 | } |
90 | |
91 | if ( data ) |
92 | { |
93 | if (aDataType == 1) upper = 2*nbData; |
94 | else if (aDataType == 2) upper = 3*nbData; |
95 | else upper = 6*nbData; |
96 | |
97 | Message_Msg Msg88("XSTEP_88"); |
98 | //allData = new TColStd_HArray1OfReal(1, upper) then fill it : |
99 | PR.ReadReals(PR.CurrentList(upper),Msg88, allData); //szv#4:S4163:12Mar99 `st=` not needed |
100 | //st = PR.ReadReals(PR.CurrentList(upper), "Tuples", allData); |
101 | } |
102 | |
103 | DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent); |
104 | ent->Init(aDataType, aZPlane, allData); |
105 | } |
106 | |
107 | |
108 | //======================================================================= |
109 | //function : WriteOwnParams |
110 | //purpose : |
111 | //======================================================================= |
112 | |
113 | void IGESGeom_ToolCopiousData::WriteOwnParams(const Handle(IGESGeom_CopiousData)& ent, |
114 | IGESData_IGESWriter& IW) const |
115 | { |
116 | Standard_Integer upper = ent->NbPoints(); |
117 | Standard_Integer dtype = ent->DataType(); |
118 | IW.Send(dtype); |
119 | IW.Send(upper); |
120 | if (ent->DataType() == 1) |
121 | IW.Send(ent->ZPlane()); |
122 | for (Standard_Integer I = 1; I <= upper; I++) { |
123 | // DataType = 1 : XY , 2 : XYZ , 3 : XYZ*2 |
124 | IW.Send( ent->Data(I,1) ); |
125 | IW.Send( ent->Data(I,2) ); |
126 | if (dtype > 1) IW.Send( ent->Data(I,3) ); |
127 | if (dtype <= 2) continue; |
128 | IW.Send( ent->Data(I,4) ); |
129 | IW.Send( ent->Data(I,5) ); |
130 | IW.Send( ent->Data(I,6) ); |
131 | } |
132 | } |
133 | |
134 | |
135 | //======================================================================= |
136 | //function : OwnShared |
137 | //purpose : |
138 | //======================================================================= |
139 | |
140 | void IGESGeom_ToolCopiousData::OwnShared(const Handle(IGESGeom_CopiousData)& /* ent */, |
141 | Interface_EntityIterator& /* iter */) const |
142 | { |
143 | } |
144 | |
145 | |
146 | //======================================================================= |
147 | //function : OwnCopy |
148 | //purpose : |
149 | //======================================================================= |
150 | |
151 | void IGESGeom_ToolCopiousData::OwnCopy(const Handle(IGESGeom_CopiousData)& another, |
152 | const Handle(IGESGeom_CopiousData)& ent, |
153 | Interface_CopyTool& /* TC */) const |
154 | { |
155 | Standard_Integer upper; |
156 | Standard_Real aZPlane = 0; |
157 | Standard_Integer nbTuples = another->NbPoints(); |
158 | Standard_Integer aDataType = another->DataType(); |
159 | Handle(TColStd_HArray1OfReal) allData; |
160 | |
161 | if (aDataType == 1) upper = 2*nbTuples; |
162 | else if (aDataType == 2) upper = 3*nbTuples; |
163 | else upper = 6*nbTuples; |
164 | |
165 | allData = new TColStd_HArray1OfReal(1, upper); |
166 | |
167 | if (aDataType == 1) aZPlane = another->ZPlane(); |
168 | |
169 | for (Standard_Integer I = 1; I <= nbTuples; I++) { |
170 | |
171 | switch (aDataType) { |
172 | case 1: |
173 | allData->SetValue(2*I-1, another->Data(I,1)); |
174 | allData->SetValue(2*I , another->Data(I,2)); |
175 | break; |
176 | case 2: |
177 | allData->SetValue(3*I-2, another->Data(I,1)); |
178 | allData->SetValue(3*I-1, another->Data(I,2)); |
179 | allData->SetValue(3*I , another->Data(I,3)); |
180 | break; |
181 | case 3: |
182 | allData->SetValue(6*I-5, another->Data(I,1)); |
183 | allData->SetValue(6*I-4, another->Data(I,2)); |
184 | allData->SetValue(6*I-3, another->Data(I,3)); |
185 | allData->SetValue(6*I-2, another->Data(I,4)); |
186 | allData->SetValue(6*I-1, another->Data(I,5)); |
187 | allData->SetValue(6*I , another->Data(I,6)); |
188 | break; |
189 | } |
190 | } |
191 | |
192 | ent->Init(aDataType, aZPlane, allData); |
193 | if (another->IsClosedPath2D()) ent->SetClosedPath2D(); |
194 | else ent->SetPolyline (another->IsPolyline()); |
195 | } |
196 | |
197 | |
198 | //======================================================================= |
199 | //function : DirChecker |
200 | //purpose : |
201 | //======================================================================= |
202 | |
203 | IGESData_DirChecker IGESGeom_ToolCopiousData::DirChecker |
204 | (const Handle(IGESGeom_CopiousData)& ent ) const |
205 | { |
206 | IGESData_DirChecker DC(106, 1, 63); |
207 | DC.Structure(IGESData_DefVoid); |
208 | if (ent->FormNumber() <= 3) |
209 | { |
210 | DC.LineFont(IGESData_DefVoid); |
211 | DC.LineWeight(IGESData_DefVoid); |
212 | } |
213 | else |
214 | { |
215 | DC.LineFont(IGESData_DefAny); |
216 | DC.LineWeight(IGESData_DefValue); |
217 | } |
218 | DC.Color(IGESData_DefAny); |
219 | DC.HierarchyStatusIgnored (); |
220 | return DC; |
221 | } |
222 | |
223 | |
224 | //======================================================================= |
225 | //function : OwnCheck |
226 | //purpose : |
227 | //======================================================================= |
228 | |
229 | void IGESGeom_ToolCopiousData::OwnCheck(const Handle(IGESGeom_CopiousData)& ent, |
230 | const Interface_ShareTool&, |
231 | Handle(Interface_Check)& ach) const |
232 | { |
233 | // MGE 28/07/98 |
234 | // Building of messages |
235 | //====================================== |
236 | Message_Msg Msg71("XSTEP_71"); |
237 | //Message_Msg Msg85("XSTEP_85"); |
238 | //====================================== |
239 | |
240 | Standard_Integer fn = ent->FormNumber(); |
241 | if ( (fn > 3 && fn < 11) || (fn > 14 && fn < 63)) { |
242 | // Message_Msg Msg71("XSTEP_71"); |
243 | ach->SendFail(Msg71); |
244 | } |
245 | Standard_Integer dt = ent->DataType(); |
246 | if (dt < 1 || dt > 3) { |
247 | Message_Msg Msg85("XSTEP_85"); |
248 | ach->SendFail(Msg85); |
249 | } |
250 | if ((dt == 1 && (fn != 1 && fn != 11 && fn != 63)) || |
251 | (dt == 2 && (fn != 2 && fn != 12)) || (dt == 3 && (fn != 3 && fn != 13))) { |
252 | // Message_Msg Msg71("XSTEP_71"); |
253 | ach->SendFail(Msg71); |
254 | } |
255 | } |
256 | |
257 | |
258 | //======================================================================= |
259 | //function : OwnDump |
260 | //purpose : |
261 | //======================================================================= |
262 | |
263 | void IGESGeom_ToolCopiousData::OwnDump(const Handle(IGESGeom_CopiousData)& ent, |
264 | const IGESData_IGESDumper& /* dumper */, |
265 | const Handle(Message_Messenger)& S, |
266 | const Standard_Integer level) const |
267 | { |
268 | Standard_Integer nbPnts = ent->NbPoints(); |
269 | Standard_Integer dtype = ent->DataType(); |
270 | Standard_Integer i; |
271 | gp_GTrsf loca = ent->Location(); |
272 | gp_GTrsf locv = ent->VectorLocation(); |
273 | Standard_Boolean yatr = (level > 5 && ent->HasTransf()); |
274 | |
04232180 |
275 | S << "IGESGeom_CopiousData" << Message_EndLine; |
7fd59977 |
276 | |
277 | if (ent->IsPointSet()) S << "Point Set "; |
278 | else if (ent->IsPolyline()) S << "Polyline "; |
279 | else if (ent->IsClosedPath2D()) S << "Closed Path 2D "; |
280 | S << "DataType " << ent->DataType() << " "; |
281 | S << "Number of T-uples = " << nbPnts << " "; |
282 | if (dtype == 1) { |
283 | S << "(Points 2D) "; |
04232180 |
284 | S << "ZPlane = " << ent->ZPlane() << Message_EndLine; |
7fd59977 |
285 | } |
286 | else if (dtype == 2) |
04232180 |
287 | S << "(Points 3D)" << Message_EndLine; |
7fd59977 |
288 | else if (dtype == 3) |
04232180 |
289 | S << "(Points 3D + Vectors 3D)" << Message_EndLine; |
7fd59977 |
290 | |
291 | if (level > 4) { |
292 | for (i = 1; i <= nbPnts; i ++) { |
293 | gp_XYZ T = ent->Point(i).XYZ(); |
294 | if (dtype == 1) |
295 | S << "[" << i << "] (" << T.X() << "," << T.Y() << ")"; |
296 | else |
297 | S << "[" << i << "] (" << T.X() << "," << T.Y() << "," << T.Z() << ")"; |
298 | |
299 | if (yatr) { |
300 | loca.Transforms(T); |
301 | S << " Transformed ("<< T.X() << "," << T.Y() << "," << T.Z() << ")"; |
302 | } |
303 | |
304 | if (dtype == 3) { |
305 | // gp_XYZ P = ent->Vector(i).XYZ(); |
306 | S << "\n Vector (" << T.X() << "," << T.Y() << "," << T.Z() << ")"; |
307 | if (yatr) { |
308 | locv.Transforms(T); |
309 | S << " Transformed ("<< T.X() << "," << T.Y() << "," << T.Z() << ")"; |
310 | } |
311 | } |
04232180 |
312 | S << Message_EndLine; |
7fd59977 |
313 | } |
314 | } |
315 | else S << " [ for content, ask level > 4 ]"; |
04232180 |
316 | S << Message_EndLine; |
7fd59977 |
317 | } |