0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / IGESGeom / IGESGeom_ToolDirection.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_Vec.hxx>
20 #include <gp_XY.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 <IGESGeom_Direction.hxx>
30 #include <IGESGeom_ToolDirection.hxx>
31 #include <Interface_Check.hxx>
32 #include <Interface_CopyTool.hxx>
33 #include <Interface_EntityIterator.hxx>
34 #include <Interface_Macros.hxx>
35 #include <Interface_ShareTool.hxx>
36 #include <Message_Messenger.hxx>
37 #include <Standard_DomainError.hxx>
38
39 IGESGeom_ToolDirection::IGESGeom_ToolDirection ()    {  }
40
41
42 void IGESGeom_ToolDirection::ReadOwnParams
43   (const Handle(IGESGeom_Direction)& ent,
44    const Handle(IGESData_IGESReaderData)& /* IR */, IGESData_ParamReader& PR) const
45 {
46   gp_XYZ aDirection;
47   gp_XY  tmpXY;
48   //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
49   Standard_Real tmpReal;
50
51   //st = PR.ReadXY(PR.CurrentList(1, 2), "Direction", tmpXY); //szv#4:S4163:12Mar99 moved in if
52   if (PR.ReadXY(PR.CurrentList(1, 2), "Direction", tmpXY)) {
53     aDirection.SetX(tmpXY.X());
54     aDirection.SetY(tmpXY.Y());
55   }
56
57   if (PR.DefinedElseSkip())
58     {
59       //st = PR.ReadReal(PR.Current(), "Direction", tmpReal); //szv#4:S4163:12Mar99 moved in if
60       if (PR.ReadReal(PR.Current(), "Direction", tmpReal))
61         aDirection.SetZ(tmpReal);
62     }
63   else
64     {
65       aDirection.SetZ(0.0);   // Default value.
66     }
67
68   DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
69   ent->Init(aDirection);
70 }
71
72 void IGESGeom_ToolDirection::WriteOwnParams
73   (const Handle(IGESGeom_Direction)& ent, IGESData_IGESWriter& IW)  const
74 {
75   IW.Send(ent->Value().X());
76   IW.Send(ent->Value().Y());
77   IW.Send(ent->Value().Z());
78 }
79
80 void  IGESGeom_ToolDirection::OwnShared
81   (const Handle(IGESGeom_Direction)& /* ent */, Interface_EntityIterator& /* iter */) const
82 {
83 }
84
85 void IGESGeom_ToolDirection::OwnCopy
86   (const Handle(IGESGeom_Direction)& another,
87    const Handle(IGESGeom_Direction)& ent, Interface_CopyTool& /* TC */) const
88 {
89   ent->Init(another->Value().XYZ());
90 }
91
92 IGESData_DirChecker IGESGeom_ToolDirection::DirChecker
93   (const Handle(IGESGeom_Direction)& /* ent */ )  const
94 {
95   IGESData_DirChecker DC(123, 0);
96   DC.Structure(IGESData_DefVoid);
97   DC.LineFont(IGESData_DefAny);
98 //  DC.LineWeight(IGESData_DefValue);
99   DC.Color(IGESData_DefAny);
100
101   DC.BlankStatusIgnored ();
102   DC.SubordinateStatusRequired (1);
103   DC.UseFlagRequired (2);
104   DC.HierarchyStatusIgnored ();
105   return DC;
106 }
107
108 void IGESGeom_ToolDirection::OwnCheck
109   (const Handle(IGESGeom_Direction)& ent,
110    const Interface_ShareTool& , Handle(Interface_Check)& ach)  const
111 {
112   if (ent->Value().XYZ().SquareModulus() <= 0.0)
113     ach->AddFail("Direction : The values indicate no direction");
114 }
115
116 void IGESGeom_ToolDirection::OwnDump
117   (const Handle(IGESGeom_Direction)& ent, const IGESData_IGESDumper& /* dumper */,
118    const Handle(Message_Messenger)& S, const Standard_Integer level)  const
119 {
120   S << "IGESGeom_Direction" << endl << endl;
121
122   S << "Value : ";
123   IGESData_DumpXYZL(S,level, ent->Value(), ent->VectorLocation());
124   S << endl;
125 }