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;
49 #include <Geom_Curve.hxx>
50 #include <GeomAdaptor_HCurve.hxx>
51 #include <GeomFill_Pipe.hxx>
52 #include <Geom_Surface.hxx>
53 #include <BRepBuilderAPI_MakeFace.hxx>
54 #include <BRep_Tool.hxx>
56 //#endi#include <gp_Vec.hxx>
58 #include <Geom_Circle.hxx>
62 //=======================================================================
64 //=======================================================================
66 static Standard_Integer prism(Draw_Interpretor& , Standard_Integer n, const char** a)
70 TopoDS_Shape base = DBRep::Get(a[2]);
71 if (base.IsNull()) return 1;
73 gp_Vec V(Draw::Atof(a[3]),Draw::Atof(a[4]),Draw::Atof(a[5]));
75 Standard_Boolean copy = Standard_False;
76 Standard_Boolean inf = Standard_False;
77 Standard_Boolean sinf = Standard_False;
80 copy = (*a[6] == 'c') || (*a[6] == 'C');
81 inf = (*a[6] == 'i') || (*a[6] == 'I');
82 sinf = (*a[6] == 's') || (*a[6] == 'S');
88 res = BRepPrimAPI_MakePrism(base,gp_Dir(V),inf);
90 res = BRepPrimAPI_MakePrism(base,V,copy);
98 //=======================================================================
100 //=======================================================================
102 static Standard_Integer revol(Draw_Interpretor& ,
103 Standard_Integer n, const char** a)
105 if (n < 10) return 1;
107 TopoDS_Shape base = DBRep::Get(a[2]);
108 if (base.IsNull()) return 1;
110 gp_Pnt P(Draw::Atof(a[3]),Draw::Atof(a[4]),Draw::Atof(a[5]));
111 gp_Dir D(Draw::Atof(a[6]),Draw::Atof(a[7]),Draw::Atof(a[8]));
114 Standard_Real angle = Draw::Atof(a[9]) * (M_PI / 180.0);
116 Standard_Boolean copy = n > 10;
118 TopoDS_Shape res = BRepPrimAPI_MakeRevol(base,A,angle,copy);
120 DBRep::Set(a[1],res);
126 //=======================================================================
128 //=======================================================================
130 static Standard_Integer pipe(Draw_Interpretor& di,
131 Standard_Integer n, const char** a)
135 di << "pipe result Wire_spine Profile [Mode [Approx]]" << "\n";
136 di << "Mode = 0 - CorrectedFrenet," << "\n";
137 di << " = 1 - Frenet," << "\n";
138 di << " = 2 - DiscreteTrihedron" << "\n";
139 di << "Approx - force C1-approximation if result is C0" << "\n";
143 if (n > 1 && n < 4) return 1;
145 TopoDS_Shape Spine = DBRep::Get(a[2],TopAbs_WIRE);
146 if ( Spine.IsNull()) return 1;
148 TopoDS_Shape Profile = DBRep::Get(a[3]);
149 if ( Profile.IsNull()) return 1;
151 GeomFill_Trihedron Mode = GeomFill_IsCorrectedFrenet;
154 Standard_Integer iMode = atoi(a[4]);
156 Mode = GeomFill_IsFrenet;
158 Mode = GeomFill_IsDiscreteTrihedron;
161 Standard_Boolean ForceApproxC1 = Standard_False;
163 ForceApproxC1 = Standard_True;
165 TopoDS_Shape S = BRepOffsetAPI_MakePipe(TopoDS::Wire(Spine),
175 //=======================================================================
177 static Standard_Integer geompipe(Draw_Interpretor& ,
178 Standard_Integer n, const char** a)
180 TopoDS_Shape Spine = DBRep::Get(a[2],TopAbs_EDGE);
181 if ( Spine.IsNull()) return 1;
182 if ( n < 5) return 1;
183 TopoDS_Shape Profile = DBRep::Get(a[3],TopAbs_EDGE);
184 if ( Profile.IsNull()) return 1;
185 Standard_Real aSpFirst,aSpLast,aPrFirst,aPrLast;
186 Handle(Geom_Curve) SpineCurve = BRep_Tool::Curve(TopoDS::Edge(Spine),aSpFirst,aSpLast);
187 Handle(Geom_Curve) ProfileCurve = BRep_Tool::Curve(TopoDS::Edge(Profile),aPrFirst,aPrLast);
188 Handle(GeomAdaptor_HCurve) aAdaptCurve = new GeomAdaptor_HCurve(SpineCurve,aSpFirst,aSpLast);
189 Standard_Boolean ByACR = Standard_False;
190 Standard_Boolean rotate = Standard_False;
191 Standard_Real Radius = Draw::Atof(a[4]);
194 ProfileCurve->D1(aSpFirst,ctr,norm);
195 gp_Vec xAxisStart(ctr,SpineCurve->Value(aSpFirst));
196 gp_Ax2 aAx2Start(ctr,norm,xAxisStart);
197 Handle(Geom_Circle) cStart=new Geom_Circle(aAx2Start,Radius);
198 Standard_Integer k =5;
200 ByACR = (Draw::Atoi(a[k++]) ==1);
202 rotate = (Draw::Atoi(a[k++])==1);
203 GeomFill_Pipe aPipe(ProfileCurve,aAdaptCurve,cStart,ByACR,rotate);
204 aPipe.Perform(Standard_True);
205 Handle(Geom_Surface) Sur=aPipe.Surface();
208 F = BRepBuilderAPI_MakeFace(Sur, Precision::Confusion());
213 //=======================================================================
216 //=======================================================================
218 Standard_Integer evolved(Draw_Interpretor& di, Standard_Integer n, const char** a)
221 //cout << " 1) evolved result base profil : "<< endl;
222 //cout << " The relative position of the profil on the base" << endl;
223 //cout << " is given in the referencial axis. " << endl;
224 //cout << " 2) evolved result base profil o : "<< endl;
225 //cout << " This position is automatically computed." << endl;
226 di << " 1) evolved result base profil : "<< "\n";
227 di << " The relative position of the profil on the base" << "\n";
228 di << " is given in the referencial axis. " << "\n";
229 di << " 2) evolved result base profil o : "<< "\n";
230 di << " This position is automatically computed." << "\n";
234 if ( n < 4 ) return 1;
235 Standard_Boolean IsAFace = Standard_False;
236 Standard_Boolean Solid = (!strcmp(a[0],"evolvedsolid"));
240 TopoDS_Shape Base = DBRep::Get(a[2],TopAbs_WIRE,Standard_False);
241 if ( Base.IsNull()) {
242 Base = DBRep::Get(a[2],TopAbs_FACE,Standard_False);
243 IsAFace = Standard_True;
245 if ( Base.IsNull()) return 1;
247 TopoDS_Shape InpuTShape(DBRep::Get(a[3],TopAbs_WIRE,Standard_False));
248 TopoDS_Wire Prof = TopoDS::Wire(InpuTShape);
249 // TopoDS_Wire Prof =
250 // TopoDS::Wire(DBRep::Get(a[3],TopAbs_WIRE,Standard_False));
251 if ( Prof.IsNull()) return 1;
255 = BRepOffsetAPI_MakeEvolved(TopoDS::Face(Base),Prof,GeomAbs_Arc,n == 4,Solid);
256 DBRep::Set(a[1],Volevo);
260 = BRepOffsetAPI_MakeEvolved(TopoDS::Wire(Base),Prof,GeomAbs_Arc,n == 4,Solid);
261 DBRep::Set(a[1],Volevo);
268 //=======================================================================
271 //=======================================================================
273 static Standard_Integer pruled(Draw_Interpretor& ,
274 Standard_Integer n, const char** a)
276 if ( n != 4) return 1;
278 Standard_Boolean YaWIRE = Standard_False;
279 TopoDS_Shape S1 = DBRep::Get(a[2],TopAbs_EDGE);
281 S1 = DBRep::Get(a[2],TopAbs_WIRE);
282 if (S1.IsNull()) return 1;
283 YaWIRE = Standard_True;
286 TopoDS_Shape S2 = DBRep::Get(a[3],TopAbs_EDGE);
288 S2 = DBRep::Get(a[3],TopAbs_WIRE);
289 if ( S2.IsNull()) return 1;
291 S1 = BRepLib_MakeWire(TopoDS::Edge(S1));
292 YaWIRE = Standard_True;
296 S2 = BRepLib_MakeWire(TopoDS::Edge(S2));
301 Result = BRepFill::Shell(TopoDS::Wire(S1),TopoDS::Wire(S2));
304 Result = BRepFill::Face(TopoDS::Edge(S1),TopoDS::Edge(S2));
307 DBRep::Set(a[1],Result);
312 //=======================================================================
314 //purpose : Create a surface between generating wires
315 //=======================================================================
317 Standard_Integer gener(Draw_Interpretor&, Standard_Integer n, const char** a)
319 if ( n < 4) return 1;
323 BRepFill_Generator Generator;
325 for ( Standard_Integer i = 2; i<= n-1 ; i++) {
326 Shape = DBRep::Get(a[i],TopAbs_WIRE);
330 Generator.AddWire(TopoDS::Wire(Shape));
335 TopoDS_Shell Shell = Generator.Shell();
337 DBRep::Set(a[1], Shell);
344 //=======================================================================
345 //function : thrusections
347 //=======================================================================
349 Standard_Integer thrusections(Draw_Interpretor&, Standard_Integer n, const char** a)
353 Standard_Boolean check = Standard_True;
354 Standard_Boolean samenumber = Standard_True;
355 Standard_Integer index = 2;
357 if (!strcmp(a[1],"-N")) {
359 check = Standard_False;
365 Standard_Boolean issolid = ( Draw::Atoi(a[index]) == 1 );
366 Standard_Boolean isruled = ( Draw::Atoi(a[index+1]) == 1 );
368 BRepOffsetAPI_ThruSections Generator(issolid,isruled);
370 Standard_Integer NbEdges = 0;
371 Standard_Boolean IsFirstWire = Standard_False;
372 for ( Standard_Integer i = index+2; i<= n-1 ; i++) {
373 Standard_Boolean IsWire = Standard_True;
374 Shape = DBRep::Get(a[i], TopAbs_WIRE);
377 Generator.AddWire(TopoDS::Wire(Shape));
379 IsFirstWire = Standard_True;
381 IsFirstWire = Standard_False;
385 Shape = DBRep::Get(a[i], TopAbs_VERTEX);
386 IsWire = Standard_False;
388 Generator.AddVertex(TopoDS::Vertex(Shape));
393 Standard_Integer cpt = 0;
395 for (PE.Init(Shape, TopAbs_EDGE); PE.More(); PE.Next()) {
401 if (IsWire && cpt != NbEdges)
402 samenumber = Standard_False;
406 check = (check || !samenumber);
407 Generator.CheckCompatibility(check);
411 TopoDS_Shape Shell = Generator.Shape();
413 DBRep::Set(a[index-1], Shell);
418 //=======================================================================
420 //=======================================================================
421 static Standard_Integer mksweep(Draw_Interpretor& ,
422 Standard_Integer n, const char** a)
424 if ( n != 2) return 1;
425 TopoDS_Shape Spine = DBRep::Get(a[1],TopAbs_WIRE);
426 if ( Spine.IsNull()) return 1;
431 Sweep = new BRepOffsetAPI_MakePipeShell(TopoDS::Wire(Spine));
435 //=======================================================================
437 //=======================================================================
438 static Standard_Integer setsweep(Draw_Interpretor& di,
439 Standard_Integer n, const char** a)
442 //cout << "setsweep options [arg1 [arg2 [...]]] : options are :" << endl;
443 //cout << " -FR : Tangent and Normal are given by Frenet trihedron" <<endl;
444 //cout << " -CF : Tangente is given by Frenet," << endl;
445 //cout << " the Normal is computed to minimize the torsion " << endl;
446 //cout << " -DX Surf : Tangent and Normal are given by Darboux trihedron,"
448 //cout << " Surf have to be a shell or a face" <<endl;
449 //cout << " -CN dx dy dz : BiNormal is given by dx dy dz" << endl;
450 //cout << " -FX Tx Ty TZ [Nx Ny Nz] : Tangent and Normal are fixed" <<endl;
451 //cout << " -G guide 0|1(ACR|Plan) 0|1(contact|no contact) : with guide"<<endl;
452 di << "setsweep options [arg1 [arg2 [...]]] : options are :" << "\n";
453 di << " -FR : Tangent and Normal are given by Frenet trihedron" <<"\n";
454 di << " -CF : Tangente is given by Frenet," << "\n";
455 di << " the Normal is computed to minimize the torsion " << "\n";
456 di << " -DT : discrete trihedron" << "\n";
457 di << " -DX Surf : Tangent and Normal are given by Darboux trihedron," <<"\n";
458 di << " Surf have to be a shell or a face" <<"\n";
459 di << " -CN dx dy dz : BiNormal is given by dx dy dz" << "\n";
460 di << " -FX Tx Ty TZ [Nx Ny Nz] : Tangent and Normal are fixed" <<"\n";
461 di << " -G guide 0|1(Plan|ACR) 0|1|2(no contact|contact|contact on border) : with guide"<<"\n";
466 //cout << "You have forgotten the <<mksweep>> command !"<< endl;
467 di << "You have forgotten the <<mksweep>> command !"<< "\n";
470 if (!strcmp(a[1],"-FR")) {
471 Sweep->SetMode(Standard_True);
473 else if (!strcmp(a[1],"-CF")) {
474 Sweep->SetMode(Standard_False);
476 else if (!strcmp(a[1],"-DT")) {
477 Sweep->SetDiscreteMode();
479 else if (!strcmp(a[1],"-DX")) {
481 //cout << "bad arguments !" << endl;
482 di << "bad arguments !" << "\n";
486 Surf = DBRep::Get(a[2],TopAbs_SHAPE);
488 //cout << a[2] <<"is not a shape !" << endl;
489 di << a[2] <<"is not a shape !" << "\n";
492 Sweep->SetMode(Surf);
494 else if (!strcmp(a[1],"-CN")) {
496 //cout << "bad arguments !" << endl;
497 di << "bad arguments !" << "\n";
500 gp_Dir D(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4]));
503 else if (!strcmp(a[1],"-FX")) {
504 if ((n!=5)&&(n!=8)) {
505 //cout << "bad arguments !" << endl;
506 di << "bad arguments !" << "\n";
509 gp_Dir D(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4]));
511 gp_Dir DN(Draw::Atof(a[5]), Draw::Atof(a[6]), Draw::Atof(a[7]));
512 gp_Ax2 Axe(gp_Pnt(0., 0., 0.), D, DN);
516 gp_Ax2 Axe(gp_Pnt(0., 0., 0.), D);
520 else if (!strcmp(a[1],"-G")) // contour guide
524 //cout << "bad arguments !" << endl;
525 di << "bad arguments !" << "\n";
530 TopoDS_Shape Guide = DBRep::Get(a[2],TopAbs_WIRE);
531 Standard_Integer CurvilinearEquivalence = Draw::Atoi(a[3]);
532 Standard_Integer KeepContact = Draw::Atoi(a[4]);
533 Sweep->SetMode(TopoDS::Wire(Guide),
534 CurvilinearEquivalence,
535 (BRepFill_TypeOfContact)KeepContact);
540 //cout << "The option "<< a[1] << " is unknown !" << endl;
541 di << "The option "<< a[1] << " is unknown !" << "\n";
548 //=======================================================================
550 //=======================================================================
551 static Standard_Integer addsweep(Draw_Interpretor& di,
552 Standard_Integer n, const char** a)
555 //cout << "addsweep wire/vertex [Vertex] [-T] [-R] [u0 v0 u1 v1 [...[uN vN]]] : options are :" << endl;
556 //cout << " -T : the wire/vertex have to be translated to assume contact"<< endl;
557 //cout << " with the spine" <<endl;
558 //cout << " -R : the wire have to be rotated to assume orthogonality"<<endl;
559 //cout << " with the spine's tangent" << endl;
560 di << "addsweep wire/vertex [Vertex] [-T] [-R] [u0 v0 u1 v1 [...[uN vN]]] : options are :" << "\n";
561 di << " -T : the wire/vertex have to be translated to assume contact"<< "\n";
562 di << " with the spine" <<"\n";
563 di << " -R : the wire have to be rotated to assume orthogonality"<<"\n";
564 di << " with the spine's tangent" << "\n";
569 //cout << "You have forgotten the <<mksweep>> command !"<< endl;
570 di << "You have forgotten the <<mksweep>> command !"<< "\n";
574 TopoDS_Shape Section;
575 TopoDS_Vertex Vertex;
576 Handle(Law_Interpol) thelaw;
578 Section = DBRep::Get(a[1], TopAbs_SHAPE);
579 if (Section.ShapeType() != TopAbs_WIRE &&
580 Section.ShapeType() != TopAbs_VERTEX)
582 //cout << a[1] <<"is not a wire and is not a vertex!" << endl;
583 di << a[1] <<"is not a wire and is not a vertex!" << "\n";
587 Standard_Boolean HasVertex=Standard_False,
592 Standard_Integer cur = 2;
594 TopoDS_Shape InputVertex(DBRep::Get(a[cur],TopAbs_VERTEX));
595 Vertex = TopoDS::Vertex(InputVertex);
596 // Vertex = TopoDS::Vertex(DBRep::Get(a[cur],TopAbs_VERTEX));
597 if (!Vertex.IsNull()) {
599 HasVertex = Standard_True;
602 // Reading of the translation option
603 if ((n>cur) && !strcmp(a[cur],"-T")) {
608 // Reading of the rotation option
609 if ((n>cur) && !strcmp(a[cur],"-R")) {
616 Standard_Integer nbreal = n-cur;
617 if ( (nbreal < 4) || (nbreal % 2 != 0) ) {
618 //cout << "bad arguments ! :" <<a[cur] << endl;
619 di << "bad arguments ! :" <<a[cur] << "\n";
620 } else { //law of interpolation
621 Standard_Integer ii, L= nbreal/2;
622 TColgp_Array1OfPnt2d ParAndRad(1, L);
623 for (ii=1; ii<=L; ii++, cur+=2) {
624 ParAndRad(ii).SetX(Draw::Atof(a[cur]));
625 ParAndRad(ii).SetY(Draw::Atof(a[cur+1]));
627 thelaw = new (Law_Interpol) ();
628 thelaw->Set(ParAndRad,
629 Abs(ParAndRad(1).Y() - ParAndRad(L).Y()) < Precision::Confusion());
634 if (thelaw.IsNull()) {
635 if (HasVertex) Sweep->Add(Section, Vertex, isT, isR);
636 else Sweep->Add(Section, isT, isR);
639 if (HasVertex) Sweep->SetLaw(Section, thelaw, Vertex, isT, isR);
640 else Sweep->SetLaw(Section, thelaw, isT, isR);
646 //=======================================================================
648 //=======================================================================
649 static Standard_Integer deletesweep(Draw_Interpretor& di,
650 Standard_Integer n, const char** a)
656 TopoDS_Shape InputShape(DBRep::Get(a[1],TopAbs_SHAPE));
657 Section = TopoDS::Wire(InputShape);
658 // Section = TopoDS::Wire(DBRep::Get(a[1],TopAbs_SHAPE));
659 if (Section.IsNull()) {
660 //cout << a[1] <<"is not a wire !" << endl;
661 di << a[1] <<"is not a wire !" << "\n";
665 Sweep->Delete(Section);
670 //=======================================================================
672 //=======================================================================
673 static Standard_Integer buildsweep(Draw_Interpretor& di,
674 Standard_Integer n, const char** a)
677 //cout << "build sweep result [-M/-C/-R] [-S] [tol] : options are" << endl;
678 //cout << " -M : Discontinuities are treated by Modfication of"<< endl;
679 //cout << " the sweeping mode : it is the default" <<endl;
680 //cout << " -C : Discontinuities are treated like Right Corner" << endl;
681 //cout << " Treatement is Extent && Intersect" << endl;
682 //cout << " -R : Discontinuities are treated like Round Corner" << endl;
683 //cout << " Treatement is Intersect and Fill" << endl;
684 //cout << " -S : To build a Solid" << endl;
685 di << "build sweep result [-M/-C/-R] [-S] [tol] : options are" << "\n";
686 di << " -M : Discontinuities are treated by Modfication of"<< "\n";
687 di << " the sweeping mode : it is the default" <<"\n";
688 di << " -C : Discontinuities are treated like Right Corner" << "\n";
689 di << " Treatement is Extent && Intersect" << "\n";
690 di << " -R : Discontinuities are treated like Round Corner" << "\n";
691 di << " Treatement is Intersect and Fill" << "\n";
692 di << " -S : To build a Solid" << "\n";
696 Standard_Boolean mksolid = Standard_False;
698 //cout << "You have forgotten the <<mksweep>> command !"<< endl;
699 di << "You have forgotten the <<mksweep>> command !"<< "\n";
703 if (!Sweep->IsReady()) {
704 //cout << "You have forgotten the <<addsweep>> command !"<< endl;
705 di << "You have forgotten the <<addsweep>> command !"<< "\n";
710 Standard_Integer cur=2;
712 BRepBuilderAPI_TransitionMode Transition = BRepBuilderAPI_Transformed;
714 // Reading Transition
715 if (!strcmp(a[cur],"-C")) {
716 Transition = BRepBuilderAPI_RightCorner;
719 else if (!strcmp(a[cur],"-R")) {
720 Transition = BRepBuilderAPI_RoundCorner;
723 Sweep->SetTransitionMode(Transition);
726 if ((n>cur) && (!strcmp(a[cur],"-S")) ) mksolid = Standard_True;
728 // Calcul le resultat
730 if (!Sweep->IsDone()) {
731 //cout << "Buildsweep : Not Done" << endl;
732 di << "Buildsweep : Not Done" << "\n";
733 BRepBuilderAPI_PipeError Stat = Sweep->GetStatus();
734 if (Stat == BRepBuilderAPI_PlaneNotIntersectGuide) {
735 //cout << "Buildsweep : One Plane not intersect the guide" << endl;
736 di << "Buildsweep : One Plane not intersect the guide" << "\n";
738 if (Stat == BRepBuilderAPI_ImpossibleContact) {
739 //cout << "BuildSweep : One section can not be in contact with the guide" << endl;
740 di << "BuildSweep : One section can not be in contact with the guide" << "\n";
747 B = Sweep->MakeSolid();
748 //if (!B) cout << " BuildSweep : It is impossible to make a solid !" << endl;
749 if (!B) di << " BuildSweep : It is impossible to make a solid !" << "\n";
751 result = Sweep->Shape();
752 DBRep::Set(a[1],result);
758 //=======================================================================
760 //=======================================================================
761 static Standard_Integer simulsweep(Draw_Interpretor& di,
762 Standard_Integer n, const char** a)
764 if ( (n!=3) && (n!=4) ) return 1;
767 //cout << "You have forgotten the <<mksweep>> command !"<< endl;
768 di << "You have forgotten the <<mksweep>> command !"<< "\n";
772 if (!Sweep->IsReady()) {
773 //cout << "You have forgotten the <<addsweep>> command !"<< endl;
774 di << "You have forgotten the <<addsweep>> command !"<< "\n";
779 TopTools_ListOfShape List;
780 TopTools_ListIteratorOfListOfShape it;
781 Standard_Integer N, ii;
782 N = Draw::Atoi(a[2]);
785 BRepBuilderAPI_TransitionMode Transition = BRepBuilderAPI_Transformed;
786 // Lecture Transition
787 if (!strcmp(a[3],"-C")) {
788 Transition = BRepBuilderAPI_RightCorner;
790 else if (!strcmp(a[3],"-R")) {
791 Transition = BRepBuilderAPI_RoundCorner;
793 Sweep->SetTransitionMode(Transition);
796 // Calculate the result
797 Sweep->Simulate(N, List);
798 for (ii=1, it.Initialize(List); it.More(); it.Next(), ii++) {
799 Sprintf(name,"%s_%d",a[1],ii);
800 DBRep::Set(name, it.Value());
806 //=======================================================================
808 //=======================================================================
809 static Standard_Integer middlepath(Draw_Interpretor& /*di*/,
810 Standard_Integer n, const char** a)
814 TopoDS_Shape aShape = DBRep::Get(a[2]);
815 if (aShape.IsNull()) return 1;
817 TopoDS_Shape StartShape = DBRep::Get(a[3]);
818 if (StartShape.IsNull()) return 1;
820 TopoDS_Shape EndShape = DBRep::Get(a[4]);
821 if (EndShape.IsNull()) return 1;
823 BRepOffsetAPI_MiddlePath Builder(aShape, StartShape, EndShape);
826 TopoDS_Shape Result = Builder.Shape();
827 DBRep::Set(a[1], Result);
832 //=======================================================================
833 //function : SweepCommands
835 //=======================================================================
837 void BRepTest::SweepCommands(Draw_Interpretor& theCommands)
839 static Standard_Boolean done = Standard_False;
841 done = Standard_True;
843 DBRep::BasicCommands(theCommands);
845 const char* g = "Sweep commands";
847 theCommands.Add("prism",
848 "prism result base dx dy dz [Copy | Inf | Seminf]",
851 theCommands.Add("revol",
852 "revol result base px py pz dx dy dz angle [Copy]",
855 theCommands.Add("pipe",
856 "pipe result Wire_spine Profile [Mode [Approx]], no args to get help",
859 theCommands.Add("evolved",
860 "evolved , no args to get help",
863 theCommands.Add("evolvedsolid",
864 "evolved , no args to get help",
867 theCommands.Add("pruled",
868 "pruled result Edge1/Wire1 Edge2/Wire2",
871 theCommands.Add("gener", "gener result wire1 wire2 [..wire..]",
874 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)",
875 __FILE__,thrusections,g);
878 theCommands.Add("mksweep", "mksweep wire",
881 theCommands.Add("setsweep", "setsweep no args to get help",
882 __FILE__,setsweep,g);
884 theCommands.Add("addsweep",
885 "addsweep wire [vertex] [-M ] [-C] [auxiilaryshape]:no args to get help",
886 __FILE__,addsweep,g);
888 theCommands.Add("deletesweep",
889 "deletesweep wire, To delete a section",
890 __FILE__,deletesweep,g);
892 theCommands.Add("buildsweep", "builsweep [r] [option] [Tol] , no args to get help"
893 __FILE__,buildsweep,g);
895 theCommands.Add("simulsweep", "simulsweep r [n] [option]"
896 __FILE__,simulsweep,g);
897 theCommands.Add("geompipe", "geompipe r spineedge profileedge radius [byACR [byrotate]]"
898 __FILE__,geompipe,g);
900 theCommands.Add("middlepath", "middlepath res shape startshape endshape",
901 __FILE__,middlepath,g);