0026583: Eliminate compile warnings obtained by building occt with vc14: declaration...
[occt.git] / src / IGESDimen / IGESDimen_ToolOrdinateDimension.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 <IGESData_DirChecker.hxx>
20 #include <IGESData_IGESDumper.hxx>
21 #include <IGESData_IGESReaderData.hxx>
22 #include <IGESData_IGESWriter.hxx>
23 #include <IGESData_ParamCursor.hxx>
24 #include <IGESData_ParamReader.hxx>
25 #include <IGESDimen_GeneralNote.hxx>
26 #include <IGESDimen_LeaderArrow.hxx>
27 #include <IGESDimen_OrdinateDimension.hxx>
28 #include <IGESDimen_ToolOrdinateDimension.hxx>
29 #include <IGESDimen_WitnessLine.hxx>
30 #include <Interface_Check.hxx>
31 #include <Interface_CopyTool.hxx>
32 #include <Interface_EntityIterator.hxx>
33 #include <Interface_Macros.hxx>
34 #include <Interface_ShareTool.hxx>
35 #include <Message_Messenger.hxx>
36 #include <Standard_DomainError.hxx>
37
38 IGESDimen_ToolOrdinateDimension::IGESDimen_ToolOrdinateDimension ()    {  }
39
40
41 void IGESDimen_ToolOrdinateDimension::ReadOwnParams
42   (const Handle(IGESDimen_OrdinateDimension)& theEnt,
43    const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
44 {
45   Handle(IGESDimen_GeneralNote) tempNote;
46   Handle(IGESDimen_WitnessLine) witLine;
47   Handle(IGESDimen_LeaderArrow) leadArr;
48   Standard_Boolean isLine=Standard_False;
49
50   PR.ReadEntity(IR,PR.Current(),"General Note",
51                 STANDARD_TYPE(IGESDimen_GeneralNote),tempNote);
52
53   if (theEnt->FormNumber() == 0)
54     {
55       Handle(IGESData_IGESEntity) ent;
56       if (!PR.ReadEntity(IR,PR.Current(),"Line or Leader", ent)) { }    // WARNING : Two possible Types allowed :
57       else if (ent->IsKind(STANDARD_TYPE(IGESDimen_WitnessLine)))
58         {
59           witLine = GetCasted(IGESDimen_WitnessLine,ent);
60           isLine = Standard_True;
61         }
62       else if (ent->IsKind(STANDARD_TYPE(IGESDimen_LeaderArrow)))
63         {
64           leadArr = GetCasted(IGESDimen_LeaderArrow,ent);
65           isLine = Standard_False;
66         }
67       else PR.AddFail("Line or Leader : Type is incorrect");
68     }
69   else
70     {
71       PR.ReadEntity(IR, PR.Current(), "Line",
72                     STANDARD_TYPE(IGESDimen_WitnessLine), witLine);
73       PR.ReadEntity(IR, PR.Current(), "Leader",
74                     STANDARD_TYPE(IGESDimen_LeaderArrow), leadArr);
75     }
76
77   DirChecker(theEnt).CheckTypeAndForm(PR.CCheck(), theEnt);
78   theEnt->Init ( tempNote, isLine, witLine, leadArr);
79 }
80
81 void IGESDimen_ToolOrdinateDimension::WriteOwnParams
82   (const Handle(IGESDimen_OrdinateDimension)& ent, IGESData_IGESWriter& IW) const
83 {
84   IW.Send(ent->Note());
85   if (ent->FormNumber() == 0)  // either WitnessLine or  LeaderArrow
86     {
87       if (ent->IsLine())
88         IW.Send(ent->WitnessLine());
89       else
90         IW.Send(ent->Leader());
91     }
92   else                         // both   WitnessLine and LeaderArrow
93     {
94       IW.Send(ent->WitnessLine());
95       IW.Send(ent->Leader());
96     }
97 }
98
99 void  IGESDimen_ToolOrdinateDimension::OwnShared
100   (const Handle(IGESDimen_OrdinateDimension)& ent, Interface_EntityIterator& iter) const
101 {
102   iter.GetOneItem(ent->Note());
103   iter.GetOneItem(ent->WitnessLine());
104   iter.GetOneItem(ent->Leader());
105 }
106
107 void IGESDimen_ToolOrdinateDimension::OwnCopy
108   (const Handle(IGESDimen_OrdinateDimension)& another,
109    const Handle(IGESDimen_OrdinateDimension)& ent, Interface_CopyTool& TC) const
110 {
111   DeclareAndCast(IGESDimen_GeneralNote, tempNote,
112                  TC.Transferred(another->Note()));
113   DeclareAndCast(IGESDimen_WitnessLine, witLine,
114                  TC.Transferred(another->WitnessLine()));
115   DeclareAndCast(IGESDimen_LeaderArrow, leadArr,
116                  TC.Transferred(another->Leader()));
117   ent->Init(tempNote, another->IsLine(), witLine, leadArr);
118 }
119
120 IGESData_DirChecker IGESDimen_ToolOrdinateDimension::DirChecker
121   (const Handle(IGESDimen_OrdinateDimension)& /*ent*/) const
122 {
123   IGESData_DirChecker DC(218, 0, 1);
124   DC.Structure(IGESData_DefVoid);
125   DC.LineFont(IGESData_DefAny);
126   DC.LineWeight(IGESData_DefValue);
127   DC.Color(IGESData_DefAny);
128
129   DC.UseFlagRequired (1);
130
131   return DC;
132 }
133
134 void IGESDimen_ToolOrdinateDimension::OwnCheck
135   (const Handle(IGESDimen_OrdinateDimension)& ent,
136    const Interface_ShareTool& , Handle(Interface_Check)& ach) const
137 {
138   Standard_Boolean nowitnes = ent->WitnessLine().IsNull();
139   Standard_Boolean noleader = ent->Leader().IsNull();
140   if (nowitnes && noleader) ach->AddFail
141     ("Neither WitnessLine nor LeaderArrow is defined");
142   else if (ent->FormNumber() == 0) {
143     if (!nowitnes && !noleader) ach->AddFail
144       ("Form 0 cannot afford both WitnessLine and LeaderArrow");
145   }
146   else {
147     if (nowitnes || noleader) ach->AddFail
148       ("Form 1 requires both WtnessLine and LeaderArrow");
149   }
150 }
151
152 void IGESDimen_ToolOrdinateDimension::OwnDump
153   (const Handle(IGESDimen_OrdinateDimension)& ent, const IGESData_IGESDumper& dumper,
154    const Handle(Message_Messenger)& S, const Standard_Integer level) const
155 {
156   S << "IGESDimen_OrdinateDimension" << endl;
157   Standard_Integer sublevel = (level <= 4) ? 0 : 1;
158
159   S << "General Note : ";
160   dumper.Dump(ent->Note(),S, sublevel);
161   S << endl;
162   Handle(IGESDimen_WitnessLine) witLine = ent->WitnessLine();
163   Handle(IGESDimen_LeaderArrow) leadArr = ent->Leader();
164   if (!witLine.IsNull()) {
165     S << "Witness line : ";
166     dumper.Dump(witLine,S, sublevel);
167     S << endl;
168   }
169   if (!leadArr.IsNull()) {
170     S << "Leader arrow :";
171     dumper.Dump(leadArr,S, sublevel);
172     S << endl;
173   }
174 }