0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / IGESBasic / IGESBasic_ToolSubfigureDef.cxx
1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 //--------------------------------------------------------------------
17 //--------------------------------------------------------------------
18
19 #include <IGESBasic_SubfigureDef.hxx>
20 #include <IGESBasic_ToolSubfigureDef.hxx>
21 #include <IGESData_DirChecker.hxx>
22 #include <IGESData_Dump.hxx>
23 #include <IGESData_HArray1OfIGESEntity.hxx>
24 #include <IGESData_IGESDumper.hxx>
25 #include <IGESData_IGESEntity.hxx>
26 #include <IGESData_IGESReaderData.hxx>
27 #include <IGESData_IGESWriter.hxx>
28 #include <IGESData_ParamReader.hxx>
29 #include <Interface_Check.hxx>
30 #include <Interface_CopyTool.hxx>
31 #include <Interface_EntityIterator.hxx>
32 #include <Interface_Macros.hxx>
33 #include <Interface_ShareTool.hxx>
34 #include <Message_Msg.hxx>
35 #include <Standard_DomainError.hxx>
36 #include <TCollection_HAsciiString.hxx>
37
38 // MGE 03/08/98
39 IGESBasic_ToolSubfigureDef::IGESBasic_ToolSubfigureDef ()    {  }
40
41
42 void  IGESBasic_ToolSubfigureDef::ReadOwnParams
43   (const Handle(IGESBasic_SubfigureDef)& ent,
44    const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
45 {
46   // MGE 03/08/98
47   // Building of messages
48   //========================================
49 //  Message_Msg Msg208("XSTEP_208");
50   Message_Msg Msg209("XSTEP_209");
51 //  Message_Msg Msg210("XSTEP_210");
52 //  Message_Msg Msg211("XSTEP_211");
53   //========================================
54
55   Standard_Integer tempDepth;
56   Handle(TCollection_HAsciiString) tempName;
57   //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
58   Standard_Integer nbval = 0;
59   Handle(IGESData_HArray1OfIGESEntity)  EntArray;
60
61   if(!PR.ReadInteger(PR.Current(),tempDepth)){ //szv#4:S4163:12Mar99 `st=` not needed
62     Message_Msg Msg208("XSTEP_208");
63     PR.SendFail(Msg208);
64   }
65   PR.ReadText(PR.Current(),Msg209,tempName); //szv#4:S4163:12Mar99 `st=` not needed
66   if (PR.ReadInteger( PR.Current(), nbval)) { //szv#4:S4163:12Mar99 `st=` not needed
67     Message_Msg Msg211("XSTEP_211");
68     PR.ReadEnts (IR,PR.CurrentList(nbval),Msg211,EntArray); //szv#4:S4163:12Mar99 `st=` not needed
69   }
70   else{
71     Message_Msg Msg210("XSTEP_210");
72     PR.SendFail(Msg210);
73   }
74   DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
75   ent->Init(tempDepth,tempName,EntArray);
76 }
77
78 void  IGESBasic_ToolSubfigureDef::WriteOwnParams
79   (const Handle(IGESBasic_SubfigureDef)& ent, IGESData_IGESWriter& IW) const
80 {
81   Standard_Integer nb = ent->NbEntities();
82
83   IW.Send(ent->Depth());
84   IW.Send(ent->Name());
85   IW.Send(nb);
86   for (Standard_Integer i = 1; i <= nb; i ++)
87     IW.Send(ent->AssociatedEntity(i));
88 }
89
90 void  IGESBasic_ToolSubfigureDef::OwnShared
91   (const Handle(IGESBasic_SubfigureDef)& ent, Interface_EntityIterator& iter) const
92 {
93   Standard_Integer nb = ent->NbEntities();
94   for (Standard_Integer i = 1; i <= nb; i ++)
95     iter.GetOneItem(ent->AssociatedEntity(i));
96 }
97
98 void  IGESBasic_ToolSubfigureDef::OwnCopy
99   (const Handle(IGESBasic_SubfigureDef)& another,
100    const Handle(IGESBasic_SubfigureDef)& ent, Interface_CopyTool& TC) const
101 {
102   Standard_Integer lower,upper;
103   Standard_Integer aDepth = another->Depth();
104   Handle(TCollection_HAsciiString) aName =
105     new TCollection_HAsciiString(another->Name());
106
107   lower = 1;
108   upper = another->NbEntities();
109   Handle(IGESData_HArray1OfIGESEntity)  EntArray = new
110     IGESData_HArray1OfIGESEntity(lower,upper);
111   for (Standard_Integer i = lower;i <= upper;i++)
112     {
113       DeclareAndCast(IGESData_IGESEntity,myentity,
114                      TC.Transferred(another->AssociatedEntity(i)));
115       EntArray->SetValue(i,myentity);
116     }
117   ent->Init(aDepth,aName,EntArray);
118 }
119
120 IGESData_DirChecker  IGESBasic_ToolSubfigureDef::DirChecker
121   (const Handle(IGESBasic_SubfigureDef)& ent ) const
122 {
123   IGESData_DirChecker DC(308,0);  //TypeNo. 308, Form no. 0
124   DC.Structure(IGESData_DefVoid);
125   if (ent->HierarchyStatus() == 1) DC.GraphicsIgnored(01);
126    // GraphicsIgnored if hierarchy status = 01
127   else
128     {
129       DC.BlankStatusIgnored();
130     }
131   DC.UseFlagRequired(02);
132   return DC;
133 }
134
135 void  IGESBasic_ToolSubfigureDef::OwnCheck
136   (const Handle(IGESBasic_SubfigureDef)& /* ent */,
137    const Interface_ShareTool& , Handle(Interface_Check)& /* ach */) const
138 {
139 }
140
141 void  IGESBasic_ToolSubfigureDef::OwnDump
142   (const Handle(IGESBasic_SubfigureDef)& ent, const IGESData_IGESDumper& dumper,
143    Standard_OStream& S, const Standard_Integer level) const
144 {
145   S << "IGESBasic_SubfigureDef\n"
146     << "Depth of the subfigure : " << ent->Depth() << "\n"
147     << "Name of subfigure : ";
148   IGESData_DumpString(S,ent->Name());
149   S << "\n"
150     << "The Associated Entities : ";
151   IGESData_DumpEntities(S,dumper,level,1,ent->NbEntities(),ent->AssociatedEntity);
152   S << std::endl;
153 }