1 // Created on: 1994-12-13
2 // Created by: Jacques GOUSSARD
3 // Copyright (c) 1994-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.
22 #include <Standard_Stream.hxx>
23 #include <Standard_Macro.hxx>
25 #include <BRepTest.hxx>
28 #include <Draw_Appli.hxx>
29 #include <Draw_Interpretor.hxx>
30 #include <Draw_Box.hxx>
32 #include <BRepBuilderAPI.hxx>
33 #include <BRepBuilderAPI_FindPlane.hxx>
34 #include <BRepBuilderAPI_Copy.hxx>
35 #include <BRepBuilderAPI_Transform.hxx>
36 #include <BRepBuilderAPI_GTransform.hxx>
37 #include <BRepBuilderAPI_NurbsConvert.hxx>
40 #include <gp_GTrsf.hxx>
41 #include <BRepOffsetAPI_NormalProjection.hxx>
42 #include <BRepLib.hxx>
43 #include <BRep_Builder.hxx>
44 #include <BRepBndLib.hxx>
45 #include <Bnd_Box.hxx>
46 #include <TopExp_Explorer.hxx>
48 #include <BRepTools_WireExplorer.hxx>
50 #include <GCPnts_QuasiUniformAbscissa.hxx>
51 #include <Geom2dAdaptor_Curve.hxx>
52 #include <GeomAdaptor_Curve.hxx>
53 #include <ProjLib_ComputeApproxOnPolarSurface.hxx>
54 #include <DrawTrSurf.hxx>
57 #include <Draw_Segment3D.hxx>
58 #include <Draw_Marker3D.hxx>
59 #include <Draw_MarkerShape.hxx>
63 Standard_IMPORT Draw_Viewer dout;
67 //=======================================================================
69 //=======================================================================
71 static Standard_Integer addpcurve(Draw_Interpretor& , Standard_Integer n, const char** a)
74 TopoDS_Shape E = DBRep::Get(a[1]);
75 if (E.IsNull()) return 1;
76 Handle(Geom2d_Curve) PC = DrawTrSurf::GetCurve2d(a[2]);
77 TopoDS_Shape F = DBRep::Get(a[3]);
78 Standard_Real tol = 1.e-7;
80 tol = Draw::Atof(a[4]);
83 BB.UpdateEdge(TopoDS::Edge(E), PC, TopoDS::Face(F),tol);
89 //=======================================================================
91 //=======================================================================
93 static Standard_Integer transform(Draw_Interpretor& di,Standard_Integer n,const char** a)
98 Standard_Integer last = n;
100 if (!strcmp(a[0],"reset")) {
102 else if (!strcmp(a[0],"tmove")) {
104 TopoDS_Shape SL = DBRep::Get(a[n-1]);
105 if (SL.IsNull()) return 0;
106 T = SL.Location().Transformation();
109 else if (!strcmp(a[0],"ttranslate")) {
111 T.SetTranslation(gp_Vec(Draw::Atof(a[n-3]),Draw::Atof(a[n-2]),Draw::Atof(a[n-1])));
114 else if (!strcmp(a[0],"trotate")) {
116 T.SetRotation(gp_Ax1(gp_Pnt(Draw::Atof(a[n-7]),Draw::Atof(a[n-6]),Draw::Atof(a[n-5])),
117 gp_Vec(Draw::Atof(a[n-4]),Draw::Atof(a[n-3]),Draw::Atof(a[n-2]))),
118 Draw::Atof(a[n-1])* (M_PI / 180.0));
121 else if (!strcmp(a[0],"tmirror")) {
123 T.SetMirror(gp_Ax2(gp_Pnt(Draw::Atof(a[n-6]),Draw::Atof(a[n-5]),Draw::Atof(a[n-4])),
124 gp_Vec(Draw::Atof(a[n-3]),Draw::Atof(a[n-2]),Draw::Atof(a[n-1]))));
127 else if (!strcmp(a[0],"tscale")) {
129 T.SetScale(gp_Pnt(Draw::Atof(a[n-4]),Draw::Atof(a[n-3]),Draw::Atof(a[n-2])),Draw::Atof(a[n-1]));
134 if (T.Form() == gp_Identity) {
136 for (Standard_Integer i = 1; i < last; i++) {
137 TopoDS_Shape S = DBRep::Get(a[i]);
139 //cout << a[i] << " is not a valid shape" << endl;
140 di << a[i] << " is not a valid shape" << "\n";
143 DBRep::Set(a[i],S.Located(L));
148 BRepBuilderAPI_Transform trf(T);
149 for (Standard_Integer i = 1; i < last; i++) {
150 TopoDS_Shape S = DBRep::Get(a[i]);
152 //cout << a[i] << " is not a valid shape" << endl;
153 di << a[i] << " is not a valid shape" << "\n";
158 DBRep::Set(a[i],trf.Shape());
170 ///=======================================================================
172 //=======================================================================
174 static Standard_Integer deform(Draw_Interpretor& di,Standard_Integer n,const char** a)
176 if (n <= 1) return 1;
178 Standard_Integer last = n;
183 // gp_Mat rot(Draw::Atof(a[last-3]),0,0,0,Draw::Atof(a[last-2]),0,0,0,Draw::Atof(a[last-1]));
184 gp_Mat rot(Draw::Atof(a[3]),0,0,0,Draw::Atof(a[4]),0,0,0,Draw::Atof(a[5]));
185 GT.SetVectorialPart(rot);
187 BRepBuilderAPI_GTransform gtrf(GT);
188 BRepBuilderAPI_NurbsConvert nbscv;
189 // for (Standard_Integer i = 1; i < last; i++) {
190 // TopoDS_Shape S = DBRep::Get(a[i]);
191 TopoDS_Shape S = DBRep::Get(a[2]);
193 //cout << a[2] << " is not a valid shape" << endl;
194 di << a[2] << " is not a valid shape" << "\n";
199 DBRep::Set(a[1],gtrf.Shape());
209 //=======================================================================
211 //=======================================================================
213 static Standard_Integer tcopy(Draw_Interpretor& di,Standard_Integer n,const char** a)
215 Standard_Boolean copyGeom = Standard_True;
216 Standard_Integer iFirst = 1; // index of first shape argument
218 if (n > 1 && a[1][0] == '-' && a[1][1] == 'n' )
220 copyGeom = Standard_False;
224 if (n < 3 || (n - iFirst) % 2) {
225 cout << "Use: " << a[0] << " [-n(ogeom)] shape1 copy1 [shape2 copy2 [...]]" << endl;
226 cout << "Option -n forbids copying of geometry (it will be shared)" << endl;
230 BRepBuilderAPI_Copy cop;
231 Standard_Integer nbPairs = (n - iFirst) / 2;
232 for (Standard_Integer i=0; i < nbPairs; i++) {
233 cop.Perform(DBRep::Get(a[i+iFirst]), copyGeom);
234 DBRep::Set(a[i+iFirst+1],cop.Shape());
235 di << a[i+iFirst+1] << " ";
241 //=======================================================================
243 //=======================================================================
245 static Standard_Integer nurbsconvert(Draw_Interpretor& di,Standard_Integer n,const char** a)
248 if ((n-1)%2 != 0) return 1;
249 BRepBuilderAPI_NurbsConvert nbscv;
250 for (Standard_Integer i=0; i<(n-1)/2; i++) {
251 TopoDS_Shape S = DBRep::Get(a[2*i+2]);
253 //cout << a[2*i+2] << " is not a valid shape" << endl;
254 di << a[2*i+2] << " is not a valid shape" << "\n";
259 DBRep::Set(a[2*i+1],nbscv.Shape());
271 //=======================================================================
272 // make a 3D edge curve
273 //=======================================================================
275 static Standard_Integer mkedgecurve (Draw_Interpretor& ,Standard_Integer n,const char** a)
278 Standard_Boolean CurveDone ;
281 Standard_Real Tolerance = Draw::Atof(a[2]) ;
283 TopoDS_Shape S = DBRep::Get(a[1]);
285 if (S.IsNull()) return 1;
288 BRepLib::BuildCurves3d(S,
293 //=======================================================================
295 //=======================================================================
297 static Standard_Integer sameparameter(Draw_Interpretor& ,Standard_Integer n,const char** a)
300 Standard_Real tol = 1.e-7;
301 TopoDS_Shape S = DBRep::Get(a[1]);
302 if (S.IsNull()) return 1;
303 Standard_Boolean force = !strcmp(a[0],"fsameparameter");
304 if (n == 3) tol = Draw::Atof(a[2]);
306 BRepLib::SameParameter(S,tol,force);
311 //=======================================================================
312 //function : updatetol
314 //=======================================================================
315 static Standard_Integer updatetol(Draw_Interpretor& ,Standard_Integer n,const char** a)
319 TopoDS_Shape S = DBRep::Get(a[1]);
320 if (S.IsNull()) return 1;
322 if (n==2) BRepLib::UpdateTolerances(S);
323 else BRepLib::UpdateTolerances(S,Standard_True);
329 //=======================================================================
330 //function : OrienSolid
332 //=======================================================================
333 static Standard_Integer orientsolid(Draw_Interpretor& ,Standard_Integer n,const char** a)
337 TopoDS_Shape S = DBRep::Get(a[1]);
338 if (S.IsNull()) return 1;
339 if (S.ShapeType()!=TopAbs_SOLID) return 1;
341 BRepLib::OrientClosedSolid(TopoDS::Solid(S));
348 //=======================================================================
349 //function : boundingstr
351 //=======================================================================
352 static Standard_Integer boundingstr(Draw_Interpretor& di,Standard_Integer n,const char** a)
355 TopoDS_Shape S = DBRep::Get(a[1]);
356 if (S.IsNull()) return 1;
358 BRepBndLib::Add(S,B);
359 Standard_Real axmin,aymin,azmin,axmax,aymax,azmax;
360 B.Get(axmin,aymin,azmin,axmax,aymax,azmax);
361 di << axmin<<" "<< aymin<<" "<< azmin<<" "<< axmax<<" "<< aymax<<" "<< azmax;
363 Draw::Set(a[2],axmin) ;
364 Draw::Set(a[3],aymin) ;
365 Draw::Set(a[4],azmin) ;
366 Draw::Set(a[5],axmax) ;
367 Draw::Set(a[6],aymax) ;
368 Draw::Set(a[7],azmax) ;
373 //=======================================================================
374 //function : getcoords
376 //=======================================================================
377 static Standard_Integer getcoords(Draw_Interpretor& di,Standard_Integer n,const char** a)
382 for (Standard_Integer i = 1; i < n; i++)
384 const TopoDS_Shape aShape = DBRep::Get (a[i]);
389 if (aShape.ShapeType() == TopAbs_VERTEX)
391 const TopoDS_Vertex& aVertex = TopoDS::Vertex(aShape);
392 gp_Pnt aPnt = BRep_Tool::Pnt(aVertex);
394 di << a[i] << " (x,y,z) : " << aPnt.X() << " " << aPnt.Y() << " " << aPnt.Z() << "\n";
401 //=======================================================================
402 //function : bounding
404 //=======================================================================
405 static Standard_Integer bounding(Draw_Interpretor& di,Standard_Integer n,const char** a)
408 Standard_Real axmin,aymin,azmin,axmax,aymax,azmax;
409 Bnd_Box B; Handle(Draw_Box) DB;
412 TopoDS_Shape S = DBRep::Get(a[1]);
413 if (S.IsNull()) return 1;
414 BRepBndLib::Add(S,B);
415 B.Get(axmin,aymin,azmin,axmax,aymax,azmax);
416 DB = new Draw_Box(gp_Pnt(axmin,aymin,azmin),gp_Pnt(axmax,aymax,azmax),Draw_orange);
418 di << axmin<<" "<< aymin<<" "<< azmin<<" "<< axmax<<" "<< aymax<<" "<< azmax;
421 axmin=Draw::Atof(a[1]);
422 aymin=Draw::Atof(a[2]);
423 azmin=Draw::Atof(a[3]);
424 axmax=Draw::Atof(a[4]);
425 aymax=Draw::Atof(a[5]);
426 azmax=Draw::Atof(a[6]);
427 DB = new Draw_Box(gp_Pnt(axmin,aymin,azmin),gp_Pnt(axmax,aymax,azmax),Draw_orange);
432 //=======================================================================
433 //function : findplane
435 //=======================================================================
436 static Standard_Integer findplane(Draw_Interpretor& di,Standard_Integer n,const char** a)
439 TopoDS_Shape S = DBRep::Get(a[1]);
440 if (S.IsNull()) return 1;
441 Standard_Real tolerance = 1.0e-5 ;
442 BRepBuilderAPI_FindPlane a_plane_finder(S,
444 if (a_plane_finder.Found()) {
445 //cout << " a plane is found " ;
446 di << " a plane is found \n";
447 DrawTrSurf::Set(a[2],a_plane_finder.Plane()) ;
451 //=======================================================================
452 //function : precision
454 //=======================================================================
456 static Standard_Integer precision(Draw_Interpretor& di,Standard_Integer n,const char** a)
461 //cout << " Current Precision = " << BRepBuilderAPI::Precision() << endl;
462 di << " Current Precision = " << BRepBuilderAPI::Precision() << "\n";
465 BRepBuilderAPI::Precision(Draw::Atof(a[1]));
471 //=======================================================================
472 //function : reperage shape (Int lin Shape) + pointe double click + maxtol
474 //=======================================================================
475 #include <IntCurvesFace_ShapeIntersector.hxx>
476 #include <gp_Lin.hxx>
478 static Standard_Integer reperageshape(Draw_Interpretor& di, Standard_Integer narg , const char** a)
480 Standard_Integer details=0;
482 if(narg==3) details=1;
483 const char *id1 = a[1];
484 TopoDS_Shape TheShape1 = DBRep::Get(id1);
486 //cout << "Pick positions with button "<<endl;
487 di << "Pick positions with button "<< "\n";
488 Standard_Integer id,X,Y,b;
491 dout.Select(id,X,Y,b);
495 Standard_Real z = dout.Zoom(id);
496 P2.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z, 0.0);
498 P1.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z,-1.0);
502 gp_Ax1 Axe(P1,gp_Vec(P1,P2));
503 IntCurvesFace_ShapeIntersector Inter;
504 Inter.Load(TheShape1,1e-7);
506 Inter.Perform(Axe,-RealLast(),RealLast());
511 for(Standard_Integer i=1; i<=Inter.NbPnt(); i++) {
512 Standard_Integer numface=1;
514 for(ExF.Init(TheShape1,TopAbs_FACE);
516 ExF.Next(),numface++) {
517 TopoDS_Face Face=TopoDS::Face(ExF.Current());
518 if(Face.IsEqual(Inter.Face(i))) {
519 //cout<<" "<<a[1]<<"_"<<numface;
520 di<<" "<<a[1]<<"_"<<numface;
524 const gp_Pnt& P = Inter.Pnt(i);
525 Standard_Real PMin = Inter.WParameter(i);
527 //cout<<" w:"<<PMin<<endl;
528 di<<" w:"<<PMin<< "\n";
530 if(Inter.Transition(i) == IntCurveSurface_In) {
531 if(Inter.State(i) == TopAbs_IN) {
532 Handle(Draw_Marker3D) p = new Draw_Marker3D(P, Draw_Square, Draw_rouge,2);
533 dout << p; dout.Flush();
535 else if(Inter.State(i) == TopAbs_ON) {
536 Handle(Draw_Marker3D) p = new Draw_Marker3D(P, Draw_Square, Draw_vert,2);
537 dout << p; dout.Flush();
541 if(Inter.Transition(i) == IntCurveSurface_Out) {
542 if(Inter.State(i) == TopAbs_IN) {
543 Handle(Draw_Marker3D) p = new Draw_Marker3D(P, Draw_X, Draw_rouge,2);
544 dout << p; dout.Flush();
546 else if(Inter.State(i) == TopAbs_ON) {
547 Handle(Draw_Marker3D) p = new Draw_Marker3D(P, Draw_X, Draw_vert,2);
548 dout << p; dout.Flush();
560 static Standard_Integer maxtolerance(Draw_Interpretor& theCommands,
561 Standard_Integer n, const char** a) {
563 TopoDS_Shape TheShape = DBRep::Get(a[1]);
564 if(TheShape.IsNull()) return(1);
566 Standard_Real T,TMF,TME,TMV,TmF,TmE,TmV;
567 Standard_Integer nbF,nbE,nbV;
568 TMF=TME=TMV=-RealLast();
569 TmF=TmE=TmV=RealLast();
571 TopTools_MapOfShape mapS;
574 for(TopExp_Explorer ex(TheShape,TopAbs_FACE);
577 TopoDS_Face Face=TopoDS::Face(ex.Current());
578 T=BRep_Tool::Tolerance(Face);
587 for(TopExp_Explorer ex(TheShape,TopAbs_EDGE);
590 TopoDS_Edge Edge=TopoDS::Edge(ex.Current());
591 T=BRep_Tool::Tolerance(Edge);
600 for(TopExp_Explorer ex(TheShape,TopAbs_VERTEX);
603 TopoDS_Vertex Vertex=TopoDS::Vertex(ex.Current());
604 T=BRep_Tool::Tolerance(Vertex);
613 Standard_SStream sss;
614 sss << "\n## Tolerances on the shape " << a[1] << " (nbFaces:" << nbF
615 << " nbEdges:" << nbE << " nbVtx:" << nbV << ")\n" ;
617 sss.setf(ios::scientific);
618 if(TmF<=TMF) sss << "\n Face : Min " << setw(8) << TmF <<" Max " << setw(8) << TMF << " \n ";
619 if(TmE<=TME) sss << "\n Edge : Min " << setw(8) << TmE <<" Max " << setw(8) << TME << " \n ";
620 if(TmV<=TMV) sss << "\n Vertex : Min " << setw(8) << TmV <<" Max " << setw(8) << TMV << " \n ";
627 static Standard_Integer vecdc(Draw_Interpretor& di,Standard_Integer ,const char** ) {
628 //cout << "Pick positions with button "<<endl;
629 di << "Pick positions with button "<< "\n";
631 Standard_Integer id,X,Y,b;
633 gp_Pnt P1,P2,PP1,PP2;
635 //-----------------------------------------------------------
636 dout.Select(id,X,Y,b); dout.GetTrsf(id,T);
638 Standard_Real z = dout.Zoom(id);
639 P1.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z,0.0);
642 dout.Select(id,X,Y,b); dout.GetTrsf(id,T);
643 T.Invert(); z = dout.Zoom(id);
645 P2.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z,0.0);
647 Standard_Real xa,ya,za;
648 if(Abs(P1.X())>Abs(P2.X())) xa = P1.X(); else xa = P2.X();
649 if(Abs(P1.Y())>Abs(P2.Y())) ya = P1.Y(); else ya = P2.Y();
650 if(Abs(P1.Z())>Abs(P2.Z())) za = P1.Z(); else za = P2.Z();
651 P1.SetCoord(xa,ya,za);
652 Handle(Draw_Marker3D) D0 = new Draw_Marker3D(gp_Pnt(P1.X(),
655 Draw_Square,Draw_blanc,1);
659 //-----------------------------------------------------------
660 dout.Select(id,X,Y,b);
664 PP1.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z,0.0);
666 dout.Select(id,X,Y,b);
670 PP2.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z,0.0);
672 if(Abs(PP1.X())>Abs(PP2.X())) xa = PP1.X(); else xa = PP2.X();
673 if(Abs(PP1.Y())>Abs(PP2.Y())) ya = PP1.Y(); else ya = PP2.Y();
674 if(Abs(PP1.Z())>Abs(PP2.Z())) za = PP1.Z(); else za = PP2.Z();
675 PP1.SetCoord(xa,ya,za);
676 Handle(Draw_Segment3D) d = new Draw_Segment3D(P1,PP1,Draw_blanc);
679 //cout<<"\nttran "<<PP1.X()-P1.X()<<" "<<PP1.Y()-P1.Y()<<" "<<PP1.Z()-P1.Z()<<endl;
680 di <<"\nttran "<<PP1.X()-P1.X()<<" "<<PP1.Y()-P1.Y()<<" "<<PP1.Z()-P1.Z()<< "\n";
682 static Standard_Integer nboxvecdp=0;
683 //cout<<"\nbox b"<<++nboxvecdp<<" "<<Min(P1.X(),PP1.X())<<" "<<Min(P1.Y(),PP1.Y())<<" "<<Min(PP1.Z(),P1.Z());
684 //cout<<" "<<Abs(PP1.X()-P1.X())<<" "<<Abs(PP1.Y()-P1.Y())<<" "<<Abs(PP1.Z()-P1.Z())<<endl;
686 //cout<<"\nDistance :"<<sqrt( (PP1.X()-P1.X())*(PP1.X()-P1.X())
687 // +(PP1.Y()-P1.Y())*(PP1.Y()-P1.Y())
688 // +(PP1.Z()-P1.Z())*(PP1.Z()-P1.Z()))<<endl;
690 di <<"\nbox b"<<++nboxvecdp<<" "<<Min(P1.X(),PP1.X())<<" "<<Min(P1.Y(),PP1.Y())<<" "<<Min(PP1.Z(),P1.Z());
691 di <<" "<<Abs(PP1.X()-P1.X())<<" "<<Abs(PP1.Y()-P1.Y())<<" "<<Abs(PP1.Z()-P1.Z())<< "\n";
693 di <<"\nDistance :"<<sqrt( (PP1.X()-P1.X())*(PP1.X()-P1.X())
694 +(PP1.Y()-P1.Y())*(PP1.Y()-P1.Y())
695 +(PP1.Z()-P1.Z())*(PP1.Z()-P1.Z()))<< "\n";
698 //=======================================================================
700 //=======================================================================
702 #include <TopTools_SequenceOfShape.hxx>
703 static Standard_Integer nproject(Draw_Interpretor& di, Standard_Integer n, const char** a)
705 if ( n < 4) return 1;
706 TopoDS_Shape InpShape;
707 Standard_Integer arg = 2, i;
708 TopTools_SequenceOfShape Args;
710 Standard_Real Tol = 1.e-4;
712 Standard_Real MaxDistance = 1.e-3;
713 GeomAbs_Shape Continuity = GeomAbs_C2;
714 Standard_Integer MaxDeg = 14;
715 Standard_Integer MaxSeg = 16;
717 while((n > arg) && !(InpShape = DBRep::Get(a[arg])).IsNull()){
718 Args.Append(InpShape);
721 if(Args.Length() < 2) return 1;
723 BRepOffsetAPI_NormalProjection OrtProj(Args.Last());
725 for(i = 1; i < Args.Length(); i++)
726 OrtProj.Add(Args(i));
729 if (!strcmp(a[arg],"-g")) {
730 OrtProj.SetLimit(Standard_False);
735 if (!strcmp(a[arg],"-d")) {
738 MaxDistance = Draw::Atof(a[arg++]);
739 OrtProj.SetMaxDistance(MaxDistance);
742 Tol = Max(Draw::Atof(a[arg++]),1.e-10);
746 if (Draw::Atoi(a[arg]) == 0) Continuity = GeomAbs_C0;
747 else if (Draw::Atoi(a[arg]) == 1) Continuity = GeomAbs_C1;
753 MaxDeg = Draw::Atoi(a[arg++]);
754 if (MaxDeg<1 || MaxDeg>14) MaxDeg = 14;
757 if(n > arg) MaxSeg = Draw::Atoi(a[arg]);
759 Tol2d = Pow(Tol, 2./3);
761 OrtProj.SetParams(Tol, Tol2d, Continuity, MaxDeg, MaxSeg);
763 TopTools_ListOfShape Wire;
764 Standard_Boolean IsWire=OrtProj.BuildWire(Wire);
766 //cout << " BuildWire OK " << endl;
767 di << " BuildWire OK " << "\n";
769 DBRep::Set(a[1], OrtProj.Shape());
773 //==========================================================================
775 // exploration of a wire
776 //==========================================================================
777 static Standard_Integer wexplo (Draw_Interpretor&,
778 Standard_Integer argc, const char** argv)
781 if (argc < 2) return 1;
783 TopoDS_Shape C1 = DBRep::Get (argv[1],TopAbs_WIRE);
786 if (argc > 2) C2 = DBRep::Get (argv[2],TopAbs_FACE);
788 if (C1.IsNull()) return 1;
790 BRepTools_WireExplorer we;
791 if (C2.IsNull()) we.Init(TopoDS::Wire(C1));
792 else we.Init(TopoDS::Wire(C1),TopoDS::Face(C2));
794 Standard_Integer k = 1;
796 TopoDS_Edge E = we.Current();
797 Sprintf(name,"WEDGE_%d",k);
806 static Standard_Integer scalexyz(Draw_Interpretor& /*di*/, Standard_Integer n, const char** a)
810 TopoDS_Shape aShapeBase = DBRep::Get(a[2]);
811 if (aShapeBase.IsNull()) return 1;
813 Standard_Real aFactorX = Draw::Atof(a[3]);
814 Standard_Real aFactorY = Draw::Atof(a[4]);
815 Standard_Real aFactorZ = Draw::Atof(a[5]);
818 gp_Mat rot (aFactorX, 0, 0,
821 aGTrsf.SetVectorialPart(rot);
822 BRepBuilderAPI_GTransform aBRepGTrsf (aShapeBase, aGTrsf, Standard_False);
823 if (!aBRepGTrsf.IsDone())
824 Standard_ConstructionError::Raise("Scaling not done");
825 TopoDS_Shape Result = aBRepGTrsf.Shape();
827 DBRep::Set(a[1], Result);
831 void BRepTest::BasicCommands(Draw_Interpretor& theCommands)
833 static Standard_Boolean done = Standard_False;
835 done = Standard_True;
837 DBRep::BasicCommands(theCommands);
839 const char* g = "TOPOLOGY Basic shape commands";
841 theCommands.Add("addpcurve",
842 "addpcurve edge 2dcurve face [tol (default 1.e-7)]",
846 theCommands.Add("reset",
847 "reset name1 name2..., remove location",
851 theCommands.Add("tmove",
852 "tmove name1 name2 ... name(location)",
856 theCommands.Add("ttranslate",
857 "tmove name1 name2 ... dx dy dz",
861 theCommands.Add("trotate","trotate name1 name2 ... x y z dx dy dz angle",
865 theCommands.Add("tmirror",
866 "tmirror name x y z dx dy dz",
870 theCommands.Add("tscale",
871 "tscale name x y z scale",
875 theCommands.Add("tcopy",
876 "tcopy [-n(ogeom)] name1 result1 [name2 result2 ...]",
880 theCommands.Add("precision",
885 theCommands.Add("mkedgecurve",
886 "mkedgecurve name tolerance",
890 theCommands.Add("fsameparameter",
891 "fsameparameter shapename [tol (default 1.e-7)], \nforce sameparameter on all edges of the shape",
895 theCommands.Add("sameparameter",
896 "sameparameter shapename [tol (default 1.e-7)]",
900 theCommands.Add("updatetolerance",
901 "updatetolerance myShape [param] \n if [param] is absent - not verify of face tolerance, else - perform it",
905 theCommands.Add("solidorientation",
906 "orientsolid myClosedSolid",
910 theCommands.Add("getcoords",
911 "getcoords vertex1 vertex 2... ; shows coords of input vertices",
915 theCommands.Add("bounding",
916 "bounding shape [ xmin ymin zmin xmax ymax zmax] ; draw bounds",
920 theCommands.Add("boundingstr",
921 "boundingstr shape [ xmin ymin zmin xmax ymax zmax] ; print bounding box",
925 theCommands.Add("nurbsconvert",
926 "nurbsconvert result name [result name]",
930 theCommands.Add("deform",
931 "deform newname name CoeffX CoeffY CoeffZ",
935 theCommands.Add("findplane",
936 "findplane name planename ",
940 theCommands.Add("maxtolerance",
941 "maxtolerance shape ",
945 theCommands.Add("reperageshape",
946 "reperage shape -> list of shape (result of interstion shape , line)",
950 theCommands.Add("vecdc",
951 "vecdc + Pointe double click ",
955 theCommands.Add("nproject","nproject pj e1 e2 e3 ... surf -g -d [dmax] [Tol [continuity [maxdeg [maxseg]]]",
959 theCommands.Add("wexplo","wexplo wire [face] create WEDGE_i",
963 theCommands.Add("scalexyz",
964 "scalexyz res shape factor_x factor_y factor_z",