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_IGESEntity.hxx>
23 #include <IGESData_IGESReaderData.hxx>
24 #include <IGESData_IGESWriter.hxx>
25 #include <IGESData_ParamCursor.hxx>
26 #include <IGESData_ParamReader.hxx>
27 #include <IGESData_Status.hxx>
28 #include <IGESSolid_Face.hxx>
29 #include <IGESSolid_HArray1OfLoop.hxx>
30 #include <IGESSolid_Loop.hxx>
31 #include <IGESSolid_ToolFace.hxx>
32 #include <Interface_Check.hxx>
33 #include <Interface_CopyTool.hxx>
34 #include <Interface_EntityIterator.hxx>
35 #include <Interface_Macros.hxx>
36 #include <Interface_ShareTool.hxx>
37 #include <Message_Messenger.hxx>
38 #include <Message_Msg.hxx>
39 #include <Standard_DomainError.hxx>
42 //=======================================================================
43 //function : IGESSolid_ToolFace
45 //=======================================================================
46 IGESSolid_ToolFace::IGESSolid_ToolFace ()
51 //=======================================================================
52 //function : ReadOwnParams
54 //=======================================================================
56 void IGESSolid_ToolFace::ReadOwnParams(const Handle(IGESSolid_Face)& ent,
57 const Handle(IGESData_IGESReaderData)& IR,
58 IGESData_ParamReader& PR) const
61 // Building of messages
62 //========================================
63 Message_Msg Msg197("XSTEP_197");
64 Message_Msg Msg198("XSTEP_198");
65 //========================================
67 Standard_Boolean outerLoopFlag; //szv#4:S4163:12Mar99 `st` moved down
68 Handle(IGESData_IGESEntity) anent;
69 Handle(IGESSolid_Loop) aloop;
70 Handle(IGESData_IGESEntity) tempSurface;
71 Standard_Integer nbloops;
72 Handle(IGESSolid_HArray1OfLoop) tempLoops;
73 IGESData_Status aStatus;
75 if (!PR.ReadEntity(IR, PR.Current(), aStatus, tempSurface)){ //szv#4:S4163:12Mar99 `st=` not needed
76 Message_Msg Msg196("XSTEP_196");
78 case IGESData_ReferenceError: {
79 Message_Msg Msg216 ("IGES_216");
80 Msg196.Arg(Msg216.Value());
83 case IGESData_EntityError: {
84 Message_Msg Msg217 ("IGES_217");
85 Msg196.Arg(Msg217.Value());
92 Standard_Boolean st = PR.ReadInteger(PR.Current(), nbloops);
97 st = PR.ReadEntity(IR, PR.Current(), "Surface", tempSurface);
98 st = PR.ReadInteger(PR.Current(), "Number of loops", nbloops);
100 if (st && nbloops > 0) tempLoops = new IGESSolid_HArray1OfLoop(1, nbloops);
101 else PR.SendFail(Msg197);
103 PR.ReadBoolean(PR.Current(), Msg198, outerLoopFlag); //szv#4:S4163:12Mar99 `st=` not needed
104 //st = PR.ReadBoolean(PR.Current(), "Outer loop flag", outerLoopFlag);
106 if (!tempLoops.IsNull()) {
107 for (Standard_Integer i=1; i<=nbloops; i++) {
108 //st = PR.ReadEntity(IR, PR.Current(), Msg199, STANDARD_TYPE(IGESSolid_Loop), aloop); //szv#4:S4163:12Mar99 moved in if
109 //st = PR.ReadEntity(IR, PR.Current(), "Loops", STANDARD_TYPE(IGESSolid_Loop), aloop);
110 if (PR.ReadEntity(IR, PR.Current(), aStatus, STANDARD_TYPE(IGESSolid_Loop), aloop))
111 tempLoops->SetValue(i, aloop);
113 Message_Msg Msg199("XSTEP_199");
115 case IGESData_ReferenceError: {
116 Message_Msg Msg216 ("IGES_216");
117 Msg199.Arg(Msg216.Value());
120 case IGESData_EntityError: {
121 Message_Msg Msg217 ("IGES_217");
122 Msg199.Arg(Msg217.Value());
125 case IGESData_TypeError: {
126 Message_Msg Msg218 ("IGES_218");
127 Msg199.Arg(Msg218.Value());
136 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
137 ent->Init (tempSurface, outerLoopFlag, tempLoops);
141 //=======================================================================
142 //function : WriteOwnParams
144 //=======================================================================
146 void IGESSolid_ToolFace::WriteOwnParams(const Handle(IGESSolid_Face)& ent,
147 IGESData_IGESWriter& IW) const
149 Standard_Integer upper = ent->NbLoops();
150 IW.Send(ent->Surface());
152 IW.SendBoolean(ent->HasOuterLoop());
153 for (Standard_Integer i = 1; i <= upper; i ++)
154 IW.Send(ent->Loop(i));
158 //=======================================================================
159 //function : OwnShared
161 //=======================================================================
163 void IGESSolid_ToolFace::OwnShared(const Handle(IGESSolid_Face)& ent,
164 Interface_EntityIterator& iter) const
166 Standard_Integer upper = ent->NbLoops();
167 iter.GetOneItem(ent->Surface());
168 for (Standard_Integer i = 1; i <= upper; i ++)
169 iter.GetOneItem(ent->Loop(i));
173 //=======================================================================
176 //=======================================================================
178 void IGESSolid_ToolFace::OwnCopy(const Handle(IGESSolid_Face)& another,
179 const Handle(IGESSolid_Face)& ent,
180 Interface_CopyTool& TC) const
182 DeclareAndCast(IGESData_IGESEntity, tempSurface,
183 TC.Transferred(another->Surface()));
184 Standard_Integer nbloops = another->NbLoops();
185 Standard_Boolean outerLoopFlag = another->HasOuterLoop();
187 Handle(IGESSolid_HArray1OfLoop) tempLoops =
188 new IGESSolid_HArray1OfLoop(1, nbloops);
189 for (Standard_Integer i=1; i<=nbloops; i++)
191 DeclareAndCast(IGESSolid_Loop, anent,
192 TC.Transferred(another->Loop(i)));
193 tempLoops->SetValue(i, anent);
196 ent->Init (tempSurface, outerLoopFlag, tempLoops);
200 //=======================================================================
201 //function : DirChecker
203 //=======================================================================
205 IGESData_DirChecker IGESSolid_ToolFace::DirChecker
206 (const Handle(IGESSolid_Face)& /* ent */ ) const
208 IGESData_DirChecker DC(510, 1);
210 DC.Structure (IGESData_DefVoid);
211 DC.LineFont (IGESData_DefVoid);
212 DC.LineWeight (IGESData_DefVoid);
213 DC.Color (IGESData_DefAny);
215 DC.SubordinateStatusRequired(1);
220 //=======================================================================
221 //function : OwnCheck
223 //=======================================================================
225 void IGESSolid_ToolFace::OwnCheck(const Handle(IGESSolid_Face)& ent,
226 const Interface_ShareTool&,
227 Handle(Interface_Check)& ach) const
230 // Building of messages
231 //========================================
232 //Message_Msg Msg197("XSTEP_197");
233 //========================================
235 if (ent->NbLoops() <= 0) {
236 Message_Msg Msg197("XSTEP_197");
237 ach->SendFail(Msg197);
242 //=======================================================================
245 //=======================================================================
247 void IGESSolid_ToolFace::OwnDump(const Handle(IGESSolid_Face)& ent,
248 const IGESData_IGESDumper& dumper,
250 const Standard_Integer level) const
252 S << "IGESSolid_Face\n";
254 Standard_Integer sublevel = (level <= 4) ? 0 : 1;
256 dumper.Dump(ent->Surface(),S, sublevel);
258 if (ent->HasOuterLoop()) S << "Outer loop is present (First one)\n";
259 else S << "Outer loop is not present\n";
261 IGESData_DumpEntities(S,dumper ,level,1, ent->NbLoops(),ent->Loop);