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