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_ParamCursor.hxx>
25 #include <IGESData_ParamReader.hxx>
26 #include <IGESData_Status.hxx>
27 #include <IGESSolid.hxx>
28 #include <IGESSolid_Face.hxx>
29 #include <IGESSolid_HArray1OfFace.hxx>
30 #include <IGESSolid_Shell.hxx>
31 #include <IGESSolid_ToolShell.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>
40 #include <TColStd_HArray1OfInteger.hxx>
43 //=======================================================================
44 //function : IGESSolid_ToolShell
46 //=======================================================================
47 IGESSolid_ToolShell::IGESSolid_ToolShell ()
52 //=======================================================================
53 //function : ReadOwnParams
55 //=======================================================================
57 void IGESSolid_ToolShell::ReadOwnParams(const Handle(IGESSolid_Shell)& ent,
58 const Handle(IGESData_IGESReaderData)& IR,
59 IGESData_ParamReader& PR) const
64 //Standard_Boolean abool; //szv#4:S4163:12Mar99 moved down
65 Standard_Integer nbfaces=0; //szv#4:S4163:12Mar99 `i` moved in for
66 //Handle(IGESSolid_Face) aface; //szv#4:S4163:12Mar99 moved down
67 Handle(IGESSolid_HArray1OfFace) tempFaces;
68 Handle(TColStd_HArray1OfInteger) tempOrientation;
70 //st = PR.ReadInteger(PR.Current(), Msg200, nbfaces); //szv#4:S4163:12Mar99 moved in if
71 //st = PR.ReadInteger(PR.Current(), "Number of faces", nbfaces);
72 Standard_Boolean sb = PR.ReadInteger(PR.Current(), nbfaces);
73 if (sb && nbfaces > 0 ) {
74 Message_Msg Msg180("XSTEP_180");
76 Standard_Boolean abool;
77 Handle(IGESSolid_Face) aface;
78 tempFaces = new IGESSolid_HArray1OfFace(1, nbfaces);
79 tempOrientation = new TColStd_HArray1OfInteger(1, nbfaces);
80 IGESData_Status aStatus;
81 for (Standard_Integer i=1; i<=nbfaces; i++) {
82 //st = PR.ReadEntity(IR, PR.Current(),Msg201, STANDARD_TYPE(IGESSolid_Face), aface); //szv#4:S4163:12Mar99 moved in if
83 //st = PR.ReadEntity(IR, PR.Current(), "Faces", STANDARD_TYPE(IGESSolid_Face), aface);
84 if (PR.ReadEntity(IR, PR.Current(),aStatus, STANDARD_TYPE(IGESSolid_Face), aface))
85 tempFaces->SetValue(i, aface);
87 Message_Msg Msg201("XSTEP_201");
89 case IGESData_ReferenceError: {
90 Message_Msg Msg216 ("IGES_216");
91 Msg201.Arg(Msg216.Value());
94 case IGESData_EntityError: {
95 Message_Msg Msg217 ("IGES_217");
96 Msg201.Arg(Msg217.Value());
99 case IGESData_TypeError: {
100 Message_Msg Msg218 ("IGES_218");
101 Msg201.Arg(Msg218.Value());
108 //st = PR.ReadBoolean(PR.Current(), Msg180, abool); //szv#4:S4163:12Mar99 moved in if
109 //st = PR.ReadBoolean(PR.Current(), "Orientation flags", abool);
110 if (PR.ReadBoolean(PR.Current(), Msg180, abool))
111 tempOrientation->SetValue(i, (abool ? 1 : 0) );
115 Message_Msg Msg200("XSTEP_200");
119 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
120 ent->Init (tempFaces, tempOrientation);
124 //=======================================================================
125 //function : WriteOwnParams
127 //=======================================================================
129 void IGESSolid_ToolShell::WriteOwnParams(const Handle(IGESSolid_Shell)& ent,
130 IGESData_IGESWriter& IW) const
132 Standard_Integer i, nbfaces = ent->NbFaces();
135 for (i = 1; i <= nbfaces; i ++)
137 IW.Send(ent->Face(i));
138 IW.SendBoolean(ent->Orientation(i));
143 //=======================================================================
144 //function : OwnShared
146 //=======================================================================
148 void IGESSolid_ToolShell::OwnShared(const Handle(IGESSolid_Shell)& ent,
149 Interface_EntityIterator& iter) const
151 Standard_Integer nbfaces = ent->NbFaces();
152 for (Standard_Integer i = 1; i <= nbfaces; i ++)
153 iter.GetOneItem(ent->Face(i));
157 //=======================================================================
160 //=======================================================================
162 void IGESSolid_ToolShell::OwnCopy(const Handle(IGESSolid_Shell)& another,
163 const Handle(IGESSolid_Shell)& ent,
164 Interface_CopyTool& TC) const
166 Standard_Integer nbfaces = another->NbFaces();
168 Handle(IGESSolid_HArray1OfFace) tempFaces = new
169 IGESSolid_HArray1OfFace(1, nbfaces);
170 Handle(TColStd_HArray1OfInteger) tempOrientation = new
171 TColStd_HArray1OfInteger(1, nbfaces);
172 for (Standard_Integer i=1; i<=nbfaces; i++)
174 DeclareAndCast(IGESSolid_Face, face,
175 TC.Transferred(another->Face(i)));
176 tempFaces->SetValue(i, face);
177 tempOrientation->SetValue(i, (another->Orientation(i) ? 1 : 0) );
179 ent->Init (tempFaces, tempOrientation);
183 //=======================================================================
184 //function : DirChecker
186 //=======================================================================
188 IGESData_DirChecker IGESSolid_ToolShell::DirChecker
189 (const Handle(IGESSolid_Shell)& /* ent */ ) const
191 IGESData_DirChecker DC(514, 1,2);
193 DC.Structure (IGESData_DefVoid);
194 DC.LineFont (IGESData_DefVoid);
195 DC.LineWeight (IGESData_DefVoid);
196 DC.Color (IGESData_DefVoid);
198 DC.SubordinateStatusRequired(1);
203 //=======================================================================
204 //function : OwnCheck
206 //=======================================================================
208 void IGESSolid_ToolShell::OwnCheck(const Handle(IGESSolid_Shell)& ent,
209 const Interface_ShareTool&,
210 Handle(Interface_Check)& ach) const
213 // Building of messages
214 //========================================
215 //Message_Msg Msg200("XSTEP_200");
216 //========================================
218 if (ent->NbFaces() <= 0) {
219 Message_Msg Msg200("XSTEP_200");
220 ach->SendFail(Msg200);
225 //=======================================================================
228 //=======================================================================
230 void IGESSolid_ToolShell::OwnDump(const Handle(IGESSolid_Shell)& ent,
231 const IGESData_IGESDumper& dumper,
233 const Standard_Integer level) const
235 S << "IGESSolid_Shell\n";
236 Standard_Integer upper = ent->NbFaces();
237 Standard_Integer sublevel = (level <= 4) ? 0 : 1;
239 S << "Faces :\nOrientation flags : ";
240 IGESData_DumpEntities(S,dumper,-level,1, ent->NbFaces(),ent->Face);
245 for (Standard_Integer i = 1; i <= upper; i ++)
247 S << "[" << i << "]: "
249 dumper.Dump (ent->Face(i),S, sublevel);
250 S << " - Orientation flag : ";
251 if (ent->Orientation(i)) S << "True\n";