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_ToolFace.ixx>
20 #include <IGESData_ParamCursor.hxx>
21 #include <IGESData_IGESEntity.hxx>
22 #include <IGESSolid_Loop.hxx>
23 #include <IGESSolid_HArray1OfLoop.hxx>
24 #include <IGESData_Dump.hxx>
25 #include <Interface_Macros.hxx>
28 #include <Message_Msg.hxx>
29 #include <IGESData_Status.hxx>
31 //=======================================================================
32 //function : IGESSolid_ToolFace
34 //=======================================================================
36 IGESSolid_ToolFace::IGESSolid_ToolFace ()
41 //=======================================================================
42 //function : ReadOwnParams
44 //=======================================================================
46 void IGESSolid_ToolFace::ReadOwnParams(const Handle(IGESSolid_Face)& ent,
47 const Handle(IGESData_IGESReaderData)& IR,
48 IGESData_ParamReader& PR) const
51 // Building of messages
52 //========================================
53 Message_Msg Msg197("XSTEP_197");
54 Message_Msg Msg198("XSTEP_198");
55 //========================================
57 Standard_Boolean outerLoopFlag; //szv#4:S4163:12Mar99 `st` moved down
58 Handle(IGESData_IGESEntity) anent;
59 Handle(IGESSolid_Loop) aloop;
60 Handle(IGESData_IGESEntity) tempSurface;
61 Standard_Integer nbloops;
62 Handle(IGESSolid_HArray1OfLoop) tempLoops;
63 IGESData_Status aStatus;
65 if (!PR.ReadEntity(IR, PR.Current(), aStatus, tempSurface)){ //szv#4:S4163:12Mar99 `st=` not needed
66 Message_Msg Msg196("XSTEP_196");
68 case IGESData_ReferenceError: {
69 Message_Msg Msg216 ("IGES_216");
70 Msg196.Arg(Msg216.Value());
73 case IGESData_EntityError: {
74 Message_Msg Msg217 ("IGES_217");
75 Msg196.Arg(Msg217.Value());
82 Standard_Boolean st = PR.ReadInteger(PR.Current(), nbloops);
87 st = PR.ReadEntity(IR, PR.Current(), "Surface", tempSurface);
88 st = PR.ReadInteger(PR.Current(), "Number of loops", nbloops);
90 if (st && nbloops > 0) tempLoops = new IGESSolid_HArray1OfLoop(1, nbloops);
91 else PR.SendFail(Msg197);
93 PR.ReadBoolean(PR.Current(), Msg198, outerLoopFlag); //szv#4:S4163:12Mar99 `st=` not needed
94 //st = PR.ReadBoolean(PR.Current(), "Outer loop flag", outerLoopFlag);
96 if (!tempLoops.IsNull()) {
97 for (Standard_Integer i=1; i<=nbloops; i++) {
98 //st = PR.ReadEntity(IR, PR.Current(), Msg199, STANDARD_TYPE(IGESSolid_Loop), aloop); //szv#4:S4163:12Mar99 moved in if
99 //st = PR.ReadEntity(IR, PR.Current(), "Loops", STANDARD_TYPE(IGESSolid_Loop), aloop);
100 if (PR.ReadEntity(IR, PR.Current(), aStatus, STANDARD_TYPE(IGESSolid_Loop), aloop))
101 tempLoops->SetValue(i, aloop);
103 Message_Msg Msg199("XSTEP_199");
105 case IGESData_ReferenceError: {
106 Message_Msg Msg216 ("IGES_216");
107 Msg199.Arg(Msg216.Value());
110 case IGESData_EntityError: {
111 Message_Msg Msg217 ("IGES_217");
112 Msg199.Arg(Msg217.Value());
115 case IGESData_TypeError: {
116 Message_Msg Msg218 ("IGES_218");
117 Msg199.Arg(Msg218.Value());
126 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
127 ent->Init (tempSurface, outerLoopFlag, tempLoops);
131 //=======================================================================
132 //function : WriteOwnParams
134 //=======================================================================
136 void IGESSolid_ToolFace::WriteOwnParams(const Handle(IGESSolid_Face)& ent,
137 IGESData_IGESWriter& IW) const
139 Standard_Integer upper = ent->NbLoops();
140 IW.Send(ent->Surface());
142 IW.SendBoolean(ent->HasOuterLoop());
143 for (Standard_Integer i = 1; i <= upper; i ++)
144 IW.Send(ent->Loop(i));
148 //=======================================================================
149 //function : OwnShared
151 //=======================================================================
153 void IGESSolid_ToolFace::OwnShared(const Handle(IGESSolid_Face)& ent,
154 Interface_EntityIterator& iter) const
156 Standard_Integer upper = ent->NbLoops();
157 iter.GetOneItem(ent->Surface());
158 for (Standard_Integer i = 1; i <= upper; i ++)
159 iter.GetOneItem(ent->Loop(i));
163 //=======================================================================
166 //=======================================================================
168 void IGESSolid_ToolFace::OwnCopy(const Handle(IGESSolid_Face)& another,
169 const Handle(IGESSolid_Face)& ent,
170 Interface_CopyTool& TC) const
172 DeclareAndCast(IGESData_IGESEntity, tempSurface,
173 TC.Transferred(another->Surface()));
174 Standard_Integer nbloops = another->NbLoops();
175 Standard_Boolean outerLoopFlag = another->HasOuterLoop();
177 Handle(IGESSolid_HArray1OfLoop) tempLoops =
178 new IGESSolid_HArray1OfLoop(1, nbloops);
179 for (Standard_Integer i=1; i<=nbloops; i++)
181 DeclareAndCast(IGESSolid_Loop, anent,
182 TC.Transferred(another->Loop(i)));
183 tempLoops->SetValue(i, anent);
186 ent->Init (tempSurface, outerLoopFlag, tempLoops);
190 //=======================================================================
191 //function : DirChecker
193 //=======================================================================
195 IGESData_DirChecker IGESSolid_ToolFace::DirChecker
196 (const Handle(IGESSolid_Face)& /* ent */ ) const
198 IGESData_DirChecker DC(510, 1);
200 DC.Structure (IGESData_DefVoid);
201 DC.LineFont (IGESData_DefVoid);
202 DC.LineWeight (IGESData_DefVoid);
203 DC.Color (IGESData_DefVoid);
205 DC.SubordinateStatusRequired(1);
210 //=======================================================================
211 //function : OwnCheck
213 //=======================================================================
215 void IGESSolid_ToolFace::OwnCheck(const Handle(IGESSolid_Face)& ent,
216 const Interface_ShareTool&,
217 Handle(Interface_Check)& ach) const
220 // Building of messages
221 //========================================
222 //Message_Msg Msg197("XSTEP_197");
223 //========================================
225 if (ent->NbLoops() <= 0) {
226 Message_Msg Msg197("XSTEP_197");
227 ach->SendFail(Msg197);
232 //=======================================================================
235 //=======================================================================
237 void IGESSolid_ToolFace::OwnDump(const Handle(IGESSolid_Face)& ent,
238 const IGESData_IGESDumper& dumper,
239 const Handle(Message_Messenger)& S,
240 const Standard_Integer level) const
242 S << "IGESSolid_Face" << endl;
244 Standard_Integer sublevel = (level <= 4) ? 0 : 1;
246 dumper.Dump(ent->Surface(),S, sublevel);
248 if (ent->HasOuterLoop()) S << "Outer loop is present (First one)" << endl;
249 else S << "Outer loop is not present" << endl;
251 IGESData_DumpEntities(S,dumper ,level,1, ent->NbLoops(),ent->Loop);