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 <IGESData_DirChecker.hxx> |
20 | #include <IGESData_Dump.hxx> |
21 | #include <IGESData_HArray1OfIGESEntity.hxx> |
22 | #include <IGESData_IGESDumper.hxx> |
23 | #include <IGESData_IGESEntity.hxx> |
24 | #include <IGESData_IGESReaderData.hxx> |
25 | #include <IGESData_IGESWriter.hxx> |
7fd59977 |
26 | #include <IGESData_ParamCursor.hxx> |
42cf5bc1 |
27 | #include <IGESData_ParamReader.hxx> |
7fd59977 |
28 | #include <IGESData_ViewKindEntity.hxx> |
7fd59977 |
29 | #include <IGESDraw_HArray1OfViewKindEntity.hxx> |
42cf5bc1 |
30 | #include <IGESDraw_ToolViewsVisible.hxx> |
31 | #include <IGESDraw_ViewsVisible.hxx> |
32 | #include <Interface_Check.hxx> |
33 | #include <Interface_CopyTool.hxx> |
34 | #include <Interface_EntityIterator.hxx> |
7fd59977 |
35 | #include <Interface_Macros.hxx> |
42cf5bc1 |
36 | #include <Interface_ShareTool.hxx> |
37 | #include <Message_Messenger.hxx> |
38 | #include <Standard_DomainError.hxx> |
7fd59977 |
39 | |
42cf5bc1 |
40 | #include <stdio.h> |
7fd59977 |
41 | IGESDraw_ToolViewsVisible::IGESDraw_ToolViewsVisible () { } |
42 | |
43 | |
44 | void IGESDraw_ToolViewsVisible::ReadOwnParams |
45 | (const Handle(IGESDraw_ViewsVisible)& ent, |
46 | const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const |
47 | { |
48 | //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed |
49 | |
50 | Standard_Integer tempNbViewsVisible, tempNbDisplayedEntities; |
51 | Handle(IGESDraw_HArray1OfViewKindEntity) tempViewEntities; |
52 | Handle(IGESData_HArray1OfIGESEntity) tempDisplayEntity; |
53 | |
54 | //st = PR.ReadInteger(PR.Current(), "Number Of Views Visible", |
55 | //tempNbViewsVisible); //szv#4:S4163:12Mar99 moved in if |
56 | if (PR.ReadInteger(PR.Current(), "Number Of Views Visible", tempNbViewsVisible)) { |
57 | // Initialise HArray1 only if there is no error reading its Length |
58 | if (tempNbViewsVisible <= 0) |
59 | PR.AddFail("Number Of Views Visible : Not Positive"); |
60 | else tempViewEntities = new IGESDraw_HArray1OfViewKindEntity (1, tempNbViewsVisible); |
61 | } |
62 | |
63 | if (PR.DefinedElseSkip()) |
64 | PR.ReadInteger(PR.Current(), "Number of Entities Displayed", |
65 | tempNbDisplayedEntities); //szv#4:S4163:12Mar99 `st=` not needed |
66 | else { |
67 | tempNbDisplayedEntities = 0; |
68 | PR.AddWarning("Number of Entities Displayed : undefined, set to Zero"); |
69 | } |
70 | // Initialise HArray1 only if there is no error reading its Length |
71 | if (tempNbDisplayedEntities < 0) |
72 | PR.AddFail ("Number Of Entities Displayed : Less than Zero"); |
73 | // else if (tempNbDisplayedEntities > 0) { |
74 | |
75 | if (! tempViewEntities.IsNull()) { |
76 | // Read the HArray1 only if its Length was read without any Error |
77 | Standard_Integer I; |
78 | for (I = 1; I <= tempNbViewsVisible; I++) { |
79 | Handle(IGESData_ViewKindEntity) tempViewEntity1; |
80 | //st = PR.ReadEntity(IR, PR.Current(), "View Entity", |
81 | //STANDARD_TYPE(IGESData_ViewKindEntity), tempViewEntity1); //szv#4:S4163:12Mar99 moved in if |
82 | if (PR.ReadEntity(IR, PR.Current(), "View Entity", |
83 | STANDARD_TYPE(IGESData_ViewKindEntity), tempViewEntity1)) |
84 | tempViewEntities->SetValue(I, tempViewEntity1); |
85 | } |
86 | } |
87 | |
88 | // Read the HArray1 only if its Length was read without any Error |
89 | if (tempNbDisplayedEntities > 0) { |
90 | PR.ReadEnts (IR,PR.CurrentList(tempNbDisplayedEntities), |
91 | "Displayed Entities",tempDisplayEntity); //szv#4:S4163:12Mar99 `st=` not needed |
92 | /* |
93 | tempDisplayEntity = |
94 | new IGESData_HArray1OfIGESEntity (1, tempNbDisplayedEntities); |
95 | |
96 | Handle(IGESData_IGESEntity) tempEntity2; |
97 | Standard_Integer I; |
98 | for (I = 1; I <= tempNbDisplayedEntities; I++) { |
99 | st = PR.ReadEntity(IR, PR.Current(), "Displayed Entity", |
100 | tempEntity2); |
101 | if (st) tempDisplayEntity->SetValue(I, tempEntity2); |
102 | } |
103 | */ |
104 | } |
105 | |
106 | DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent); |
107 | ent->Init(tempViewEntities, tempDisplayEntity); |
108 | } |
109 | |
110 | void IGESDraw_ToolViewsVisible::WriteOwnParams |
111 | (const Handle(IGESDraw_ViewsVisible)& ent, IGESData_IGESWriter& IW) const |
112 | { |
113 | IW.Send(ent->NbViews()); |
114 | IW.Send(ent->NbDisplayedEntities()); |
115 | |
116 | Standard_Integer I; |
117 | Standard_Integer up = ent->NbViews(); |
118 | for (I = 1; I <= up; I++) |
119 | IW.Send(ent->ViewItem(I)); |
120 | up = ent->NbDisplayedEntities(); |
121 | for (I = 1; I <= up; I++) |
122 | IW.Send(ent->DisplayedEntity(I)); |
123 | } |
124 | |
125 | void IGESDraw_ToolViewsVisible::OwnShared |
126 | (const Handle(IGESDraw_ViewsVisible)& ent, Interface_EntityIterator& iter) const |
127 | { |
128 | Standard_Integer I,up; |
129 | up = ent->NbViews(); |
130 | for (I = 1; I <= up; I++) |
131 | iter.GetOneItem(ent->ViewItem(I)); |
132 | // Displayed -> Implied |
133 | } |
134 | |
135 | void IGESDraw_ToolViewsVisible::OwnImplied |
136 | (const Handle(IGESDraw_ViewsVisible)& ent, Interface_EntityIterator& iter) const |
137 | { |
138 | Standard_Integer I,up; |
139 | up = ent->NbDisplayedEntities(); |
140 | for (I = 1; I <= up; I++) |
141 | iter.GetOneItem(ent->DisplayedEntity(I)); |
142 | } |
143 | |
144 | |
145 | void IGESDraw_ToolViewsVisible::OwnCopy |
146 | (const Handle(IGESDraw_ViewsVisible)& another, |
147 | const Handle(IGESDraw_ViewsVisible)& ent, Interface_CopyTool& TC) const |
148 | { |
149 | Handle(IGESDraw_HArray1OfViewKindEntity) tempViewEntities = |
150 | new IGESDraw_HArray1OfViewKindEntity(1, another->NbViews()); |
151 | Standard_Integer I, up; |
152 | up = another->NbViews(); |
153 | for (I = 1; I <= up; I++) { |
154 | DeclareAndCast(IGESData_ViewKindEntity, tempView, |
155 | TC.Transferred(another->ViewItem(I))); |
156 | tempViewEntities->SetValue(I, tempView); |
157 | } |
158 | // Displayed -> Implied : mettre une liste vide par defaut |
159 | Handle(IGESData_HArray1OfIGESEntity) tempDisplayEntities; |
160 | ent->Init(tempViewEntities, tempDisplayEntities); |
161 | } |
162 | |
163 | void IGESDraw_ToolViewsVisible::OwnRenew |
164 | (const Handle(IGESDraw_ViewsVisible)& another, |
165 | const Handle(IGESDraw_ViewsVisible)& ent, const Interface_CopyTool& TC) const |
166 | { |
167 | Interface_EntityIterator newdisp; |
168 | Standard_Integer I, up; |
169 | up = another->NbDisplayedEntities(); |
170 | if (up == 0) return; |
171 | Handle(IGESData_HArray1OfIGESEntity) tempDisplayEntities; |
aa00364d |
172 | Handle(Standard_Transient) anew; |
7fd59977 |
173 | for (I = 1; I <= up; I++) { |
174 | if (TC.Search (another->DisplayedEntity(I),anew)) newdisp.GetOneItem(anew); |
175 | } |
176 | |
177 | up = newdisp.NbEntities(); I = 0; |
178 | if (up > 0) tempDisplayEntities = new IGESData_HArray1OfIGESEntity(1,up); |
179 | for (newdisp.Start(); newdisp.More(); newdisp.Next()) { |
180 | I ++; |
181 | DeclareAndCast(IGESData_IGESEntity, tempEntity,newdisp.Value()); |
182 | tempDisplayEntities->SetValue(I, tempEntity); |
183 | } |
184 | ent->InitImplied (tempDisplayEntities); |
185 | } |
186 | |
187 | |
188 | IGESData_DirChecker IGESDraw_ToolViewsVisible::DirChecker |
189 | (const Handle(IGESDraw_ViewsVisible)& /*ent*/) const |
190 | { |
191 | IGESData_DirChecker DC(402, 3); |
192 | DC.Structure(IGESData_DefVoid); |
193 | DC.LineFont(IGESData_DefVoid); |
194 | DC.LineWeight(IGESData_DefVoid); |
195 | DC.Color(IGESData_DefVoid); |
196 | DC.BlankStatusIgnored(); |
197 | DC.SubordinateStatusRequired(0); |
198 | DC.UseFlagRequired(1); |
199 | DC.HierarchyStatusIgnored(); |
200 | |
201 | return DC; |
202 | } |
203 | |
204 | void IGESDraw_ToolViewsVisible::OwnCheck |
205 | (const Handle(IGESDraw_ViewsVisible)& ent, |
206 | const Interface_ShareTool& , Handle(Interface_Check)& ach) const |
207 | { |
208 | Standard_Integer res = 0; |
209 | Standard_Integer nb = ent->NbDisplayedEntities(); |
5b111128 |
210 | Handle(IGESData_ViewKindEntity) entcomp (ent); |
7fd59977 |
211 | for (Standard_Integer i = 1; i <= nb; i ++) { |
212 | Handle(IGESData_IGESEntity) displayed = ent->DisplayedEntity(i); |
213 | if (entcomp != displayed->View()) res ++; |
214 | } |
215 | if (!res) return; |
216 | char mess[80]; |
217 | sprintf(mess,"Mismatch for %d Entities displayed",res); |
218 | ach->AddFail(mess,"Mismatch for %d Entities displayed"); |
219 | } |
220 | |
221 | void IGESDraw_ToolViewsVisible::OwnWhenDelete |
222 | (const Handle(IGESDraw_ViewsVisible)& ent) const |
223 | { |
224 | Handle(IGESData_HArray1OfIGESEntity) tempDisplayEntities; |
225 | ent->InitImplied (tempDisplayEntities); |
226 | } |
227 | |
228 | void IGESDraw_ToolViewsVisible::OwnDump |
229 | (const Handle(IGESDraw_ViewsVisible)& ent, const IGESData_IGESDumper& dumper, |
230 | const Handle(Message_Messenger)& S, const Standard_Integer level) const |
231 | { |
232 | S << "IGESDraw_ViewsVisible" << endl; |
233 | |
234 | S << "Views Visible : "; |
235 | IGESData_DumpEntities(S,dumper ,level,1, ent->NbViews(),ent->ViewItem); |
236 | S << endl; |
237 | S << "Entities Displayed : "; |
238 | IGESData_DumpEntities |
239 | (S,dumper ,level,1, ent->NbDisplayedEntities(),ent->DisplayedEntity); |
240 | S << endl; |
241 | } |
242 | |
243 | Standard_Boolean IGESDraw_ToolViewsVisible::OwnCorrect |
244 | (const Handle(IGESDraw_ViewsVisible)& ent) const |
245 | { |
246 | // Les entites affichees doivent referencer <ent>. Elles ont priorite. |
247 | Standard_Boolean res = Standard_False; |
248 | Standard_Integer nb = ent->NbDisplayedEntities(); |
5b111128 |
249 | Handle(IGESData_ViewKindEntity) entcomp (ent); |
7fd59977 |
250 | for (Standard_Integer i = 1; i <= nb; i ++) { |
251 | Handle(IGESData_IGESEntity) displayed = ent->DisplayedEntity(i); |
252 | if (entcomp != displayed->View()) res = Standard_True; |
253 | } |
254 | if (!res) return res; |
255 | Handle(IGESData_HArray1OfIGESEntity) nulDisplayEntities; |
256 | ent->InitImplied (nulDisplayEntities); |
257 | return res; |
258 | } |