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 : bounding
376 //=======================================================================
377 static Standard_Integer bounding(Draw_Interpretor& di,Standard_Integer n,const char** a)
380 Standard_Real axmin,aymin,azmin,axmax,aymax,azmax;
381 Bnd_Box B; Handle(Draw_Box) DB;
384 TopoDS_Shape S = DBRep::Get(a[1]);
385 if (S.IsNull()) return 1;
386 BRepBndLib::Add(S,B);
387 B.Get(axmin,aymin,azmin,axmax,aymax,azmax);
388 DB = new Draw_Box(gp_Pnt(axmin,aymin,azmin),gp_Pnt(axmax,aymax,azmax),Draw_orange);
390 di << axmin<<" "<< aymin<<" "<< azmin<<" "<< axmax<<" "<< aymax<<" "<< azmax;
393 axmin=Draw::Atof(a[1]);
394 aymin=Draw::Atof(a[2]);
395 azmin=Draw::Atof(a[3]);
396 axmax=Draw::Atof(a[4]);
397 aymax=Draw::Atof(a[5]);
398 azmax=Draw::Atof(a[6]);
399 DB = new Draw_Box(gp_Pnt(axmin,aymin,azmin),gp_Pnt(axmax,aymax,azmax),Draw_orange);
404 //=======================================================================
405 //function : findplane
407 //=======================================================================
408 static Standard_Integer findplane(Draw_Interpretor& di,Standard_Integer n,const char** a)
411 TopoDS_Shape S = DBRep::Get(a[1]);
412 if (S.IsNull()) return 1;
413 Standard_Real tolerance = 1.0e-5 ;
414 BRepBuilderAPI_FindPlane a_plane_finder(S,
416 if (a_plane_finder.Found()) {
417 //cout << " a plane is found " ;
418 di << " a plane is found \n";
419 DrawTrSurf::Set(a[2],a_plane_finder.Plane()) ;
423 //=======================================================================
424 //function : precision
426 //=======================================================================
428 static Standard_Integer precision(Draw_Interpretor& di,Standard_Integer n,const char** a)
433 //cout << " Current Precision = " << BRepBuilderAPI::Precision() << endl;
434 di << " Current Precision = " << BRepBuilderAPI::Precision() << "\n";
437 BRepBuilderAPI::Precision(Draw::Atof(a[1]));
443 //=======================================================================
444 //function : reperage shape (Int lin Shape) + pointe double click + maxtol
446 //=======================================================================
447 #include <IntCurvesFace_ShapeIntersector.hxx>
448 #include <gp_Lin.hxx>
450 static Standard_Integer reperageshape(Draw_Interpretor& di, Standard_Integer narg , const char** a)
452 Standard_Integer details=0;
454 if(narg==3) details=1;
455 const char *id1 = a[1];
456 TopoDS_Shape TheShape1 = DBRep::Get(id1);
458 //cout << "Pick positions with button "<<endl;
459 di << "Pick positions with button "<< "\n";
460 Standard_Integer id,X,Y,b;
463 dout.Select(id,X,Y,b);
467 Standard_Real z = dout.Zoom(id);
468 P2.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z, 0.0);
470 P1.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z,-1.0);
474 gp_Ax1 Axe(P1,gp_Vec(P1,P2));
475 IntCurvesFace_ShapeIntersector Inter;
476 Inter.Load(TheShape1,1e-7);
478 Inter.Perform(Axe,-RealLast(),RealLast());
483 for(Standard_Integer i=1; i<=Inter.NbPnt(); i++) {
484 Standard_Integer numface=1;
486 for(ExF.Init(TheShape1,TopAbs_FACE);
488 ExF.Next(),numface++) {
489 TopoDS_Face Face=TopoDS::Face(ExF.Current());
490 if(Face.IsEqual(Inter.Face(i))) {
491 //cout<<" "<<a[1]<<"_"<<numface;
492 di<<" "<<a[1]<<"_"<<numface;
496 const gp_Pnt& P = Inter.Pnt(i);
497 Standard_Real PMin = Inter.WParameter(i);
499 //cout<<" w:"<<PMin<<endl;
500 di<<" w:"<<PMin<< "\n";
502 if(Inter.Transition(i) == IntCurveSurface_In) {
503 if(Inter.State(i) == TopAbs_IN) {
504 Handle(Draw_Marker3D) p = new Draw_Marker3D(P, Draw_Square, Draw_rouge,2);
505 dout << p; dout.Flush();
507 else if(Inter.State(i) == TopAbs_ON) {
508 Handle(Draw_Marker3D) p = new Draw_Marker3D(P, Draw_Square, Draw_vert,2);
509 dout << p; dout.Flush();
513 if(Inter.Transition(i) == IntCurveSurface_Out) {
514 if(Inter.State(i) == TopAbs_IN) {
515 Handle(Draw_Marker3D) p = new Draw_Marker3D(P, Draw_X, Draw_rouge,2);
516 dout << p; dout.Flush();
518 else if(Inter.State(i) == TopAbs_ON) {
519 Handle(Draw_Marker3D) p = new Draw_Marker3D(P, Draw_X, Draw_vert,2);
520 dout << p; dout.Flush();
532 static Standard_Integer maxtolerance(Draw_Interpretor& theCommands,
533 Standard_Integer n, const char** a) {
535 TopoDS_Shape TheShape = DBRep::Get(a[1]);
536 if(TheShape.IsNull()) return(1);
538 Standard_Real T,TMF,TME,TMV,TmF,TmE,TmV;
539 Standard_Integer nbF,nbE,nbV;
540 TMF=TME=TMV=-RealLast();
541 TmF=TmE=TmV=RealLast();
543 TopTools_MapOfShape mapS;
546 for(TopExp_Explorer ex(TheShape,TopAbs_FACE);
549 TopoDS_Face Face=TopoDS::Face(ex.Current());
550 T=BRep_Tool::Tolerance(Face);
559 for(TopExp_Explorer ex(TheShape,TopAbs_EDGE);
562 TopoDS_Edge Edge=TopoDS::Edge(ex.Current());
563 T=BRep_Tool::Tolerance(Edge);
572 for(TopExp_Explorer ex(TheShape,TopAbs_VERTEX);
575 TopoDS_Vertex Vertex=TopoDS::Vertex(ex.Current());
576 T=BRep_Tool::Tolerance(Vertex);
585 Standard_SStream sss;
586 sss << "\n## Tolerances on the shape " << a[1] << " (nbFaces:" << nbF
587 << " nbEdges:" << nbE << " nbVtx:" << nbV << ")\n" ;
589 sss.setf(ios::scientific);
590 if(TmF<=TMF) sss << "\n Face : Min " << setw(8) << TmF <<" Max " << setw(8) << TMF << " \n ";
591 if(TmE<=TME) sss << "\n Edge : Min " << setw(8) << TmE <<" Max " << setw(8) << TME << " \n ";
592 if(TmV<=TMV) sss << "\n Vertex : Min " << setw(8) << TmV <<" Max " << setw(8) << TMV << " \n ";
599 static Standard_Integer vecdc(Draw_Interpretor& di,Standard_Integer ,const char** ) {
600 //cout << "Pick positions with button "<<endl;
601 di << "Pick positions with button "<< "\n";
603 Standard_Integer id,X,Y,b;
605 gp_Pnt P1,P2,PP1,PP2;
607 //-----------------------------------------------------------
608 dout.Select(id,X,Y,b); dout.GetTrsf(id,T);
610 Standard_Real z = dout.Zoom(id);
611 P1.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z,0.0);
614 dout.Select(id,X,Y,b); dout.GetTrsf(id,T);
615 T.Invert(); z = dout.Zoom(id);
617 P2.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z,0.0);
619 Standard_Real xa,ya,za;
620 if(Abs(P1.X())>Abs(P2.X())) xa = P1.X(); else xa = P2.X();
621 if(Abs(P1.Y())>Abs(P2.Y())) ya = P1.Y(); else ya = P2.Y();
622 if(Abs(P1.Z())>Abs(P2.Z())) za = P1.Z(); else za = P2.Z();
623 P1.SetCoord(xa,ya,za);
624 Handle(Draw_Marker3D) D0 = new Draw_Marker3D(gp_Pnt(P1.X(),
627 Draw_Square,Draw_blanc,1);
631 //-----------------------------------------------------------
632 dout.Select(id,X,Y,b);
636 PP1.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z,0.0);
638 dout.Select(id,X,Y,b);
642 PP2.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z,0.0);
644 if(Abs(PP1.X())>Abs(PP2.X())) xa = PP1.X(); else xa = PP2.X();
645 if(Abs(PP1.Y())>Abs(PP2.Y())) ya = PP1.Y(); else ya = PP2.Y();
646 if(Abs(PP1.Z())>Abs(PP2.Z())) za = PP1.Z(); else za = PP2.Z();
647 PP1.SetCoord(xa,ya,za);
648 Handle(Draw_Segment3D) d = new Draw_Segment3D(P1,PP1,Draw_blanc);
651 //cout<<"\nttran "<<PP1.X()-P1.X()<<" "<<PP1.Y()-P1.Y()<<" "<<PP1.Z()-P1.Z()<<endl;
652 di <<"\nttran "<<PP1.X()-P1.X()<<" "<<PP1.Y()-P1.Y()<<" "<<PP1.Z()-P1.Z()<< "\n";
654 static Standard_Integer nboxvecdp=0;
655 //cout<<"\nbox b"<<++nboxvecdp<<" "<<Min(P1.X(),PP1.X())<<" "<<Min(P1.Y(),PP1.Y())<<" "<<Min(PP1.Z(),P1.Z());
656 //cout<<" "<<Abs(PP1.X()-P1.X())<<" "<<Abs(PP1.Y()-P1.Y())<<" "<<Abs(PP1.Z()-P1.Z())<<endl;
658 //cout<<"\nDistance :"<<sqrt( (PP1.X()-P1.X())*(PP1.X()-P1.X())
659 // +(PP1.Y()-P1.Y())*(PP1.Y()-P1.Y())
660 // +(PP1.Z()-P1.Z())*(PP1.Z()-P1.Z()))<<endl;
662 di <<"\nbox b"<<++nboxvecdp<<" "<<Min(P1.X(),PP1.X())<<" "<<Min(P1.Y(),PP1.Y())<<" "<<Min(PP1.Z(),P1.Z());
663 di <<" "<<Abs(PP1.X()-P1.X())<<" "<<Abs(PP1.Y()-P1.Y())<<" "<<Abs(PP1.Z()-P1.Z())<< "\n";
665 di <<"\nDistance :"<<sqrt( (PP1.X()-P1.X())*(PP1.X()-P1.X())
666 +(PP1.Y()-P1.Y())*(PP1.Y()-P1.Y())
667 +(PP1.Z()-P1.Z())*(PP1.Z()-P1.Z()))<< "\n";
670 //=======================================================================
672 //=======================================================================
674 #include <TopTools_SequenceOfShape.hxx>
675 static Standard_Integer nproject(Draw_Interpretor& di, Standard_Integer n, const char** a)
677 if ( n < 4) return 1;
678 TopoDS_Shape InpShape;
679 Standard_Integer arg = 2, i;
680 TopTools_SequenceOfShape Args;
682 Standard_Real Tol = 1.e-4;
684 Standard_Real MaxDistance = 1.e-3;
685 GeomAbs_Shape Continuity = GeomAbs_C2;
686 Standard_Integer MaxDeg = 14;
687 Standard_Integer MaxSeg = 16;
689 while((n > arg) && !(InpShape = DBRep::Get(a[arg])).IsNull()){
690 Args.Append(InpShape);
693 if(Args.Length() < 2) return 1;
695 BRepOffsetAPI_NormalProjection OrtProj(Args.Last());
697 for(i = 1; i < Args.Length(); i++)
698 OrtProj.Add(Args(i));
701 if (!strcmp(a[arg],"-g")) {
702 OrtProj.SetLimit(Standard_False);
707 if (!strcmp(a[arg],"-d")) {
710 MaxDistance = Draw::Atof(a[arg++]);
711 OrtProj.SetMaxDistance(MaxDistance);
714 Tol = Max(Draw::Atof(a[arg++]),1.e-10);
718 if (Draw::Atoi(a[arg]) == 0) Continuity = GeomAbs_C0;
719 else if (Draw::Atoi(a[arg]) == 1) Continuity = GeomAbs_C1;
725 MaxDeg = Draw::Atoi(a[arg++]);
726 if (MaxDeg<1 || MaxDeg>14) MaxDeg = 14;
729 if(n > arg) MaxSeg = Draw::Atoi(a[arg]);
731 Tol2d = Pow(Tol, 2./3);
733 OrtProj.SetParams(Tol, Tol2d, Continuity, MaxDeg, MaxSeg);
735 TopTools_ListOfShape Wire;
736 Standard_Boolean IsWire=OrtProj.BuildWire(Wire);
738 //cout << " BuildWire OK " << endl;
739 di << " BuildWire OK " << "\n";
741 DBRep::Set(a[1], OrtProj.Shape());
745 //==========================================================================
747 // exploration of a wire
748 //==========================================================================
749 static Standard_Integer wexplo (Draw_Interpretor&,
750 Standard_Integer argc, const char** argv)
753 if (argc < 2) return 1;
755 TopoDS_Shape C1 = DBRep::Get (argv[1],TopAbs_WIRE);
758 if (argc > 2) C2 = DBRep::Get (argv[2],TopAbs_FACE);
760 if (C1.IsNull()) return 1;
762 BRepTools_WireExplorer we;
763 if (C2.IsNull()) we.Init(TopoDS::Wire(C1));
764 else we.Init(TopoDS::Wire(C1),TopoDS::Face(C2));
766 Standard_Integer k = 1;
768 TopoDS_Edge E = we.Current();
769 Sprintf(name,"WEDGE_%d",k);
778 static Standard_Integer scalexyz(Draw_Interpretor& di, Standard_Integer n, const char** a)
782 TopoDS_Shape aShapeBase = DBRep::Get(a[2]);
783 if (aShapeBase.IsNull()) return 1;
785 Standard_Real aFactorX = Draw::Atof(a[3]);
786 Standard_Real aFactorY = Draw::Atof(a[4]);
787 Standard_Real aFactorZ = Draw::Atof(a[5]);
790 gp_Mat rot (aFactorX, 0, 0,
793 aGTrsf.SetVectorialPart(rot);
794 BRepBuilderAPI_GTransform aBRepGTrsf (aShapeBase, aGTrsf, Standard_False);
795 if (!aBRepGTrsf.IsDone())
796 Standard_ConstructionError::Raise("Scaling not done");
797 TopoDS_Shape Result = aBRepGTrsf.Shape();
799 DBRep::Set(a[1], Result);
803 void BRepTest::BasicCommands(Draw_Interpretor& theCommands)
805 static Standard_Boolean done = Standard_False;
807 done = Standard_True;
809 DBRep::BasicCommands(theCommands);
811 const char* g = "TOPOLOGY Basic shape commands";
813 theCommands.Add("addpcurve",
814 "addpcurve edge 2dcurve face [tol (default 1.e-7)]",
818 theCommands.Add("reset",
819 "reset name1 name2..., remove location",
823 theCommands.Add("tmove",
824 "tmove name1 name2 ... name(location)",
828 theCommands.Add("ttranslate",
829 "tmove name1 name2 ... dx dy dz",
833 theCommands.Add("trotate","trotate name1 name2 ... x y z dx dy dz angle",
837 theCommands.Add("tmirror",
838 "tmirror name x y z dx dy dz",
842 theCommands.Add("tscale",
843 "tscale name x y z scale",
847 theCommands.Add("tcopy",
848 "tcopy [-n(ogeom)] name1 result1 [name2 result2 ...]",
852 theCommands.Add("precision",
857 theCommands.Add("mkedgecurve",
858 "mkedgecurve name tolerance",
862 theCommands.Add("fsameparameter",
863 "fsameparameter shapename [tol (default 1.e-7)], \nforce sameparameter on all edges of the shape",
867 theCommands.Add("sameparameter",
868 "sameparameter shapename [tol (default 1.e-7)]",
872 theCommands.Add("updatetolerance",
873 "updatetolerance myShape [param] \n if [param] is absent - not verify of face tolerance, else - perform it",
877 theCommands.Add("solidorientation",
878 "orientsolid myClosedSolid",
882 theCommands.Add("bounding",
883 "bounding shape [ xmin ymin zmin xmax ymax zmax] ; draw bounds",
887 theCommands.Add("boundingstr",
888 "boundingstr shape [ xmin ymin zmin xmax ymax zmax] ; print bounding box",
892 theCommands.Add("nurbsconvert",
893 "nurbsconvert result name [result name]",
897 theCommands.Add("deform",
898 "deform newname name CoeffX CoeffY CoeffZ",
902 theCommands.Add("findplane",
903 "findplane name planename ",
907 theCommands.Add("maxtolerance",
908 "maxtolerance shape ",
912 theCommands.Add("reperageshape",
913 "reperage shape -> list of shape (result of interstion shape , line)",
917 theCommands.Add("vecdc",
918 "vecdc + Pointe double click ",
922 theCommands.Add("nproject","nproject pj e1 e2 e3 ... surf -g -d [dmax] [Tol [continuity [maxdeg [maxseg]]]",
926 theCommands.Add("wexplo","wexplo wire [face] create WEDGE_i",
930 theCommands.Add("scalexyz",
931 "scalexyz res shape factor_x factor_y factor_z",