0022627: Change OCCT memory management defaults
[occt.git] / src / IGESGeom / IGESGeom_ToolBoundedSurface.cxx
CommitLineData
7fd59977 1//--------------------------------------------------------------------
2//
3// File Name : IGESGeom_BoundedSurface.cxx
4// Date :
5// Author : CKY / Contract Toubro-Larsen
6// Copyright : MATRA-DATAVISION 1993
7//
8//--------------------------------------------------------------------
9
10#include <IGESGeom_ToolBoundedSurface.ixx>
11#include <IGESData_ParamCursor.hxx>
12#include <IGESGeom_Boundary.hxx>
13#include <IGESData_IGESEntity.hxx>
14#include <IGESGeom_HArray1OfBoundary.hxx>
15#include <IGESData_Dump.hxx>
16#include <Interface_Macros.hxx>
17
18// MGE 31/07/98
19#include <Message_Msg.hxx>
20#include <IGESData_Status.hxx>
21
22//=======================================================================
23//function : IGESGeom_ToolBoundedSurface
24//purpose :
25//=======================================================================
26
27IGESGeom_ToolBoundedSurface::IGESGeom_ToolBoundedSurface ()
28{
29}
30
31
32//=======================================================================
33//function : ReadOwnParams
34//purpose :
35//=======================================================================
36
37void IGESGeom_ToolBoundedSurface::ReadOwnParams(const Handle(IGESGeom_BoundedSurface)& ent,
38 const Handle(IGESData_IGESReaderData)& IR,
39 IGESData_ParamReader& PR) const
40{
41 // MGE 31/07/98
42
43 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
44 Standard_Integer num, i;
45 Standard_Integer tempType;
46 Handle(IGESData_IGESEntity) tempSurface;
47 Handle(IGESGeom_HArray1OfBoundary) tempBounds;
48 IGESData_Status aStatus;
49
50 //szv#4:S4163:12Mar99 `st=` not needed
51 if (!PR.ReadInteger(PR.Current(), tempType)){
52 Message_Msg Msg165("XTSEP_165");
53 PR.SendFail(Msg165);
54 }
55 if (!PR.ReadEntity(IR, PR.Current(), aStatus, tempSurface)){
56 Message_Msg Msg166("XTSEP_166");
57 switch(aStatus) {
58 case IGESData_ReferenceError: {
59 Message_Msg Msg216 ("IGES_216");
60 Msg166.Arg(Msg216.Value());
61 PR.SendFail(Msg166);
62 break; }
63 case IGESData_EntityError: {
64 Message_Msg Msg217 ("IGES_217");
65 Msg166.Arg(Msg217.Value());
66 PR.SendFail(Msg166);
67 break; }
68 default:{
69 }
70 }
71 }
72 //st = PR.ReadInteger(PR.Current(), Msg167, num); //szv#4:S4163:12Mar99 moved in if
73/*
74 st = PR.ReadInteger(PR.Current(), "Bounded Surface Representation Type", tempType);
75 st = PR.ReadEntity(IR, PR.Current(), "Surface to be Bounded", tempSurface);
76 st = PR.ReadInteger(PR.Current(), "Number Of Boundary Entities", num);
77*/
78
79 //szv#4:S4163:12Mar99 optimized
80 //if (st && num > 0) tempBounds = new IGESGeom_HArray1OfBoundary(1, num);
81 //if (st && num <= 0) PR.SendFail(Msg167);
82 if (PR.ReadInteger(PR.Current(), num) && (num > 0)) {
83 tempBounds = new IGESGeom_HArray1OfBoundary(1, num);
84 }
85 else{
86 Message_Msg Msg167("XTSEP_167");
87 PR.SendFail(Msg167);
88 }
89
90 if (!tempBounds.IsNull()){
91 for ( i = 1; i <= num; i++ )
92 {
93 Handle(IGESGeom_Boundary) tempEnt;
94 //st = PR.ReadEntity(IR, PR.Current(), Msg168, tempEnt); //szv#4:S4163:12Mar99 moved in if
95 //st = PR.ReadEntity(IR, PR.Current(), "Boundary Entities", tempEnt);
96 if (PR.ReadEntity(IR, PR.Current(), aStatus, tempEnt))
97 tempBounds->SetValue(i, tempEnt);
98 else{
99 Message_Msg Msg168("XTSEP_168");
100 switch(aStatus) {
101 case IGESData_ReferenceError: {
102 Message_Msg Msg216 ("IGES_216");
103 Msg168.Arg(Msg216.Value());
104 PR.SendFail(Msg168);
105 break; }
106 case IGESData_EntityError: {
107 Message_Msg Msg217 ("IGES_217");
108 Msg168.Arg(Msg217.Value());
109 PR.SendFail(Msg168);
110 break; }
111 default:{
112 }
113 }
114 }
115 }
116 }
117 //sln 28.09.2001, BUC61004, If(tempBounds.IsNull()) function ent->Init is not called in order to avoid exception
118 if(!tempBounds.IsNull())
119 {
120 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
121 ent->Init(tempType, tempSurface, tempBounds);
122 }
123}
124
125
126//=======================================================================
127//function : WriteOwnParams
128//purpose :
129//=======================================================================
130
131void IGESGeom_ToolBoundedSurface::WriteOwnParams(const Handle(IGESGeom_BoundedSurface)& ent,
132 IGESData_IGESWriter& IW) const
133{
134 Standard_Integer i, num;
135 IW.Send(ent->RepresentationType());
136 IW.Send(ent->Surface());
137 IW.Send(ent->NbBoundaries());
138 for ( num = ent->NbBoundaries(), i = 1; i <= num; i++ )
139 IW.Send(ent->Boundary(i));
140}
141
142
143//=======================================================================
144//function : OwnShared
145//purpose :
146//=======================================================================
147
148void IGESGeom_ToolBoundedSurface::OwnShared(const Handle(IGESGeom_BoundedSurface)& ent,
149 Interface_EntityIterator& iter) const
150{
151 Standard_Integer i, num;
152 iter.GetOneItem(ent->Surface());
153 for ( num = ent->NbBoundaries(), i = 1; i <= num; i++ )
154 iter.GetOneItem(ent->Boundary(i));
155}
156
157
158//=======================================================================
159//function : OwnCopy
160//purpose :
161//=======================================================================
162
163void IGESGeom_ToolBoundedSurface::OwnCopy(const Handle(IGESGeom_BoundedSurface)& another,
164 const Handle(IGESGeom_BoundedSurface)& ent,
165 Interface_CopyTool& TC) const
166{
167 Standard_Integer i, num;
168
169 Standard_Integer tempType = another->RepresentationType();
170 DeclareAndCast(IGESData_IGESEntity, tempSurface,
171 TC.Transferred(another->Surface()));
172 num = another->NbBoundaries();
173 Handle(IGESGeom_HArray1OfBoundary) tempBounds;
174 if (num > 0) tempBounds = new IGESGeom_HArray1OfBoundary(1, num);
175 for (i = 1; i <= num; i++)
176 {
177 DeclareAndCast(IGESGeom_Boundary, tempBoundary,
178 TC.Transferred(another->Boundary(i)));
179 tempBounds->SetValue(i, tempBoundary);
180 }
181 ent->Init(tempType, tempSurface, tempBounds);
182}
183
184
185//=======================================================================
186//function : DirChecker
187//purpose :
188//=======================================================================
189
190IGESData_DirChecker IGESGeom_ToolBoundedSurface::DirChecker
191 (const Handle(IGESGeom_BoundedSurface)& /* ent */ ) const
192{
193 IGESData_DirChecker DC(143,0);
194 DC.Structure(IGESData_DefVoid);
195 DC.GraphicsIgnored();
196 DC.LineFont(IGESData_DefAny);
197// DC.LineWeight(IGESData_DefValue);
198 DC.Color(IGESData_DefAny);
199 DC.UseFlagRequired(0);
200 DC.HierarchyStatusIgnored();
201 return DC;
202}
203
204
205//=======================================================================
206//function : OwnCheck
207//purpose :
208//=======================================================================
209
210void IGESGeom_ToolBoundedSurface::OwnCheck(const Handle(IGESGeom_BoundedSurface)& ent,
211 const Interface_ShareTool&,
212 Handle(Interface_Check)& ach) const
213{
214 // MGE 31/07/98
215 // Building of messages
216 //========================================
217 //Message_Msg Msg165("XTSEP_165");
218 //========================================
219
220 if ((ent->RepresentationType() != 0) && (ent->RepresentationType() != 1)) {
221 Message_Msg Msg165("XTSEP_165");
222 ach->SendFail(Msg165);
223 }
224}
225
226
227//=======================================================================
228//function : OwnDump
229//purpose :
230//=======================================================================
231
232void IGESGeom_ToolBoundedSurface::OwnDump(const Handle(IGESGeom_BoundedSurface)& ent,
233 const IGESData_IGESDumper& dumper,
234 const Handle(Message_Messenger)& S,
235 const Standard_Integer level) const
236{
237 Standard_Integer sublevel = (level > 4) ? 1 : 0;
238 S << "IGESGeom_BoundedSurface" << endl;
239 S << "Representation Type : " << ent->RepresentationType() << endl;
240 S << "Surface to be Bounded : ";
241 dumper.Dump(ent->Surface(),S, sublevel);
242 S << endl;
243 S << "Boundary Entities : ";
244 IGESData_DumpEntities(S,dumper ,level,1, ent->NbBoundaries(),ent->Boundary);
245 S << endl;
246}