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