1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 //--------------------------------------------------------------------
17 //--------------------------------------------------------------------
19 #include <IGESBasic_HArray1OfHArray1OfIGESEntity.hxx>
20 #include <IGESData_DirChecker.hxx>
21 #include <IGESData_Dump.hxx>
22 #include <IGESData_HArray1OfIGESEntity.hxx>
23 #include <IGESData_IGESDumper.hxx>
24 #include <IGESData_IGESEntity.hxx>
25 #include <IGESData_IGESReaderData.hxx>
26 #include <IGESData_IGESWriter.hxx>
27 #include <IGESData_ParamReader.hxx>
28 #include <IGESData_Status.hxx>
29 #include <IGESGeom_Boundary.hxx>
30 #include <IGESGeom_ToolBoundary.hxx>
31 #include <Interface_Check.hxx>
32 #include <Interface_CopyTool.hxx>
33 #include <Interface_EntityIterator.hxx>
34 #include <Interface_Macros.hxx>
35 #include <Interface_ShareTool.hxx>
36 #include <Message_Msg.hxx>
37 #include <Standard_DomainError.hxx>
38 #include <TColStd_HArray1OfInteger.hxx>
42 //=======================================================================
43 //function : IGESGeom_ToolBoundary
45 //=======================================================================
46 IGESGeom_ToolBoundary::IGESGeom_ToolBoundary ()
51 //=======================================================================
52 //function : ReadOwnParams
54 //=======================================================================
56 void IGESGeom_ToolBoundary::ReadOwnParams(const Handle(IGESGeom_Boundary)& ent,
57 const Handle(IGESData_IGESReaderData)& IR,
58 IGESData_ParamReader& PR) const
62 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
63 Standard_Integer num; //szv#4:S4163:12Mar99 j not needed, i moved down in `for`
64 Standard_Integer tempType, tempPreference;
65 Handle(IGESData_IGESEntity) tempSurface;
66 Handle(TColStd_HArray1OfInteger) tempSenses;
67 Handle(IGESData_HArray1OfIGESEntity) tempModelCurves;
68 Handle(IGESBasic_HArray1OfHArray1OfIGESEntity) tempParameterCurves;
69 IGESData_Status aStatus;
71 //szv#4:S4163:12Mar99 `st=` not needed
72 if (!PR.ReadInteger(PR.Current(), tempType)){
73 Message_Msg Msg122("XTSEP_122");
76 if (!PR.ReadInteger(PR.Current(), tempPreference)){
77 Message_Msg Msg123("XTSEP_123");
81 if (!PR.ReadEntity(IR, PR.Current(), aStatus, tempSurface)){
82 Message_Msg Msg124("XTSEP_124");
84 case IGESData_ReferenceError: {
85 Message_Msg Msg216 ("IGES_216");
86 Msg124.Arg(Msg216.Value());
89 case IGESData_EntityError: {
90 Message_Msg Msg217 ("IGES_217");
91 Msg124.Arg(Msg217.Value());
99 if (PR.ReadInteger(PR.Current(), num) && (num > 0)) {
100 tempSenses = new TColStd_HArray1OfInteger(1, num);
101 tempModelCurves = new IGESData_HArray1OfIGESEntity(1, num);
102 tempParameterCurves = new IGESBasic_HArray1OfHArray1OfIGESEntity(1, num);
105 Message_Msg Msg126("XTSEP_126");
109 if (!tempSenses.IsNull() && !tempModelCurves.IsNull() && !tempParameterCurves.IsNull() ) {
110 for ( Standard_Integer i = 1; i <= num; i++ ) //szv#4:S4163:12Mar99 Standard_Integer moved in `for`
112 Handle(IGESData_IGESEntity) tempEnt;
113 //st = PR.ReadEntity(IR, PR.Current(), Msg127, tempEnt); //szv#4:S4163:12Mar99 moved in if
114 //st = PR.ReadEntity(IR, PR.Current(), "Model Space Curves", tempEnt);
115 if (PR.ReadEntity(IR, PR.Current(), aStatus, tempEnt))
116 tempModelCurves->SetValue(i, tempEnt);
118 Message_Msg Msg127("XTSEP_127");
120 case IGESData_ReferenceError: {
121 Message_Msg Msg216 ("IGES_216");
122 Msg127.Arg(Msg216.Value());
125 case IGESData_EntityError: {
126 Message_Msg Msg217 ("IGES_217");
127 Msg127.Arg(Msg217.Value());
135 Standard_Integer tempSense;
136 //st = PR.ReadInteger(PR.Current(), Msg128, tempSense); //szv#4:S4163:12Mar99 moved in if
137 //st = PR.ReadInteger(PR.Current(), "Orientation flags", tempSense);
138 if (PR.ReadInteger(PR.Current(), tempSense))
139 tempSenses->SetValue(i, tempSense);
141 Message_Msg Msg128("XTSEP_128");
145 Standard_Integer tempCount;
146 //st = PR.ReadInteger(PR.Current(), Msg129, tempCount); //szv#4:S4163:12Mar99 moved in if
147 //st = PR.ReadInteger(PR.Current(), "Count of Parameter Space Curves", tempCount);
148 //szv#4:S4163:12Mar99 optimized
150 if (st && tempCount >= 0)
152 Handle(IGESData_HArray1OfIGESEntity) tempParCurves;
154 st = PR.ReadEnts (IR,PR.CurrentList(tempCount), Msg130, tempParCurves);
155 //st = PR.ReadEnts (IR,PR.CurrentList(tempCount), "Parameter Space Curves", tempParCurves);
160 IGESData_HArray1OfIGESEntity(1, tempCount);
161 for ( j = 1; j <= tempCount; j++ ) {
162 Handle(IGESData_IGESEntity) tempEnt;
163 st = PR.ReadEntity(IR, PR.Current(),
164 "Parameter Space Curves", tempEnt);
165 if (st) tempParCurves->SetValue(j, tempEnt);
170 tempParameterCurves->SetValue(i, tempParCurves);
172 if (st && tempCount < 0)
175 if (PR.ReadInteger(PR.Current(), tempCount) && (tempCount >= 0)) {
176 Handle(IGESData_HArray1OfIGESEntity) tempParCurves;
178 Message_Msg Msg130("XTSEP_130");
179 PR.ReadEnts (IR,PR.CurrentList(tempCount), Msg130, tempParCurves); //szv#4:S4163:12Mar99 `st=` not needed
181 tempParameterCurves->SetValue(i, tempParCurves);
184 Message_Msg Msg129("XTSEP_129");
190 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
192 (tempType, tempPreference, tempSurface, tempModelCurves,
193 tempSenses, tempParameterCurves);
197 //=======================================================================
198 //function : WriteOwnParams
200 //=======================================================================
202 void IGESGeom_ToolBoundary::WriteOwnParams(const Handle(IGESGeom_Boundary)& ent,
203 IGESData_IGESWriter& IW) const
205 Standard_Integer i, j, num1;
206 IW.Send(ent->BoundaryType());
207 IW.Send(ent->PreferenceType());
208 IW.Send(ent->Surface());
209 IW.Send(ent->NbModelSpaceCurves());
210 for ( num1 = ent->NbModelSpaceCurves(), i = 1; i <= num1; i++)
212 IW.Send(ent->ModelSpaceCurve(i));
213 IW.Send(ent->Sense(i));
214 Handle(IGESData_HArray1OfIGESEntity) curves = ent->ParameterCurves(i);
215 Standard_Integer nbc = ent->NbParameterCurves(i);
219 for ( j = 1; j <= nbc; j ++)
220 IW.Send(curves->Value(j));
226 //=======================================================================
227 //function : OwnShared
229 //=======================================================================
231 void IGESGeom_ToolBoundary::OwnShared(const Handle(IGESGeom_Boundary)& ent,
232 Interface_EntityIterator& iter) const
234 Standard_Integer i, j, num1;
235 iter.GetOneItem(ent->Surface());
236 for ( num1 = ent->NbModelSpaceCurves(), i = 1; i <= num1; i++)
238 iter.GetOneItem(ent->ModelSpaceCurve(i));
239 Handle(IGESData_HArray1OfIGESEntity) curves = ent->ParameterCurves(i);
240 if (!curves.IsNull())
242 Standard_Integer nbc = curves->Length();
243 for ( j = 1; j <= nbc; j ++)
244 iter.GetOneItem(curves->Value(j));
250 //=======================================================================
253 //=======================================================================
255 void IGESGeom_ToolBoundary::OwnCopy(const Handle(IGESGeom_Boundary)& another,
256 const Handle(IGESGeom_Boundary)& ent,
257 Interface_CopyTool& TC) const
259 Standard_Integer i, j;
260 Standard_Integer tempType = another->BoundaryType();
261 Standard_Integer tempPreference = another->PreferenceType();
262 Standard_Integer num1 = another->NbModelSpaceCurves();
264 DeclareAndCast(IGESData_IGESEntity, tempSurface,
265 TC.Transferred(another->Surface()) );
267 Handle(TColStd_HArray1OfInteger) tempSenses =
268 new TColStd_HArray1OfInteger(1, num1);
269 Handle(IGESData_HArray1OfIGESEntity) tempModelCurves =
270 new IGESData_HArray1OfIGESEntity(1, num1);
271 Handle(IGESBasic_HArray1OfHArray1OfIGESEntity) tempParameterCurves =
272 new IGESBasic_HArray1OfHArray1OfIGESEntity(1, num1);
274 for ( i = 1; i <= num1; i++ )
276 DeclareAndCast(IGESData_IGESEntity, tempEnt,
277 TC.Transferred(another->ModelSpaceCurve(i)) );
278 tempModelCurves->SetValue(i, tempEnt);
279 tempSenses->SetValue(i, another->Sense(i));
280 Standard_Integer num2 = another->NbParameterCurves(i);
281 Handle(IGESData_HArray1OfIGESEntity) ParCurves =
282 another->ParameterCurves(i);
283 Handle(IGESData_HArray1OfIGESEntity) tempParCurves;
284 if (num2 > 0) tempParCurves = new IGESData_HArray1OfIGESEntity(1, num2);
285 for ( j = 1; j <= num2; j++ )
287 DeclareAndCast(IGESData_IGESEntity, tempEnt1,
288 TC.Transferred(ParCurves->Value(j)) );
289 tempParCurves->SetValue(j, tempEnt1);
291 tempParameterCurves->SetValue(i, tempParCurves);
293 ent->Init(tempType, tempPreference, tempSurface, tempModelCurves,
294 tempSenses, tempParameterCurves);
298 //=======================================================================
299 //function : OwnCorrect
301 //=======================================================================
303 Standard_Boolean IGESGeom_ToolBoundary::OwnCorrect
304 (const Handle(IGESGeom_Boundary)& ent) const
306 // Standard_Boolean t0 = (ent->BoundaryType() == 0);
307 Standard_Boolean res = Standard_False;
308 Standard_Boolean r2d = Standard_False;
309 Standard_Integer nb = ent->NbModelSpaceCurves();
310 Standard_Integer i; // svv Jan11 2000 : porting on DEC
311 for (i = 1; i <= nb; i ++) {
312 Standard_Integer nbi = ent->NbParameterCurves(i);
313 if (nbi == 0) continue;
314 for (Standard_Integer j = 1; j <= nbi; j ++) {
315 Handle(IGESData_IGESEntity) c2d = ent->ParameterCurve (i,j);
316 if (c2d.IsNull()) continue;
318 (c2d->BlankStatus(),c2d->SubordinateStatus(),5,c2d->HierarchyStatus());
323 if (!r2d) return res;
324 if (ent->BoundaryType() != 0) return res; // OK
326 // Reste Boundary Type : s ilya des ParameterCurves, il doit valoir 1
327 // On reconstruit donc la Boundary a l identique, mais avec BoundaryType = 1
329 // si type = 0, annuller tous les ParameterCurves
330 // -> On reconstruit, avec ParameterCurves Nulles
331 // En plus, les ParameterCurves doivent avoir leur UseFlag a 5
333 Handle(IGESBasic_HArray1OfHArray1OfIGESEntity) cv2d =
334 new IGESBasic_HArray1OfHArray1OfIGESEntity(1,nb);
335 Handle(IGESData_HArray1OfIGESEntity) modcv =
336 new IGESData_HArray1OfIGESEntity(1,nb);
337 Handle(TColStd_HArray1OfInteger) senses = new TColStd_HArray1OfInteger(1,nb);
338 for (i = 1; i <= nb; i ++) {
339 senses->SetValue(i, ent->Sense(i));
340 modcv->SetValue (i, ent->ModelSpaceCurve(i));
341 cv2d->SetValue (i, ent->ParameterCurves(i));
343 ent->Init (1, ent->PreferenceType(), ent->Surface(),
344 modcv, senses, cv2d);
345 return Standard_True;
349 //=======================================================================
350 //function : DirChecker
352 //=======================================================================
354 IGESData_DirChecker IGESGeom_ToolBoundary::DirChecker
355 (const Handle(IGESGeom_Boundary)& /* ent */ ) const
357 IGESData_DirChecker DC(141, 0);
358 DC.Structure(IGESData_DefVoid);
359 DC.GraphicsIgnored();
360 DC.LineFont(IGESData_DefAny);
361 // DC.LineWeight(IGESData_DefValue);
362 DC.Color(IGESData_DefAny);
363 DC.SubordinateStatusRequired(0);
364 DC.HierarchyStatusIgnored();
369 //=======================================================================
370 //function : OwnCheck
372 //=======================================================================
374 void IGESGeom_ToolBoundary::OwnCheck(const Handle(IGESGeom_Boundary)& ent,
375 const Interface_ShareTool&,
376 Handle(Interface_Check)& ach) const
379 // Building of messages
380 //========================================
381 //Message_Msg Msg122("XTSEP_122");
382 //Message_Msg Msg123("XTSEP_123");
383 //Message_Msg Msg125("XTSEP_125");
384 //Message_Msg Msg128("XTSEP_128");
385 //========================================
387 if ((ent->BoundaryType() != 0) && (ent->BoundaryType() != 1)) {
388 Message_Msg Msg122("XTSEP_122");
389 ach->SendFail(Msg122);
391 if ((ent->PreferenceType() < 0) || (ent->PreferenceType() > 3)) {
392 Message_Msg Msg123("XTSEP_123");
393 ach->SendFail(Msg123);
396 // il faudrait aussi tester que, pour BoundaryType = 1, la Surface est bien
397 // Parametrique ... (au moins un cas ne passe pas : c est Plane 108)
398 if (ent->BoundaryType() == 1) {
399 if (ent->Surface()->TypeNumber() == 108) {
400 Message_Msg Msg125("XTSEP_125");
401 ach->SendFail(Msg125);
405 Standard_Integer i, num;
406 for ( num = ent->NbModelSpaceCurves(), i = 1; i <= num; i++ )
407 if (ent->Sense(i) != 1 && ent->Sense(i) != 2) {
408 Message_Msg Msg128("XTSEP_128");
409 ach->SendFail(Msg128);
412 if (ent->BoundaryType() == 0)
413 for ( num = ent->NbModelSpaceCurves(), i = 1; i <= num; i++ )
414 if (ent->NbParameterCurves(i) != 0)
417 sprintf(mess,"Nb. Parameter Space Curve %d !=0 while Boundary Type=0",i);
424 //=======================================================================
427 //=======================================================================
429 void IGESGeom_ToolBoundary::OwnDump(const Handle(IGESGeom_Boundary)& ent,
430 const IGESData_IGESDumper& dumper,
432 const Standard_Integer level) const
434 Standard_Integer i, num, sublevel = (level > 4) ? 1 : 0;
435 S << "IGESGeom_Boundary\n"
436 << "Bounded Surface Representation Type : " << ent->BoundaryType() << "\n"
437 << "Trimming Curves Representation : " << ent->PreferenceType() << "\n"
438 << "Bounded Surface : ";
439 dumper.Dump(ent->Surface(),S, sublevel);
441 << "Model Space Curves :\n"
442 << "Orientation Flags :\n"
443 << "Parameter Curves Set : ";
444 IGESData_DumpEntities(S,dumper,-level,1,ent->NbModelSpaceCurves(),ent->ModelSpaceCurve);
447 for ( num = ent->NbModelSpaceCurves(), i = 1; i <= num; i++ )
449 S << "[" << i << "]: "
450 << "Model Space Curve : ";
451 dumper.Dump (ent->ModelSpaceCurve(i),S, 1);
452 S << " Orientation Flags : " << ent->Sense(i) << "\n"
453 << " Parameter Curves : ";
454 Handle(IGESData_HArray1OfIGESEntity) curves = ent->ParameterCurves(i);
455 if (!curves.IsNull()) {
456 IGESData_DumpEntities(S,dumper, level,1,curves->Length(),curves->Value);