1 // Created on: 1993-07-22
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
24 #include <BRepTest.hxx>
26 #include <Draw_Interpretor.hxx>
27 #include <Draw_Appli.hxx>
29 #include <BRepFill.hxx>
30 #include <BRepBuilderAPI_PipeError.hxx>
31 #include <BRepFill_Generator.hxx>
32 #include <BRepPrimAPI_MakePrism.hxx>
33 #include <BRepPrimAPI_MakeRevol.hxx>
34 #include <BRepOffsetAPI_MakePipe.hxx>
35 #include <BRepOffsetAPI_MakeEvolved.hxx>
36 #include <BRepOffsetAPI_ThruSections.hxx>
37 #include <BRepOffsetAPI_MakePipeShell.hxx>
38 #include <BRepOffsetAPI_MiddlePath.hxx>
40 #include <BRepLib_MakeWire.hxx>
42 #include <TopTools_ListIteratorOfListOfShape.hxx>
43 #include <TopExp_Explorer.hxx>
45 #include <Precision.hxx>
46 #include <Law_Interpol.hxx>
49 #include <gp_Pnt2d.hxx>
50 #include <TColgp_Array1OfPnt2d.hxx>
52 static BRepOffsetAPI_MakePipeShell* Sweep= 0;
56 #include <Geom_Curve.hxx>
57 #include <GeomAdaptor_HCurve.hxx>
58 #include <GeomFill_Pipe.hxx>
59 #include <Geom_Surface.hxx>
60 #include <BRepBuilderAPI_MakeFace.hxx>
61 #include <BRep_Tool.hxx>
63 //#endi#include <gp_Vec.hxx>
65 #include <Geom_Circle.hxx>
69 //=======================================================================
71 //=======================================================================
73 static Standard_Integer prism(Draw_Interpretor& , Standard_Integer n, const char** a)
77 TopoDS_Shape base = DBRep::Get(a[2]);
78 if (base.IsNull()) return 1;
80 gp_Vec V(Draw::Atof(a[3]),Draw::Atof(a[4]),Draw::Atof(a[5]));
82 Standard_Boolean copy = Standard_False;
83 Standard_Boolean inf = Standard_False;
84 Standard_Boolean sinf = Standard_False;
87 copy = (*a[6] == 'c') || (*a[6] == 'C');
88 inf = (*a[6] == 'i') || (*a[6] == 'I');
89 sinf = (*a[6] == 's') || (*a[6] == 'S');
95 res = BRepPrimAPI_MakePrism(base,gp_Dir(V),inf);
97 res = BRepPrimAPI_MakePrism(base,V,copy);
105 //=======================================================================
107 //=======================================================================
109 static Standard_Integer revol(Draw_Interpretor& ,
110 Standard_Integer n, const char** a)
112 if (n < 10) return 1;
114 TopoDS_Shape base = DBRep::Get(a[2]);
115 if (base.IsNull()) return 1;
117 gp_Pnt P(Draw::Atof(a[3]),Draw::Atof(a[4]),Draw::Atof(a[5]));
118 gp_Dir D(Draw::Atof(a[6]),Draw::Atof(a[7]),Draw::Atof(a[8]));
121 Standard_Real angle = Draw::Atof(a[9]) * (M_PI / 180.0);
123 Standard_Boolean copy = n > 10;
125 TopoDS_Shape res = BRepPrimAPI_MakeRevol(base,A,angle,copy);
127 DBRep::Set(a[1],res);
133 //=======================================================================
135 //=======================================================================
137 static Standard_Integer pipe(Draw_Interpretor& di,
138 Standard_Integer n, const char** a)
142 di << "pipe result Wire_spine Profile [Mode [Approx]]" << "\n";
143 di << "Mode = 0 - CorrectedFrenet," << "\n";
144 di << " = 1 - Frenet," << "\n";
145 di << " = 2 - DiscreteTrihedron" << "\n";
146 di << "Approx - force C1-approximation if result is C0" << "\n";
150 if (n > 1 && n < 4) return 1;
152 TopoDS_Shape Spine = DBRep::Get(a[2],TopAbs_WIRE);
153 if ( Spine.IsNull()) return 1;
155 TopoDS_Shape Profile = DBRep::Get(a[3]);
156 if ( Profile.IsNull()) return 1;
158 GeomFill_Trihedron Mode = GeomFill_IsCorrectedFrenet;
161 Standard_Integer iMode = atoi(a[4]);
163 Mode = GeomFill_IsFrenet;
165 Mode = GeomFill_IsDiscreteTrihedron;
168 Standard_Boolean ForceApproxC1 = Standard_False;
170 ForceApproxC1 = Standard_True;
172 TopoDS_Shape S = BRepOffsetAPI_MakePipe(TopoDS::Wire(Spine),
182 //=======================================================================
184 static Standard_Integer geompipe(Draw_Interpretor& ,
185 Standard_Integer n, const char** a)
187 TopoDS_Shape Spine = DBRep::Get(a[2],TopAbs_EDGE);
188 if ( Spine.IsNull()) return 1;
189 if ( n < 5) return 1;
190 TopoDS_Shape Profile = DBRep::Get(a[3],TopAbs_EDGE);
191 if ( Profile.IsNull()) return 1;
192 Standard_Real aSpFirst,aSpLast,aPrFirst,aPrLast;
193 Handle(Geom_Curve) SpineCurve = BRep_Tool::Curve(TopoDS::Edge(Spine),aSpFirst,aSpLast);
194 Handle(Geom_Curve) ProfileCurve = BRep_Tool::Curve(TopoDS::Edge(Profile),aPrFirst,aPrLast);
195 Handle(GeomAdaptor_HCurve) aAdaptCurve = new GeomAdaptor_HCurve(SpineCurve,aSpFirst,aSpLast);
196 Standard_Boolean ByACR = Standard_False;
197 Standard_Boolean rotate = Standard_False;
198 Standard_Real Radius = Draw::Atof(a[4]);
201 ProfileCurve->D1(aSpFirst,ctr,norm);
202 gp_Vec xAxisStart(ctr,SpineCurve->Value(aSpFirst));
203 gp_Ax2 aAx2Start(ctr,norm,xAxisStart);
204 Handle(Geom_Circle) cStart=new Geom_Circle(aAx2Start,Radius);
205 Standard_Integer k =5;
207 ByACR = (Draw::Atoi(a[k++]) ==1);
209 rotate = (Draw::Atoi(a[k++])==1);
210 GeomFill_Pipe aPipe(ProfileCurve,aAdaptCurve,cStart,ByACR,rotate);
211 aPipe.Perform(Standard_True);
212 Handle(Geom_Surface) Sur=aPipe.Surface();
215 F = BRepBuilderAPI_MakeFace(Sur, Precision::Confusion());
220 //=======================================================================
223 //=======================================================================
225 Standard_Integer evolved(Draw_Interpretor& di, Standard_Integer n, const char** a)
228 //cout << " 1) evolved result base profil : "<< endl;
229 //cout << " The relative position of the profil on the base" << endl;
230 //cout << " is given in the referencial axis. " << endl;
231 //cout << " 2) evolved result base profil o : "<< endl;
232 //cout << " This position is automatically computed." << endl;
233 di << " 1) evolved result base profil : "<< "\n";
234 di << " The relative position of the profil on the base" << "\n";
235 di << " is given in the referencial axis. " << "\n";
236 di << " 2) evolved result base profil o : "<< "\n";
237 di << " This position is automatically computed." << "\n";
241 if ( n < 4 ) return 1;
242 Standard_Boolean IsAFace = Standard_False;
243 Standard_Boolean Solid = (!strcmp(a[0],"evolvedsolid"));
247 TopoDS_Shape Base = DBRep::Get(a[2],TopAbs_WIRE,Standard_False);
248 if ( Base.IsNull()) {
249 Base = DBRep::Get(a[2],TopAbs_FACE,Standard_False);
250 IsAFace = Standard_True;
252 if ( Base.IsNull()) return 1;
254 TopoDS_Shape InpuTShape(DBRep::Get(a[3],TopAbs_WIRE,Standard_False));
255 TopoDS_Wire Prof = TopoDS::Wire(InpuTShape);
256 // TopoDS_Wire Prof =
257 // TopoDS::Wire(DBRep::Get(a[3],TopAbs_WIRE,Standard_False));
258 if ( Prof.IsNull()) return 1;
262 = BRepOffsetAPI_MakeEvolved(TopoDS::Face(Base),Prof,GeomAbs_Arc,n == 4,Solid);
263 DBRep::Set(a[1],Volevo);
267 = BRepOffsetAPI_MakeEvolved(TopoDS::Wire(Base),Prof,GeomAbs_Arc,n == 4,Solid);
268 DBRep::Set(a[1],Volevo);
275 //=======================================================================
278 //=======================================================================
280 static Standard_Integer pruled(Draw_Interpretor& ,
281 Standard_Integer n, const char** a)
283 if ( n != 4) return 1;
285 Standard_Boolean YaWIRE = Standard_False;
286 TopoDS_Shape S1 = DBRep::Get(a[2],TopAbs_EDGE);
288 S1 = DBRep::Get(a[2],TopAbs_WIRE);
289 if (S1.IsNull()) return 1;
290 YaWIRE = Standard_True;
293 TopoDS_Shape S2 = DBRep::Get(a[3],TopAbs_EDGE);
295 S2 = DBRep::Get(a[3],TopAbs_WIRE);
296 if ( S2.IsNull()) return 1;
298 S1 = BRepLib_MakeWire(TopoDS::Edge(S1));
299 YaWIRE = Standard_True;
303 S2 = BRepLib_MakeWire(TopoDS::Edge(S2));
308 Result = BRepFill::Shell(TopoDS::Wire(S1),TopoDS::Wire(S2));
311 Result = BRepFill::Face(TopoDS::Edge(S1),TopoDS::Edge(S2));
314 DBRep::Set(a[1],Result);
319 //=======================================================================
321 //purpose : Create a surface between generating wires
322 //=======================================================================
324 Standard_Integer gener(Draw_Interpretor&, Standard_Integer n, const char** a)
326 if ( n < 4) return 1;
330 BRepFill_Generator Generator;
332 for ( Standard_Integer i = 2; i<= n-1 ; i++) {
333 Shape = DBRep::Get(a[i],TopAbs_WIRE);
337 Generator.AddWire(TopoDS::Wire(Shape));
342 TopoDS_Shell Shell = Generator.Shell();
344 DBRep::Set(a[1], Shell);
351 //=======================================================================
352 //function : thrusections
354 //=======================================================================
356 Standard_Integer thrusections(Draw_Interpretor&, Standard_Integer n, const char** a)
360 Standard_Boolean check = Standard_True;
361 Standard_Boolean samenumber = Standard_True;
362 Standard_Integer index = 2;
364 if (!strcmp(a[1],"-N")) {
366 check = Standard_False;
372 Standard_Boolean issolid = ( Draw::Atoi(a[index]) == 1 );
373 Standard_Boolean isruled = ( Draw::Atoi(a[index+1]) == 1 );
375 BRepOffsetAPI_ThruSections Generator(issolid,isruled);
377 Standard_Integer NbEdges = 0;
378 Standard_Boolean IsFirstWire = Standard_False;
379 for ( Standard_Integer i = index+2; i<= n-1 ; i++) {
380 Standard_Boolean IsWire = Standard_True;
381 Shape = DBRep::Get(a[i], TopAbs_WIRE);
384 Generator.AddWire(TopoDS::Wire(Shape));
386 IsFirstWire = Standard_True;
388 IsFirstWire = Standard_False;
392 Shape = DBRep::Get(a[i], TopAbs_VERTEX);
393 IsWire = Standard_False;
395 Generator.AddVertex(TopoDS::Vertex(Shape));
400 Standard_Integer cpt = 0;
402 for (PE.Init(Shape, TopAbs_EDGE); PE.More(); PE.Next()) {
408 if (IsWire && cpt != NbEdges)
409 samenumber = Standard_False;
413 check = (check || !samenumber);
414 Generator.CheckCompatibility(check);
418 TopoDS_Shape Shell = Generator.Shape();
420 DBRep::Set(a[index-1], Shell);
425 //=======================================================================
427 //=======================================================================
428 static Standard_Integer mksweep(Draw_Interpretor& ,
429 Standard_Integer n, const char** a)
431 if ( n != 2) return 1;
432 TopoDS_Shape Spine = DBRep::Get(a[1],TopAbs_WIRE);
433 if ( Spine.IsNull()) return 1;
438 Sweep = new BRepOffsetAPI_MakePipeShell(TopoDS::Wire(Spine));
442 //=======================================================================
444 //=======================================================================
445 static Standard_Integer setsweep(Draw_Interpretor& di,
446 Standard_Integer n, const char** a)
449 //cout << "setsweep options [arg1 [arg2 [...]]] : options are :" << endl;
450 //cout << " -FR : Tangent and Normal are given by Frenet trihedron" <<endl;
451 //cout << " -CF : Tangente is given by Frenet," << endl;
452 //cout << " the Normal is computed to minimize the torsion " << endl;
453 //cout << " -DX Surf : Tangent and Normal are given by Darboux trihedron,"
455 //cout << " Surf have to be a shell or a face" <<endl;
456 //cout << " -CN dx dy dz : BiNormal is given by dx dy dz" << endl;
457 //cout << " -FX Tx Ty TZ [Nx Ny Nz] : Tangent and Normal are fixed" <<endl;
458 //cout << " -G guide 0|1(ACR|Plan) 0|1(contact|no contact) : with guide"<<endl;
459 di << "setsweep options [arg1 [arg2 [...]]] : options are :" << "\n";
460 di << " -FR : Tangent and Normal are given by Frenet trihedron" <<"\n";
461 di << " -CF : Tangente is given by Frenet," << "\n";
462 di << " the Normal is computed to minimize the torsion " << "\n";
463 di << " -DT : discrete trihedron" << "\n";
464 di << " -DX Surf : Tangent and Normal are given by Darboux trihedron," <<"\n";
465 di << " Surf have to be a shell or a face" <<"\n";
466 di << " -CN dx dy dz : BiNormal is given by dx dy dz" << "\n";
467 di << " -FX Tx Ty TZ [Nx Ny Nz] : Tangent and Normal are fixed" <<"\n";
468 di << " -G guide 0|1(Plan|ACR) 0|1|2(no contact|contact|contact on border) : with guide"<<"\n";
473 //cout << "You have forgotten the <<mksweep>> command !"<< endl;
474 di << "You have forgotten the <<mksweep>> command !"<< "\n";
477 if (!strcmp(a[1],"-FR")) {
478 Sweep->SetMode(Standard_True);
480 else if (!strcmp(a[1],"-CF")) {
481 Sweep->SetMode(Standard_False);
483 else if (!strcmp(a[1],"-DT")) {
484 Sweep->SetDiscreteMode();
486 else if (!strcmp(a[1],"-DX")) {
488 //cout << "bad arguments !" << endl;
489 di << "bad arguments !" << "\n";
493 Surf = DBRep::Get(a[2],TopAbs_SHAPE);
495 //cout << a[2] <<"is not a shape !" << endl;
496 di << a[2] <<"is not a shape !" << "\n";
499 Sweep->SetMode(Surf);
501 else if (!strcmp(a[1],"-CN")) {
503 //cout << "bad arguments !" << endl;
504 di << "bad arguments !" << "\n";
507 gp_Dir D(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4]));
510 else if (!strcmp(a[1],"-FX")) {
511 if ((n!=5)&&(n!=8)) {
512 //cout << "bad arguments !" << endl;
513 di << "bad arguments !" << "\n";
516 gp_Dir D(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4]));
518 gp_Dir DN(Draw::Atof(a[5]), Draw::Atof(a[6]), Draw::Atof(a[7]));
519 gp_Ax2 Axe(gp_Pnt(0., 0., 0.), D, DN);
523 gp_Ax2 Axe(gp_Pnt(0., 0., 0.), D);
527 else if (!strcmp(a[1],"-G")) // contour guide
531 //cout << "bad arguments !" << endl;
532 di << "bad arguments !" << "\n";
537 TopoDS_Shape Guide = DBRep::Get(a[2],TopAbs_WIRE);
538 Standard_Integer CurvilinearEquivalence = Draw::Atoi(a[3]);
539 Standard_Integer KeepContact = Draw::Atoi(a[4]);
540 Sweep->SetMode(TopoDS::Wire(Guide),
541 CurvilinearEquivalence,
542 (BRepFill_TypeOfContact)KeepContact);
547 //cout << "The option "<< a[1] << " is unknown !" << endl;
548 di << "The option "<< a[1] << " is unknown !" << "\n";
555 //=======================================================================
557 //=======================================================================
558 static Standard_Integer addsweep(Draw_Interpretor& di,
559 Standard_Integer n, const char** a)
562 //cout << "addsweep wire/vertex [Vertex] [-T] [-R] [u0 v0 u1 v1 [...[uN vN]]] : options are :" << endl;
563 //cout << " -T : the wire/vertex have to be translated to assume contact"<< endl;
564 //cout << " with the spine" <<endl;
565 //cout << " -R : the wire have to be rotated to assume orthogonality"<<endl;
566 //cout << " with the spine's tangent" << endl;
567 di << "addsweep wire/vertex [Vertex] [-T] [-R] [u0 v0 u1 v1 [...[uN vN]]] : options are :" << "\n";
568 di << " -T : the wire/vertex have to be translated to assume contact"<< "\n";
569 di << " with the spine" <<"\n";
570 di << " -R : the wire have to be rotated to assume orthogonality"<<"\n";
571 di << " with the spine's tangent" << "\n";
576 //cout << "You have forgotten the <<mksweep>> command !"<< endl;
577 di << "You have forgotten the <<mksweep>> command !"<< "\n";
581 TopoDS_Shape Section;
582 TopoDS_Vertex Vertex;
583 Handle(Law_Interpol) thelaw;
585 Section = DBRep::Get(a[1], TopAbs_SHAPE);
586 if (Section.ShapeType() != TopAbs_WIRE &&
587 Section.ShapeType() != TopAbs_VERTEX)
589 //cout << a[1] <<"is not a wire and is not a vertex!" << endl;
590 di << a[1] <<"is not a wire and is not a vertex!" << "\n";
594 Standard_Boolean HasVertex=Standard_False,
599 Standard_Integer cur = 2;
601 TopoDS_Shape InputVertex(DBRep::Get(a[cur],TopAbs_VERTEX));
602 Vertex = TopoDS::Vertex(InputVertex);
603 // Vertex = TopoDS::Vertex(DBRep::Get(a[cur],TopAbs_VERTEX));
604 if (!Vertex.IsNull()) {
606 HasVertex = Standard_True;
609 // Reading of the translation option
610 if ((n>cur) && !strcmp(a[cur],"-T")) {
615 // Reading of the rotation option
616 if ((n>cur) && !strcmp(a[cur],"-R")) {
623 Standard_Integer nbreal = n-cur;
624 if ( (nbreal < 4) || (nbreal % 2 != 0) ) {
625 //cout << "bad arguments ! :" <<a[cur] << endl;
626 di << "bad arguments ! :" <<a[cur] << "\n";
627 } else { //law of interpolation
628 Standard_Integer ii, L= nbreal/2;
629 TColgp_Array1OfPnt2d ParAndRad(1, L);
630 for (ii=1; ii<=L; ii++, cur+=2) {
631 ParAndRad(ii).SetX(Draw::Atof(a[cur]));
632 ParAndRad(ii).SetY(Draw::Atof(a[cur+1]));
634 thelaw = new (Law_Interpol) ();
635 thelaw->Set(ParAndRad,
636 Abs(ParAndRad(1).Y() - ParAndRad(L).Y()) < Precision::Confusion());
641 if (thelaw.IsNull()) {
642 if (HasVertex) Sweep->Add(Section, Vertex, isT, isR);
643 else Sweep->Add(Section, isT, isR);
646 if (HasVertex) Sweep->SetLaw(Section, thelaw, Vertex, isT, isR);
647 else Sweep->SetLaw(Section, thelaw, isT, isR);
653 //=======================================================================
655 //=======================================================================
656 static Standard_Integer deletesweep(Draw_Interpretor& di,
657 Standard_Integer n, const char** a)
663 TopoDS_Shape InputShape(DBRep::Get(a[1],TopAbs_SHAPE));
664 Section = TopoDS::Wire(InputShape);
665 // Section = TopoDS::Wire(DBRep::Get(a[1],TopAbs_SHAPE));
666 if (Section.IsNull()) {
667 //cout << a[1] <<"is not a wire !" << endl;
668 di << a[1] <<"is not a wire !" << "\n";
672 Sweep->Delete(Section);
677 //=======================================================================
679 //=======================================================================
680 static Standard_Integer buildsweep(Draw_Interpretor& di,
681 Standard_Integer n, const char** a)
684 //cout << "build sweep result [-M/-C/-R] [-S] [tol] : options are" << endl;
685 //cout << " -M : Discontinuities are treated by Modfication of"<< endl;
686 //cout << " the sweeping mode : it is the default" <<endl;
687 //cout << " -C : Discontinuities are treated like Right Corner" << endl;
688 //cout << " Treatement is Extent && Intersect" << endl;
689 //cout << " -R : Discontinuities are treated like Round Corner" << endl;
690 //cout << " Treatement is Intersect and Fill" << endl;
691 //cout << " -S : To build a Solid" << endl;
692 di << "build sweep result [-M/-C/-R] [-S] [tol] : options are" << "\n";
693 di << " -M : Discontinuities are treated by Modfication of"<< "\n";
694 di << " the sweeping mode : it is the default" <<"\n";
695 di << " -C : Discontinuities are treated like Right Corner" << "\n";
696 di << " Treatement is Extent && Intersect" << "\n";
697 di << " -R : Discontinuities are treated like Round Corner" << "\n";
698 di << " Treatement is Intersect and Fill" << "\n";
699 di << " -S : To build a Solid" << "\n";
703 Standard_Boolean mksolid = Standard_False;
705 //cout << "You have forgotten the <<mksweep>> command !"<< endl;
706 di << "You have forgotten the <<mksweep>> command !"<< "\n";
710 if (!Sweep->IsReady()) {
711 //cout << "You have forgotten the <<addsweep>> command !"<< endl;
712 di << "You have forgotten the <<addsweep>> command !"<< "\n";
717 Standard_Integer cur=2;
719 BRepBuilderAPI_TransitionMode Transition = BRepBuilderAPI_Transformed;
721 // Reading Transition
722 if (!strcmp(a[cur],"-C")) {
723 Transition = BRepBuilderAPI_RightCorner;
726 else if (!strcmp(a[cur],"-R")) {
727 Transition = BRepBuilderAPI_RoundCorner;
730 Sweep->SetTransitionMode(Transition);
733 if ((n>cur) && (!strcmp(a[cur],"-S")) ) mksolid = Standard_True;
735 // Calcul le resultat
737 if (!Sweep->IsDone()) {
738 //cout << "Buildsweep : Not Done" << endl;
739 di << "Buildsweep : Not Done" << "\n";
740 BRepBuilderAPI_PipeError Stat = Sweep->GetStatus();
741 if (Stat == BRepBuilderAPI_PlaneNotIntersectGuide) {
742 //cout << "Buildsweep : One Plane not intersect the guide" << endl;
743 di << "Buildsweep : One Plane not intersect the guide" << "\n";
745 if (Stat == BRepBuilderAPI_ImpossibleContact) {
746 //cout << "BuildSweep : One section can not be in contact with the guide" << endl;
747 di << "BuildSweep : One section can not be in contact with the guide" << "\n";
754 B = Sweep->MakeSolid();
755 //if (!B) cout << " BuildSweep : It is impossible to make a solid !" << endl;
756 if (!B) di << " BuildSweep : It is impossible to make a solid !" << "\n";
758 result = Sweep->Shape();
759 DBRep::Set(a[1],result);
765 //=======================================================================
767 //=======================================================================
768 static Standard_Integer simulsweep(Draw_Interpretor& di,
769 Standard_Integer n, const char** a)
771 if ( (n!=3) && (n!=4) ) return 1;
774 //cout << "You have forgotten the <<mksweep>> command !"<< endl;
775 di << "You have forgotten the <<mksweep>> command !"<< "\n";
779 if (!Sweep->IsReady()) {
780 //cout << "You have forgotten the <<addsweep>> command !"<< endl;
781 di << "You have forgotten the <<addsweep>> command !"<< "\n";
786 TopTools_ListOfShape List;
787 TopTools_ListIteratorOfListOfShape it;
788 Standard_Integer N, ii;
789 N = Draw::Atoi(a[2]);
792 BRepBuilderAPI_TransitionMode Transition = BRepBuilderAPI_Transformed;
793 // Lecture Transition
794 if (!strcmp(a[3],"-C")) {
795 Transition = BRepBuilderAPI_RightCorner;
797 else if (!strcmp(a[3],"-R")) {
798 Transition = BRepBuilderAPI_RoundCorner;
800 Sweep->SetTransitionMode(Transition);
803 // Calculate the result
804 Sweep->Simulate(N, List);
805 for (ii=1, it.Initialize(List); it.More(); it.Next(), ii++) {
806 Sprintf(name,"%s_%d",a[1],ii);
807 DBRep::Set(name, it.Value());
813 //=======================================================================
815 //=======================================================================
816 static Standard_Integer middlepath(Draw_Interpretor& /*di*/,
817 Standard_Integer n, const char** a)
821 TopoDS_Shape aShape = DBRep::Get(a[2]);
822 if (aShape.IsNull()) return 1;
824 TopoDS_Shape StartShape = DBRep::Get(a[3]);
825 if (StartShape.IsNull()) return 1;
827 TopoDS_Shape EndShape = DBRep::Get(a[4]);
828 if (EndShape.IsNull()) return 1;
830 BRepOffsetAPI_MiddlePath Builder(aShape, StartShape, EndShape);
833 TopoDS_Shape Result = Builder.Shape();
834 DBRep::Set(a[1], Result);
839 //=======================================================================
840 //function : SweepCommands
842 //=======================================================================
844 void BRepTest::SweepCommands(Draw_Interpretor& theCommands)
846 static Standard_Boolean done = Standard_False;
848 done = Standard_True;
850 DBRep::BasicCommands(theCommands);
852 const char* g = "Sweep commands";
854 theCommands.Add("prism",
855 "prism result base dx dy dz [Copy | Inf | Seminf]",
858 theCommands.Add("revol",
859 "revol result base px py pz dx dy dz angle [Copy]",
862 theCommands.Add("pipe",
863 "pipe result Wire_spine Profile [Mode [Approx]], no args to get help",
866 theCommands.Add("evolved",
867 "evolved , no args to get help",
870 theCommands.Add("evolvedsolid",
871 "evolved , no args to get help",
874 theCommands.Add("pruled",
875 "pruled result Edge1/Wire1 Edge2/Wire2",
878 theCommands.Add("gener", "gener result wire1 wire2 [..wire..]",
881 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)",
882 __FILE__,thrusections,g);
885 theCommands.Add("mksweep", "mksweep wire",
888 theCommands.Add("setsweep", "setsweep no args to get help",
889 __FILE__,setsweep,g);
891 theCommands.Add("addsweep",
892 "addsweep wire [vertex] [-M ] [-C] [auxiilaryshape]:no args to get help",
893 __FILE__,addsweep,g);
895 theCommands.Add("deletesweep",
896 "deletesweep wire, To delete a section",
897 __FILE__,deletesweep,g);
899 theCommands.Add("buildsweep", "builsweep [r] [option] [Tol] , no args to get help"
900 __FILE__,buildsweep,g);
902 theCommands.Add("simulsweep", "simulsweep r [n] [option]"
903 __FILE__,simulsweep,g);
904 theCommands.Add("geompipe", "geompipe r spineedge profileedge radius [byACR [byrotate]]"
905 __FILE__,geompipe,g);
907 theCommands.Add("middlepath", "middlepath res shape startshape endshape",
908 __FILE__,middlepath,g);