b311480e |
1 | // Created by: CKY / Contract Toubro-Larsen |
2 | // Copyright (c) 1993-1999 Matra Datavision |
973c2be1 |
3 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
7fd59977 |
6 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
7fd59977 |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
b311480e |
15 | |
16 | //-------------------------------------------------------------------- |
7fd59977 |
17 | //-------------------------------------------------------------------- |
18 | |
42cf5bc1 |
19 | #include <IGESBasic_Group.hxx> |
20 | #include <IGESBasic_ToolGroup.hxx> |
21 | #include <IGESData_DirChecker.hxx> |
7fd59977 |
22 | #include <IGESData_Dump.hxx> |
42cf5bc1 |
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> |
7fd59977 |
33 | #include <Interface_Macros.hxx> |
42cf5bc1 |
34 | #include <Interface_ShareTool.hxx> |
35 | #include <Message_Messenger.hxx> |
7fd59977 |
36 | #include <Message_Msg.hxx> |
42cf5bc1 |
37 | #include <Standard_DomainError.hxx> |
7fd59977 |
38 | |
42cf5bc1 |
39 | // MGE 03/08/98 |
7fd59977 |
40 | IGESBasic_ToolGroup::IGESBasic_ToolGroup () { } |
41 | |
42 | |
43 | void IGESBasic_ToolGroup::ReadOwnParams |
44 | (const Handle(IGESBasic_Group)& ent, |
45 | const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const |
46 | { |
47 | // MGE 03/08/98 |
48 | // Building of messages |
49 | //======================================== |
50 | // Message_Msg Msg202("XSTEP_202"); |
51 | // Message_Msg Msg203("XSTEP_203"); |
52 | //======================================== |
53 | |
54 | //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed |
55 | Standard_Integer nbval = 0; |
56 | // Msg202.Arg(1); |
57 | //st = PR.ReadInteger( PR.Current(), Msg202, nbval); //szv#4:S4163:12Mar99 moved down |
58 | //st = PR.ReadInteger( PR.Current(), "Count of Entities", nbval); |
59 | |
60 | Handle(IGESData_HArray1OfIGESEntity) EntArray; |
61 | if ( PR.ReadInteger( PR.Current(), nbval) ) { //szv#4:S4163:12Mar99 `st=` not needed |
62 | Message_Msg Msg203("XSTEP_203"); |
63 | Msg203.Arg(1); |
64 | PR.ReadEnts (IR,PR.CurrentList(nbval),Msg203,EntArray); //szv#4:S4163:12Mar99 `st=` not needed |
65 | } |
66 | else { |
67 | Message_Msg Msg202("XSTEP_202"); |
68 | Msg202.Arg(1); |
69 | PR.SendFail(Msg202); |
70 | } |
71 | |
72 | |
73 | DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent); |
74 | ent->Init(EntArray); |
75 | } |
76 | |
77 | void IGESBasic_ToolGroup::WriteOwnParams |
78 | (const Handle(IGESBasic_Group)& ent, IGESData_IGESWriter& IW) const |
79 | { |
80 | Standard_Integer upper = ent->NbEntities(); |
81 | IW.Send(upper); |
82 | for (Standard_Integer i = 1; i <= upper;i++) |
83 | IW.Send(ent->Entity(i)); |
84 | } |
85 | |
86 | void IGESBasic_ToolGroup::OwnShared |
87 | (const Handle(IGESBasic_Group)& ent, Interface_EntityIterator& iter) const |
88 | { |
89 | Standard_Integer upper = ent->NbEntities(); |
90 | for (Standard_Integer i = 1; i <= upper;i++) |
91 | iter.GetOneItem(ent->Entity(i)); |
92 | } |
93 | |
94 | void IGESBasic_ToolGroup::OwnCopy |
95 | (const Handle(IGESBasic_Group)& another, |
96 | const Handle(IGESBasic_Group)& ent, Interface_CopyTool& TC) const |
97 | { |
98 | Standard_Integer lower,upper; |
99 | lower = 1; |
100 | upper = another->NbEntities(); |
101 | Handle(IGESData_HArray1OfIGESEntity) EntArray = new |
102 | IGESData_HArray1OfIGESEntity(lower,upper); |
103 | for (Standard_Integer i = lower;i <= upper;i++) |
104 | { |
105 | DeclareAndCast |
106 | (IGESData_IGESEntity,myentity,TC.Transferred(another->Entity(i))); |
107 | EntArray->SetValue(i,myentity); |
108 | } |
109 | ent->Init(EntArray); |
110 | } |
111 | |
112 | Standard_Boolean IGESBasic_ToolGroup::OwnCorrect |
113 | (const Handle(IGESBasic_Group)& ent ) const |
114 | { |
115 | Standard_Integer ianul = 0; |
116 | Standard_Integer i, nbtrue = 0, nb = ent->NbEntities(); |
117 | for (i = 1; i <= nb; i ++) { |
118 | Handle(IGESData_IGESEntity) val = ent->Entity(i); |
119 | if (val.IsNull()) ianul ++; |
120 | else if (val->TypeNumber() == 0) ianul ++; |
121 | } |
122 | if (ianul == 0) return Standard_False; |
123 | Handle(IGESData_HArray1OfIGESEntity) EntArray; |
124 | if (ianul < nb) EntArray = new IGESData_HArray1OfIGESEntity(1,nb-ianul); |
125 | for (i = 1; i <= nb; i ++) { |
126 | Handle(IGESData_IGESEntity) val = ent->Entity(i); |
127 | if (val.IsNull()) continue; |
128 | else if (val->TypeNumber() == 0) continue; |
129 | nbtrue ++; |
130 | EntArray->SetValue (nbtrue,ent->Entity(i)); |
131 | } |
132 | ent->Init(EntArray); |
133 | return Standard_True; |
134 | } |
135 | |
136 | |
137 | IGESData_DirChecker IGESBasic_ToolGroup::DirChecker |
138 | (const Handle(IGESBasic_Group)& /* ent */ ) const |
139 | { |
140 | IGESData_DirChecker DC(402,1); //TypeNo. 402, Form no. 1 |
141 | DC.Structure(IGESData_DefVoid); |
142 | DC.GraphicsIgnored(); |
143 | DC.BlankStatusIgnored(); |
144 | DC.HierarchyStatusIgnored(); |
145 | return DC; |
146 | } |
147 | |
148 | void IGESBasic_ToolGroup::OwnCheck(const Handle(IGESBasic_Group)& ent, |
149 | const Interface_ShareTool&, |
150 | Handle(Interface_Check)& /* ach */) const |
151 | { |
152 | Standard_Boolean ianul = Standard_False; |
153 | Standard_Integer i, nb = ent->NbEntities(); |
154 | for (i = 1; i <= nb; i ++) { |
155 | Handle(IGESData_IGESEntity) val = ent->Entity(i); |
156 | if (val.IsNull()) ianul = Standard_True; |
157 | else if (val->TypeNumber() == 0) ianul = Standard_True; |
158 | if (ianul) { |
159 | break; |
160 | } |
161 | } |
162 | } |
163 | |
164 | void IGESBasic_ToolGroup::OwnDump |
165 | (const Handle(IGESBasic_Group)& ent, const IGESData_IGESDumper& dumper, |
166 | const Handle(Message_Messenger)& S, const Standard_Integer level) const |
167 | { |
168 | S << "IGESBasic_Group" << endl; |
169 | S << "Entries in the Group : "; |
170 | IGESData_DumpEntities(S,dumper ,level,1, ent->NbEntities(),ent->Entity); |
171 | S << endl; |
172 | } |
173 | |