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