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>
61 #include <TopoDS_Face.hxx>
62 #include <TopoDS_Edge.hxx>
63 #include <TopoDS_Vertex.hxx>
64 #include <BRep_Tool.hxx>
65 #include <TopTools_ListOfShape.hxx>
69 Standard_IMPORT Draw_Viewer dout;
73 //=======================================================================
75 //=======================================================================
77 static Standard_Integer addpcurve(Draw_Interpretor& , Standard_Integer n, const char** a)
80 TopoDS_Shape E = DBRep::Get(a[1]);
81 if (E.IsNull()) return 1;
82 Handle(Geom2d_Curve) PC = DrawTrSurf::GetCurve2d(a[2]);
83 TopoDS_Shape F = DBRep::Get(a[3]);
84 Standard_Real tol = 1.e-7;
89 BB.UpdateEdge(TopoDS::Edge(E), PC, TopoDS::Face(F),tol);
95 //=======================================================================
97 //=======================================================================
99 static Standard_Integer transform(Draw_Interpretor& di,Standard_Integer n,const char** a)
101 if (n <= 1) return 1;
104 Standard_Integer last = n;
106 if (!strcmp(a[0],"reset")) {
108 else if (!strcmp(a[0],"tmove")) {
110 TopoDS_Shape SL = DBRep::Get(a[n-1]);
111 if (SL.IsNull()) return 0;
112 T = SL.Location().Transformation();
115 else if (!strcmp(a[0],"ttranslate")) {
117 T.SetTranslation(gp_Vec(atof(a[n-3]),atof(a[n-2]),atof(a[n-1])));
120 else if (!strcmp(a[0],"trotate")) {
122 T.SetRotation(gp_Ax1(gp_Pnt(atof(a[n-7]),atof(a[n-6]),atof(a[n-5])),
123 gp_Vec(atof(a[n-4]),atof(a[n-3]),atof(a[n-2]))),
124 atof(a[n-1])* (M_PI / 180.0));
127 else if (!strcmp(a[0],"tmirror")) {
129 T.SetMirror(gp_Ax2(gp_Pnt(atof(a[n-6]),atof(a[n-5]),atof(a[n-4])),
130 gp_Vec(atof(a[n-3]),atof(a[n-2]),atof(a[n-1]))));
133 else if (!strcmp(a[0],"tscale")) {
135 T.SetScale(gp_Pnt(atof(a[n-4]),atof(a[n-3]),atof(a[n-2])),atof(a[n-1]));
140 if (T.Form() == gp_Identity) {
142 for (Standard_Integer i = 1; i < last; i++) {
143 TopoDS_Shape S = DBRep::Get(a[i]);
145 //cout << a[i] << " is not a valid shape" << endl;
146 di << a[i] << " is not a valid shape" << "\n";
149 DBRep::Set(a[i],S.Located(L));
154 BRepBuilderAPI_Transform trf(T);
155 for (Standard_Integer i = 1; i < last; i++) {
156 TopoDS_Shape S = DBRep::Get(a[i]);
158 //cout << a[i] << " is not a valid shape" << endl;
159 di << a[i] << " is not a valid shape" << "\n";
164 DBRep::Set(a[i],trf.Shape());
176 ///=======================================================================
178 //=======================================================================
180 static Standard_Integer deform(Draw_Interpretor& di,Standard_Integer n,const char** a)
182 if (n <= 1) return 1;
184 Standard_Integer last = n;
189 // gp_Mat rot(atof(a[last-3]),0,0,0,atof(a[last-2]),0,0,0,atof(a[last-1]));
190 gp_Mat rot(atof(a[3]),0,0,0,atof(a[4]),0,0,0,atof(a[5]));
191 GT.SetVectorialPart(rot);
193 BRepBuilderAPI_GTransform gtrf(GT);
194 BRepBuilderAPI_NurbsConvert nbscv;
195 // for (Standard_Integer i = 1; i < last; i++) {
196 // TopoDS_Shape S = DBRep::Get(a[i]);
197 TopoDS_Shape S = DBRep::Get(a[2]);
199 //cout << a[2] << " is not a valid shape" << endl;
200 di << a[2] << " is not a valid shape" << "\n";
205 DBRep::Set(a[1],gtrf.Shape());
215 //=======================================================================
217 //=======================================================================
219 static Standard_Integer tcopy(Draw_Interpretor& di,Standard_Integer n,const char** a)
221 Standard_Boolean copyGeom = Standard_True;
222 Standard_Integer iFirst = 1; // index of first shape argument
224 if (n > 1 && a[1][0] == '-' && a[1][1] == 'n' )
226 copyGeom = Standard_False;
230 if (n < 3 || (n - iFirst) % 2) {
231 cout << "Use: " << a[0] << " [-n(ogeom)] shape1 copy1 [shape2 copy2 [...]]" << endl;
232 cout << "Option -n forbids copying of geometry (it will be shared)" << endl;
236 BRepBuilderAPI_Copy cop;
237 Standard_Integer nbPairs = (n - iFirst) / 2;
238 for (Standard_Integer i=0; i < nbPairs; i++) {
239 cop.Perform(DBRep::Get(a[i+iFirst]), copyGeom);
240 DBRep::Set(a[i+iFirst+1],cop.Shape());
241 di << a[i+iFirst+1] << " ";
247 //=======================================================================
249 //=======================================================================
251 static Standard_Integer nurbsconvert(Draw_Interpretor& di,Standard_Integer n,const char** a)
254 if ((n-1)%2 != 0) return 1;
255 BRepBuilderAPI_NurbsConvert nbscv;
256 for (Standard_Integer i=0; i<(n-1)/2; i++) {
257 TopoDS_Shape S = DBRep::Get(a[2*i+2]);
259 //cout << a[2*i+2] << " is not a valid shape" << endl;
260 di << a[2*i+2] << " is not a valid shape" << "\n";
265 DBRep::Set(a[2*i+1],nbscv.Shape());
277 //=======================================================================
278 // make a 3D edge curve
279 //=======================================================================
281 static Standard_Integer mkedgecurve (Draw_Interpretor& ,Standard_Integer n,const char** a)
284 Standard_Boolean CurveDone ;
287 Standard_Real Tolerance = atof(a[2]) ;
289 TopoDS_Shape S = DBRep::Get(a[1]);
291 if (S.IsNull()) return 1;
294 BRepLib::BuildCurves3d(S,
299 //=======================================================================
301 //=======================================================================
303 static Standard_Integer sameparameter(Draw_Interpretor& ,Standard_Integer n,const char** a)
306 Standard_Real tol = 1.e-7;
307 TopoDS_Shape S = DBRep::Get(a[1]);
308 if (S.IsNull()) return 1;
309 Standard_Boolean force = !strcmp(a[0],"fsameparameter");
310 if (n == 3) tol = atof(a[2]);
312 BRepLib::SameParameter(S,tol,force);
317 //=======================================================================
318 //function : updatetol
320 //=======================================================================
321 static Standard_Integer updatetol(Draw_Interpretor& ,Standard_Integer n,const char** a)
325 TopoDS_Shape S = DBRep::Get(a[1]);
326 if (S.IsNull()) return 1;
328 if (n==2) BRepLib::UpdateTolerances(S);
329 else BRepLib::UpdateTolerances(S,Standard_True);
335 //=======================================================================
336 //function : OrienSolid
338 //=======================================================================
339 static Standard_Integer orientsolid(Draw_Interpretor& ,Standard_Integer n,const char** a)
343 TopoDS_Shape S = DBRep::Get(a[1]);
344 if (S.IsNull()) return 1;
345 if (S.ShapeType()!=TopAbs_SOLID) return 1;
347 BRepLib::OrientClosedSolid(TopoDS::Solid(S));
354 //=======================================================================
355 //function : boundingstr
357 //=======================================================================
358 static Standard_Integer boundingstr(Draw_Interpretor& di,Standard_Integer n,const char** a)
361 TopoDS_Shape S = DBRep::Get(a[1]);
362 if (S.IsNull()) return 1;
364 BRepBndLib::Add(S,B);
365 Standard_Real axmin,aymin,azmin,axmax,aymax,azmax;
366 B.Get(axmin,aymin,azmin,axmax,aymax,azmax);
367 di << axmin<<" "<< aymin<<" "<< azmin<<" "<< axmax<<" "<< aymax<<" "<< azmax;
369 Draw::Set(a[2],axmin) ;
370 Draw::Set(a[3],aymin) ;
371 Draw::Set(a[4],azmin) ;
372 Draw::Set(a[5],axmax) ;
373 Draw::Set(a[6],aymax) ;
374 Draw::Set(a[7],azmax) ;
379 //=======================================================================
380 //function : bounding
382 //=======================================================================
383 static Standard_Integer bounding(Draw_Interpretor& di,Standard_Integer n,const char** a)
386 Standard_Real axmin,aymin,azmin,axmax,aymax,azmax;
387 Bnd_Box B; Handle(Draw_Box) DB;
390 TopoDS_Shape S = DBRep::Get(a[1]);
391 if (S.IsNull()) return 1;
392 BRepBndLib::Add(S,B);
393 B.Get(axmin,aymin,azmin,axmax,aymax,azmax);
394 DB = new Draw_Box(gp_Pnt(axmin,aymin,azmin),gp_Pnt(axmax,aymax,azmax),Draw_orange);
396 di << axmin<<" "<< aymin<<" "<< azmin<<" "<< axmax<<" "<< aymax<<" "<< azmax;
405 DB = new Draw_Box(gp_Pnt(axmin,aymin,azmin),gp_Pnt(axmax,aymax,azmax),Draw_orange);
410 //=======================================================================
411 //function : findplane
413 //=======================================================================
414 static Standard_Integer findplane(Draw_Interpretor& di,Standard_Integer n,const char** a)
417 TopoDS_Shape S = DBRep::Get(a[1]);
418 if (S.IsNull()) return 1;
419 Standard_Real tolerance = 1.0e-5 ;
420 BRepBuilderAPI_FindPlane a_plane_finder(S,
422 if (a_plane_finder.Found()) {
423 //cout << " a plane is found " ;
424 di << " a plane is found \n";
425 DrawTrSurf::Set(a[2],a_plane_finder.Plane()) ;
429 //=======================================================================
430 //function : precision
432 //=======================================================================
434 static Standard_Integer precision(Draw_Interpretor& di,Standard_Integer n,const char** a)
439 //cout << " Current Precision = " << BRepBuilderAPI::Precision() << endl;
440 di << " Current Precision = " << BRepBuilderAPI::Precision() << "\n";
443 BRepBuilderAPI::Precision(atof(a[1]));
449 //=======================================================================
450 //function : reperage shape (Int lin Shape) + pointe double click + maxtol
452 //=======================================================================
453 #include <IntCurvesFace_ShapeIntersector.hxx>
454 #include <gp_Lin.hxx>
456 static Standard_Integer reperageshape(Draw_Interpretor& di, Standard_Integer narg , const char** a)
458 Standard_Integer details=0;
460 if(narg==3) details=1;
461 const char *id1 = a[1];
462 TopoDS_Shape TheShape1 = DBRep::Get(id1);
464 //cout << "Pick positions with button "<<endl;
465 di << "Pick positions with button "<< "\n";
466 Standard_Integer id,X,Y,b;
469 dout.Select(id,X,Y,b);
473 Standard_Real z = dout.Zoom(id);
474 P2.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z, 0.0);
476 P1.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z,-1.0);
480 gp_Ax1 Axe(P1,gp_Vec(P1,P2));
481 IntCurvesFace_ShapeIntersector Inter;
482 Inter.Load(TheShape1,1e-7);
484 Inter.Perform(Axe,-RealLast(),RealLast());
489 for(Standard_Integer i=1; i<=Inter.NbPnt(); i++) {
490 Standard_Integer numface=1;
492 for(ExF.Init(TheShape1,TopAbs_FACE);
494 ExF.Next(),numface++) {
495 TopoDS_Face Face=TopoDS::Face(ExF.Current());
496 if(Face.IsEqual(Inter.Face(i))) {
497 //cout<<" "<<a[1]<<"_"<<numface;
498 di<<" "<<a[1]<<"_"<<numface;
502 const gp_Pnt& P = Inter.Pnt(i);
503 Standard_Real PMin = Inter.WParameter(i);
505 //cout<<" w:"<<PMin<<endl;
506 di<<" w:"<<PMin<< "\n";
508 if(Inter.Transition(i) == IntCurveSurface_In) {
509 if(Inter.State(i) == TopAbs_IN) {
510 Handle(Draw_Marker3D) p = new Draw_Marker3D(P, Draw_Square, Draw_rouge,2);
511 dout << p; dout.Flush();
513 else if(Inter.State(i) == TopAbs_ON) {
514 Handle(Draw_Marker3D) p = new Draw_Marker3D(P, Draw_Square, Draw_vert,2);
515 dout << p; dout.Flush();
519 if(Inter.Transition(i) == IntCurveSurface_Out) {
520 if(Inter.State(i) == TopAbs_IN) {
521 Handle(Draw_Marker3D) p = new Draw_Marker3D(P, Draw_X, Draw_rouge,2);
522 dout << p; dout.Flush();
524 else if(Inter.State(i) == TopAbs_ON) {
525 Handle(Draw_Marker3D) p = new Draw_Marker3D(P, Draw_X, Draw_vert,2);
526 dout << p; dout.Flush();
538 static Standard_Integer maxtolerance(Draw_Interpretor& theCommands,
539 Standard_Integer n, const char** a) {
541 TopoDS_Shape TheShape = DBRep::Get(a[1]);
542 if(TheShape.IsNull()) return(1);
544 Standard_Real T,TMF,TME,TMV,TmF,TmE,TmV;
545 Standard_Integer nbF,nbE,nbV;
546 TMF=TME=TMV=-RealLast();
547 TmF=TmE=TmV=RealLast();
551 for(ExF.Init(TheShape,TopAbs_FACE);
554 TopoDS_Face Face=TopoDS::Face(ExF.Current());
555 T=BRep_Tool::Tolerance(Face);
561 for(ExE.Init(TheShape,TopAbs_EDGE);
564 TopoDS_Edge Edge=TopoDS::Edge(ExE.Current());
565 T=BRep_Tool::Tolerance(Edge);
571 for(ExV.Init(TheShape,TopAbs_VERTEX);
574 TopoDS_Vertex Vertex=TopoDS::Vertex(ExV.Current());
575 T=BRep_Tool::Tolerance(Vertex);
581 // printf("\n## Tolerances sur le shape %s (nbFaces:%3d nbEdges:%3d nbVtx:%3d)\n",a[1],nbF,nbE,nbV);
582 // if(TmF<=TMF) printf("\n Face : Min %+5.8e Max %+5.8e \n ",TmF,TMF);
583 // if(TmE<=TME) printf("\n Edge : Min %+5.8e Max %+5.8e \n ",TmE,TME);
584 // if(TmV<=TMV) printf("\n Vertex : Min %+5.8e Max %+5.8e \n\n ",TmV,TMV);
587 Standard_SStream sss;
588 sss << "\n## Tolerances on the shape " << a[1] << " (nbFaces:" << nbF
589 << " nbEdges:" << nbE << " nbVtx:" << nbV << ")\n" ;
591 sss.setf(ios::scientific);
592 if(TmF<=TMF) sss << "\n Face : Min " << setw(8) << TmF <<" Max " << setw(8) << TMF << " \n ";
593 if(TmE<=TME) sss << "\n Edge : Min " << setw(8) << TmE <<" Max " << setw(8) << TME << " \n ";
594 if(TmV<=TMV) sss << "\n Vertex : Min " << setw(8) << TmV <<" Max " << setw(8) << TMV << " \n ";
601 static Standard_Integer vecdc(Draw_Interpretor& di,Standard_Integer ,const char** ) {
602 //cout << "Pick positions with button "<<endl;
603 di << "Pick positions with button "<< "\n";
605 Standard_Integer id,X,Y,b;
607 gp_Pnt P1,P2,PP1,PP2;
609 //-----------------------------------------------------------
610 dout.Select(id,X,Y,b); dout.GetTrsf(id,T);
612 Standard_Real z = dout.Zoom(id);
613 P1.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z,0.0);
616 dout.Select(id,X,Y,b); dout.GetTrsf(id,T);
617 T.Invert(); z = dout.Zoom(id);
619 P2.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z,0.0);
621 Standard_Real xa,ya,za;
622 if(Abs(P1.X())>Abs(P2.X())) xa = P1.X(); else xa = P2.X();
623 if(Abs(P1.Y())>Abs(P2.Y())) ya = P1.Y(); else ya = P2.Y();
624 if(Abs(P1.Z())>Abs(P2.Z())) za = P1.Z(); else za = P2.Z();
625 P1.SetCoord(xa,ya,za);
626 Handle(Draw_Marker3D) D0 = new Draw_Marker3D(gp_Pnt(P1.X(),
629 Draw_Square,Draw_blanc,1);
633 //-----------------------------------------------------------
634 dout.Select(id,X,Y,b);
638 PP1.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z,0.0);
640 dout.Select(id,X,Y,b);
644 PP2.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z,0.0);
646 if(Abs(PP1.X())>Abs(PP2.X())) xa = PP1.X(); else xa = PP2.X();
647 if(Abs(PP1.Y())>Abs(PP2.Y())) ya = PP1.Y(); else ya = PP2.Y();
648 if(Abs(PP1.Z())>Abs(PP2.Z())) za = PP1.Z(); else za = PP2.Z();
649 PP1.SetCoord(xa,ya,za);
650 Handle(Draw_Segment3D) d = new Draw_Segment3D(P1,PP1,Draw_blanc);
653 //cout<<"\nttran "<<PP1.X()-P1.X()<<" "<<PP1.Y()-P1.Y()<<" "<<PP1.Z()-P1.Z()<<endl;
654 di <<"\nttran "<<PP1.X()-P1.X()<<" "<<PP1.Y()-P1.Y()<<" "<<PP1.Z()-P1.Z()<< "\n";
656 static Standard_Integer nboxvecdp=0;
657 //cout<<"\nbox b"<<++nboxvecdp<<" "<<Min(P1.X(),PP1.X())<<" "<<Min(P1.Y(),PP1.Y())<<" "<<Min(PP1.Z(),P1.Z());
658 //cout<<" "<<Abs(PP1.X()-P1.X())<<" "<<Abs(PP1.Y()-P1.Y())<<" "<<Abs(PP1.Z()-P1.Z())<<endl;
660 //cout<<"\nDistance :"<<sqrt( (PP1.X()-P1.X())*(PP1.X()-P1.X())
661 // +(PP1.Y()-P1.Y())*(PP1.Y()-P1.Y())
662 // +(PP1.Z()-P1.Z())*(PP1.Z()-P1.Z()))<<endl;
664 di <<"\nbox b"<<++nboxvecdp<<" "<<Min(P1.X(),PP1.X())<<" "<<Min(P1.Y(),PP1.Y())<<" "<<Min(PP1.Z(),P1.Z());
665 di <<" "<<Abs(PP1.X()-P1.X())<<" "<<Abs(PP1.Y()-P1.Y())<<" "<<Abs(PP1.Z()-P1.Z())<< "\n";
667 di <<"\nDistance :"<<sqrt( (PP1.X()-P1.X())*(PP1.X()-P1.X())
668 +(PP1.Y()-P1.Y())*(PP1.Y()-P1.Y())
669 +(PP1.Z()-P1.Z())*(PP1.Z()-P1.Z()))<< "\n";
672 //=======================================================================
674 //=======================================================================
676 #include <TopTools_SequenceOfShape.hxx>
677 static Standard_Integer nproject(Draw_Interpretor& di, Standard_Integer n, const char** a)
679 if ( n < 4) return 1;
680 TopoDS_Shape InpShape;
681 Standard_Integer arg = 2, i;
682 TopTools_SequenceOfShape Args;
684 Standard_Real Tol = 1.e-4;
686 Standard_Real MaxDistance = 1.e-3;
687 GeomAbs_Shape Continuity = GeomAbs_C2;
688 Standard_Integer MaxDeg = 14;
689 Standard_Integer MaxSeg = 16;
691 while((n > arg) && !(InpShape = DBRep::Get(a[arg])).IsNull()){
692 Args.Append(InpShape);
695 if(Args.Length() < 2) return 1;
697 BRepOffsetAPI_NormalProjection OrtProj(Args.Last());
699 for(i = 1; i < Args.Length(); i++)
700 OrtProj.Add(Args(i));
703 if (!strcmp(a[arg],"-g")) {
704 OrtProj.SetLimit(Standard_False);
709 if (!strcmp(a[arg],"-d")) {
712 MaxDistance = atof(a[arg++]);
713 OrtProj.SetMaxDistance(MaxDistance);
716 Tol = Max(atof(a[arg++]),1.e-10);
720 if (atoi(a[arg]) == 0) Continuity = GeomAbs_C0;
721 else if (atoi(a[arg]) == 1) Continuity = GeomAbs_C1;
727 MaxDeg = atoi(a[arg++]);
728 if (MaxDeg<1 || MaxDeg>14) MaxDeg = 14;
731 if(n > arg) MaxSeg = atoi(a[arg]);
733 Tol2d = Pow(Tol, 2./3);
735 OrtProj.SetParams(Tol, Tol2d, Continuity, MaxDeg, MaxSeg);
737 TopTools_ListOfShape Wire;
738 Standard_Boolean IsWire=OrtProj.BuildWire(Wire);
740 //cout << " BuildWire OK " << endl;
741 di << " BuildWire OK " << "\n";
743 DBRep::Set(a[1], OrtProj.Shape());
747 //==========================================================================
749 // exploration of a wire
750 //==========================================================================
751 static Standard_Integer wexplo (Draw_Interpretor&,
752 Standard_Integer argc, const char** argv)
755 if (argc < 2) return 1;
757 TopoDS_Shape C1 = DBRep::Get (argv[1],TopAbs_WIRE);
760 if (argc > 2) C2 = DBRep::Get (argv[2],TopAbs_FACE);
762 if (C1.IsNull()) return 1;
764 BRepTools_WireExplorer we;
765 if (C2.IsNull()) we.Init(TopoDS::Wire(C1));
766 else we.Init(TopoDS::Wire(C1),TopoDS::Face(C2));
768 Standard_Integer k = 1;
770 TopoDS_Edge E = we.Current();
771 sprintf(name,"WEDGE_%d",k);
780 static Standard_Integer scalexyz(Draw_Interpretor& di, Standard_Integer n, const char** a)
784 TopoDS_Shape aShapeBase = DBRep::Get(a[2]);
785 if (aShapeBase.IsNull()) return 1;
787 Standard_Real aFactorX = atof(a[3]);
788 Standard_Real aFactorY = atof(a[4]);
789 Standard_Real aFactorZ = atof(a[5]);
792 gp_Mat rot (aFactorX, 0, 0,
795 aGTrsf.SetVectorialPart(rot);
796 BRepBuilderAPI_GTransform aBRepGTrsf (aShapeBase, aGTrsf, Standard_False);
797 if (!aBRepGTrsf.IsDone())
798 Standard_ConstructionError::Raise("Scaling not done");
799 TopoDS_Shape Result = aBRepGTrsf.Shape();
801 DBRep::Set(a[1], Result);
805 void BRepTest::BasicCommands(Draw_Interpretor& theCommands)
807 static Standard_Boolean done = Standard_False;
809 done = Standard_True;
811 DBRep::BasicCommands(theCommands);
813 const char* g = "TOPOLOGY Basic shape commands";
815 theCommands.Add("addpcurve",
816 "addpcurve edge 2dcurve face [tol (default 1.e-7)]",
820 theCommands.Add("reset",
821 "reset name1 name2..., remove location",
825 theCommands.Add("tmove",
826 "tmove name1 name2 ... name(location)",
830 theCommands.Add("ttranslate",
831 "tmove name1 name2 ... dx dy dz",
835 theCommands.Add("trotate","trotate name1 name2 ... x y z dx dy dz angle",
839 theCommands.Add("tmirror",
840 "tmirror name x y z dx dy dz",
844 theCommands.Add("tscale",
845 "tscale name x y z scale",
849 theCommands.Add("tcopy",
850 "tcopy [-n(ogeom)] name1 result1 [name2 result2 ...]",
854 theCommands.Add("precision",
859 theCommands.Add("mkedgecurve",
860 "mkedgecurve name tolerance",
864 theCommands.Add("fsameparameter",
865 "fsameparameter shapename [tol (default 1.e-7)], \nforce sameparameter on all edges of the shape",
869 theCommands.Add("sameparameter",
870 "sameparameter shapename [tol (default 1.e-7)]",
874 theCommands.Add("updatetolerance",
875 "updatetolerance myShape [param] \n if [param] is absent - not verify of face tolerance, else - perform it",
879 theCommands.Add("solidorientation",
880 "orientsolid myClosedSolid",
884 theCommands.Add("bounding",
885 "bounding shape [ xmin ymin zmin xmax ymax zmax] ; draw bounds",
889 theCommands.Add("boundingstr",
890 "boundingstr shape [ xmin ymin zmin xmax ymax zmax] ; print bounding box",
894 theCommands.Add("nurbsconvert",
895 "nurbsconvert result name [result name]",
899 theCommands.Add("deform",
900 "deform newname name CoeffX CoeffY CoeffZ",
904 theCommands.Add("findplane",
905 "findplane name planename ",
909 theCommands.Add("maxtolerance",
910 "maxtolerance shape ",
914 theCommands.Add("reperageshape",
915 "reperage shape -> list of shape (result of interstion shape , line)",
919 theCommands.Add("vecdc",
920 "vecdc + Pointe double click ",
924 theCommands.Add("nproject","nproject pj e1 e2 e3 ... surf -g -d [dmax] [Tol [continuity [maxdeg [maxseg]]]",
928 theCommands.Add("wexplo","wexplo wire [face] create WEDGE_i",
932 theCommands.Add("scalexyz",
933 "scalexyz res shape factor_x factor_y factor_z",