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;
46 static BRepOffsetAPI_ThruSections* Generator = 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>
57 #include <Geom_Circle.hxx>
61 //=======================================================================
63 //=======================================================================
65 static Standard_Integer prism(Draw_Interpretor& , Standard_Integer n, const char** a)
69 TopoDS_Shape base = DBRep::Get(a[2]);
70 if (base.IsNull()) return 1;
72 gp_Vec V(Draw::Atof(a[3]),Draw::Atof(a[4]),Draw::Atof(a[5]));
74 Standard_Boolean copy = Standard_False;
75 Standard_Boolean inf = Standard_False;
76 Standard_Boolean sinf = Standard_False;
79 copy = (*a[6] == 'c') || (*a[6] == 'C');
80 inf = (*a[6] == 'i') || (*a[6] == 'I');
81 sinf = (*a[6] == 's') || (*a[6] == 'S');
87 res = BRepPrimAPI_MakePrism(base,gp_Dir(V),inf);
89 res = BRepPrimAPI_MakePrism(base,V,copy);
97 //=======================================================================
99 //=======================================================================
101 static Standard_Integer revol(Draw_Interpretor& ,
102 Standard_Integer n, const char** a)
104 if (n < 10) return 1;
106 TopoDS_Shape base = DBRep::Get(a[2]);
107 if (base.IsNull()) return 1;
109 gp_Pnt P(Draw::Atof(a[3]),Draw::Atof(a[4]),Draw::Atof(a[5]));
110 gp_Dir D(Draw::Atof(a[6]),Draw::Atof(a[7]),Draw::Atof(a[8]));
113 Standard_Real angle = Draw::Atof(a[9]) * (M_PI / 180.0);
115 Standard_Boolean copy = n > 10;
117 TopoDS_Shape res = BRepPrimAPI_MakeRevol(base,A,angle,copy);
119 DBRep::Set(a[1],res);
125 //=======================================================================
127 //=======================================================================
129 static Standard_Integer pipe(Draw_Interpretor& di,
130 Standard_Integer n, const char** a)
134 di << "pipe result Wire_spine Profile [Mode [Approx]]\n";
135 di << "Mode = 0 - CorrectedFrenet,\n";
136 di << " = 1 - Frenet,\n";
137 di << " = 2 - DiscreteTrihedron\n";
138 di << "Approx - force C1-approximation if result is C0\n";
142 if (n > 1 && n < 4) return 1;
144 TopoDS_Shape Spine = DBRep::Get(a[2],TopAbs_WIRE);
145 if ( Spine.IsNull()) return 1;
147 TopoDS_Shape Profile = DBRep::Get(a[3]);
148 if ( Profile.IsNull()) return 1;
150 GeomFill_Trihedron Mode = GeomFill_IsCorrectedFrenet;
153 Standard_Integer iMode = atoi(a[4]);
155 Mode = GeomFill_IsFrenet;
157 Mode = GeomFill_IsDiscreteTrihedron;
160 Standard_Boolean ForceApproxC1 = Standard_False;
162 ForceApproxC1 = Standard_True;
164 TopoDS_Shape S = BRepOffsetAPI_MakePipe(TopoDS::Wire(Spine),
174 //=======================================================================
176 static Standard_Integer geompipe(Draw_Interpretor& ,
177 Standard_Integer n, const char** a)
179 TopoDS_Shape Spine = DBRep::Get(a[2],TopAbs_EDGE);
180 if ( Spine.IsNull()) return 1;
181 if ( n < 5) return 1;
182 TopoDS_Shape Profile = DBRep::Get(a[3],TopAbs_EDGE);
183 if ( Profile.IsNull()) return 1;
184 Standard_Real aSpFirst,aSpLast,aPrFirst,aPrLast;
185 Handle(Geom_Curve) SpineCurve = BRep_Tool::Curve(TopoDS::Edge(Spine),aSpFirst,aSpLast);
186 Handle(Geom_Curve) ProfileCurve = BRep_Tool::Curve(TopoDS::Edge(Profile),aPrFirst,aPrLast);
187 Handle(GeomAdaptor_HCurve) aAdaptCurve = new GeomAdaptor_HCurve(SpineCurve,aSpFirst,aSpLast);
188 Standard_Boolean ByACR = Standard_False;
189 Standard_Boolean rotate = Standard_False;
190 Standard_Real Radius = Draw::Atof(a[4]);
193 ProfileCurve->D1(aSpFirst,ctr,norm);
194 gp_Vec xAxisStart(ctr,SpineCurve->Value(aSpFirst));
195 gp_Ax2 aAx2Start(ctr,norm,xAxisStart);
196 Handle(Geom_Circle) cStart=new Geom_Circle(aAx2Start,Radius);
197 Standard_Integer k =5;
199 ByACR = (Draw::Atoi(a[k++]) ==1);
201 rotate = (Draw::Atoi(a[k++])==1);
202 GeomFill_Pipe aPipe(ProfileCurve,aAdaptCurve,cStart,ByACR,rotate);
203 aPipe.Perform(Standard_True);
206 cout << "GeomFill_Pipe cannot make a surface" << endl;
209 Handle(Geom_Surface) Sur=aPipe.Surface();
212 F = BRepBuilderAPI_MakeFace(Sur, Precision::Confusion());
217 //=======================================================================
220 //=======================================================================
222 Standard_Integer evolved(Draw_Interpretor& di, Standard_Integer n, const char** a)
225 //cout << " 1) evolved result base profil : "<< endl;
226 //cout << " The relative position of the profil on the base" << endl;
227 //cout << " is given in the referencial axis. " << endl;
228 //cout << " 2) evolved result base profil o : "<< endl;
229 //cout << " This position is automatically computed." << endl;
230 di << " 1) evolved result base profil : \n";
231 di << " The relative position of the profil on the base\n";
232 di << " is given in the referencial axis. \n";
233 di << " 2) evolved result base profil o : \n";
234 di << " This position is automatically computed.\n";
238 if ( n < 4 ) return 1;
239 Standard_Boolean IsAFace = Standard_False;
240 Standard_Boolean Solid = (!strcmp(a[0],"evolvedsolid"));
244 TopoDS_Shape Base = DBRep::Get(a[2],TopAbs_WIRE,Standard_False);
245 if ( Base.IsNull()) {
246 Base = DBRep::Get(a[2],TopAbs_FACE,Standard_False);
247 IsAFace = Standard_True;
249 if ( Base.IsNull()) return 1;
251 TopoDS_Shape InpuTShape(DBRep::Get(a[3],TopAbs_WIRE,Standard_False));
252 TopoDS_Wire Prof = TopoDS::Wire(InpuTShape);
253 // TopoDS_Wire Prof =
254 // TopoDS::Wire(DBRep::Get(a[3],TopAbs_WIRE,Standard_False));
255 if ( Prof.IsNull()) return 1;
259 = BRepOffsetAPI_MakeEvolved(TopoDS::Face(Base),Prof,GeomAbs_Arc,n == 4,Solid);
260 DBRep::Set(a[1],Volevo);
264 = BRepOffsetAPI_MakeEvolved(TopoDS::Wire(Base),Prof,GeomAbs_Arc,n == 4,Solid);
265 DBRep::Set(a[1],Volevo);
272 //=======================================================================
275 //=======================================================================
277 static Standard_Integer pruled(Draw_Interpretor& ,
278 Standard_Integer n, const char** a)
280 if ( n != 4) return 1;
282 Standard_Boolean YaWIRE = Standard_False;
283 TopoDS_Shape S1 = DBRep::Get(a[2],TopAbs_EDGE);
285 S1 = DBRep::Get(a[2],TopAbs_WIRE);
286 if (S1.IsNull()) return 1;
287 YaWIRE = Standard_True;
290 TopoDS_Shape S2 = DBRep::Get(a[3],TopAbs_EDGE);
292 S2 = DBRep::Get(a[3],TopAbs_WIRE);
293 if ( S2.IsNull()) return 1;
295 S1 = BRepLib_MakeWire(TopoDS::Edge(S1));
296 YaWIRE = Standard_True;
300 S2 = BRepLib_MakeWire(TopoDS::Edge(S2));
305 Result = BRepFill::Shell(TopoDS::Wire(S1),TopoDS::Wire(S2));
308 Result = BRepFill::Face(TopoDS::Edge(S1),TopoDS::Edge(S2));
311 DBRep::Set(a[1],Result);
316 //=======================================================================
318 //purpose : Create a surface between generating wires
319 //=======================================================================
321 Standard_Integer gener(Draw_Interpretor&, Standard_Integer n, const char** a)
323 if ( n < 4) return 1;
327 BRepFill_Generator aGenerator;
329 for ( Standard_Integer i = 2; i<= n-1 ; i++) {
330 Shape = DBRep::Get(a[i],TopAbs_WIRE);
334 aGenerator.AddWire(TopoDS::Wire(Shape));
337 aGenerator.Perform();
339 TopoDS_Shell Shell = aGenerator.Shell();
341 DBRep::Set(a[1], Shell);
348 //=======================================================================
349 //function : thrusections
351 //=======================================================================
353 Standard_Integer thrusections(Draw_Interpretor&, Standard_Integer n, const char** a)
357 Standard_Boolean check = Standard_True;
358 Standard_Boolean samenumber = Standard_True;
359 Standard_Integer index = 2;
361 if (!strcmp(a[1],"-N")) {
363 check = Standard_False;
369 Standard_Boolean issolid = ( Draw::Atoi(a[index]) == 1 );
370 Standard_Boolean isruled = ( Draw::Atoi(a[index+1]) == 1 );
377 Generator = new BRepOffsetAPI_ThruSections(issolid,isruled);
379 Standard_Integer NbEdges = 0;
380 Standard_Boolean IsFirstWire = Standard_False;
381 for ( Standard_Integer i = index+2; i<= n-1 ; i++) {
382 Standard_Boolean IsWire = Standard_True;
383 Shape = DBRep::Get(a[i], TopAbs_WIRE);
386 Generator->AddWire(TopoDS::Wire(Shape));
388 IsFirstWire = Standard_True;
390 IsFirstWire = Standard_False;
394 Shape = DBRep::Get(a[i], TopAbs_VERTEX);
395 IsWire = Standard_False;
397 Generator->AddVertex(TopoDS::Vertex(Shape));
402 Standard_Integer cpt = 0;
404 for (PE.Init(Shape, TopAbs_EDGE); PE.More(); PE.Next()) {
410 if (IsWire && cpt != NbEdges)
411 samenumber = Standard_False;
415 check = (check || !samenumber);
416 Generator->CheckCompatibility(check);
420 if (Generator->IsDone()) {
421 TopoDS_Shape Shell = Generator->Shape();
422 DBRep::Set(a[index-1], Shell);
425 cout << "Algorithm is not done" << endl;
430 //============================================================================
431 //function : genthrus
432 //purpose : returns generated shape for subshape of a section of thrusections
433 // Thrusections must be done previously
434 //============================================================================
435 static Standard_Integer genthrus(Draw_Interpretor& di,
436 Standard_Integer n, const char** a)
440 di << "genthrus: it is called after thrusections command\n";
442 di << "- chain of generated faces for sub-edge of a profile;\n";
443 di << "- chain of generated edges for sub-vertex of a profile;\n";
444 di << "- bunch of chains of generated edges for start or end vertex if it is degenerated section.\n";
445 di << "Usage: genthrus res subshape_of_profile, thrusections must be done\n";
450 di << "You have forgotten the <<thrusections>> command !\n";
453 if (!Generator->IsDone())
455 di << "Thrusections is not done\n";
458 TopoDS_Shape aShape = DBRep::Get(a[2]);
461 cout<<"Null subshape"<<endl;
464 const TopTools_ListOfShape& Edges = Generator->Generated(aShape);
465 TopoDS_Compound aCompound;
467 BB.MakeCompound(aCompound);
468 TopTools_ListIteratorOfListOfShape iter(Edges);
469 for (; iter.More(); iter.Next())
471 const TopoDS_Shape& anEdge = iter.Value();
472 BB.Add(aCompound, anEdge);
475 DBRep::Set(a[1], aCompound);
479 //=======================================================================
481 //=======================================================================
482 static Standard_Integer mksweep(Draw_Interpretor& ,
483 Standard_Integer n, const char** a)
485 if ( n != 2) return 1;
486 TopoDS_Shape Spine = DBRep::Get(a[1],TopAbs_WIRE);
487 if ( Spine.IsNull()) return 1;
492 Sweep = new BRepOffsetAPI_MakePipeShell(TopoDS::Wire(Spine));
496 //=======================================================================
498 //=======================================================================
499 static Standard_Integer setsweep(Draw_Interpretor& di,
500 Standard_Integer n, const char** a)
503 //cout << "setsweep options [arg1 [arg2 [...]]] : options are :" << endl;
504 //cout << " -FR : Tangent and Normal are given by Frenet trihedron" <<endl;
505 //cout << " -CF : Tangente is given by Frenet," << endl;
506 //cout << " the Normal is computed to minimize the torsion " << endl;
507 //cout << " -DX Surf : Tangent and Normal are given by Darboux trihedron,"
509 //cout << " Surf have to be a shell or a face" <<endl;
510 //cout << " -CN dx dy dz : BiNormal is given by dx dy dz" << endl;
511 //cout << " -FX Tx Ty TZ [Nx Ny Nz] : Tangent and Normal are fixed" <<endl;
512 //cout << " -G guide 0|1(ACR|Plan) 0|1(contact|no contact) : with guide"<<endl;
513 di << "setsweep options [arg1 [arg2 [...]]] : options are :\n";
514 di << " -FR : Tangent and Normal are given by Frenet trihedron\n";
515 di << " -CF : Tangente is given by Frenet,\n";
516 di << " the Normal is computed to minimize the torsion \n";
517 di << " -DT : discrete trihedron\n";
518 di << " -DX Surf : Tangent and Normal are given by Darboux trihedron,\n";
519 di << " Surf have to be a shell or a face\n";
520 di << " -CN dx dy dz : BiNormal is given by dx dy dz\n";
521 di << " -FX Tx Ty TZ [Nx Ny Nz] : Tangent and Normal are fixed\n";
522 di << " -G guide 0|1(Plan|ACR) 0|1|2(no contact|contact|contact on border) : with guide\n";
527 //cout << "You have forgotten the <<mksweep>> command !"<< endl;
528 di << "You have forgotten the <<mksweep>> command !\n";
531 if (!strcmp(a[1],"-FR")) {
532 Sweep->SetMode(Standard_True);
534 else if (!strcmp(a[1],"-CF")) {
535 Sweep->SetMode(Standard_False);
537 else if (!strcmp(a[1],"-DT")) {
538 Sweep->SetDiscreteMode();
540 else if (!strcmp(a[1],"-DX")) {
542 //cout << "bad arguments !" << endl;
543 di << "bad arguments !\n";
547 Surf = DBRep::Get(a[2],TopAbs_SHAPE);
549 //cout << a[2] <<"is not a shape !" << endl;
550 di << a[2] <<"is not a shape !\n";
553 Sweep->SetMode(Surf);
555 else if (!strcmp(a[1],"-CN")) {
557 //cout << "bad arguments !" << endl;
558 di << "bad arguments !\n";
561 gp_Dir D(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4]));
564 else if (!strcmp(a[1],"-FX")) {
565 if ((n!=5)&&(n!=8)) {
566 //cout << "bad arguments !" << endl;
567 di << "bad arguments !\n";
570 gp_Dir D(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4]));
572 gp_Dir DN(Draw::Atof(a[5]), Draw::Atof(a[6]), Draw::Atof(a[7]));
573 gp_Ax2 Axe(gp_Pnt(0., 0., 0.), D, DN);
577 gp_Ax2 Axe(gp_Pnt(0., 0., 0.), D);
581 else if (!strcmp(a[1],"-G")) // contour guide
585 //cout << "bad arguments !" << endl;
586 di << "bad arguments !\n";
591 TopoDS_Shape Guide = DBRep::Get(a[2],TopAbs_WIRE);
592 Standard_Boolean CurvilinearEquivalence = Draw::Atoi(a[3]) != 0;
593 Standard_Integer KeepContact = Draw::Atoi(a[4]);
594 Sweep->SetMode(TopoDS::Wire(Guide),
595 CurvilinearEquivalence,
596 (BRepFill_TypeOfContact)KeepContact);
601 //cout << "The option "<< a[1] << " is unknown !" << endl;
602 di << "The option "<< a[1] << " is unknown !\n";
609 //=======================================================================
611 //=======================================================================
612 static Standard_Integer addsweep(Draw_Interpretor& di,
613 Standard_Integer n, const char** a)
616 //cout << "addsweep wire/vertex [Vertex] [-T] [-R] [u0 v0 u1 v1 [...[uN vN]]] : options are :" << endl;
617 //cout << " -T : the wire/vertex have to be translated to assume contact"<< endl;
618 //cout << " with the spine" <<endl;
619 //cout << " -R : the wire have to be rotated to assume orthogonality"<<endl;
620 //cout << " with the spine's tangent" << endl;
621 di << "addsweep wire/vertex [Vertex] [-T] [-R] [u0 v0 u1 v1 [...[uN vN]]] : options are :\n";
622 di << " -T : the wire/vertex have to be translated to assume contact\n";
623 di << " with the spine\n";
624 di << " -R : the wire have to be rotated to assume orthogonality\n";
625 di << " with the spine's tangent\n";
630 //cout << "You have forgotten the <<mksweep>> command !"<< endl;
631 di << "You have forgotten the <<mksweep>> command !\n";
635 TopoDS_Shape Section;
636 TopoDS_Vertex Vertex;
637 Handle(Law_Interpol) thelaw;
639 Section = DBRep::Get(a[1], TopAbs_SHAPE);
640 if (Section.IsNull() ||
641 (Section.ShapeType() != TopAbs_WIRE &&
642 Section.ShapeType() != TopAbs_VERTEX))
644 //cout << a[1] <<"is not a wire and is not a vertex!" << endl;
645 di << a[1] <<" is not a wire and is not a vertex!\n";
649 Standard_Boolean HasVertex=Standard_False,
654 Standard_Integer cur = 2;
656 TopoDS_Shape InputVertex(DBRep::Get(a[cur],TopAbs_VERTEX));
657 Vertex = TopoDS::Vertex(InputVertex);
658 // Vertex = TopoDS::Vertex(DBRep::Get(a[cur],TopAbs_VERTEX));
659 if (!Vertex.IsNull()) {
661 HasVertex = Standard_True;
664 // Reading of the translation option
665 if ((n>cur) && !strcmp(a[cur],"-T")) {
670 // Reading of the rotation option
671 if ((n>cur) && !strcmp(a[cur],"-R")) {
678 Standard_Integer nbreal = n-cur;
679 if ( (nbreal < 4) || (nbreal % 2 != 0) ) {
680 //cout << "bad arguments ! :" <<a[cur] << endl;
681 di << "bad arguments ! :" <<a[cur] << "\n";
682 } else { //law of interpolation
683 Standard_Integer ii, L= nbreal/2;
684 TColgp_Array1OfPnt2d ParAndRad(1, L);
685 for (ii=1; ii<=L; ii++, cur+=2) {
686 ParAndRad(ii).SetX(Draw::Atof(a[cur]));
687 ParAndRad(ii).SetY(Draw::Atof(a[cur+1]));
689 thelaw = new (Law_Interpol) ();
690 thelaw->Set(ParAndRad,
691 Abs(ParAndRad(1).Y() - ParAndRad(L).Y()) < Precision::Confusion());
696 if (thelaw.IsNull()) {
697 if (HasVertex) Sweep->Add(Section, Vertex, isT, isR);
698 else Sweep->Add(Section, isT, isR);
701 if (HasVertex) Sweep->SetLaw(Section, thelaw, Vertex, isT, isR);
702 else Sweep->SetLaw(Section, thelaw, isT, isR);
708 //=======================================================================
710 //=======================================================================
711 static Standard_Integer deletesweep(Draw_Interpretor& di,
712 Standard_Integer n, const char** a)
718 TopoDS_Shape InputShape(DBRep::Get(a[1],TopAbs_SHAPE));
719 Section = TopoDS::Wire(InputShape);
720 // Section = TopoDS::Wire(DBRep::Get(a[1],TopAbs_SHAPE));
721 if (Section.IsNull()) {
722 //cout << a[1] <<"is not a wire !" << endl;
723 di << a[1] <<"is not a wire !\n";
727 Sweep->Delete(Section);
732 //=======================================================================
734 //=======================================================================
735 static Standard_Integer buildsweep(Draw_Interpretor& di,
736 Standard_Integer n, const char** a)
739 //cout << "build sweep result [-M/-C/-R] [-S] [tol] : options are" << endl;
740 //cout << " -M : Discontinuities are treated by Modfication of"<< endl;
741 //cout << " the sweeping mode : it is the default" <<endl;
742 //cout << " -C : Discontinuities are treated like Right Corner" << endl;
743 //cout << " Treatement is Extent && Intersect" << endl;
744 //cout << " -R : Discontinuities are treated like Round Corner" << endl;
745 //cout << " Treatement is Intersect and Fill" << endl;
746 //cout << " -S : To build a Solid" << endl;
747 di << "build sweep result [-M/-C/-R] [-S] [tol] : options are\n";
748 di << " -M : Discontinuities are treated by Modfication of\n";
749 di << " the sweeping mode : it is the default\n";
750 di << " -C : Discontinuities are treated like Right Corner\n";
751 di << " Treatement is Extent && Intersect\n";
752 di << " -R : Discontinuities are treated like Round Corner\n";
753 di << " Treatement is Intersect and Fill\n";
754 di << " -S : To build a Solid\n";
758 Standard_Boolean mksolid = Standard_False;
760 //cout << "You have forgotten the <<mksweep>> command !"<< endl;
761 di << "You have forgotten the <<mksweep>> command !\n";
765 if (!Sweep->IsReady()) {
766 //cout << "You have forgotten the <<addsweep>> command !"<< endl;
767 di << "You have forgotten the <<addsweep>> command !\n";
772 Standard_Integer cur=2;
774 BRepBuilderAPI_TransitionMode Transition = BRepBuilderAPI_Transformed;
776 // Reading Transition
777 if (!strcmp(a[cur],"-C")) {
778 Transition = BRepBuilderAPI_RightCorner;
781 else if (!strcmp(a[cur],"-R")) {
782 Transition = BRepBuilderAPI_RoundCorner;
785 Sweep->SetTransitionMode(Transition);
788 if ((n>cur) && (!strcmp(a[cur],"-S")) ) mksolid = Standard_True;
790 // Calcul le resultat
792 if (!Sweep->IsDone()) {
793 //cout << "Buildsweep : Not Done" << endl;
794 di << "Buildsweep : Not Done\n";
795 BRepBuilderAPI_PipeError Stat = Sweep->GetStatus();
796 if (Stat == BRepBuilderAPI_PlaneNotIntersectGuide) {
797 //cout << "Buildsweep : One Plane not intersect the guide" << endl;
798 di << "Buildsweep : One Plane not intersect the guide\n";
800 if (Stat == BRepBuilderAPI_ImpossibleContact) {
801 //cout << "BuildSweep : One section can not be in contact with the guide" << endl;
802 di << "BuildSweep : One section can not be in contact with the guide\n";
809 B = Sweep->MakeSolid();
810 //if (!B) cout << " BuildSweep : It is impossible to make a solid !" << endl;
811 if (!B) di << " BuildSweep : It is impossible to make a solid !\n";
813 result = Sweep->Shape();
814 DBRep::Set(a[1],result);
820 //=======================================================================
821 //function : gensweep
822 //purpose : returns generated shape for subshape of a section of sweep
823 // Sweep must be done previously
824 //=======================================================================
825 static Standard_Integer gensweep(Draw_Interpretor&,
826 Standard_Integer n, const char** a)
830 cout<<"Usage: gensweep res subshape_of_profile, sweep must be done"<<endl;
833 if (!Sweep->IsDone())
835 cout<<"Sweep is not done"<<endl;
838 TopoDS_Shape aShape = DBRep::Get(a[2]);
841 cout<<"Null subshape"<<endl;
844 TopTools_ListOfShape Shells = Sweep->Generated(aShape);
845 TopoDS_Compound aCompound;
847 BB.MakeCompound(aCompound);
848 TopTools_ListIteratorOfListOfShape itsh(Shells);
849 for (; itsh.More(); itsh.Next())
851 const TopoDS_Shape& aShell = itsh.Value();
852 BB.Add(aCompound, aShell);
855 DBRep::Set(a[1], aCompound);
859 //=======================================================================
860 //function : errorsweep
861 //purpose : returns the summary error on resulting surfaces
863 //=======================================================================
864 static Standard_Integer errorsweep(Draw_Interpretor& di,
865 Standard_Integer, const char**)
867 if (!Sweep->IsDone())
869 di << "Sweep is not done\n";
872 Standard_Real ErrorOnSurfaces = Sweep->ErrorOnSurface();
873 di << "Tolerance on surfaces = " << ErrorOnSurfaces << "\n";
877 //=======================================================================
879 //=======================================================================
880 static Standard_Integer simulsweep(Draw_Interpretor& di,
881 Standard_Integer n, const char** a)
883 if ( (n!=3) && (n!=4) ) return 1;
886 //cout << "You have forgotten the <<mksweep>> command !"<< endl;
887 di << "You have forgotten the <<mksweep>> command !\n";
891 if (!Sweep->IsReady()) {
892 //cout << "You have forgotten the <<addsweep>> command !"<< endl;
893 di << "You have forgotten the <<addsweep>> command !\n";
898 TopTools_ListOfShape List;
899 TopTools_ListIteratorOfListOfShape it;
900 Standard_Integer N, ii;
901 N = Draw::Atoi(a[2]);
904 BRepBuilderAPI_TransitionMode Transition = BRepBuilderAPI_Transformed;
905 // Lecture Transition
906 if (!strcmp(a[3],"-C")) {
907 Transition = BRepBuilderAPI_RightCorner;
909 else if (!strcmp(a[3],"-R")) {
910 Transition = BRepBuilderAPI_RoundCorner;
912 Sweep->SetTransitionMode(Transition);
915 // Calculate the result
916 Sweep->Simulate(N, List);
917 for (ii=1, it.Initialize(List); it.More(); it.Next(), ii++) {
918 Sprintf(name,"%s_%d",a[1],ii);
919 DBRep::Set(name, it.Value());
925 //=======================================================================
927 //=======================================================================
928 static Standard_Integer middlepath(Draw_Interpretor& /*di*/,
929 Standard_Integer n, const char** a)
933 TopoDS_Shape aShape = DBRep::Get(a[2]);
934 if (aShape.IsNull()) return 1;
936 TopoDS_Shape StartShape = DBRep::Get(a[3]);
937 if (StartShape.IsNull()) return 1;
939 TopoDS_Shape EndShape = DBRep::Get(a[4]);
940 if (EndShape.IsNull()) return 1;
942 BRepOffsetAPI_MiddlePath Builder(aShape, StartShape, EndShape);
945 TopoDS_Shape Result = Builder.Shape();
946 DBRep::Set(a[1], Result);
951 //=======================================================================
952 //function : SweepCommands
954 //=======================================================================
956 void BRepTest::SweepCommands(Draw_Interpretor& theCommands)
958 static Standard_Boolean done = Standard_False;
960 done = Standard_True;
962 DBRep::BasicCommands(theCommands);
964 const char* g = "Sweep commands";
966 theCommands.Add("prism",
967 "prism result base dx dy dz [Copy | Inf | Seminf]",
970 theCommands.Add("revol",
971 "revol result base px py pz dx dy dz angle [Copy]",
974 theCommands.Add("pipe",
975 "pipe result Wire_spine Profile [Mode [Approx]], no args to get help",
978 theCommands.Add("evolved",
979 "evolved , no args to get help",
982 theCommands.Add("evolvedsolid",
983 "evolved , no args to get help",
986 theCommands.Add("pruled",
987 "pruled result Edge1/Wire1 Edge2/Wire2",
990 theCommands.Add("gener", "gener result wire1 wire2 [..wire..]",
993 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)",
994 __FILE__,thrusections,g);
996 theCommands.Add("genthrus", "genthrus res subshape_of_profile",
997 __FILE__,genthrus,g);
999 theCommands.Add("mksweep", "mksweep wire",
1000 __FILE__,mksweep,g);
1002 theCommands.Add("setsweep", "setsweep no args to get help",
1003 __FILE__,setsweep,g);
1005 theCommands.Add("addsweep",
1006 "addsweep wire [vertex] [-M ] [-C] [auxiilaryshape]:no args to get help",
1007 __FILE__,addsweep,g);
1009 theCommands.Add("deletesweep",
1010 "deletesweep wire, To delete a section",
1011 __FILE__,deletesweep,g);
1013 theCommands.Add("buildsweep", "builsweep [r] [option] [Tol] , no args to get help",
1014 __FILE__,buildsweep,g);
1016 theCommands.Add("gensweep", "gensweep res subshape_of_profile",
1017 __FILE__,gensweep,g);
1019 theCommands.Add("errorsweep", "errorsweep: returns the summary error on resulting surfaces reached by Sweep",
1020 __FILE__,errorsweep,g);
1022 theCommands.Add("simulsweep", "simulsweep r [n] [option]"
1023 __FILE__,simulsweep,g);
1024 theCommands.Add("geompipe", "geompipe r spineedge profileedge radius [byACR [byrotate]]"
1025 __FILE__,geompipe,g);
1027 theCommands.Add("middlepath", "middlepath res shape startshape endshape",
1028 __FILE__,middlepath,g);