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 | |
7fd59977 |
19 | #include <IGESBasic_HArray1OfHArray1OfInteger.hxx> |
42cf5bc1 |
20 | #include <IGESData_DirChecker.hxx> |
7fd59977 |
21 | #include <IGESData_Dump.hxx> |
42cf5bc1 |
22 | #include <IGESData_IGESDumper.hxx> |
23 | #include <IGESData_IGESReaderData.hxx> |
24 | #include <IGESData_IGESWriter.hxx> |
25 | #include <IGESData_ParamCursor.hxx> |
26 | #include <IGESData_ParamReader.hxx> |
27 | #include <IGESDefs_AssociativityDef.hxx> |
28 | #include <IGESDefs_ToolAssociativityDef.hxx> |
29 | #include <Interface_Check.hxx> |
30 | #include <Interface_CopyTool.hxx> |
31 | #include <Interface_EntityIterator.hxx> |
7fd59977 |
32 | #include <Interface_Macros.hxx> |
42cf5bc1 |
33 | #include <Interface_ShareTool.hxx> |
34 | #include <Message_Messenger.hxx> |
35 | #include <Standard_DomainError.hxx> |
36 | #include <TColStd_HArray1OfInteger.hxx> |
7fd59977 |
37 | |
38 | IGESDefs_ToolAssociativityDef::IGESDefs_ToolAssociativityDef () { } |
39 | |
40 | |
41 | void IGESDefs_ToolAssociativityDef::ReadOwnParams |
42 | (const Handle(IGESDefs_AssociativityDef)& ent, |
43 | const Handle(IGESData_IGESReaderData)& /* IR */, IGESData_ParamReader& PR) const |
44 | { |
45 | //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down |
46 | Handle(TColStd_HArray1OfInteger) requirements; |
47 | Handle(TColStd_HArray1OfInteger) orders; |
48 | Handle(TColStd_HArray1OfInteger) numItems; |
49 | Handle(IGESBasic_HArray1OfHArray1OfInteger) items; |
50 | Standard_Integer nbval; |
51 | |
52 | Standard_Boolean st = PR.ReadInteger(PR.Current(), "No. of Class definitions", nbval); |
53 | if (st && nbval > 0) |
54 | { |
55 | requirements = new TColStd_HArray1OfInteger(1, nbval); |
56 | orders = new TColStd_HArray1OfInteger(1, nbval); |
57 | numItems = new TColStd_HArray1OfInteger(1, nbval); |
58 | items = new IGESBasic_HArray1OfHArray1OfInteger(1, nbval); |
59 | } |
60 | else PR.AddFail("No. of Class definitions: Not Positive"); |
61 | |
62 | if ( ! requirements.IsNull()) |
63 | for (Standard_Integer i = 1; i <= nbval; i++) |
64 | { |
65 | Standard_Integer requirement; |
66 | Standard_Integer order; |
67 | Standard_Integer numItem; |
68 | Handle(TColStd_HArray1OfInteger) item; |
69 | |
70 | //st = PR.ReadInteger(PR.Current(), "Back Pointer Requirement", requirement); //szv#4:S4163:12Mar99 moved in if |
71 | if (PR.ReadInteger(PR.Current(), "Back Pointer Requirement", requirement)) |
72 | requirements->SetValue(i, requirement); |
73 | |
74 | //st = PR.ReadInteger(PR.Current(), "Ordered/Unordered Class", order); //szv#4:S4163:12Mar99 moved in if |
75 | if (PR.ReadInteger(PR.Current(), "Ordered/Unordered Class", order)) |
76 | orders->SetValue(i, order); |
77 | |
78 | //st = PR.ReadInteger(PR.Current(),"No. of items per entry", numItem); //szv#4:S4163:12Mar99 moved in if |
79 | if (PR.ReadInteger(PR.Current(),"No. of items per entry", numItem)) { |
80 | Standard_Integer temp; |
81 | numItems->SetValue(i, numItem); |
82 | item = new TColStd_HArray1OfInteger(1, numItem); |
83 | for (Standard_Integer j = 1; j <= numItem; j++) |
84 | { |
85 | //Standard_Integer temp; //szv#4:S4163:12Mar99 moved out of for |
86 | //st = PR.ReadInteger(PR.Current(), "Item", temp); //szv#4:S4163:12Mar99 moved in if |
87 | if (PR.ReadInteger(PR.Current(), "Item", temp)) |
88 | item->SetValue(j, temp); |
89 | } |
90 | items->SetValue(i, item); |
91 | } |
92 | } |
93 | |
94 | DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent); |
95 | ent->Init(requirements, orders, numItems, items); |
96 | } |
97 | |
98 | void IGESDefs_ToolAssociativityDef::WriteOwnParams |
99 | (const Handle(IGESDefs_AssociativityDef)& ent, IGESData_IGESWriter& IW) const |
100 | { |
101 | Standard_Integer upper = ent->NbClassDefs(); |
102 | IW.Send(upper); |
103 | for (Standard_Integer i = 1; i <= upper; i++) { |
104 | IW.Send(ent->BackPointerReq(i)); |
105 | IW.Send(ent->ClassOrder(i)); |
106 | IW.Send(ent->NbItemsPerClass(i)); |
107 | Standard_Integer items = ent->NbItemsPerClass(i); |
108 | for (Standard_Integer j = 1; j <= items; j++) |
109 | IW.Send(ent->Item(i,j)); |
110 | } |
111 | } |
112 | |
113 | void IGESDefs_ToolAssociativityDef::OwnShared |
114 | (const Handle(IGESDefs_AssociativityDef)& /* ent */, Interface_EntityIterator& /* iter */) const |
115 | { |
116 | } |
117 | |
118 | void IGESDefs_ToolAssociativityDef::OwnCopy |
119 | (const Handle(IGESDefs_AssociativityDef)& another, |
120 | const Handle(IGESDefs_AssociativityDef)& ent, Interface_CopyTool& /* TC */) const |
121 | { |
122 | |
123 | Handle(TColStd_HArray1OfInteger) requirements; |
124 | Handle(TColStd_HArray1OfInteger) orders; |
125 | Handle(TColStd_HArray1OfInteger) numItems; |
126 | Handle(IGESBasic_HArray1OfHArray1OfInteger) items; |
127 | |
128 | Standard_Integer nbval = another->NbClassDefs(); |
129 | |
130 | requirements = new TColStd_HArray1OfInteger(1, nbval); |
131 | orders = new TColStd_HArray1OfInteger(1, nbval); |
132 | numItems = new TColStd_HArray1OfInteger(1, nbval); |
133 | items = new IGESBasic_HArray1OfHArray1OfInteger(1, nbval); |
134 | |
135 | for (Standard_Integer i = 1; i <= nbval; i++) |
136 | { |
137 | Standard_Integer requirement = another->BackPointerReq(i); |
138 | requirements->SetValue(i, requirement); |
139 | Standard_Integer order = another->ClassOrder(i); |
140 | orders->SetValue(i, order); |
141 | Standard_Integer numItem = another->NbItemsPerClass(i); |
142 | numItems->SetValue(i, numItem); |
143 | Handle(TColStd_HArray1OfInteger) item; |
144 | item = new TColStd_HArray1OfInteger(1, numItem); |
145 | |
146 | for (Standard_Integer j = 1; j <= numItem; j++) |
147 | { |
148 | Standard_Integer temp = another->Item(i, j); |
149 | item->SetValue(j, temp); |
150 | } |
151 | items->SetValue(i, item); |
152 | } |
153 | ent->Init(requirements, orders, numItems, items); |
154 | ent->SetFormNumber (another->FormNumber()); |
155 | } |
156 | |
157 | IGESData_DirChecker IGESDefs_ToolAssociativityDef::DirChecker |
158 | (const Handle(IGESDefs_AssociativityDef)& /* ent */ ) const |
159 | { |
160 | IGESData_DirChecker DC (302, 5001, 9999); |
161 | DC.Structure(IGESData_DefVoid); |
162 | DC.LineFont(IGESData_DefVoid); |
163 | DC.LineWeight(IGESData_DefVoid); |
164 | DC.Color(IGESData_DefVoid); |
165 | DC.BlankStatusIgnored(); |
166 | DC.SubordinateStatusRequired(0); |
167 | DC.UseFlagRequired(2); |
168 | DC.HierarchyStatusIgnored(); |
169 | return DC; |
170 | } |
171 | |
172 | void IGESDefs_ToolAssociativityDef::OwnCheck |
173 | (const Handle(IGESDefs_AssociativityDef)& /* ent */, |
174 | const Interface_ShareTool& , Handle(Interface_Check)& /* ach */) const |
175 | { |
176 | } |
177 | |
178 | void IGESDefs_ToolAssociativityDef::OwnDump |
179 | (const Handle(IGESDefs_AssociativityDef)& ent, const IGESData_IGESDumper& /* dumper */, |
0ebe5b0a |
180 | Standard_OStream& S, const Standard_Integer level) const |
7fd59977 |
181 | { |
0ebe5b0a |
182 | S << "IGESDefs_AssociativityDef\n" |
183 | << "Number of Class Definitions : " << ent->NbClassDefs() << "\n" |
184 | << "Back Pointer Requirement :\n" |
185 | << "Ordered / Unordered Class :\n" |
186 | << "Number Of Items per Entry :\n" |
187 | << "Items :\n"; |
7fd59977 |
188 | IGESData_DumpVals(S,-level,1, ent->NbClassDefs(),ent->BackPointerReq); |
0ebe5b0a |
189 | S << std::endl; |
7fd59977 |
190 | if (level > 4) |
191 | { |
192 | // Warning : Item is a JAGGED Array |
193 | Standard_Integer upper = ent->NbClassDefs(); |
194 | for (Standard_Integer i = 1; i <= upper; i ++) { |
0ebe5b0a |
195 | S << "[" << i << "]:\n"; |
7fd59977 |
196 | S << "Back Pointer Requirement : " << ent->BackPointerReq(i) << " "; |
197 | if (ent->IsBackPointerReq(i)) S << "(Yes) "; |
198 | else S << "(No) "; |
199 | S << " Ordered/Unordered Class : " << ent->ClassOrder(i) << " "; |
0ebe5b0a |
200 | if (ent->IsOrdered(i)) S << "(Yes)\n"; |
201 | else S << "(No)\n"; |
7fd59977 |
202 | S << "Number Of Items per Entry : " << ent->NbItemsPerClass(i); |
203 | if (level < 6) { |
0ebe5b0a |
204 | S << " [ask level > 5 for more]\n"; |
7fd59977 |
205 | continue; |
206 | } |
0ebe5b0a |
207 | S << "\n ["; |
7fd59977 |
208 | for (Standard_Integer j = 1; j <= ent->NbItemsPerClass(i); j ++) |
209 | S << " " << ent->Item(i,j); |
0ebe5b0a |
210 | S << "]\n"; |
7fd59977 |
211 | } |
212 | } |
0ebe5b0a |
213 | S << std::endl; |
7fd59977 |
214 | } |
215 | |