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 <IGESData_DirChecker.hxx>
20 #include <IGESData_Dump.hxx>
21 #include <IGESData_IGESDumper.hxx>
22 #include <IGESData_IGESReaderData.hxx>
23 #include <IGESData_IGESWriter.hxx>
24 #include <IGESData_ParamReader.hxx>
25 #include <IGESDraw_ToolViewsVisible.hxx>
26 #include <IGESDraw_ViewsVisible.hxx>
27 #include <Interface_Check.hxx>
28 #include <Interface_CopyTool.hxx>
29 #include <Interface_EntityIterator.hxx>
30 #include <Interface_Macros.hxx>
31 #include <Interface_ShareTool.hxx>
34 IGESDraw_ToolViewsVisible::IGESDraw_ToolViewsVisible () { }
37 void IGESDraw_ToolViewsVisible::ReadOwnParams
38 (const Handle(IGESDraw_ViewsVisible)& ent,
39 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
41 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
43 Standard_Integer tempNbViewsVisible, tempNbDisplayedEntities;
44 Handle(IGESDraw_HArray1OfViewKindEntity) tempViewEntities;
45 Handle(IGESData_HArray1OfIGESEntity) tempDisplayEntity;
47 //st = PR.ReadInteger(PR.Current(), "Number Of Views Visible",
48 //tempNbViewsVisible); //szv#4:S4163:12Mar99 moved in if
49 if (PR.ReadInteger(PR.Current(), "Number Of Views Visible", tempNbViewsVisible)) {
50 // Initialise HArray1 only if there is no error reading its Length
51 if (tempNbViewsVisible <= 0)
52 PR.AddFail("Number Of Views Visible : Not Positive");
53 else tempViewEntities = new IGESDraw_HArray1OfViewKindEntity (1, tempNbViewsVisible);
56 if (PR.DefinedElseSkip())
57 PR.ReadInteger(PR.Current(), "Number of Entities Displayed",
58 tempNbDisplayedEntities); //szv#4:S4163:12Mar99 `st=` not needed
60 tempNbDisplayedEntities = 0;
61 PR.AddWarning("Number of Entities Displayed : undefined, set to Zero");
63 // Initialise HArray1 only if there is no error reading its Length
64 if (tempNbDisplayedEntities < 0)
65 PR.AddFail ("Number Of Entities Displayed : Less than Zero");
66 // else if (tempNbDisplayedEntities > 0) {
68 if (! tempViewEntities.IsNull()) {
69 // Read the HArray1 only if its Length was read without any Error
71 for (I = 1; I <= tempNbViewsVisible; I++) {
72 Handle(IGESData_ViewKindEntity) tempViewEntity1;
73 //st = PR.ReadEntity(IR, PR.Current(), "View Entity",
74 //STANDARD_TYPE(IGESData_ViewKindEntity), tempViewEntity1); //szv#4:S4163:12Mar99 moved in if
75 if (PR.ReadEntity(IR, PR.Current(), "View Entity",
76 STANDARD_TYPE(IGESData_ViewKindEntity), tempViewEntity1))
77 tempViewEntities->SetValue(I, tempViewEntity1);
81 // Read the HArray1 only if its Length was read without any Error
82 if (tempNbDisplayedEntities > 0) {
83 PR.ReadEnts (IR,PR.CurrentList(tempNbDisplayedEntities),
84 "Displayed Entities",tempDisplayEntity); //szv#4:S4163:12Mar99 `st=` not needed
87 new IGESData_HArray1OfIGESEntity (1, tempNbDisplayedEntities);
89 Handle(IGESData_IGESEntity) tempEntity2;
91 for (I = 1; I <= tempNbDisplayedEntities; I++) {
92 st = PR.ReadEntity(IR, PR.Current(), "Displayed Entity",
94 if (st) tempDisplayEntity->SetValue(I, tempEntity2);
99 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
100 ent->Init(tempViewEntities, tempDisplayEntity);
103 void IGESDraw_ToolViewsVisible::WriteOwnParams
104 (const Handle(IGESDraw_ViewsVisible)& ent, IGESData_IGESWriter& IW) const
106 IW.Send(ent->NbViews());
107 IW.Send(ent->NbDisplayedEntities());
110 Standard_Integer up = ent->NbViews();
111 for (I = 1; I <= up; I++)
112 IW.Send(ent->ViewItem(I));
113 up = ent->NbDisplayedEntities();
114 for (I = 1; I <= up; I++)
115 IW.Send(ent->DisplayedEntity(I));
118 void IGESDraw_ToolViewsVisible::OwnShared
119 (const Handle(IGESDraw_ViewsVisible)& ent, Interface_EntityIterator& iter) const
121 Standard_Integer I,up;
123 for (I = 1; I <= up; I++)
124 iter.GetOneItem(ent->ViewItem(I));
125 // Displayed -> Implied
128 void IGESDraw_ToolViewsVisible::OwnImplied
129 (const Handle(IGESDraw_ViewsVisible)& ent, Interface_EntityIterator& iter) const
131 Standard_Integer I,up;
132 up = ent->NbDisplayedEntities();
133 for (I = 1; I <= up; I++)
134 iter.GetOneItem(ent->DisplayedEntity(I));
138 void IGESDraw_ToolViewsVisible::OwnCopy
139 (const Handle(IGESDraw_ViewsVisible)& another,
140 const Handle(IGESDraw_ViewsVisible)& ent, Interface_CopyTool& TC) const
142 Handle(IGESDraw_HArray1OfViewKindEntity) tempViewEntities =
143 new IGESDraw_HArray1OfViewKindEntity(1, another->NbViews());
144 Standard_Integer I, up;
145 up = another->NbViews();
146 for (I = 1; I <= up; I++) {
147 DeclareAndCast(IGESData_ViewKindEntity, tempView,
148 TC.Transferred(another->ViewItem(I)));
149 tempViewEntities->SetValue(I, tempView);
151 // Displayed -> Implied : mettre une liste vide par defaut
152 Handle(IGESData_HArray1OfIGESEntity) tempDisplayEntities;
153 ent->Init(tempViewEntities, tempDisplayEntities);
156 void IGESDraw_ToolViewsVisible::OwnRenew
157 (const Handle(IGESDraw_ViewsVisible)& another,
158 const Handle(IGESDraw_ViewsVisible)& ent, const Interface_CopyTool& TC) const
160 Interface_EntityIterator newdisp;
161 Standard_Integer I, up;
162 up = another->NbDisplayedEntities();
164 Handle(IGESData_HArray1OfIGESEntity) tempDisplayEntities;
165 Handle(Standard_Transient) anew;
166 for (I = 1; I <= up; I++) {
167 if (TC.Search (another->DisplayedEntity(I),anew)) newdisp.GetOneItem(anew);
170 up = newdisp.NbEntities(); I = 0;
171 if (up > 0) tempDisplayEntities = new IGESData_HArray1OfIGESEntity(1,up);
172 for (newdisp.Start(); newdisp.More(); newdisp.Next()) {
174 DeclareAndCast(IGESData_IGESEntity, tempEntity,newdisp.Value());
175 tempDisplayEntities->SetValue(I, tempEntity);
177 ent->InitImplied (tempDisplayEntities);
181 IGESData_DirChecker IGESDraw_ToolViewsVisible::DirChecker
182 (const Handle(IGESDraw_ViewsVisible)& /*ent*/) const
184 IGESData_DirChecker DC(402, 3);
185 DC.Structure(IGESData_DefVoid);
186 DC.LineFont(IGESData_DefVoid);
187 DC.LineWeight(IGESData_DefVoid);
188 DC.Color(IGESData_DefVoid);
189 DC.BlankStatusIgnored();
190 DC.SubordinateStatusRequired(0);
191 DC.UseFlagRequired(1);
192 DC.HierarchyStatusIgnored();
197 void IGESDraw_ToolViewsVisible::OwnCheck
198 (const Handle(IGESDraw_ViewsVisible)& ent,
199 const Interface_ShareTool& , Handle(Interface_Check)& ach) const
201 Standard_Integer res = 0;
202 Standard_Integer nb = ent->NbDisplayedEntities();
203 const Handle(IGESData_ViewKindEntity)& entcomp = ent;
204 for (Standard_Integer i = 1; i <= nb; i ++) {
205 Handle(IGESData_IGESEntity) displayed = ent->DisplayedEntity(i);
206 if (entcomp != displayed->View()) res ++;
210 sprintf(mess,"Mismatch for %d Entities displayed",res);
211 ach->AddFail(mess,"Mismatch for %d Entities displayed");
214 void IGESDraw_ToolViewsVisible::OwnWhenDelete
215 (const Handle(IGESDraw_ViewsVisible)& ent) const
217 Handle(IGESData_HArray1OfIGESEntity) tempDisplayEntities;
218 ent->InitImplied (tempDisplayEntities);
221 void IGESDraw_ToolViewsVisible::OwnDump
222 (const Handle(IGESDraw_ViewsVisible)& ent, const IGESData_IGESDumper& dumper,
223 Standard_OStream& S, const Standard_Integer level) const
225 S << "IGESDraw_ViewsVisible\n"
226 << "Views Visible : ";
227 IGESData_DumpEntities(S,dumper ,level,1, ent->NbViews(),ent->ViewItem);
229 << "Entities Displayed : ";
230 IGESData_DumpEntities(S,dumper ,level,1, ent->NbDisplayedEntities(),ent->DisplayedEntity);
234 Standard_Boolean IGESDraw_ToolViewsVisible::OwnCorrect
235 (const Handle(IGESDraw_ViewsVisible)& ent) const
237 // Les entites affichees doivent referencer <ent>. Elles ont priorite.
238 Standard_Boolean res = Standard_False;
239 Standard_Integer nb = ent->NbDisplayedEntities();
240 const Handle(IGESData_ViewKindEntity)& entcomp = ent;
241 for (Standard_Integer i = 1; i <= nb; i ++) {
242 Handle(IGESData_IGESEntity) displayed = ent->DisplayedEntity(i);
243 if (entcomp != displayed->View()) res = Standard_True;
245 if (!res) return res;
246 Handle(IGESData_HArray1OfIGESEntity) nulDisplayEntities;
247 ent->InitImplied (nulDisplayEntities);