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 <IGESBasic_HArray1OfLineFontEntity.hxx>
20 #include <IGESData_DirChecker.hxx>
21 #include <IGESData_IGESDumper.hxx>
22 #include <IGESData_IGESReaderData.hxx>
23 #include <IGESData_IGESWriter.hxx>
24 #include <IGESData_LineFontEntity.hxx>
25 #include <IGESData_ParamCursor.hxx>
26 #include <IGESData_ParamReader.hxx>
27 #include <IGESData_ViewKindEntity.hxx>
28 #include <IGESDraw_HArray1OfViewKindEntity.hxx>
29 #include <IGESDraw_SegmentedViewsVisible.hxx>
30 #include <IGESDraw_ToolSegmentedViewsVisible.hxx>
31 #include <IGESGraph_Color.hxx>
32 #include <IGESGraph_HArray1OfColor.hxx>
33 #include <Interface_Check.hxx>
34 #include <Interface_CopyTool.hxx>
35 #include <Interface_EntityIterator.hxx>
36 #include <Interface_Macros.hxx>
37 #include <Interface_ShareTool.hxx>
38 #include <Standard_DomainError.hxx>
39 #include <TColStd_HArray1OfInteger.hxx>
40 #include <TColStd_HArray1OfReal.hxx>
41
IGESDraw_ToolSegmentedViewsVisible()42 IGESDraw_ToolSegmentedViewsVisible::IGESDraw_ToolSegmentedViewsVisible () { }
43
44
ReadOwnParams(const Handle (IGESDraw_SegmentedViewsVisible)& ent,const Handle (IGESData_IGESReaderData)& IR,IGESData_ParamReader & PR) const45 void IGESDraw_ToolSegmentedViewsVisible::ReadOwnParams
46 (const Handle(IGESDraw_SegmentedViewsVisible)& ent,
47 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
48 {
49 //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down
50 Standard_Integer nbval;
51
52 Handle(IGESDraw_HArray1OfViewKindEntity) views;
53 Handle(TColStd_HArray1OfReal) breakpointParameters;
54 Handle(TColStd_HArray1OfInteger) displayFlags;
55 Handle(TColStd_HArray1OfInteger) colorValues;
56 Handle(IGESGraph_HArray1OfColor) colorDefinitions;
57 Handle(TColStd_HArray1OfInteger) lineFontValues;
58 Handle(IGESBasic_HArray1OfLineFontEntity) lineFontDefinitions;
59 Handle(TColStd_HArray1OfInteger) lineWeights;
60
61 // Reading nbval(Integer)
62 Standard_Boolean st = PR.ReadInteger( PR.Current(), "No. of View/segment blocks", nbval );
63 if (st && nbval > 0) {
64 views = new IGESDraw_HArray1OfViewKindEntity(1, nbval);
65 breakpointParameters = new TColStd_HArray1OfReal(1, nbval);
66 displayFlags = new TColStd_HArray1OfInteger(1, nbval);
67 colorValues = new TColStd_HArray1OfInteger(1, nbval);
68 colorDefinitions = new IGESGraph_HArray1OfColor(1, nbval);
69 lineFontValues = new TColStd_HArray1OfInteger(1, nbval);
70 lineFontDefinitions = new IGESBasic_HArray1OfLineFontEntity(1, nbval);
71 lineWeights = new TColStd_HArray1OfInteger(1, nbval);
72
73 Handle(IGESData_ViewKindEntity) tempView;
74 Standard_Real tempBreak;
75 Standard_Integer tempDisplay;
76 Standard_Integer tempColorValue;
77 Handle(IGESGraph_Color) tempColorDef;
78 Standard_Integer tempLineFontValue;
79 Handle(IGESData_LineFontEntity) tempLineFontDef;
80 Standard_Integer tempLine;
81
82 for (Standard_Integer i = 1; i <= nbval; i++)
83 {
84 // Reading views(HArray1OfView)
85 //st = PR.ReadEntity( IR, PR.Current(), "Instance of views",
86 //STANDARD_TYPE(IGESData_ViewKindEntity), tempView ); //szv#4:S4163:12Mar99 moved in if
87 if (PR.ReadEntity(IR, PR.Current(), "Instance of views",
88 STANDARD_TYPE(IGESData_ViewKindEntity), tempView))
89 views->SetValue(i, tempView);
90
91 // Reading breakpointParameters(HArray1OfReal)
92 //st = PR.ReadReal(PR.Current(), "array breakpointParameters", tempBreak ); //szv#4:S4163:12Mar99 moved in if
93 if (PR.ReadReal(PR.Current(), "array breakpointParameters", tempBreak ))
94 breakpointParameters->SetValue(i, tempBreak);
95
96 // Reading displayFlags(HArray1OfInteger)
97 //st = PR.ReadInteger( PR.Current(), "array displayFlags", tempDisplay ); //szv#4:S4163:12Mar99 moved in if
98 if (PR.ReadInteger( PR.Current(), "array displayFlags", tempDisplay ))
99 displayFlags->SetValue(i, tempDisplay);
100
101 Standard_Integer curnum = PR.CurrentNumber();
102
103 // Reading Color : Value (>0) or Definition (<0 = D.E. Pointer)
104 PR.ReadInteger( PR.Current(), "array colorValues", tempColorValue); //szv#4:S4163:12Mar99 `st=` not needed
105 if (tempColorValue < 0) {
106 colorValues->SetValue(i, -1);
107 tempColorDef = GetCasted(IGESGraph_Color,PR.ParamEntity(IR,curnum));
108 if (tempColorDef.IsNull()) PR.AddFail
109 ("A Color Definition Entity is incorrect");
110 else colorDefinitions->SetValue(i, tempColorDef);
111 }
112 else
113 colorValues->SetValue(i, tempColorValue);
114
115 curnum = PR.CurrentNumber();
116 // Reading Line Font : Value (>0) or Definition (<0 = D.E. Pointer)
117 PR.ReadInteger( PR.Current(), "array lineFontValues", tempLineFontValue ); //szv#4:S4163:12Mar99 `st=` not needed
118 if (tempLineFontValue < 0 ) {
119 lineFontValues->SetValue(i, -1);
120 tempLineFontDef = GetCasted(IGESData_LineFontEntity,
121 PR.ParamEntity(IR,curnum));
122 if (tempLineFontDef.IsNull()) PR.AddFail
123 ("A Line Font Definition Entity is incorrect");
124 lineFontDefinitions->SetValue(i,tempLineFontDef);
125 }
126 else
127 lineFontValues->SetValue(i, tempLineFontValue);
128
129 // Reading lineWeights(HArray1OfInteger)
130 //st = PR.ReadInteger( PR.Current(), "array lineWeights", tempLine ); //szv#4:S4163:12Mar99 moved in if
131 if (PR.ReadInteger( PR.Current(), "array lineWeights", tempLine ))
132 lineWeights->SetValue(i, tempLine);
133 }
134 }
135 else
136 PR.AddFail("No. of View/segment blocks : Not Positive");
137
138 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
139 ent->Init
140 (views, breakpointParameters, displayFlags,colorValues, colorDefinitions,
141 lineFontValues, lineFontDefinitions, lineWeights);
142 }
143
WriteOwnParams(const Handle (IGESDraw_SegmentedViewsVisible)& ent,IGESData_IGESWriter & IW) const144 void IGESDraw_ToolSegmentedViewsVisible::WriteOwnParams
145 (const Handle(IGESDraw_SegmentedViewsVisible)& ent, IGESData_IGESWriter& IW) const
146 {
147 Standard_Integer Up = ent->NbSegmentBlocks();
148 IW.Send( Up );
149 for ( Standard_Integer i = 1; i <= Up; i++)
150 {
151 IW.Send( ent->ViewItem(i) );
152 IW.Send( ent->BreakpointParameter(i) );
153 IW.Send( ent->DisplayFlag(i) );
154
155 if (ent->IsColorDefinition(i))
156 IW.Send( ent->ColorDefinition(i), Standard_True ); // negative
157 else
158 IW.Send( ent->ColorValue(i) );
159
160 if (ent->IsFontDefinition(i))
161 IW.Send( ent->LineFontDefinition(i), Standard_True ); // negative
162 else
163 IW.Send( ent->LineFontValue(i) );
164
165 IW.Send( ent->LineWeightItem(i) );
166 }
167 }
168
OwnShared(const Handle (IGESDraw_SegmentedViewsVisible)& ent,Interface_EntityIterator & iter) const169 void IGESDraw_ToolSegmentedViewsVisible::OwnShared
170 (const Handle(IGESDraw_SegmentedViewsVisible)& ent, Interface_EntityIterator& iter) const
171 {
172 Standard_Integer Up = ent->NbSegmentBlocks();
173 for ( Standard_Integer i = 1; i <= Up; i++)
174 {
175 iter.GetOneItem( ent->ViewItem(i) );
176 if (ent->IsColorDefinition(i))
177 iter.GetOneItem( ent->ColorDefinition(i) );
178 if (!ent->IsFontDefinition(i))
179 iter.GetOneItem( ent->LineFontDefinition(i) );
180 }
181 }
182
OwnCopy(const Handle (IGESDraw_SegmentedViewsVisible)& another,const Handle (IGESDraw_SegmentedViewsVisible)& ent,Interface_CopyTool & TC) const183 void IGESDraw_ToolSegmentedViewsVisible::OwnCopy
184 (const Handle(IGESDraw_SegmentedViewsVisible)& another,
185 const Handle(IGESDraw_SegmentedViewsVisible)& ent, Interface_CopyTool& TC) const
186 {
187 Standard_Integer nbval;
188 Handle(IGESDraw_HArray1OfViewKindEntity) views;
189 Handle(TColStd_HArray1OfReal) breakpointParameters;
190 Handle(TColStd_HArray1OfInteger) displayFlags;
191 Handle(TColStd_HArray1OfInteger) colorValues;
192 Handle(IGESGraph_HArray1OfColor) colorDefinitions;
193 Handle(TColStd_HArray1OfInteger) lineFontValues;
194 Handle(IGESBasic_HArray1OfLineFontEntity) lineFontDefinitions;
195 Handle(TColStd_HArray1OfInteger) lineWeights;
196
197 Handle(IGESData_ViewKindEntity) retView;
198 Handle(IGESGraph_Color) retColorDef;
199 Handle(IGESData_LineFontEntity) retLineFontDef;
200
201 nbval = another->NbSegmentBlocks();
202 views = new IGESDraw_HArray1OfViewKindEntity(1, nbval);
203 breakpointParameters = new TColStd_HArray1OfReal(1, nbval);
204 displayFlags = new TColStd_HArray1OfInteger(1, nbval);
205 colorValues = new TColStd_HArray1OfInteger(1, nbval);
206 lineFontValues = new TColStd_HArray1OfInteger(1, nbval);
207 colorDefinitions = new IGESGraph_HArray1OfColor(1, nbval);
208 lineFontDefinitions = new IGESBasic_HArray1OfLineFontEntity(1, nbval);
209 lineWeights = new TColStd_HArray1OfInteger(1, nbval);
210
211 for (Standard_Integer i = 1; i <= nbval; i++)
212 {
213 retView = another->ViewItem(i);
214 DeclareAndCast(IGESData_ViewKindEntity,
215 tempView, TC.Transferred(retView));
216 views->SetValue( i, tempView );
217
218 breakpointParameters->SetValue( i, another->BreakpointParameter(i) );
219
220 displayFlags->SetValue( i, another->DisplayFlag(i) );
221
222 if ( another->IsColorDefinition(i) )
223 {
224 retColorDef = another->ColorDefinition(i);
225 DeclareAndCast(IGESGraph_Color, tempColorDef,
226 TC.Transferred(retColorDef));
227 colorDefinitions->SetValue( i, tempColorDef );
228 }
229 else
230 {
231 colorValues->SetValue( i, another->ColorValue(i) );
232 //// colorDefinitions->SetValue( i, NULL ); par defaut
233 }
234
235 if ( another->IsFontDefinition(i) )
236 {
237 retLineFontDef = another->LineFontDefinition(i);
238 DeclareAndCast(IGESData_LineFontEntity, tempLineFontDef,
239 TC.Transferred(retLineFontDef));
240 lineFontDefinitions->SetValue( i, tempLineFontDef );
241 }
242 else
243 {
244 lineFontValues->SetValue( i, another->LineFontValue(i) );
245 //// lineFontDefinitions->SetValue( i, NULL ); par defaut
246 }
247
248 lineWeights->SetValue( i, another->LineWeightItem(i) );
249 }
250
251 ent->Init(views, breakpointParameters, displayFlags,
252 colorValues, colorDefinitions,
253 lineFontValues, lineFontDefinitions, lineWeights);
254 }
255
DirChecker(const Handle (IGESDraw_SegmentedViewsVisible)&) const256 IGESData_DirChecker IGESDraw_ToolSegmentedViewsVisible::DirChecker
257 (const Handle(IGESDraw_SegmentedViewsVisible)& /*ent*/) const
258 {
259 IGESData_DirChecker DC (402, 19);
260 DC.Structure(IGESData_DefVoid);
261 DC.LineFont(IGESData_DefVoid);
262 DC.LineWeight(IGESData_DefVoid);
263 DC.Color(IGESData_DefVoid);
264 DC.BlankStatusIgnored();
265 DC.SubordinateStatusRequired(0);
266 DC.UseFlagRequired(1);
267 DC.HierarchyStatusIgnored();
268 return DC;
269 }
270
OwnCheck(const Handle (IGESDraw_SegmentedViewsVisible)&,const Interface_ShareTool &,Handle (Interface_Check)&) const271 void IGESDraw_ToolSegmentedViewsVisible::OwnCheck
272 (const Handle(IGESDraw_SegmentedViewsVisible)& /*ent*/,
273 const Interface_ShareTool& , Handle(Interface_Check)& /*ach*/) const
274 {
275 }
276
OwnDump(const Handle (IGESDraw_SegmentedViewsVisible)& ent,const IGESData_IGESDumper & dumper,Standard_OStream & S,const Standard_Integer level) const277 void IGESDraw_ToolSegmentedViewsVisible::OwnDump
278 (const Handle(IGESDraw_SegmentedViewsVisible)& ent, const IGESData_IGESDumper& dumper,
279 Standard_OStream& S, const Standard_Integer level) const
280 {
281 Standard_Integer sublevel = (level <= 4) ? 0 : 1;
282
283 S << "IGESDraw_SegmentedViewsVisible\n"
284 << "View Entities :\n"
285 << "Breakpoint parameters :\n"
286 << "Display flags :\n"
287 << "Color Values :\n"
288 << "Color Definitions :\n"
289 << "LineFont Values :\n"
290 << "LineFont Definitions :\n"
291 << "Line Weights :\n"
292 << "Count Of Blocks = " << ent->NbSegmentBlocks() << "\n";
293 switch (level)
294 {
295 case 4 : S << " [ for content, ask level > 4 ]\n";
296 break; // Nothing to be dumped here
297 case 5 : // Presently level 5 and 6 have the same Dump
298 case 6 :
299 {
300 Standard_Integer I;
301 Standard_Integer up = ent->NbSegmentBlocks();
302 for (I = 1; I <= up; I++)
303 {
304 S << "[" << I << "]:\n"
305 << "View Entity : ";
306 dumper.Dump (ent->ViewItem(I),S, sublevel);
307 S << "\n"
308 << "Breakpoint parameter : " <<ent->BreakpointParameter(I)<< "\n"
309 << "Display Flag : " << ent->DisplayFlag(I) << "\n";
310 if ( (ent->ColorDefinition(I)).IsNull() )
311 {
312 S << "Color Value : " << ent->ColorValue(I);
313 }
314 else
315 {
316 S << "Color Definition : ";
317 dumper.Dump (ent->ColorDefinition(I),S, sublevel);
318 }
319 S << "\n";
320 if ( (ent->LineFontDefinition(I)).IsNull() )
321 {
322 S << "LineFont Value : " << ent->LineFontValue(I);
323 }
324 else
325 {
326 S << "LineFont Definition : ";
327 dumper.Dump (ent->LineFontDefinition(I),S, sublevel);
328 }
329 S << "\n"
330 << "Line Weight : " << ent->LineWeightItem(I) << "\n";
331 }
332 }
333 break;
334 }
335 S << std::endl;
336 }
337