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