0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / IGESData / IGESData_DefaultGeneral.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_DefaultGeneral.hxx>
17 #include <IGESData_DirChecker.hxx>
18 #include <IGESData_FreeFormatEntity.hxx>
19 #include <IGESData_IGESEntity.hxx>
20 #include <IGESData_Protocol.hxx>
21 #include <IGESData_UndefinedEntity.hxx>
22 #include <Interface_Check.hxx>
23 #include <Interface_CopyTool.hxx>
24 #include <Interface_EntityIterator.hxx>
25 #include <Interface_GeneralLib.hxx>
26 #include <Interface_Macros.hxx>
27 #include <Interface_ShareTool.hxx>
28 #include <Interface_UndefinedContent.hxx>
29 #include <Standard_Transient.hxx>
30 #include <Standard_Type.hxx>
31 #include <TColStd_HSequenceOfInteger.hxx>
32
33 IMPLEMENT_STANDARD_RTTIEXT(IGESData_DefaultGeneral,IGESData_GeneralModule)
34
35 IGESData_DefaultGeneral::IGESData_DefaultGeneral ()
36 {  Interface_GeneralLib::SetGlobal(this, IGESData::Protocol());  }
37
38     void  IGESData_DefaultGeneral::OwnSharedCase
39   (const Standard_Integer CN, const Handle(IGESData_IGESEntity)& ent,
40    Interface_EntityIterator& iter) const
41 {
42   if (CN == 0) return;
43   DeclareAndCast(IGESData_UndefinedEntity,anent,ent);
44   if (anent.IsNull()) return;
45   Handle(Interface_UndefinedContent) cont = anent->UndefinedContent();
46   Standard_Integer nb = cont->NbParams();
47   for (Standard_Integer i = 1; i <= nb; i ++) {
48     if (cont->IsParamEntity(i)) iter.GetOneItem (cont->ParamEntity(i));
49   }
50 }
51
52
53     IGESData_DirChecker  IGESData_DefaultGeneral::DirChecker
54   (const Standard_Integer , const Handle(IGESData_IGESEntity)& ) const 
55 {  IGESData_DirChecker dc; return dc;  }  // aucun critere specifique
56
57
58     void  IGESData_DefaultGeneral::OwnCheckCase
59   (const Standard_Integer , const Handle(IGESData_IGESEntity)& ,
60    const Interface_ShareTool& , Handle(Interface_Check)& ) const 
61 {  }  // aucun critere specifique
62
63
64     Standard_Boolean  IGESData_DefaultGeneral::NewVoid
65   (const Standard_Integer CN, Handle(Standard_Transient)& entto) const
66 {
67   entto.Nullify();
68   if (CN == 0) return Standard_False;
69   if (CN == 1) entto = new IGESData_UndefinedEntity;
70   if (CN == 2) entto = new IGESData_FreeFormatEntity;
71   return (!entto.IsNull());
72 }
73
74     void  IGESData_DefaultGeneral::OwnCopyCase
75   (const Standard_Integer CN,
76    const Handle(IGESData_IGESEntity)& entfrom,
77    const Handle(IGESData_IGESEntity)& entto,
78    Interface_CopyTool& TC) const 
79 {
80   if (CN == 0) return;
81   DeclareAndCast(IGESData_UndefinedEntity,enfr,entfrom);
82   DeclareAndCast(IGESData_UndefinedEntity,ento,entto);
83 //  ShallowCopy aura passe DirStatus
84 //  transmettre les contenus des UndefinedContents
85   Handle(Interface_UndefinedContent) cont = new Interface_UndefinedContent;
86   cont->GetFromAnother(enfr->UndefinedContent(),TC);
87   ento->SetNewContent (cont);
88 //  FreeFormat, encore des choses
89   if (enfr->IsKind(STANDARD_TYPE(IGESData_FreeFormatEntity))) {
90     DeclareAndCast(IGESData_FreeFormatEntity,enf,entfrom);
91     DeclareAndCast(IGESData_FreeFormatEntity,ent,entto);
92     ent->ClearNegativePointers();
93     ent->AddNegativePointers(enf->NegativePointers());
94   }
95 }