b311480e |
1 | // Created by: CKY / Contract Toubro-Larsen |
2 | // Copyright (c) 1993-1999 Matra Datavision |
973c2be1 |
3 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
7fd59977 |
6 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
7fd59977 |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
b311480e |
15 | |
16 | //-------------------------------------------------------------------- |
7fd59977 |
17 | //-------------------------------------------------------------------- |
18 | |
42cf5bc1 |
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> |
7fd59977 |
25 | #include <IGESData_ParamCursor.hxx> |
42cf5bc1 |
26 | #include <IGESData_ParamReader.hxx> |
27 | #include <IGESData_Status.hxx> |
7fd59977 |
28 | #include <IGESGeom_Boundary.hxx> |
42cf5bc1 |
29 | #include <IGESGeom_BoundedSurface.hxx> |
7fd59977 |
30 | #include <IGESGeom_HArray1OfBoundary.hxx> |
42cf5bc1 |
31 | #include <IGESGeom_ToolBoundedSurface.hxx> |
32 | #include <Interface_Check.hxx> |
33 | #include <Interface_CopyTool.hxx> |
34 | #include <Interface_EntityIterator.hxx> |
7fd59977 |
35 | #include <Interface_Macros.hxx> |
42cf5bc1 |
36 | #include <Interface_ShareTool.hxx> |
37 | #include <Message_Messenger.hxx> |
7fd59977 |
38 | #include <Message_Msg.hxx> |
42cf5bc1 |
39 | #include <Standard_DomainError.hxx> |
7fd59977 |
40 | |
42cf5bc1 |
41 | // MGE 31/07/98 |
7fd59977 |
42 | //======================================================================= |
43 | //function : IGESGeom_ToolBoundedSurface |
44 | //purpose : |
45 | //======================================================================= |
7fd59977 |
46 | IGESGeom_ToolBoundedSurface::IGESGeom_ToolBoundedSurface () |
47 | { |
48 | } |
49 | |
50 | |
51 | //======================================================================= |
52 | //function : ReadOwnParams |
53 | //purpose : |
54 | //======================================================================= |
55 | |
56 | void IGESGeom_ToolBoundedSurface::ReadOwnParams(const Handle(IGESGeom_BoundedSurface)& ent, |
57 | const Handle(IGESData_IGESReaderData)& IR, |
58 | IGESData_ParamReader& PR) const |
59 | { |
60 | // MGE 31/07/98 |
61 | |
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; |
68 | |
69 | //szv#4:S4163:12Mar99 `st=` not needed |
70 | if (!PR.ReadInteger(PR.Current(), tempType)){ |
71 | Message_Msg Msg165("XTSEP_165"); |
72 | PR.SendFail(Msg165); |
73 | } |
74 | if (!PR.ReadEntity(IR, PR.Current(), aStatus, tempSurface)){ |
75 | Message_Msg Msg166("XTSEP_166"); |
76 | switch(aStatus) { |
77 | case IGESData_ReferenceError: { |
78 | Message_Msg Msg216 ("IGES_216"); |
79 | Msg166.Arg(Msg216.Value()); |
80 | PR.SendFail(Msg166); |
81 | break; } |
82 | case IGESData_EntityError: { |
83 | Message_Msg Msg217 ("IGES_217"); |
84 | Msg166.Arg(Msg217.Value()); |
85 | PR.SendFail(Msg166); |
86 | break; } |
87 | default:{ |
88 | } |
89 | } |
90 | } |
91 | //st = PR.ReadInteger(PR.Current(), Msg167, num); //szv#4:S4163:12Mar99 moved in if |
92 | /* |
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); |
96 | */ |
97 | |
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); |
103 | } |
104 | else{ |
105 | Message_Msg Msg167("XTSEP_167"); |
106 | PR.SendFail(Msg167); |
107 | } |
108 | |
109 | if (!tempBounds.IsNull()){ |
110 | for ( i = 1; i <= num; i++ ) |
111 | { |
aa00364d |
112 | Handle(IGESData_IGESEntity) tempEnt; |
7fd59977 |
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)) |
aa00364d |
116 | tempBounds->SetValue(i, Handle(IGESGeom_Boundary)::DownCast (tempEnt)); |
7fd59977 |
117 | else{ |
118 | Message_Msg Msg168("XTSEP_168"); |
119 | switch(aStatus) { |
120 | case IGESData_ReferenceError: { |
121 | Message_Msg Msg216 ("IGES_216"); |
122 | Msg168.Arg(Msg216.Value()); |
123 | PR.SendFail(Msg168); |
124 | break; } |
125 | case IGESData_EntityError: { |
126 | Message_Msg Msg217 ("IGES_217"); |
127 | Msg168.Arg(Msg217.Value()); |
128 | PR.SendFail(Msg168); |
129 | break; } |
130 | default:{ |
131 | } |
132 | } |
133 | } |
134 | } |
135 | } |
136 | //sln 28.09.2001, BUC61004, If(tempBounds.IsNull()) function ent->Init is not called in order to avoid exception |
137 | if(!tempBounds.IsNull()) |
138 | { |
139 | DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent); |
140 | ent->Init(tempType, tempSurface, tempBounds); |
141 | } |
142 | } |
143 | |
144 | |
145 | //======================================================================= |
146 | //function : WriteOwnParams |
147 | //purpose : |
148 | //======================================================================= |
149 | |
150 | void IGESGeom_ToolBoundedSurface::WriteOwnParams(const Handle(IGESGeom_BoundedSurface)& ent, |
151 | IGESData_IGESWriter& IW) const |
152 | { |
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)); |
159 | } |
160 | |
161 | |
162 | //======================================================================= |
163 | //function : OwnShared |
164 | //purpose : |
165 | //======================================================================= |
166 | |
167 | void IGESGeom_ToolBoundedSurface::OwnShared(const Handle(IGESGeom_BoundedSurface)& ent, |
168 | Interface_EntityIterator& iter) const |
169 | { |
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)); |
174 | } |
175 | |
176 | |
177 | //======================================================================= |
178 | //function : OwnCopy |
179 | //purpose : |
180 | //======================================================================= |
181 | |
182 | void IGESGeom_ToolBoundedSurface::OwnCopy(const Handle(IGESGeom_BoundedSurface)& another, |
183 | const Handle(IGESGeom_BoundedSurface)& ent, |
184 | Interface_CopyTool& TC) const |
185 | { |
186 | Standard_Integer i, num; |
187 | |
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++) |
195 | { |
196 | DeclareAndCast(IGESGeom_Boundary, tempBoundary, |
197 | TC.Transferred(another->Boundary(i))); |
198 | tempBounds->SetValue(i, tempBoundary); |
199 | } |
200 | ent->Init(tempType, tempSurface, tempBounds); |
201 | } |
202 | |
203 | |
204 | //======================================================================= |
205 | //function : DirChecker |
206 | //purpose : |
207 | //======================================================================= |
208 | |
209 | IGESData_DirChecker IGESGeom_ToolBoundedSurface::DirChecker |
210 | (const Handle(IGESGeom_BoundedSurface)& /* ent */ ) const |
211 | { |
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(); |
220 | return DC; |
221 | } |
222 | |
223 | |
224 | //======================================================================= |
225 | //function : OwnCheck |
226 | //purpose : |
227 | //======================================================================= |
228 | |
229 | void IGESGeom_ToolBoundedSurface::OwnCheck(const Handle(IGESGeom_BoundedSurface)& ent, |
230 | const Interface_ShareTool&, |
231 | Handle(Interface_Check)& ach) const |
232 | { |
233 | // MGE 31/07/98 |
234 | // Building of messages |
235 | //======================================== |
236 | //Message_Msg Msg165("XTSEP_165"); |
237 | //======================================== |
238 | |
239 | if ((ent->RepresentationType() != 0) && (ent->RepresentationType() != 1)) { |
240 | Message_Msg Msg165("XTSEP_165"); |
241 | ach->SendFail(Msg165); |
242 | } |
243 | } |
244 | |
245 | |
246 | //======================================================================= |
247 | //function : OwnDump |
248 | //purpose : |
249 | //======================================================================= |
250 | |
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 |
255 | { |
256 | Standard_Integer sublevel = (level > 4) ? 1 : 0; |
257 | S << "IGESGeom_BoundedSurface" << endl; |
258 | S << "Representation Type : " << ent->RepresentationType() << endl; |
259 | S << "Surface to be Bounded : "; |
260 | dumper.Dump(ent->Surface(),S, sublevel); |
261 | S << endl; |
262 | S << "Boundary Entities : "; |
263 | IGESData_DumpEntities(S,dumper ,level,1, ent->NbBoundaries(),ent->Boundary); |
264 | S << endl; |
265 | } |