0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / IGESSolid / IGESSolid_ToolSolidOfRevolution.cxx
CommitLineData
b311480e 1// Created by: CKY / Contract Toubro-Larsen
2// Copyright (c) 1993-1999 Matra Datavision
973c2be1 3// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
7fd59977 6//
d5f74e42 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
973c2be1 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.
7fd59977 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
b311480e 15
16//--------------------------------------------------------------------
7fd59977 17//--------------------------------------------------------------------
18
7fd59977 19#include <gp_Dir.hxx>
42cf5bc1 20#include <gp_Pnt.hxx>
21#include <gp_XYZ.hxx>
22#include <IGESData_DirChecker.hxx>
7fd59977 23#include <IGESData_Dump.hxx>
42cf5bc1 24#include <IGESData_IGESDumper.hxx>
25#include <IGESData_IGESEntity.hxx>
26#include <IGESData_IGESReaderData.hxx>
27#include <IGESData_IGESWriter.hxx>
28#include <IGESData_ParamCursor.hxx>
29#include <IGESData_ParamReader.hxx>
30#include <IGESSolid_SolidOfRevolution.hxx>
31#include <IGESSolid_ToolSolidOfRevolution.hxx>
32#include <Interface_Check.hxx>
33#include <Interface_CopyTool.hxx>
34#include <Interface_EntityIterator.hxx>
7fd59977 35#include <Interface_Macros.hxx>
42cf5bc1 36#include <Interface_ShareTool.hxx>
37#include <Message_Messenger.hxx>
38#include <Standard_DomainError.hxx>
7fd59977 39
40IGESSolid_ToolSolidOfRevolution::IGESSolid_ToolSolidOfRevolution () { }
41
42
43void IGESSolid_ToolSolidOfRevolution::ReadOwnParams
44 (const Handle(IGESSolid_SolidOfRevolution)& ent,
45 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
46{
47 Handle(IGESData_IGESEntity) tempEntity;
48 gp_XYZ tempAxisPoint;
49 gp_XYZ tempAxis;
50 Standard_Real tempFraction;
51 Standard_Real tempreal;
52 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
53
54 PR.ReadEntity(IR, PR.Current(), "Curve Entity", tempEntity); //szv#4:S4163:12Mar99 `st=` not needed
55
56 if (PR.DefinedElseSkip())
57 PR.ReadReal(PR.Current(), "Fraction of rotation", tempFraction); //szv#4:S4163:12Mar99 `st=` not needed
58 else
59 tempFraction = 1.0;
60 if (PR.DefinedElseSkip())
61 {
62 //st = PR.ReadReal(PR.Current(), "Axis Point (X)", tempreal); //szv#4:S4163:12Mar99 moved in if
63 if (PR.ReadReal(PR.Current(), "Axis Point (X)", tempreal))
64 tempAxisPoint.SetX(tempreal);
65 }
66 else tempAxisPoint.SetX(0.0);
67
68 if (PR.DefinedElseSkip())
69 {
70 //st = PR.ReadReal(PR.Current(), "Axis Point (Y)", tempreal); //szv#4:S4163:12Mar99 moved in if
71 if (PR.ReadReal(PR.Current(), "Axis Point (Y)", tempreal))
72 tempAxisPoint.SetY(tempreal);
73 }
74 else tempAxisPoint.SetY(0.0);
75
76 if (PR.DefinedElseSkip())
77 {
78 //st = PR.ReadReal(PR.Current(), "Axis Point (Z)", tempreal); //szv#4:S4163:12Mar99 moved in if
79 if (PR.ReadReal(PR.Current(), "Axis Point (Z)", tempreal))
80 tempAxisPoint.SetZ(tempreal);
81 }
82 else tempAxisPoint.SetZ(0.0);
83
84 if (PR.DefinedElseSkip())
85 {
86 //st = PR.ReadReal(PR.Current(), "Axis direction (I)", tempreal); //szv#4:S4163:12Mar99 moved in if
87 if (PR.ReadReal(PR.Current(), "Axis direction (I)", tempreal))
88 tempAxis.SetX(tempreal);
89 }
90 else tempAxis.SetX(0.0);
91
92 if (PR.DefinedElseSkip())
93 {
94 //st = PR.ReadReal(PR.Current(), "Axis direction (J)", tempreal); //szv#4:S4163:12Mar99 moved in if
95 if (PR.ReadReal(PR.Current(), "Axis direction (J)", tempreal))
96 tempAxis.SetY(tempreal);
97 }
98 else tempAxis.SetY(0.0);
99
100 if (PR.DefinedElseSkip())
101 {
102 //st = PR.ReadReal(PR.Current(), "Axis direction (K)", tempreal); //szv#4:S4163:12Mar99 moved in if
103 if (PR.ReadReal(PR.Current(), "Axis direction (K)", tempreal))
104 tempAxis.SetZ(tempreal);
105 }
106 else tempAxis.SetZ(1.0);
107
108 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
109 ent->Init (tempEntity, tempFraction, tempAxisPoint, tempAxis);
110 Standard_Real eps = 1.E-05;
111 if (!tempAxis.IsEqual(ent->Axis().XYZ(),eps))
112 PR.AddWarning("Axis poorly unitary, normalized");
113}
114
115void IGESSolid_ToolSolidOfRevolution::WriteOwnParams
116 (const Handle(IGESSolid_SolidOfRevolution)& ent, IGESData_IGESWriter& IW) const
117{
118 IW.Send(ent->Curve());
119 IW.Send(ent->Fraction());
120 IW.Send(ent->AxisPoint().X());
121 IW.Send(ent->AxisPoint().Y());
122 IW.Send(ent->AxisPoint().Z());
123 IW.Send(ent->Axis().X());
124 IW.Send(ent->Axis().Y());
125 IW.Send(ent->Axis().Z());
126}
127
128void IGESSolid_ToolSolidOfRevolution::OwnShared
129 (const Handle(IGESSolid_SolidOfRevolution)& ent, Interface_EntityIterator& iter) const
130{
131 iter.GetOneItem(ent->Curve());
132}
133
134void IGESSolid_ToolSolidOfRevolution::OwnCopy
135 (const Handle(IGESSolid_SolidOfRevolution)& another,
136 const Handle(IGESSolid_SolidOfRevolution)& ent, Interface_CopyTool& TC) const
137{
138 DeclareAndCast(IGESData_IGESEntity, tempEntity,
139 TC.Transferred(another->Curve()));
140 Standard_Real tempFraction = another->Fraction();
141 gp_XYZ tempAxisPoint = another->AxisPoint().XYZ();
142 gp_XYZ tempAxis= another->Axis().XYZ();
143 ent->Init(tempEntity, tempFraction, tempAxisPoint, tempAxis);
144}
145
146IGESData_DirChecker IGESSolid_ToolSolidOfRevolution::DirChecker
147 (const Handle(IGESSolid_SolidOfRevolution)& /* ent */ ) const
148{
149 IGESData_DirChecker DC(162, 0, 1);
150
151 DC.Structure (IGESData_DefVoid);
152 DC.LineFont (IGESData_DefAny);
153 DC.Color (IGESData_DefAny);
154
155 DC.UseFlagRequired (0);
156 DC.HierarchyStatusIgnored ();
157 return DC;
158}
159
160void IGESSolid_ToolSolidOfRevolution::OwnCheck
161 (const Handle(IGESSolid_SolidOfRevolution)& ent,
162 const Interface_ShareTool& , Handle(Interface_Check)& ach) const
163{
164 if (ent->Fraction() <= 0 || ent->Fraction() > 1.0)
165 ach->AddFail("Fraction of rotation : Incorrect value");
166}
167
168void IGESSolid_ToolSolidOfRevolution::OwnDump
169 (const Handle(IGESSolid_SolidOfRevolution)& ent, const IGESData_IGESDumper& dumper,
170 const Handle(Message_Messenger)& S, const Standard_Integer level) const
171{
172 S << "IGESSolid_SolidOfRevolution" << endl;
173
174 S << "Curve entity :";
175 dumper.Dump(ent->Curve(),S, (level <= 4) ? 0 : 1);
176 S << endl;
177 S << "Fraction of rotation : " << ent->Fraction() << endl;
178 S << "Axis Point : ";
179 IGESData_DumpXYZL(S,level, ent->AxisPoint(), ent->Location());
180 S << endl << "Axis direction : ";
181 IGESData_DumpXYZL(S,level, ent->Axis(), ent->VectorLocation());
182 S << endl;
183}