0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / IGESSolid / IGESSolid_ToolTorus.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_ToolTorus.hxx>
30 #include <IGESSolid_Torus.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_ToolTorus::IGESSolid_ToolTorus ()    {  }
39
40
41 void  IGESSolid_ToolTorus::ReadOwnParams
42   (const Handle(IGESSolid_Torus)& ent,
43    const Handle(IGESData_IGESReaderData)& /* IR */, IGESData_ParamReader& PR) const
44 {
45   Standard_Real r1, r2;
46   Standard_Real tempreal;
47   gp_XYZ tempPoint, tempAxis;
48   //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
49
50   PR.ReadReal(PR.Current(), "Radius of revolution", r1); //szv#4:S4163:12Mar99 `st=` not needed
51   PR.ReadReal(PR.Current(), "Radius of disc", r2); //szv#4:S4163:12Mar99 `st=` not needed
52
53   if (PR.DefinedElseSkip())
54     {
55       //st = PR.ReadReal(PR.Current(), "Center Point (X)", tempreal); //szv#4:S4163:12Mar99 moved in if
56       if (PR.ReadReal(PR.Current(), "Center Point (X)", tempreal))
57         tempPoint.SetX(tempreal);
58     }
59   else  tempPoint.SetX(0.0);
60
61   if (PR.DefinedElseSkip())
62     {
63       //st = PR.ReadReal(PR.Current(), "Center Point (Y)", tempreal); //szv#4:S4163:12Mar99 moved in if
64       if (PR.ReadReal(PR.Current(), "Center Point (Y)", tempreal))
65         tempPoint.SetY(tempreal);
66     }
67   else  tempPoint.SetY(0.0);
68
69   if (PR.DefinedElseSkip())
70     {
71       //st = PR.ReadReal(PR.Current(), "Center Point (Z)", tempreal); //szv#4:S4163:12Mar99 moved in if
72       if (PR.ReadReal(PR.Current(), "Center Point (Z)", tempreal))
73         tempPoint.SetZ(tempreal);
74     }
75   else  tempPoint.SetZ(0.0);
76
77   if (PR.DefinedElseSkip())
78     {
79       //st = PR.ReadReal(PR.Current(), "Axis direction (I)", tempreal); //szv#4:S4163:12Mar99 moved in if
80       if (PR.ReadReal(PR.Current(), "Axis direction (I)", tempreal))
81         tempAxis.SetX(tempreal);
82     }
83   else  tempAxis.SetX(0.0);
84
85   if (PR.DefinedElseSkip())
86     {
87       //st = PR.ReadReal(PR.Current(), "Axis direction (J)", tempreal); //szv#4:S4163:12Mar99 moved in if
88       if (PR.ReadReal(PR.Current(), "Axis direction (J)", tempreal))
89         tempAxis.SetY(tempreal);
90     }
91   else  tempAxis.SetY(0.0);
92
93   if (PR.DefinedElseSkip())
94     {
95       //st = PR.ReadReal(PR.Current(), "Axis direction (K)", tempreal); //szv#4:S4163:12Mar99 moved in if
96       if (PR.ReadReal(PR.Current(), "Axis direction (K)", tempreal))
97         tempAxis.SetZ(tempreal);
98     }
99   else  tempAxis.SetZ(1.0);
100
101   DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
102   ent->Init (r1, r2, tempPoint, tempAxis);
103   Standard_Real eps = 1.E-05;
104   if (!tempAxis.IsEqual(ent->Axis().XYZ(),eps))
105     PR.AddWarning("Axis poorly unitary, normalized");
106 }
107
108 void  IGESSolid_ToolTorus::WriteOwnParams
109   (const Handle(IGESSolid_Torus)& ent, IGESData_IGESWriter& IW) const
110 {
111   IW.Send(ent->MajorRadius());
112   IW.Send(ent->DiscRadius());
113   IW.Send(ent->AxisPoint().X());
114   IW.Send(ent->AxisPoint().Y());
115   IW.Send(ent->AxisPoint().Z());
116   IW.Send(ent->Axis().X());
117   IW.Send(ent->Axis().Y());
118   IW.Send(ent->Axis().Z());
119 }
120
121 void  IGESSolid_ToolTorus::OwnShared
122   (const Handle(IGESSolid_Torus)& /* ent */, Interface_EntityIterator& /* iter */) const
123 {
124 }
125
126 void  IGESSolid_ToolTorus::OwnCopy
127   (const Handle(IGESSolid_Torus)& another,
128    const Handle(IGESSolid_Torus)& ent, Interface_CopyTool& /* TC */) const
129 {
130   ent->Init (another->MajorRadius(), another->DiscRadius(),
131              another->AxisPoint().XYZ(), another->Axis().XYZ());
132 }
133
134 IGESData_DirChecker  IGESSolid_ToolTorus::DirChecker
135   (const Handle(IGESSolid_Torus)& /* ent */ ) const
136 {
137   IGESData_DirChecker DC(160, 0);
138
139   DC.Structure  (IGESData_DefVoid);
140   DC.LineFont   (IGESData_DefAny);
141   DC.Color      (IGESData_DefAny);
142
143   DC.UseFlagRequired (0);
144   DC.HierarchyStatusIgnored ();
145   return DC;
146 }
147
148 void  IGESSolid_ToolTorus::OwnCheck
149   (const Handle(IGESSolid_Torus)& ent,
150    const Interface_ShareTool& , Handle(Interface_Check)& ach) const
151 {
152   if (ent->MajorRadius() <= 0.0)
153     ach->AddFail("Radius of revolution : Not Positive");
154   if (ent->DiscRadius() <= 0.0)
155     ach->AddFail("Radius of disc : Not Positive");
156   if (ent->DiscRadius() >= ent->MajorRadius())
157     ach->AddFail("Radius of disc : is not Less than Radius of revolution");
158 }
159
160 void  IGESSolid_ToolTorus::OwnDump
161   (const Handle(IGESSolid_Torus)& ent, const IGESData_IGESDumper& /* dumper */,
162    Standard_OStream& S, const Standard_Integer level) const
163 {
164   S << "IGESSolid_Torus\n"
165     << "Radius of revolution : " << ent->MajorRadius() << "  "
166     << "Radius of the disc   : " << ent->DiscRadius()  << "\n"
167     << "Center Point   : ";
168   IGESData_DumpXYZL(S,level, ent->AxisPoint(), ent->Location());
169   S << "\nAxis direction : ";
170   IGESData_DumpXYZL(S,level, ent->Axis(), ent->VectorLocation());
171   S << std::endl;
172 }