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_OrderedGroupWithoutBackP.hxx>
20 #include <IGESBasic_ToolOrderedGroupWithoutBackP.hxx>
21 #include <IGESData_DirChecker.hxx>
22 #include <IGESData_Dump.hxx>
23 #include <IGESData_HArray1OfIGESEntity.hxx>
24 #include <IGESData_IGESDumper.hxx>
25 #include <IGESData_IGESEntity.hxx>
26 #include <IGESData_IGESReaderData.hxx>
27 #include <IGESData_IGESWriter.hxx>
28 #include <IGESData_ParamCursor.hxx>
29 #include <IGESData_ParamReader.hxx>
30 #include <Interface_Check.hxx>
31 #include <Interface_CopyTool.hxx>
32 #include <Interface_EntityIterator.hxx>
33 #include <Interface_Macros.hxx>
34 #include <Interface_ShareTool.hxx>
35 #include <Message_Messenger.hxx>
36 #include <Standard_DomainError.hxx>
38 IGESBasic_ToolOrderedGroupWithoutBackP::IGESBasic_ToolOrderedGroupWithoutBackP()
42 void IGESBasic_ToolOrderedGroupWithoutBackP::ReadOwnParams
43 (const Handle(IGESBasic_OrderedGroupWithoutBackP)& ent,
44 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
46 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
47 Standard_Integer nbval = 0;
48 Handle(IGESData_HArray1OfIGESEntity) EntArray;
50 if (PR.ReadInteger( PR.Current(), "Count of Entities", nbval)) { //szv#4:S4163:12Mar99 `st=` not needed
51 PR.ReadEnts (IR,PR.CurrentList(nbval),"Entities",EntArray); //szv#4:S4163:12Mar99 `st=` not needed
53 EntArray = new IGESData_HArray1OfIGESEntity(1,nbval);
54 for (Standard_Integer i = 1;i <= nbval;i++)
56 Handle(IGESData_IGESEntity) anent;
57 st = PR.ReadEntity (IR,PR.Current(),"Element of the Group",anent,Standard_True);
58 if (st) EntArray->SetValue(i,anent);
62 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
66 void IGESBasic_ToolOrderedGroupWithoutBackP::WriteOwnParams
67 (const Handle(IGESBasic_OrderedGroupWithoutBackP)& ent, IGESData_IGESWriter& IW) const
69 Standard_Integer upper = ent->NbEntities();
70 IW.Send(ent->NbEntities());
71 for (Standard_Integer i = 1; i <= upper; i ++)
72 IW.Send(ent->Entity(i));
75 void IGESBasic_ToolOrderedGroupWithoutBackP::OwnShared
76 (const Handle(IGESBasic_OrderedGroupWithoutBackP)& ent, Interface_EntityIterator& iter) const
78 Standard_Integer upper = ent->NbEntities();
79 for (Standard_Integer i = 1; i <= upper; i ++)
80 iter.GetOneItem(ent->Entity(i));
83 void IGESBasic_ToolOrderedGroupWithoutBackP::OwnCopy
84 (const Handle(IGESBasic_OrderedGroupWithoutBackP)& another,
85 const Handle(IGESBasic_OrderedGroupWithoutBackP)& ent, Interface_CopyTool& TC) const
87 Standard_Integer lower,upper;
89 upper = another->NbEntities();
90 Handle(IGESData_HArray1OfIGESEntity) EntArray = new
91 IGESData_HArray1OfIGESEntity(lower,upper);
92 for (Standard_Integer i = lower;i <= upper;i++)
95 (IGESData_IGESEntity,myentity,TC.Transferred(another->Entity(i)));
96 EntArray->SetValue(i,myentity);
101 Standard_Boolean IGESBasic_ToolOrderedGroupWithoutBackP::OwnCorrect
102 (const Handle(IGESBasic_OrderedGroupWithoutBackP)& ent ) const
104 Standard_Integer ianul = 0;
105 Standard_Integer i, nbtrue = 0, nb = ent->NbEntities();
106 for (i = 1; i <= nb; i ++) {
107 Handle(IGESData_IGESEntity) val = ent->Entity(i);
108 if (val.IsNull()) ianul ++;
109 else if (val->TypeNumber() == 0) ianul ++;
111 if (ianul == 0) return Standard_False;
112 Handle(IGESData_HArray1OfIGESEntity) EntArray;
113 if (ianul < nb) EntArray = new IGESData_HArray1OfIGESEntity(1,nb-ianul);
114 for (i = 1; i <= nb; i ++) {
115 Handle(IGESData_IGESEntity) val = ent->Entity(i);
116 if (val.IsNull()) continue;
117 else if (val->TypeNumber() == 0) continue;
119 EntArray->SetValue (nbtrue,ent->Entity(i));
122 return Standard_True;
125 IGESData_DirChecker IGESBasic_ToolOrderedGroupWithoutBackP::DirChecker
126 (const Handle(IGESBasic_OrderedGroupWithoutBackP)& /* ent */) const
128 IGESData_DirChecker DC(402,15); //TypeNo. 402, Form no. 15
129 DC.Structure(IGESData_DefVoid);
130 DC.GraphicsIgnored();
131 DC.BlankStatusIgnored();
132 DC.HierarchyStatusIgnored();
136 void IGESBasic_ToolOrderedGroupWithoutBackP::OwnCheck
137 (const Handle(IGESBasic_OrderedGroupWithoutBackP)& ent,
138 const Interface_ShareTool& , Handle(Interface_Check)& ach) const
140 Standard_Boolean ianul = Standard_False;
141 Standard_Integer i, nb = ent->NbEntities();
142 for (i = 1; i <= nb; i ++) {
143 Handle(IGESData_IGESEntity) val = ent->Entity(i);
144 if (val.IsNull()) ianul = Standard_True;
145 else if (val->TypeNumber() == 0) ianul = Standard_True;
147 ach->AddWarning ("At least one element is Null");
153 void IGESBasic_ToolOrderedGroupWithoutBackP::OwnDump
154 (const Handle(IGESBasic_OrderedGroupWithoutBackP)& ent, const IGESData_IGESDumper& dumper,
155 Standard_OStream& S, const Standard_Integer level) const
157 S << "IGESBasic_OrderedGroupWithoutBackP\n"
158 << "Entries in the Group : ";
159 IGESData_DumpEntities(S,dumper ,level,1, ent->NbEntities(),ent->Entity);