0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / IGESData / IGESData_GeneralModule.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14
15 #include <IGESData.hxx>
16 #include <IGESData_ColorEntity.hxx>
17 #include <IGESData_DirChecker.hxx>
18 #include <IGESData_GeneralModule.hxx>
19 #include <IGESData_IGESEntity.hxx>
20 #include <IGESData_LabelDisplayEntity.hxx>
21 #include <IGESData_LevelListEntity.hxx>
22 #include <IGESData_LineFontEntity.hxx>
23 #include <IGESData_Protocol.hxx>
24 #include <IGESData_TransfEntity.hxx>
25 #include <IGESData_ViewKindEntity.hxx>
26 #include <Interface_Check.hxx>
27 #include <Interface_CopyTool.hxx>
28 #include <Interface_EntityIterator.hxx>
29 #include <Interface_GeneralLib.hxx>
30 #include <Interface_Macros.hxx>
31 #include <Interface_ShareTool.hxx>
32 #include <Standard_Transient.hxx>
33 #include <Standard_Type.hxx>
34 #include <TCollection_HAsciiString.hxx>
35
36 IMPLEMENT_STANDARD_RTTIEXT(IGESData_GeneralModule,Interface_GeneralModule)
37
38 void  IGESData_GeneralModule::FillSharedCase
39   (const Standard_Integer CN, const Handle(Standard_Transient)& ent,
40    Interface_EntityIterator& iter) const 
41 {
42   DeclareAndCast(IGESData_IGESEntity,anent,ent);
43   if (anent.IsNull()) return;
44 //  .... Directory Part
45   iter.AddItem (anent->DirFieldEntity (3));
46   iter.AddItem (anent->DirFieldEntity (4));
47   iter.AddItem (anent->DirFieldEntity (5));
48   iter.AddItem (anent->DirFieldEntity (6));
49   iter.AddItem (anent->DirFieldEntity (7));
50   iter.AddItem (anent->DirFieldEntity (8));
51   iter.AddItem (anent->DirFieldEntity (13));
52
53 //  .... Own Parameters
54   OwnSharedCase (CN,anent,iter);
55
56 //  .... Properties
57   Interface_EntityIterator assocs = anent->Properties();
58   for (; assocs.More(); assocs.Next())  iter.AddItem (assocs.Value());
59 }
60
61     void  IGESData_GeneralModule::ListImpliedCase
62   (const Standard_Integer CN, const Handle(Standard_Transient)& ent,
63    Interface_EntityIterator& iter) const
64 {
65   DeclareAndCast(IGESData_IGESEntity,anent,ent);
66   if (anent.IsNull()) return;
67   OwnImpliedCase (CN,anent,iter);
68   Interface_EntityIterator assocs = anent->Associativities();
69   for (; assocs.More(); assocs.Next())  iter.AddItem (assocs.Value());
70 }
71
72
73     void  IGESData_GeneralModule::OwnImpliedCase
74   (const Standard_Integer , const Handle(IGESData_IGESEntity)& ,
75    Interface_EntityIterator& ) const 
76       {  }  // par defaut, rien  (redefinissable)
77
78
79
80     void  IGESData_GeneralModule::CheckCase
81   (const Standard_Integer CN, const Handle(Standard_Transient)& ent,
82    const Interface_ShareTool& shares, Handle(Interface_Check)& ach) const
83 {
84   DeclareAndCast(IGESData_IGESEntity,anent,ent);
85
86   IGESData_DirChecker dc = DirChecker(CN,anent);
87   dc.Check(ach,anent);
88   OwnCheckCase (CN,anent,shares,ach);
89 }
90
91
92     Standard_Boolean  IGESData_GeneralModule::CanCopy
93   (const Standard_Integer /*CN*/, const Handle(Standard_Transient)& /*ent*/) const
94       {  return Standard_True;  }
95
96     void  IGESData_GeneralModule::CopyCase
97   (const Standard_Integer CN, const Handle(Standard_Transient)& entfrom,
98    const Handle(Standard_Transient)& entto, Interface_CopyTool& TC) const 
99 {
100   DeclareAndCast(IGESData_IGESEntity,ento,entto);
101   DeclareAndCast(IGESData_IGESEntity,enfr,entfrom);
102 ////  ento->Clear();
103
104 // ...                Reprendre entete                ...
105 //?  ento->InitTypeAndForm (enfr->TypeNumber(), enfr->FormNumber());ShallowCopy
106   
107   if (enfr->DefLineFont() == IGESData_DefReference) ento->InitLineFont
108     (GetCasted(IGESData_LineFontEntity,    TC.Transferred(enfr->LineFont())));
109   else ento->InitLineFont (enfr->LineFont() , enfr->RankLineFont());
110
111   if (enfr->DefLevel() == IGESData_DefSeveral) ento->InitLevel
112     (GetCasted(IGESData_LevelListEntity,TC.Transferred(enfr->LevelList())),-1);
113   else ento->InitLevel (enfr->LevelList() , enfr->Level());
114
115   if (enfr->DefView() != IGESData_DefNone) ento->InitView
116     (GetCasted(IGESData_ViewKindEntity,    TC.Transferred(enfr->View())));
117
118   if (enfr->HasTransf()) ento->InitTransf
119     (GetCasted(IGESData_TransfEntity,      TC.Transferred(enfr->Transf())));
120
121   ento->InitStatus (enfr->BlankStatus() ,
122                     enfr->SubordinateStatus() ,
123                     enfr->UseFlag() ,
124                     enfr->HierarchyStatus() );
125
126   if (enfr->DefColor() == IGESData_DefReference) ento->InitColor
127     (GetCasted(IGESData_ColorEntity,TC.Transferred(enfr->Color())));
128   else ento->InitColor (enfr->Color() , enfr->RankColor());
129
130   if (enfr->HasShortLabel()) ento->SetLabel
131     (new TCollection_HAsciiString(enfr->ShortLabel()),
132      enfr->SubScriptNumber());
133   else ento->SetLabel (enfr->ShortLabel() , enfr->SubScriptNumber());
134
135 //  Directory Part : Miscellaneous
136   Handle(IGESData_IGESEntity) Structure;
137   if (enfr->HasStructure()) Structure =
138     GetCasted(IGESData_IGESEntity,         TC.Transferred(enfr->Structure()));
139   if (enfr->HasLabelDisplay()) ento->InitMisc
140     (Structure,
141      GetCasted(IGESData_LabelDisplayEntity,TC.Transferred(enfr->LabelDisplay())),
142      enfr->LineWeightNumber());
143   else ento->InitMisc
144     (Structure , enfr->LabelDisplay() , enfr->LineWeightNumber());
145
146 //  LineWeightValue, Res1, Res2 : through action of ShallowCopy ?
147
148   OwnCopyCase (CN,enfr,ento,TC);
149
150 //  ..  Properties
151   if (enfr->NbProperties() != 0) {
152     for (Interface_EntityIterator iter = enfr->Properties();
153          iter.More(); iter.Next()) {
154       ento->AddProperty
155         (GetCasted(IGESData_IGESEntity,TC.Transferred(iter.Value())));
156     }
157   }
158 }
159
160     void  IGESData_GeneralModule::RenewImpliedCase
161   (const Standard_Integer CN, const Handle(Standard_Transient)& entfrom,
162    const Handle(Standard_Transient)& entto, const Interface_CopyTool& TC) const
163 {
164   DeclareAndCast(IGESData_IGESEntity,ento,entto);
165   DeclareAndCast(IGESData_IGESEntity,enfr,entfrom);
166
167   OwnRenewCase (CN,enfr,ento,TC);
168
169 //  .. Associativities
170   if (enfr->NbAssociativities() != 0) {
171     for (Interface_EntityIterator iter = enfr->Associativities();
172          iter.More(); iter.Next()) {
173       Handle(Standard_Transient) anent = iter.Value();
174       Handle(Standard_Transient) newent;
175       if (TC.Search(anent,newent)) ento->AddAssociativity
176         (GetCasted(IGESData_IGESEntity,newent));
177     }
178   }
179 }
180
181     void  IGESData_GeneralModule::OwnRenewCase
182   (const Standard_Integer , const Handle(IGESData_IGESEntity)& ,
183    const Handle(IGESData_IGESEntity)& , const Interface_CopyTool& ) const
184      {  }
185
186     void  IGESData_GeneralModule::WhenDeleteCase
187   (const Standard_Integer CN, const Handle(Standard_Transient)& ent,
188    const Standard_Boolean ) const    // dispatched : ignored
189 {
190   DeclareAndCast(IGESData_IGESEntity,anent,ent);
191   if (anent.IsNull()) return;
192   anent->Clear();
193   OwnDeleteCase (CN,anent);
194 }
195
196     void  IGESData_GeneralModule::OwnDeleteCase
197   (const Standard_Integer , const Handle(IGESData_IGESEntity)& ) const
198       {  }  // par defaut, rien  (redefinissable)
199
200
201     Handle(TCollection_HAsciiString)  IGESData_GeneralModule::Name
202   (const Standard_Integer , const Handle(Standard_Transient)& ent,
203    const Interface_ShareTool& ) const
204 {
205   Handle(TCollection_HAsciiString) name;
206   DeclareAndCast(IGESData_IGESEntity,anent,ent);
207   if (anent.IsNull()) return name;
208   name = anent->NameValue ();
209   return name;
210 }