0032961: Coding - get rid of unused headers [IGESAppli to IGESToBRep]
[occt.git] / src / IGESSolid / IGESSolid_ToolConicalSurface.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 <IGESData_DirChecker.hxx>
20 #include <IGESData_IGESDumper.hxx>
21 #include <IGESData_IGESReaderData.hxx>
22 #include <IGESData_IGESWriter.hxx>
23 #include <IGESData_ParamReader.hxx>
24 #include <IGESGeom_Direction.hxx>
25 #include <IGESGeom_Point.hxx>
26 #include <IGESSolid_ConicalSurface.hxx>
27 #include <IGESSolid_ToolConicalSurface.hxx>
28 #include <Interface_Check.hxx>
29 #include <Interface_CopyTool.hxx>
30 #include <Interface_EntityIterator.hxx>
31 #include <Interface_Macros.hxx>
32 #include <Interface_ShareTool.hxx>
33
34 IGESSolid_ToolConicalSurface::IGESSolid_ToolConicalSurface ()    {  }
35
36
37 void  IGESSolid_ToolConicalSurface::ReadOwnParams
38   (const Handle(IGESSolid_ConicalSurface)& ent,
39    const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
40 {
41   Handle(IGESGeom_Point) tempLocation;
42   Handle(IGESGeom_Direction) tempAxis;
43   Handle(IGESGeom_Direction) tempRefdir;   // default Unparametrised
44   Standard_Real tempRadius, tempAngle;
45   //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
46
47   PR.ReadEntity(IR, PR.Current(), "Point on axis",
48                 STANDARD_TYPE(IGESGeom_Point), tempLocation); //szv#4:S4163:12Mar99 `st=` not needed
49
50   PR.ReadEntity(IR, PR.Current(), "Axis direction",
51                 STANDARD_TYPE(IGESGeom_Direction), tempAxis); //szv#4:S4163:12Mar99 `st=` not needed
52
53   PR.ReadReal(PR.Current(), "Radius", tempRadius); //szv#4:S4163:12Mar99 `st=` not needed
54
55   PR.ReadReal(PR.Current(), "Semi-angle", tempAngle); //szv#4:S4163:12Mar99 `st=` not needed
56
57   if (ent->FormNumber() == 1)      // Parametrised surface
58     PR.ReadEntity(IR, PR.Current(), "Reference direction",
59                   STANDARD_TYPE(IGESGeom_Direction), tempRefdir); //szv#4:S4163:12Mar99 `st=` not needed
60
61   DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
62   ent->Init
63     (tempLocation, tempAxis, tempRadius, tempAngle, tempRefdir);
64 }
65
66 void  IGESSolid_ToolConicalSurface::WriteOwnParams
67   (const Handle(IGESSolid_ConicalSurface)& ent, IGESData_IGESWriter& IW) const
68 {
69   IW.Send(ent->LocationPoint());
70   IW.Send(ent->Axis());
71   IW.Send(ent->Radius());
72   IW.Send(ent->SemiAngle());
73   if (ent->IsParametrised())    IW.Send(ent->ReferenceDir());  // cf FormNumber
74 }
75
76 void  IGESSolid_ToolConicalSurface::OwnShared
77   (const Handle(IGESSolid_ConicalSurface)& ent, Interface_EntityIterator& iter) const
78 {
79   iter.GetOneItem(ent->LocationPoint());
80   iter.GetOneItem(ent->Axis());
81   iter.GetOneItem(ent->ReferenceDir());
82 }
83
84 void  IGESSolid_ToolConicalSurface::OwnCopy
85   (const Handle(IGESSolid_ConicalSurface)& another,
86    const Handle(IGESSolid_ConicalSurface)& ent, Interface_CopyTool& TC) const
87 {
88   Standard_Real tempRadius, tempAngle;
89   //Standard_Boolean IsItParametrised = Standard_False; //szv#4:S4163:12Mar99 unused
90
91   DeclareAndCast(IGESGeom_Point, tempLocation,
92                  TC.Transferred(another->LocationPoint()));
93   DeclareAndCast(IGESGeom_Direction, tempAxis,
94                  TC.Transferred(another->Axis()));
95   tempRadius = another->Radius();
96   tempAngle  = another->SemiAngle();
97   if (another->IsParametrised())
98     {
99       DeclareAndCast(IGESGeom_Direction, tempRefdir,
100                      TC.Transferred(another->ReferenceDir()));
101       ent->Init (tempLocation, tempAxis, tempRadius, tempAngle, tempRefdir);
102     }
103   else
104     {
105       Handle(IGESGeom_Direction) tempRefdir;
106       ent->Init (tempLocation, tempAxis, tempRadius, tempAngle, tempRefdir);
107     }
108 }
109
110 IGESData_DirChecker  IGESSolid_ToolConicalSurface::DirChecker
111   (const Handle(IGESSolid_ConicalSurface)& /*ent*/) const
112 {
113   IGESData_DirChecker DC(194, 0, 1);
114
115   DC.Structure  (IGESData_DefVoid);
116   DC.LineFont   (IGESData_DefAny);
117   DC.Color      (IGESData_DefAny);
118
119   DC.BlankStatusIgnored ();
120   DC.SubordinateStatusRequired (1);
121   DC.HierarchyStatusIgnored ();
122   return DC;
123 }
124
125 void  IGESSolid_ToolConicalSurface::OwnCheck
126   (const Handle(IGESSolid_ConicalSurface)& ent,
127    const Interface_ShareTool& , Handle(Interface_Check)& ach) const
128 {
129   if (ent->Radius() < 0.0)
130     ach->AddFail("Radius : Value Negative");
131   if (ent->SemiAngle() < 0.0 || ent->SemiAngle() > 90.0)
132     ach->AddFail("Semi-angle : Value not in the range [0 - 90]");
133   Standard_Integer fn = 0;
134   if (ent->IsParametrised()) fn = 1;
135   if (fn != ent->FormNumber()) ach->AddFail
136     ("Parametrised Status Mismatches with Form Number");
137 }
138
139 void  IGESSolid_ToolConicalSurface::OwnDump
140   (const Handle(IGESSolid_ConicalSurface)& ent, const IGESData_IGESDumper& dumper,
141    Standard_OStream& S, const Standard_Integer level) const
142 {
143   S << "IGESSolid_ConicalSurface\n";
144
145   Standard_Integer sublevel = (level <= 4) ? 0 : 1;
146   S << "Point on axis  : ";
147   dumper.Dump(ent->LocationPoint(),S, sublevel);
148   S << "\n"
149     << "Axis direction : ";
150   dumper.Dump(ent->Axis(),S, sublevel);
151   S << "\n"
152     << "Radius         : " << ent->Radius() << "  "
153     << "Semi-angle     : " << ent->SemiAngle() << "\n";
154   if (ent->IsParametrised())
155     {
156       S << "Surface is Parametrised  -  Reference direction :\n";
157       dumper.Dump(ent->ReferenceDir(),S, sublevel);
158       S << std::endl;
159     }
160   else S << "Surface is UnParametrised" << std::endl;
161 }