0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / IGESSolid / IGESSolid_ToolSphere.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_Pnt.hxx>
20 #include <gp_XYZ.hxx>
21 #include <IGESData_DirChecker.hxx>
22 #include <IGESData_Dump.hxx>
23 #include <IGESData_IGESDumper.hxx>
24 #include <IGESData_IGESReaderData.hxx>
25 #include <IGESData_IGESWriter.hxx>
26 #include <IGESData_ParamCursor.hxx>
27 #include <IGESData_ParamReader.hxx>
28 #include <IGESSolid_Sphere.hxx>
29 #include <IGESSolid_ToolSphere.hxx>
30 #include <Interface_Check.hxx>
31 #include <Interface_CopyTool.hxx>
32 #include <Interface_EntityIterator.hxx>
33 #include <Interface_ShareTool.hxx>
34 #include <Message_Messenger.hxx>
35 #include <Standard_DomainError.hxx>
36
37 IGESSolid_ToolSphere::IGESSolid_ToolSphere ()    {  }
38
39
40 void  IGESSolid_ToolSphere::ReadOwnParams
41   (const Handle(IGESSolid_Sphere)& ent,
42    const Handle(IGESData_IGESReaderData)& /* IR */, IGESData_ParamReader& PR) const
43 {
44   Standard_Real tempRadius, tempreal;
45   gp_XYZ tempCenter;
46   //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
47
48   PR.ReadReal(PR.Current(), "Radius", tempRadius); //szv#4:S4163:12Mar99 `st=` not needed
49
50   if (PR.DefinedElseSkip())
51     {
52       //st = PR.ReadReal(PR.Current(), "Center (X)", tempreal); //szv#4:S4163:12Mar99 moved in if
53       if (PR.ReadReal(PR.Current(), "Center (X)", tempreal))
54         tempCenter.SetX(tempreal);
55     }
56   else  tempCenter.SetX(0.0);
57
58   if (PR.DefinedElseSkip())
59     {
60       //st = PR.ReadReal(PR.Current(), "Center (Y)", tempreal); //szv#4:S4163:12Mar99 moved in if
61       if (PR.ReadReal(PR.Current(), "Center (Y)", tempreal))
62         tempCenter.SetY(tempreal);
63     }
64   else  tempCenter.SetY(0.0);
65
66   if (PR.DefinedElseSkip())
67     {
68       //st = PR.ReadReal(PR.Current(), "Center (Z)", tempreal); //szv#4:S4163:12Mar99 moved in if
69       if (PR.ReadReal(PR.Current(), "Center (Z)", tempreal))
70         tempCenter.SetZ(tempreal);
71     }
72   else  tempCenter.SetZ(0.0);
73
74   DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
75   ent->Init (tempRadius, tempCenter);
76 }
77
78 void  IGESSolid_ToolSphere::WriteOwnParams
79   (const Handle(IGESSolid_Sphere)& ent, IGESData_IGESWriter& IW) const
80 {
81   IW.Send(ent->Radius());
82   IW.Send(ent->Center().X());
83   IW.Send(ent->Center().Y());
84   IW.Send(ent->Center().Z());
85 }
86
87 void  IGESSolid_ToolSphere::OwnShared
88   (const Handle(IGESSolid_Sphere)& /* ent */, Interface_EntityIterator& /* iter */) const
89 {
90 }
91
92 void  IGESSolid_ToolSphere::OwnCopy
93   (const Handle(IGESSolid_Sphere)& another,
94    const Handle(IGESSolid_Sphere)& ent, Interface_CopyTool& /* TC */) const
95 {
96   ent->Init (another->Radius(), another->Center().XYZ());
97 }
98
99 IGESData_DirChecker  IGESSolid_ToolSphere::DirChecker
100   (const Handle(IGESSolid_Sphere)& /* ent */ ) const
101 {
102   IGESData_DirChecker DC(158, 0);
103
104   DC.Structure  (IGESData_DefVoid);
105   DC.LineFont   (IGESData_DefAny);
106   DC.Color      (IGESData_DefAny);
107
108   DC.UseFlagRequired (0);
109   DC.HierarchyStatusIgnored ();
110   return DC;
111 }
112
113 void  IGESSolid_ToolSphere::OwnCheck
114   (const Handle(IGESSolid_Sphere)& ent,
115    const Interface_ShareTool& , Handle(Interface_Check)& ach) const
116 {
117   if (ent->Radius() <= 0.0)
118     ach->AddFail("Radius : Not Positive");
119 }
120
121 void  IGESSolid_ToolSphere::OwnDump
122   (const Handle(IGESSolid_Sphere)& ent, const IGESData_IGESDumper& /* dumper */,
123    Standard_OStream& S, const Standard_Integer level) const
124 {
125   S << "IGESSolid_Sphere\n"
126     << "Radius : " << ent->Radius() << "\n"
127     << "Center : ";
128   IGESData_DumpXYZL(S,level, ent->Center(), ent->Location());
129   S << std::endl;
130 }