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 <IGESData_DirChecker.hxx>
20 #include <IGESData_Dump.hxx>
21 #include <IGESData_IGESDumper.hxx>
22 #include <IGESData_IGESReaderData.hxx>
23 #include <IGESData_IGESWriter.hxx>
24 #include <IGESData_ParamReader.hxx>
25 #include <IGESData_Status.hxx>
26 #include <IGESSolid_Face.hxx>
27 #include <IGESSolid_HArray1OfLoop.hxx>
28 #include <IGESSolid_Loop.hxx>
29 #include <IGESSolid_ToolFace.hxx>
30 #include <Interface_Check.hxx>
31 #include <Interface_CopyTool.hxx>
32 #include <Interface_EntityIterator.hxx>
33 #include <Interface_Macros.hxx>
34 #include <Interface_ShareTool.hxx>
35 #include <Message_Messenger.hxx>
36 #include <Message_Msg.hxx>
39 //=======================================================================
40 //function : IGESSolid_ToolFace
42 //=======================================================================
43 IGESSolid_ToolFace::IGESSolid_ToolFace ()
48 //=======================================================================
49 //function : ReadOwnParams
51 //=======================================================================
53 void IGESSolid_ToolFace::ReadOwnParams(const Handle(IGESSolid_Face)& ent,
54 const Handle(IGESData_IGESReaderData)& IR,
55 IGESData_ParamReader& PR) const
58 // Building of messages
59 //========================================
60 Message_Msg Msg197("XSTEP_197");
61 Message_Msg Msg198("XSTEP_198");
62 //========================================
64 Standard_Boolean outerLoopFlag; //szv#4:S4163:12Mar99 `st` moved down
65 Handle(IGESData_IGESEntity) anent;
66 Handle(IGESSolid_Loop) aloop;
67 Handle(IGESData_IGESEntity) tempSurface;
68 Standard_Integer nbloops;
69 Handle(IGESSolid_HArray1OfLoop) tempLoops;
70 IGESData_Status aStatus;
72 if (!PR.ReadEntity(IR, PR.Current(), aStatus, tempSurface)){ //szv#4:S4163:12Mar99 `st=` not needed
73 Message_Msg Msg196("XSTEP_196");
75 case IGESData_ReferenceError: {
76 Message_Msg Msg216 ("IGES_216");
77 Msg196.Arg(Msg216.Value());
80 case IGESData_EntityError: {
81 Message_Msg Msg217 ("IGES_217");
82 Msg196.Arg(Msg217.Value());
89 Standard_Boolean st = PR.ReadInteger(PR.Current(), nbloops);
94 st = PR.ReadEntity(IR, PR.Current(), "Surface", tempSurface);
95 st = PR.ReadInteger(PR.Current(), "Number of loops", nbloops);
97 if (st && nbloops > 0) tempLoops = new IGESSolid_HArray1OfLoop(1, nbloops);
98 else PR.SendFail(Msg197);
100 PR.ReadBoolean(PR.Current(), Msg198, outerLoopFlag); //szv#4:S4163:12Mar99 `st=` not needed
101 //st = PR.ReadBoolean(PR.Current(), "Outer loop flag", outerLoopFlag);
103 if (!tempLoops.IsNull()) {
104 for (Standard_Integer i=1; i<=nbloops; i++) {
105 //st = PR.ReadEntity(IR, PR.Current(), Msg199, STANDARD_TYPE(IGESSolid_Loop), aloop); //szv#4:S4163:12Mar99 moved in if
106 //st = PR.ReadEntity(IR, PR.Current(), "Loops", STANDARD_TYPE(IGESSolid_Loop), aloop);
107 if (PR.ReadEntity(IR, PR.Current(), aStatus, STANDARD_TYPE(IGESSolid_Loop), aloop))
108 tempLoops->SetValue(i, aloop);
110 Message_Msg Msg199("XSTEP_199");
112 case IGESData_ReferenceError: {
113 Message_Msg Msg216 ("IGES_216");
114 Msg199.Arg(Msg216.Value());
117 case IGESData_EntityError: {
118 Message_Msg Msg217 ("IGES_217");
119 Msg199.Arg(Msg217.Value());
122 case IGESData_TypeError: {
123 Message_Msg Msg218 ("IGES_218");
124 Msg199.Arg(Msg218.Value());
133 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
134 ent->Init (tempSurface, outerLoopFlag, tempLoops);
138 //=======================================================================
139 //function : WriteOwnParams
141 //=======================================================================
143 void IGESSolid_ToolFace::WriteOwnParams(const Handle(IGESSolid_Face)& ent,
144 IGESData_IGESWriter& IW) const
146 Standard_Integer upper = ent->NbLoops();
147 IW.Send(ent->Surface());
149 IW.SendBoolean(ent->HasOuterLoop());
150 for (Standard_Integer i = 1; i <= upper; i ++)
151 IW.Send(ent->Loop(i));
155 //=======================================================================
156 //function : OwnShared
158 //=======================================================================
160 void IGESSolid_ToolFace::OwnShared(const Handle(IGESSolid_Face)& ent,
161 Interface_EntityIterator& iter) const
163 Standard_Integer upper = ent->NbLoops();
164 iter.GetOneItem(ent->Surface());
165 for (Standard_Integer i = 1; i <= upper; i ++)
166 iter.GetOneItem(ent->Loop(i));
170 //=======================================================================
173 //=======================================================================
175 void IGESSolid_ToolFace::OwnCopy(const Handle(IGESSolid_Face)& another,
176 const Handle(IGESSolid_Face)& ent,
177 Interface_CopyTool& TC) const
179 DeclareAndCast(IGESData_IGESEntity, tempSurface,
180 TC.Transferred(another->Surface()));
181 Standard_Integer nbloops = another->NbLoops();
182 Standard_Boolean outerLoopFlag = another->HasOuterLoop();
184 Handle(IGESSolid_HArray1OfLoop) tempLoops =
185 new IGESSolid_HArray1OfLoop(1, nbloops);
186 for (Standard_Integer i=1; i<=nbloops; i++)
188 DeclareAndCast(IGESSolid_Loop, anent,
189 TC.Transferred(another->Loop(i)));
190 tempLoops->SetValue(i, anent);
193 ent->Init (tempSurface, outerLoopFlag, tempLoops);
197 //=======================================================================
198 //function : DirChecker
200 //=======================================================================
202 IGESData_DirChecker IGESSolid_ToolFace::DirChecker
203 (const Handle(IGESSolid_Face)& /* ent */ ) const
205 IGESData_DirChecker DC(510, 1);
207 DC.Structure (IGESData_DefVoid);
208 DC.LineFont (IGESData_DefVoid);
209 DC.LineWeight (IGESData_DefVoid);
210 DC.Color (IGESData_DefAny);
212 DC.SubordinateStatusRequired(1);
217 //=======================================================================
218 //function : OwnCheck
220 //=======================================================================
222 void IGESSolid_ToolFace::OwnCheck(const Handle(IGESSolid_Face)& ent,
223 const Interface_ShareTool&,
224 Handle(Interface_Check)& ach) const
227 // Building of messages
228 //========================================
229 //Message_Msg Msg197("XSTEP_197");
230 //========================================
232 if (ent->NbLoops() <= 0) {
233 Message_Msg Msg197("XSTEP_197");
234 ach->SendFail(Msg197);
239 //=======================================================================
242 //=======================================================================
244 void IGESSolid_ToolFace::OwnDump(const Handle(IGESSolid_Face)& ent,
245 const IGESData_IGESDumper& dumper,
247 const Standard_Integer level) const
249 S << "IGESSolid_Face\n";
251 Standard_Integer sublevel = (level <= 4) ? 0 : 1;
253 dumper.Dump(ent->Surface(),S, sublevel);
255 if (ent->HasOuterLoop()) S << "Outer loop is present (First one)\n";
256 else S << "Outer loop is not present\n";
258 IGESData_DumpEntities(S,dumper ,level,1, ent->NbLoops(),ent->Loop);