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 //--------------------------------------------------------------------
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_ParamReader.hxx>
27 #include <IGESSolid_Cylinder.hxx>
28 #include <IGESSolid_ToolCylinder.hxx>
29 #include <Interface_Check.hxx>
30 #include <Interface_CopyTool.hxx>
31 #include <Interface_EntityIterator.hxx>
32 #include <Interface_ShareTool.hxx>
33 #include <Message_Messenger.hxx>
34 #include <Standard_DomainError.hxx>
36 IGESSolid_ToolCylinder::IGESSolid_ToolCylinder () { }
39 void IGESSolid_ToolCylinder::ReadOwnParams
40 (const Handle(IGESSolid_Cylinder)& ent,
41 const Handle(IGESData_IGESReaderData)& /* IR */, IGESData_ParamReader& PR) const
43 Standard_Real tempHeight, tempRadius, tempreal;
44 gp_XYZ tempCenter, tempAxis;
45 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
47 PR.ReadReal(PR.Current(), "Height", tempHeight); //szv#4:S4163:12Mar99 `st=` not needed
49 PR.ReadReal(PR.Current(), "Radius", tempRadius); //szv#4:S4163:12Mar99 `st=` not needed
51 if (PR.DefinedElseSkip())
53 //st = PR.ReadReal(PR.Current(), "Face center (X)", tempreal); //szv#4:S4163:12Mar99 moved in if
54 if (PR.ReadReal(PR.Current(), "Face center (X)", tempreal))
55 tempCenter.SetX(tempreal);
57 else tempCenter.SetX(0.0);
59 if (PR.DefinedElseSkip())
61 //st = PR.ReadReal(PR.Current(), "Face center (Y)", tempreal); //szv#4:S4163:12Mar99 moved in if
62 if (PR.ReadReal(PR.Current(), "Face center (Y)", tempreal))
63 tempCenter.SetY(tempreal);
65 else tempCenter.SetY(0.0);
67 if (PR.DefinedElseSkip())
69 //st = PR.ReadReal(PR.Current(), "Face center (Z)", tempreal); //szv#4:S4163:12Mar99 moved in if
70 if (PR.ReadReal(PR.Current(), "Face center (Z)", tempreal))
71 tempCenter.SetZ(tempreal);
73 else tempCenter.SetZ(0.0);
75 if (PR.DefinedElseSkip())
77 //st = PR.ReadReal(PR.Current(), "Axis direction (I)", tempreal); //szv#4:S4163:12Mar99 moved in if
78 if (PR.ReadReal(PR.Current(), "Axis direction (I)", tempreal))
79 tempAxis.SetX(tempreal);
81 else tempAxis.SetX(0.0);
83 if (PR.DefinedElseSkip())
85 //st = PR.ReadReal(PR.Current(), "Axis direction (J)", tempreal); //szv#4:S4163:12Mar99 moved in if
86 if (PR.ReadReal(PR.Current(), "Axis direction (J)", tempreal))
87 tempAxis.SetY(tempreal);
89 else tempAxis.SetY(0.0);
91 if (PR.DefinedElseSkip())
93 //st = PR.ReadReal(PR.Current(), "Axis direction (K)", tempreal); //szv#4:S4163:12Mar99 moved in if
94 if (PR.ReadReal(PR.Current(), "Axis direction (K)", tempreal))
95 tempAxis.SetZ(tempreal);
97 else tempAxis.SetZ(1.0);
99 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
101 (tempHeight, tempRadius, tempCenter, tempAxis);
102 Standard_Real eps = 1.E-05;
103 if (!tempAxis.IsEqual(ent->Axis().XYZ(),eps)) PR.AddWarning
104 ("Axis poorly unitary, normalized");
107 void IGESSolid_ToolCylinder::WriteOwnParams
108 (const Handle(IGESSolid_Cylinder)& ent, IGESData_IGESWriter& IW) const
110 IW.Send(ent->Height());
111 IW.Send(ent->Radius());
112 IW.Send(ent->FaceCenter().X());
113 IW.Send(ent->FaceCenter().Y());
114 IW.Send(ent->FaceCenter().Z());
115 IW.Send(ent->Axis().X());
116 IW.Send(ent->Axis().Y());
117 IW.Send(ent->Axis().Z());
120 void IGESSolid_ToolCylinder::OwnShared
121 (const Handle(IGESSolid_Cylinder)& /* ent */, Interface_EntityIterator& /* iter */) const
125 void IGESSolid_ToolCylinder::OwnCopy
126 (const Handle(IGESSolid_Cylinder)& another,
127 const Handle(IGESSolid_Cylinder)& ent, Interface_CopyTool& /* TC */) const
130 (another->Height(), another->Radius(), another->FaceCenter().XYZ(),
131 another->Axis().XYZ());
134 IGESData_DirChecker IGESSolid_ToolCylinder::DirChecker
135 (const Handle(IGESSolid_Cylinder)& /* ent */ ) const
137 IGESData_DirChecker DC(154, 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_ToolCylinder::OwnCheck
149 (const Handle(IGESSolid_Cylinder)& ent,
150 const Interface_ShareTool& , Handle(Interface_Check)& ach) const
152 if (ent->Height() <= 0.0)
153 ach->AddFail("Height : Value < 0");
154 if (ent->Radius() <= 0.0)
155 ach->AddFail("Radius : Value < 0");
158 void IGESSolid_ToolCylinder::OwnDump
159 (const Handle(IGESSolid_Cylinder)& ent, const IGESData_IGESDumper& /* dumper */,
160 Standard_OStream& S, const Standard_Integer level) const
163 // Standard_Boolean locprint = (ent->HasTransf() && level >=6);
164 // gp_Pnt TCenter = ent->TransformedFaceCenter();
165 // gp_Dir TAxis = ent->TransformedAxis();
167 S << "IGESSolid_Cylinder\n"
168 << "Height : " << ent->Height() << " "
169 << "Radius : " << ent->Radius() << "\n"
171 IGESData_DumpXYZL(S,level, ent->FaceCenter(), ent->Location());
173 IGESData_DumpXYZL(S,level, ent->Axis(), ent->VectorLocation());