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_ParamCursor.hxx>
27 #include <IGESData_ParamReader.hxx>
28 #include <IGESSolid_Cylinder.hxx>
29 #include <IGESSolid_ToolCylinder.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>
37 IGESSolid_ToolCylinder::IGESSolid_ToolCylinder () { }
40 void IGESSolid_ToolCylinder::ReadOwnParams
41 (const Handle(IGESSolid_Cylinder)& ent,
42 const Handle(IGESData_IGESReaderData)& /* IR */, IGESData_ParamReader& PR) const
44 Standard_Real tempHeight, tempRadius, tempreal;
45 gp_XYZ tempCenter, tempAxis;
46 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
48 PR.ReadReal(PR.Current(), "Height", tempHeight); //szv#4:S4163:12Mar99 `st=` not needed
50 PR.ReadReal(PR.Current(), "Radius", tempRadius); //szv#4:S4163:12Mar99 `st=` not needed
52 if (PR.DefinedElseSkip())
54 //st = PR.ReadReal(PR.Current(), "Face center (X)", tempreal); //szv#4:S4163:12Mar99 moved in if
55 if (PR.ReadReal(PR.Current(), "Face center (X)", tempreal))
56 tempCenter.SetX(tempreal);
58 else tempCenter.SetX(0.0);
60 if (PR.DefinedElseSkip())
62 //st = PR.ReadReal(PR.Current(), "Face center (Y)", tempreal); //szv#4:S4163:12Mar99 moved in if
63 if (PR.ReadReal(PR.Current(), "Face center (Y)", tempreal))
64 tempCenter.SetY(tempreal);
66 else tempCenter.SetY(0.0);
68 if (PR.DefinedElseSkip())
70 //st = PR.ReadReal(PR.Current(), "Face center (Z)", tempreal); //szv#4:S4163:12Mar99 moved in if
71 if (PR.ReadReal(PR.Current(), "Face center (Z)", tempreal))
72 tempCenter.SetZ(tempreal);
74 else tempCenter.SetZ(0.0);
76 if (PR.DefinedElseSkip())
78 //st = PR.ReadReal(PR.Current(), "Axis direction (I)", tempreal); //szv#4:S4163:12Mar99 moved in if
79 if (PR.ReadReal(PR.Current(), "Axis direction (I)", tempreal))
80 tempAxis.SetX(tempreal);
82 else tempAxis.SetX(0.0);
84 if (PR.DefinedElseSkip())
86 //st = PR.ReadReal(PR.Current(), "Axis direction (J)", tempreal); //szv#4:S4163:12Mar99 moved in if
87 if (PR.ReadReal(PR.Current(), "Axis direction (J)", tempreal))
88 tempAxis.SetY(tempreal);
90 else tempAxis.SetY(0.0);
92 if (PR.DefinedElseSkip())
94 //st = PR.ReadReal(PR.Current(), "Axis direction (K)", tempreal); //szv#4:S4163:12Mar99 moved in if
95 if (PR.ReadReal(PR.Current(), "Axis direction (K)", tempreal))
96 tempAxis.SetZ(tempreal);
98 else tempAxis.SetZ(1.0);
100 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
102 (tempHeight, tempRadius, tempCenter, tempAxis);
103 Standard_Real eps = 1.E-05;
104 if (!tempAxis.IsEqual(ent->Axis().XYZ(),eps)) PR.AddWarning
105 ("Axis poorly unitary, normalized");
108 void IGESSolid_ToolCylinder::WriteOwnParams
109 (const Handle(IGESSolid_Cylinder)& ent, IGESData_IGESWriter& IW) const
111 IW.Send(ent->Height());
112 IW.Send(ent->Radius());
113 IW.Send(ent->FaceCenter().X());
114 IW.Send(ent->FaceCenter().Y());
115 IW.Send(ent->FaceCenter().Z());
116 IW.Send(ent->Axis().X());
117 IW.Send(ent->Axis().Y());
118 IW.Send(ent->Axis().Z());
121 void IGESSolid_ToolCylinder::OwnShared
122 (const Handle(IGESSolid_Cylinder)& /* ent */, Interface_EntityIterator& /* iter */) const
126 void IGESSolid_ToolCylinder::OwnCopy
127 (const Handle(IGESSolid_Cylinder)& another,
128 const Handle(IGESSolid_Cylinder)& ent, Interface_CopyTool& /* TC */) const
131 (another->Height(), another->Radius(), another->FaceCenter().XYZ(),
132 another->Axis().XYZ());
135 IGESData_DirChecker IGESSolid_ToolCylinder::DirChecker
136 (const Handle(IGESSolid_Cylinder)& /* ent */ ) const
138 IGESData_DirChecker DC(154, 0);
140 DC.Structure (IGESData_DefVoid);
141 DC.LineFont (IGESData_DefAny);
142 DC.Color (IGESData_DefAny);
144 DC.UseFlagRequired (0);
145 DC.HierarchyStatusIgnored ();
149 void IGESSolid_ToolCylinder::OwnCheck
150 (const Handle(IGESSolid_Cylinder)& ent,
151 const Interface_ShareTool& , Handle(Interface_Check)& ach) const
153 if (ent->Height() <= 0.0)
154 ach->AddFail("Height : Value < 0");
155 if (ent->Radius() <= 0.0)
156 ach->AddFail("Radius : Value < 0");
159 void IGESSolid_ToolCylinder::OwnDump
160 (const Handle(IGESSolid_Cylinder)& ent, const IGESData_IGESDumper& /* dumper */,
161 const Handle(Message_Messenger)& S, const Standard_Integer level) const
164 // Standard_Boolean locprint = (ent->HasTransf() && level >=6);
165 // gp_Pnt TCenter = ent->TransformedFaceCenter();
166 // gp_Dir TAxis = ent->TransformedAxis();
168 S << "IGESSolid_Cylinder" << endl;
170 S << "Height : " << ent->Height() << " ";
171 S << "Radius : " << ent->Radius() << endl;
173 IGESData_DumpXYZL(S,level, ent->FaceCenter(), ent->Location());
174 S << endl << "Axis : ";
175 IGESData_DumpXYZL(S,level, ent->Axis(), ent->VectorLocation());