0022627: Change OCCT memory management defaults
[occt.git] / src / IGESBasic / IGESBasic_ToolSingularSubfigure.cxx
1 //--------------------------------------------------------------------
2 //
3 //  File Name : IGESBasic_SingularSubfigure.cxx
4 //  Date      :
5 //  Author    : CKY / Contract Toubro-Larsen
6 //  Copyright : MATRA-DATAVISION 1993
7 //
8 //--------------------------------------------------------------------
9
10 #include <IGESBasic_ToolSingularSubfigure.ixx>
11 #include <IGESData_ParamCursor.hxx>
12 #include <gp_XYZ.hxx>
13 #include <IGESBasic_SubfigureDef.hxx>
14 #include <IGESData_Dump.hxx>
15 #include <gp_GTrsf.hxx>
16 #include <Interface_Macros.hxx>
17
18 // MGE 03/08/98
19 #include <Message_Msg.hxx>
20 #include <IGESData_Status.hxx>
21
22
23 IGESBasic_ToolSingularSubfigure::IGESBasic_ToolSingularSubfigure ()    {  }
24
25
26 void  IGESBasic_ToolSingularSubfigure::ReadOwnParams
27   (const Handle(IGESBasic_SingularSubfigure)& ent,
28    const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
29 {
30   // MGE 03/08/98
31   // Building of messages
32   //========================================
33   Message_Msg Msg213("XSTEP_213");
34   //========================================
35
36   //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
37   Standard_Boolean temphasscale;
38   Standard_Real tempScaleFactor;
39   Handle(IGESBasic_SubfigureDef) tempSubfigureDef;
40   gp_XYZ tempTranslation;
41   IGESData_Status aStatus;
42
43   if(!PR.ReadEntity(IR,PR.Current(),aStatus,STANDARD_TYPE(IGESBasic_SubfigureDef),tempSubfigureDef)){ //szv#4:S4163:12Mar99 `st=` not needed;
44     Message_Msg Msg212("XSTEP_212");
45     switch(aStatus) {
46     case IGESData_ReferenceError: {  
47       Message_Msg Msg216 ("IGES_216");
48       Msg212.Arg(Msg216.Value());
49       PR.SendFail(Msg212);
50       break; }
51     case IGESData_EntityError: {
52       Message_Msg Msg217 ("IGES_217");
53       Msg212.Arg(Msg217.Value());
54       PR.SendFail(Msg212);
55       break; }
56     case IGESData_TypeError: {
57       Message_Msg Msg218 ("IGES_218");
58       Msg212.Arg(Msg218.Value());
59       PR.SendFail(Msg212);
60       break; }
61     default:{
62     }
63     }
64   }
65   PR.ReadXYZ (PR.CurrentList(1, 3),Msg213,tempTranslation); //szv#4:S4163:12Mar99 `st=` not needed
66 //st = PR.ReadEntity(IR,PR.Current(),"Subfigure definition entity",
67 //                   STANDARD_TYPE(IGESBasic_SubfigureDef), tempSubfigureDef);
68 //st = PR.ReadXYZ
69 //  (PR.CurrentList(1, 3),"Translation data",tempTranslation);
70   if (PR.DefinedElseSkip())
71     {
72       //st = PR.ReadReal(PR.Current(),Msg214,tempScaleFactor); //szv#4:S4163:12Mar99 moved down
73       //st = PR.ReadReal(PR.Current(),"Scale Factor",tempScaleFactor); 
74       temphasscale = PR.ReadReal(PR.Current(),tempScaleFactor);
75       if (!temphasscale){
76         Message_Msg Msg214("XSTEP_214");
77         PR.SendFail(Msg214);
78       }
79     }
80   else
81     {
82       tempScaleFactor = 1.0;
83       temphasscale = Standard_False;
84     }
85
86   DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
87   ent->Init
88     (tempSubfigureDef,tempTranslation,temphasscale,tempScaleFactor);
89 }
90
91 void  IGESBasic_ToolSingularSubfigure::WriteOwnParams
92   (const Handle(IGESBasic_SingularSubfigure)& ent, IGESData_IGESWriter& IW) const
93 {
94   IW.Send(ent->Subfigure());
95   IW.Send(ent->Translation().X());
96   IW.Send(ent->Translation().Y());
97   IW.Send(ent->Translation().Z());
98   if (ent->HasScaleFactor()) IW.Send(ent->ScaleFactor());
99   else IW.SendVoid();
100 }
101
102 void  IGESBasic_ToolSingularSubfigure::OwnShared
103   (const Handle(IGESBasic_SingularSubfigure)& ent, Interface_EntityIterator& iter) const
104 {
105   iter.GetOneItem(ent->Subfigure());
106 }
107
108 void  IGESBasic_ToolSingularSubfigure::OwnCopy
109   (const Handle(IGESBasic_SingularSubfigure)& another,
110    const Handle(IGESBasic_SingularSubfigure)& ent, Interface_CopyTool& TC) const
111 {
112   gp_XYZ aTranslation;
113   Standard_Boolean ahasScale;
114   Standard_Real aScale;
115
116   DeclareAndCast
117     (IGESBasic_SubfigureDef,aSubfigureDef,TC.Transferred(another->Subfigure()));
118   aTranslation  = another->Translation();
119   ahasScale     = another->HasScaleFactor();
120   aScale        = another->ScaleFactor();
121
122   ent->Init(aSubfigureDef,aTranslation,ahasScale,aScale);
123 }
124
125 IGESData_DirChecker  IGESBasic_ToolSingularSubfigure::DirChecker
126   (const Handle(IGESBasic_SingularSubfigure)& ent ) const
127 {
128   IGESData_DirChecker DC(408,0);  //TypeNo. 408, Form no. 0
129   DC.Structure(IGESData_DefVoid);
130   if (ent->HierarchyStatus() == 1)
131     DC.GraphicsIgnored(01);   // GraphicsIgnored if Hierarchy = 01
132   return DC;
133 }
134
135 void  IGESBasic_ToolSingularSubfigure::OwnCheck
136   (const Handle(IGESBasic_SingularSubfigure)& /* ent */,
137    const Interface_ShareTool& , Handle(Interface_Check)& /* ach */) const
138 {
139 }
140
141 void  IGESBasic_ToolSingularSubfigure::OwnDump
142   (const Handle(IGESBasic_SingularSubfigure)& ent, const IGESData_IGESDumper& dumper,
143    const Handle(Message_Messenger)& S, const Standard_Integer level) const
144 {
145   S << "IGESBasic_SingularSubfigure" << endl;
146
147   S << "Subfigure Definition Entity : " ;
148   dumper.Dump(ent->Subfigure(),S,(level <= 4) ? 0 : 1);
149   S << endl;
150   S << " Translation Data : ";
151   IGESData_DumpXYZL(S,level, ent->Translation(), ent->Location());
152   S << "  Scale Factors : " << ent->ScaleFactor() << endl;
153   S << endl;
154 }