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 <BRepTest_Objects.hxx>
22 #include <Draw_Interpretor.hxx>
23 #include <Draw_Appli.hxx>
25 #include <BRepFill.hxx>
26 #include <BRepBuilderAPI_PipeError.hxx>
27 #include <BRepFill_Generator.hxx>
28 #include <BRepPrimAPI_MakePrism.hxx>
29 #include <BRepPrimAPI_MakeRevol.hxx>
30 #include <BRepOffsetAPI_MakePipe.hxx>
31 #include <BRepOffsetAPI_MakeEvolved.hxx>
32 #include <BRepOffsetAPI_ThruSections.hxx>
33 #include <BRepOffsetAPI_MakePipeShell.hxx>
34 #include <BRepOffsetAPI_MiddlePath.hxx>
36 #include <BRepLib_MakeWire.hxx>
38 #include <TopTools_ListIteratorOfListOfShape.hxx>
39 #include <TopExp_Explorer.hxx>
41 #include <Precision.hxx>
42 #include <Law_Interpol.hxx>
45 #include <gp_Pnt2d.hxx>
46 #include <TColgp_Array1OfPnt2d.hxx>
48 static BRepOffsetAPI_MakePipeShell* Sweep= 0;
49 static BRepOffsetAPI_ThruSections* Generator = 0;
52 #include <Geom_Curve.hxx>
53 #include <GeomAdaptor_HCurve.hxx>
54 #include <GeomFill_Pipe.hxx>
55 #include <Geom_Surface.hxx>
56 #include <BRepBuilderAPI_MakeFace.hxx>
57 #include <BRep_Tool.hxx>
60 #include <Geom_Circle.hxx>
64 //=======================================================================
66 //=======================================================================
68 static Standard_Integer prism(Draw_Interpretor& , Standard_Integer n, const char** a)
72 TopoDS_Shape base = DBRep::Get(a[2]);
73 if (base.IsNull()) return 1;
75 gp_Vec V(Draw::Atof(a[3]),Draw::Atof(a[4]),Draw::Atof(a[5]));
77 Standard_Boolean copy = Standard_False;
78 Standard_Boolean inf = Standard_False;
79 Standard_Boolean sinf = Standard_False;
82 copy = (*a[6] == 'c') || (*a[6] == 'C');
83 inf = (*a[6] == 'i') || (*a[6] == 'I');
84 sinf = (*a[6] == 's') || (*a[6] == 'S');
90 res = BRepPrimAPI_MakePrism(base,gp_Dir(V),inf);
92 res = BRepPrimAPI_MakePrism(base,V,copy);
100 //=======================================================================
102 //=======================================================================
103 static Standard_Integer revol(Draw_Interpretor& ,
104 Standard_Integer n, const char** a)
106 if (n < 10) return 1;
108 TopoDS_Shape base = DBRep::Get(a[2]);
109 if (base.IsNull()) return 1;
111 gp_Pnt P(Draw::Atof(a[3]),Draw::Atof(a[4]),Draw::Atof(a[5]));
112 gp_Dir D(Draw::Atof(a[6]),Draw::Atof(a[7]),Draw::Atof(a[8]));
115 Standard_Real angle = Draw::Atof(a[9]) * (M_PI / 180.0);
117 Standard_Boolean copy = n > 10;
120 BRepPrimAPI_MakeRevol Revol(base, A, angle, copy);
122 TopoDS_Shape res = Revol.Shape();
124 DBRep::Set(a[1],res);
127 TopTools_ListOfShape anArgs;
129 BRepTest_Objects::SetHistory(anArgs, Revol);
135 //=======================================================================
137 //=======================================================================
139 static Standard_Integer pipe(Draw_Interpretor& di,
140 Standard_Integer n, const char** a)
144 di << "pipe result Wire_spine Profile [Mode [Approx]]\n";
145 di << "Mode = 0 - CorrectedFrenet,\n";
146 di << " = 1 - Frenet,\n";
147 di << " = 2 - DiscreteTrihedron\n";
148 di << "Approx - force C1-approximation if result is C0\n";
152 if (n > 1 && n < 4) return 1;
154 TopoDS_Shape Spine = DBRep::Get(a[2],TopAbs_WIRE);
155 if ( Spine.IsNull()) return 1;
157 TopoDS_Shape Profile = DBRep::Get(a[3]);
158 if ( Profile.IsNull()) return 1;
160 GeomFill_Trihedron Mode = GeomFill_IsCorrectedFrenet;
163 Standard_Integer iMode = atoi(a[4]);
165 Mode = GeomFill_IsFrenet;
167 Mode = GeomFill_IsDiscreteTrihedron;
170 Standard_Boolean ForceApproxC1 = Standard_False;
172 ForceApproxC1 = Standard_True;
174 TopoDS_Shape S = BRepOffsetAPI_MakePipe(TopoDS::Wire(Spine),
184 //=======================================================================
186 static Standard_Integer geompipe(Draw_Interpretor& ,
187 Standard_Integer n, const char** a)
189 TopoDS_Shape Spine = DBRep::Get(a[2],TopAbs_EDGE);
190 if ( Spine.IsNull()) return 1;
191 if ( n < 5) return 1;
192 TopoDS_Shape Profile = DBRep::Get(a[3],TopAbs_EDGE);
193 if ( Profile.IsNull()) return 1;
194 Standard_Real aSpFirst,aSpLast,aPrFirst,aPrLast;
195 Handle(Geom_Curve) SpineCurve = BRep_Tool::Curve(TopoDS::Edge(Spine),aSpFirst,aSpLast);
196 Handle(Geom_Curve) ProfileCurve = BRep_Tool::Curve(TopoDS::Edge(Profile),aPrFirst,aPrLast);
197 Handle(GeomAdaptor_HCurve) aAdaptCurve = new GeomAdaptor_HCurve(SpineCurve,aSpFirst,aSpLast);
198 Standard_Boolean ByACR = Standard_False;
199 Standard_Boolean rotate = Standard_False;
200 Standard_Real Radius = Draw::Atof(a[4]);
203 ProfileCurve->D1(aSpFirst,ctr,norm);
204 gp_Vec xAxisStart(ctr,SpineCurve->Value(aSpFirst));
205 gp_Ax2 aAx2Start(ctr,norm,xAxisStart);
206 Handle(Geom_Circle) cStart=new Geom_Circle(aAx2Start,Radius);
207 Standard_Integer k =5;
209 ByACR = (Draw::Atoi(a[k++]) ==1);
211 rotate = (Draw::Atoi(a[k++])==1);
212 GeomFill_Pipe aPipe(ProfileCurve,aAdaptCurve,cStart,ByACR,rotate);
213 aPipe.Perform(Standard_True);
216 cout << "GeomFill_Pipe cannot make a surface" << endl;
219 Handle(Geom_Surface) Sur=aPipe.Surface();
222 F = BRepBuilderAPI_MakeFace(Sur, Precision::Confusion());
227 //=======================================================================
230 //=======================================================================
232 Standard_Integer evolved(Draw_Interpretor& di, Standard_Integer n, const char** a)
235 //cout << " 1) evolved result base profil : "<< endl;
236 //cout << " The relative position of the profil on the base" << endl;
237 //cout << " is given in the referencial axis. " << endl;
238 //cout << " 2) evolved result base profil o : "<< endl;
239 //cout << " This position is automatically computed." << endl;
240 di << " 1) evolved result base profil : \n";
241 di << " The relative position of the profil on the base\n";
242 di << " is given in the referencial axis. \n";
243 di << " 2) evolved result base profil o : \n";
244 di << " This position is automatically computed.\n";
248 if ( n < 4 ) return 1;
249 Standard_Boolean IsAFace = Standard_False;
250 Standard_Boolean Solid = (!strcmp(a[0],"evolvedsolid"));
254 TopoDS_Shape Base = DBRep::Get(a[2],TopAbs_WIRE,Standard_False);
255 if ( Base.IsNull()) {
256 Base = DBRep::Get(a[2],TopAbs_FACE,Standard_False);
257 IsAFace = Standard_True;
259 if ( Base.IsNull()) return 1;
261 TopoDS_Shape InpuTShape(DBRep::Get(a[3],TopAbs_WIRE,Standard_False));
262 TopoDS_Wire Prof = TopoDS::Wire(InpuTShape);
263 // TopoDS_Wire Prof =
264 // TopoDS::Wire(DBRep::Get(a[3],TopAbs_WIRE,Standard_False));
265 if ( Prof.IsNull()) return 1;
269 = BRepOffsetAPI_MakeEvolved(TopoDS::Face(Base),Prof,GeomAbs_Arc,n == 4,Solid);
270 DBRep::Set(a[1],Volevo);
274 = BRepOffsetAPI_MakeEvolved(TopoDS::Wire(Base),Prof,GeomAbs_Arc,n == 4,Solid);
275 DBRep::Set(a[1],Volevo);
282 //=======================================================================
285 //=======================================================================
287 static Standard_Integer pruled(Draw_Interpretor& ,
288 Standard_Integer n, const char** a)
290 if ( n != 4) return 1;
292 Standard_Boolean YaWIRE = Standard_False;
293 TopoDS_Shape S1 = DBRep::Get(a[2],TopAbs_EDGE);
295 S1 = DBRep::Get(a[2],TopAbs_WIRE);
296 if (S1.IsNull()) return 1;
297 YaWIRE = Standard_True;
300 TopoDS_Shape S2 = DBRep::Get(a[3],TopAbs_EDGE);
302 S2 = DBRep::Get(a[3],TopAbs_WIRE);
303 if ( S2.IsNull()) return 1;
305 S1 = BRepLib_MakeWire(TopoDS::Edge(S1));
306 YaWIRE = Standard_True;
310 S2 = BRepLib_MakeWire(TopoDS::Edge(S2));
315 Result = BRepFill::Shell(TopoDS::Wire(S1),TopoDS::Wire(S2));
318 Result = BRepFill::Face(TopoDS::Edge(S1),TopoDS::Edge(S2));
321 DBRep::Set(a[1],Result);
326 //=======================================================================
328 //purpose : Create a surface between generating wires
329 //=======================================================================
331 Standard_Integer gener(Draw_Interpretor&, Standard_Integer n, const char** a)
333 if ( n < 4) return 1;
337 BRepFill_Generator aGenerator;
339 for ( Standard_Integer i = 2; i<= n-1 ; i++) {
340 Shape = DBRep::Get(a[i],TopAbs_WIRE);
344 aGenerator.AddWire(TopoDS::Wire(Shape));
347 aGenerator.Perform();
349 TopoDS_Shell Shell = aGenerator.Shell();
351 DBRep::Set(a[1], Shell);
358 //=======================================================================
359 //function : thrusections
361 //=======================================================================
363 Standard_Integer thrusections(Draw_Interpretor&, Standard_Integer n, const char** a)
367 Standard_Boolean check = Standard_True;
368 Standard_Boolean samenumber = Standard_True;
369 Standard_Integer index = 2;
371 if (!strcmp(a[1],"-N")) {
373 check = Standard_False;
379 Standard_Boolean issolid = ( Draw::Atoi(a[index]) == 1 );
380 Standard_Boolean isruled = ( Draw::Atoi(a[index+1]) == 1 );
387 Generator = new BRepOffsetAPI_ThruSections(issolid,isruled);
389 Standard_Integer NbEdges = 0;
390 Standard_Boolean IsFirstWire = Standard_False;
391 for ( Standard_Integer i = index+2; i<= n-1 ; i++) {
392 Standard_Boolean IsWire = Standard_True;
393 Shape = DBRep::Get(a[i], TopAbs_WIRE);
396 Generator->AddWire(TopoDS::Wire(Shape));
398 IsFirstWire = Standard_True;
400 IsFirstWire = Standard_False;
404 Shape = DBRep::Get(a[i], TopAbs_VERTEX);
405 IsWire = Standard_False;
407 Generator->AddVertex(TopoDS::Vertex(Shape));
412 Standard_Integer cpt = 0;
414 for (PE.Init(Shape, TopAbs_EDGE); PE.More(); PE.Next()) {
420 if (IsWire && cpt != NbEdges)
421 samenumber = Standard_False;
425 check = (check || !samenumber);
426 Generator->CheckCompatibility(check);
430 if (Generator->IsDone()) {
431 TopoDS_Shape Shell = Generator->Shape();
432 DBRep::Set(a[index-1], Shell);
433 // Save history of the lofting
434 if (BRepTest_Objects::IsHistoryNeeded())
435 BRepTest_Objects::SetHistory(Generator->Wires(), *Generator);
438 cout << "Algorithm is not done" << endl;
444 //=======================================================================
446 //=======================================================================
447 static Standard_Integer mksweep(Draw_Interpretor& ,
448 Standard_Integer n, const char** a)
450 if ( n != 2) return 1;
451 TopoDS_Shape Spine = DBRep::Get(a[1],TopAbs_WIRE);
452 if ( Spine.IsNull()) return 1;
457 Sweep = new BRepOffsetAPI_MakePipeShell(TopoDS::Wire(Spine));
461 //=======================================================================
463 //=======================================================================
464 static Standard_Integer setsweep(Draw_Interpretor& di,
465 Standard_Integer n, const char** a)
468 //cout << "setsweep options [arg1 [arg2 [...]]] : options are :" << endl;
469 //cout << " -FR : Tangent and Normal are given by Frenet trihedron" <<endl;
470 //cout << " -CF : Tangente is given by Frenet," << endl;
471 //cout << " the Normal is computed to minimize the torsion " << endl;
472 //cout << " -DX Surf : Tangent and Normal are given by Darboux trihedron,"
474 //cout << " Surf have to be a shell or a face" <<endl;
475 //cout << " -CN dx dy dz : BiNormal is given by dx dy dz" << endl;
476 //cout << " -FX Tx Ty TZ [Nx Ny Nz] : Tangent and Normal are fixed" <<endl;
477 //cout << " -G guide 0|1(ACR|Plan) 0|1(contact|no contact) : with guide"<<endl;
478 di << "setsweep options [arg1 [arg2 [...]]] : options are :\n";
479 di << " -FR : Tangent and Normal are given by Frenet trihedron\n";
480 di << " -CF : Tangente is given by Frenet,\n";
481 di << " the Normal is computed to minimize the torsion \n";
482 di << " -DT : discrete trihedron\n";
483 di << " -DX Surf : Tangent and Normal are given by Darboux trihedron,\n";
484 di << " Surf have to be a shell or a face\n";
485 di << " -CN dx dy dz : BiNormal is given by dx dy dz\n";
486 di << " -FX Tx Ty TZ [Nx Ny Nz] : Tangent and Normal are fixed\n";
487 di << " -G guide 0|1(Plan|ACR) 0|1|2(no contact|contact|contact on border) : with guide\n";
492 //cout << "You have forgotten the <<mksweep>> command !"<< endl;
493 di << "You have forgotten the <<mksweep>> command !\n";
496 if (!strcmp(a[1],"-FR")) {
497 Sweep->SetMode(Standard_True);
499 else if (!strcmp(a[1],"-CF")) {
500 Sweep->SetMode(Standard_False);
502 else if (!strcmp(a[1],"-DT")) {
503 Sweep->SetDiscreteMode();
505 else if (!strcmp(a[1],"-DX")) {
507 //cout << "bad arguments !" << endl;
508 di << "bad arguments !\n";
512 Surf = DBRep::Get(a[2],TopAbs_SHAPE);
514 //cout << a[2] <<"is not a shape !" << endl;
515 di << a[2] <<"is not a shape !\n";
518 Sweep->SetMode(Surf);
520 else if (!strcmp(a[1],"-CN")) {
522 //cout << "bad arguments !" << endl;
523 di << "bad arguments !\n";
526 gp_Dir D(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4]));
529 else if (!strcmp(a[1],"-FX")) {
530 if ((n!=5)&&(n!=8)) {
531 //cout << "bad arguments !" << endl;
532 di << "bad arguments !\n";
535 gp_Dir D(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4]));
537 gp_Dir DN(Draw::Atof(a[5]), Draw::Atof(a[6]), Draw::Atof(a[7]));
538 gp_Ax2 Axe(gp_Pnt(0., 0., 0.), D, DN);
542 gp_Ax2 Axe(gp_Pnt(0., 0., 0.), D);
546 else if (!strcmp(a[1],"-G")) // contour guide
550 //cout << "bad arguments !" << endl;
551 di << "bad arguments !\n";
556 TopoDS_Shape Guide = DBRep::Get(a[2],TopAbs_WIRE);
557 Standard_Boolean CurvilinearEquivalence = Draw::Atoi(a[3]) != 0;
558 Standard_Integer KeepContact = Draw::Atoi(a[4]);
559 Sweep->SetMode(TopoDS::Wire(Guide),
560 CurvilinearEquivalence,
561 (BRepFill_TypeOfContact)KeepContact);
566 //cout << "The option "<< a[1] << " is unknown !" << endl;
567 di << "The option "<< a[1] << " is unknown !\n";
574 //=======================================================================
576 //=======================================================================
577 static Standard_Integer addsweep(Draw_Interpretor& di,
578 Standard_Integer n, const char** a)
581 //cout << "addsweep wire/vertex [Vertex] [-T] [-R] [u0 v0 u1 v1 [...[uN vN]]] : options are :" << endl;
582 //cout << " -T : the wire/vertex have to be translated to assume contact"<< endl;
583 //cout << " with the spine" <<endl;
584 //cout << " -R : the wire have to be rotated to assume orthogonality"<<endl;
585 //cout << " with the spine's tangent" << endl;
586 di << "addsweep wire/vertex [Vertex] [-T] [-R] [u0 v0 u1 v1 [...[uN vN]]] : options are :\n";
587 di << " -T : the wire/vertex have to be translated to assume contact\n";
588 di << " with the spine\n";
589 di << " -R : the wire have to be rotated to assume orthogonality\n";
590 di << " with the spine's tangent\n";
595 //cout << "You have forgotten the <<mksweep>> command !"<< endl;
596 di << "You have forgotten the <<mksweep>> command !\n";
600 TopoDS_Shape Section;
601 TopoDS_Vertex Vertex;
602 Handle(Law_Interpol) thelaw;
604 Section = DBRep::Get(a[1], TopAbs_SHAPE);
605 if (Section.IsNull() ||
606 (Section.ShapeType() != TopAbs_WIRE &&
607 Section.ShapeType() != TopAbs_VERTEX))
609 //cout << a[1] <<"is not a wire and is not a vertex!" << endl;
610 di << a[1] <<" is not a wire and is not a vertex!\n";
614 Standard_Boolean HasVertex=Standard_False,
619 Standard_Integer cur = 2;
621 TopoDS_Shape InputVertex(DBRep::Get(a[cur],TopAbs_VERTEX));
622 Vertex = TopoDS::Vertex(InputVertex);
623 // Vertex = TopoDS::Vertex(DBRep::Get(a[cur],TopAbs_VERTEX));
624 if (!Vertex.IsNull()) {
626 HasVertex = Standard_True;
629 // Reading of the translation option
630 if ((n>cur) && !strcmp(a[cur],"-T")) {
635 // Reading of the rotation option
636 if ((n>cur) && !strcmp(a[cur],"-R")) {
643 Standard_Integer nbreal = n-cur;
644 if ( (nbreal < 4) || (nbreal % 2 != 0) ) {
645 //cout << "bad arguments ! :" <<a[cur] << endl;
646 di << "bad arguments ! :" <<a[cur] << "\n";
647 } else { //law of interpolation
648 Standard_Integer ii, L= nbreal/2;
649 TColgp_Array1OfPnt2d ParAndRad(1, L);
650 for (ii=1; ii<=L; ii++, cur+=2) {
651 ParAndRad(ii).SetX(Draw::Atof(a[cur]));
652 ParAndRad(ii).SetY(Draw::Atof(a[cur+1]));
654 thelaw = new (Law_Interpol) ();
655 thelaw->Set(ParAndRad,
656 Abs(ParAndRad(1).Y() - ParAndRad(L).Y()) < Precision::Confusion());
661 if (thelaw.IsNull()) {
662 if (HasVertex) Sweep->Add(Section, Vertex, isT, isR);
663 else Sweep->Add(Section, isT, isR);
666 if (HasVertex) Sweep->SetLaw(Section, thelaw, Vertex, isT, isR);
667 else Sweep->SetLaw(Section, thelaw, isT, isR);
673 //=======================================================================
675 //=======================================================================
676 static Standard_Integer deletesweep(Draw_Interpretor& di,
677 Standard_Integer n, const char** a)
683 TopoDS_Shape InputShape(DBRep::Get(a[1],TopAbs_SHAPE));
684 Section = TopoDS::Wire(InputShape);
685 // Section = TopoDS::Wire(DBRep::Get(a[1],TopAbs_SHAPE));
686 if (Section.IsNull()) {
687 //cout << a[1] <<"is not a wire !" << endl;
688 di << a[1] <<"is not a wire !\n";
692 Sweep->Delete(Section);
697 //=======================================================================
699 //=======================================================================
700 static Standard_Integer buildsweep(Draw_Interpretor& di,
701 Standard_Integer n, const char** a)
704 //cout << "build sweep result [-M/-C/-R] [-S] [tol] : options are" << endl;
705 //cout << " -M : Discontinuities are treated by Modfication of"<< endl;
706 //cout << " the sweeping mode : it is the default" <<endl;
707 //cout << " -C : Discontinuities are treated like Right Corner" << endl;
708 //cout << " Treatement is Extent && Intersect" << endl;
709 //cout << " -R : Discontinuities are treated like Round Corner" << endl;
710 //cout << " Treatement is Intersect and Fill" << endl;
711 //cout << " -S : To build a Solid" << endl;
712 di << "build sweep result [-M/-C/-R] [-S] [tol] : options are\n";
713 di << " -M : Discontinuities are treated by Modfication of\n";
714 di << " the sweeping mode : it is the default\n";
715 di << " -C : Discontinuities are treated like Right Corner\n";
716 di << " Treatement is Extent && Intersect\n";
717 di << " -R : Discontinuities are treated like Round Corner\n";
718 di << " Treatement is Intersect and Fill\n";
719 di << " -S : To build a Solid\n";
723 Standard_Boolean mksolid = Standard_False;
725 //cout << "You have forgotten the <<mksweep>> command !"<< endl;
726 di << "You have forgotten the <<mksweep>> command !\n";
730 if (!Sweep->IsReady()) {
731 //cout << "You have forgotten the <<addsweep>> command !"<< endl;
732 di << "You have forgotten the <<addsweep>> command !\n";
737 Standard_Integer cur=2;
739 BRepBuilderAPI_TransitionMode Transition = BRepBuilderAPI_Transformed;
741 // Reading Transition
742 if (!strcmp(a[cur],"-C")) {
743 Transition = BRepBuilderAPI_RightCorner;
746 else if (!strcmp(a[cur],"-R")) {
747 Transition = BRepBuilderAPI_RoundCorner;
750 Sweep->SetTransitionMode(Transition);
753 if ((n>cur) && (!strcmp(a[cur],"-S")) ) mksolid = Standard_True;
755 // Calcul le resultat
757 if (!Sweep->IsDone()) {
758 //cout << "Buildsweep : Not Done" << endl;
759 di << "Buildsweep : Not Done\n";
760 BRepBuilderAPI_PipeError Stat = Sweep->GetStatus();
761 if (Stat == BRepBuilderAPI_PlaneNotIntersectGuide) {
762 //cout << "Buildsweep : One Plane not intersect the guide" << endl;
763 di << "Buildsweep : One Plane not intersect the guide\n";
765 if (Stat == BRepBuilderAPI_ImpossibleContact) {
766 //cout << "BuildSweep : One section can not be in contact with the guide" << endl;
767 di << "BuildSweep : One section can not be in contact with the guide\n";
773 B = Sweep->MakeSolid();
774 //if (!B) cout << " BuildSweep : It is impossible to make a solid !" << endl;
775 if (!B) di << " BuildSweep : It is impossible to make a solid !\n";
777 result = Sweep->Shape();
778 DBRep::Set(a[1],result);
779 // Save history of sweep
780 if (BRepTest_Objects::IsHistoryNeeded())
782 TopTools_ListOfShape aProfiles;
783 Sweep->Profiles(aProfiles);
784 BRepTest_Objects::SetHistory(aProfiles, *Sweep);
791 //=======================================================================
792 //function : errorsweep
793 //purpose : returns the summary error on resulting surfaces
795 //=======================================================================
796 static Standard_Integer errorsweep(Draw_Interpretor& di,
797 Standard_Integer, const char**)
799 if (!Sweep->IsDone())
801 di << "Sweep is not done\n";
804 Standard_Real ErrorOnSurfaces = Sweep->ErrorOnSurface();
805 di << "Tolerance on surfaces = " << ErrorOnSurfaces << "\n";
809 //=======================================================================
811 //=======================================================================
812 static Standard_Integer simulsweep(Draw_Interpretor& di,
813 Standard_Integer n, const char** a)
815 if ( (n!=3) && (n!=4) ) return 1;
818 //cout << "You have forgotten the <<mksweep>> command !"<< endl;
819 di << "You have forgotten the <<mksweep>> command !\n";
823 if (!Sweep->IsReady()) {
824 //cout << "You have forgotten the <<addsweep>> command !"<< endl;
825 di << "You have forgotten the <<addsweep>> command !\n";
830 TopTools_ListOfShape List;
831 TopTools_ListIteratorOfListOfShape it;
832 Standard_Integer N, ii;
833 N = Draw::Atoi(a[2]);
836 BRepBuilderAPI_TransitionMode Transition = BRepBuilderAPI_Transformed;
837 // Lecture Transition
838 if (!strcmp(a[3],"-C")) {
839 Transition = BRepBuilderAPI_RightCorner;
841 else if (!strcmp(a[3],"-R")) {
842 Transition = BRepBuilderAPI_RoundCorner;
844 Sweep->SetTransitionMode(Transition);
847 // Calculate the result
848 Sweep->Simulate(N, List);
849 for (ii=1, it.Initialize(List); it.More(); it.Next(), ii++) {
850 Sprintf(name,"%s_%d",a[1],ii);
851 DBRep::Set(name, it.Value());
857 //=======================================================================
859 //=======================================================================
860 static Standard_Integer middlepath(Draw_Interpretor& /*di*/,
861 Standard_Integer n, const char** a)
865 TopoDS_Shape aShape = DBRep::Get(a[2]);
866 if (aShape.IsNull()) return 1;
868 TopoDS_Shape StartShape = DBRep::Get(a[3]);
869 if (StartShape.IsNull()) return 1;
871 TopoDS_Shape EndShape = DBRep::Get(a[4]);
872 if (EndShape.IsNull()) return 1;
874 BRepOffsetAPI_MiddlePath Builder(aShape, StartShape, EndShape);
877 TopoDS_Shape Result = Builder.Shape();
878 DBRep::Set(a[1], Result);
883 //=======================================================================
884 //function : SweepCommands
886 //=======================================================================
888 void BRepTest::SweepCommands(Draw_Interpretor& theCommands)
890 static Standard_Boolean done = Standard_False;
892 done = Standard_True;
894 DBRep::BasicCommands(theCommands);
896 const char* g = "Sweep commands";
898 theCommands.Add("prism",
899 "prism result base dx dy dz [Copy | Inf | Seminf]",
902 theCommands.Add("revol",
903 "revol result base px py pz dx dy dz angle [Copy]",
906 theCommands.Add("pipe",
907 "pipe result Wire_spine Profile [Mode [Approx]], no args to get help",
910 theCommands.Add("evolved",
911 "evolved , no args to get help",
914 theCommands.Add("evolvedsolid",
915 "evolved , no args to get help",
918 theCommands.Add("pruled",
919 "pruled result Edge1/Wire1 Edge2/Wire2",
922 theCommands.Add("gener", "gener result wire1 wire2 [..wire..]",
925 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)",
926 __FILE__,thrusections,g);
928 theCommands.Add("mksweep", "mksweep wire",
931 theCommands.Add("setsweep", "setsweep no args to get help",
932 __FILE__,setsweep,g);
934 theCommands.Add("addsweep",
935 "addsweep wire [vertex] [-M ] [-C] [auxiilaryshape]:no args to get help",
936 __FILE__,addsweep,g);
938 theCommands.Add("deletesweep",
939 "deletesweep wire, To delete a section",
940 __FILE__,deletesweep,g);
942 theCommands.Add("buildsweep", "builsweep [r] [option] [Tol] , no args to get help",
943 __FILE__,buildsweep,g);
945 theCommands.Add("errorsweep", "errorsweep: returns the summary error on resulting surfaces reached by Sweep",
946 __FILE__,errorsweep,g);
948 theCommands.Add("simulsweep", "simulsweep r [n] [option]"
949 __FILE__,simulsweep,g);
950 theCommands.Add("geompipe", "geompipe r spineedge profileedge radius [byACR [byrotate]]"
951 __FILE__,geompipe,g);
953 theCommands.Add("middlepath", "middlepath res shape startshape endshape",
954 __FILE__,middlepath,g);