0030895: Coding Rules - specify std namespace explicitly for std::cout and streams
[occt.git] / src / IGESSolid / IGESSolid_ToolConeFrustum.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 <gp_Dir.hxx>
20 #include <gp_Pnt.hxx>
21 #include <gp_XYZ.hxx>
22 #include <IGESData_DirChecker.hxx>
23 #include <IGESData_Dump.hxx>
24 #include <IGESData_IGESDumper.hxx>
25 #include <IGESData_IGESReaderData.hxx>
26 #include <IGESData_IGESWriter.hxx>
27 #include <IGESData_ParamCursor.hxx>
28 #include <IGESData_ParamReader.hxx>
29 #include <IGESSolid_ConeFrustum.hxx>
30 #include <IGESSolid_ToolConeFrustum.hxx>
31 #include <Interface_Check.hxx>
32 #include <Interface_CopyTool.hxx>
33 #include <Interface_EntityIterator.hxx>
34 #include <Interface_ShareTool.hxx>
35 #include <Message_Messenger.hxx>
36 #include <Standard_DomainError.hxx>
37
38 IGESSolid_ToolConeFrustum::IGESSolid_ToolConeFrustum ()    {  }
39
40
41 void  IGESSolid_ToolConeFrustum::ReadOwnParams
42   (const Handle(IGESSolid_ConeFrustum)& ent,
43    const Handle(IGESData_IGESReaderData)& /* IR */, IGESData_ParamReader& PR) const
44 {
45   Standard_Real tempHeight, tempR1, tempR2, tempreal;
46   gp_XYZ tempCenter, tempAxis;
47   //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
48
49   PR.ReadReal(PR.Current(), "Height", tempHeight); //szv#4:S4163:12Mar99 `st=` not needed
50
51   PR.ReadReal(PR.Current(), "Larger face radius", tempR1); //szv#4:S4163:12Mar99 `st=` not needed
52
53   if (PR.DefinedElseSkip())
54     PR.ReadReal(PR.Current(), "Smaller face radius", tempR2); //szv#4:S4163:12Mar99 `st=` not needed
55   else
56     tempR2 = 0.0;
57
58   if (PR.DefinedElseSkip())
59     {
60       //st = PR.ReadReal(PR.Current(), "Face center (X)", tempreal); //szv#4:S4163:12Mar99 moved in if
61       if (PR.ReadReal(PR.Current(), "Face center (X)", tempreal))
62         tempCenter.SetX(tempreal);
63     }
64   else  tempCenter.SetX(0.0);
65
66   if (PR.DefinedElseSkip())
67     {
68       //st = PR.ReadReal(PR.Current(), "Face center (Y)", tempreal); //szv#4:S4163:12Mar99 moved in if
69       if (PR.ReadReal(PR.Current(), "Face center (Y)", tempreal))
70         tempCenter.SetY(tempreal);
71     }
72   else  tempCenter.SetY(0.0);
73
74   if (PR.DefinedElseSkip())
75     {
76       //st = PR.ReadReal(PR.Current(), "Face center (Z)", tempreal); //szv#4:S4163:12Mar99 moved in if
77       if (PR.ReadReal(PR.Current(), "Face center (Z)", tempreal))
78         tempCenter.SetZ(tempreal);
79     }
80   else  tempCenter.SetZ(0.0);
81
82   if (PR.DefinedElseSkip())
83     {
84       //st = PR.ReadReal(PR.Current(), "Axis direction (I)", tempreal); //szv#4:S4163:12Mar99 moved in if
85       if (PR.ReadReal(PR.Current(), "Axis direction (I)", tempreal))
86         tempAxis.SetX(tempreal);
87     }
88   else  tempAxis.SetX(0.0);
89
90   if (PR.DefinedElseSkip())
91     {
92       //st = PR.ReadReal(PR.Current(), "Axis direction (J)", tempreal); //szv#4:S4163:12Mar99 moved in if
93       if (PR.ReadReal(PR.Current(), "Axis direction (J)", tempreal))
94         tempAxis.SetY(tempreal);
95     }
96   else  tempAxis.SetY(0.0);
97
98   if (PR.DefinedElseSkip())
99     {
100       //st = PR.ReadReal(PR.Current(), "Axis direction (K)", tempreal); //szv#4:S4163:12Mar99 moved in if
101       if (PR.ReadReal(PR.Current(), "Axis direction (K)", tempreal))
102         tempAxis.SetZ(tempreal);
103     }
104   else  tempAxis.SetZ(1.0);
105
106   DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
107   ent->Init
108     (tempHeight, tempR1, tempR2, tempCenter, tempAxis);
109   Standard_Real eps = 1.E-05;
110   if (!tempAxis.IsEqual(ent->Axis().XYZ(),eps)) PR.AddWarning
111     ("Axis poorly unitary, normalized");
112 }
113
114 void  IGESSolid_ToolConeFrustum::WriteOwnParams
115   (const Handle(IGESSolid_ConeFrustum)& ent, IGESData_IGESWriter& IW) const
116 {
117   IW.Send(ent->Height());
118   IW.Send(ent->LargerRadius());
119   IW.Send(ent->SmallerRadius());
120   IW.Send(ent->FaceCenter().X());
121   IW.Send(ent->FaceCenter().Y());
122   IW.Send(ent->FaceCenter().Z());
123   IW.Send(ent->Axis().X());
124   IW.Send(ent->Axis().Y());
125   IW.Send(ent->Axis().Z());
126 }
127
128 void  IGESSolid_ToolConeFrustum::OwnShared
129   (const Handle(IGESSolid_ConeFrustum)& /* ent */, Interface_EntityIterator& /* iter */) const
130 {
131 }
132
133 void  IGESSolid_ToolConeFrustum::OwnCopy
134   (const Handle(IGESSolid_ConeFrustum)& another,
135    const Handle(IGESSolid_ConeFrustum)& ent, Interface_CopyTool& /* TC */) const
136 {
137   ent->Init
138     (another->Height(), another->LargerRadius(), another->SmallerRadius(),
139      another->FaceCenter().XYZ(), another->Axis().XYZ());
140 }
141
142 IGESData_DirChecker  IGESSolid_ToolConeFrustum::DirChecker
143   (const Handle(IGESSolid_ConeFrustum)& /* ent */ ) const
144 {
145   IGESData_DirChecker DC(156, 0);
146
147   DC.Structure  (IGESData_DefVoid);
148   DC.LineFont   (IGESData_DefAny);
149   DC.Color      (IGESData_DefAny);
150
151   DC.UseFlagRequired (0);
152   DC.HierarchyStatusIgnored ();
153   return DC;
154 }
155
156 void  IGESSolid_ToolConeFrustum::OwnCheck
157   (const Handle(IGESSolid_ConeFrustum)& ent,
158    const Interface_ShareTool& , Handle(Interface_Check)& ach) const
159 {
160   if (ent->Height() <= 0.0)
161     ach->AddFail("Height : Value Not Positive");
162   if (ent->LargerRadius() <= 0.0)
163     ach->AddFail("Larger face radius : Value Not Positive");
164   if (ent->SmallerRadius() < 0.0)
165     ach->AddFail("Smaller face radius : Value Not Positive");
166   if (ent->SmallerRadius() > ent->LargerRadius())
167     ach->AddFail("Smaller face radius : is greater than Larger face radius");
168 }
169
170 void  IGESSolid_ToolConeFrustum::OwnDump
171   (const Handle(IGESSolid_ConeFrustum)& ent, const IGESData_IGESDumper& /* dumper */,
172    const Handle(Message_Messenger)& S, const Standard_Integer level) const
173 {
174   S << "IGESSolid_ConeFrustum" << Message_EndLine;
175
176   S << "Height : " << ent->Height() << "  ";
177   S << "Larger face Radius : "  << ent->LargerRadius() << "  ";
178   S << "Smaller face Radius : " << ent->SmallerRadius() << Message_EndLine;
179   S << "Face Center : ";
180   IGESData_DumpXYZL(S,level, ent->FaceCenter(), ent->Location());
181   S << Message_EndLine << "Axis : ";
182   IGESData_DumpXYZL(S,level, ent->Axis(), ent->VectorLocation());
183   S << Message_EndLine;
184 }