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_XYZ.hxx> |
21 | #include <IGESData_DirChecker.hxx> |
7fd59977 |
22 | #include <IGESData_Dump.hxx> |
42cf5bc1 |
23 | #include <IGESData_IGESDumper.hxx> |
24 | #include <IGESData_IGESEntity.hxx> |
25 | #include <IGESData_IGESReaderData.hxx> |
26 | #include <IGESData_IGESWriter.hxx> |
27 | #include <IGESData_ParamCursor.hxx> |
28 | #include <IGESData_ParamReader.hxx> |
29 | #include <IGESDraw_RectArraySubfigure.hxx> |
30 | #include <IGESDraw_ToolRectArraySubfigure.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 <TColStd_HArray1OfInteger.hxx> |
7fd59977 |
39 | |
40 | IGESDraw_ToolRectArraySubfigure::IGESDraw_ToolRectArraySubfigure () { } |
41 | |
42 | |
43 | void IGESDraw_ToolRectArraySubfigure::ReadOwnParams |
44 | (const Handle(IGESDraw_RectArraySubfigure)& ent, |
45 | const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const |
46 | { |
47 | //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed |
48 | |
49 | gp_XYZ tempLowerLeftCorner; |
50 | Standard_Real tempScaleFactor; |
51 | Handle(IGESData_IGESEntity) tempBaseEntity; |
52 | Handle(TColStd_HArray1OfInteger) tempPositions; |
53 | Standard_Real tempColumnSeparation, tempRowSeparation, tempRotationAngle; |
54 | Standard_Integer tempNbColumns, tempNbRows, tempDoDontFlag, tempListCount; |
55 | |
56 | PR.ReadEntity(IR, PR.Current(), "Base Entity", tempBaseEntity); //szv#4:S4163:12Mar99 `st=` not needed |
57 | |
58 | if (PR.DefinedElseSkip()) |
59 | PR.ReadReal(PR.Current(), "Scale Factor", tempScaleFactor); //szv#4:S4163:12Mar99 `st=` not needed |
60 | else |
61 | tempScaleFactor = 1.0; // Setting to default value of 1.0 |
62 | |
63 | //szv#4:S4163:12Mar99 `st=` not needed |
64 | PR.ReadXYZ(PR.CurrentList(1, 3), "Lower Left Coordinate Of Array", tempLowerLeftCorner); |
65 | PR.ReadInteger(PR.Current(), "Number Of Columns", tempNbColumns); |
66 | PR.ReadInteger(PR.Current(), "Number Of Rows", tempNbRows); |
67 | PR.ReadReal(PR.Current(), "Horizontal Distance Between Columns", tempColumnSeparation); |
68 | PR.ReadReal(PR.Current(), "Vertical Distance Between Rows", tempRowSeparation); |
69 | PR.ReadReal(PR.Current(), "Rotation Angle", tempRotationAngle); |
70 | |
71 | //st = PR.ReadInteger(PR.Current(), "DO-DONT List Count", tempListCount); //szv#4:S4163:12Mar99 moved in if |
72 | if (PR.ReadInteger(PR.Current(), "DO-DONT List Count", tempListCount)) { |
73 | // Initialise HArray1 only if there is no error reading its Length |
74 | if (tempListCount > 0) |
75 | tempPositions = new TColStd_HArray1OfInteger (1, tempListCount); |
76 | else if (tempListCount < 0) |
77 | PR.AddFail("DO-DONT List Count : Less than Zero"); |
78 | } |
79 | |
80 | PR.ReadInteger(PR.Current(), "DO-DONT Flag", tempDoDontFlag); //szv#4:S4163:12Mar99 `st=` not needed |
81 | |
82 | // Read the HArray1 only if its Length was read without any Error |
83 | if (! tempPositions.IsNull()) { |
84 | Standard_Integer I; |
85 | for (I = 1; I <= tempListCount; I++) { |
86 | Standard_Integer tempPos; |
87 | //st = PR.ReadInteger(PR.Current(), "Number Of Position To Process", |
88 | //tempPos); //szv#4:S4163:12Mar99 moved in if |
89 | if (PR.ReadInteger(PR.Current(), "Number Of Position To Process", tempPos)) |
90 | tempPositions->SetValue(I, tempPos); |
91 | } |
92 | } |
93 | |
94 | DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent); |
95 | ent->Init |
96 | (tempBaseEntity, tempScaleFactor, tempLowerLeftCorner, |
97 | tempNbColumns, tempNbRows, tempColumnSeparation, tempRowSeparation, |
98 | tempRotationAngle, tempDoDontFlag, tempPositions); |
99 | } |
100 | |
101 | void IGESDraw_ToolRectArraySubfigure::WriteOwnParams |
102 | (const Handle(IGESDraw_RectArraySubfigure)& ent, IGESData_IGESWriter& IW) const |
103 | { |
104 | IW.Send(ent->BaseEntity()); |
105 | IW.Send(ent->ScaleFactor()); |
106 | IW.Send(ent->LowerLeftCorner().X()); |
107 | IW.Send(ent->LowerLeftCorner().Y()); |
108 | IW.Send(ent->LowerLeftCorner().Z()); |
109 | IW.Send(ent->NbColumns()); |
110 | IW.Send(ent->NbRows()); |
111 | IW.Send(ent->ColumnSeparation()); |
112 | IW.Send(ent->RowSeparation()); |
113 | IW.Send(ent->RotationAngle()); |
114 | IW.Send(ent->ListCount()); |
115 | IW.SendBoolean(ent->DoDontFlag()); |
116 | Standard_Integer I; |
117 | Standard_Integer up = ent->ListCount(); |
118 | for (I = 1; I <= up; I++) |
119 | IW.Send(ent->ListPosition(I)); |
120 | } |
121 | |
122 | void IGESDraw_ToolRectArraySubfigure::OwnShared |
123 | (const Handle(IGESDraw_RectArraySubfigure)& ent, Interface_EntityIterator& iter) const |
124 | { |
125 | iter.GetOneItem(ent->BaseEntity()); |
126 | } |
127 | |
128 | void IGESDraw_ToolRectArraySubfigure::OwnCopy |
129 | (const Handle(IGESDraw_RectArraySubfigure)& another, |
130 | const Handle(IGESDraw_RectArraySubfigure)& ent, Interface_CopyTool& TC) const |
131 | { |
132 | DeclareAndCast(IGESData_IGESEntity, tempBaseEntity, |
133 | TC.Transferred(another->BaseEntity())); |
134 | Standard_Real tempScaleFactor = another->ScaleFactor(); |
135 | gp_XYZ tempLowerLeftCorner = (another->LowerLeftCorner()).XYZ(); |
136 | Standard_Integer tempNbColumns = another->NbColumns(); |
137 | Standard_Integer tempNbRows = another->NbRows(); |
138 | Standard_Real tempColumnSeparation = another->ColumnSeparation(); |
139 | Standard_Real tempRowSeparation = another->RowSeparation(); |
140 | Standard_Real tempRotationAngle = another->RotationAngle(); |
141 | Standard_Integer tempListCount = another->ListCount(); |
142 | Standard_Integer tempDoDontFlag = (another->DoDontFlag() ? 1 : 0); |
143 | Handle(TColStd_HArray1OfInteger) tempPositions; |
144 | if (tempListCount != 0) { |
145 | tempPositions = new TColStd_HArray1OfInteger (1,tempListCount); |
146 | Standard_Integer I; |
147 | for (I = 1; I <= tempListCount; I++) |
148 | tempPositions->SetValue(I, another->ListPosition(I)); |
149 | } |
150 | |
151 | ent->Init(tempBaseEntity, tempScaleFactor, tempLowerLeftCorner, |
152 | tempNbColumns, tempNbRows, tempColumnSeparation, tempRowSeparation, |
153 | tempRotationAngle, tempDoDontFlag, tempPositions); |
154 | } |
155 | |
156 | IGESData_DirChecker IGESDraw_ToolRectArraySubfigure::DirChecker |
157 | (const Handle(IGESDraw_RectArraySubfigure)& /*ent*/) const |
158 | { |
159 | IGESData_DirChecker DC(412, 0); |
160 | DC.Structure(IGESData_DefVoid); |
161 | DC.LineFont(IGESData_DefAny); |
162 | DC.LineWeight(IGESData_DefValue); |
163 | DC.Color(IGESData_DefAny); |
164 | DC.GraphicsIgnored(1); |
165 | |
166 | return DC; |
167 | } |
168 | |
169 | void IGESDraw_ToolRectArraySubfigure::OwnCheck |
170 | (const Handle(IGESDraw_RectArraySubfigure)& /*ent*/, |
171 | const Interface_ShareTool& , Handle(Interface_Check)& /*ach*/) const |
172 | { |
173 | } |
174 | |
175 | void IGESDraw_ToolRectArraySubfigure::OwnDump |
176 | (const Handle(IGESDraw_RectArraySubfigure)& ent, const IGESData_IGESDumper& dumper, |
0ebe5b0a |
177 | Standard_OStream& S, const Standard_Integer level) const |
7fd59977 |
178 | { |
179 | Standard_Integer tempSubLevel = (level <= 4) ? 0 : 1; |
180 | |
0ebe5b0a |
181 | S << "IGESDraw_RectArraySubfigure\n" |
182 | << "Base Entity : "; |
7fd59977 |
183 | dumper.Dump(ent->BaseEntity(),S, tempSubLevel); |
0ebe5b0a |
184 | S << "\n" |
185 | << "Scale Factor : " << ent->ScaleFactor() << " " |
186 | << "Lower Left Corner Of Array : "; |
7fd59977 |
187 | IGESData_DumpXYZL(S,level, ent->LowerLeftCorner(),gp_GTrsf()); // no location |
0ebe5b0a |
188 | S << "Number Of Columns : " << ent->NbColumns() << " " |
189 | << "Number Of Rows : " << ent->NbRows() << "\n" |
190 | << "Horizontal Distance Between Columns : " << ent->ColumnSeparation()<< "\n" |
191 | << "Vertical Distance Between Rows : " << ent->RowSeparation() << "\n" |
192 | << "Rotation Angle (in radians) : " << ent->RotationAngle() << "\n" |
193 | << "Do-Dont Flag : "; |
7fd59977 |
194 | if (ent->DoDontFlag()) S << "(1)Dont "; |
195 | else S << "(0)Do "; |
196 | S << "Do-Dont List : "; |
0ebe5b0a |
197 | IGESData_DumpVals(S,level,1, ent->ListCount(),ent->ListPosition); |
198 | S << std::endl; |
7fd59977 |
199 | } |