1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 //--------------------------------------------------------------------
17 //--------------------------------------------------------------------
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>
38 IGESSolid_ToolTorus::IGESSolid_ToolTorus () { }
41 void IGESSolid_ToolTorus::ReadOwnParams
42 (const Handle(IGESSolid_Torus)& ent,
43 const Handle(IGESData_IGESReaderData)& /* IR */, IGESData_ParamReader& PR) const
46 Standard_Real tempreal;
47 gp_XYZ tempPoint, tempAxis;
48 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
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
53 if (PR.DefinedElseSkip())
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);
59 else tempPoint.SetX(0.0);
61 if (PR.DefinedElseSkip())
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);
67 else tempPoint.SetY(0.0);
69 if (PR.DefinedElseSkip())
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);
75 else tempPoint.SetZ(0.0);
77 if (PR.DefinedElseSkip())
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);
83 else tempAxis.SetX(0.0);
85 if (PR.DefinedElseSkip())
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);
91 else tempAxis.SetY(0.0);
93 if (PR.DefinedElseSkip())
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);
99 else tempAxis.SetZ(1.0);
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");
108 void IGESSolid_ToolTorus::WriteOwnParams
109 (const Handle(IGESSolid_Torus)& ent, IGESData_IGESWriter& IW) const
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());
121 void IGESSolid_ToolTorus::OwnShared
122 (const Handle(IGESSolid_Torus)& /* ent */, Interface_EntityIterator& /* iter */) const
126 void IGESSolid_ToolTorus::OwnCopy
127 (const Handle(IGESSolid_Torus)& another,
128 const Handle(IGESSolid_Torus)& ent, Interface_CopyTool& /* TC */) const
130 ent->Init (another->MajorRadius(), another->DiscRadius(),
131 another->AxisPoint().XYZ(), another->Axis().XYZ());
134 IGESData_DirChecker IGESSolid_ToolTorus::DirChecker
135 (const Handle(IGESSolid_Torus)& /* ent */ ) const
137 IGESData_DirChecker DC(160, 0);
139 DC.Structure (IGESData_DefVoid);
140 DC.LineFont (IGESData_DefAny);
141 DC.Color (IGESData_DefAny);
143 DC.UseFlagRequired (0);
144 DC.HierarchyStatusIgnored ();
148 void IGESSolid_ToolTorus::OwnCheck
149 (const Handle(IGESSolid_Torus)& ent,
150 const Interface_ShareTool& , Handle(Interface_Check)& ach) const
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");
160 void IGESSolid_ToolTorus::OwnDump
161 (const Handle(IGESSolid_Torus)& ent, const IGESData_IGESDumper& /* dumper */,
162 const Handle(Message_Messenger)& S, const Standard_Integer level) const
164 S << "IGESSolid_Torus" << Message_EndLine;
166 S << "Radius of revolution : " << ent->MajorRadius() << " ";
167 S << "Radius of the disc : " << ent->DiscRadius() << Message_EndLine;
168 S << "Center Point : ";
169 IGESData_DumpXYZL(S,level, ent->AxisPoint(), ent->Location());
170 S << Message_EndLine << "Axis direction : ";
171 IGESData_DumpXYZL(S,level, ent->Axis(), ent->VectorLocation());
172 S << Message_EndLine;