1 // Created on: 1993-07-22
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <BRepTest.hxx>
19 #include <Draw_Interpretor.hxx>
20 #include <Draw_Appli.hxx>
22 #include <BRepFill.hxx>
23 #include <BRepBuilderAPI_PipeError.hxx>
24 #include <BRepFill_Generator.hxx>
25 #include <BRepPrimAPI_MakePrism.hxx>
26 #include <BRepPrimAPI_MakeRevol.hxx>
27 #include <BRepOffsetAPI_MakePipe.hxx>
28 #include <BRepOffsetAPI_MakeEvolved.hxx>
29 #include <BRepOffsetAPI_ThruSections.hxx>
30 #include <BRepOffsetAPI_MakePipeShell.hxx>
31 #include <BRepOffsetAPI_MiddlePath.hxx>
33 #include <BRepLib_MakeWire.hxx>
35 #include <TopTools_ListIteratorOfListOfShape.hxx>
36 #include <TopExp_Explorer.hxx>
38 #include <Precision.hxx>
39 #include <Law_Interpol.hxx>
42 #include <gp_Pnt2d.hxx>
43 #include <TColgp_Array1OfPnt2d.hxx>
45 static BRepOffsetAPI_MakePipeShell* Sweep= 0;
48 #include <Geom_Curve.hxx>
49 #include <GeomAdaptor_HCurve.hxx>
50 #include <GeomFill_Pipe.hxx>
51 #include <Geom_Surface.hxx>
52 #include <BRepBuilderAPI_MakeFace.hxx>
53 #include <BRep_Tool.hxx>
56 #include <Geom_Circle.hxx>
60 //=======================================================================
62 //=======================================================================
64 static Standard_Integer prism(Draw_Interpretor& , Standard_Integer n, const char** a)
68 TopoDS_Shape base = DBRep::Get(a[2]);
69 if (base.IsNull()) return 1;
71 gp_Vec V(Draw::Atof(a[3]),Draw::Atof(a[4]),Draw::Atof(a[5]));
73 Standard_Boolean copy = Standard_False;
74 Standard_Boolean inf = Standard_False;
75 Standard_Boolean sinf = Standard_False;
78 copy = (*a[6] == 'c') || (*a[6] == 'C');
79 inf = (*a[6] == 'i') || (*a[6] == 'I');
80 sinf = (*a[6] == 's') || (*a[6] == 'S');
86 res = BRepPrimAPI_MakePrism(base,gp_Dir(V),inf);
88 res = BRepPrimAPI_MakePrism(base,V,copy);
96 //=======================================================================
98 //=======================================================================
100 static Standard_Integer revol(Draw_Interpretor& ,
101 Standard_Integer n, const char** a)
103 if (n < 10) return 1;
105 TopoDS_Shape base = DBRep::Get(a[2]);
106 if (base.IsNull()) return 1;
108 gp_Pnt P(Draw::Atof(a[3]),Draw::Atof(a[4]),Draw::Atof(a[5]));
109 gp_Dir D(Draw::Atof(a[6]),Draw::Atof(a[7]),Draw::Atof(a[8]));
112 Standard_Real angle = Draw::Atof(a[9]) * (M_PI / 180.0);
114 Standard_Boolean copy = n > 10;
116 TopoDS_Shape res = BRepPrimAPI_MakeRevol(base,A,angle,copy);
118 DBRep::Set(a[1],res);
124 //=======================================================================
126 //=======================================================================
128 static Standard_Integer pipe(Draw_Interpretor& di,
129 Standard_Integer n, const char** a)
133 di << "pipe result Wire_spine Profile [Mode [Approx]]\n";
134 di << "Mode = 0 - CorrectedFrenet,\n";
135 di << " = 1 - Frenet,\n";
136 di << " = 2 - DiscreteTrihedron\n";
137 di << "Approx - force C1-approximation if result is C0\n";
141 if (n > 1 && n < 4) return 1;
143 TopoDS_Shape Spine = DBRep::Get(a[2],TopAbs_WIRE);
144 if ( Spine.IsNull()) return 1;
146 TopoDS_Shape Profile = DBRep::Get(a[3]);
147 if ( Profile.IsNull()) return 1;
149 GeomFill_Trihedron Mode = GeomFill_IsCorrectedFrenet;
152 Standard_Integer iMode = atoi(a[4]);
154 Mode = GeomFill_IsFrenet;
156 Mode = GeomFill_IsDiscreteTrihedron;
159 Standard_Boolean ForceApproxC1 = Standard_False;
161 ForceApproxC1 = Standard_True;
163 TopoDS_Shape S = BRepOffsetAPI_MakePipe(TopoDS::Wire(Spine),
173 //=======================================================================
175 static Standard_Integer geompipe(Draw_Interpretor& ,
176 Standard_Integer n, const char** a)
178 TopoDS_Shape Spine = DBRep::Get(a[2],TopAbs_EDGE);
179 if ( Spine.IsNull()) return 1;
180 if ( n < 5) return 1;
181 TopoDS_Shape Profile = DBRep::Get(a[3],TopAbs_EDGE);
182 if ( Profile.IsNull()) return 1;
183 Standard_Real aSpFirst,aSpLast,aPrFirst,aPrLast;
184 Handle(Geom_Curve) SpineCurve = BRep_Tool::Curve(TopoDS::Edge(Spine),aSpFirst,aSpLast);
185 Handle(Geom_Curve) ProfileCurve = BRep_Tool::Curve(TopoDS::Edge(Profile),aPrFirst,aPrLast);
186 Handle(GeomAdaptor_HCurve) aAdaptCurve = new GeomAdaptor_HCurve(SpineCurve,aSpFirst,aSpLast);
187 Standard_Boolean ByACR = Standard_False;
188 Standard_Boolean rotate = Standard_False;
189 Standard_Real Radius = Draw::Atof(a[4]);
192 ProfileCurve->D1(aSpFirst,ctr,norm);
193 gp_Vec xAxisStart(ctr,SpineCurve->Value(aSpFirst));
194 gp_Ax2 aAx2Start(ctr,norm,xAxisStart);
195 Handle(Geom_Circle) cStart=new Geom_Circle(aAx2Start,Radius);
196 Standard_Integer k =5;
198 ByACR = (Draw::Atoi(a[k++]) ==1);
200 rotate = (Draw::Atoi(a[k++])==1);
201 GeomFill_Pipe aPipe(ProfileCurve,aAdaptCurve,cStart,ByACR,rotate);
202 aPipe.Perform(Standard_True);
203 Handle(Geom_Surface) Sur=aPipe.Surface();
206 F = BRepBuilderAPI_MakeFace(Sur, Precision::Confusion());
211 //=======================================================================
214 //=======================================================================
216 Standard_Integer evolved(Draw_Interpretor& di, Standard_Integer n, const char** a)
219 //cout << " 1) evolved result base profil : "<< endl;
220 //cout << " The relative position of the profil on the base" << endl;
221 //cout << " is given in the referencial axis. " << endl;
222 //cout << " 2) evolved result base profil o : "<< endl;
223 //cout << " This position is automatically computed." << endl;
224 di << " 1) evolved result base profil : \n";
225 di << " The relative position of the profil on the base\n";
226 di << " is given in the referencial axis. \n";
227 di << " 2) evolved result base profil o : \n";
228 di << " This position is automatically computed.\n";
232 if ( n < 4 ) return 1;
233 Standard_Boolean IsAFace = Standard_False;
234 Standard_Boolean Solid = (!strcmp(a[0],"evolvedsolid"));
238 TopoDS_Shape Base = DBRep::Get(a[2],TopAbs_WIRE,Standard_False);
239 if ( Base.IsNull()) {
240 Base = DBRep::Get(a[2],TopAbs_FACE,Standard_False);
241 IsAFace = Standard_True;
243 if ( Base.IsNull()) return 1;
245 TopoDS_Shape InpuTShape(DBRep::Get(a[3],TopAbs_WIRE,Standard_False));
246 TopoDS_Wire Prof = TopoDS::Wire(InpuTShape);
247 // TopoDS_Wire Prof =
248 // TopoDS::Wire(DBRep::Get(a[3],TopAbs_WIRE,Standard_False));
249 if ( Prof.IsNull()) return 1;
253 = BRepOffsetAPI_MakeEvolved(TopoDS::Face(Base),Prof,GeomAbs_Arc,n == 4,Solid);
254 DBRep::Set(a[1],Volevo);
258 = BRepOffsetAPI_MakeEvolved(TopoDS::Wire(Base),Prof,GeomAbs_Arc,n == 4,Solid);
259 DBRep::Set(a[1],Volevo);
266 //=======================================================================
269 //=======================================================================
271 static Standard_Integer pruled(Draw_Interpretor& ,
272 Standard_Integer n, const char** a)
274 if ( n != 4) return 1;
276 Standard_Boolean YaWIRE = Standard_False;
277 TopoDS_Shape S1 = DBRep::Get(a[2],TopAbs_EDGE);
279 S1 = DBRep::Get(a[2],TopAbs_WIRE);
280 if (S1.IsNull()) return 1;
281 YaWIRE = Standard_True;
284 TopoDS_Shape S2 = DBRep::Get(a[3],TopAbs_EDGE);
286 S2 = DBRep::Get(a[3],TopAbs_WIRE);
287 if ( S2.IsNull()) return 1;
289 S1 = BRepLib_MakeWire(TopoDS::Edge(S1));
290 YaWIRE = Standard_True;
294 S2 = BRepLib_MakeWire(TopoDS::Edge(S2));
299 Result = BRepFill::Shell(TopoDS::Wire(S1),TopoDS::Wire(S2));
302 Result = BRepFill::Face(TopoDS::Edge(S1),TopoDS::Edge(S2));
305 DBRep::Set(a[1],Result);
310 //=======================================================================
312 //purpose : Create a surface between generating wires
313 //=======================================================================
315 Standard_Integer gener(Draw_Interpretor&, Standard_Integer n, const char** a)
317 if ( n < 4) return 1;
321 BRepFill_Generator Generator;
323 for ( Standard_Integer i = 2; i<= n-1 ; i++) {
324 Shape = DBRep::Get(a[i],TopAbs_WIRE);
328 Generator.AddWire(TopoDS::Wire(Shape));
333 TopoDS_Shell Shell = Generator.Shell();
335 DBRep::Set(a[1], Shell);
342 //=======================================================================
343 //function : thrusections
345 //=======================================================================
347 Standard_Integer thrusections(Draw_Interpretor&, Standard_Integer n, const char** a)
351 Standard_Boolean check = Standard_True;
352 Standard_Boolean samenumber = Standard_True;
353 Standard_Integer index = 2;
355 if (!strcmp(a[1],"-N")) {
357 check = Standard_False;
363 Standard_Boolean issolid = ( Draw::Atoi(a[index]) == 1 );
364 Standard_Boolean isruled = ( Draw::Atoi(a[index+1]) == 1 );
366 BRepOffsetAPI_ThruSections Generator(issolid,isruled);
368 Standard_Integer NbEdges = 0;
369 Standard_Boolean IsFirstWire = Standard_False;
370 for ( Standard_Integer i = index+2; i<= n-1 ; i++) {
371 Standard_Boolean IsWire = Standard_True;
372 Shape = DBRep::Get(a[i], TopAbs_WIRE);
375 Generator.AddWire(TopoDS::Wire(Shape));
377 IsFirstWire = Standard_True;
379 IsFirstWire = Standard_False;
383 Shape = DBRep::Get(a[i], TopAbs_VERTEX);
384 IsWire = Standard_False;
386 Generator.AddVertex(TopoDS::Vertex(Shape));
391 Standard_Integer cpt = 0;
393 for (PE.Init(Shape, TopAbs_EDGE); PE.More(); PE.Next()) {
399 if (IsWire && cpt != NbEdges)
400 samenumber = Standard_False;
404 check = (check || !samenumber);
405 Generator.CheckCompatibility(check);
409 if (Generator.IsDone()) {
410 TopoDS_Shape Shell = Generator.Shape();
411 DBRep::Set(a[index-1], Shell);
414 cout << "Algorithm is not done" << endl;
419 //=======================================================================
421 //=======================================================================
422 static Standard_Integer mksweep(Draw_Interpretor& ,
423 Standard_Integer n, const char** a)
425 if ( n != 2) return 1;
426 TopoDS_Shape Spine = DBRep::Get(a[1],TopAbs_WIRE);
427 if ( Spine.IsNull()) return 1;
432 Sweep = new BRepOffsetAPI_MakePipeShell(TopoDS::Wire(Spine));
436 //=======================================================================
438 //=======================================================================
439 static Standard_Integer setsweep(Draw_Interpretor& di,
440 Standard_Integer n, const char** a)
443 //cout << "setsweep options [arg1 [arg2 [...]]] : options are :" << endl;
444 //cout << " -FR : Tangent and Normal are given by Frenet trihedron" <<endl;
445 //cout << " -CF : Tangente is given by Frenet," << endl;
446 //cout << " the Normal is computed to minimize the torsion " << endl;
447 //cout << " -DX Surf : Tangent and Normal are given by Darboux trihedron,"
449 //cout << " Surf have to be a shell or a face" <<endl;
450 //cout << " -CN dx dy dz : BiNormal is given by dx dy dz" << endl;
451 //cout << " -FX Tx Ty TZ [Nx Ny Nz] : Tangent and Normal are fixed" <<endl;
452 //cout << " -G guide 0|1(ACR|Plan) 0|1(contact|no contact) : with guide"<<endl;
453 di << "setsweep options [arg1 [arg2 [...]]] : options are :\n";
454 di << " -FR : Tangent and Normal are given by Frenet trihedron\n";
455 di << " -CF : Tangente is given by Frenet,\n";
456 di << " the Normal is computed to minimize the torsion \n";
457 di << " -DT : discrete trihedron\n";
458 di << " -DX Surf : Tangent and Normal are given by Darboux trihedron,\n";
459 di << " Surf have to be a shell or a face\n";
460 di << " -CN dx dy dz : BiNormal is given by dx dy dz\n";
461 di << " -FX Tx Ty TZ [Nx Ny Nz] : Tangent and Normal are fixed\n";
462 di << " -G guide 0|1(Plan|ACR) 0|1|2(no contact|contact|contact on border) : with guide\n";
467 //cout << "You have forgotten the <<mksweep>> command !"<< endl;
468 di << "You have forgotten the <<mksweep>> command !\n";
471 if (!strcmp(a[1],"-FR")) {
472 Sweep->SetMode(Standard_True);
474 else if (!strcmp(a[1],"-CF")) {
475 Sweep->SetMode(Standard_False);
477 else if (!strcmp(a[1],"-DT")) {
478 Sweep->SetDiscreteMode();
480 else if (!strcmp(a[1],"-DX")) {
482 //cout << "bad arguments !" << endl;
483 di << "bad arguments !\n";
487 Surf = DBRep::Get(a[2],TopAbs_SHAPE);
489 //cout << a[2] <<"is not a shape !" << endl;
490 di << a[2] <<"is not a shape !\n";
493 Sweep->SetMode(Surf);
495 else if (!strcmp(a[1],"-CN")) {
497 //cout << "bad arguments !" << endl;
498 di << "bad arguments !\n";
501 gp_Dir D(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4]));
504 else if (!strcmp(a[1],"-FX")) {
505 if ((n!=5)&&(n!=8)) {
506 //cout << "bad arguments !" << endl;
507 di << "bad arguments !\n";
510 gp_Dir D(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4]));
512 gp_Dir DN(Draw::Atof(a[5]), Draw::Atof(a[6]), Draw::Atof(a[7]));
513 gp_Ax2 Axe(gp_Pnt(0., 0., 0.), D, DN);
517 gp_Ax2 Axe(gp_Pnt(0., 0., 0.), D);
521 else if (!strcmp(a[1],"-G")) // contour guide
525 //cout << "bad arguments !" << endl;
526 di << "bad arguments !\n";
531 TopoDS_Shape Guide = DBRep::Get(a[2],TopAbs_WIRE);
532 Standard_Boolean CurvilinearEquivalence = Draw::Atoi(a[3]) != 0;
533 Standard_Integer KeepContact = Draw::Atoi(a[4]);
534 Sweep->SetMode(TopoDS::Wire(Guide),
535 CurvilinearEquivalence,
536 (BRepFill_TypeOfContact)KeepContact);
541 //cout << "The option "<< a[1] << " is unknown !" << endl;
542 di << "The option "<< a[1] << " is unknown !\n";
549 //=======================================================================
551 //=======================================================================
552 static Standard_Integer addsweep(Draw_Interpretor& di,
553 Standard_Integer n, const char** a)
556 //cout << "addsweep wire/vertex [Vertex] [-T] [-R] [u0 v0 u1 v1 [...[uN vN]]] : options are :" << endl;
557 //cout << " -T : the wire/vertex have to be translated to assume contact"<< endl;
558 //cout << " with the spine" <<endl;
559 //cout << " -R : the wire have to be rotated to assume orthogonality"<<endl;
560 //cout << " with the spine's tangent" << endl;
561 di << "addsweep wire/vertex [Vertex] [-T] [-R] [u0 v0 u1 v1 [...[uN vN]]] : options are :\n";
562 di << " -T : the wire/vertex have to be translated to assume contact\n";
563 di << " with the spine\n";
564 di << " -R : the wire have to be rotated to assume orthogonality\n";
565 di << " with the spine's tangent\n";
570 //cout << "You have forgotten the <<mksweep>> command !"<< endl;
571 di << "You have forgotten the <<mksweep>> command !\n";
575 TopoDS_Shape Section;
576 TopoDS_Vertex Vertex;
577 Handle(Law_Interpol) thelaw;
579 Section = DBRep::Get(a[1], TopAbs_SHAPE);
580 if (Section.IsNull() ||
581 (Section.ShapeType() != TopAbs_WIRE &&
582 Section.ShapeType() != TopAbs_VERTEX))
584 //cout << a[1] <<"is not a wire and is not a vertex!" << endl;
585 di << a[1] <<" is not a wire and is not a vertex!\n";
589 Standard_Boolean HasVertex=Standard_False,
594 Standard_Integer cur = 2;
596 TopoDS_Shape InputVertex(DBRep::Get(a[cur],TopAbs_VERTEX));
597 Vertex = TopoDS::Vertex(InputVertex);
598 // Vertex = TopoDS::Vertex(DBRep::Get(a[cur],TopAbs_VERTEX));
599 if (!Vertex.IsNull()) {
601 HasVertex = Standard_True;
604 // Reading of the translation option
605 if ((n>cur) && !strcmp(a[cur],"-T")) {
610 // Reading of the rotation option
611 if ((n>cur) && !strcmp(a[cur],"-R")) {
618 Standard_Integer nbreal = n-cur;
619 if ( (nbreal < 4) || (nbreal % 2 != 0) ) {
620 //cout << "bad arguments ! :" <<a[cur] << endl;
621 di << "bad arguments ! :" <<a[cur] << "\n";
622 } else { //law of interpolation
623 Standard_Integer ii, L= nbreal/2;
624 TColgp_Array1OfPnt2d ParAndRad(1, L);
625 for (ii=1; ii<=L; ii++, cur+=2) {
626 ParAndRad(ii).SetX(Draw::Atof(a[cur]));
627 ParAndRad(ii).SetY(Draw::Atof(a[cur+1]));
629 thelaw = new (Law_Interpol) ();
630 thelaw->Set(ParAndRad,
631 Abs(ParAndRad(1).Y() - ParAndRad(L).Y()) < Precision::Confusion());
636 if (thelaw.IsNull()) {
637 if (HasVertex) Sweep->Add(Section, Vertex, isT, isR);
638 else Sweep->Add(Section, isT, isR);
641 if (HasVertex) Sweep->SetLaw(Section, thelaw, Vertex, isT, isR);
642 else Sweep->SetLaw(Section, thelaw, isT, isR);
648 //=======================================================================
650 //=======================================================================
651 static Standard_Integer deletesweep(Draw_Interpretor& di,
652 Standard_Integer n, const char** a)
658 TopoDS_Shape InputShape(DBRep::Get(a[1],TopAbs_SHAPE));
659 Section = TopoDS::Wire(InputShape);
660 // Section = TopoDS::Wire(DBRep::Get(a[1],TopAbs_SHAPE));
661 if (Section.IsNull()) {
662 //cout << a[1] <<"is not a wire !" << endl;
663 di << a[1] <<"is not a wire !\n";
667 Sweep->Delete(Section);
672 //=======================================================================
674 //=======================================================================
675 static Standard_Integer buildsweep(Draw_Interpretor& di,
676 Standard_Integer n, const char** a)
679 //cout << "build sweep result [-M/-C/-R] [-S] [tol] : options are" << endl;
680 //cout << " -M : Discontinuities are treated by Modfication of"<< endl;
681 //cout << " the sweeping mode : it is the default" <<endl;
682 //cout << " -C : Discontinuities are treated like Right Corner" << endl;
683 //cout << " Treatement is Extent && Intersect" << endl;
684 //cout << " -R : Discontinuities are treated like Round Corner" << endl;
685 //cout << " Treatement is Intersect and Fill" << endl;
686 //cout << " -S : To build a Solid" << endl;
687 di << "build sweep result [-M/-C/-R] [-S] [tol] : options are\n";
688 di << " -M : Discontinuities are treated by Modfication of\n";
689 di << " the sweeping mode : it is the default\n";
690 di << " -C : Discontinuities are treated like Right Corner\n";
691 di << " Treatement is Extent && Intersect\n";
692 di << " -R : Discontinuities are treated like Round Corner\n";
693 di << " Treatement is Intersect and Fill\n";
694 di << " -S : To build a Solid\n";
698 Standard_Boolean mksolid = Standard_False;
700 //cout << "You have forgotten the <<mksweep>> command !"<< endl;
701 di << "You have forgotten the <<mksweep>> command !\n";
705 if (!Sweep->IsReady()) {
706 //cout << "You have forgotten the <<addsweep>> command !"<< endl;
707 di << "You have forgotten the <<addsweep>> command !\n";
712 Standard_Integer cur=2;
714 BRepBuilderAPI_TransitionMode Transition = BRepBuilderAPI_Transformed;
716 // Reading Transition
717 if (!strcmp(a[cur],"-C")) {
718 Transition = BRepBuilderAPI_RightCorner;
721 else if (!strcmp(a[cur],"-R")) {
722 Transition = BRepBuilderAPI_RoundCorner;
725 Sweep->SetTransitionMode(Transition);
728 if ((n>cur) && (!strcmp(a[cur],"-S")) ) mksolid = Standard_True;
730 // Calcul le resultat
732 if (!Sweep->IsDone()) {
733 //cout << "Buildsweep : Not Done" << endl;
734 di << "Buildsweep : Not Done\n";
735 BRepBuilderAPI_PipeError Stat = Sweep->GetStatus();
736 if (Stat == BRepBuilderAPI_PlaneNotIntersectGuide) {
737 //cout << "Buildsweep : One Plane not intersect the guide" << endl;
738 di << "Buildsweep : One Plane not intersect the guide\n";
740 if (Stat == BRepBuilderAPI_ImpossibleContact) {
741 //cout << "BuildSweep : One section can not be in contact with the guide" << endl;
742 di << "BuildSweep : One section can not be in contact with the guide\n";
749 B = Sweep->MakeSolid();
750 //if (!B) cout << " BuildSweep : It is impossible to make a solid !" << endl;
751 if (!B) di << " BuildSweep : It is impossible to make a solid !\n";
753 result = Sweep->Shape();
754 DBRep::Set(a[1],result);
760 //=======================================================================
762 //=======================================================================
763 static Standard_Integer simulsweep(Draw_Interpretor& di,
764 Standard_Integer n, const char** a)
766 if ( (n!=3) && (n!=4) ) return 1;
769 //cout << "You have forgotten the <<mksweep>> command !"<< endl;
770 di << "You have forgotten the <<mksweep>> command !\n";
774 if (!Sweep->IsReady()) {
775 //cout << "You have forgotten the <<addsweep>> command !"<< endl;
776 di << "You have forgotten the <<addsweep>> command !\n";
781 TopTools_ListOfShape List;
782 TopTools_ListIteratorOfListOfShape it;
783 Standard_Integer N, ii;
784 N = Draw::Atoi(a[2]);
787 BRepBuilderAPI_TransitionMode Transition = BRepBuilderAPI_Transformed;
788 // Lecture Transition
789 if (!strcmp(a[3],"-C")) {
790 Transition = BRepBuilderAPI_RightCorner;
792 else if (!strcmp(a[3],"-R")) {
793 Transition = BRepBuilderAPI_RoundCorner;
795 Sweep->SetTransitionMode(Transition);
798 // Calculate the result
799 Sweep->Simulate(N, List);
800 for (ii=1, it.Initialize(List); it.More(); it.Next(), ii++) {
801 Sprintf(name,"%s_%d",a[1],ii);
802 DBRep::Set(name, it.Value());
808 //=======================================================================
810 //=======================================================================
811 static Standard_Integer middlepath(Draw_Interpretor& /*di*/,
812 Standard_Integer n, const char** a)
816 TopoDS_Shape aShape = DBRep::Get(a[2]);
817 if (aShape.IsNull()) return 1;
819 TopoDS_Shape StartShape = DBRep::Get(a[3]);
820 if (StartShape.IsNull()) return 1;
822 TopoDS_Shape EndShape = DBRep::Get(a[4]);
823 if (EndShape.IsNull()) return 1;
825 BRepOffsetAPI_MiddlePath Builder(aShape, StartShape, EndShape);
828 TopoDS_Shape Result = Builder.Shape();
829 DBRep::Set(a[1], Result);
834 //=======================================================================
835 //function : SweepCommands
837 //=======================================================================
839 void BRepTest::SweepCommands(Draw_Interpretor& theCommands)
841 static Standard_Boolean done = Standard_False;
843 done = Standard_True;
845 DBRep::BasicCommands(theCommands);
847 const char* g = "Sweep commands";
849 theCommands.Add("prism",
850 "prism result base dx dy dz [Copy | Inf | Seminf]",
853 theCommands.Add("revol",
854 "revol result base px py pz dx dy dz angle [Copy]",
857 theCommands.Add("pipe",
858 "pipe result Wire_spine Profile [Mode [Approx]], no args to get help",
861 theCommands.Add("evolved",
862 "evolved , no args to get help",
865 theCommands.Add("evolvedsolid",
866 "evolved , no args to get help",
869 theCommands.Add("pruled",
870 "pruled result Edge1/Wire1 Edge2/Wire2",
873 theCommands.Add("gener", "gener result wire1 wire2 [..wire..]",
876 theCommands.Add("thrusections", "thrusections [-N] result issolid isruled shape1 shape2 [..shape..], the option -N means no check on wires, shapes must be wires or vertices (only first or last)",
877 __FILE__,thrusections,g);
880 theCommands.Add("mksweep", "mksweep wire",
883 theCommands.Add("setsweep", "setsweep no args to get help",
884 __FILE__,setsweep,g);
886 theCommands.Add("addsweep",
887 "addsweep wire [vertex] [-M ] [-C] [auxiilaryshape]:no args to get help",
888 __FILE__,addsweep,g);
890 theCommands.Add("deletesweep",
891 "deletesweep wire, To delete a section",
892 __FILE__,deletesweep,g);
894 theCommands.Add("buildsweep", "builsweep [r] [option] [Tol] , no args to get help"
895 __FILE__,buildsweep,g);
897 theCommands.Add("simulsweep", "simulsweep r [n] [option]"
898 __FILE__,simulsweep,g);
899 theCommands.Add("geompipe", "geompipe r spineedge profileedge radius [byACR [byrotate]]"
900 __FILE__,geompipe,g);
902 theCommands.Add("middlepath", "middlepath res shape startshape endshape",
903 __FILE__,middlepath,g);