0023258: Missing parenthesis
[occt.git] / src / IGESGeom / IGESGeom_ToolOffsetCurve.cxx
CommitLineData
b311480e 1// Created by: CKY / Contract Toubro-Larsen
2// Copyright (c) 1993-1999 Matra Datavision
3// Copyright (c) 1999-2012 OPEN CASCADE SAS
4//
5// The content of this file is subject to the Open CASCADE Technology Public
6// License Version 6.5 (the "License"). You may not use the content of this file
7// except in compliance with the License. Please obtain a copy of the License
8// at http://www.opencascade.org and read it completely before using this file.
7fd59977 9//
b311480e 10// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
7fd59977 12//
b311480e 13// The Original Code and all software distributed under the License is
14// distributed on an "AS IS" basis, without warranty of any kind, and the
15// Initial Developer hereby disclaims all such warranties, including without
16// limitation, any warranties of merchantability, fitness for a particular
17// purpose or non-infringement. Please see the License for the specific terms
18// and conditions governing the rights and limitations under the License.
19
20//--------------------------------------------------------------------
7fd59977 21//--------------------------------------------------------------------
22//:l9 abv 15.01.99: CTS22023 and TEC0278: issue data fail on offset tapered flag
23// only if type is not constant
24
25#include <IGESGeom_ToolOffsetCurve.ixx>
26#include <IGESData_ParamCursor.hxx>
27#include <gp_XYZ.hxx>
28#include <gp_Vec.hxx>
29#include <IGESData_IGESEntity.hxx>
30#include <IGESData_Dump.hxx>
31#include <Interface_Macros.hxx>
32
33// MGE 30/07/98
34#include <Message_Msg.hxx>
35#include <IGESData_Status.hxx>
36
37//=======================================================================
38//function : IGESGeom_ToolOffsetCurve
39//purpose :
40//=======================================================================
41
42IGESGeom_ToolOffsetCurve::IGESGeom_ToolOffsetCurve ()
43{
44}
45
46
47//=======================================================================
48//function : ReadOwnParams
49//purpose :
50//=======================================================================
51
52void IGESGeom_ToolOffsetCurve::ReadOwnParams(const Handle(IGESGeom_OffsetCurve)& ent,
53 const Handle(IGESData_IGESReaderData)& IR,
54 IGESData_ParamReader& PR) const
55{
56 // MGE 30/07/98
57 // Building of messages
58 //========================================
59 Message_Msg Msg121("XSTEP_121");
60 //========================================
61
62 Standard_Integer anOffsetType, aFunctionCoord, aTaperedOffsetType;
63 Standard_Real offDistance1, offDistance2;
64 Standard_Real arcLength1, arcLength2, anOffsetParam, anotherOffsetParam;
65 gp_XYZ aNormalVec;
66 Handle(IGESData_IGESEntity) aBaseCurve;
67 Handle(IGESData_IGESEntity) aFunction;
68 IGESData_Status aStatus;
69 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
70
71 // Reading the curve entity to be offset
72 if (!PR.ReadEntity(IR, PR.Current(), aStatus, aBaseCurve)){
73 Message_Msg Msg110("XSTEP_110");
74 switch(aStatus) {
75 case IGESData_ReferenceError: {
76 Message_Msg Msg216 ("IGES_216");
77 Msg110.Arg(Msg216.Value());
78 PR.SendFail(Msg110);
79 break; }
80 case IGESData_EntityError: {
81 Message_Msg Msg217 ("IGES_217");
82 Msg110.Arg(Msg217.Value());
83 PR.SendFail(Msg110);
84 break; }
85 default:{
86 }
87 }
88 } //szv#4:S4163:12Mar99 `st=` not needed
89 //st = PR.ReadEntity(IR, PR.Current(), "Curve to be offset", aBaseCurve);
90
91 // Reading the offset distance flag
92 if (!PR.ReadInteger(PR.Current(), anOffsetType)){ //szv#4:S4163:12Mar99 `st=` not needed
93 Message_Msg Msg111("XSTEP_111");
94 PR.SendFail(Msg111);
95 }
96 //st = PR.ReadInteger(PR.Current(), "Offset Distance Flag", anOffsetType);
97
98 // Reading the curve entity describing the offset as a function, can be Null
99 if (!PR.ReadEntity(IR, PR.Current(), aStatus, aFunction, Standard_True)){
100 Message_Msg Msg112("XSTEP_112");
101 switch(aStatus) {
102 case IGESData_ReferenceError: {
103 Message_Msg Msg216 ("IGES_216");
104 Msg112.Arg(Msg216.Value());
105 PR.SendFail(Msg112);
106 break; }
107 case IGESData_EntityError: {
108 Message_Msg Msg217 ("IGES_217");
109 Msg112.Arg(Msg217.Value());
110 PR.SendFail(Msg112);
111 break; }
112 default:{
113 }
114 }
115 } //szv#4:S4163:12Mar99 `st=` not needed
116/*
117 st = PR.ReadEntity(IR, PR.Current(), "Curve whose coordinate describes the offset", aFunction, Standard_True);
118*/
119
120 // Reading the coordinate describing the offset as a function
121 if (!PR.ReadInteger(PR.Current(), aFunctionCoord)){ //szv#4:S4163:12Mar99 `st=` not needed
122 Message_Msg Msg113("XSTEP_113");
123 PR.SendFail(Msg113);
124 }
125 //st = PR.ReadInteger(PR.Current(), "Coordinate of the curve", aFunctionCoord);
126
127 // Reading the tapered offset type flag
128 if (!PR.ReadInteger(PR.Current(), aTaperedOffsetType)){ //szv#4:S4163:12Mar99 `st=` not needed
129 Message_Msg Msg114("XSTEP_114");
130 PR.SendFail(Msg114);
131 }
132 //st = PR.ReadInteger(PR.Current(), "Tapered offset type flag", aTaperedOffsetType);
133
134 // Reading the first offset distance
135 if (!PR.ReadReal(PR.Current(), offDistance1)){
136 Message_Msg Msg115("XSTEP_115");
137 PR.SendFail(Msg115);
138 } //szv#4:S4163:12Mar99 `st=` not needed
139 //st = PR.ReadReal(PR.Current(), "First Offset distance", offDistance1);
140
141 // Reading the arc length or parameter value of the first offset distance
142 if (!PR.ReadReal(PR.Current(), arcLength1)){
143 Message_Msg Msg116("XSTEP_116");
144 PR.SendFail(Msg116);
145 } //szv#4:S4163:12Mar99 `st=` not needed
146 //st = PR.ReadReal(PR.Current(), "Arc length of first offset distance", arcLength1);
147
148 // Reading the second offset distance
149 if (!PR.ReadReal(PR.Current(),offDistance2)){
150 Message_Msg Msg117("XSTEP_117");
151 PR.SendFail(Msg117);
152 } //szv#4:S4163:12Mar99 `st=` not needed
153 //st = PR.ReadReal(PR.Current(), "Second Offset distance", offDistance2);
154
155 // Reading the arc length or parameter value of the second offset distance
156 if (!PR.ReadReal(PR.Current(), arcLength2)){
157 Message_Msg Msg118("XSTEP_118");
158 PR.SendFail(Msg118);
159 } //szv#4:S4163:12Mar99 `st=` not needed
160 //st = PR.ReadReal(PR.Current(), "Arc length of Second offset distance", arcLength2);
161
162 // Reading the Unit vector normal to plane
163 PR.ReadXYZ (PR.CurrentList(1, 3), Msg121, aNormalVec); //szv#4:S4163:12Mar99 `st=` not needed
164 //st = PR.ReadXYZ (PR.CurrentList(1, 3), "Unit vector normal to plane", aNormalVec);
165
166 // Reading the offset curve starting parameter value
167 if (!PR.ReadReal(PR.Current(), anOffsetParam)){
168 Message_Msg Msg119("XSTEP_119");
169 PR.SendFail(Msg119);
170 } //szv#4:S4163:12Mar99 `st=` not needed
171 //st = PR.ReadReal(PR.Current(), "Starting parameter value of Offset curve", anOffsetParam);
172
173 // Reading the offset curve ending parameter value
174 if (!PR.ReadReal(PR.Current(), anotherOffsetParam)){
175 Message_Msg Msg120("XSTEP_120");
176 PR.SendFail(Msg120);
177 } //szv#4:S4163:12Mar99 `st=` not needed
178 //st = PR.ReadReal(PR.Current(), "Ending parameter value of Offset curve", anotherOffsetParam);
179
180 // Reading the Unit vector normal to plane
181 PR.ReadXYZ (PR.CurrentList(1, 3), Msg121, aNormalVec); //szv#4:S4163:12Mar99 `st=` not needed
182 //st = PR.ReadXYZ (PR.CurrentList(1, 3), "Unit vector normal to plane", aNormalVec);
183
184 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
185 ent->Init
186 (aBaseCurve, anOffsetType, aFunction, aFunctionCoord,
187 aTaperedOffsetType, offDistance1, arcLength1, offDistance2,
188 arcLength2, aNormalVec, anOffsetParam, anotherOffsetParam);
189}
190
191
192//=======================================================================
193//function : WriteOwnParams
194//purpose :
195//=======================================================================
196
197void IGESGeom_ToolOffsetCurve::WriteOwnParams(const Handle(IGESGeom_OffsetCurve)& ent,
198 IGESData_IGESWriter& IW) const
199{
200 IW.Send(ent->BaseCurve());
201 IW.Send(ent->OffsetType());
202
203 IW.Send(ent->Function());
204
205 IW.Send(ent->FunctionParameter());
206 IW.Send(ent->TaperedOffsetType());
207 IW.Send(ent->FirstOffsetDistance());
208 IW.Send(ent->ArcLength1());
209 IW.Send(ent->SecondOffsetDistance());
210 IW.Send(ent->ArcLength2());
211 IW.Send(ent->NormalVector().X());
212 IW.Send(ent->NormalVector().Y());
213 IW.Send(ent->NormalVector().Z());
214 IW.Send(ent->StartParameter());
215 IW.Send(ent->EndParameter());
216}
217
218
219//=======================================================================
220//function : OwnShared
221//purpose :
222//=======================================================================
223
224void IGESGeom_ToolOffsetCurve::OwnShared(const Handle(IGESGeom_OffsetCurve)& ent,
225 Interface_EntityIterator& iter) const
226{
227 iter.GetOneItem(ent->BaseCurve());
228 iter.GetOneItem(ent->Function());
229}
230
231
232//=======================================================================
233//function : OwnCopy
234//purpose :
235//=======================================================================
236
237void IGESGeom_ToolOffsetCurve::OwnCopy(const Handle(IGESGeom_OffsetCurve)& another,
238 const Handle(IGESGeom_OffsetCurve)& ent,
239 Interface_CopyTool& TC) const
240{
241 Standard_Integer anOffsetType, aFunctionCoord, aTaperedOffsetType;
242 Standard_Real offDistance1, offDistance2;
243 Standard_Real arcLength1, arcLength2, anOffsetParam1, anOffsetParam2;
244
245 DeclareAndCast(IGESData_IGESEntity, aBaseCurve,
246 TC.Transferred(another->BaseCurve()));
247 anOffsetType = another->OffsetType();
248 DeclareAndCast(IGESData_IGESEntity, aFunction,
249 TC.Transferred(another->Function()));
250 aFunctionCoord = another->FunctionParameter();
251 aTaperedOffsetType = another->TaperedOffsetType();
252 offDistance1 = another->FirstOffsetDistance();
253 arcLength1 = another->ArcLength1();
254 offDistance2 = another->SecondOffsetDistance();
255 arcLength2 = another->ArcLength2();
256 gp_XYZ aNormalVec = (another->NormalVector()).XYZ();
257 anOffsetParam1 = another->StartParameter();
258 anOffsetParam2 = another->EndParameter();
259
260 ent->Init(aBaseCurve, anOffsetType, aFunction, aFunctionCoord,
261 aTaperedOffsetType, offDistance1, arcLength1, offDistance2,
262 arcLength2, aNormalVec, anOffsetParam1, anOffsetParam2);
263}
264
265
266//=======================================================================
267//function : OwnCorrect
268//purpose :
269//=======================================================================
270
271Standard_Boolean IGESGeom_ToolOffsetCurve::OwnCorrect
272 (const Handle(IGESGeom_OffsetCurve)& ent) const
273{
274 if (ent->OffsetType() == 3) return Standard_False;
275 Handle(IGESData_IGESEntity) func = ent->Function();
276 if (func.IsNull()) return Standard_False;
277// OffsetType != 3 : reconstruire avec Offset Function Nulle
278 func.Nullify();
279 ent->Init (ent->BaseCurve(), ent->OffsetType(), func,0, // func+coord Nuls
280 ent->TaperedOffsetType(),
281 ent->FirstOffsetDistance(), ent->ArcLength1(),
282 ent->SecondOffsetDistance(), ent->ArcLength2(),
283 ent->NormalVector().XYZ(),
284 ent->StartParameter(), ent->EndParameter() );
285 return Standard_True;
286}
287
288
289//=======================================================================
290//function : DirChecker
291//purpose :
292//=======================================================================
293
294IGESData_DirChecker IGESGeom_ToolOffsetCurve::DirChecker
295 (const Handle(IGESGeom_OffsetCurve)& /* ent */ ) const
296{
297 IGESData_DirChecker DC(130, 0);
298 DC.Structure(IGESData_DefVoid);
299 DC.LineFont(IGESData_DefAny);
300// DC.LineWeight(IGESData_DefValue);
301 DC.Color(IGESData_DefAny);
302 DC.HierarchyStatusIgnored();
303 return DC;
304}
305
306
307//=======================================================================
308//function : OwnCheck
309//purpose :
310//=======================================================================
311
312void IGESGeom_ToolOffsetCurve::OwnCheck(const Handle(IGESGeom_OffsetCurve)& ent,
313 const Interface_ShareTool&,
314 Handle(Interface_Check)& ach) const
315{
316 // MGE 30/07/98
317 // Building of messages
318 //========================================
319 //Message_Msg Msg111("XSTEP_111");
320 //Message_Msg Msg114("XSTEP_114");
321 //========================================
322
323 Standard_Integer ot = ent->OffsetType();
324 if (ot < 1 || ot > 3) {
325 Message_Msg Msg111("XSTEP_111");
326 ach->SendFail(Msg111);
327 }
328/* if (ot == 3) if (ent->Function().IsNull())
329 ach.SendFail("Offset Function Not Defined while Offset Type = 3");
330 if (ot == 3 && (ent->FunctionParameter() < 1 || ent->FunctionParameter() > 3))
331 ach.SendFail("Offset Function Parameter != 1-2 or 3 (rq : for X-Y or Z)");
332*/
333 if (ot !=1 && //:l9 abv 15.01.99: CTS22023 and TEC0278: only if ot is function
f272f76c 334 ((ent->TaperedOffsetType() < 1) || (ent->TaperedOffsetType() > 2))) {
7fd59977 335 Message_Msg Msg114("XSTEP_114");
336 ach->SendFail(Msg114);
337 }
338}
339
340
341//=======================================================================
342//function : OwnDump
343//purpose :
344//=======================================================================
345
346void IGESGeom_ToolOffsetCurve::OwnDump(const Handle(IGESGeom_OffsetCurve)& ent,
347 const IGESData_IGESDumper& dumper,
348 const Handle(Message_Messenger)& S,
349 const Standard_Integer level) const
350{
351 Standard_Integer sublevel = (level <= 4) ? 0 : 1;
352
353 S << "IGESGeom_OffsetCurve" << endl;
354
355 S << "The curve to be offset : " << endl;
356 dumper.Dump(ent->BaseCurve(),S, sublevel);
357 S << "Offset Distance Flag : " << ent->OffsetType() << endl;
358 S << "Curve entity whose coordinate defines the offset : ";
359 dumper.Dump(ent->Function(),S, sublevel);
360 S << endl;
361 S << "In which Coordinate to use : " << ent->FunctionParameter() << endl;
362 S << "Tapered Offset Type Flag : " << ent->TaperedOffsetType() << endl;
363 S << "First Offset Distance : " << ent->FirstOffsetDistance() << " ";
364 S << "Arc Length : " << ent->ArcLength1() << endl;
365 S << "Second Offset Distance : " << ent->SecondOffsetDistance() << " ";
366 S << "Arc Length : " << ent->ArcLength2() << endl;
367 S << "Normal Vector : ";
368 IGESData_DumpXYZL(S,level, ent->NormalVector(), ent->VectorLocation()); S<<endl;
369 S << "Offset curve Parameters. Starting : " << ent->StartParameter() << " ";
370 S << "Ending : " << ent->EndParameter() << endl;
371}