1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2012 OPEN CASCADE SAS
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.
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.
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.
20 //--------------------------------------------------------------------
21 //--------------------------------------------------------------------
22 //:l9 abv 15.01.99: CTS22023 and TEC0278: issue data fail on offset tapered flag
23 // only if type is not constant
25 #include <IGESGeom_ToolOffsetCurve.ixx>
26 #include <IGESData_ParamCursor.hxx>
29 #include <IGESData_IGESEntity.hxx>
30 #include <IGESData_Dump.hxx>
31 #include <Interface_Macros.hxx>
34 #include <Message_Msg.hxx>
35 #include <IGESData_Status.hxx>
37 //=======================================================================
38 //function : IGESGeom_ToolOffsetCurve
40 //=======================================================================
42 IGESGeom_ToolOffsetCurve::IGESGeom_ToolOffsetCurve ()
47 //=======================================================================
48 //function : ReadOwnParams
50 //=======================================================================
52 void IGESGeom_ToolOffsetCurve::ReadOwnParams(const Handle(IGESGeom_OffsetCurve)& ent,
53 const Handle(IGESData_IGESReaderData)& IR,
54 IGESData_ParamReader& PR) const
57 // Building of messages
58 //========================================
59 Message_Msg Msg121("XSTEP_121");
60 //========================================
62 Standard_Integer anOffsetType, aFunctionCoord, aTaperedOffsetType;
63 Standard_Real offDistance1, offDistance2;
64 Standard_Real arcLength1, arcLength2, anOffsetParam, anotherOffsetParam;
66 Handle(IGESData_IGESEntity) aBaseCurve;
67 Handle(IGESData_IGESEntity) aFunction;
68 IGESData_Status aStatus;
69 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
71 // Reading the curve entity to be offset
72 if (!PR.ReadEntity(IR, PR.Current(), aStatus, aBaseCurve)){
73 Message_Msg Msg110("XSTEP_110");
75 case IGESData_ReferenceError: {
76 Message_Msg Msg216 ("IGES_216");
77 Msg110.Arg(Msg216.Value());
80 case IGESData_EntityError: {
81 Message_Msg Msg217 ("IGES_217");
82 Msg110.Arg(Msg217.Value());
88 } //szv#4:S4163:12Mar99 `st=` not needed
89 //st = PR.ReadEntity(IR, PR.Current(), "Curve to be offset", aBaseCurve);
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");
96 //st = PR.ReadInteger(PR.Current(), "Offset Distance Flag", anOffsetType);
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");
102 case IGESData_ReferenceError: {
103 Message_Msg Msg216 ("IGES_216");
104 Msg112.Arg(Msg216.Value());
107 case IGESData_EntityError: {
108 Message_Msg Msg217 ("IGES_217");
109 Msg112.Arg(Msg217.Value());
115 } //szv#4:S4163:12Mar99 `st=` not needed
117 st = PR.ReadEntity(IR, PR.Current(), "Curve whose coordinate describes the offset", aFunction, Standard_True);
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");
125 //st = PR.ReadInteger(PR.Current(), "Coordinate of the curve", aFunctionCoord);
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");
132 //st = PR.ReadInteger(PR.Current(), "Tapered offset type flag", aTaperedOffsetType);
134 // Reading the first offset distance
135 if (!PR.ReadReal(PR.Current(), offDistance1)){
136 Message_Msg Msg115("XSTEP_115");
138 } //szv#4:S4163:12Mar99 `st=` not needed
139 //st = PR.ReadReal(PR.Current(), "First Offset distance", offDistance1);
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");
145 } //szv#4:S4163:12Mar99 `st=` not needed
146 //st = PR.ReadReal(PR.Current(), "Arc length of first offset distance", arcLength1);
148 // Reading the second offset distance
149 if (!PR.ReadReal(PR.Current(),offDistance2)){
150 Message_Msg Msg117("XSTEP_117");
152 } //szv#4:S4163:12Mar99 `st=` not needed
153 //st = PR.ReadReal(PR.Current(), "Second Offset distance", offDistance2);
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");
159 } //szv#4:S4163:12Mar99 `st=` not needed
160 //st = PR.ReadReal(PR.Current(), "Arc length of Second offset distance", arcLength2);
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);
166 // Reading the offset curve starting parameter value
167 if (!PR.ReadReal(PR.Current(), anOffsetParam)){
168 Message_Msg Msg119("XSTEP_119");
170 } //szv#4:S4163:12Mar99 `st=` not needed
171 //st = PR.ReadReal(PR.Current(), "Starting parameter value of Offset curve", anOffsetParam);
173 // Reading the offset curve ending parameter value
174 if (!PR.ReadReal(PR.Current(), anotherOffsetParam)){
175 Message_Msg Msg120("XSTEP_120");
177 } //szv#4:S4163:12Mar99 `st=` not needed
178 //st = PR.ReadReal(PR.Current(), "Ending parameter value of Offset curve", anotherOffsetParam);
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);
184 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
186 (aBaseCurve, anOffsetType, aFunction, aFunctionCoord,
187 aTaperedOffsetType, offDistance1, arcLength1, offDistance2,
188 arcLength2, aNormalVec, anOffsetParam, anotherOffsetParam);
192 //=======================================================================
193 //function : WriteOwnParams
195 //=======================================================================
197 void IGESGeom_ToolOffsetCurve::WriteOwnParams(const Handle(IGESGeom_OffsetCurve)& ent,
198 IGESData_IGESWriter& IW) const
200 IW.Send(ent->BaseCurve());
201 IW.Send(ent->OffsetType());
203 IW.Send(ent->Function());
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());
219 //=======================================================================
220 //function : OwnShared
222 //=======================================================================
224 void IGESGeom_ToolOffsetCurve::OwnShared(const Handle(IGESGeom_OffsetCurve)& ent,
225 Interface_EntityIterator& iter) const
227 iter.GetOneItem(ent->BaseCurve());
228 iter.GetOneItem(ent->Function());
232 //=======================================================================
235 //=======================================================================
237 void IGESGeom_ToolOffsetCurve::OwnCopy(const Handle(IGESGeom_OffsetCurve)& another,
238 const Handle(IGESGeom_OffsetCurve)& ent,
239 Interface_CopyTool& TC) const
241 Standard_Integer anOffsetType, aFunctionCoord, aTaperedOffsetType;
242 Standard_Real offDistance1, offDistance2;
243 Standard_Real arcLength1, arcLength2, anOffsetParam1, anOffsetParam2;
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();
260 ent->Init(aBaseCurve, anOffsetType, aFunction, aFunctionCoord,
261 aTaperedOffsetType, offDistance1, arcLength1, offDistance2,
262 arcLength2, aNormalVec, anOffsetParam1, anOffsetParam2);
266 //=======================================================================
267 //function : OwnCorrect
269 //=======================================================================
271 Standard_Boolean IGESGeom_ToolOffsetCurve::OwnCorrect
272 (const Handle(IGESGeom_OffsetCurve)& ent) const
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
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;
289 //=======================================================================
290 //function : DirChecker
292 //=======================================================================
294 IGESData_DirChecker IGESGeom_ToolOffsetCurve::DirChecker
295 (const Handle(IGESGeom_OffsetCurve)& /* ent */ ) const
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();
307 //=======================================================================
308 //function : OwnCheck
310 //=======================================================================
312 void IGESGeom_ToolOffsetCurve::OwnCheck(const Handle(IGESGeom_OffsetCurve)& ent,
313 const Interface_ShareTool&,
314 Handle(Interface_Check)& ach) const
317 // Building of messages
318 //========================================
319 //Message_Msg Msg111("XSTEP_111");
320 //Message_Msg Msg114("XSTEP_114");
321 //========================================
323 Standard_Integer ot = ent->OffsetType();
324 if (ot < 1 || ot > 3) {
325 Message_Msg Msg111("XSTEP_111");
326 ach->SendFail(Msg111);
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)");
333 if (ot !=1 && //:l9 abv 15.01.99: CTS22023 and TEC0278: only if ot is function
334 (ent->TaperedOffsetType() < 1) || (ent->TaperedOffsetType() > 2)) {
335 Message_Msg Msg114("XSTEP_114");
336 ach->SendFail(Msg114);
341 //=======================================================================
344 //=======================================================================
346 void 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
351 Standard_Integer sublevel = (level <= 4) ? 0 : 1;
353 S << "IGESGeom_OffsetCurve" << endl;
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);
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;