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