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_Pnt.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_LineFontEntity.hxx> |
27 | #include <IGESData_ParamCursor.hxx> |
28 | #include <IGESData_ParamReader.hxx> |
29 | #include <IGESDimen_CenterLine.hxx> |
30 | #include <IGESDimen_ToolCenterLine.hxx> |
31 | #include <Interface_Check.hxx> |
32 | #include <Interface_CopyTool.hxx> |
33 | #include <Interface_EntityIterator.hxx> |
7fd59977 |
34 | #include <Interface_Macros.hxx> |
42cf5bc1 |
35 | #include <Interface_ShareTool.hxx> |
36 | #include <Message_Messenger.hxx> |
37 | #include <Standard_DomainError.hxx> |
38 | #include <TColgp_HArray1OfXY.hxx> |
7fd59977 |
39 | |
40 | IGESDimen_ToolCenterLine::IGESDimen_ToolCenterLine () { } |
41 | |
42 | |
43 | void IGESDimen_ToolCenterLine::ReadOwnParams |
44 | (const Handle(IGESDimen_CenterLine)& ent, |
45 | const Handle(IGESData_IGESReaderData)& /* IR */, IGESData_ParamReader& PR) const |
46 | { |
47 | //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed |
48 | |
49 | Standard_Integer datatype; |
50 | Standard_Real zDisplacement; |
51 | Standard_Integer nbval; |
52 | Handle(TColgp_HArray1OfXY) dataPoints; |
53 | |
54 | PR.ReadInteger(PR.Current(), "Interpretation Flag", datatype); //szv#4:S4163:12Mar99 `st=` not needed |
55 | |
56 | Standard_Boolean st = PR.ReadInteger(PR.Current(), "Number of data points", nbval); |
57 | if (st && nbval > 0) dataPoints = new TColgp_HArray1OfXY(1, nbval); |
58 | else PR.AddFail("Number of data points: Not Positive"); |
59 | |
60 | PR.ReadReal(PR.Current(), "Common Z Displacement", zDisplacement); //szv#4:S4163:12Mar99 `st=` not needed |
61 | |
62 | if (! dataPoints.IsNull()) |
63 | for (Standard_Integer i = 1; i <= nbval; i++) |
64 | { |
65 | gp_XY tempXY; |
66 | //st = PR.ReadXY(PR.CurrentList(1, 2), "Data Points", tempXY); //szv#4:S4163:12Mar99 moved in if |
67 | if (PR.ReadXY(PR.CurrentList(1, 2), "Data Points", tempXY)) |
68 | dataPoints->SetValue(i, tempXY); |
69 | } |
70 | |
71 | DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent); |
72 | ent->Init(datatype, zDisplacement, dataPoints); |
73 | } |
74 | |
75 | void IGESDimen_ToolCenterLine::WriteOwnParams |
76 | (const Handle(IGESDimen_CenterLine)& ent, IGESData_IGESWriter& IW) const |
77 | { |
78 | Standard_Integer upper = ent->NbPoints(); |
79 | IW.Send(ent->Datatype()); |
80 | IW.Send(upper); |
81 | IW.Send(ent->ZDisplacement()); |
82 | for (Standard_Integer i = 1; i <= upper; i++) |
83 | { |
84 | IW.Send((ent->Point(i)).X()); |
85 | IW.Send((ent->Point(i)).Y()); |
86 | } |
87 | } |
88 | |
89 | void IGESDimen_ToolCenterLine::OwnShared |
90 | (const Handle(IGESDimen_CenterLine)& /* ent */, Interface_EntityIterator& /* iter */) const |
91 | { |
92 | } |
93 | |
94 | void IGESDimen_ToolCenterLine::OwnCopy |
95 | (const Handle(IGESDimen_CenterLine)& another, |
96 | const Handle(IGESDimen_CenterLine)& ent, Interface_CopyTool& /* TC */) const |
97 | { |
98 | Standard_Integer datatype = another->Datatype(); |
99 | Standard_Integer nbval = another->NbPoints(); |
100 | Standard_Real zDisplacement = another->ZDisplacement(); |
101 | |
102 | Handle(TColgp_HArray1OfXY) dataPoints = new TColgp_HArray1OfXY(1, nbval); |
103 | |
104 | for (Standard_Integer i = 1; i <= nbval; i++) |
105 | { |
106 | gp_Pnt tempPnt = (another->Point(i)); |
107 | gp_XY tempPnt2d(tempPnt.X(), tempPnt.Y()); |
108 | dataPoints->SetValue(i, tempPnt2d); |
109 | } |
110 | ent->Init(datatype, zDisplacement, dataPoints); |
111 | ent->SetCrossHair (another->IsCrossHair()); |
112 | } |
113 | |
114 | Standard_Boolean IGESDimen_ToolCenterLine::OwnCorrect |
115 | (const Handle(IGESDimen_CenterLine)& ent) const |
116 | { |
117 | Standard_Boolean res = (ent->RankLineFont() != 1); |
118 | if (res) { |
119 | Handle(IGESData_LineFontEntity) nulfont; |
120 | ent->InitLineFont(nulfont,1); |
121 | } |
122 | if (ent->Datatype() == 1) return res; |
123 | // Forcer DataType = 1 -> reconstruire |
124 | Standard_Integer nb = ent->NbPoints(); |
125 | if (nb == 0) return res; // rien pu faire (est-ce possible ?) |
126 | Handle(TColgp_HArray1OfXY) pts = new TColgp_HArray1OfXY(1,nb); |
127 | for (Standard_Integer i = 1; i <= nb; i ++) |
128 | pts->SetValue(i, gp_XY(ent->Point(i).X(),ent->Point(i).Y()) ); |
129 | ent->Init (1,ent->ZDisplacement(),pts); |
130 | return Standard_True; |
131 | } |
132 | |
133 | IGESData_DirChecker IGESDimen_ToolCenterLine::DirChecker |
134 | (const Handle(IGESDimen_CenterLine)& /* ent */) const |
135 | { |
136 | IGESData_DirChecker DC (106, 20, 21); |
137 | DC.Structure(IGESData_DefVoid); |
138 | DC.LineFont(IGESData_DefValue); |
139 | DC.LineWeight(IGESData_DefValue); |
140 | DC.Color(IGESData_DefAny); |
141 | DC.UseFlagRequired(1); |
142 | DC.HierarchyStatusIgnored(); |
143 | return DC; |
144 | } |
145 | |
146 | void IGESDimen_ToolCenterLine::OwnCheck |
147 | (const Handle(IGESDimen_CenterLine)& ent, |
148 | const Interface_ShareTool& , Handle(Interface_Check)& ach) const |
149 | { |
150 | if (ent->RankLineFont() != 1) |
151 | ach->AddFail("Line Font Pattern != 1"); |
152 | if (ent->Datatype() != 1) |
153 | ach->AddFail("Interpretation Flag != 1"); |
154 | if (ent->NbPoints()%2 != 0) |
155 | ach->AddFail("Number of data points is not even"); |
156 | } |
157 | |
158 | void IGESDimen_ToolCenterLine::OwnDump |
159 | (const Handle(IGESDimen_CenterLine)& ent, const IGESData_IGESDumper& /* dumper */, |
160 | const Handle(Message_Messenger)& S, const Standard_Integer level) const |
161 | { |
162 | S << "IGESDimen_CenterLine" << endl; |
163 | if (ent->IsCrossHair()) S << "Cross Hair" << endl; |
164 | else S << "Through Circle Centers" << endl; |
165 | S << "Data Type : " << ent->Datatype() << " "; |
166 | S << "Number of Data Points : " << ent->NbPoints() << " "; |
167 | S << "Common Z displacement : " << ent->ZDisplacement() << " "; |
168 | S << "Data Points : " << endl; |
169 | IGESData_DumpListXYLZ(S ,level,1, ent->NbPoints(),ent->Point, |
170 | ent->Location(), ent->ZDisplacement()); |
171 | S << endl; |
172 | } |