1 // Created on: 1994-12-13
2 // Created by: Jacques GOUSSARD
3 // Copyright (c) 1994-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 <Standard_Stream.hxx>
18 #include <Standard_Macro.hxx>
20 #include <BRepTest.hxx>
23 #include <Draw_Appli.hxx>
24 #include <Draw_Interpretor.hxx>
25 #include <Draw_Box.hxx>
27 #include <BRepBuilderAPI.hxx>
28 #include <BRepBuilderAPI_FindPlane.hxx>
29 #include <BRepBuilderAPI_Copy.hxx>
30 #include <BRepBuilderAPI_Transform.hxx>
31 #include <BRepBuilderAPI_GTransform.hxx>
32 #include <BRepBuilderAPI_NurbsConvert.hxx>
35 #include <gp_GTrsf.hxx>
36 #include <BRepOffsetAPI_NormalProjection.hxx>
37 #include <BRepLib.hxx>
38 #include <BRep_Builder.hxx>
39 #include <BRepBndLib.hxx>
40 #include <Bnd_Box.hxx>
41 #include <TopExp_Explorer.hxx>
43 #include <BRepTools_WireExplorer.hxx>
45 #include <GCPnts_QuasiUniformAbscissa.hxx>
46 #include <Geom2dAdaptor_Curve.hxx>
47 #include <GeomAdaptor_Curve.hxx>
48 #include <ProjLib_ComputeApproxOnPolarSurface.hxx>
49 #include <DrawTrSurf.hxx>
50 #include <Geom_Plane.hxx>
52 #include <Draw_Segment3D.hxx>
53 #include <Draw_Marker3D.hxx>
54 #include <Draw_MarkerShape.hxx>
58 Standard_IMPORT Draw_Viewer dout;
62 //=======================================================================
64 //=======================================================================
66 static Standard_Integer addpcurve(Draw_Interpretor& , Standard_Integer n, const char** a)
69 TopoDS_Shape E = DBRep::Get(a[1]);
70 if (E.IsNull()) return 1;
71 Handle(Geom2d_Curve) PC = DrawTrSurf::GetCurve2d(a[2]);
72 TopoDS_Shape F = DBRep::Get(a[3]);
73 Standard_Real tol = 1.e-7;
75 tol = Draw::Atof(a[4]);
78 BB.UpdateEdge(TopoDS::Edge(E), PC, TopoDS::Face(F),tol);
84 //=======================================================================
86 //=======================================================================
88 static Standard_Integer transform(Draw_Interpretor& ,Standard_Integer n,const char** a)
93 Standard_Integer last = n;
94 const char* aName = a[0];
96 Standard_Boolean isBasic = Standard_False;
98 if (!strcmp(aName,"reset")) {
101 isBasic = (aName[0] == 'b');
104 if (!strcmp(aName,"move")) {
106 TopoDS_Shape SL = DBRep::Get(a[n-1]);
107 if (SL.IsNull()) return 0;
108 T = SL.Location().Transformation();
111 else if (!strcmp(aName,"translate")) {
113 T.SetTranslation(gp_Vec(Draw::Atof(a[n-3]),Draw::Atof(a[n-2]),Draw::Atof(a[n-1])));
116 else if (!strcmp(aName,"rotate")) {
118 T.SetRotation(gp_Ax1(gp_Pnt(Draw::Atof(a[n-7]),Draw::Atof(a[n-6]),Draw::Atof(a[n-5])),
119 gp_Vec(Draw::Atof(a[n-4]),Draw::Atof(a[n-3]),Draw::Atof(a[n-2]))),
120 Draw::Atof(a[n-1])* (M_PI / 180.0));
123 else if (!strcmp(aName,"mirror")) {
125 T.SetMirror(gp_Ax2(gp_Pnt(Draw::Atof(a[n-6]),Draw::Atof(a[n-5]),Draw::Atof(a[n-4])),
126 gp_Vec(Draw::Atof(a[n-3]),Draw::Atof(a[n-2]),Draw::Atof(a[n-1]))));
129 else if (!strcmp(aName,"scale")) {
131 T.SetScale(gp_Pnt(Draw::Atof(a[n-4]),Draw::Atof(a[n-3]),Draw::Atof(a[n-2])),Draw::Atof(a[n-1]));
136 if (T.Form() == gp_Identity || isBasic) {
137 TopLoc_Location L(T);
138 for (Standard_Integer i = 1; i < last; i++) {
139 TopoDS_Shape S = DBRep::Get(a[i]);
142 std::cerr << "Error: " << a[i] << " is not a valid shape\n";
146 DBRep::Set(a[i],S.Located(L));
150 BRepBuilderAPI_Transform trf(T);
151 for (Standard_Integer i = 1; i < last; i++) {
152 TopoDS_Shape S = DBRep::Get(a[i]);
154 std::cerr << "Error: " << a[i] << " is not a valid shape\n";
161 DBRep::Set(a[i],trf.Shape());
168 ///=======================================================================
170 //=======================================================================
172 static Standard_Integer deform(Draw_Interpretor& di,Standard_Integer n,const char** a)
174 if (n <= 1) return 1;
176 Standard_Integer last = n;
181 // gp_Mat rot(Draw::Atof(a[last-3]),0,0,0,Draw::Atof(a[last-2]),0,0,0,Draw::Atof(a[last-1]));
182 gp_Mat rot(Draw::Atof(a[3]),0,0,0,Draw::Atof(a[4]),0,0,0,Draw::Atof(a[5]));
183 GT.SetVectorialPart(rot);
185 BRepBuilderAPI_GTransform gtrf(GT);
186 BRepBuilderAPI_NurbsConvert nbscv;
187 // for (Standard_Integer i = 1; i < last; i++) {
188 // TopoDS_Shape S = DBRep::Get(a[i]);
189 TopoDS_Shape S = DBRep::Get(a[2]);
191 //cout << a[2] << " is not a valid shape" << endl;
192 di << a[2] << " is not a valid shape" << "\n";
197 DBRep::Set(a[1],gtrf.Shape());
207 //=======================================================================
209 //=======================================================================
211 static Standard_Integer tcopy(Draw_Interpretor& di,Standard_Integer n,const char** a)
213 Standard_Boolean copyGeom = Standard_True;
214 Standard_Boolean copyMesh = Standard_False;
215 Standard_Integer iFirst = 1; // index of first shape argument
219 for (Standard_Integer i = 1; i <= 2; i++)
225 copyGeom = Standard_False;
228 else if (a[i][1] == 'm')
230 copyMesh = Standard_True;
236 if (n < 3 || (n - iFirst) % 2) {
237 cout << "Use: " << a[0] << " [-n(ogeom)] [-m(esh)] shape1 copy1 [shape2 copy2 [...]]" << endl;
238 cout << "Option -n forbids copying of geometry (it will be shared)" << endl;
239 cout << "Option -m forces copying of mesh (disabled by default)" << endl;
243 BRepBuilderAPI_Copy cop;
244 Standard_Integer nbPairs = (n - iFirst) / 2;
245 for (Standard_Integer i=0; i < nbPairs; i++) {
246 cop.Perform(DBRep::Get(a[i+iFirst]), copyGeom, copyMesh);
247 DBRep::Set(a[i+iFirst+1],cop.Shape());
248 di << a[i+iFirst+1] << " ";
254 //=======================================================================
256 //=======================================================================
258 static Standard_Integer nurbsconvert(Draw_Interpretor& di,Standard_Integer n,const char** a)
261 if ((n-1)%2 != 0) return 1;
262 BRepBuilderAPI_NurbsConvert nbscv;
263 for (Standard_Integer i=0; i<(n-1)/2; i++) {
264 TopoDS_Shape S = DBRep::Get(a[2*i+2]);
266 //cout << a[2*i+2] << " is not a valid shape" << endl;
267 di << a[2*i+2] << " is not a valid shape" << "\n";
272 DBRep::Set(a[2*i+1],nbscv.Shape());
284 //=======================================================================
285 // make a 3D edge curve
286 //=======================================================================
288 static Standard_Integer mkedgecurve (Draw_Interpretor& ,Standard_Integer n,const char** a)
292 Standard_Real Tolerance = Draw::Atof(a[2]) ;
294 TopoDS_Shape S = DBRep::Get(a[1]);
296 if (S.IsNull()) return 1;
298 BRepLib::BuildCurves3d(S,
303 //=======================================================================
305 //=======================================================================
307 static Standard_Integer sameparameter(Draw_Interpretor& ,Standard_Integer n,const char** a)
310 Standard_Real tol = 1.e-7;
311 TopoDS_Shape S = DBRep::Get(a[1]);
312 if (S.IsNull()) return 1;
313 Standard_Boolean force = !strcmp(a[0],"fsameparameter");
314 if (n == 3) tol = Draw::Atof(a[2]);
316 BRepLib::SameParameter(S,tol,force);
321 //=======================================================================
322 //function : updatetol
324 //=======================================================================
325 static Standard_Integer updatetol(Draw_Interpretor& ,Standard_Integer n,const char** a)
329 TopoDS_Shape S = DBRep::Get(a[1]);
330 if (S.IsNull()) return 1;
332 if (n==2) BRepLib::UpdateTolerances(S);
333 else BRepLib::UpdateTolerances(S,Standard_True);
339 //=======================================================================
340 //function : OrienSolid
342 //=======================================================================
343 static Standard_Integer orientsolid(Draw_Interpretor& ,Standard_Integer n,const char** a)
347 TopoDS_Shape S = DBRep::Get(a[1]);
348 if (S.IsNull()) return 1;
349 if (S.ShapeType()!=TopAbs_SOLID) return 1;
351 BRepLib::OrientClosedSolid(TopoDS::Solid(S));
358 //=======================================================================
359 //function : boundingstr
361 //=======================================================================
362 static Standard_Integer boundingstr(Draw_Interpretor& di,Standard_Integer n,const char** a)
365 TopoDS_Shape S = DBRep::Get(a[1]);
366 if (S.IsNull()) return 1;
368 BRepBndLib::Add(S,B);
369 Standard_Real axmin,aymin,azmin,axmax,aymax,azmax;
370 B.Get(axmin,aymin,azmin,axmax,aymax,azmax);
371 di << axmin<<" "<< aymin<<" "<< azmin<<" "<< axmax<<" "<< aymax<<" "<< azmax;
373 Draw::Set(a[2],axmin) ;
374 Draw::Set(a[3],aymin) ;
375 Draw::Set(a[4],azmin) ;
376 Draw::Set(a[5],axmax) ;
377 Draw::Set(a[6],aymax) ;
378 Draw::Set(a[7],azmax) ;
383 //=======================================================================
384 //function : getcoords
386 //=======================================================================
387 static Standard_Integer getcoords(Draw_Interpretor& di,Standard_Integer n,const char** a)
392 for (Standard_Integer i = 1; i < n; i++)
394 const TopoDS_Shape aShape = DBRep::Get (a[i]);
399 if (aShape.ShapeType() == TopAbs_VERTEX)
401 const TopoDS_Vertex& aVertex = TopoDS::Vertex(aShape);
402 gp_Pnt aPnt = BRep_Tool::Pnt(aVertex);
404 di << a[i] << " (x,y,z) : " << aPnt.X() << " " << aPnt.Y() << " " << aPnt.Z() << "\n";
411 //=======================================================================
412 //function : bounding
414 //=======================================================================
415 static Standard_Integer bounding(Draw_Interpretor& di,Standard_Integer n,const char** a)
418 Standard_Real axmin,aymin,azmin,axmax,aymax,azmax;
419 Bnd_Box B; Handle(Draw_Box) DB;
422 TopoDS_Shape S = DBRep::Get(a[1]);
423 if (S.IsNull()) return 1;
424 BRepBndLib::Add(S,B);
425 B.Get(axmin,aymin,azmin,axmax,aymax,azmax);
426 DB = new Draw_Box(gp_Pnt(axmin,aymin,azmin),gp_Pnt(axmax,aymax,azmax),Draw_orange);
428 di << axmin<<" "<< aymin<<" "<< azmin<<" "<< axmax<<" "<< aymax<<" "<< azmax;
431 axmin=Draw::Atof(a[1]);
432 aymin=Draw::Atof(a[2]);
433 azmin=Draw::Atof(a[3]);
434 axmax=Draw::Atof(a[4]);
435 aymax=Draw::Atof(a[5]);
436 azmax=Draw::Atof(a[6]);
437 DB = new Draw_Box(gp_Pnt(axmin,aymin,azmin),gp_Pnt(axmax,aymax,azmax),Draw_orange);
442 //=======================================================================
443 //function : findplane
445 //=======================================================================
446 static Standard_Integer findplane(Draw_Interpretor& di,Standard_Integer n,const char** a)
449 TopoDS_Shape S = DBRep::Get(a[1]);
450 if (S.IsNull()) return 1;
451 Standard_Real tolerance = 1.0e-5 ;
452 BRepBuilderAPI_FindPlane a_plane_finder(S,
454 if (a_plane_finder.Found()) {
455 //cout << " a plane is found " ;
456 di << " a plane is found \n";
457 const Handle(Geom_Geometry)& aSurf = a_plane_finder.Plane(); // to avoid ambiguity
458 DrawTrSurf::Set(a[2],aSurf) ;
462 //=======================================================================
463 //function : precision
465 //=======================================================================
467 static Standard_Integer precision(Draw_Interpretor& di,Standard_Integer n,const char** a)
472 //cout << " Current Precision = " << BRepBuilderAPI::Precision() << endl;
473 di << " Current Precision = " << BRepBuilderAPI::Precision() << "\n";
476 BRepBuilderAPI::Precision(Draw::Atof(a[1]));
482 //=======================================================================
483 //function : reperage shape (Int lin Shape) + pointe double click + maxtol
485 //=======================================================================
486 #include <IntCurvesFace_ShapeIntersector.hxx>
487 #include <gp_Lin.hxx>
489 static Standard_Integer reperageshape(Draw_Interpretor& di, Standard_Integer narg , const char** a)
491 Standard_Integer details=0;
493 if(narg==3) details=1;
494 const char *id1 = a[1];
495 TopoDS_Shape TheShape1 = DBRep::Get(id1);
497 //cout << "Pick positions with button "<<endl;
498 di << "Pick positions with button "<< "\n";
499 Standard_Integer id,X,Y,b;
502 dout.Select(id,X,Y,b);
506 Standard_Real z = dout.Zoom(id);
507 P2.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z, 0.0);
509 P1.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z,-1.0);
513 gp_Ax1 Axe(P1,gp_Vec(P1,P2));
514 IntCurvesFace_ShapeIntersector Inter;
515 Inter.Load(TheShape1,1e-7);
517 Inter.Perform(Axe,-RealLast(),RealLast());
522 for(Standard_Integer i=1; i<=Inter.NbPnt(); i++) {
523 Standard_Integer numface=1;
525 for(ExF.Init(TheShape1,TopAbs_FACE);
527 ExF.Next(),numface++) {
528 TopoDS_Face Face=TopoDS::Face(ExF.Current());
529 if(Face.IsEqual(Inter.Face(i))) {
530 //cout<<" "<<a[1]<<"_"<<numface;
531 di<<" "<<a[1]<<"_"<<numface;
535 const gp_Pnt& P = Inter.Pnt(i);
536 Standard_Real PMin = Inter.WParameter(i);
538 //cout<<" w:"<<PMin<<endl;
539 di<<" w:"<<PMin<< "\n";
541 if(Inter.Transition(i) == IntCurveSurface_In) {
542 if(Inter.State(i) == TopAbs_IN) {
543 Handle(Draw_Marker3D) p = new Draw_Marker3D(P, Draw_Square, 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_Square, Draw_vert,2);
548 dout << p; dout.Flush();
552 if(Inter.Transition(i) == IntCurveSurface_Out) {
553 if(Inter.State(i) == TopAbs_IN) {
554 Handle(Draw_Marker3D) p = new Draw_Marker3D(P, Draw_X, Draw_rouge,2);
555 dout << p; dout.Flush();
557 else if(Inter.State(i) == TopAbs_ON) {
558 Handle(Draw_Marker3D) p = new Draw_Marker3D(P, Draw_X, Draw_vert,2);
559 dout << p; dout.Flush();
571 static Standard_Integer maxtolerance(Draw_Interpretor& theCommands,
572 Standard_Integer n, const char** a) {
574 TopoDS_Shape TheShape = DBRep::Get(a[1]);
575 if(TheShape.IsNull()) return(1);
577 Standard_Real T,TMF,TME,TMV,TmF,TmE,TmV;
578 Standard_Integer nbF,nbE,nbV;
579 TMF=TME=TMV=-RealLast();
580 TmF=TmE=TmV=RealLast();
582 TopTools_MapOfShape mapS;
585 for(TopExp_Explorer ex(TheShape,TopAbs_FACE);
588 TopoDS_Face Face=TopoDS::Face(ex.Current());
589 T=BRep_Tool::Tolerance(Face);
598 for(TopExp_Explorer ex(TheShape,TopAbs_EDGE);
601 TopoDS_Edge Edge=TopoDS::Edge(ex.Current());
602 T=BRep_Tool::Tolerance(Edge);
611 for(TopExp_Explorer ex(TheShape,TopAbs_VERTEX);
614 TopoDS_Vertex Vertex=TopoDS::Vertex(ex.Current());
615 T=BRep_Tool::Tolerance(Vertex);
624 Standard_SStream sss;
625 sss << "\n## Tolerances on the shape " << a[1] << " (nbFaces:" << nbF
626 << " nbEdges:" << nbE << " nbVtx:" << nbV << ")\n" ;
628 sss.setf(ios::scientific);
629 if(TmF<=TMF) sss << "\n Face : Min " << setw(8) << TmF <<" Max " << setw(8) << TMF << " \n ";
630 if(TmE<=TME) sss << "\n Edge : Min " << setw(8) << TmE <<" Max " << setw(8) << TME << " \n ";
631 if(TmV<=TMV) sss << "\n Vertex : Min " << setw(8) << TmV <<" Max " << setw(8) << TMV << " \n ";
638 static Standard_Integer vecdc(Draw_Interpretor& di,Standard_Integer ,const char** ) {
639 //cout << "Pick positions with button "<<endl;
640 di << "Pick positions with button "<< "\n";
642 Standard_Integer id,X,Y,b;
644 gp_Pnt P1,P2,PP1,PP2;
646 //-----------------------------------------------------------
647 dout.Select(id,X,Y,b); dout.GetTrsf(id,T);
649 Standard_Real z = dout.Zoom(id);
650 P1.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z,0.0);
653 dout.Select(id,X,Y,b); dout.GetTrsf(id,T);
654 T.Invert(); z = dout.Zoom(id);
656 P2.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z,0.0);
658 Standard_Real xa,ya,za;
659 if(Abs(P1.X())>Abs(P2.X())) xa = P1.X(); else xa = P2.X();
660 if(Abs(P1.Y())>Abs(P2.Y())) ya = P1.Y(); else ya = P2.Y();
661 if(Abs(P1.Z())>Abs(P2.Z())) za = P1.Z(); else za = P2.Z();
662 P1.SetCoord(xa,ya,za);
663 Handle(Draw_Marker3D) D0 = new Draw_Marker3D(gp_Pnt(P1.X(),
666 Draw_Square,Draw_blanc,1);
670 //-----------------------------------------------------------
671 dout.Select(id,X,Y,b);
675 PP1.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z,0.0);
677 dout.Select(id,X,Y,b);
681 PP2.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z,0.0);
683 if(Abs(PP1.X())>Abs(PP2.X())) xa = PP1.X(); else xa = PP2.X();
684 if(Abs(PP1.Y())>Abs(PP2.Y())) ya = PP1.Y(); else ya = PP2.Y();
685 if(Abs(PP1.Z())>Abs(PP2.Z())) za = PP1.Z(); else za = PP2.Z();
686 PP1.SetCoord(xa,ya,za);
687 Handle(Draw_Segment3D) d = new Draw_Segment3D(P1,PP1,Draw_blanc);
690 //cout<<"\nttran "<<PP1.X()-P1.X()<<" "<<PP1.Y()-P1.Y()<<" "<<PP1.Z()-P1.Z()<<endl;
691 di <<"\nttran "<<PP1.X()-P1.X()<<" "<<PP1.Y()-P1.Y()<<" "<<PP1.Z()-P1.Z()<< "\n";
693 static Standard_Integer nboxvecdp=0;
694 //cout<<"\nbox b"<<++nboxvecdp<<" "<<Min(P1.X(),PP1.X())<<" "<<Min(P1.Y(),PP1.Y())<<" "<<Min(PP1.Z(),P1.Z());
695 //cout<<" "<<Abs(PP1.X()-P1.X())<<" "<<Abs(PP1.Y()-P1.Y())<<" "<<Abs(PP1.Z()-P1.Z())<<endl;
697 //cout<<"\nDistance :"<<sqrt( (PP1.X()-P1.X())*(PP1.X()-P1.X())
698 // +(PP1.Y()-P1.Y())*(PP1.Y()-P1.Y())
699 // +(PP1.Z()-P1.Z())*(PP1.Z()-P1.Z()))<<endl;
701 di <<"\nbox b"<<++nboxvecdp<<" "<<Min(P1.X(),PP1.X())<<" "<<Min(P1.Y(),PP1.Y())<<" "<<Min(PP1.Z(),P1.Z());
702 di <<" "<<Abs(PP1.X()-P1.X())<<" "<<Abs(PP1.Y()-P1.Y())<<" "<<Abs(PP1.Z()-P1.Z())<< "\n";
704 di <<"\nDistance :"<<sqrt( (PP1.X()-P1.X())*(PP1.X()-P1.X())
705 +(PP1.Y()-P1.Y())*(PP1.Y()-P1.Y())
706 +(PP1.Z()-P1.Z())*(PP1.Z()-P1.Z()))<< "\n";
709 //=======================================================================
711 //=======================================================================
713 #include <TopTools_SequenceOfShape.hxx>
714 static Standard_Integer nproject(Draw_Interpretor& di, Standard_Integer n, const char** a)
716 if ( n < 4) return 1;
717 TopoDS_Shape InpShape;
718 Standard_Integer arg = 2, i;
719 TopTools_SequenceOfShape Args;
721 Standard_Real Tol = 1.e-4;
723 Standard_Real MaxDistance = 1.e-3;
724 GeomAbs_Shape Continuity = GeomAbs_C2;
725 Standard_Integer MaxDeg = 14;
726 Standard_Integer MaxSeg = 16;
728 while((n > arg) && !(InpShape = DBRep::Get(a[arg])).IsNull()){
729 Args.Append(InpShape);
732 if(Args.Length() < 2) return 1;
734 BRepOffsetAPI_NormalProjection OrtProj(Args.Last());
736 for(i = 1; i < Args.Length(); i++)
737 OrtProj.Add(Args(i));
740 if (!strcmp(a[arg],"-g")) {
741 OrtProj.SetLimit(Standard_False);
746 if (!strcmp(a[arg],"-d")) {
749 MaxDistance = Draw::Atof(a[arg++]);
750 OrtProj.SetMaxDistance(MaxDistance);
753 Tol = Max(Draw::Atof(a[arg++]),1.e-10);
757 if (Draw::Atoi(a[arg]) == 0) Continuity = GeomAbs_C0;
758 else if (Draw::Atoi(a[arg]) == 1) Continuity = GeomAbs_C1;
764 MaxDeg = Draw::Atoi(a[arg++]);
765 if (MaxDeg<1 || MaxDeg>14) MaxDeg = 14;
768 if(n > arg) MaxSeg = Draw::Atoi(a[arg]);
770 Tol2d = Pow(Tol, 2./3);
772 OrtProj.SetParams(Tol, Tol2d, Continuity, MaxDeg, MaxSeg);
774 TopTools_ListOfShape Wire;
775 Standard_Boolean IsWire=OrtProj.BuildWire(Wire);
777 //cout << " BuildWire OK " << endl;
778 di << " BuildWire OK " << "\n";
780 DBRep::Set(a[1], OrtProj.Shape());
784 //==========================================================================
786 // exploration of a wire
787 //==========================================================================
788 static Standard_Integer wexplo (Draw_Interpretor&,
789 Standard_Integer argc, const char** argv)
792 if (argc < 2) return 1;
794 TopoDS_Shape C1 = DBRep::Get (argv[1],TopAbs_WIRE);
797 if (argc > 2) C2 = DBRep::Get (argv[2],TopAbs_FACE);
799 if (C1.IsNull()) return 1;
801 BRepTools_WireExplorer we;
802 if (C2.IsNull()) we.Init(TopoDS::Wire(C1));
803 else we.Init(TopoDS::Wire(C1),TopoDS::Face(C2));
805 Standard_Integer k = 1;
807 TopoDS_Edge E = we.Current();
808 Sprintf(name,"WEDGE_%d",k);
817 static Standard_Integer scalexyz(Draw_Interpretor& /*di*/, Standard_Integer n, const char** a)
821 TopoDS_Shape aShapeBase = DBRep::Get(a[2]);
822 if (aShapeBase.IsNull()) return 1;
824 Standard_Real aFactorX = Draw::Atof(a[3]);
825 Standard_Real aFactorY = Draw::Atof(a[4]);
826 Standard_Real aFactorZ = Draw::Atof(a[5]);
829 gp_Mat rot (aFactorX, 0, 0,
832 aGTrsf.SetVectorialPart(rot);
833 BRepBuilderAPI_GTransform aBRepGTrsf (aShapeBase, aGTrsf, Standard_False);
834 if (!aBRepGTrsf.IsDone())
835 Standard_ConstructionError::Raise("Scaling not done");
836 TopoDS_Shape Result = aBRepGTrsf.Shape();
838 DBRep::Set(a[1], Result);
842 void BRepTest::BasicCommands(Draw_Interpretor& theCommands)
844 static Standard_Boolean done = Standard_False;
846 done = Standard_True;
848 DBRep::BasicCommands(theCommands);
850 const char* g = "TOPOLOGY Basic shape commands";
852 theCommands.Add("addpcurve",
853 "addpcurve edge 2dcurve face [tol (default 1.e-7)]",
857 theCommands.Add("reset",
858 "reset name1 name2 ..., remove location",
862 theCommands.Add("tmove",
863 "tmove name1 name2 ... name, set location from name",
867 theCommands.Add("ttranslate",
868 "ttranslate name1 name2 ... dx dy dz",
872 theCommands.Add("trotate",
873 "trotate name1 name2 ... x y z dx dy dz angle",
877 theCommands.Add("tmirror",
878 "tmirror name x y z dx dy dz",
882 theCommands.Add("tscale",
883 "tscale name x y z scale",
887 theCommands.Add("tcopy",
888 "tcopy [-n(ogeom)] [-m(esh)] name1 result1 [name2 result2 ...]",
892 theCommands.Add("bmove",
893 "bmove name1 name2 ... name, set location from name",
897 theCommands.Add("btranslate",
898 "btranslate name1 name2 ... dx dy dz",
902 theCommands.Add("brotate",
903 "brotate name1 name2 ... x y z dx dy dz angle",
907 theCommands.Add("bmirror",
908 "bmirror name x y z dx dy dz",
912 theCommands.Add("bscale",
913 "bscale name x y z scale",
917 theCommands.Add("precision",
922 theCommands.Add("mkedgecurve",
923 "mkedgecurve name tolerance",
927 theCommands.Add("fsameparameter",
928 "fsameparameter shapename [tol (default 1.e-7)], \nforce sameparameter on all edges of the shape",
932 theCommands.Add("sameparameter",
933 "sameparameter shapename [tol (default 1.e-7)]",
937 theCommands.Add("updatetolerance",
938 "updatetolerance myShape [param] \n if [param] is absent - not verify of face tolerance, else - perform it",
942 theCommands.Add("solidorientation",
943 "orientsolid myClosedSolid",
947 theCommands.Add("getcoords",
948 "getcoords vertex1 vertex 2... ; shows coords of input vertices",
952 theCommands.Add("bounding",
953 "bounding shape [ xmin ymin zmin xmax ymax zmax] ; draw bounds",
957 theCommands.Add("boundingstr",
958 "boundingstr shape [ xmin ymin zmin xmax ymax zmax] ; print bounding box",
962 theCommands.Add("nurbsconvert",
963 "nurbsconvert result name [result name]",
967 theCommands.Add("deform",
968 "deform newname name CoeffX CoeffY CoeffZ",
972 theCommands.Add("findplane",
973 "findplane name planename ",
977 theCommands.Add("maxtolerance",
978 "maxtolerance shape ",
982 theCommands.Add("reperageshape",
983 "reperage shape -> list of shape (result of interstion shape , line)",
987 theCommands.Add("vecdc",
988 "vecdc + Pointe double click ",
992 theCommands.Add("nproject","nproject pj e1 e2 e3 ... surf -g -d [dmax] [Tol [continuity [maxdeg [maxseg]]]",
996 theCommands.Add("wexplo","wexplo wire [face] create WEDGE_i",
1000 theCommands.Add("scalexyz",
1001 "scalexyz res shape factor_x factor_y factor_z",