1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 //--------------------------------------------------------------------
17 //--------------------------------------------------------------------
19 #include <IGESSolid_ToolEdgeList.ixx>
20 #include <IGESData_ParamCursor.hxx>
21 #include <IGESData_IGESEntity.hxx>
22 #include <IGESSolid_VertexList.hxx>
23 #include <IGESData_HArray1OfIGESEntity.hxx>
24 #include <IGESSolid_HArray1OfVertexList.hxx>
25 #include <TColStd_HArray1OfInteger.hxx>
26 #include <IGESData_Dump.hxx>
27 #include <Interface_Macros.hxx>
30 #include <Message_Msg.hxx>
31 #include <IGESData_Status.hxx>
33 //=======================================================================
34 //function : IGESSolid_ToolEdgeList
36 //=======================================================================
38 IGESSolid_ToolEdgeList::IGESSolid_ToolEdgeList ()
43 //=======================================================================
44 //function : ReadOwnParams
46 //=======================================================================
48 void IGESSolid_ToolEdgeList::ReadOwnParams(const Handle(IGESSolid_EdgeList)& ent,
49 const Handle(IGESData_IGESReaderData)& IR,
50 IGESData_ParamReader& PR) const
53 //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down
54 Standard_Integer length, anint;
55 Handle(IGESData_IGESEntity) anent;
56 Handle(IGESSolid_VertexList) avert;
57 Handle(IGESData_HArray1OfIGESEntity) tempCurves;
58 Handle(IGESSolid_HArray1OfVertexList) tempStartVertexList;
59 Handle(TColStd_HArray1OfInteger) tempStartVertexIndex;
60 Handle(IGESSolid_HArray1OfVertexList) tempEndVertexList;
61 Handle(TColStd_HArray1OfInteger) tempEndVertexIndex;
62 IGESData_Status aStatus;
64 Standard_Boolean st = PR.ReadInteger(PR.Current(), length);
66 Message_Msg Msg184("XSTEP_184");
69 //st = PR.ReadInteger(PR.Current(), "Number of edges", length);
72 tempCurves = new IGESData_HArray1OfIGESEntity(1, length);
73 tempStartVertexList = new IGESSolid_HArray1OfVertexList(1, length);
74 tempStartVertexIndex = new TColStd_HArray1OfInteger(1, length);
75 tempEndVertexList = new IGESSolid_HArray1OfVertexList(1, length);
76 tempEndVertexIndex = new TColStd_HArray1OfInteger(1, length);
77 for (Standard_Integer i=1 ; i<=length ; i++)
80 //st = PR.ReadEntity(IR, PR.Current(), Msg185, anent); //szv#4:S4163:12Mar99 moved in if
81 //st = PR.ReadEntity(IR, PR.Current(), "Model space curve", anent);
82 if (PR.ReadEntity(IR, PR.Current(), aStatus, anent))
83 tempCurves->SetValue(i, anent);
85 Message_Msg Msg185("XSTEP_185");
87 case IGESData_ReferenceError: {
88 Message_Msg Msg216 ("IGES_216");
89 Msg185.Arg(Msg216.Value());
92 case IGESData_EntityError: {
93 Message_Msg Msg217 ("IGES_217");
94 Msg185.Arg(Msg217.Value());
102 //st = PR.ReadEntity(IR, PR.Current(), Msg188,
103 //STANDARD_TYPE(IGESSolid_VertexList), avert); //szv#4:S4163:12Mar99 moved in if
105 st = PR.ReadEntity(IR, PR.Current(), "Start vertex list",
106 STANDARD_TYPE(IGESSolid_VertexList), avert);
108 if (PR.ReadEntity(IR, PR.Current(), aStatus, STANDARD_TYPE(IGESSolid_VertexList), avert))
109 tempStartVertexList->SetValue(i, avert);
111 Message_Msg Msg188("XSTEP_188");
113 case IGESData_ReferenceError: {
114 Message_Msg Msg216 ("IGES_216");
115 Msg188.Arg(Msg216.Value());
118 case IGESData_EntityError: {
119 Message_Msg Msg217 ("IGES_217");
120 Msg188.Arg(Msg217.Value());
123 case IGESData_TypeError: {
124 Message_Msg Msg218 ("IGES_218");
125 Msg188.Arg(Msg218.Value());
133 // Start vertex index
134 //st = PR.ReadInteger(PR.Current(), Msg186, anint); //szv#4:S4163:12Mar99 moved in if
135 //st = PR.ReadInteger(PR.Current(), "Start vertex index", anint);
136 if (PR.ReadInteger(PR.Current(), anint))
137 tempStartVertexIndex->SetValue(i, anint);
139 Message_Msg Msg186("XSTEP_186");
144 //st = PR.ReadEntity(IR, PR.Current(),Msg189 ,
145 //STANDARD_TYPE(IGESSolid_VertexList), avert); //szv#4:S4163:12Mar99 moved in if
147 st = PR.ReadEntity(IR, PR.Current(), "End vertex list",
148 STANDARD_TYPE(IGESSolid_VertexList), avert);
150 if (PR.ReadEntity(IR, PR.Current(), aStatus, STANDARD_TYPE(IGESSolid_VertexList), avert))
151 tempEndVertexList->SetValue(i, avert);
153 Message_Msg Msg189("XSTEP_189");
155 case IGESData_ReferenceError: {
156 Message_Msg Msg216 ("IGES_216");
157 Msg189.Arg(Msg216.Value());
160 case IGESData_EntityError: {
161 Message_Msg Msg217 ("IGES_217");
162 Msg189.Arg(Msg217.Value());
165 case IGESData_TypeError: {
166 Message_Msg Msg218 ("IGES_218");
167 Msg189.Arg(Msg218.Value());
175 //st = PR.ReadInteger(PR.Current(), Msg187, anint); //szv#4:S4163:12Mar99 moved in if
176 //st = PR.ReadInteger(PR.Current(), "End vertex index", anint);
177 if (PR.ReadInteger(PR.Current(), anint))
178 tempEndVertexIndex->SetValue(i, anint);
180 Message_Msg Msg187("XSTEP_187");
186 if (st && length <= 0){
187 Message_Msg Msg184("XSTEP_184");
190 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
191 if (length > 0) ent->Init
192 (tempCurves, tempStartVertexList, tempStartVertexIndex,
193 tempEndVertexList, tempEndVertexIndex);
197 //=======================================================================
198 //function : WriteOwnParams
200 //=======================================================================
202 void IGESSolid_ToolEdgeList::WriteOwnParams(const Handle(IGESSolid_EdgeList)& ent,
203 IGESData_IGESWriter& IW) const
205 Standard_Integer length = ent->NbEdges();
208 for (Standard_Integer i = 1; i <= length; i ++)
210 IW.Send(ent->Curve(i));
211 IW.Send(ent->StartVertexList(i));
212 IW.Send(ent->StartVertexIndex(i));
213 IW.Send(ent->EndVertexList(i));
214 IW.Send(ent->EndVertexIndex(i));
219 //=======================================================================
220 //function : OwnShared
222 //=======================================================================
224 void IGESSolid_ToolEdgeList::OwnShared(const Handle(IGESSolid_EdgeList)& ent,
225 Interface_EntityIterator& iter) const
227 Standard_Integer length = ent->NbEdges();
228 for (Standard_Integer i = 1; i <= length; i ++)
230 iter.GetOneItem(ent->Curve(i));
231 iter.GetOneItem(ent->StartVertexList(i));
232 iter.GetOneItem(ent->EndVertexList(i));
237 //=======================================================================
240 //=======================================================================
242 void IGESSolid_ToolEdgeList::OwnCopy(const Handle(IGESSolid_EdgeList)& another,
243 const Handle(IGESSolid_EdgeList)& ent,
244 Interface_CopyTool& TC) const
246 Standard_Integer length;
248 length = another->NbEdges();
249 Handle(IGESData_HArray1OfIGESEntity) tempCurves =
250 new IGESData_HArray1OfIGESEntity(1, length);
251 Handle(IGESSolid_HArray1OfVertexList) tempStartVertexList =
252 new IGESSolid_HArray1OfVertexList(1, length);
253 Handle(TColStd_HArray1OfInteger) tempStartVertexIndex =
254 new TColStd_HArray1OfInteger(1, length);
255 Handle(IGESSolid_HArray1OfVertexList) tempEndVertexList =
256 new IGESSolid_HArray1OfVertexList(1, length);
257 Handle(TColStd_HArray1OfInteger) tempEndVertexIndex =
258 new TColStd_HArray1OfInteger(1, length);
260 for (Standard_Integer i=1 ; i<=length ; i++)
263 DeclareAndCast(IGESData_IGESEntity, curve,
264 TC.Transferred(another->Curve(i)));
265 tempCurves->SetValue(i, curve);
268 DeclareAndCast(IGESSolid_VertexList, start,
269 TC.Transferred(another->StartVertexList(i)));
270 tempStartVertexList->SetValue(i, start);
272 // Start vertex index
273 tempStartVertexIndex->SetValue(i, another->StartVertexIndex(i));
276 DeclareAndCast(IGESSolid_VertexList, end,
277 TC.Transferred(another->EndVertexList(i)));
278 tempEndVertexList->SetValue(i, end);
281 tempEndVertexIndex->SetValue(i, another->EndVertexIndex(i));
284 ent->Init (tempCurves, tempStartVertexList, tempStartVertexIndex,
285 tempEndVertexList, tempEndVertexIndex);
289 //=======================================================================
290 //function : DirChecker
292 //=======================================================================
294 IGESData_DirChecker IGESSolid_ToolEdgeList::DirChecker
295 (const Handle(IGESSolid_EdgeList)& /* ent */ ) const
297 IGESData_DirChecker DC(504, 1);
299 DC.Structure (IGESData_DefVoid);
300 DC.LineFont (IGESData_DefVoid);
301 DC.LineWeight (IGESData_DefVoid);
302 DC.Color (IGESData_DefVoid);
304 DC.SubordinateStatusRequired (1);
305 DC.HierarchyStatusRequired (1);
310 //=======================================================================
311 //function : OwnCheck
313 //=======================================================================
315 void IGESSolid_ToolEdgeList::OwnCheck(const Handle(IGESSolid_EdgeList)& ent,
316 const Interface_ShareTool&,
317 Handle(Interface_Check)& ach) const
320 // Building of messages
321 //========================================
322 //Message_Msg Msg184("XSTEP_184");
323 //========================================
325 if (ent->NbEdges() <= 0) {
326 Message_Msg Msg184("XSTEP_184");
327 ach->SendFail(Msg184);
332 //=======================================================================
335 //=======================================================================
337 void IGESSolid_ToolEdgeList::OwnDump(const Handle(IGESSolid_EdgeList)& ent,
338 const IGESData_IGESDumper& dumper,
339 const Handle(Message_Messenger)& S,
340 const Standard_Integer level) const
342 Standard_Integer i, length = ent->NbEdges();
344 S << "IGESSolid_EdgeList" << endl;
345 S << "Number of edge tuples : " << length << endl;
350 S << "Start Vertex List : ";
351 S << "Start Vertex Index : ";
352 IGESData_DumpVals(S ,level,1, length,ent->StartVertexIndex);
354 S << "End Vertex List : ";
355 S << "End Vertex Index : ";
356 IGESData_DumpVals(S ,level,1, length,ent->EndVertexIndex);
361 S<<" Curve - Vertices. Start : (VertexList,Index) End : (VertexList,Index)"<<endl;
362 for (i = 1; i <= length; i ++)
364 //[123]:Curve : #1234 - Vertices. Start = (#5678 , 3467) End = (#1234 , 4664)
365 S << "[" << i << "]:Curve : ";
366 dumper.Dump (ent->Curve(i),S, level-5);
367 S <<" - Vertices. Start : (";
368 dumper.Dump (ent->StartVertexList(i),S, 0);
369 S << " , " << ent->StartVertexIndex(i);
371 dumper.Dump (ent->EndVertexList(i),S, 0);
372 S << " , " << ent->EndVertexIndex(i);