0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / IGESGeom / IGESGeom_ToolCircularArc.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_Pnt2d.hxx>
20 #include <gp_XY.hxx>
21 #include <IGESData_DirChecker.hxx>
22 #include <IGESData_Dump.hxx>
23 #include <IGESData_IGESDumper.hxx>
24 #include <IGESData_IGESReaderData.hxx>
25 #include <IGESData_IGESWriter.hxx>
26 #include <IGESData_ParamCursor.hxx>
27 #include <IGESData_ParamReader.hxx>
28 #include <IGESGeom_CircularArc.hxx>
29 #include <IGESGeom_ToolCircularArc.hxx>
30 #include <Interface_Check.hxx>
31 #include <Interface_CopyTool.hxx>
32 #include <Interface_EntityIterator.hxx>
33 #include <Interface_Macros.hxx>
34 #include <Interface_MSG.hxx>
35 #include <Interface_ShareTool.hxx>
36 #include <Message_Msg.hxx>
37 #include <Standard_DomainError.hxx>
38
39 #include <stdio.h>
40 // MGE 28/07/98
41 IGESGeom_ToolCircularArc::IGESGeom_ToolCircularArc ()    {  }
42
43
44 void IGESGeom_ToolCircularArc::ReadOwnParams
45   (const Handle(IGESGeom_CircularArc)& ent,
46    const Handle(IGESData_IGESReaderData)& /* IR */, IGESData_ParamReader& PR) const
47 {
48   // MGE 28/07/98
49   // Building of messages
50   //=====================================
51   Message_Msg Msg76("XSTEP_76");
52   Message_Msg Msg77("XSTEP_77");
53   Message_Msg Msg78("XSTEP_78");
54   //=====================================
55   
56   Standard_Real aZT;
57   gp_XY aCenter, aStart, anEnd;
58   //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
59
60   // MGE 28/07/98
61   if (!PR.ReadReal(PR.Current(), aZT)){ //szv#4:S4163:12Mar99 `st=` not needed
62     Message_Msg Msg75("XSTEP_75");
63     PR.SendFail(Msg75);
64   }
65   PR.ReadXY(PR.CurrentList(1, 2), Msg76, aCenter); //szv#4:S4163:12Mar99 `st=` not needed
66   PR.ReadXY(PR.CurrentList(1, 2), Msg77, aStart); //szv#4:S4163:12Mar99 `st=` not needed
67   PR.ReadXY(PR.CurrentList(1, 2), Msg78, anEnd); //szv#4:S4163:12Mar99 `st=` not needed
68   
69 /*
70   st = PR.ReadReal(PR.Current(), "Shift above z-plane", aZT);
71   st = PR.ReadXY(PR.CurrentList(1, 2), "Center Of Arc", aCenter);
72   st = PR.ReadXY(PR.CurrentList(1, 2), "Start Point Of Arc", aStart);
73   st = PR.ReadXY(PR.CurrentList(1, 2), "End Point Of Arc", anEnd);
74 */
75
76   DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
77   ent->Init(aZT, aCenter, aStart, anEnd);
78
79 }
80
81 void IGESGeom_ToolCircularArc::WriteOwnParams
82   (const Handle(IGESGeom_CircularArc)& ent, IGESData_IGESWriter& IW)  const
83 {
84   IW.Send(ent->ZPlane());
85   IW.Send(ent->Center().X());
86   IW.Send(ent->Center().Y());
87   IW.Send(ent->StartPoint().X());
88   IW.Send(ent->StartPoint().Y());
89   IW.Send(ent->EndPoint().X());
90   IW.Send(ent->EndPoint().Y());
91 }
92
93 void  IGESGeom_ToolCircularArc::OwnShared
94   (const Handle(IGESGeom_CircularArc)& /* ent */, Interface_EntityIterator& /* iter */) const
95 {
96 }
97
98 void IGESGeom_ToolCircularArc::OwnCopy 
99   (const Handle(IGESGeom_CircularArc)& another,
100    const Handle(IGESGeom_CircularArc)& ent, Interface_CopyTool& /* TC */) const
101 {
102   ent->Init(another->ZPlane(), another->Center().XY(),
103             another->StartPoint().XY(), another->EndPoint().XY());
104 }
105
106
107 IGESData_DirChecker IGESGeom_ToolCircularArc::DirChecker
108   (const Handle(IGESGeom_CircularArc)& /* ent */ )  const
109 {
110   IGESData_DirChecker DC(100, 0);
111   DC.Structure(IGESData_DefVoid);
112   DC.LineFont(IGESData_DefAny);
113 //  DC.LineWeight(IGESData_DefValue);
114   DC.Color(IGESData_DefAny);
115   DC.HierarchyStatusIgnored();
116   return DC;
117 }
118
119 void IGESGeom_ToolCircularArc::OwnCheck
120   (const Handle(IGESGeom_CircularArc)& /*ent*/,
121    const Interface_ShareTool& , Handle(Interface_Check)& /*ach*/)  const
122 {
123 /*
124   //Standard_Real eps  = 1.E-04;    // Tolerance des tests ?? //szv#4:S4163:12Mar99 not needed
125
126   Standard_Real Rad1 = Sqrt(Square(ent->StartPoint().X() - ent->Center().X()) +
127                             Square(ent->StartPoint().Y() - ent->Center().Y()));
128   Standard_Real Rad2 = Sqrt(Square(ent->EndPoint().X()   - ent->Center().X()) +
129                             Square(ent->EndPoint().Y()   - ent->Center().Y()));
130
131   Standard_Real ratio = Abs(Rad1 - Rad2) / (Rad1+Rad2);
132   if (ratio > eps) {
133     char mess[80];
134     Sprintf(mess,"Radius at Start & End Points, relative gap over %f",
135             Interface_MSG::Intervalled (ratio));
136     ach.AddFail(mess,"Radius at Start & End Points, relative gap over %f");
137   }
138 */
139 }
140
141 void IGESGeom_ToolCircularArc::OwnDump
142   (const Handle(IGESGeom_CircularArc)& ent, const IGESData_IGESDumper& /* dumper */,
143    Standard_OStream& S, const Standard_Integer level)  const
144 {
145   S << "CircularArc from IGESGeom]\n"
146     << "Z-Plane Displacement : " << ent->ZPlane() << "\n"
147     << "Center      : ";
148   IGESData_DumpXYLZ(S,level, ent->Center(), ent->Location(), ent->ZPlane());
149   S << "\n"
150     << "Start Point : ";
151   IGESData_DumpXYLZ(S,level, ent->StartPoint(), ent->Location(),ent->ZPlane());
152   S << "\n"
153     << "End Point   : ";
154   IGESData_DumpXYLZ(S,level, ent->EndPoint(), ent->Location(), ent->ZPlane());
155   S << "\n";
156   if (level <= 5) return;
157   S << "  Normal Axis : ";  IGESData_DumpXYZL(S,level,ent->Axis(),ent->VectorLocation());
158   S << std::endl;
159 }