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_IGESDumper.hxx> |
7fd59977 |
21 | #include <IGESData_IGESEntity.hxx> |
42cf5bc1 |
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 <IGESGeom_CurveOnSurface.hxx> |
28 | #include <IGESGeom_ToolCurveOnSurface.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> |
42cf5bc1 |
36 | #include <Standard_DomainError.hxx> |
7fd59977 |
37 | |
42cf5bc1 |
38 | // MGE 30/07/98 |
7fd59977 |
39 | //======================================================================= |
40 | //function : IGESGeom_ToolCurveOnSurface |
41 | //purpose : |
42 | //======================================================================= |
7fd59977 |
43 | IGESGeom_ToolCurveOnSurface::IGESGeom_ToolCurveOnSurface () |
44 | { |
45 | } |
46 | |
47 | |
48 | //======================================================================= |
49 | //function : ReadOwnParams |
50 | //purpose : |
51 | //======================================================================= |
52 | |
53 | void IGESGeom_ToolCurveOnSurface::ReadOwnParams |
54 | (const Handle(IGESGeom_CurveOnSurface)& ent, |
55 | const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const |
56 | { |
57 | |
58 | // MGE 30/07/98 |
59 | |
60 | Standard_Integer aMode, aPreference; |
61 | Handle(IGESData_IGESEntity) aSurface; |
62 | Handle(IGESData_IGESEntity) aCurveUV; |
63 | Handle(IGESData_IGESEntity) aCurve3D; |
64 | IGESData_Status aStatus; |
65 | |
66 | //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed |
67 | |
68 | if (!PR.ReadInteger(PR.Current(), aMode)){ //szv#4:S4163:12Mar99 `st=` not needed |
69 | Message_Msg Msg276("XSTEP_276"); |
70 | PR.SendFail(Msg276); |
71 | } |
72 | if (!PR.ReadEntity(IR, PR.Current(),aStatus, aSurface)){ |
73 | Message_Msg Msg131("XSTEP_131"); |
74 | switch(aStatus) { |
75 | case IGESData_ReferenceError: { |
76 | Message_Msg Msg216 ("IGES_216"); |
77 | Msg131.Arg(Msg216.Value()); |
78 | PR.SendFail(Msg131); |
79 | break; } |
80 | case IGESData_EntityError: { |
81 | Message_Msg Msg217 ("IGES_217"); |
82 | Msg131.Arg(Msg217.Value()); |
83 | PR.SendFail(Msg131); |
84 | break; } |
85 | default:{ |
86 | } |
87 | } |
88 | } //szv#4:S4163:12Mar99 `st=` not needed |
89 | |
90 | if (!PR.ReadEntity(IR, PR.Current(), aStatus, aCurveUV, Standard_True)){ |
91 | Message_Msg Msg132("XSTEP_132"); |
92 | switch(aStatus) { |
93 | case IGESData_ReferenceError: { |
94 | Message_Msg Msg216 ("IGES_216"); |
95 | Msg132.Arg(Msg216.Value()); |
96 | PR.SendFail(Msg132); |
97 | break; } |
98 | case IGESData_EntityError: { |
99 | Message_Msg Msg217 ("IGES_217"); |
100 | Msg132.Arg(Msg217.Value()); |
101 | PR.SendFail(Msg132); |
102 | break; } |
103 | default:{ |
104 | } |
105 | } |
106 | } //szv#4:S4163:12Mar99 `st=` not needed |
107 | if (!PR.ReadEntity(IR, PR.Current(), aStatus, aCurve3D, Standard_True)){; //szv#4:S4163:12Mar99 `st=` not needed |
108 | Message_Msg Msg133("XSTEP_133"); |
109 | switch(aStatus) { |
110 | case IGESData_ReferenceError: { |
111 | Message_Msg Msg216 ("IGES_216"); |
112 | Msg133.Arg(Msg216.Value()); |
113 | PR.SendFail(Msg133); |
114 | break; } |
115 | case IGESData_EntityError: { |
116 | Message_Msg Msg217 ("IGES_217"); |
117 | Msg133.Arg(Msg217.Value()); |
118 | PR.SendFail(Msg133); |
119 | break; } |
120 | default:{ |
121 | } |
122 | } |
123 | } |
124 | if (!PR.ReadInteger(PR.Current(), aPreference)){ //szv#4:S4163:12Mar99 `st=` not needed |
125 | Message_Msg Msg277("XSTEP_277"); |
126 | PR.SendFail(Msg277); |
127 | } |
128 | /* |
129 | st = PR.ReadInteger(PR.Current(), "Creation mode of curve", aMode); |
130 | st = PR.ReadEntity(IR, PR.Current(), "Surface (on which curve lies)", aSurface); |
131 | st = PR.ReadEntity(IR, PR.Current(), "Curve UV", aCurveUV, Standard_True); |
132 | st = PR.ReadEntity(IR, PR.Current(), "Curve 3D", aCurve3D, Standard_True); |
133 | st = PR.ReadInteger(PR.Current(), "Preferred representation", aPreference); |
134 | */ |
135 | DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent); |
136 | ent->Init |
137 | (aMode, aSurface, aCurveUV, aCurve3D, aPreference); |
138 | } |
139 | |
140 | |
141 | //======================================================================= |
142 | //function : WriteOwnParams |
143 | //purpose : |
144 | //======================================================================= |
145 | |
146 | void IGESGeom_ToolCurveOnSurface::WriteOwnParams |
147 | (const Handle(IGESGeom_CurveOnSurface)& ent, IGESData_IGESWriter& IW) const |
148 | { |
149 | IW.Send(ent->CreationMode()); |
150 | IW.Send(ent->Surface()); |
151 | IW.Send(ent->CurveUV()); |
152 | IW.Send(ent->Curve3D()); |
153 | IW.Send(ent->PreferenceMode()); |
154 | } |
155 | |
156 | |
157 | //======================================================================= |
158 | //function : OwnShared |
159 | //purpose : |
160 | //======================================================================= |
161 | |
162 | void IGESGeom_ToolCurveOnSurface::OwnShared(const Handle(IGESGeom_CurveOnSurface)& ent, |
163 | Interface_EntityIterator& iter) const |
164 | { |
165 | iter.GetOneItem(ent->Surface()); |
166 | iter.GetOneItem(ent->CurveUV()); |
167 | iter.GetOneItem(ent->Curve3D()); |
168 | } |
169 | |
170 | |
171 | //======================================================================= |
172 | //function : OwnCopy |
173 | //purpose : |
174 | //======================================================================= |
175 | |
176 | void IGESGeom_ToolCurveOnSurface::OwnCopy(const Handle(IGESGeom_CurveOnSurface)& another, |
177 | const Handle(IGESGeom_CurveOnSurface)& ent, |
178 | Interface_CopyTool& TC) const |
179 | { |
180 | DeclareAndCast(IGESData_IGESEntity, aSurface, TC.Transferred(another->Surface())); |
181 | DeclareAndCast(IGESData_IGESEntity, aCurveUV, TC.Transferred(another->CurveUV())); |
182 | DeclareAndCast(IGESData_IGESEntity, aCurve3D, TC.Transferred(another->Curve3D())); |
183 | |
184 | Standard_Integer aMode = another->CreationMode(); |
185 | Standard_Integer aPreference = another->PreferenceMode(); |
186 | |
187 | ent->Init(aMode, aSurface, aCurveUV, aCurve3D, aPreference); |
188 | } |
189 | |
190 | |
191 | //======================================================================= |
192 | //function : OwnCorrect |
193 | //purpose : |
194 | //======================================================================= |
195 | |
196 | Standard_Boolean IGESGeom_ToolCurveOnSurface::OwnCorrect |
197 | (const Handle(IGESGeom_CurveOnSurface)& ent) const |
198 | { |
199 | Handle(IGESData_IGESEntity) c2d = ent->CurveUV(); |
200 | if (c2d.IsNull()) return Standard_False; |
201 | Standard_Integer uf = c2d->UseFlag(); |
202 | if (uf == 5) return Standard_False; |
203 | c2d->InitStatus |
204 | (c2d->BlankStatus(),c2d->SubordinateStatus(),5,c2d->HierarchyStatus()); |
205 | return Standard_True; |
206 | } |
207 | |
208 | |
209 | //======================================================================= |
210 | //function : DirChecker |
211 | //purpose : |
212 | //======================================================================= |
213 | |
214 | IGESData_DirChecker IGESGeom_ToolCurveOnSurface::DirChecker |
215 | (const Handle(IGESGeom_CurveOnSurface)& /* ent */ ) const |
216 | { |
217 | IGESData_DirChecker DC(142, 0); |
218 | DC.Structure(IGESData_DefVoid); |
219 | DC.LineFont(IGESData_DefAny); |
220 | // DC.LineWeight(IGESData_DefValue); |
221 | DC.Color(IGESData_DefAny); |
222 | |
223 | DC.UseFlagRequired (5); |
224 | DC.HierarchyStatusIgnored (); |
225 | return DC; |
226 | } |
227 | |
228 | |
229 | //======================================================================= |
230 | //function : OwnCheck |
231 | //purpose : |
232 | //======================================================================= |
233 | |
234 | void IGESGeom_ToolCurveOnSurface::OwnCheck(const Handle(IGESGeom_CurveOnSurface)& ent, |
235 | const Interface_ShareTool&, |
236 | Handle(Interface_Check)& ach) const |
237 | { |
238 | // MGE 30/07/98 |
239 | // Building of messages |
240 | //======================================== |
241 | //Message_Msg Msg134 = Message_Msg("XSTEP_134"); |
242 | //======================================== |
243 | |
244 | // if (ent->CreationMode() < 0 || ent->CreationMode() > 3) |
245 | // ach.SendFail("Incorrect value for the Creation Mode"); |
246 | // Standard_Integer pref = ent->PreferenceMode(); |
247 | // if (pref < 0 || pref > 3) |
248 | // ach.SendFail("Incorrect value for the Preference Mode"); |
249 | // tolerance a la norme |
250 | // if (pref == 1 && ent->CurveUV().IsNull()) |
251 | // ach.AddWarning("Preference Mode asks UV and Curve UV not defined"); |
252 | // if (pref == 2 && ent->Curve3D().IsNull()) |
253 | // ach.AddWarning("Preference Mode asks UV and Curve UV not defined"); |
254 | if (ent->CurveUV().IsNull() && ent->Curve3D().IsNull()) { |
255 | Message_Msg Msg134 = Message_Msg("XSTEP_134"); |
256 | ach->SendFail(Msg134); |
257 | } |
258 | } |
259 | |
260 | |
261 | //======================================================================= |
262 | //function : OwnDump |
263 | //purpose : |
264 | //======================================================================= |
265 | |
266 | void IGESGeom_ToolCurveOnSurface::OwnDump(const Handle(IGESGeom_CurveOnSurface)& ent, |
267 | const IGESData_IGESDumper& dumper, |
268 | const Handle(Message_Messenger)& S, |
269 | const Standard_Integer level) const |
270 | { |
271 | S << "IGESGeom_CurveOnSurface" << endl << endl; |
272 | Standard_Integer sublevel = (level <= 4) ? 0 : 1; |
273 | |
274 | Standard_Integer crem = ent->CreationMode(); |
275 | S << "Creation Mode : " << crem << " i.e. "; |
276 | if (crem == 0) S << " <Unspecified>" << endl; |
277 | else if (crem == 1) S << " Projection of a Curve on a Surface" << endl; |
278 | else if (crem == 2) S << " Intersection of two Surfaces" << endl; |
279 | else if (crem == 3) S << " Isoparametric Curve (either U or V)" << endl; |
280 | else S << " <Incorrect Value>" << endl; |
281 | S << "The Surface on which the curve lies : "; |
282 | dumper.Dump(ent->Surface(),S, sublevel); |
283 | S << endl; |
284 | S << "The curve B (in the parametric space (u, v)) : "; |
285 | dumper.Dump(ent->CurveUV(),S, sublevel); |
286 | S << endl; |
287 | S << "The curve C (in the 3D Space) : "; |
288 | dumper.Dump(ent->Curve3D(),S, sublevel); |
289 | S << endl; |
290 | Standard_Integer pref = ent->PreferenceMode(); |
291 | S << "Preferred representation mode : " << pref << " i.e. "; |
292 | if (pref == 0) S << " <Unspecified>" << endl; |
293 | else if (pref == 1) S << " Curve B on Surface" << endl; |
294 | else if (pref == 2) S << " Curve C in 3D Space" << endl; |
295 | else if (pref == 3) S << " Curves B & C equally preferred" << endl; |
296 | else S << " <Incorrect Value>" << endl; |
297 | } |