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