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);
623 Standard_SStream sss;
624 sss << "\n## Tolerances on the shape " << a[1] << " (nbFaces:" << nbF
625 << " nbEdges:" << nbE << " nbVtx:" << nbV << ")\n" ;
627 sss.setf(ios::scientific);
628 if(TmF<=TMF) sss << "\n Face : Min " << setw(8) << TmF <<" Max " << setw(8) << TMF << " \n ";
629 if(TmE<=TME) sss << "\n Edge : Min " << setw(8) << TmE <<" Max " << setw(8) << TME << " \n ";
630 if(TmV<=TMV) sss << "\n Vertex : Min " << setw(8) << TmV <<" Max " << setw(8) << TMV << " \n ";
637 static Standard_Integer vecdc(Draw_Interpretor& di,Standard_Integer ,const char** ) {
638 //cout << "Pick positions with button "<<endl;
639 di << "Pick positions with button \n";
641 Standard_Integer id,X,Y,b;
643 gp_Pnt P1,P2,PP1,PP2;
645 //-----------------------------------------------------------
646 dout.Select(id,X,Y,b); dout.GetTrsf(id,T);
648 Standard_Real z = dout.Zoom(id);
649 P1.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z,0.0);
652 dout.Select(id,X,Y,b); dout.GetTrsf(id,T);
653 T.Invert(); z = dout.Zoom(id);
655 P2.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z,0.0);
657 Standard_Real xa,ya,za;
658 if(Abs(P1.X())>Abs(P2.X())) xa = P1.X(); else xa = P2.X();
659 if(Abs(P1.Y())>Abs(P2.Y())) ya = P1.Y(); else ya = P2.Y();
660 if(Abs(P1.Z())>Abs(P2.Z())) za = P1.Z(); else za = P2.Z();
661 P1.SetCoord(xa,ya,za);
662 Handle(Draw_Marker3D) D0 = new Draw_Marker3D(gp_Pnt(P1.X(),
665 Draw_Square,Draw_blanc,1);
669 //-----------------------------------------------------------
670 dout.Select(id,X,Y,b);
674 PP1.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z,0.0);
676 dout.Select(id,X,Y,b);
680 PP2.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z,0.0);
682 if(Abs(PP1.X())>Abs(PP2.X())) xa = PP1.X(); else xa = PP2.X();
683 if(Abs(PP1.Y())>Abs(PP2.Y())) ya = PP1.Y(); else ya = PP2.Y();
684 if(Abs(PP1.Z())>Abs(PP2.Z())) za = PP1.Z(); else za = PP2.Z();
685 PP1.SetCoord(xa,ya,za);
686 Handle(Draw_Segment3D) d = new Draw_Segment3D(P1,PP1,Draw_blanc);
689 //cout<<"\nttran "<<PP1.X()-P1.X()<<" "<<PP1.Y()-P1.Y()<<" "<<PP1.Z()-P1.Z()<<endl;
690 di <<"\nttran "<<PP1.X()-P1.X()<<" "<<PP1.Y()-P1.Y()<<" "<<PP1.Z()-P1.Z()<< "\n";
692 static Standard_Integer nboxvecdp=0;
693 //cout<<"\nbox b"<<++nboxvecdp<<" "<<Min(P1.X(),PP1.X())<<" "<<Min(P1.Y(),PP1.Y())<<" "<<Min(PP1.Z(),P1.Z());
694 //cout<<" "<<Abs(PP1.X()-P1.X())<<" "<<Abs(PP1.Y()-P1.Y())<<" "<<Abs(PP1.Z()-P1.Z())<<endl;
696 //cout<<"\nDistance :"<<sqrt( (PP1.X()-P1.X())*(PP1.X()-P1.X())
697 // +(PP1.Y()-P1.Y())*(PP1.Y()-P1.Y())
698 // +(PP1.Z()-P1.Z())*(PP1.Z()-P1.Z()))<<endl;
700 di <<"\nbox b"<<++nboxvecdp<<" "<<Min(P1.X(),PP1.X())<<" "<<Min(P1.Y(),PP1.Y())<<" "<<Min(PP1.Z(),P1.Z());
701 di <<" "<<Abs(PP1.X()-P1.X())<<" "<<Abs(PP1.Y()-P1.Y())<<" "<<Abs(PP1.Z()-P1.Z())<< "\n";
703 di <<"\nDistance :"<<sqrt( (PP1.X()-P1.X())*(PP1.X()-P1.X())
704 +(PP1.Y()-P1.Y())*(PP1.Y()-P1.Y())
705 +(PP1.Z()-P1.Z())*(PP1.Z()-P1.Z()))<< "\n";
708 //=======================================================================
710 //=======================================================================
712 #include <TopTools_SequenceOfShape.hxx>
713 static Standard_Integer nproject(Draw_Interpretor& di, Standard_Integer n, const char** a)
715 if ( n < 4) return 1;
716 TopoDS_Shape InpShape;
717 Standard_Integer arg = 2, i;
718 TopTools_SequenceOfShape Args;
720 Standard_Real Tol = 1.e-4;
722 Standard_Real MaxDistance = 1.e-3;
723 GeomAbs_Shape Continuity = GeomAbs_C2;
724 Standard_Integer MaxDeg = 14;
725 Standard_Integer MaxSeg = 16;
727 while((n > arg) && !(InpShape = DBRep::Get(a[arg])).IsNull()){
728 Args.Append(InpShape);
731 if(Args.Length() < 2) return 1;
733 BRepOffsetAPI_NormalProjection OrtProj(Args.Last());
735 for(i = 1; i < Args.Length(); i++)
736 OrtProj.Add(Args(i));
739 if (!strcmp(a[arg],"-g")) {
740 OrtProj.SetLimit(Standard_False);
745 if (!strcmp(a[arg],"-d")) {
748 MaxDistance = Draw::Atof(a[arg++]);
749 OrtProj.SetMaxDistance(MaxDistance);
752 Tol = Max(Draw::Atof(a[arg++]),1.e-10);
756 if (Draw::Atoi(a[arg]) == 0) Continuity = GeomAbs_C0;
757 else if (Draw::Atoi(a[arg]) == 1) Continuity = GeomAbs_C1;
763 MaxDeg = Draw::Atoi(a[arg++]);
764 if (MaxDeg<1 || MaxDeg>14) MaxDeg = 14;
767 if(n > arg) MaxSeg = Draw::Atoi(a[arg]);
769 Tol2d = Pow(Tol, 2./3);
771 OrtProj.SetParams(Tol, Tol2d, Continuity, MaxDeg, MaxSeg);
773 TopTools_ListOfShape Wire;
774 Standard_Boolean IsWire=OrtProj.BuildWire(Wire);
776 //cout << " BuildWire OK " << endl;
777 di << " BuildWire OK \n";
779 DBRep::Set(a[1], OrtProj.Shape());
783 //==========================================================================
785 // exploration of a wire
786 //==========================================================================
787 static Standard_Integer wexplo (Draw_Interpretor&,
788 Standard_Integer argc, const char** argv)
791 if (argc < 2) return 1;
793 TopoDS_Shape C1 = DBRep::Get (argv[1],TopAbs_WIRE);
796 if (argc > 2) C2 = DBRep::Get (argv[2],TopAbs_FACE);
798 if (C1.IsNull()) return 1;
800 BRepTools_WireExplorer we;
801 if (C2.IsNull()) we.Init(TopoDS::Wire(C1));
802 else we.Init(TopoDS::Wire(C1),TopoDS::Face(C2));
804 Standard_Integer k = 1;
806 TopoDS_Edge E = we.Current();
807 Sprintf(name,"WEDGE_%d",k);
816 static Standard_Integer scalexyz(Draw_Interpretor& /*di*/, Standard_Integer n, const char** a)
820 TopoDS_Shape aShapeBase = DBRep::Get(a[2]);
821 if (aShapeBase.IsNull()) return 1;
823 Standard_Real aFactorX = Draw::Atof(a[3]);
824 Standard_Real aFactorY = Draw::Atof(a[4]);
825 Standard_Real aFactorZ = Draw::Atof(a[5]);
828 gp_Mat rot (aFactorX, 0, 0,
831 aGTrsf.SetVectorialPart(rot);
832 BRepBuilderAPI_GTransform aBRepGTrsf (aShapeBase, aGTrsf, Standard_False);
833 if (!aBRepGTrsf.IsDone())
834 Standard_ConstructionError::Raise("Scaling not done");
835 TopoDS_Shape Result = aBRepGTrsf.Shape();
837 DBRep::Set(a[1], Result);
841 void BRepTest::BasicCommands(Draw_Interpretor& theCommands)
843 static Standard_Boolean done = Standard_False;
845 done = Standard_True;
847 DBRep::BasicCommands(theCommands);
849 const char* g = "TOPOLOGY Basic shape commands";
851 theCommands.Add("addpcurve",
852 "addpcurve edge 2dcurve face [tol (default 1.e-7)]",
856 theCommands.Add("reset",
857 "reset name1 name2 ..., remove location",
861 theCommands.Add("tmove",
862 "tmove name1 name2 ... name, set location from name",
866 theCommands.Add("ttranslate",
867 "ttranslate name1 name2 ... dx dy dz",
871 theCommands.Add("trotate",
872 "trotate name1 name2 ... x y z dx dy dz angle",
876 theCommands.Add("tmirror",
877 "tmirror name x y z dx dy dz",
881 theCommands.Add("tscale",
882 "tscale name x y z scale",
886 theCommands.Add("tcopy",
887 "tcopy [-n(ogeom)] [-m(esh)] name1 result1 [name2 result2 ...]",
891 theCommands.Add("bmove",
892 "bmove name1 name2 ... name, set location from name",
896 theCommands.Add("btranslate",
897 "btranslate name1 name2 ... dx dy dz",
901 theCommands.Add("brotate",
902 "brotate name1 name2 ... x y z dx dy dz angle",
906 theCommands.Add("bmirror",
907 "bmirror name x y z dx dy dz",
911 theCommands.Add("bscale",
912 "bscale name x y z scale",
916 theCommands.Add("precision",
921 theCommands.Add("mkedgecurve",
922 "mkedgecurve name tolerance",
926 theCommands.Add("fsameparameter",
927 "fsameparameter shapename [tol (default 1.e-7)], \nforce sameparameter on all edges of the shape",
931 theCommands.Add("sameparameter",
932 "sameparameter shapename [tol (default 1.e-7)]",
936 theCommands.Add("updatetolerance",
937 "updatetolerance myShape [param] \n if [param] is absent - not verify of face tolerance, else - perform it",
941 theCommands.Add("solidorientation",
942 "orientsolid myClosedSolid",
946 theCommands.Add("getcoords",
947 "getcoords vertex1 vertex 2... ; shows coords of input vertices",
951 theCommands.Add("bounding",
952 "bounding shape [ xmin ymin zmin xmax ymax zmax] ; draw bounds",
956 theCommands.Add("boundingstr",
957 "boundingstr shape [ xmin ymin zmin xmax ymax zmax] ; print bounding box",
961 theCommands.Add("nurbsconvert",
962 "nurbsconvert result name [result name]",
966 theCommands.Add("deform",
967 "deform newname name CoeffX CoeffY CoeffZ",
971 theCommands.Add("findplane",
972 "findplane name planename ",
976 theCommands.Add("maxtolerance",
977 "maxtolerance shape ",
981 theCommands.Add("reperageshape",
982 "reperage shape -> list of shape (result of interstion shape , line)",
986 theCommands.Add("vecdc",
987 "vecdc + Pointe double click ",
991 theCommands.Add("nproject","nproject pj e1 e2 e3 ... surf -g -d [dmax] [Tol [continuity [maxdeg [maxseg]]]",
995 theCommands.Add("wexplo","wexplo wire [face] create WEDGE_i",
999 theCommands.Add("scalexyz",
1000 "scalexyz res shape factor_x factor_y factor_z",