0023258: Missing parenthesis
[occt.git] / src / IGESGeom / IGESGeom_ToolSplineSurface.cxx
CommitLineData
b311480e 1// Created by: CKY / Contract Toubro-Larsen
2// Copyright (c) 1993-1999 Matra Datavision
3// Copyright (c) 1999-2012 OPEN CASCADE SAS
4//
5// The content of this file is subject to the Open CASCADE Technology Public
6// License Version 6.5 (the "License"). You may not use the content of this file
7// except in compliance with the License. Please obtain a copy of the License
8// at http://www.opencascade.org and read it completely before using this file.
7fd59977 9//
b311480e 10// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
7fd59977 12//
b311480e 13// The Original Code and all software distributed under the License is
14// distributed on an "AS IS" basis, without warranty of any kind, and the
15// Initial Developer hereby disclaims all such warranties, including without
16// limitation, any warranties of merchantability, fitness for a particular
17// purpose or non-infringement. Please see the License for the specific terms
18// and conditions governing the rights and limitations under the License.
19
20//--------------------------------------------------------------------
7fd59977 21//--------------------------------------------------------------------
22
23#include <IGESGeom_ToolSplineSurface.ixx>
24#include <IGESData_ParamCursor.hxx>
25#include <TColStd_HArray1OfReal.hxx>
26#include <IGESBasic_HArray2OfHArray1OfReal.hxx>
27#include <IGESData_Dump.hxx>
28#include <Interface_Macros.hxx>
29
30// MGE 30/07/98
31#include <Message_Msg.hxx>
32
33
34IGESGeom_ToolSplineSurface::IGESGeom_ToolSplineSurface () { }
35
36
37void IGESGeom_ToolSplineSurface::ReadOwnParams
38 (const Handle(IGESGeom_SplineSurface)& ent,
39 const Handle(IGESData_IGESReaderData)& /* IR */, IGESData_ParamReader& PR) const
40{
41
42 // MGE 30/07/98
43
44 Standard_Integer aBoundaryType, aPatchType, allNbUSegments, allNbVSegments;
45 Standard_Integer i, j, k;
46 Standard_Boolean ubreak=Standard_False, vbreak=Standard_False;
47 Handle(TColStd_HArray1OfReal) allUBreakPoints;
48 Handle(TColStd_HArray1OfReal) allVBreakPoints;
49 Handle(IGESBasic_HArray2OfHArray1OfReal) allXCoeffs;
50 Handle(IGESBasic_HArray2OfHArray1OfReal) allYCoeffs;
51 Handle(IGESBasic_HArray2OfHArray1OfReal) allZCoeffs;
52
53 //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down
54
55 //szv#4:S4163:12Mar99 `st=` not needed
56 if (!PR.ReadInteger(PR.Current(), aBoundaryType)){
57 Message_Msg Msg140("XSTEP_140");
58 PR.SendFail(Msg140);
59 }
60 if (!PR.ReadInteger(PR.Current(), aPatchType)){
61 Message_Msg Msg278("XSTEP_278");
62 PR.SendFail(Msg278);
63 }
64 //st = PR.ReadInteger(PR.Current(), Msg141, allNbUSegments); //szv#4:S4163:12Mar99 moved in if
65 if (PR.ReadInteger(PR.Current(),allNbUSegments)) {
66 ubreak = Standard_True;
67 allUBreakPoints = new TColStd_HArray1OfReal(1, allNbUSegments+1);
68 }
69 else{
70 Message_Msg Msg141("XSTEP_141");
71 PR.SendFail(Msg141);
72 }
73
74 //st = PR.ReadInteger(PR.Current(), Msg142, allNbVSegments); //szv#4:S4163:12Mar99 moved in if
75 //st = PR.ReadInteger(PR.Current(), "Number Of V Segments", allNbVSegments);
76 if (PR.ReadInteger(PR.Current(),allNbVSegments)) {
77 vbreak = Standard_True;
78 allVBreakPoints = new TColStd_HArray1OfReal(1, allNbVSegments+1);
79 }
80 else{
81 Message_Msg Msg142("XSTEP_142");
82 PR.SendFail(Msg142);
83 }
84
85
86 if (!allUBreakPoints.IsNull()){
87 Message_Msg Msg143("XSTEP_143");
88 PR.ReadReals(PR.CurrentList(allNbUSegments+1), Msg143, allUBreakPoints); //szv#4:S4163:12Mar99 `st=` not needed
89 //st = PR.ReadReals(PR.CurrentList(allNbUSegments+1), "U Break Points", allUBreakPoints);
90 }
91
92 if (!allVBreakPoints.IsNull()){
93 Message_Msg Msg144("XSTEP_144");
94 PR.ReadReals(PR.CurrentList(allNbVSegments+1), Msg144, allVBreakPoints); //szv#4:S4163:12Mar99 `st=` not needed
95 //st = PR.ReadReals(PR.CurrentList(allNbVSegments+1), "V Break Points", allVBreakPoints);
96 }
97
98 if (ubreak && vbreak)
99 {
100 allXCoeffs = new IGESBasic_HArray2OfHArray1OfReal(1, allNbUSegments, 1, allNbVSegments);
101 allYCoeffs = new IGESBasic_HArray2OfHArray1OfReal(1, allNbUSegments, 1, allNbVSegments);
102 allZCoeffs = new IGESBasic_HArray2OfHArray1OfReal(1, allNbUSegments, 1, allNbVSegments);
103 }
104
105 Handle(TColStd_HArray1OfReal) Temp; // = new TColStd_HArray1OfReal(1, 16);
106
107 if (! allXCoeffs.IsNull()) {
108 Standard_Boolean st;
109
110 Message_Msg Msg145_X("XSTEP_145");
111 Msg145_X.Arg("X");
112
113 Message_Msg Msg145_Y("XSTEP_145");
114 Msg145_Y.Arg("Y");
115
116 Message_Msg Msg145_Z("XSTEP_145");
117 Msg145_Z.Arg("Z");
118
119 for (i = 1; i <= allNbUSegments; i++) {
120 for (j = 1; j <= allNbVSegments; j++) {
121 st = PR.ReadReals (PR.CurrentList(16),Msg145_X,Temp);
122 //st = PR.ReadReals (PR.CurrentList(16),"X Coefficient Of Patch",Temp);
123 if (st && Temp->Length() == 16) allXCoeffs->SetValue(i,j,Temp);
124 else {
125 Message_Msg Msg147_X("XSTEP_147");
126 Msg147_X.Arg("X");
127 PR.SendFail (Msg147_X);
128 }
129 st = PR.ReadReals (PR.CurrentList(16),Msg145_Y,Temp);
130 //st = PR.ReadReals (PR.CurrentList(16),"Y Coefficient Of Patch",Temp);
131 if (st && Temp->Length() == 16) allYCoeffs->SetValue(i, j, Temp);
132 else {
133 Message_Msg Msg147_Y("XSTEP_147");
134 Msg147_Y.Arg("Y");
135 PR.SendFail (Msg147_Y);
136 }
137 st = PR.ReadReals (PR.CurrentList(16),Msg145_Z,Temp);
138 //st = PR.ReadReals (PR.CurrentList(16),"Z Coefficient Of Patch",Temp);
139 if (st && Temp->Length() == 16) allZCoeffs->SetValue(i, j, Temp);
140 else if (i < allNbUSegments || j < allNbVSegments) {
141 Message_Msg Msg147_Z("XSTEP_147");
142 Msg147_Z.Arg("Z");
143 PR.SendFail (Msg147_Z);
144 }
145 else {
146// Si fin manquante ... On refait temp !
147// Les valeurs n ont pas ete lues ... il faut d abord les relire !
148 Temp = new TColStd_HArray1OfReal (1,16); Temp->Init(0.);
149 for (k = 1; k <= 16; k ++) {
150 Standard_Real vl;
151 if (!PR.ReadReal (PR.Current(),vl)) {
152 Message_Msg Msg146("XSTEP_146");
153 PR.SendFail(Msg146);
154 break;
155 }
156 //if (!PR.ReadReal (PR.Current(),"Z of very last patch",vl)) break;
157 Temp->SetValue(k,vl);
158 }
159 allZCoeffs->SetValue(i, j, Temp);
160 PR.Mend("Last patch incomplete, defaulted");
161 }
162 }
163 for (Standard_Integer kk = 1; kk <= 48; kk++)
164 PR.SetCurrentNumber(PR.CurrentNumber() + 1);
165 //Skip the Arbitrary Values
166 }
167 }
168 if (vbreak)
169 for (k = 1; k <= 48*(allNbVSegments+1); k++)
170 PR.SetCurrentNumber(PR.CurrentNumber() + 1);
171 // Skip the Arbitrary Values
172
173 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
174 ent->Init
175 (aBoundaryType , aPatchType, allUBreakPoints, allVBreakPoints,
176 allXCoeffs, allYCoeffs, allZCoeffs);
177}
178
179void IGESGeom_ToolSplineSurface::WriteOwnParams
180 (const Handle(IGESGeom_SplineSurface)& ent, IGESData_IGESWriter& IW) const
181{
182 Standard_Integer I,J,k;
183
184 IW.Send(ent->BoundaryType());
185 IW.Send(ent->PatchType());
186
187 Standard_Integer nbUSegs = ent->NbUSegments();
188 Standard_Integer nbVSegs = ent->NbVSegments();
189 IW.Send(nbUSegs);
190 IW.Send(nbVSegs);
191
192 for (I = 1; I <= nbUSegs + 1; I ++)
193 IW.Send(ent->UBreakPoint(I));
194
195 for (I = 1; I <= nbVSegs + 1; I ++)
196 IW.Send(ent->VBreakPoint(I));
197
198 for (I = 1; I <= nbUSegs; I++)
199 {
200 for (J = 1 ; J <= nbVSegs; J++)
201 {
202 for (k = 1; k <= 16; k++)
203 IW.Send((ent->XPolynomial(I, J))->Value(k));
204 for (k = 1; k <= 16; k++)
205 IW.Send((ent->YPolynomial(I, J))->Value(k));
206 for (k = 1; k <= 16; k++)
207 IW.Send((ent->ZPolynomial(I, J))->Value(k));
208 }
209 for (k = 1; k <= 48; k++)
210 IW.Send( 0.0); //Send Arbitrary Values
211 }
212 for (J = 1; J <= (nbVSegs+1)*48; J++)
213 IW.Send( 0.0); //Send Arbitrary Values
214}
215
216void IGESGeom_ToolSplineSurface::OwnShared
217 (const Handle(IGESGeom_SplineSurface)& /* ent */, Interface_EntityIterator& /* iter */) const
218{
219}
220
221void IGESGeom_ToolSplineSurface::OwnCopy
222 (const Handle(IGESGeom_SplineSurface)& another,
223 const Handle(IGESGeom_SplineSurface)& ent, Interface_CopyTool& /* TC */) const
224{
225
226 Standard_Integer aBoundaryType, aPatchType, allNbUSegments, allNbVSegments;
227 Standard_Integer I, J;
228
229 aBoundaryType = another->BoundaryType();
230 aPatchType = another->PatchType();
231 allNbUSegments = another->NbUSegments();
232 allNbVSegments = another->NbVSegments();
233
234 Handle(TColStd_HArray1OfReal) allUBreakPoints =
235 new TColStd_HArray1OfReal(1, allNbUSegments+1);
236
237 Handle(TColStd_HArray1OfReal) allVBreakPoints =
238 new TColStd_HArray1OfReal(1, allNbVSegments+1);
239
240 for ( I =1; I <= allNbUSegments+1; I++)
241 allUBreakPoints->SetValue(I, another->UBreakPoint(I));
242
243 for ( I =1; I <= allNbVSegments+1; I++)
244 allVBreakPoints->SetValue(I, another->VBreakPoint(I));
245
246 Handle(IGESBasic_HArray2OfHArray1OfReal) allXCoeffs = new
247 IGESBasic_HArray2OfHArray1OfReal(1,allNbUSegments,1,allNbVSegments);
248
249 Handle(IGESBasic_HArray2OfHArray1OfReal) allYCoeffs = new
250 IGESBasic_HArray2OfHArray1OfReal(1,allNbUSegments,1,allNbVSegments);
251
252 Handle(IGESBasic_HArray2OfHArray1OfReal) allZCoeffs = new
253 IGESBasic_HArray2OfHArray1OfReal(1,allNbUSegments,1,allNbVSegments);
254
255 Handle(TColStd_HArray1OfReal) temp =
256 new TColStd_HArray1OfReal(1, 16);
257
258 for (I =1; I <= allNbUSegments; I++)
259 for (J = 1; J <= allNbVSegments; J++)
260 {
261 temp = another->XPolynomial(I, J);
262 allXCoeffs->SetValue(I,J,temp);
263 temp = another->YPolynomial(I,J);
264 allYCoeffs->SetValue(I,J,temp);
265 temp = another->ZPolynomial(I,J);
266 allZCoeffs->SetValue(I,J,temp);
267 }
268
269 ent->Init(aBoundaryType , aPatchType, allUBreakPoints, allVBreakPoints,
270 allXCoeffs, allYCoeffs, allZCoeffs);
271}
272
273
274IGESData_DirChecker IGESGeom_ToolSplineSurface::DirChecker
275 (const Handle(IGESGeom_SplineSurface)& /* ent */ ) const
276{
277 IGESData_DirChecker DC(114,0);
278 DC.Structure(IGESData_DefVoid);
279 DC.LineFont(IGESData_DefAny);
280// DC.LineWeight(IGESData_DefValue);
281 DC.Color(IGESData_DefAny);
282 DC.HierarchyStatusIgnored ();
283 return DC;
284}
285
286void IGESGeom_ToolSplineSurface::OwnCheck
287 (const Handle(IGESGeom_SplineSurface)& ent,
288 const Interface_ShareTool& , Handle(Interface_Check)& ach) const
289{
290
291 // MGE 30/07/98
292 // Building of messages
293 //========================================
294 // Message_Msg Msg140("XSTEP_140");
295 //========================================
296
297 if (ent->BoundaryType() < 1 || ent->BoundaryType() > 6){
298 Message_Msg Msg140("XSTEP_140");
299 ach->SendFail(Msg140);
300 }
301// if (ent->PatchType() < 0 || ent->PatchType() > 1)
302// ach.AddFail("Incorrect Patch Type not in [0-1]");
303}
304
305void IGESGeom_ToolSplineSurface::OwnDump
306 (const Handle(IGESGeom_SplineSurface)& ent, const IGESData_IGESDumper& /* dumper */,
307 const Handle(Message_Messenger)& S, const Standard_Integer level) const
308{
309 S << "IGESGeom_SplineSurface" << endl;
310
311 Standard_Integer I, J;
312 Standard_Integer nbUSegs = ent->NbUSegments();
313 Standard_Integer nbVSegs = ent->NbVSegments();
314 Handle(TColStd_HArray1OfReal) temp;
315
316 S << "The Spline Boundary Type : " << ent->BoundaryType() ;
317 switch (ent->BoundaryType())
318 {
319 case 1 : S << " (Linear)"; break;
320 case 2 : S << " (Quadratic)"; break;
321 case 3 : S << " (Cubic)"; break;
322 case 4 : S << " (Wilson-Fowler)"; break;
323 case 5 : S << " (Modified Wison-Fowler)"; break;
324 case 6 : S << " (B-Spline)"; break;
325 default : S << " (Invalid value)"; break;
326 }
327 S << endl;
328 S << "The Patch Type : " << ent->PatchType();
329 if (ent->PatchType() == 1) S << " (Cartesian Product)";
330 else S << " (Unspecified)";
331 S << endl;
332 S << "Number Of Segments. In U : "
333 << nbUSegs << " " << " In V : " << nbVSegs << endl;
334 S << "The U Break Points : ";
335 IGESData_DumpVals(S ,level,1, nbUSegs+1,ent->UBreakPoint);
336 S <<endl<< "The V Break Points : ";
337 IGESData_DumpVals(S ,level,1, nbVSegs+1,ent->VBreakPoint);
338
339 S <<endl<< " X-Y-Z Polynomials Of Segments : ";
340 S << endl;
341 if (level > 4)
342 {
343 for (I = 1; I <= nbUSegs; I++)
344 for (J = 1; J <= nbVSegs; J++)
345 {
346 S << "[" << I <<"," << J << "]: " << endl;
347 S << "X Polynomial : ";
348 temp = ent->XPolynomial(I,J);
349 IGESData_DumpVals(S,level,1, temp->Length(),temp->Value);
350 S << endl;
351 S << "Y Polynomial : ";
352 temp = ent->YPolynomial(I,J);
353 IGESData_DumpVals(S,level,1, temp->Length(),temp->Value);
354 S << endl;
355 S << "Z Polynomial : ";
356 temp = ent->ZPolynomial(I,J);
357 IGESData_DumpVals(S,level,1, temp->Length(),temp->Value);
358 S << endl;
359 }
360 }
361 else S << endl;
362}