0028661: BRepOffsetAPI_MakePipeShell throws an exception Standard_NoSuchObject: NColl...
[occt.git] / src / BRepTest / BRepTest_FilletCommands.cxx
CommitLineData
b311480e 1// Created on: 1994-06-20
2// Created by: Modeling
3// Copyright (c) 1994-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
7fd59977 17#include <BRepTest.hxx>
18#include <TColgp_Array1OfPnt2d.hxx>
19#include <DBRep.hxx>
20#include <Draw_Interpretor.hxx>
21#include <Draw_Appli.hxx>
22#include <BRepFilletAPI_MakeFillet.hxx>
7fd59977 23#include <BiTgte_Blend.hxx>
24#include <TopOpeBRepBuild_HBuilder.hxx>
25#include <TopTools_ListIteratorOfListOfShape.hxx>
26#include <TopAbs_ShapeEnum.hxx>
27#include <TopoDS_Shape.hxx>
28#include <TopoDS_Compound.hxx>
29#include <TopoDS_Edge.hxx>
30#include <TopoDS_Vertex.hxx>
31#include <TopoDS.hxx>
32#include <TopExp.hxx>
33#include <TopExp_Explorer.hxx>
34
4e57c75e 35#include <BOPAlgo_PaveFiller.hxx>
36
7fd59977 37#include <BRepAlgoAPI_BooleanOperation.hxx>
38#include <BRepAlgoAPI_Fuse.hxx>
39#include <BRepAlgoAPI_Cut.hxx>
40#include <BRepAlgoAPI_Section.hxx>
41
42#include <FilletSurf_Builder.hxx>
43#include <ChFi3d_FilletShape.hxx>
44#include <Geom_TrimmedCurve.hxx>
543a9964 45#include <Geom_Surface.hxx>
46#include <Geom_Curve.hxx>
47#include <Geom2d_Curve.hxx>
7fd59977 48#include <TopTools_ListOfShape.hxx>
49#include <FilletSurf_StatusType.hxx>
50#include <FilletSurf_ErrorTypeStatus.hxx>
51#include <TopAbs.hxx>
52#include <DrawTrSurf.hxx>
53
7fd59977 54#include <stdio.h>
7fd59977 55
56
57static Standard_Real t3d = 1.e-4;
58static Standard_Real t2d = 1.e-5;
59static Standard_Real ta = 1.e-2;
60static Standard_Real fl = 1.e-3;
61static Standard_Real tapp_angle = 1.e-2;
62static GeomAbs_Shape blend_cont = GeomAbs_C1;
63
64static BRepFilletAPI_MakeFillet* Rakk = 0;
65static BRepFilletAPI_MakeFillet* Rake = 0;
66static char name[100];
67
68
69static Standard_Integer contblend(Draw_Interpretor& di, Standard_Integer narg, const char** a)
70{
71 if(narg ==1) {
72 //cout<<"tolerance angular of approximation : "<< tapp_angle <<endl;
73 //cout<<"internal continuity : ";
74 di<<"tolerance angular of approximation : "<< tapp_angle <<"\n";
75 di<<"internal continuity : ";
76 switch (blend_cont) {
77 case GeomAbs_C0:
78 //cout << ""<<endl;
586db386 79 di << "C0\n";
7fd59977 80 break;
81 case GeomAbs_C1:
82 //cout << "C1"<<endl;
586db386 83 di << "C1\n";
7fd59977 84 break;
85 case GeomAbs_C2:
86 //cout << "C2"<<endl;
586db386 87 di << "C2\n";
7fd59977 88 break;
7fd59977 89 default:
90 break;
7fd59977 91 }
92 return 0;
93 }
94 else {
95 if (narg >3) return 1;
91322f44 96 if (narg == 3) { tapp_angle = Abs(Draw::Atof(a[2])); }
7fd59977 97 char c=a[1][1];
98 switch (c) {
99 case '0':
100 blend_cont = GeomAbs_C0;
101 break;
102 case '2':
103 blend_cont = GeomAbs_C2;
104 break;
105 default :
106 blend_cont = GeomAbs_C1;
107 }
108 return 0;
109 }
110}
111
112static void printtolblend(Draw_Interpretor& di)
113{
114 //cout<<"tolerance ang : "<<ta<<endl;
115 //cout<<"tolerance 3d : "<<t3d<<endl;
116 //cout<<"tolerance 2d : "<<t2d<<endl;
117 //cout<<"fleche : "<<fl<<endl;
118
119 //cout<<"tolblend "<<ta<<" "<<t3d<<" "<<t2d<<" "<<fl<<endl;
120
121 di<<"tolerance ang : "<<ta<<"\n";
122 di<<"tolerance 3d : "<<t3d<<"\n";
123 di<<"tolerance 2d : "<<t2d<<"\n";
124 di<<"fleche : "<<fl<<"\n";
125
126 di<<"tolblend "<<ta<<" "<<t3d<<" "<<t2d<<" "<<fl<<"\n";
127}
128
129static Standard_Integer tolblend(Draw_Interpretor& di, Standard_Integer narg, const char** a)
130{
131 if(narg == 1){
132 printtolblend(di);
133 return 0;
134 }
135 else if(narg == 5){
91322f44 136 ta = Draw::Atof(a[1]);
137 t3d = Draw::Atof(a[2]);
138 t2d = Draw::Atof(a[3]);
139 fl = Draw::Atof(a[4]);
7fd59977 140 return 0;
141 }
142 return 1;
143}
144static Standard_Integer BLEND(Draw_Interpretor& di, Standard_Integer narg, const char** a)
145{
146 if(Rakk != 0) {delete Rakk; Rakk = 0;}
147 printtolblend(di);
148 if (narg<5) return 1;
149 TopoDS_Shape V = DBRep::Get(a[2]);
150 if(V.IsNull()) return 1;
151 ChFi3d_FilletShape FSh = ChFi3d_Rational;
152 if (narg%2 == 0) {
153 if (!strcasecmp(a[narg-1], "Q")) {
154 FSh = ChFi3d_QuasiAngular;
155 }
156 else if (!strcasecmp(a[narg-1], "P")) {
157 FSh = ChFi3d_Polynomial;
158 }
159 }
160 Rakk = new BRepFilletAPI_MakeFillet(V,FSh);
161 Rakk->SetParams(ta,t3d,t2d,t3d,t2d,fl);
162 Rakk->SetContinuity(blend_cont, tapp_angle);
163 Standard_Real Rad;
164 TopoDS_Edge E;
165 Standard_Integer nbedge = 0;
166 for (Standard_Integer ii = 1; ii < (narg-1)/2; ii++){
91322f44 167 Rad = Draw::Atof(a[2*ii + 1]);
7fd59977 168 TopoDS_Shape aLocalEdge(DBRep::Get(a[(2*ii+2)],TopAbs_EDGE));
169 E = TopoDS::Edge(aLocalEdge);
170// E = TopoDS::Edge(DBRep::Get(a[(2*ii+2)],TopAbs_EDGE));
171 if(!E.IsNull()){
172 Rakk->Add(Rad,E);
173 nbedge++;
174 }
175 }
176 if(!nbedge) return 1;
177 Rakk->Build();
178 if(!Rakk->IsDone()) return 1;
179 TopoDS_Shape res = Rakk->Shape();
180 DBRep::Set(a[1],res);
181 return 0;
182}
183
184static void PrintHist(const TopoDS_Shape& S,
185 TopTools_ListIteratorOfListOfShape& It,
186 Standard_Integer& nbgen)
187{
188 TopoDS_Compound C;
189 BRep_Builder B;
190 B.MakeCompound(C);
191 B.Add(C,S);
192 char localname[100];
193 if(nbgen<10){
91322f44 194 Sprintf(localname,"generated_00%d", nbgen++);
7fd59977 195 }
196 else if(nbgen<100){
91322f44 197 Sprintf(localname,"generated_0%d", nbgen++);
7fd59977 198 }
199 else {
91322f44 200 Sprintf(localname,"generated_%d", nbgen++);
7fd59977 201 }
202 for(; It.More(); It.Next()){
203 B.Add(C,It.Value());
204 }
205 DBRep::Set(localname,C);
206}
207
208static Standard_Integer CheckHist(Draw_Interpretor& di,
209 Standard_Integer ,
210 const char** )
211{
212 if(Rakk == 0) {
0d969553 213 //cout<<"No active Builder"<<endl;
586db386 214 di<<"No active Builder\n";
7fd59977 215 return 1;
216 }
217 if(!Rakk->IsDone()) {
0d969553 218 //cout<<"Active Builder Not Done"<<endl;
586db386 219 di<<"Active Builder Not Done\n";
7fd59977 220 return 1;
221 }
222 Standard_Integer nbc = Rakk->NbContours();
223 Standard_Integer nbgen = 0;
224 TopTools_ListIteratorOfListOfShape It;
225 TopoDS_Shape curshape;
226 for(Standard_Integer i = 1; i <= nbc; i++){
227 curshape = Rakk->FirstVertex(i);
228 It.Initialize(Rakk->Generated(curshape));
229 PrintHist(curshape,It,nbgen);
230 Standard_Integer nbe = Rakk->NbEdges(i);
231 for(Standard_Integer j = 1; j <= nbe; j++){
232 curshape = Rakk->Edge(i,j);
233 It.Initialize(Rakk->Generated(curshape));
234 PrintHist(curshape,It,nbgen);
235 }
236 curshape = Rakk->LastVertex(i);
237 It.Initialize(Rakk->Generated(curshape));
238 PrintHist(curshape,It,nbgen);
239 }
240 //cout<<"foreach g [lsort [dir gen*]] { wclick; puts [dname $g]; donl $g; }"<<endl;
586db386 241 di<<"foreach g [lsort [dir gen*]] { wclick; puts [dname $g]; donl $g; }\n";
7fd59977 242 return 0;
243}
244
245static Standard_Integer MKEVOL(Draw_Interpretor& di,
246 Standard_Integer narg,
247 const char** a)
248{
249 if(Rake != 0) {delete Rake; Rake = 0;}
250 printtolblend(di);
251 if (narg < 3) return 1;
252 TopoDS_Shape V = DBRep::Get(a[2]);
253 Rake = new BRepFilletAPI_MakeFillet(V);
254 Rake->SetParams(ta,t3d,t2d,t3d,t2d,fl);
255 Rake->SetContinuity(blend_cont, tapp_angle);
256 if (narg == 4) {
257 ChFi3d_FilletShape FSh = ChFi3d_Rational;
258 if (!strcasecmp(a[3], "Q")) {
259 FSh = ChFi3d_QuasiAngular;
260 }
261 else if (!strcasecmp(a[3], "P")) {
262 FSh = ChFi3d_Polynomial;
263 }
264 Rake->SetFilletShape(FSh);
265 }
266 strcpy(name, a[1]);
267 return 0;
268}
269
270static Standard_Integer UPDATEVOL(Draw_Interpretor& di,
271 Standard_Integer narg,
272 const char** a)
273{
274 if(Rake == 0){
0d969553 275 //cout << "MakeFillet not initialized"<<endl;
586db386 276 di << "MakeFillet not initialized\n";
7fd59977 277 return 1 ;
278 }
279 if(narg%2 != 0 || narg < 4) return 1;
280 TColgp_Array1OfPnt2d uandr(1,(narg/2)-1);
281 Standard_Real Rad, Par;
282 TopoDS_Shape aLocalEdge(DBRep::Get(a[1],TopAbs_EDGE));
283 TopoDS_Edge E = TopoDS::Edge(aLocalEdge);
284// TopoDS_Edge E = TopoDS::Edge(DBRep::Get(a[1],TopAbs_EDGE));
285 for (Standard_Integer ii = 1; ii <= (narg/2)-1; ii++){
91322f44 286 Par = Draw::Atof(a[2*ii]);
287 Rad = Draw::Atof(a[2*ii + 1]);
7fd59977 288 uandr.ChangeValue(ii).SetCoord(Par,Rad);
289 }
290 Rake->Add(uandr,E);
291 return 0;
292}
293
294static Standard_Integer BUILDEVOL(Draw_Interpretor& di,
295 Standard_Integer,
296 const char**)
297{
298 if(Rake == 0){
0d969553 299 //cout << "MakeFillet not initialized"<<endl;
586db386 300 di << "MakeFillet not initialized\n";
7fd59977 301 return 1 ;
302 }
303 Rake->Build();
304 if(Rake->IsDone()){
305 TopoDS_Shape result = Rake->Shape();
306 DBRep::Set(name,result);
307 if(Rake != 0) {delete Rake; Rake = 0;}
308 return 0;
309 }
310 if(Rake != 0) {delete Rake; Rake = 0;}
311 return 1;
312}
313
314
315
316
7fd59977 317//**********************************************
318// bfuse or bcut and then blend the section
319//**********************************************
320
321Standard_Integer boptopoblend(Draw_Interpretor& di, Standard_Integer narg, const char** a)
322{
323 printtolblend(di);
b5ef9d91 324 if(narg < 5)
325 {
326 cout << "Use <command name> result shape1 shape2 radius [-d]" << endl;
327 return 1;
328 }
7fd59977 329
330 Standard_Boolean fuse = !strcmp(a[0],"bfuseblend");
331 TopoDS_Shape S1 = DBRep::Get(a[2]);
332 TopoDS_Shape S2 = DBRep::Get(a[3]);
333 if (S1.IsNull() || S2.IsNull()) {
334 printf(" Null shapes are not allowed \n");
335 return 1;
336 }
91322f44 337 Standard_Real Rad = Draw::Atof(a[4]);
b5ef9d91 338 Standard_Boolean isDebug = Standard_False;
339
340 if(narg == 6)
341 {
342 if(!strcmp(a[5], "-d"))
343 {
344 isDebug = Standard_True;
345 }
346 }
7fd59977 347
4e57c75e 348 BOPAlgo_PaveFiller theDSFiller;
349 BOPCol_ListOfShape aLS;
350 aLS.Append(S1);
351 aLS.Append(S2);
352 theDSFiller.SetArguments(aLS);
353 //
354 theDSFiller.Perform();
355 if (theDSFiller.ErrorStatus()) {
7fd59977 356 printf("Check types of the arguments, please\n");
357 return 1;
358 }
7fd59977 359
360 BRepAlgoAPI_BooleanOperation* pBuilder=NULL;
361
362 if (fuse)
363 pBuilder = new BRepAlgoAPI_Fuse( S1, S2, theDSFiller );
364 else
365 pBuilder = new BRepAlgoAPI_Cut ( S1, S2, theDSFiller );
366
367 Standard_Boolean anIsDone = pBuilder->IsDone();
368 if (!anIsDone)
b5ef9d91 369 {
370 printf("boolean operation not done ErrorStatus()=%d\n", pBuilder->ErrorStatus());
371 return 1;
372 }
7fd59977 373
374 TopoDS_Shape ResultOfBop = pBuilder->Shape();
375
376 delete pBuilder;
b5ef9d91 377
378 const int aStrLen = 1000;
379 char aBuff[aStrLen];
380
381 if(isDebug)
382 {
383 strcpy(aBuff, a[1]);
384 DBRep::Set( strcat(aBuff, "_bop"), ResultOfBop );
385
386 di << "Intermediate result of BOP-operation is saved to \"" << aBuff << "\" variable\n";
387 }
388
7fd59977 389 pBuilder = new BRepAlgoAPI_Section( S1, S2, theDSFiller );
390 TopoDS_Shape theSection = pBuilder->Shape();
391
b5ef9d91 392 if(isDebug)
393 {
394 strcpy(aBuff, a[1]);
395 DBRep::Set( strcat(aBuff, "_sec"), theSection );
396 di << "Intermediate bopsection result is saved to \"" << aBuff << "\" variable\n";
397 }
398
7fd59977 399 TopoDS_Compound result;
400 BRep_Builder BB;
401 BB.MakeCompound(result);
402
403 TopExp_Explorer Explo( ResultOfBop, TopAbs_SOLID );
404 for (; Explo.More(); Explo.Next())
b5ef9d91 405 {
406 const TopoDS_Shape& aSolid = Explo.Current();
407
408 BRepFilletAPI_MakeFillet Blender(aSolid);
409 Blender.SetParams(ta,t3d,t2d,t3d,t2d,fl);
410 Blender.SetContinuity( blend_cont, tapp_angle );
411
412 TopExp_Explorer expsec( theSection, TopAbs_EDGE );
413 for (; expsec.More(); expsec.Next())
414 {
415 TopoDS_Edge anEdge = TopoDS::Edge(expsec.Current());
416 Blender.Add( Rad, anEdge );
417 }
418
419 Blender.Build();
420 if (Blender.IsDone())
421 BB.Add( result, Blender.Shape() );
422 else
7fd59977 423 {
b5ef9d91 424 di << "Error: Cannot find the result of BLEND-operation."
425 " The result of BOP operation will be returned.\n";
426 BB.Add( result, aSolid );
7fd59977 427 }
b5ef9d91 428 }
7fd59977 429
430 delete pBuilder;
431 DBRep::Set( a[1], result );
432 return 0;
433}
434
435
436static Standard_Integer blend1(Draw_Interpretor& di, Standard_Integer narg, const char** a)
437{
438 if (narg<5) return 1;
439 TopoDS_Shape V = DBRep::Get(a[2]);
440 if(V.IsNull()) return 1;
441 Standard_Integer nb ,i;
442 Standard_Real Rad;
443 Standard_Boolean simul=Standard_False;
444 const char *ns0=(a[1]);
91322f44 445 Rad = Draw::Atof(a[3]);
7fd59977 446 TopTools_ListOfShape E;
447 for (i=4; i <=(narg-1) ; i++){
448 TopoDS_Shape edge= DBRep::Get(a[i],TopAbs_EDGE);
449 if (edge.IsNull()) return 1 ;
450 if(edge.ShapeType()!=TopAbs_EDGE) return 1;
451 E.Append(edge);
452 }
75259fc5 453 FilletSurf_Builder aRakk(V,E,Rad);
454 if (simul) aRakk.Simulate();
455 else aRakk.Perform();
7fd59977 456
457 //if (Rakk.IsDone()==FilletSurf_IsNotOk)
458 // { FilletSurf_ErrorTypeStatus err=Rakk.StatusError();
459 // if (err==FilletSurf_EmptyList) cout<< "StatusError=EmptyList"<<endl;
460 // else if (err==FilletSurf_EdgeNotG1) cout<< "StatusError=NotG1"<<endl;
461 // else if (err==FilletSurf_FacesNotG1) cout<< "StatusError=facesNotG1"<<endl;
462 // else if (err==FilletSurf_EdgeNotOnShape)
463 // cout<< "StatusError=edgenotonshape"<<endl;
464 // else if (err==FilletSurf_NotSharpEdge ) cout<< "StatusError=notsharpedge"<<endl;
465 // else if (err==FilletSurf_PbFilletCompute) cout <<"StatusError=PBFillet"<<endl;
466 // }
467 // else {
468 // if (Rakk.IsDone()==FilletSurf_IsPartial) cout <<"resultat partiel"<<endl;
75259fc5 469 if (aRakk.IsDone()==FilletSurf_IsNotOk)
470 { FilletSurf_ErrorTypeStatus err=aRakk.StatusError();
586db386 471 if (err==FilletSurf_EmptyList) di<< "StatusError=EmptyList\n";
472 else if (err==FilletSurf_EdgeNotG1) di<< "StatusError=NotG1\n";
473 else if (err==FilletSurf_FacesNotG1) di<< "StatusError=facesNotG1\n";
75259fc5 474 else if (err==FilletSurf_EdgeNotOnShape)
586db386 475 di<< "StatusError=edgenotonshape\n";
476 else if (err==FilletSurf_NotSharpEdge ) di<< "StatusError=notsharpedge\n";
477 else if (err==FilletSurf_PbFilletCompute) di <<"StatusError=PBFillet\n";
7fd59977 478 }
479 else {
586db386 480 if (aRakk.IsDone()==FilletSurf_IsPartial) di <<"partial result\n";
7fd59977 481
75259fc5 482 nb=aRakk.NbSurface();
7fd59977 483 char localname [100];
484 char *temp;
485
486 // affichage du type d'arret
487
488 if (!simul)
489 {
75259fc5 490 //if (Rakk.StartSectionStatus()==FilletSurf_NoExtremityOnEdge)
7fd59977 491 // {cout<<" type deb conges = WLBLOUT"<<endl;}
75259fc5 492 //else if (Rakk.StartSectionStatus()==FilletSurf_OneExtremityOnEdge )
7fd59977 493 // { cout<<" type deb conges = WLBLSTOP"<<endl;}
494 //else if (Rakk.StartSectionStatus()==FilletSurf_TwoExtremityOnEdge)
495 // {cout<<" type deb conges = WLBLEND"<<endl;}
75259fc5 496 if (aRakk.StartSectionStatus()==FilletSurf_NoExtremityOnEdge)
586db386 497 {di<<" type start fillets = WLBLOUT\n";}
75259fc5 498 else if (aRakk.StartSectionStatus()==FilletSurf_OneExtremityOnEdge)
586db386 499 { di<<" type start fillets = WLBLSTOP\n";}
75259fc5 500 else if (aRakk.StartSectionStatus()==FilletSurf_TwoExtremityOnEdge)
586db386 501 {di<<" type start fillets = WLBLEND\n";}
7fd59977 502
503 //if (Rakk.EndSectionStatus()==FilletSurf_NoExtremityOnEdge)
504 // {cout<<" type fin conges = WLBLOUT"<<endl;}
505 //else if (Rakk.EndSectionStatus()==FilletSurf_OneExtremityOnEdge)
506 // {cout<<" type fin conges = WLBLSTOP"<<endl;}
507 //else if (Rakk.EndSectionStatus()==FilletSurf_TwoExtremityOnEdge)
508 // { cout<<" type fin conges = WLBLEND"<<endl;}
75259fc5 509 if (aRakk.EndSectionStatus()==FilletSurf_NoExtremityOnEdge)
586db386 510 {di<<" type end fillets = WLBLOUT\n";}
75259fc5 511 else if (aRakk.EndSectionStatus()==FilletSurf_OneExtremityOnEdge)
586db386 512 {di<<" type end fillets = WLBLSTOP\n";}
75259fc5 513 else if (aRakk.EndSectionStatus()==FilletSurf_TwoExtremityOnEdge)
586db386 514 { di<<" type end fillets = WLBLEND\n";}
7fd59977 515 Standard_Real f,l;
75259fc5 516 f = aRakk.FirstParameter();
517 l = aRakk.LastParameter();
0d969553
Y
518 //cout<<"parameter on edge start : "<<f<<endl;
519 //cout<<"parameter on edge end : "<<l<<endl;
520 di<<"parametre on edge start : "<<f<<"\n";
521 di<<"parametre on edge end : "<<l<<"\n";
7fd59977 522 for (i=1;i<=nb;i++){
523 //precision
524 //cout<<"precision "<< i << "= "<<Rakk.TolApp3d(i)<<endl;
75259fc5 525 di<<"precision "<< i << "= "<<aRakk.TolApp3d(i)<<"\n";
7fd59977 526
0d969553 527 // display resulting surfaces
91322f44 528 Sprintf(localname, "%s%d" ,ns0,i);
7fd59977 529 temp = localname;
75259fc5 530 DrawTrSurf::Set(temp,aRakk.SurfaceFillet(i));
7fd59977 531 di << localname<< " ";
532
0d969553 533 // display curves 3d
91322f44 534 Sprintf(localname, "%s%d" ,"courb1",i);
7fd59977 535 temp =localname;
75259fc5 536 DrawTrSurf::Set(temp,aRakk.CurveOnFace1(i));
7fd59977 537 di << localname<< " ";
91322f44 538 Sprintf(localname, "%s%d" ,"courb2",i);
7fd59977 539 temp =localname;
75259fc5 540 DrawTrSurf::Set(temp,aRakk.CurveOnFace2(i));
7fd59977 541 di << localname<< " ";
542
0d969553 543 // display supports
91322f44 544 Sprintf(localname, "%s%d" ,"face1",i);
7fd59977 545 temp =localname ;
75259fc5 546 DBRep::Set(temp,aRakk.SupportFace1(i));
7fd59977 547 di << localname<< " ";
91322f44 548 Sprintf(localname, "%s%d" ,"face2",i);
7fd59977 549 temp =localname;
75259fc5 550 DBRep::Set(temp,aRakk.SupportFace2(i));
7fd59977 551 di << localname<< " ";
552
0d969553 553 // display Pcurves on faces
91322f44 554 Sprintf(localname, "%s%d" ,"pcurveonface1",i);
7fd59977 555 temp =localname ;
75259fc5 556 DrawTrSurf::Set(temp,aRakk.PCurveOnFace1(i));
7fd59977 557 di << localname<< " ";
91322f44 558 Sprintf(localname, "%s%d" ,"pcurveonface2",i);
7fd59977 559 temp =localname;
75259fc5 560 DrawTrSurf::Set(temp,aRakk.PCurveOnFace2(i));
7fd59977 561 di << localname<< " ";
562
0d969553 563 // display Pcurves on the fillet
91322f44 564 Sprintf(localname, "%s%d" ,"pcurveonconge1",i);
7fd59977 565 temp =localname;
75259fc5 566 DrawTrSurf::Set(temp,aRakk.PCurve1OnFillet(i));
7fd59977 567 di << localname<< " ";
91322f44 568 Sprintf(localname, "%s%d" ,"pcurveonconge2",i);
7fd59977 569 temp =localname;
75259fc5 570 DrawTrSurf::Set(temp,aRakk.PCurve2OnFillet(i));
7fd59977 571 di << localname<< " ";
572
573 } }
574 else{
575 Standard_Integer j;
576
577 for (i=1;i<=nb;i++)
75259fc5 578 {Standard_Integer s=aRakk.NbSection(i);
7fd59977 579 for (j=1;j<=s;j++)
c04c30b3 580 {Handle(Geom_TrimmedCurve) Sec;
75259fc5 581 aRakk.Section(i,j,Sec);
91322f44 582 Sprintf(localname, "%s%d%d" ,"sec",i,j);
7fd59977 583 temp =localname;
584 DrawTrSurf::Set (temp,Sec);
585 di << localname<< " ";}
586 }}
587 }
588 return 0;
589}
590
591//=======================================================================
592//function : rollingball
593//purpose :
594//=======================================================================
595
596Standard_Integer rollingball(Draw_Interpretor& di, Standard_Integer n, const char** a)
597{
598 if ( n < 2) return 1;
599
600 TopoDS_Shape S = DBRep::Get(a[2]);
601 if ( S.IsNull()) return 1;
91322f44 602 Standard_Real Rad = Draw::Atof(a[3]);
7fd59977 603
0d969553 604 Standard_Real Tol = t3d; //the same as blend ! 1.e-7;
7fd59977 605
606 BiTgte_Blend Roll;
607 Roll.Init(S,Rad,Tol,Standard_False);
608
609 Standard_Integer Nb = 0;
610 for ( Standard_Integer i = 4; i <= n-1; i++) {
611 if ( !strcmp(a[i],"@")) {
612 Nb++;
613 continue;
614 }
615
0d969553 616 if ( Nb == 0) { // return stop faces.
7fd59977 617 TopoDS_Shape aLocalFace(DBRep::Get(a[i],TopAbs_FACE));
618 TopoDS_Face F1 = TopoDS::Face(aLocalFace);
619// TopoDS_Face F1 = TopoDS::Face(DBRep::Get(a[i],TopAbs_FACE));
620 if ( F1.IsNull()) {
0d969553 621 //cout << " Stop face not referenced." << endl;
586db386 622 di << " Stop face not referenced.\n";
7fd59977 623 return 1;
624 }
625 Roll.SetStoppingFace(F1);
626 }
0d969553 627 else if (Nb == 1) { // return faces on which the ball rotates
7fd59977 628 TopoDS_Shape aLocalFace(DBRep::Get(a[i],TopAbs_FACE));
629 TopoDS_Face F1 = TopoDS::Face(aLocalFace);
630// TopoDS_Face F1 = TopoDS::Face(DBRep::Get(a[i],TopAbs_FACE));
631 i++;
632 if ( !strcmp(a[i],"@")) {
0d969553 633 //cout << " Even number of ball support faces is required " << endl;
586db386 634 di << " Even number of ball support faces is required \n";
7fd59977 635 return 1;
636 }
637 aLocalFace = DBRep::Get(a[i],TopAbs_FACE);
638 TopoDS_Face F2 = TopoDS::Face(aLocalFace);
639// TopoDS_Face F2 = TopoDS::Face(DBRep::Get(a[i],TopAbs_FACE));
640 if ( F1.IsNull() || F2.IsNull()) {
0d969553 641 //cout << " Support face not referenced." << endl;
586db386 642 di << " Support face not referenced.\n";
7fd59977 643 return 1;
644 }
645 Roll.SetFaces(F1,F2);
646 }
0d969553 647 else if (Nb == 2) { // return the edge on which the ball rotates
7fd59977 648 TopoDS_Shape aLocalShape(DBRep::Get(a[i],TopAbs_EDGE));
649 TopoDS_Edge E = TopoDS::Edge(aLocalShape);
650// TopoDS_Edge E = TopoDS::Edge(DBRep::Get(a[i],TopAbs_EDGE));
651 if ( E.IsNull()) {
0d969553 652 //cout << " Edge not referenced." << endl;
586db386 653 di << " Edge not referenced.\n";
7fd59977 654 return 1;
655 }
656 Roll.SetEdge(E);
657 }
658
659 }
660 Standard_Boolean BuildShape = (!strcmp(a[0],"brollingball"));
661
662 Roll.Perform(BuildShape);
663
664 Standard_Boolean ComputeBranches = (!strcmp(a[0],"trollingball"));
665 char localname[100];
666 if (ComputeBranches) {
667 Standard_Integer NbBranches = Roll.NbBranches();
668 for (Standard_Integer i = 1; i <= NbBranches; i++) {
669 Standard_Integer From,To;
670 Roll.IndicesOfBranche(i,From,To);
0d969553 671 //cout << " Indexes of the " << i << "th Branch : ";
7fd59977 672 //cout << " " << From << " " << To << endl;
0d969553 673 di << " Indexes of the " << i << "th Branch : ";
7fd59977 674 di << " " << From << " " << To << "\n";
675 for (Standard_Integer j = From; j <= To; j++) {
676 const TopoDS_Shape& CurF = Roll.Face(j);
91322f44 677 Sprintf(localname,"%s_%d_%d",a[1],i,j);
7fd59977 678 DBRep::Set(localname,CurF);
679 }
680 }
681
682 }
683 else
684 DBRep::Set(a[1],Roll.Shape());
685
686 return 0;
687}
688
689//=======================================================================
690//function : FilletCommands
691//purpose :
692//=======================================================================
693
694void BRepTest::FilletCommands(Draw_Interpretor& theCommands)
695{
696 static Standard_Boolean done = Standard_False;
697 if (done) return;
698 done = Standard_True;
699
700 DBRep::BasicCommands(theCommands);
701
702 const char* g = "TOPOLOGY Fillet construction commands";
703
704 theCommands.Add("continuityblend",
705 "continuityblend C0/C1/C2 [tangle]",__FILE__,
706 contblend,g);
707
708 theCommands.Add("tolblend",
709 "tolblend [ta t3d t2d fl]",__FILE__,
710 tolblend,g);
711
712 theCommands.Add("blend",
713 "blend result object rad1 ed1 rad2 ed2 ... [R/Q/P]",__FILE__,
714 BLEND,g);
715
716 theCommands.Add("checkhist",
717 "checkhist",__FILE__,
718 CheckHist,g);
719
720 theCommands.Add("mkevol",
721 "mkevol result object (then use updatevol) [R/Q/P]",__FILE__,
722 MKEVOL,g);
723
724 theCommands.Add("updatevol",
725 "updatevol edge u1 rad1 u2 rad2 ...",__FILE__,
726 UPDATEVOL,g);
727
728 theCommands.Add("buildevol",
729 "buildevol end of the evol fillet computation",__FILE__,
730 BUILDEVOL,g);
731
7fd59977 732 theCommands.Add("bfuseblend",
b5ef9d91 733 "bfuseblend result shape1 shape2 radius [-d]",__FILE__,
7fd59977 734 boptopoblend,g);
735
736 theCommands.Add("bcutblend",
b5ef9d91 737 "bcutblend result shape1 tool radius [-d]",__FILE__,
7fd59977 738 boptopoblend,g);
739
740 theCommands.Add("blend1",
741 "blend1 result object rad ed1 ed2 ...",__FILE__,
742 blend1,g);
743
744 theCommands.Add("rollingball",
745 "rollingball r S radius [stopf1 ..] @ [f1 f2 ..] @ [e1 ..]",
746 __FILE__,
747 rollingball);
748
749 theCommands.Add("brollingball",
750 "brollingball r S radius [stopf1 ..] @ [f1 f2 ..] @ [e1 ..]",
751 __FILE__,
752 rollingball);
753
754 theCommands.Add("trollingball",
755 "trollingball r S radius [stopf1 ..] @ [f1 f2 ..] @ [e1 ..]",
756 __FILE__,
757 rollingball);
758}