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