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');
89 BRepPrimAPI_MakePrism* Prism;
92 Prism = new BRepPrimAPI_MakePrism(base, gp_Dir(V), inf);
96 Prism = new BRepPrimAPI_MakePrism(base, V, copy);
101 DBRep::Set(a[1], res);
104 TopTools_ListOfShape anArgs;
106 BRepTest_Objects::SetHistory(anArgs, *Prism);
114 //=======================================================================
116 //=======================================================================
117 static Standard_Integer revol(Draw_Interpretor& di,
118 Standard_Integer n, const char** a)
120 if (n < 10) return 1;
122 TopoDS_Shape base = DBRep::Get(a[2]);
123 if (base.IsNull()) return 1;
125 gp_Pnt P(Draw::Atof(a[3]), Draw::Atof(a[4]), Draw::Atof(a[5]));
126 gp_Dir D(Draw::Atof(a[6]), Draw::Atof(a[7]), Draw::Atof(a[8]));
129 Standard_Real angle = Draw::Atof(a[9]) * (M_PI / 180.0);
131 Standard_Boolean copy = n > 10;
134 BRepPrimAPI_MakeRevol Revol(base, A, angle, copy);
138 TopoDS_Shape res = Revol.Shape();
140 DBRep::Set(a[1], res);
143 TopTools_ListOfShape anArgs;
145 BRepTest_Objects::SetHistory(anArgs, Revol);
149 di << "Revol not done \n";
156 //=======================================================================
158 //=======================================================================
160 static Standard_Integer pipe(Draw_Interpretor& di,
161 Standard_Integer n, const char** a)
165 di << "pipe result Wire_spine Profile [Mode [Approx]]\n";
166 di << "Mode = 0 - CorrectedFrenet,\n";
167 di << " = 1 - Frenet,\n";
168 di << " = 2 - DiscreteTrihedron\n";
169 di << "Approx - force C1-approximation if result is C0\n";
173 if (n > 1 && n < 4) return 1;
175 TopoDS_Shape Spine = DBRep::Get(a[2], TopAbs_WIRE);
176 if (Spine.IsNull()) return 1;
178 TopoDS_Shape Profile = DBRep::Get(a[3]);
179 if (Profile.IsNull()) return 1;
181 GeomFill_Trihedron Mode = GeomFill_IsCorrectedFrenet;
184 Standard_Integer iMode = atoi(a[4]);
186 Mode = GeomFill_IsFrenet;
188 Mode = GeomFill_IsDiscreteTrihedron;
191 Standard_Boolean ForceApproxC1 = Standard_False;
193 ForceApproxC1 = Standard_True;
195 BRepOffsetAPI_MakePipe PipeBuilder(TopoDS::Wire(Spine),
199 TopoDS_Shape S = PipeBuilder.Shape();
203 // Save history of pipe
204 if (BRepTest_Objects::IsHistoryNeeded())
206 TopTools_ListOfShape aList;
207 aList.Append(Profile);
209 BRepTest_Objects::SetHistory(aList, PipeBuilder);
215 //=======================================================================
217 static Standard_Integer geompipe(Draw_Interpretor&,
218 Standard_Integer n, const char** a)
220 TopoDS_Shape Spine = DBRep::Get(a[2], TopAbs_EDGE);
221 if (Spine.IsNull()) return 1;
223 TopoDS_Shape Profile = DBRep::Get(a[3], TopAbs_EDGE);
224 if (Profile.IsNull()) return 1;
225 Standard_Real aSpFirst, aSpLast, aPrFirst, aPrLast;
226 Handle(Geom_Curve) SpineCurve = BRep_Tool::Curve(TopoDS::Edge(Spine), aSpFirst, aSpLast);
227 Handle(Geom_Curve) ProfileCurve = BRep_Tool::Curve(TopoDS::Edge(Profile), aPrFirst, aPrLast);
228 Handle(GeomAdaptor_HCurve) aAdaptCurve = new GeomAdaptor_HCurve(SpineCurve, aSpFirst, aSpLast);
229 Standard_Boolean ByACR = Standard_False;
230 Standard_Boolean rotate = Standard_False;
231 Standard_Real Radius = Draw::Atof(a[4]);
234 ProfileCurve->D1(aSpFirst, ctr, norm);
235 gp_Vec xAxisStart(ctr, SpineCurve->Value(aSpFirst));
236 gp_Ax2 aAx2Start(ctr, norm, xAxisStart);
237 Handle(Geom_Circle) cStart = new Geom_Circle(aAx2Start, Radius);
238 Standard_Integer k = 5;
240 ByACR = (Draw::Atoi(a[k++]) == 1);
242 rotate = (Draw::Atoi(a[k++]) == 1);
243 GeomFill_Pipe aPipe(ProfileCurve, aAdaptCurve, cStart, ByACR, rotate);
244 aPipe.Perform(Standard_True);
247 std::cout << "GeomFill_Pipe cannot make a surface" << std::endl;
251 Standard_Real Accuracy = aPipe.ErrorOnSurf();
252 std::cout << "Accuracy of approximation = " << Accuracy << std::endl;
254 Handle(Geom_Surface) Sur = aPipe.Surface();
257 F = BRepBuilderAPI_MakeFace(Sur, Precision::Confusion());
262 //=======================================================================
265 //=======================================================================
267 Standard_Integer evolved(Draw_Interpretor& di, Standard_Integer n, const char** a)
270 di << " evolved result -s spine -p profile [-solid] [-v] [-a] [-t toler] [-parallel] : \n";
271 di << " Make evolved profile on spine.\n";
272 di << " -solid means make closed solid.\n";
273 di << " -v means use alternative algorithm (volume mode).\n";
274 di << " -a means referencial CS is automatically computed, otherwise global CS is used. \n";
275 di << " -t sets the tolerance.\n";
276 di << " -parallel turns on parallel execution.\n";
281 Standard_Boolean Solid = Standard_False;
282 Standard_Boolean isVolume = Standard_False;
283 Standard_Boolean hasToComputeAxes = Standard_False;
284 Standard_Real aTolerance = 0.0;
287 Standard_Boolean isParallel = Standard_True;
289 for (Standard_Integer i = 2; i < n; i++)
293 di << "Error: wrong option!\n";
297 if (!Solid && !strcmp(a[i], "-solid"))
299 Solid = Standard_True;
303 if (!strcmp(a[i], "-stm"))
305 isParallel = Standard_False;
313 Base = DBRep::Get(a[++i], TopAbs_WIRE, Standard_False);
316 Base = DBRep::Get(a[i], TopAbs_FACE, Standard_False);
323 Prof = TopoDS::Wire(DBRep::Get(a[++i], TopAbs_WIRE, Standard_False));
329 isVolume = Standard_True;
335 hasToComputeAxes = Standard_True;
341 aTolerance = Draw::Atof(a[++i]);
346 di << "Error: Unknown option!\n";
351 if (Base.IsNull() || Prof.IsNull())
353 di << "spine (face or wire) and profile (wire) are expected\n";
357 TopoDS_Shape Volevo = BRepOffsetAPI_MakeEvolved(Base, Prof, GeomAbs_Arc, !hasToComputeAxes,
358 Solid, Standard_False,
359 aTolerance, isVolume, isParallel);
361 DBRep::Set(a[1],Volevo);
367 //=======================================================================
370 //=======================================================================
372 static Standard_Integer pruled(Draw_Interpretor&,
373 Standard_Integer n, const char** a)
375 if (n != 4) return 1;
377 Standard_Boolean YaWIRE = Standard_False;
378 TopoDS_Shape S1 = DBRep::Get(a[2], TopAbs_EDGE);
380 S1 = DBRep::Get(a[2], TopAbs_WIRE);
381 if (S1.IsNull()) return 1;
382 YaWIRE = Standard_True;
385 TopoDS_Shape S2 = DBRep::Get(a[3], TopAbs_EDGE);
387 S2 = DBRep::Get(a[3], TopAbs_WIRE);
388 if (S2.IsNull()) return 1;
390 S1 = BRepLib_MakeWire(TopoDS::Edge(S1));
391 YaWIRE = Standard_True;
395 S2 = BRepLib_MakeWire(TopoDS::Edge(S2));
400 Result = BRepFill::Shell(TopoDS::Wire(S1), TopoDS::Wire(S2));
403 Result = BRepFill::Face(TopoDS::Edge(S1), TopoDS::Edge(S2));
406 DBRep::Set(a[1], Result);
411 //=======================================================================
413 //purpose : Create a surface between generating wires
414 //=======================================================================
416 Standard_Integer gener(Draw_Interpretor&, Standard_Integer n, const char** a)
422 BRepFill_Generator aGenerator;
424 for (Standard_Integer i = 2; i <= n - 1; i++) {
425 Shape = DBRep::Get(a[i], TopAbs_WIRE);
429 aGenerator.AddWire(TopoDS::Wire(Shape));
432 aGenerator.Perform();
434 TopoDS_Shell Shell = aGenerator.Shell();
436 DBRep::Set(a[1], Shell);
443 //=======================================================================
444 //function : thrusections
446 //=======================================================================
448 Standard_Integer thrusections(Draw_Interpretor&, Standard_Integer n, const char** a)
452 Standard_Boolean check = Standard_True;
453 Standard_Boolean samenumber = Standard_True;
454 Standard_Integer index = 2;
456 if (!strcmp(a[1], "-N")) {
458 check = Standard_False;
464 Standard_Boolean issolid = (Draw::Atoi(a[index]) == 1);
465 Standard_Boolean isruled = (Draw::Atoi(a[index + 1]) == 1);
472 Generator = new BRepOffsetAPI_ThruSections(issolid, isruled);
474 Standard_Integer NbEdges = 0;
475 Standard_Boolean IsFirstWire = Standard_False;
476 for (Standard_Integer i = index + 2; i <= n - 1; i++) {
477 Standard_Boolean IsWire = Standard_True;
478 Shape = DBRep::Get(a[i], TopAbs_WIRE);
481 Generator->AddWire(TopoDS::Wire(Shape));
483 IsFirstWire = Standard_True;
485 IsFirstWire = Standard_False;
489 Shape = DBRep::Get(a[i], TopAbs_VERTEX);
490 IsWire = Standard_False;
492 Generator->AddVertex(TopoDS::Vertex(Shape));
497 Standard_Integer cpt = 0;
499 for (PE.Init(Shape, TopAbs_EDGE); PE.More(); PE.Next()) {
505 if (IsWire && cpt != NbEdges)
506 samenumber = Standard_False;
510 check = (check || !samenumber);
511 Generator->CheckCompatibility(check);
515 if (Generator->IsDone()) {
516 TopoDS_Shape Shell = Generator->Shape();
517 DBRep::Set(a[index - 1], Shell);
518 // Save history of the lofting
519 if (BRepTest_Objects::IsHistoryNeeded())
520 BRepTest_Objects::SetHistory(Generator->Wires(), *Generator);
523 std::cout << "Algorithm is not done" << std::endl;
529 //=======================================================================
531 //=======================================================================
532 static Standard_Integer mksweep(Draw_Interpretor&,
533 Standard_Integer n, const char** a)
535 if (n != 2) return 1;
536 TopoDS_Shape Spine = DBRep::Get(a[1], TopAbs_WIRE);
537 if (Spine.IsNull()) return 1;
542 Sweep = new BRepOffsetAPI_MakePipeShell(TopoDS::Wire(Spine));
546 //=======================================================================
548 //=======================================================================
549 static Standard_Integer setsweep(Draw_Interpretor& di,
550 Standard_Integer n, const char** a)
553 //std::cout << "setsweep options [arg1 [arg2 [...]]] : options are :" << std::endl;
554 //std::cout << " -FR : Tangent and Normal are given by Frenet trihedron" <<std::endl;
555 //std::cout << " -CF : Tangente is given by Frenet," << std::endl;
556 //std::cout << " the Normal is computed to minimize the torsion " << std::endl;
557 //std::cout << " -DX Surf : Tangent and Normal are given by Darboux trihedron,"
559 //std::cout << " Surf have to be a shell or a face" <<std::endl;
560 //std::cout << " -CN dx dy dz : BiNormal is given by dx dy dz" << std::endl;
561 //std::cout << " -FX Tx Ty TZ [Nx Ny Nz] : Tangent and Normal are fixed" <<std::endl;
562 //std::cout << " -G guide 0|1(ACR|Plan) 0|1(contact|no contact) : with guide"<<std::endl;
563 di << "setsweep options [arg1 [arg2 [...]]] : options are :\n";
564 di << " -FR : Tangent and Normal are given by Frenet trihedron\n";
565 di << " -CF : Tangente is given by Frenet,\n";
566 di << " the Normal is computed to minimize the torsion \n";
567 di << " -DT : discrete trihedron\n";
568 di << " -DX Surf : Tangent and Normal are given by Darboux trihedron,\n";
569 di << " Surf have to be a shell or a face\n";
570 di << " -CN dx dy dz : BiNormal is given by dx dy dz\n";
571 di << " -FX Tx Ty TZ [Nx Ny Nz] : Tangent and Normal are fixed\n";
572 di << " -G guide 0|1(Plan|ACR) 0|1|2(no contact|contact|contact on border) : with guide\n";
577 //std::cout << "You have forgotten the <<mksweep>> command !"<< std::endl;
578 di << "You have forgotten the <<mksweep>> command !\n";
581 if (!strcmp(a[1], "-FR")) {
582 Sweep->SetMode(Standard_True);
584 else if (!strcmp(a[1], "-CF")) {
585 Sweep->SetMode(Standard_False);
587 else if (!strcmp(a[1], "-DT")) {
588 Sweep->SetDiscreteMode();
590 else if (!strcmp(a[1], "-DX")) {
592 //std::cout << "bad arguments !" << std::endl;
593 di << "bad arguments !\n";
597 Surf = DBRep::Get(a[2], TopAbs_SHAPE);
599 //std::cout << a[2] <<"is not a shape !" << std::endl;
600 di << a[2] << "is not a shape !\n";
603 Sweep->SetMode(Surf);
605 else if (!strcmp(a[1], "-CN")) {
607 //std::cout << "bad arguments !" << std::endl;
608 di << "bad arguments !\n";
611 gp_Dir D(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4]));
614 else if (!strcmp(a[1], "-FX")) {
615 if ((n != 5) && (n != 8)) {
616 //std::cout << "bad arguments !" << std::endl;
617 di << "bad arguments !\n";
620 gp_Dir D(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4]));
622 gp_Dir DN(Draw::Atof(a[5]), Draw::Atof(a[6]), Draw::Atof(a[7]));
623 gp_Ax2 Axe(gp_Pnt(0., 0., 0.), D, DN);
627 gp_Ax2 Axe(gp_Pnt(0., 0., 0.), D);
631 else if (!strcmp(a[1], "-G")) // contour guide
635 //std::cout << "bad arguments !" << std::endl;
636 di << "bad arguments !\n";
641 TopoDS_Shape Guide = DBRep::Get(a[2], TopAbs_WIRE);
642 Standard_Boolean CurvilinearEquivalence = Draw::Atoi(a[3]) != 0;
643 Standard_Integer KeepContact = Draw::Atoi(a[4]);
644 Sweep->SetMode(TopoDS::Wire(Guide),
645 CurvilinearEquivalence,
646 (BRepFill_TypeOfContact)KeepContact);
651 //std::cout << "The option "<< a[1] << " is unknown !" << std::endl;
652 di << "The option " << a[1] << " is unknown !\n";
659 //=======================================================================
661 //=======================================================================
662 static Standard_Integer addsweep(Draw_Interpretor& di,
663 Standard_Integer n, const char** a)
666 //std::cout << "addsweep wire/vertex [Vertex] [-T] [-R] [u0 v0 u1 v1 [...[uN vN]]] : options are :" << std::endl;
667 //std::cout << " -T : the wire/vertex have to be translated to assume contact"<< std::endl;
668 //std::cout << " with the spine" <<std::endl;
669 //std::cout << " -R : the wire have to be rotated to assume orthogonality"<<std::endl;
670 //std::cout << " with the spine's tangent" << std::endl;
671 di << "addsweep wire/vertex [Vertex] [-T] [-R] [u0 v0 u1 v1 [...[uN vN]]] : options are :\n";
672 di << " -T : the wire/vertex have to be translated to assume contact\n";
673 di << " with the spine\n";
674 di << " -R : the wire have to be rotated to assume orthogonality\n";
675 di << " with the spine's tangent\n";
680 //std::cout << "You have forgotten the <<mksweep>> command !"<< std::endl;
681 di << "You have forgotten the <<mksweep>> command !\n";
685 TopoDS_Shape Section;
686 TopoDS_Vertex Vertex;
687 Handle(Law_Interpol) thelaw;
689 Section = DBRep::Get(a[1], TopAbs_SHAPE);
690 if (Section.IsNull() ||
691 (Section.ShapeType() != TopAbs_WIRE &&
692 Section.ShapeType() != TopAbs_VERTEX))
694 //std::cout << a[1] <<"is not a wire and is not a vertex!" << std::endl;
695 di << a[1] << " is not a wire and is not a vertex!\n";
699 Standard_Boolean HasVertex = Standard_False,
700 isT = Standard_False,
701 isR = Standard_False;
704 Standard_Integer cur = 2;
706 TopoDS_Shape InputVertex(DBRep::Get(a[cur], TopAbs_VERTEX));
707 Vertex = TopoDS::Vertex(InputVertex);
708 // Vertex = TopoDS::Vertex(DBRep::Get(a[cur],TopAbs_VERTEX));
709 if (!Vertex.IsNull()) {
711 HasVertex = Standard_True;
714 // Reading of the translation option
715 if ((n > cur) && !strcmp(a[cur], "-T")) {
720 // Reading of the rotation option
721 if ((n > cur) && !strcmp(a[cur], "-R")) {
728 Standard_Integer nbreal = n - cur;
729 if ((nbreal < 4) || (nbreal % 2 != 0)) {
730 //std::cout << "bad arguments ! :" <<a[cur] << std::endl;
731 di << "bad arguments ! :" << a[cur] << "\n";
733 else { //law of interpolation
734 Standard_Integer ii, L = nbreal / 2;
735 TColgp_Array1OfPnt2d ParAndRad(1, L);
736 for (ii = 1; ii <= L; ii++, cur += 2) {
737 ParAndRad(ii).SetX(Draw::Atof(a[cur]));
738 ParAndRad(ii).SetY(Draw::Atof(a[cur + 1]));
740 thelaw = new (Law_Interpol)();
741 thelaw->Set(ParAndRad,
742 Abs(ParAndRad(1).Y() - ParAndRad(L).Y()) < Precision::Confusion());
747 if (thelaw.IsNull()) {
748 if (HasVertex) Sweep->Add(Section, Vertex, isT, isR);
749 else Sweep->Add(Section, isT, isR);
752 if (HasVertex) Sweep->SetLaw(Section, thelaw, Vertex, isT, isR);
753 else Sweep->SetLaw(Section, thelaw, isT, isR);
759 //=======================================================================
761 //=======================================================================
762 static Standard_Integer deletesweep(Draw_Interpretor& di,
763 Standard_Integer n, const char** a)
769 TopoDS_Shape InputShape(DBRep::Get(a[1], TopAbs_SHAPE));
770 Section = TopoDS::Wire(InputShape);
771 // Section = TopoDS::Wire(DBRep::Get(a[1],TopAbs_SHAPE));
772 if (Section.IsNull()) {
773 //std::cout << a[1] <<"is not a wire !" << std::endl;
774 di << a[1] << "is not a wire !\n";
778 Sweep->Delete(Section);
783 //=======================================================================
785 //=======================================================================
786 static Standard_Integer buildsweep(Draw_Interpretor& di,
787 Standard_Integer n, const char** a)
790 //std::cout << "build sweep result [-M/-C/-R] [-S] [tol] : options are" << std::endl;
791 //std::cout << " -M : Discontinuities are treated by Modfication of"<< std::endl;
792 //std::cout << " the sweeping mode : it is the default" <<std::endl;
793 //std::cout << " -C : Discontinuities are treated like Right Corner" << std::endl;
794 //std::cout << " Treatement is Extent && Intersect" << std::endl;
795 //std::cout << " -R : Discontinuities are treated like Round Corner" << std::endl;
796 //std::cout << " Treatement is Intersect and Fill" << std::endl;
797 //std::cout << " -S : To build a Solid" << std::endl;
798 di << "build sweep result [-M/-C/-R] [-S] [tol] : options are\n";
799 di << " -M : Discontinuities are treated by Modfication of\n";
800 di << " the sweeping mode : it is the default\n";
801 di << " -C : Discontinuities are treated like Right Corner\n";
802 di << " Treatement is Extent && Intersect\n";
803 di << " -R : Discontinuities are treated like Round Corner\n";
804 di << " Treatement is Intersect and Fill\n";
805 di << " -S : To build a Solid\n";
809 Standard_Boolean mksolid = Standard_False;
811 //std::cout << "You have forgotten the <<mksweep>> command !"<< std::endl;
812 di << "You have forgotten the <<mksweep>> command !\n";
816 if (!Sweep->IsReady()) {
817 //std::cout << "You have forgotten the <<addsweep>> command !"<< std::endl;
818 di << "You have forgotten the <<addsweep>> command !\n";
823 Standard_Integer cur = 2;
825 BRepBuilderAPI_TransitionMode Transition = BRepBuilderAPI_Transformed;
827 // Reading Transition
828 if (!strcmp(a[cur], "-C")) {
829 Transition = BRepBuilderAPI_RightCorner;
832 else if (!strcmp(a[cur], "-R")) {
833 Transition = BRepBuilderAPI_RoundCorner;
836 Sweep->SetTransitionMode(Transition);
839 if ((n > cur) && (!strcmp(a[cur], "-S"))) mksolid = Standard_True;
841 // Calcul le resultat
843 if (!Sweep->IsDone()) {
844 //std::cout << "Buildsweep : Not Done" << std::endl;
845 di << "Buildsweep : Not Done\n";
846 BRepBuilderAPI_PipeError Stat = Sweep->GetStatus();
847 if (Stat == BRepBuilderAPI_PlaneNotIntersectGuide) {
848 //std::cout << "Buildsweep : One Plane not intersect the guide" << std::endl;
849 di << "Buildsweep : One Plane not intersect the guide\n";
851 if (Stat == BRepBuilderAPI_ImpossibleContact) {
852 //std::cout << "BuildSweep : One section can not be in contact with the guide" << std::endl;
853 di << "BuildSweep : One section can not be in contact with the guide\n";
859 B = Sweep->MakeSolid();
860 //if (!B) std::cout << " BuildSweep : It is impossible to make a solid !" << std::endl;
861 if (!B) di << " BuildSweep : It is impossible to make a solid !\n";
863 result = Sweep->Shape();
864 DBRep::Set(a[1], result);
865 // Save history of sweep
866 if (BRepTest_Objects::IsHistoryNeeded())
868 TopTools_ListOfShape aList;
869 Sweep->Profiles(aList);
870 TopoDS_Shape aSpine = Sweep->Spine();
871 aList.Append(aSpine);
872 BRepTest_Objects::SetHistory(aList, *Sweep);
879 //=======================================================================
880 //function : errorsweep
881 //purpose : returns the summary error on resulting surfaces
883 //=======================================================================
884 static Standard_Integer errorsweep(Draw_Interpretor& di,
885 Standard_Integer, const char**)
887 if (!Sweep->IsDone())
889 di << "Sweep is not done\n";
892 Standard_Real ErrorOnSurfaces = Sweep->ErrorOnSurface();
893 di << "Tolerance on surfaces = " << ErrorOnSurfaces << "\n";
897 //=======================================================================
899 //=======================================================================
900 static Standard_Integer simulsweep(Draw_Interpretor& di,
901 Standard_Integer n, const char** a)
903 if ((n != 3) && (n != 4)) return 1;
906 //std::cout << "You have forgotten the <<mksweep>> command !"<< std::endl;
907 di << "You have forgotten the <<mksweep>> command !\n";
911 if (!Sweep->IsReady()) {
912 //std::cout << "You have forgotten the <<addsweep>> command !"<< std::endl;
913 di << "You have forgotten the <<addsweep>> command !\n";
918 TopTools_ListOfShape List;
919 TopTools_ListIteratorOfListOfShape it;
920 Standard_Integer N, ii;
921 N = Draw::Atoi(a[2]);
924 BRepBuilderAPI_TransitionMode Transition = BRepBuilderAPI_Transformed;
925 // Lecture Transition
926 if (!strcmp(a[3], "-C")) {
927 Transition = BRepBuilderAPI_RightCorner;
929 else if (!strcmp(a[3], "-R")) {
930 Transition = BRepBuilderAPI_RoundCorner;
932 Sweep->SetTransitionMode(Transition);
935 // Calculate the result
936 Sweep->Simulate(N, List);
937 for (ii = 1, it.Initialize(List); it.More(); it.Next(), ii++) {
938 Sprintf(name, "%s_%d", a[1], ii);
939 DBRep::Set(name, it.Value());
945 //=======================================================================
947 //=======================================================================
948 static Standard_Integer middlepath(Draw_Interpretor& /*di*/,
949 Standard_Integer n, const char** a)
953 TopoDS_Shape aShape = DBRep::Get(a[2]);
954 if (aShape.IsNull()) return 1;
956 TopoDS_Shape StartShape = DBRep::Get(a[3]);
957 if (StartShape.IsNull()) return 1;
959 TopoDS_Shape EndShape = DBRep::Get(a[4]);
960 if (EndShape.IsNull()) return 1;
962 BRepOffsetAPI_MiddlePath Builder(aShape, StartShape, EndShape);
965 TopoDS_Shape Result = Builder.Shape();
966 DBRep::Set(a[1], Result);
971 //=======================================================================
972 //function : SweepCommands
974 //=======================================================================
976 void BRepTest::SweepCommands(Draw_Interpretor& theCommands)
978 static Standard_Boolean done = Standard_False;
980 done = Standard_True;
982 DBRep::BasicCommands(theCommands);
984 const char* g = "Sweep commands";
986 theCommands.Add("prism",
987 "prism result base dx dy dz [Copy | Inf | Seminf]",
990 theCommands.Add("revol",
991 "revol result base px py pz dx dy dz angle [Copy]",
994 theCommands.Add("pipe",
995 "pipe result Wire_spine Profile [Mode [Approx]], no args to get help",
998 theCommands.Add("evolved",
999 "evolved , no args to get help",
1000 __FILE__, evolved, g);
1002 theCommands.Add("pruled",
1003 "pruled result Edge1/Wire1 Edge2/Wire2",
1004 __FILE__, pruled, g);
1006 theCommands.Add("gener", "gener result wire1 wire2 [..wire..]",
1007 __FILE__, gener, g);
1009 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)",
1010 __FILE__, thrusections, g);
1012 theCommands.Add("mksweep", "mksweep wire",
1013 __FILE__, mksweep, g);
1015 theCommands.Add("setsweep", "setsweep no args to get help",
1016 __FILE__, setsweep, g);
1018 theCommands.Add("addsweep",
1019 "addsweep wire [vertex] [-M ] [-C] [auxiilaryshape]:no args to get help",
1020 __FILE__, addsweep, g);
1022 theCommands.Add("deletesweep",
1023 "deletesweep wire, To delete a section",
1024 __FILE__, deletesweep, g);
1026 theCommands.Add("buildsweep", "builsweep [r] [option] [Tol] , no args to get help",
1027 __FILE__, buildsweep, g);
1029 theCommands.Add("errorsweep", "errorsweep: returns the summary error on resulting surfaces reached by Sweep",
1030 __FILE__, errorsweep, g);
1032 theCommands.Add("simulsweep", "simulsweep r [n] [option]"
1033 __FILE__, simulsweep, g);
1034 theCommands.Add("geompipe", "geompipe r spineedge profileedge radius [byACR [byrotate]]"
1035 __FILE__, geompipe, g);
1037 theCommands.Add("middlepath", "middlepath res shape startshape endshape",
1038 __FILE__, middlepath, g);