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 <IGESGeom_Boundary.hxx>
29 #include <IGESGeom_BoundedSurface.hxx>
30 #include <IGESGeom_HArray1OfBoundary.hxx>
31 #include <IGESGeom_ToolBoundedSurface.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 : IGESGeom_ToolBoundedSurface
45 //=======================================================================
46 IGESGeom_ToolBoundedSurface::IGESGeom_ToolBoundedSurface ()
51 //=======================================================================
52 //function : ReadOwnParams
54 //=======================================================================
56 void IGESGeom_ToolBoundedSurface::ReadOwnParams(const Handle(IGESGeom_BoundedSurface)& ent,
57 const Handle(IGESData_IGESReaderData)& IR,
58 IGESData_ParamReader& PR) const
62 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
63 Standard_Integer num, i;
64 Standard_Integer tempType;
65 Handle(IGESData_IGESEntity) tempSurface;
66 Handle(IGESGeom_HArray1OfBoundary) tempBounds;
67 IGESData_Status aStatus;
69 //szv#4:S4163:12Mar99 `st=` not needed
70 if (!PR.ReadInteger(PR.Current(), tempType)){
71 Message_Msg Msg165("XTSEP_165");
74 if (!PR.ReadEntity(IR, PR.Current(), aStatus, tempSurface)){
75 Message_Msg Msg166("XTSEP_166");
77 case IGESData_ReferenceError: {
78 Message_Msg Msg216 ("IGES_216");
79 Msg166.Arg(Msg216.Value());
82 case IGESData_EntityError: {
83 Message_Msg Msg217 ("IGES_217");
84 Msg166.Arg(Msg217.Value());
91 //st = PR.ReadInteger(PR.Current(), Msg167, num); //szv#4:S4163:12Mar99 moved in if
93 st = PR.ReadInteger(PR.Current(), "Bounded Surface Representation Type", tempType);
94 st = PR.ReadEntity(IR, PR.Current(), "Surface to be Bounded", tempSurface);
95 st = PR.ReadInteger(PR.Current(), "Number Of Boundary Entities", num);
98 //szv#4:S4163:12Mar99 optimized
99 //if (st && num > 0) tempBounds = new IGESGeom_HArray1OfBoundary(1, num);
100 //if (st && num <= 0) PR.SendFail(Msg167);
101 if (PR.ReadInteger(PR.Current(), num) && (num > 0)) {
102 tempBounds = new IGESGeom_HArray1OfBoundary(1, num);
105 Message_Msg Msg167("XTSEP_167");
109 if (!tempBounds.IsNull()){
110 for ( i = 1; i <= num; i++ )
112 Handle(IGESData_IGESEntity) tempEnt;
113 //st = PR.ReadEntity(IR, PR.Current(), Msg168, tempEnt); //szv#4:S4163:12Mar99 moved in if
114 //st = PR.ReadEntity(IR, PR.Current(), "Boundary Entities", tempEnt);
115 if (PR.ReadEntity(IR, PR.Current(), aStatus, tempEnt))
116 tempBounds->SetValue(i, Handle(IGESGeom_Boundary)::DownCast (tempEnt));
118 Message_Msg Msg168("XTSEP_168");
120 case IGESData_ReferenceError: {
121 Message_Msg Msg216 ("IGES_216");
122 Msg168.Arg(Msg216.Value());
125 case IGESData_EntityError: {
126 Message_Msg Msg217 ("IGES_217");
127 Msg168.Arg(Msg217.Value());
136 //sln 28.09.2001, BUC61004, If(tempBounds.IsNull()) function ent->Init is not called in order to avoid exception
137 if(!tempBounds.IsNull())
139 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
140 ent->Init(tempType, tempSurface, tempBounds);
145 //=======================================================================
146 //function : WriteOwnParams
148 //=======================================================================
150 void IGESGeom_ToolBoundedSurface::WriteOwnParams(const Handle(IGESGeom_BoundedSurface)& ent,
151 IGESData_IGESWriter& IW) const
153 Standard_Integer i, num;
154 IW.Send(ent->RepresentationType());
155 IW.Send(ent->Surface());
156 IW.Send(ent->NbBoundaries());
157 for ( num = ent->NbBoundaries(), i = 1; i <= num; i++ )
158 IW.Send(ent->Boundary(i));
162 //=======================================================================
163 //function : OwnShared
165 //=======================================================================
167 void IGESGeom_ToolBoundedSurface::OwnShared(const Handle(IGESGeom_BoundedSurface)& ent,
168 Interface_EntityIterator& iter) const
170 Standard_Integer i, num;
171 iter.GetOneItem(ent->Surface());
172 for ( num = ent->NbBoundaries(), i = 1; i <= num; i++ )
173 iter.GetOneItem(ent->Boundary(i));
177 //=======================================================================
180 //=======================================================================
182 void IGESGeom_ToolBoundedSurface::OwnCopy(const Handle(IGESGeom_BoundedSurface)& another,
183 const Handle(IGESGeom_BoundedSurface)& ent,
184 Interface_CopyTool& TC) const
186 Standard_Integer i, num;
188 Standard_Integer tempType = another->RepresentationType();
189 DeclareAndCast(IGESData_IGESEntity, tempSurface,
190 TC.Transferred(another->Surface()));
191 num = another->NbBoundaries();
192 Handle(IGESGeom_HArray1OfBoundary) tempBounds;
193 if (num > 0) tempBounds = new IGESGeom_HArray1OfBoundary(1, num);
194 for (i = 1; i <= num; i++)
196 DeclareAndCast(IGESGeom_Boundary, tempBoundary,
197 TC.Transferred(another->Boundary(i)));
198 tempBounds->SetValue(i, tempBoundary);
200 ent->Init(tempType, tempSurface, tempBounds);
204 //=======================================================================
205 //function : DirChecker
207 //=======================================================================
209 IGESData_DirChecker IGESGeom_ToolBoundedSurface::DirChecker
210 (const Handle(IGESGeom_BoundedSurface)& /* ent */ ) const
212 IGESData_DirChecker DC(143,0);
213 DC.Structure(IGESData_DefVoid);
214 DC.GraphicsIgnored();
215 DC.LineFont(IGESData_DefAny);
216 // DC.LineWeight(IGESData_DefValue);
217 DC.Color(IGESData_DefAny);
218 DC.UseFlagRequired(0);
219 DC.HierarchyStatusIgnored();
224 //=======================================================================
225 //function : OwnCheck
227 //=======================================================================
229 void IGESGeom_ToolBoundedSurface::OwnCheck(const Handle(IGESGeom_BoundedSurface)& ent,
230 const Interface_ShareTool&,
231 Handle(Interface_Check)& ach) const
234 // Building of messages
235 //========================================
236 //Message_Msg Msg165("XTSEP_165");
237 //========================================
239 if ((ent->RepresentationType() != 0) && (ent->RepresentationType() != 1)) {
240 Message_Msg Msg165("XTSEP_165");
241 ach->SendFail(Msg165);
246 //=======================================================================
249 //=======================================================================
251 void IGESGeom_ToolBoundedSurface::OwnDump(const Handle(IGESGeom_BoundedSurface)& ent,
252 const IGESData_IGESDumper& dumper,
253 const Handle(Message_Messenger)& S,
254 const Standard_Integer level) const
256 Standard_Integer sublevel = (level > 4) ? 1 : 0;
257 S << "IGESGeom_BoundedSurface" << Message_EndLine;
258 S << "Representation Type : " << ent->RepresentationType() << Message_EndLine;
259 S << "Surface to be Bounded : ";
260 dumper.Dump(ent->Surface(),S, sublevel);
261 S << Message_EndLine;
262 S << "Boundary Entities : ";
263 IGESData_DumpEntities(S,dumper ,level,1, ent->NbBoundaries(),ent->Boundary);
264 S << Message_EndLine;