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