0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / IGESSolid / IGESSolid_ToolEdgeList.cxx
CommitLineData
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 <IGESData_DirChecker.hxx>
20#include <IGESData_Dump.hxx>
7fd59977 21#include <IGESData_HArray1OfIGESEntity.hxx>
42cf5bc1 22#include <IGESData_IGESDumper.hxx>
23#include <IGESData_IGESEntity.hxx>
24#include <IGESData_IGESReaderData.hxx>
25#include <IGESData_IGESWriter.hxx>
26#include <IGESData_ParamCursor.hxx>
27#include <IGESData_ParamReader.hxx>
28#include <IGESData_Status.hxx>
29#include <IGESSolid_EdgeList.hxx>
7fd59977 30#include <IGESSolid_HArray1OfVertexList.hxx>
42cf5bc1 31#include <IGESSolid_ToolEdgeList.hxx>
32#include <IGESSolid_VertexList.hxx>
33#include <Interface_Check.hxx>
34#include <Interface_CopyTool.hxx>
35#include <Interface_EntityIterator.hxx>
7fd59977 36#include <Interface_Macros.hxx>
42cf5bc1 37#include <Interface_ShareTool.hxx>
38#include <Message_Messenger.hxx>
7fd59977 39#include <Message_Msg.hxx>
42cf5bc1 40#include <Standard_DomainError.hxx>
41#include <TColStd_HArray1OfInteger.hxx>
7fd59977 42
42cf5bc1 43// MGE 03/08/98
7fd59977 44//=======================================================================
45//function : IGESSolid_ToolEdgeList
46//purpose :
47//=======================================================================
7fd59977 48IGESSolid_ToolEdgeList::IGESSolid_ToolEdgeList ()
49{
50}
51
52
53//=======================================================================
54//function : ReadOwnParams
55//purpose :
56//=======================================================================
57
58void IGESSolid_ToolEdgeList::ReadOwnParams(const Handle(IGESSolid_EdgeList)& ent,
59 const Handle(IGESData_IGESReaderData)& IR,
60 IGESData_ParamReader& PR) const
61{
62 // MGE 03/08/98
63 //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down
64 Standard_Integer length, anint;
65 Handle(IGESData_IGESEntity) anent;
66 Handle(IGESSolid_VertexList) avert;
67 Handle(IGESData_HArray1OfIGESEntity) tempCurves;
68 Handle(IGESSolid_HArray1OfVertexList) tempStartVertexList;
69 Handle(TColStd_HArray1OfInteger) tempStartVertexIndex;
70 Handle(IGESSolid_HArray1OfVertexList) tempEndVertexList;
71 Handle(TColStd_HArray1OfInteger) tempEndVertexIndex;
72 IGESData_Status aStatus;
73
74 Standard_Boolean st = PR.ReadInteger(PR.Current(), length);
75 if(!st){
76 Message_Msg Msg184("XSTEP_184");
77 PR.SendFail(Msg184);
78 }
79 //st = PR.ReadInteger(PR.Current(), "Number of edges", length);
80 if (st && length > 0)
81 {
82 tempCurves = new IGESData_HArray1OfIGESEntity(1, length);
83 tempStartVertexList = new IGESSolid_HArray1OfVertexList(1, length);
84 tempStartVertexIndex = new TColStd_HArray1OfInteger(1, length);
85 tempEndVertexList = new IGESSolid_HArray1OfVertexList(1, length);
86 tempEndVertexIndex = new TColStd_HArray1OfInteger(1, length);
87 for (Standard_Integer i=1 ; i<=length ; i++)
88 {
89 // Curves
90 //st = PR.ReadEntity(IR, PR.Current(), Msg185, anent); //szv#4:S4163:12Mar99 moved in if
91 //st = PR.ReadEntity(IR, PR.Current(), "Model space curve", anent);
92 if (PR.ReadEntity(IR, PR.Current(), aStatus, anent))
93 tempCurves->SetValue(i, anent);
94 else{
95 Message_Msg Msg185("XSTEP_185");
96 switch(aStatus) {
97 case IGESData_ReferenceError: {
98 Message_Msg Msg216 ("IGES_216");
99 Msg185.Arg(Msg216.Value());
100 PR.SendFail(Msg185);
101 break; }
102 case IGESData_EntityError: {
103 Message_Msg Msg217 ("IGES_217");
104 Msg185.Arg(Msg217.Value());
105 PR.SendFail(Msg185);
106 break; }
107 default:{
108 }
109 }
110 }
111 // Start vertex list
112 //st = PR.ReadEntity(IR, PR.Current(), Msg188,
113 //STANDARD_TYPE(IGESSolid_VertexList), avert); //szv#4:S4163:12Mar99 moved in if
114 /*
115 st = PR.ReadEntity(IR, PR.Current(), "Start vertex list",
116 STANDARD_TYPE(IGESSolid_VertexList), avert);
117 */
118 if (PR.ReadEntity(IR, PR.Current(), aStatus, STANDARD_TYPE(IGESSolid_VertexList), avert))
119 tempStartVertexList->SetValue(i, avert);
120 else{
121 Message_Msg Msg188("XSTEP_188");
122 switch(aStatus) {
123 case IGESData_ReferenceError: {
124 Message_Msg Msg216 ("IGES_216");
125 Msg188.Arg(Msg216.Value());
126 PR.SendFail(Msg188);
127 break; }
128 case IGESData_EntityError: {
129 Message_Msg Msg217 ("IGES_217");
130 Msg188.Arg(Msg217.Value());
131 PR.SendFail(Msg188);
132 break; }
133 case IGESData_TypeError: {
134 Message_Msg Msg218 ("IGES_218");
135 Msg188.Arg(Msg218.Value());
136 PR.SendFail(Msg188);
137 break; }
138 default:{
139 }
140 }
141 }
142
143 // Start vertex index
144 //st = PR.ReadInteger(PR.Current(), Msg186, anint); //szv#4:S4163:12Mar99 moved in if
145 //st = PR.ReadInteger(PR.Current(), "Start vertex index", anint);
146 if (PR.ReadInteger(PR.Current(), anint))
147 tempStartVertexIndex->SetValue(i, anint);
148 else{
149 Message_Msg Msg186("XSTEP_186");
150 PR.SendFail(Msg186);
151 }
152
153 // End vertex list
154 //st = PR.ReadEntity(IR, PR.Current(),Msg189 ,
155 //STANDARD_TYPE(IGESSolid_VertexList), avert); //szv#4:S4163:12Mar99 moved in if
156 /*
157 st = PR.ReadEntity(IR, PR.Current(), "End vertex list",
158 STANDARD_TYPE(IGESSolid_VertexList), avert);
159 */
160 if (PR.ReadEntity(IR, PR.Current(), aStatus, STANDARD_TYPE(IGESSolid_VertexList), avert))
161 tempEndVertexList->SetValue(i, avert);
162 else{
163 Message_Msg Msg189("XSTEP_189");
164 switch(aStatus) {
165 case IGESData_ReferenceError: {
166 Message_Msg Msg216 ("IGES_216");
167 Msg189.Arg(Msg216.Value());
168 PR.SendFail(Msg189);
169 break; }
170 case IGESData_EntityError: {
171 Message_Msg Msg217 ("IGES_217");
172 Msg189.Arg(Msg217.Value());
173 PR.SendFail(Msg189);
174 break; }
175 case IGESData_TypeError: {
176 Message_Msg Msg218 ("IGES_218");
177 Msg189.Arg(Msg218.Value());
178 PR.SendFail(Msg189);
179 break; }
180 default:{
181 }
182 }
183 }
184 // End vertex index
185 //st = PR.ReadInteger(PR.Current(), Msg187, anint); //szv#4:S4163:12Mar99 moved in if
186 //st = PR.ReadInteger(PR.Current(), "End vertex index", anint);
187 if (PR.ReadInteger(PR.Current(), anint))
188 tempEndVertexIndex->SetValue(i, anint);
189 else {
190 Message_Msg Msg187("XSTEP_187");
191 PR.SendFail(Msg187);
192 }
193 }
194 }
195
196 if (st && length <= 0){
197 Message_Msg Msg184("XSTEP_184");
198 PR.SendFail(Msg184);
199 }
200 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
201 if (length > 0) ent->Init
202 (tempCurves, tempStartVertexList, tempStartVertexIndex,
203 tempEndVertexList, tempEndVertexIndex);
204}
205
206
207//=======================================================================
208//function : WriteOwnParams
209//purpose :
210//=======================================================================
211
212void IGESSolid_ToolEdgeList::WriteOwnParams(const Handle(IGESSolid_EdgeList)& ent,
213 IGESData_IGESWriter& IW) const
214{
215 Standard_Integer length = ent->NbEdges();
216
217 IW.Send(length);
218 for (Standard_Integer i = 1; i <= length; i ++)
219 {
220 IW.Send(ent->Curve(i));
221 IW.Send(ent->StartVertexList(i));
222 IW.Send(ent->StartVertexIndex(i));
223 IW.Send(ent->EndVertexList(i));
224 IW.Send(ent->EndVertexIndex(i));
225 }
226}
227
228
229//=======================================================================
230//function : OwnShared
231//purpose :
232//=======================================================================
233
234void IGESSolid_ToolEdgeList::OwnShared(const Handle(IGESSolid_EdgeList)& ent,
235 Interface_EntityIterator& iter) const
236{
237 Standard_Integer length = ent->NbEdges();
238 for (Standard_Integer i = 1; i <= length; i ++)
239 {
240 iter.GetOneItem(ent->Curve(i));
241 iter.GetOneItem(ent->StartVertexList(i));
242 iter.GetOneItem(ent->EndVertexList(i));
243 }
244}
245
246
247//=======================================================================
248//function : OwnCopy
249//purpose :
250//=======================================================================
251
252void IGESSolid_ToolEdgeList::OwnCopy(const Handle(IGESSolid_EdgeList)& another,
253 const Handle(IGESSolid_EdgeList)& ent,
254 Interface_CopyTool& TC) const
255{
256 Standard_Integer length;
257
258 length = another->NbEdges();
259 Handle(IGESData_HArray1OfIGESEntity) tempCurves =
260 new IGESData_HArray1OfIGESEntity(1, length);
261 Handle(IGESSolid_HArray1OfVertexList) tempStartVertexList =
262 new IGESSolid_HArray1OfVertexList(1, length);
263 Handle(TColStd_HArray1OfInteger) tempStartVertexIndex =
264 new TColStd_HArray1OfInteger(1, length);
265 Handle(IGESSolid_HArray1OfVertexList) tempEndVertexList =
266 new IGESSolid_HArray1OfVertexList(1, length);
267 Handle(TColStd_HArray1OfInteger) tempEndVertexIndex =
268 new TColStd_HArray1OfInteger(1, length);
269
270 for (Standard_Integer i=1 ; i<=length ; i++)
271 {
272 // Curves
273 DeclareAndCast(IGESData_IGESEntity, curve,
274 TC.Transferred(another->Curve(i)));
275 tempCurves->SetValue(i, curve);
276
277 // Start vertex list
278 DeclareAndCast(IGESSolid_VertexList, start,
279 TC.Transferred(another->StartVertexList(i)));
280 tempStartVertexList->SetValue(i, start);
281
282 // Start vertex index
283 tempStartVertexIndex->SetValue(i, another->StartVertexIndex(i));
284
285 // End vertex list
286 DeclareAndCast(IGESSolid_VertexList, end,
287 TC.Transferred(another->EndVertexList(i)));
288 tempEndVertexList->SetValue(i, end);
289
290 // End vertex index
291 tempEndVertexIndex->SetValue(i, another->EndVertexIndex(i));
292 }
293
294 ent->Init (tempCurves, tempStartVertexList, tempStartVertexIndex,
295 tempEndVertexList, tempEndVertexIndex);
296}
297
298
299//=======================================================================
300//function : DirChecker
301//purpose :
302//=======================================================================
303
304IGESData_DirChecker IGESSolid_ToolEdgeList::DirChecker
305 (const Handle(IGESSolid_EdgeList)& /* ent */ ) const
306{
307 IGESData_DirChecker DC(504, 1);
308
309 DC.Structure (IGESData_DefVoid);
310 DC.LineFont (IGESData_DefVoid);
311 DC.LineWeight (IGESData_DefVoid);
312 DC.Color (IGESData_DefVoid);
313
314 DC.SubordinateStatusRequired (1);
315 DC.HierarchyStatusRequired (1);
316 return DC;
317}
318
319
320//=======================================================================
321//function : OwnCheck
322//purpose :
323//=======================================================================
324
325void IGESSolid_ToolEdgeList::OwnCheck(const Handle(IGESSolid_EdgeList)& ent,
326 const Interface_ShareTool&,
327 Handle(Interface_Check)& ach) const
328{
329 // MGE 03/08/98
330 // Building of messages
331 //========================================
332 //Message_Msg Msg184("XSTEP_184");
333 //========================================
334
335 if (ent->NbEdges() <= 0) {
336 Message_Msg Msg184("XSTEP_184");
337 ach->SendFail(Msg184);
338 }
339}
340
341
342//=======================================================================
343//function : OwnDump
344//purpose :
345//=======================================================================
346
347void IGESSolid_ToolEdgeList::OwnDump(const Handle(IGESSolid_EdgeList)& ent,
348 const IGESData_IGESDumper& dumper,
0ebe5b0a 349 Standard_OStream& S,
7fd59977 350 const Standard_Integer level) const
351{
352 Standard_Integer i, length = ent->NbEdges();
353
0ebe5b0a 354 S << "IGESSolid_EdgeList\n"
355 << "Number of edge tuples : " << length << "\n";
7fd59977 356 switch (level)
357 {
358 case 4 :
0ebe5b0a 359 S << "Curves : "
360 << "Start Vertex List : "
361 << "Start Vertex Index : ";
362 IGESData_DumpVals(S,level,1, length,ent->StartVertexIndex);
363 S << "\n"
364 << "End Vertex List : "
365 << "End Vertex Index : ";
366 IGESData_DumpVals(S,level,1, length,ent->EndVertexIndex);
367 S << "\n";
7fd59977 368 break;
369 case 5 :
370 case 6 :
0ebe5b0a 371 S <<" Curve - Vertices. Start : (VertexList,Index) End : (VertexList,Index)\n";
7fd59977 372 for (i = 1; i <= length; i ++)
373 {
374//[123]:Curve : #1234 - Vertices. Start = (#5678 , 3467) End = (#1234 , 4664)
375 S << "[" << i << "]:Curve : ";
376 dumper.Dump (ent->Curve(i),S, level-5);
377 S <<" - Vertices. Start : (";
378 dumper.Dump (ent->StartVertexList(i),S, 0);
0ebe5b0a 379 S << " , " << ent->StartVertexIndex(i)
380 << ") End : (";
7fd59977 381 dumper.Dump (ent->EndVertexList(i),S, 0);
0ebe5b0a 382 S << " , " << ent->EndVertexIndex(i)
383 << ")" << "\n";
7fd59977 384 }
385 break;
386 default :
387 break;
388 }
0ebe5b0a 389 S << std::endl;
7fd59977 390}