2 // Created: Mon Mar 18 16:17:15 2002
4 // <qa@umnox.nnov.matra-dtv.fr>
8 #define Viewer2dTest QAViewer2dTest
13 #include <QATelco.hxx>
15 #include <Draw_Interpretor.hxx>
17 #include <DrawTrSurf.hxx>
18 #include <AIS_InteractiveContext.hxx>
19 #include <ViewerTest.hxx>
20 #include <AIS_Shape.hxx>
21 #include <TopoDS_Shape.hxx>
23 #include <Geom_Circle.hxx>
24 #include <Geom_Ellipse.hxx>
25 #include <Geom_Plane.hxx>
27 #include <Geom2d_Curve.hxx>
28 #include <GeomAPI.hxx>
29 #include <Geom2dAdaptor_Curve.hxx>
30 #include <Geom2dGcc_QualifiedCurve.hxx>
31 #include <Geom2dGcc_Lin2d2Tan.hxx>
32 #include <Geom2d_Line.hxx>
33 #include <BRepBuilderAPI_MakeEdge.hxx>
34 #include <TopoDS_Edge.hxx>
35 #include <Precision.hxx>
36 #include <Geom2d_Circle.hxx>
37 #include <Geom2dGcc_MyQCurve.hxx>
38 #include <GccEnt_QualifiedCirc.hxx>
39 #include <Geom2dGcc_MyL2d2Tan.hxx>
40 #include <BRepBuilderAPI_MakeWire.hxx>
41 #include <TopExp_Explorer.hxx>
43 #include <TopoDS_Wire.hxx>
44 #include <BRep_Tool.hxx>
45 #include <gp_Circ.hxx>
46 #include <BRepOffsetAPI_MakePipeShell.hxx>
47 #include <AIS_Trihedron.hxx>
48 #include <Geom_Axis2Placement.hxx>
49 #include <V3d_View.hxx>
50 #include <ViewerTest_Tool.hxx>
51 #include <BRepBuilderAPI_MakeVertex.hxx>
52 #include <AIS_LengthDimension.hxx>
53 #include <AIS_RadiusDimension.hxx>
54 #include <BRepPrimAPI_MakeBox.hxx>
55 #include <GeomAdaptor_Surface.hxx>
56 #include <Extrema_ExtPS.hxx>
57 #include <Geom_CartesianPoint.hxx>
58 #include <Geom2d_CartesianPoint.hxx>
59 #include <Geom2dGcc_Circ2d3Tan.hxx>
60 #include <Aspect_Window.hxx>
62 #include <TopoDS_Compound.hxx>
63 #include <TopoDS_CompSolid.hxx>
64 #include <StdSelect_ShapeTypeFilter.hxx>
66 #include <QATelco_MyText.hxx>
69 #include <QAViewer2dTest.hxx>
70 #include <QAViewer2dTest_DoubleMapOfInteractiveAndName.hxx>
72 #include <Viewer2dTest.hxx>
73 #include <Viewer2dTest_DoubleMapOfInteractiveAndName.hxx>
76 #include <Prs3d_Projector.hxx>
77 #include <HLRAlgo_Projector.hxx>
78 #include <AIS2D_ProjShape.hxx>
79 #include <AIS2D_InteractiveContext.hxx>
80 #include <Standard_ErrorHandler.hxx>
84 extern QAViewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D();
86 extern Viewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D();
89 Standard_EXPORT Viewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D();
92 #include <GGraphic2d_SetOfCurves.hxx>
93 #include <Graphic2d_SetOfSegments.hxx>
95 #include <Graphic3d_NameOfFont.hxx>
97 static Standard_Integer BUC60842 (Draw_Interpretor& di, Standard_Integer /*argc*/,const char ** /*argv*/)
99 Standard_Character abuf[16];
100 //Standard_Character * abuf = new Standard_Character[16];
102 Standard_CString st = abuf;
104 Handle(Geom_Circle) cir = new Geom_Circle (gp_Ax2 (gp_Pnt (823.687192, 502.366825, 478.960440), gp_Dir (0.173648, 0.984808, 0.000000), gp_Dir (-0.932169, 0.164367, -0.322560)), 50);
105 Handle(Geom_Ellipse) ell = new Geom_Ellipse (gp_Ax2 (gp_Pnt (1262.224429, 425.040878, 363.609716), gp_Dir (0.173648, 0.984808, 0.000000), gp_Dir (-0.932169, 0.164367, -0.322560)), 150, 100);
106 Handle(Geom_Plane) plne = new Geom_Plane (gp_Ax3 (gp_Ax2 (gp_Pnt (1262.224429, 425.040878, 363.609716), gp_Dir (0.173648, 0.984808, 0.000000), gp_Dir (-0.932169, 0.164367, -0.322560))));
108 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
110 gp_Pln pln = plne->Pln();
111 Handle(Geom2d_Curve) curve2d = GeomAPI::To2d (ell, pln);
113 DrawTrSurf::Set(st,curve2d);
114 if(!aContext.IsNull()) {
115 Handle(AIS_Shape) aisp =
116 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(curve2d, pln)).Edge());
117 aContext->Display (aisp);
120 Handle(Geom2d_Curve) fromcurve2d = GeomAPI::To2d (cir, pln);
122 DrawTrSurf::Set(st,fromcurve2d);
123 if(!aContext.IsNull()) {
124 Handle(AIS_Shape) aisp =
125 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(fromcurve2d, pln)).Edge());
126 aContext->Display (aisp);
129 Geom2dAdaptor_Curve acur (curve2d), afromcur (fromcurve2d);
130 Geom2dGcc_QualifiedCurve qcur (acur, GccEnt_outside);
131 Geom2dGcc_QualifiedCurve qfromcur (afromcur, GccEnt_outside);
132 Geom2dGcc_Lin2d2Tan lintan (qcur, qfromcur, 0.1, 0.0, 0.0);
133 Standard_Integer i=0;
134 for(i=0;i<lintan.NbSolutions();i++) {
135 sprintf(abuf,"lintan_%d",i);
136 Handle(Geom2d_Line) glin = new Geom2d_Line(lintan.ThisSolution(i));
137 DrawTrSurf::Set(st,glin);
138 if(!aContext.IsNull()) {
139 Handle(AIS_Shape) aisp =
140 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(glin, pln)).Edge()); aContext->Display (aisp);
143 di << " Is Done = \n" << (Standard_Integer) lintan.IsDone();
147 static Standard_Integer BUC60843 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
149 if (argc != 4 && argc != 5 && argc != 6 && argc != 7) {
150 di << "Usage : " << argv[0] << "result_shape name_of_circle name_of_curve [ par1 [ tol ] ]" << "\n";
154 Standard_Real par1 = 0.0, par2 = 0.0;
155 Standard_Real tol = Precision::Angular();
157 par1 = atof(argv[4]);
159 par2 = atof(argv[5]);
162 Handle(Geom2d_Curve) aCur2d1 = DrawTrSurf::GetCurve2d(argv[2]);
163 Handle(Geom2d_Curve) aCur2d2 = DrawTrSurf::GetCurve2d(argv[3]);
164 if (aCur2d1.IsNull() || aCur2d2.IsNull()) {
165 di << "Faulty : not curves" << "\n";
168 Standard_Boolean c1IsCircle = Standard_False;
169 Handle(Geom2d_Circle) aCir2d = Handle(Geom2d_Circle)::DownCast(aCur2d1);
170 if (!aCir2d.IsNull()) {
171 c1IsCircle = Standard_True;
172 if (argc == 6) tol = atof(argv[5]);
175 Geom2dAdaptor_Curve acur(aCur2d2);
176 Geom2dGcc_MyQCurve qcur(acur, GccEnt_unqualified);
177 GccEnt_QualifiedCirc qfromcur(aCir2d->Circ2d(), GccEnt_unqualified);
178 Geom2dGcc_MyL2d2Tan lintan(qfromcur, qcur , par1, tol);
179 if (lintan.IsDone()) {
180 gp_Lin2d lin = lintan.ThisSolution();
181 Handle(Geom2d_Line) glin = new Geom2d_Line(lin);
182 DrawTrSurf::Set(argv[1], glin);
184 di << "Faulty : tangent line is not done." << "\n";
188 Geom2dAdaptor_Curve acur1(aCur2d1);
189 Geom2dAdaptor_Curve acur2(aCur2d2);
190 Geom2dGcc_MyQCurve qcur1(acur1, GccEnt_unqualified);
191 Geom2dGcc_MyQCurve qcur2(acur2, GccEnt_unqualified);
192 Geom2dGcc_MyL2d2Tan lintan(qcur1, qcur2 , par1, par2, tol);
193 if (lintan.IsDone()) {
194 gp_Lin2d lin = lintan.ThisSolution();
195 Handle(Geom2d_Line) glin = new Geom2d_Line(lin);
196 DrawTrSurf::Set(argv[1], glin);
198 di << "Faulty : tangent line is not done." << "\n";
204 static Standard_Integer BUC60970 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
208 di << "Usage : " << argv[0] << " shape result" <<"\n";
212 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
213 if(aContext.IsNull()) {
214 di << "use 'vinit' command before " << argv[0] << "\n";
218 TopoDS_Shape aResult = DBRep::Get(argv[1]);
220 BRepBuilderAPI_MakeWire bRepSpineWire;
221 TopExp_Explorer exp_(aResult, TopAbs_WIRE);
223 Standard_Integer i = 0;
224 for(;exp_.More();exp_.Next()){
226 bRepSpineWire.Add(TopoDS::Wire(exp_.Current()));
229 //printf("total no of wires are ............. %d\n", i);
230 di << "total no of wires are ............. " << i << "\n";
232 TopoDS_Wire spineWire = bRepSpineWire.Wire();
233 aContext->Display(new AIS_Shape(spineWire));
235 DBRep::Set("slineW",spineWire);
237 TopExp_Explorer spineWireExp(spineWire, TopAbs_EDGE);
238 Standard_Real first, last;
239 Handle_Geom_Curve curl_ = BRep_Tool::Curve(TopoDS::Edge(spineWireExp.Current()), first, last);
242 curl_->D1(first, firstPnt, tanVec);
244 gp_Dir tanDir(tanVec.X(), tanVec.Y(), tanVec.Z());
245 gp_Ax2 gpAx2(firstPnt, tanDir);
246 gp_Circ gpCirc(gpAx2, 2.5);
247 BRepBuilderAPI_MakeWire aMWire(BRepBuilderAPI_MakeEdge(new Geom_Circle(gpCirc)).Edge());
248 TopoDS_Wire topoWire(aMWire);
249 aContext->Display(new AIS_Shape(topoWire));
251 DBRep::Set("topoW",topoWire);
253 BRepOffsetAPI_MakePipeShell bRepPipe(spineWire);
254 bRepPipe.Add(topoWire);
257 aContext->Display(new AIS_Shape(bRepPipe.Shape()));
259 DBRep::Set(argv[2],bRepPipe.Shape());
264 static Standard_Integer BUC60818(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
268 di << "Usage : " << argv[0] << "\n";
272 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
273 if(myAISContext.IsNull())
275 di << "use 'vinit' command before " << argv[0] << "\n";
280 Handle(AIS_Trihedron) aTrihedron;
281 Handle(Geom_Axis2Placement) aTrihedronAxis=new Geom_Axis2Placement(gp::XOY());
282 aTrihedron=new AIS_Trihedron(aTrihedronAxis);
283 myAISContext->Display(aTrihedron);
285 myAISContext->OpenLocalContext();
286 myAISContext->Load(aTrihedron,0);
288 myAISContext->SetAutomaticHilight( Standard_False );
290 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
292 myV3dView->Project(0,0,0,Xv,Yv);
294 Standard_Integer Xp,Yp;
295 myV3dView->Convert(Xv,Yv,Xp,Yp);
297 myAISContext->MoveTo( Xp,Yp, myV3dView );
298 myAISContext->MoveTo( Xp,Yp, myV3dView );
300 if (myAISContext->HasDetected( ))
301 di << "has detected shape : OK" << "\n";
302 else di << "has detected shape : bugged - Faulty " << "\n";
304 myAISContext->SetAutomaticHilight( Standard_True );
309 static Standard_Integer BUC60915_1(Draw_Interpretor& di, Standard_Integer argc, const char ** /*argv*/)
312 di<<"Function don't has parameters"<<"\n";
316 Handle(AIS_InteractiveContext) context= ViewerTest_Tool::MakeContext ("buc60915");
317 ViewerTest_Tool::InitViewerTest (context);
319 //The following dimesion code has problems regarding arrow_size. The desired effect is not produced.
320 /***************************************/
322 /***************************************/
323 gp_Pnt p1 = gp_Pnt(602.51,50.,0.);
324 gp_Pnt p2 = gp_Pnt(602.51,200.,0.);
325 gp_Pnt p3 = gp_Pnt(102.51,200.,0.);
326 gp_Pnt p4 = gp_Pnt(102.51,170.,0.);
327 gp_Pnt p5 = gp_Pnt(502.51,170.,0.);
328 gp_Pnt p6 = gp_Pnt(502.51,80.,0.);
329 gp_Pnt p7 = gp_Pnt(102.51,80.,0.);
330 gp_Pnt p8 = gp_Pnt(102.51,50.,0.);
331 TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(p1);
332 TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(p2);
333 TopoDS_Vertex V3 = BRepBuilderAPI_MakeVertex(p3);
334 TopoDS_Vertex V4 = BRepBuilderAPI_MakeVertex(p4);
335 TopoDS_Vertex V5 = BRepBuilderAPI_MakeVertex(p5);
336 TopoDS_Vertex V6 = BRepBuilderAPI_MakeVertex(p6);
337 TopoDS_Vertex V7 = BRepBuilderAPI_MakeVertex(p7);
338 TopoDS_Vertex V8 = BRepBuilderAPI_MakeVertex(p8);
339 gp_Pnt plnpt(0, 0, 0);
340 gp_Dir plndir(0, 0, 1);
341 Handle(Geom_Plane) pln = new Geom_Plane(plnpt,plndir);
342 /***************************************/
343 //dimension "L 502.51"
344 /***************************************/
345 Handle(AIS_LengthDimension) len = new AIS_LengthDimension(V2, V3, pln, 502.51, "502.51");
346 len->SetPosition(gp_Pnt(350, 250, 0));
347 len->SetTypeOfDist(AIS_TOD_Horizontal);
348 len->SetArrowSize(30.0);
349 context->Display(len);
350 /***************************************/
352 /***************************************/
353 Handle(AIS_LengthDimension) len1 = new AIS_LengthDimension(V4, V7, pln, 90, "90");
354 len1->SetPosition(gp_Pnt(70, 120, 0));
355 len1->SetTypeOfDist(AIS_TOD_Vertical);
356 len1->SetArrowSize(100.0);
357 context->Display(len1);
358 /***************************************/
360 /***************************************/
361 Handle(AIS_LengthDimension) len2 = new AIS_LengthDimension(V1, V2, pln, 150, "150",gp_Pnt(650, 120, 0),DsgPrs_AS_BOTHAR,
362 AIS_TOD_Vertical, 100.0 );
363 //len2->SetPosition(gp_Pnt(650, 120, 0));
364 //len2->SetTypeOfDist(AIS_TOD_Vertical);
365 //len1->SetArrowSize(100.0);
366 context->Display(len2);
367 /***************************************/
368 //dimension "R 88.58"
369 /***************************************/
370 gp_Circ cir = gp_Circ(gp_Ax2(gp_Pnt(191.09, -88.58, 0), gp_Dir(0, 0, 1)), 88.58);
371 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(cir,gp_Pnt(191.09,0,0.),gp_Pnt(191.09,-177.16,0.) );
372 Handle(AIS_RadiusDimension) dim1 = new AIS_RadiusDimension(E1,88.58, "R 88.58",gp_Pnt(-30.0, -80.0, 0.0),DsgPrs_AS_BOTHAR,
374 context->Display(dim1);
375 /***************************************/
376 //dimension "R 43.80"
377 /***************************************/
378 gp_Circ cir1 = gp_Circ(gp_Ax2(gp_Pnt(191.09, -88.58, 0), gp_Dir(0, 0, 1)), 43.80);
379 TopoDS_Edge E_cir1 = BRepBuilderAPI_MakeEdge(cir1);
380 dim1 = new AIS_RadiusDimension(E_cir1,43.80, "R 43.80",gp_Pnt(0.0, -50.0, 0.0),DsgPrs_AS_LASTAR, 60.0 );
381 context->Display(dim1);
382 /***************************************/
383 //dimension "R 17.86"
384 /***************************************/
385 gp_Circ cir2 = gp_Circ(gp_Ax2(gp_Pnt(566.11, -88.58, 0), gp_Dir(0, 0, -1)), 17.86);
386 TopoDS_Edge E_cir2 = BRepBuilderAPI_MakeEdge(cir2);
387 dim1 = new AIS_RadiusDimension(E_cir2,17.86, "R 17.86",gp_Pnt(600.0, -50.0, 0.0),DsgPrs_AS_LASTAR, 40.0 );
388 context->Display(dim1);
393 static Standard_Integer OCC138 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
395 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
396 if(aContext.IsNull()) {
397 di << "use 'vinit' command before " << argv[0] << "\n";
401 BRepPrimAPI_MakeBox box1(gp_Pnt(0, 0, 0), gp_Pnt(100, 100, 100));
402 BRepPrimAPI_MakeBox box2(gp_Pnt(120, 120, 120), gp_Pnt(300, 300,300));
403 BRepPrimAPI_MakeBox box3(gp_Pnt(320, 320, 320), gp_Pnt(500, 500,500));
405 Handle_AIS_Shape ais1 = new AIS_Shape(box1.Shape());
406 Handle_AIS_Shape ais2 = new AIS_Shape(box2.Shape());
407 Handle_AIS_Shape ais3 = new AIS_Shape(box3.Shape());
409 aContext->Display(ais1);
410 aContext->Display(ais2);
411 aContext->Display(ais3);
413 aContext->AddOrRemoveCurrentObject(ais1);
414 aContext->AddOrRemoveCurrentObject(ais2);
415 aContext->AddOrRemoveCurrentObject(ais3);
417 di << "\n No of currents = " << aContext->NbCurrents();
419 aContext->InitCurrent();
422 while(aContext->MoreCurrent())
424 di << "\n count is = " << count++;
425 Handle_AIS_InteractiveObject ais = aContext->Current();
426 aContext->AddOrRemoveCurrentObject(ais);
427 aContext->InitCurrent();
433 static Standard_Integer BUC60821(Draw_Interpretor& di, Standard_Integer argc,const char ** argv )
437 di << "Usage: " << argv[0] << " TextHight1 TextHight2 TextHight2";
441 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
443 if(aContext.IsNull())
445 di << "use 'vinit' command before " << argv[0] << "\n";
449 Handle(QATelco_MyText) txt1 = new QATelco_MyText("Gosha1",gp_Pnt(0,0,0),Graphic3d_NOF_ASCII_SIMPLEX,Quantity_NOC_RED,atoi(argv[1]));
450 aContext->Display(txt1);
452 Handle(QATelco_MyText) txt2 = new QATelco_MyText("Gosha2",gp_Pnt(0,0,100),Graphic3d_NOF_ASCII_SIMPLEX,Quantity_NOC_YELLOW,atoi(argv[2]));
453 aContext->Display(txt2);
455 Handle(QATelco_MyText) txt3 = new QATelco_MyText("Gosha3",gp_Pnt(0,100,100),Graphic3d_NOF_ASCII_SIMPLEX,Quantity_NOC_SKYBLUE,atoi(argv[3]));
456 aContext->Display(txt3);
461 static int geom_get_2Dpt_from_3Dpt(const gp_Pnt& pnt3d, const gp_Pln& pln, gp_Pnt2d& pnt2d)
464 Handle_Geom_Plane gpln = new Geom_Plane(pln);
465 GeomAdaptor_Surface adsur(gpln);
466 Extrema_ExtPS extps(pnt3d, adsur, 0.001, 0.001);
470 for(index=1; index<= extps.NbExt(); index++ )
472 Extrema_POnSurf pons = extps.Point(index);
474 pons.Parameter(U, V);
475 pnt2d.SetCoord(U, V);
482 static Standard_Integer OCC353 (Draw_Interpretor& di, Standard_Integer , const char ** )
484 gp_Ax2 ax21( gp_Pnt(100,0,0), gp_Dir(0,0,1) );
485 Handle_Geom_Circle h_cir1 = new Geom_Circle( ax21, 25 );
487 gp_Ax2 ax22( gp_Pnt(-100,0,0), gp_Dir(0,0,1) );
488 Handle_Geom_Circle h_cir2 = new Geom_Circle( ax22, 25 );
490 gp_Pln refpln( gp_Pnt(0,0,0), gp_Dir(0,0,1) );
491 Handle_Geom2d_Curve cir2d1 = GeomAPI::To2d(h_cir1, refpln);
492 Handle_Geom2d_Curve cir2d2 = GeomAPI::To2d(h_cir2, refpln);
494 Geom2dAdaptor_Curve adop1(cir2d1);
495 Geom2dAdaptor_Curve adop2(cir2d2);
497 Geom2dGcc_QualifiedCurve qcur1(adop1, GccEnt_enclosing);
498 Geom2dGcc_QualifiedCurve qcur2(adop2, GccEnt_enclosing);
500 Handle_Geom_CartesianPoint h_carpt = new Geom_CartesianPoint(0,175,0);
502 gp_Pnt pt3d = h_carpt->Pnt();
504 geom_get_2Dpt_from_3Dpt(pt3d, refpln, pt2d);
508 DrawTrSurf::Set(st,cir2d1);
510 DrawTrSurf::Set(st,cir2d2);
512 DrawTrSurf::Set(st,pt2d);
514 Handle_Geom2d_CartesianPoint pt = new Geom2d_CartesianPoint(pt2d);
515 Geom2dGcc_Circ2d3Tan sol( qcur1, qcur2, pt, 0.001, 0.0, 0.0);
518 Standard_Character buf[10];
522 res = sol.NbSolutions();
523 for(Standard_Integer i=1;i<=res;i++) {
524 Handle(Geom2d_Circle) aC = new Geom2d_Circle(sol.ThisSolution(i));
525 sprintf(buf,"Result_%d",i);
527 DrawTrSurf::Set(st,aC);
531 di << "\n Faulty: no solutions found ";
532 //printf("\n Faulty: no solutions found ");
534 //printf("\n Num of solutions are %d ", res );
535 di << "\n Num of solutions are " << res << " ";
540 static Standard_Integer OCC280 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
542 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
543 if(aContext.IsNull())
545 di << "use 'vinit' command before " << argv[0] << "\n";
549 di << "ERROR : Usage : " << argv[0] << " hlr=0/1 setsurfecedetail=0/1; set perspecrive view" << "\n";
553 Standard_Integer HLR = atoi(argv[1]);
558 Handle(V3d_View) aView = ViewerTest::CurrentView();
560 Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
562 aViewer->SetDefaultSurfaceDetail(V3d_TEX_ALL);
564 aViewer->SetDefaultTypeOfView(V3d_PERSPECTIVE);
566 Handle(Aspect_Window) asp = aView->Window();
567 aViewer->SetViewOff(aView);
570 Handle(V3d_View) aNewView = aViewer->CreateView();
571 ViewerTest::CurrentView(aNewView);
573 aNewView->SetWindow(asp);
574 if (!asp->IsMapped()) asp->Map();
580 aNewView->SetDegenerateModeOff();
586 static Standard_Integer OCC232 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
588 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
589 if(aContext.IsNull()) {
590 di << "use 'vinit' command before " << argv[0] << "\n";
594 BRep_Builder builder;
595 TopoDS_Compound comp;
596 TopoDS_CompSolid cs1, cs2;
598 builder.MakeCompound(comp);
599 builder.MakeCompSolid(cs1);
600 builder.MakeCompSolid(cs2);
602 TopoDS_Shape sh1 = BRepPrimAPI_MakeBox(gp_Pnt(0, 0, 0), 100, 100, 100).Shape();
603 TopoDS_Shape sh2 = BRepPrimAPI_MakeBox(gp_Pnt(100, 0, 0), 100, 100, 100).Shape();
604 TopoDS_Shape sh3 = BRepPrimAPI_MakeBox(gp_Pnt(200, 0, 0), 100, 100, 100).Shape();
605 builder.Add(cs1, sh1);
606 builder.Add(cs1, sh2);
607 builder.Add(cs1, sh3);
609 TopoDS_Shape sh4 = BRepPrimAPI_MakeBox(gp_Pnt(0, 500, 0), 100, 100, 100).Shape();
610 TopoDS_Shape sh5 = BRepPrimAPI_MakeBox(gp_Pnt(100, 500, 0), 100, 100, 100).Shape();
611 TopoDS_Shape sh6 = BRepPrimAPI_MakeBox(gp_Pnt(200, 500, 0), 100, 100, 100).Shape();
613 builder.Add(cs2, sh4);
614 builder.Add(cs2, sh5);
615 builder.Add(cs2, sh6);
617 builder.Add(comp, cs1);
618 builder.Add(comp, cs2);
620 Handle_AIS_Shape ais = new AIS_Shape(comp);
621 aContext->Display(ais);
623 TopExp_Explorer exp(comp, TopAbs_COMPSOLID);
626 //printf("\n TopAbs_COMPSOLID is there \n");
627 di << "\n TopAbs_COMPSOLID is there \n";
631 Handle (StdSelect_ShapeTypeFilter) filt = new StdSelect_ShapeTypeFilter(TopAbs_COMPSOLID);
632 aContext->AddFilter(filt);
633 aContext->CloseAllContexts();
634 aContext->OpenLocalContext();
635 aContext->ActivateStandardMode(TopAbs_SOLID);
640 static Standard_Integer OCC138LC (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
642 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
643 if(aContext.IsNull()) {
644 di << "use 'vinit' command before " << argv[0] << "\n";
648 BRepPrimAPI_MakeBox box1(gp_Pnt(0, 0, 0), gp_Pnt(100, 100, 100));
649 BRepPrimAPI_MakeBox box2(gp_Pnt(120, 120, 120), gp_Pnt(300, 300,300));
650 BRepPrimAPI_MakeBox box3(gp_Pnt(320, 320, 320), gp_Pnt(500, 500,500));
652 Handle_AIS_Shape ais1 = new AIS_Shape(box1.Shape());
653 Handle_AIS_Shape ais2 = new AIS_Shape(box2.Shape());
654 Handle_AIS_Shape ais3 = new AIS_Shape(box3.Shape());
656 aContext->Display(ais1);
657 aContext->Display(ais2);
658 aContext->Display(ais3);
660 aContext->AddOrRemoveSelected(ais1);
661 aContext->AddOrRemoveSelected(ais2);
662 aContext->AddOrRemoveSelected(ais3);
664 di << "\n No of selected = " << aContext->NbSelected();
666 aContext->InitSelected();
669 while(aContext->MoreSelected())
671 di << "\n count is = %d" << count++;
672 Handle_AIS_InteractiveObject ais = aContext->SelectedInteractive();
673 aContext->AddOrRemoveSelected(ais);
674 aContext->InitSelected();
680 static Standard_Integer OCC189 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
682 Handle(AIS_InteractiveContext) aContext1 = ViewerTest::GetAISContext();
683 if(aContext1.IsNull()) {
684 di << "use 'vinit' command before " << argv[0] << "\n";
687 Handle(AIS_InteractiveContext) aContext2 = ViewerTest::GetAISContext();
688 if(aContext2.IsNull()) {
689 di << "use 'vinit' command before " << argv[0] << "\n";
693 BRepPrimAPI_MakeBox box1(gp_Pnt(0, 0, 0), gp_Pnt(100, 100, 100));
694 BRepPrimAPI_MakeBox box2(gp_Pnt(120, 120, 120), gp_Pnt(300, 300, 300));
695 BRepPrimAPI_MakeBox box3(gp_Pnt(320, 320, 320), gp_Pnt(500, 500, 500));
697 Handle_AIS_Shape ais1 = new AIS_Shape(box1.Shape());
698 Handle_AIS_Shape ais2 = new AIS_Shape(box2.Shape());
699 Handle_AIS_Shape ais3 = new AIS_Shape(box3.Shape());
701 aContext1->Display(ais1);
702 aContext1->Display(ais2);
703 aContext1->Display(ais3);
705 aContext2->Display(ais1);
706 aContext2->Display(ais2);
707 aContext2->Display(ais3);
709 aContext1->AddOrRemoveCurrentObject(ais1);
710 aContext1->AddOrRemoveCurrentObject(ais2);
711 aContext1->AddOrRemoveCurrentObject(ais3);
713 di << "\n Stage : 1";
714 di << "\n \t No of currents on aContext1 = " << aContext1->NbCurrents();
715 di << "\n \t No of currents on aContext2 = " << aContext2->NbCurrents() << "\n\n";
717 di << "\n aContext1->IsCurrent = " << (Standard_Integer) aContext1->IsCurrent(ais1) << ", aContext2->IsCurrent = " << (Standard_Integer) aContext2->IsCurrent(ais1) << " ";
719 aContext2->AddOrRemoveCurrentObject(ais1);
720 aContext2->AddOrRemoveCurrentObject(ais2);
721 aContext2->AddOrRemoveCurrentObject(ais3);
723 di << "\n Stage : 2";
724 di << "\n \t No of currents on aContext1 = " << aContext1->NbCurrents();
725 di << "\n \t No of currents on aContext2 = " << aContext2->NbCurrents() << "\n\n";
727 aContext1->InitCurrent();
729 while(aContext1->MoreCurrent())
731 di << "\n count1 is = " << count1++;
732 Handle_AIS_InteractiveObject ais = aContext1->Current();
733 aContext1->AddOrRemoveCurrentObject(ais);
734 aContext1->InitCurrent();
737 di << "\n Stage : 3";
738 di << "\n \t No of currents on aContext1 = " << aContext1->NbCurrents();
739 di << "\n \t No of currents on aContext2 = " << aContext2->NbCurrents() << "\n\n";
741 aContext2->InitCurrent();
743 while(aContext2->MoreCurrent())
745 di << "\n count2 is = " << count2++;
746 Handle_AIS_InteractiveObject ais = aContext2->Current();
747 aContext2->AddOrRemoveCurrentObject(ais);
748 aContext2->InitCurrent();
751 di << "\n\n Stage : 4";
752 di << "\n \t No of currents on aContext1 = " << aContext1->NbCurrents();
753 di << "\n \t No of currents on aContext2 = " << aContext2->NbCurrents();
758 static Standard_Integer OCC389 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
762 di<<"Usage: " << argv[0] << " name shape1 [shape2] ..."<<"\n";
766 //if (Viewer2dTest::CurrentView().IsNull())
768 // cout << "2D AIS Viewer Initialization ..." << endl;
769 // Viewer2dTest::ViewerInit();
770 // cout << "Done" << endl;
774 Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
775 di<<"Check InteractiveContext"<<"\n";
777 if(aContext.IsNull()) {
778 di << "use 'v2dinit' command before " << argv[0] << "\n";
782 di<<"CloseLocalContext"<<"\n";
783 aContext->CloseLocalContext();
785 di<<"OpenLocalContext"<<"\n";
786 aContext->OpenLocalContext();
788 TCollection_AsciiString name(argv[1]);
790 di<<"Found name"<<"\n";
791 Standard_Boolean IsBound = GetMapOfAIS2D().IsBound2(name);
794 di<<"Already displayed"<<"\n";
796 else // Create the AIS2D_ProjShape from a name
798 di<<"Create the AIS2D_ProjShape from a name; (1)"<<"\n";
799 Prs3d_Projector aPrs3dProjector(Standard_False, 1, -1.0,0.2,0.3, 0.0, 0.0, 0.0, -0.0,0.0,1.0);
800 di<<"Create the AIS2D_ProjShape from a name; (2)"<<"\n";
801 HLRAlgo_Projector aProjector = aPrs3dProjector.Projector();
802 di<<"Create the AIS2D_ProjShape from a name; (3)"<<"\n";
803 Handle(AIS2D_ProjShape) shp_2d =
804 new AIS2D_ProjShape(aProjector, 0, Standard_False, Standard_True);
805 di<<"Create the AIS2D_ProjShape from a name; (4)"<<"\n";
808 Standard_Boolean isValid = Standard_False;
809 for (i = 2; i < argc; i++)
811 di<<"i="<< i-1 <<"\n";
812 TopoDS_Shape aShape = DBRep::Get(argv[i]);
813 if (!aShape.IsNull())
815 shp_2d->Add( aShape );
816 di<<"Added shape: "<<argv[i]<<"\n";
817 isValid = Standard_True;
823 di<<"Now start displaying..."<<"\n";
824 aContext->Display(shp_2d, 1, 1, Standard_True);
826 GetMapOfAIS2D().Bind(shp_2d, name);
830 aContext->UpdateCurrentViewer();
834 #include <BRepBndLib.hxx>
836 //=======================================================================
839 //=======================================================================
840 static Standard_Integer OCC566(Draw_Interpretor& di,Standard_Integer n,const char ** a)
843 di<<"Usage: " << a[0] << " shape [ xmin ymin zmin xmax ymax zmax]"<<"\n";
846 TopoDS_Shape S = DBRep::Get(a[1]);
847 if (S.IsNull()) return 1;
849 BRepBndLib::AddClose(S,B);
850 Standard_Real axmin,aymin,azmin,axmax,aymax,azmax;
851 B.Get(axmin,aymin,azmin,axmax,aymax,azmax);
852 di << axmin<<" "<< aymin<<" "<< azmin<<" "<< axmax<<" "<< aymax<<" "<< azmax;
854 Draw::Set(a[2],axmin) ;
855 Draw::Set(a[3],aymin) ;
856 Draw::Set(a[4],azmin) ;
857 Draw::Set(a[5],axmax) ;
858 Draw::Set(a[6],aymax) ;
859 Draw::Set(a[7],azmax) ;
864 #include <BRepFilletAPI_MakeFillet.hxx>
865 //=======================================================================
868 //=======================================================================
869 static Standard_Integer OCC570 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
872 di<<"Usage: " << argv[0] << " result"<<"\n";
876 BRepPrimAPI_MakeBox mkBox(100.,100.,100.);
877 TopoDS_Shape aBox = mkBox.Shape();
879 TopExp_Explorer aExp;
880 aExp.Init(aBox,TopAbs_WIRE);
883 TopoDS_Shape aWire = aExp.Current();
885 aExp.Init(aWire,TopAbs_EDGE);
886 TopoDS_Edge e1 = TopoDS::Edge(aExp.Current()); aExp.Next();
887 TopoDS_Edge e2 = TopoDS::Edge(aExp.Current()); aExp.Next();
888 TopoDS_Edge e3 = TopoDS::Edge(aExp.Current()); aExp.Next();
889 TopoDS_Edge e4 = TopoDS::Edge(aExp.Current());
894 BRepFilletAPI_MakeFillet mkFillet(aBox);
895 mkFillet.SetContinuity(GeomAbs_C1,.001);
897 // Setup variable fillet data
898 TColgp_Array1OfPnt2d t_pnt(1,4);
899 t_pnt.SetValue(1,gp_Pnt2d(0.0,5.0));
900 t_pnt.SetValue(2,gp_Pnt2d(0.3,15.0));
901 t_pnt.SetValue(3,gp_Pnt2d(0.7,15.0));
902 t_pnt.SetValue(4,gp_Pnt2d(1.0,5.0));
905 // It is impossible to build fillet if at least one edge
906 // with variable radius is added!!! If all are constant, everything is ok.
907 mkFillet.Add(t_pnt,e1);
908 mkFillet.Add(5.0,e2);
909 mkFillet.Add(t_pnt,e3);
910 mkFillet.Add(5.0,e4);
913 TopoDS_Shape aFinalShape = mkFillet.Shape();
915 DBRep::Set(argv[1],aFinalShape);
917 catch(Standard_Failure)
919 di << argv[0] << ": Exception in fillet"<<"\n";
927 #include <Law_Interpol.hxx>
929 static Standard_Real t3d = 1.e-4;
930 static Standard_Real t2d = 1.e-5;
931 static Standard_Real ta = 1.e-2;
932 static Standard_Real fl = 1.e-3;
933 static Standard_Real tapp_angle = 1.e-2;
934 static GeomAbs_Shape blend_cont = GeomAbs_C1;
936 static BRepFilletAPI_MakeFillet* Rakk = 0;
937 static BRepFilletAPI_MakeFillet* Rake = 0;
938 static char name[100];
940 static void printtolblend(Draw_Interpretor& di)
942 di<<"tolerance ang : "<<ta<<"\n";
943 di<<"tolerance 3d : "<<t3d<<"\n";
944 di<<"tolerance 2d : "<<t2d<<"\n";
945 di<<"fleche : "<<fl<<"\n";
947 di<<"tolblend "<<ta<<" "<<t3d<<" "<<t2d<<" "<<fl<<"\n";
950 static Standard_Integer MKEVOL(Draw_Interpretor& di,
951 Standard_Integer narg,
954 if(Rake != 0) {delete Rake; Rake = 0;}
956 if (narg < 3) return 1;
957 TopoDS_Shape V = DBRep::Get(a[2]);
958 Rake = new BRepFilletAPI_MakeFillet(V);
959 Rake->SetParams(ta,t3d,t2d,t3d,t2d,fl);
960 Rake->SetContinuity(blend_cont, tapp_angle);
962 ChFi3d_FilletShape FSh = ChFi3d_Rational;
963 if (!strcasecmp(a[3], "Q")) {
964 FSh = ChFi3d_QuasiAngular;
966 else if (!strcasecmp(a[3], "P")) {
967 FSh = ChFi3d_Polynomial;
969 Rake->SetFilletShape(FSh);
975 static Standard_Integer UPDATEVOL(Draw_Interpretor& di,
976 Standard_Integer narg,
980 di << "MakeFillet non initialise"<<"\n";
983 if(narg%2 != 0 || narg < 4) return 1;
984 TColgp_Array1OfPnt2d uandr(1,(narg/2)-1);
985 Standard_Real Rad, Par;
986 TopoDS_Shape aLocalEdge(DBRep::Get(a[1],TopAbs_EDGE));
987 TopoDS_Edge E = TopoDS::Edge(aLocalEdge);
988 for (Standard_Integer ii = 1; ii <= (narg/2)-1; ii++){
990 Rad = atof(a[2*ii + 1]);
991 uandr.ChangeValue(ii).SetCoord(Par,Rad);
993 //HELPDESK: Add law creation
994 const Standard_Boolean aLawMode = !strcmp(a[0],"OCC570evollaw");
997 di<<"INFO: Using law to define variable fillet"<<"\n";
998 Handle(Law_Interpol) law = new Law_Interpol;
1008 static Standard_Integer BUILDEVOL(Draw_Interpretor& di,
1013 di << "MakeFillet non initialise"<<"\n";
1018 TopoDS_Shape result = Rake->Shape();
1019 DBRep::Set(name,result);
1020 if(Rake != 0) {delete Rake; Rake = 0;}
1023 if(Rake != 0) {delete Rake; Rake = 0;}
1027 #include <TColGeom_SequenceOfCurve.hxx>
1028 #include <Geom_TrimmedCurve.hxx>
1029 #include <GeomFill_NSections.hxx>
1030 #include <BRepBuilderAPI_MakeFace.hxx>
1031 //=======================================================================
1034 //=======================================================================
1035 static Standard_Integer OCC606 ( Draw_Interpretor& di, Standard_Integer n, const char ** a )
1037 if (n != 3 && n != 4)
1039 di << "Usage : " << a[0] << " result shape [-t]" << "\n";
1043 Standard_Boolean TrimMode = (n == 4);
1044 if (TrimMode) di<<"INFO: Using trimmed curves..."<<"\n";
1045 else di<<"INFO: Using non trimmed curves..."<<"\n";
1047 TopoDS_Shape S = DBRep::Get(a[2]);
1049 TopExp_Explorer t_exp(S,TopAbs_EDGE);
1050 TColGeom_SequenceOfCurve n_curves1;
1051 TColStd_SequenceOfReal np;
1052 Standard_Real param = 5.0;
1054 for (;t_exp.More();t_exp.Next())
1057 Handle(Geom_Curve) h_cur = BRep_Tool::Curve(TopoDS::Edge(t_exp.Current()),f,l);
1058 if (!h_cur.IsNull())
1060 if (TrimMode) h_cur = new Geom_TrimmedCurve(h_cur,f,l);
1062 n_curves1.Append(h_cur);
1068 if (n_curves1.Length()>1 && !np.IsEmpty())
1073 GeomFill_NSections b_surface1(n_curves1, np);
1074 b_surface1.ComputeSurface();
1075 Handle(Geom_BSplineSurface) result_surf1 = b_surface1.BSplineSurface();
1076 if (!result_surf1.IsNull())
1078 BRepBuilderAPI_MakeFace b_face1(result_surf1);
1079 TopoDS_Face bsp_face1 = b_face1.Face();
1080 DBRep::Set(a[1],bsp_face1);
1083 catch(Standard_Failure)
1085 di<<"ERROR: Exception in GeomFill_NSections"<<"\n";
1093 //=======================================================================
1096 //=======================================================================
1097 static Standard_Integer OCC813 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
1101 di << "Usage : " << argv[0] << " U V" << "\n";
1105 Standard_CString str;
1106 Standard_Real U = atof(argv[1]);
1107 Standard_Real V = atof(argv[2]);
1109 //Between ellipse and point:
1111 Handle(Geom_Ellipse) ell = new Geom_Ellipse(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
1112 gp_Dir(0.173648,0.984808,0.000000),
1113 gp_Dir(-0.932169,0.164367,-0.322560)), 150, 100);
1114 Handle(Geom_Plane) plne = new Geom_Plane(gp_Ax3(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
1115 gp_Dir(0.173648,0.984808,0.000000),
1116 gp_Dir(-0.932169,0.164367,-0.322560))) );
1118 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1121 gp_Pln pln = plne->Pln();
1123 str = "OCC813_pnt"; DrawTrSurf::Set(str,pt2d);
1125 Handle(Geom2d_Curve) curve2d = GeomAPI::To2d(ell,pln);
1126 Geom2dAdaptor_Curve acur(curve2d);
1127 Geom2dGcc_QualifiedCurve qcur(acur, GccEnt_outside);
1129 str = "OCC813_ell"; DrawTrSurf::Set(str,curve2d);
1130 if(!aContext.IsNull()) {
1131 Handle(AIS_Shape) aisp =
1132 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(curve2d, pln)).Edge());
1133 aContext->Display (aisp);
1136 //This does not give any solutions.
1137 Geom2dGcc_Lin2d2Tan lintan(qcur, pt2d, 0.1);
1138 di<<"OCC813 nb of solutions = "<<lintan.NbSolutions()<<"\n";
1140 Standard_Character abuf[16];
1141 Standard_CString st = abuf;
1144 for(i=1;i<=lintan.NbSolutions();i++) {
1145 sprintf(abuf,"lintan_%d",i);
1146 Handle(Geom2d_Line) glin = new Geom2d_Line(lintan.ThisSolution(i));
1147 DrawTrSurf::Set(st,glin);
1148 if(!aContext.IsNull()) {
1149 Handle(AIS_Shape) aisp =
1150 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(glin, pln)).Edge()); aContext->Display (aisp);
1157 //=======================================================================
1160 //=======================================================================
1161 static Standard_Integer OCC814 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
1165 di << "Usage : " << argv[0] << "\n";
1169 Standard_CString str;
1171 //Between Ellipse and Circle:
1173 Handle(Geom_Circle) cir = new Geom_Circle(gp_Ax2(gp_Pnt(823.687192,502.366825,478.960440),
1174 gp_Dir(0.173648,0.984808,0.000000),
1175 gp_Dir(-0.932169,0.164367,-0.322560)), 50);
1176 Handle(Geom_Ellipse) ell = new Geom_Ellipse(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
1177 gp_Dir(0.173648,0.984808,0.000000),
1178 gp_Dir(-0.932169,0.164367,-0.322560)), 150, 100);
1179 Handle(Geom_Plane) plne = new Geom_Plane(gp_Ax3(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
1180 gp_Dir(0.173648,0.984808,0.000000),
1181 gp_Dir(-0.932169,0.164367,-0.322560))) );
1183 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1185 gp_Pln pln = plne->Pln();
1186 Handle(Geom2d_Curve) curve2d = GeomAPI::To2d(ell, pln);
1187 Handle(Geom2d_Curve) fromcurve2d = GeomAPI::To2d(cir, pln);
1189 str = "OCC814_cir"; DrawTrSurf::Set(str,curve2d);
1190 str = "OCC814_ell"; DrawTrSurf::Set(str,fromcurve2d);
1191 if(!aContext.IsNull()) {
1192 Handle(AIS_Shape) aisp =
1193 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(curve2d, pln)).Edge());
1194 aContext->Display (aisp);
1196 if(!aContext.IsNull()) {
1197 Handle(AIS_Shape) aisp =
1198 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(fromcurve2d, pln)).Edge());
1199 aContext->Display (aisp);
1202 Geom2dAdaptor_Curve acur(curve2d), afromcur(fromcurve2d);
1204 Geom2dGcc_QualifiedCurve qcur(acur, GccEnt_outside) ;
1205 Geom2dGcc_QualifiedCurve qfromcur(afromcur, GccEnt_outside) ;
1207 //This does not give any solutions.
1208 Geom2dGcc_Lin2d2Tan lintan(qcur, qfromcur, 0.1);
1209 di<<"OCC814 nb of solutions = "<<lintan.NbSolutions()<<"\n";
1211 Standard_Character abuf[16];
1212 Standard_CString st = abuf;
1215 for(i=1;i<=lintan.NbSolutions();i++) {
1216 sprintf(abuf,"lintan_%d",i);
1217 Handle(Geom2d_Line) glin = new Geom2d_Line(lintan.ThisSolution(i));
1218 DrawTrSurf::Set(st,glin);
1219 if(!aContext.IsNull()) {
1220 Handle(AIS_Shape) aisp =
1221 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(glin, pln)).Edge()); aContext->Display (aisp);
1228 #include <ShapeAnalysis_Wire.hxx>
1229 #include <IntRes2d_SequenceOfIntersectionPoint.hxx>
1230 #include <TColgp_SequenceOfPnt.hxx>
1231 #include <ShapeFix_Wire.hxx>
1232 //=======================================================================
1235 //=======================================================================
1236 static Standard_Integer OCC884 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1238 if (argc < 3 || argc > 5)
1240 di << "Usage : " << argv[0] << " result shape [toler [maxtoler]]" << "\n";
1244 TopoDS_Shape shape = DBRep::Get(argv[2]); //read the shape
1246 TopExp_Explorer exp(shape, TopAbs_EDGE);
1249 di<<"Error: no edge found"<<"\n";
1253 BRep_Builder builder;
1255 builder.MakeWire(wire);
1256 builder.Add(wire, TopoDS::Edge(exp.Current()));
1258 // HelpDesk: Create planar face if possible
1259 TopoDS_Face face = BRepBuilderAPI_MakeFace(wire,Standard_True);
1261 Handle(ShapeAnalysis_Wire) advWA = new ShapeAnalysis_Wire;
1263 advWA->SetFace(face);
1264 advWA->SetPrecision(0.001);
1266 IntRes2d_SequenceOfIntersectionPoint points2d;
1267 TColgp_SequenceOfPnt points3d;
1269 di << "Info: CheckSelfIntersectingEdge = " << (Standard_Integer) advWA->CheckSelfIntersectingEdge(1,points2d,points3d) << "\n";
1271 ShapeExtend_Status status = ShapeExtend_FAIL1;
1272 if (advWA->StatusSelfIntersection(status))
1273 di << "Info: No P Curve found in the edge\n";
1275 status = ShapeExtend_FAIL2;
1276 if (advWA->StatusSelfIntersection(status))
1277 di << "Info: No Vertices found in the edge\n";
1279 status = ShapeExtend_DONE1;
1280 if (advWA->StatusSelfIntersection(status))
1281 di << "Info: Self-intersection found in the edge\n";
1283 Standard_Integer i, num = points2d.Length();
1284 di << "Info: No. of self-intersection points : " << num << "\n";
1287 Standard_CString name = str;
1288 for (i = 1; i <= num; ++i)
1290 gp_Pnt pt = points3d(i);
1291 di << "Info: Intersecting pt : (" << pt.X() << ", " << pt.Y() << ", " << pt.Z() << ")\n";
1292 sprintf(str,"p_%d",i);
1293 DrawTrSurf::Set(name,pt);
1296 Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire;
1300 if (argc > 3) sfw->SetPrecision(atof(argv[3])/*0.1*/);
1301 if (argc > 4) sfw->SetMaxTolerance(atof(argv[4]));
1302 di << "Info: Precision is set to " << sfw->Precision() << "\n";
1303 di << "Info: MaxTolerance is set to " << sfw->MaxTolerance() << "\n";
1305 sfw->ModifyTopologyMode() = 1;
1306 sfw->ModifyGeometryMode() = 1;
1307 sfw->FixSelfIntersectingEdgeMode() = 1;
1308 //printf("Info: FixSelfIntersection = %d\n",sfw->FixSelfIntersection());
1309 di << "Info: FixSelfIntersection = " << (Standard_Integer) sfw->FixSelfIntersection() << "\n";
1311 DBRep::Set(argv[1],sfw->Wire());
1313 status = ShapeExtend_OK;
1314 if (sfw->StatusSelfIntersection(status))
1315 di << "Info: ShapeExtend_OK : No intersection found\n";
1316 //printf("Info: ShapeExtend_OK : No intersection found\n");
1318 status = ShapeExtend_FAIL1;
1319 if (sfw->StatusSelfIntersection(status))
1320 di << "Info: ShapeExtend_FAIL1 : analysis failed (edge has no pcurve, or no vertices etc.)\n";
1322 status = ShapeExtend_FAIL2;
1323 if (sfw->StatusSelfIntersection(status))
1324 di << "Info: ShapeExtend_FAIL2 : self-intersection was found, but not fixed because of limit of increasing tolerance (MaxTolerance)\n";
1326 status = ShapeExtend_FAIL3;
1327 if (sfw->StatusSelfIntersection(status))
1328 di << "Info: ShapeExtend_FAIL3 : intercestion of non adjacent edges found, but not fixed because of limit of increasing tolerance (MaxTolerance)\n";
1330 status = ShapeExtend_DONE1;
1331 if (sfw->StatusSelfIntersection(status))
1332 di << "Info: ShapeExtend_DONE1 : tolerance of vertex was increased to fix self-intersection\n";
1334 status = ShapeExtend_DONE2;
1335 if (sfw->StatusSelfIntersection(status))
1336 di << "Info: ShapeExtend_DONE2 : vertex was moved to fix self-intersection\n";
1338 status = ShapeExtend_DONE3;
1339 if (sfw->StatusSelfIntersection(status))
1340 di << "Info: ShapeExtend_DONE3 : some edges were removed because of intersection\n";
1342 status = ShapeExtend_DONE4;
1343 if (sfw->StatusSelfIntersection(status))
1344 di << "Info: ShapeExtend_DONE4 : pcurve(s) was(were) modified\n";
1346 status = ShapeExtend_DONE5;
1347 if (sfw->StatusSelfIntersection(status))
1348 di << "Info: ShapeExtend_DONE5 : non adjacent intersection fixed by increasing tolerance of vertex(vertices)\n";
1350 status = ShapeExtend_DONE6;
1351 if (sfw->StatusSelfIntersection(status))
1352 di << "Info: ShapeExtend_DONE6 : tolerance of edge was increased to hide intersection\n";
1354 status = ShapeExtend_DONE7;
1355 if (sfw->StatusSelfIntersection(status))
1356 di << "Info: ShapeExtend_DONE7 : range of some edges was decreased to avoid intersection\n";
1361 #include <Aspect_FillMethod.hxx>
1362 //=======================================================================
1363 //function : OCC1188
1365 //=======================================================================
1366 static Standard_Integer OCC1188 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1368 if (argc < 2 || argc > 3)
1370 di << "Usage : " << argv[0] << " imagefile [filltype] : Load image as background" << "\n";
1374 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1375 if(AISContext.IsNull())
1377 di << "use 'vinit' command before " << argv[0] << "\n";
1381 Aspect_FillMethod aFillType = Aspect_FM_CENTERED;
1384 const char* szType = argv[2];
1385 if (strcmp(szType, "NONE" ) == 0) aFillType = Aspect_FM_NONE;
1386 else if (strcmp(szType, "CENTERED") == 0) aFillType = Aspect_FM_CENTERED;
1387 else if (strcmp(szType, "TILED" ) == 0) aFillType = Aspect_FM_TILED;
1388 else if (strcmp(szType, "STRETCH" ) == 0) aFillType = Aspect_FM_STRETCH;
1391 di << "Wrong fill type : " << szType << "\n";
1392 di << "Must be one of CENTERED, TILED, STRETCH, NONE" << "\n";
1397 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
1398 V3dView->SetBackgroundImage(argv[1], aFillType, Standard_True);
1403 #include <AIS_Drawer.hxx>
1404 #include <Graphic3d_MaterialAspect.hxx>
1405 #include <Prs3d_ShadingAspect.hxx>
1406 //=======================================================================
1407 //function : OCC1174_1
1409 //=======================================================================
1410 static Standard_Integer OCC1174_1 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1414 di << "Usage : " << argv[0] << " shape" << "\n";
1418 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1419 if(AISContext.IsNull())
1421 di << "use 'vinit' command before " << argv[0] << "\n";
1425 TopoDS_Shape sh = DBRep::Get(argv[1]);
1427 Handle(AIS_Shape) ais = new AIS_Shape(sh);
1429 Quantity_Color colf(0.0, 0.4, 0.0, Quantity_TOC_RGB);
1430 Quantity_Color colb(0.0, 0.0, 0.6, Quantity_TOC_RGB);
1432 Handle(Prs3d_ShadingAspect) sa = ais->Attributes()->ShadingAspect();
1434 Graphic3d_MaterialAspect front = sa->Material(Aspect_TOFM_FRONT_SIDE);
1435 front.SetAmbientColor(colf);
1436 front.SetDiffuseColor(colf);
1437 front.SetSpecularColor(colf);
1438 front.SetEmissiveColor(colf);
1439 front.SetTransparency(0.0);
1440 sa->SetMaterial(front,Aspect_TOFM_FRONT_SIDE);
1442 Graphic3d_MaterialAspect back = sa->Material(Aspect_TOFM_BACK_SIDE);
1443 back.SetAmbientColor(colb);
1444 back.SetDiffuseColor(colb);
1445 back.SetSpecularColor(colb);
1446 back.SetEmissiveColor(colb);
1447 back.SetTransparency(0.0);
1448 sa->SetMaterial(back,Aspect_TOFM_BACK_SIDE);
1450 AISContext->Display(ais,1,0);
1452 Standard_Real r, g, b;
1453 sa->Color(Aspect_TOFM_FRONT_SIDE).Values(r,g,b, Quantity_TOC_RGB);
1454 di << "Info: color on front side (" << r << "," << g << "," << b << ")\n";
1455 sa->Color(Aspect_TOFM_BACK_SIDE).Values(r,g,b, Quantity_TOC_RGB);
1456 di << "Info: color on back side (" << r << "," << g << "," << b << ")\n";
1461 //=======================================================================
1462 //function : OCC1174_2
1464 //=======================================================================
1465 static Standard_Integer OCC1174_2 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1469 di << "Usage : " << argv[0] << " shape" << "\n";
1473 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1474 if(AISContext.IsNull())
1476 di << "use 'vinit' command before " << argv[0] << "\n";
1480 TopoDS_Shape sh = DBRep::Get(argv[1]);
1482 Handle(AIS_Shape) ais = new AIS_Shape(sh);
1483 AISContext->Display(ais,1,0);
1484 AISContext->SetMaterial(ais,Graphic3d_NOM_SHINY_PLASTIC);
1486 Quantity_Color colf(0.0, 0.4, 0.0, Quantity_TOC_RGB);
1487 Quantity_Color colb(0.0, 0.0, 0.6, Quantity_TOC_RGB);
1488 Handle(Prs3d_ShadingAspect) sa = ais->Attributes()->ShadingAspect();
1490 Graphic3d_MaterialAspect front = sa->Material(Aspect_TOFM_FRONT_SIDE);
1491 front.SetAmbientColor(colf);
1492 front.SetDiffuseColor(colf);
1493 front.SetSpecularColor(colf);
1494 front.SetEmissiveColor(colf);
1495 front.SetTransparency(0.4);
1496 sa->SetMaterial(front,Aspect_TOFM_FRONT_SIDE);
1498 Graphic3d_MaterialAspect back = sa->Material(Aspect_TOFM_BACK_SIDE);
1499 back.SetAmbientColor(colb);
1500 back.SetDiffuseColor(colb);
1501 back.SetSpecularColor(colb);
1502 back.SetEmissiveColor(colb);
1503 back.SetTransparency(0.2);
1504 sa->SetMaterial(back,Aspect_TOFM_BACK_SIDE);
1506 AISContext->Redisplay(ais,1,0);
1511 #include <Graphic2d_Segment.hxx>
1512 #include <Prs2d_Length.hxx>
1513 #include <Prs2d_AspectLine.hxx>
1514 #include <AIS2D_InteractiveObject.hxx>
1515 //=======================================================================
1520 // OCC672_ShortLength
1521 //=======================================================================
1523 static Standard_Integer OCC672_Length (Draw_Interpretor& di, Standard_Integer n,const char ** argv)
1526 di << " wrong parameters !\n";
1527 di << "must be : OCC672_Length x1 y1 x2 y2 str scale_text length_dist angle_arrow length_arrow x3 y3 x4 y4 TxtAngle TxtPosH TxtPosV\n";
1531 Standard_Real x1=atof(argv[1]);
1532 Standard_Real y1=atof(argv[2]);
1533 Standard_Real x2=atof(argv[3]);
1534 Standard_Real y2=atof(argv[4]);
1535 Standard_Real x3=atof(argv[10]);
1536 Standard_Real y3=atof(argv[11]);
1537 Standard_Real x4=atof(argv[12]);
1538 Standard_Real y4=atof(argv[13]);
1539 Standard_Real txtAngle=atof(argv[14]);
1540 Standard_Real txtPosH=atof(argv[15]);
1541 Standard_Real txtPosV=atof(argv[16]);
1544 Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
1545 di<<"Check InteractiveContext\n";
1547 if(aContext.IsNull()) {
1548 di << "use 'v2dinit' command before " << argv[0] << "\n";
1552 di<<"CloseLocalContext\n";
1553 aContext->CloseLocalContext();
1555 di<<"OpenLocalContext\n";
1556 aContext->OpenLocalContext();
1558 Handle(AIS2D_InteractiveObject) aIO10 = new AIS2D_InteractiveObject();
1559 Handle(Graphic2d_Segment) theSegmA, theSegmB, theSegmC, theSegmD;
1561 theSegmA = new Graphic2d_Segment( aIO10, x1, y1, x2, y2 );
1562 theSegmB = new Graphic2d_Segment( aIO10, x2, y2, x3, y3 );
1563 theSegmC = new Graphic2d_Segment( aIO10, x3, y3, x4, y4 );
1564 theSegmD = new Graphic2d_Segment( aIO10, x4, y4, x1, y1 );
1566 aContext->Display( aIO10, Standard_True );
1568 Handle(Prs2d_Length) length = new Prs2d_Length(aIO10, gp_Pnt2d(x1, y1), gp_Pnt2d(x2, y2), argv[5],
1569 atof(argv[6]), atof(argv[7]), Prs2d_TOD_AUTOMATIC,
1570 atof(argv[8]), atof(argv[9]), Prs2d_TOA_FILLED,
1573 length->SetTextRelPos(txtPosH,txtPosV);
1574 length->SetTextRelAngle(txtAngle);
1576 Handle(Prs2d_AspectLine) theAspect = new Prs2d_AspectLine(Quantity_NOC_WHITE,
1577 Aspect_TOL_SOLID, Aspect_WOL_THIN);
1578 aIO10->SetAspect( theAspect, length);
1579 aContext->Display( aIO10, Standard_True );
1581 Handle(Prs2d_Length) lengthB = new Prs2d_Length(aIO10, gp_Pnt2d(x2, y2), gp_Pnt2d(x3, y3), argv[5],
1582 atof(argv[6]), atof(argv[7]), Prs2d_TOD_AUTOMATIC,
1583 atof(argv[8]), atof(argv[9]), Prs2d_TOA_FILLED,
1586 lengthB->SetTextRelPos(txtPosH,txtPosV);
1587 lengthB->SetTextRelAngle(txtAngle);
1589 aIO10->SetAspect( theAspect, lengthB);
1590 aContext->Display( aIO10, Standard_True );
1592 Handle(Prs2d_Length) lengthC = new Prs2d_Length(aIO10, gp_Pnt2d(x3, y3), gp_Pnt2d(x4, y4), argv[5],
1593 atof(argv[6]), atof(argv[7]), Prs2d_TOD_AUTOMATIC,
1594 atof(argv[8]), atof(argv[9]), Prs2d_TOA_FILLED,
1597 lengthC->SetTextRelPos(txtPosH,txtPosV);
1598 lengthC->SetTextRelAngle(txtAngle);
1600 aIO10->SetAspect( theAspect, lengthC);
1601 aContext->Display( aIO10, Standard_True );
1603 Handle(Prs2d_Length) lengthD = new Prs2d_Length(aIO10, gp_Pnt2d(x4, y4), gp_Pnt2d(x1, y1), argv[5],
1604 atof(argv[6]), atof(argv[7]), Prs2d_TOD_AUTOMATIC,
1605 atof(argv[8]), atof(argv[9]), Prs2d_TOA_FILLED,
1608 lengthD->SetTextRelPos(txtPosH,txtPosV);
1609 lengthD->SetTextRelAngle(txtAngle);
1611 aIO10->SetAspect( theAspect, lengthD);
1612 aContext->Display( aIO10, Standard_True );
1616 #include <Prs2d_Angle.hxx>
1617 static Standard_Integer OCC672_Angle (Draw_Interpretor& di, Standard_Integer n,const char ** argv)
1620 di << "Wrong parameters !\n";
1621 di << "must be : OCC672_Angle x1 y1 x2 y2 x3 y3 aRadius aText aTxtScale anArrAngle anArrLength txtAngle txtPosH txtPosV \n";
1625 Standard_Real x1=atof(argv[1]);
1626 Standard_Real y1=atof(argv[2]);
1627 Standard_Real x2=atof(argv[3]);
1628 Standard_Real y2=atof(argv[4]);
1629 Standard_Real x3=atof(argv[5]);
1630 Standard_Real y3=atof(argv[6]);
1631 Standard_Real aRadius=atof(argv[7]);
1632 Standard_Real aTxtScale=atof(argv[9]);
1633 Standard_Real anArrAngle=atof(argv[10]);
1634 Standard_Real anArrLength=atof(argv[11]);
1635 Standard_Real txtAngle=atof(argv[12]);
1636 Standard_Real txtPosH=atof(argv[13]);
1637 Standard_Real txtPosV=atof(argv[14]);
1640 Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
1641 di<<"Check InteractiveContext\n";
1643 if(aContext.IsNull()) {
1644 di << "use 'v2dinit' command before " << argv[0] << "\n";
1648 di<<"CloseLocalContext\n";
1649 aContext->CloseLocalContext();
1651 di<<"OpenLocalContext\n";
1652 aContext->OpenLocalContext();
1654 Handle(AIS2D_InteractiveObject) aIO10 = new AIS2D_InteractiveObject();
1655 Handle(Graphic2d_Segment) theSegmA, theSegmB;
1656 theSegmA = new Graphic2d_Segment( aIO10, x1, y1, x2, y2 );
1657 theSegmB = new Graphic2d_Segment( aIO10, x1, y1, x3, y3 );
1658 aContext->Display( aIO10, Standard_True );
1660 Handle(Prs2d_Angle) angle = new Prs2d_Angle(aIO10, gp_Pnt2d(x1, y1), gp_Pnt2d(x2, y2),gp_Pnt2d(x3,y3),
1661 aRadius,argv[8],aTxtScale,anArrAngle,anArrLength,Prs2d_TOA_FILLED,
1664 angle->SetTextRelPos(txtPosH,txtPosV);
1665 angle->SetTextAbsAngle(txtAngle);
1667 aContext->Display( aIO10, Standard_True );
1671 #include <Prs2d_Diameter.hxx>
1672 #include <gp_Circ2d.hxx>
1673 #include <Graphic2d_Circle.hxx>
1674 #include <Prs2d_AspectText.hxx>
1675 static Standard_Integer OCC672_Diameter (Draw_Interpretor& di, Standard_Integer n,const char ** argv)
1678 di << "Wrong parameters !\n";
1679 di << "must be : OCC672_Diameter x1 y1 cx cy radius aText aTxtScale anArrAngle anArrLength txtAngle txtPosH txtPosV\n";
1683 Standard_Real x1=atof(argv[1]);
1684 Standard_Real y1=atof(argv[2]);
1685 Standard_Real cx=atof(argv[3]); //coordinats for circle
1686 Standard_Real cy=atof(argv[4]); //
1687 Standard_Real radius=atof(argv[5]);//radius for circle
1688 Standard_Real aTxtScale=atof(argv[7]);
1689 Standard_Real anArrAngle=atof(argv[8]);
1690 Standard_Real anArrLength=atof(argv[9]);
1692 Standard_Real txtAngle=atof(argv[10]);
1693 Standard_Real txtPosH=atof(argv[11]);
1694 Standard_Real txtPosV=atof(argv[12]);
1698 Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
1699 di<<"Check InteractiveContext\n";
1701 if(aContext.IsNull()) {
1702 di << "use 'v2dinit' command before " << argv[0] << "\n";
1706 di<<"CloseLocalContext\n";
1707 aContext->CloseLocalContext();
1709 di<<"OpenLocalContext\n";
1710 aContext->OpenLocalContext();
1711 Handle(AIS2D_InteractiveObject) aIO10 = new AIS2D_InteractiveObject();
1713 Handle (Graphic2d_Circle) HCirc;
1714 HCirc= new Graphic2d_Circle(aIO10,cx,cy,radius);
1716 gp_Dir2d myDir2d(1,0);
1717 gp_Pnt2d myPnt2d(cx,cy);
1718 gp_Ax2d myAx2d(myPnt2d,myDir2d);
1719 gp_Circ2d myCirc(myAx2d,radius);
1721 Handle(Prs2d_Diameter) diameter = new Prs2d_Diameter(aIO10, gp_Pnt2d(x1, y1),myCirc,
1722 argv[6],aTxtScale,anArrAngle,anArrLength,
1724 Prs2d_AS_BOTHAR,Standard_True);
1726 diameter->SetTextRelPos(txtPosH,txtPosV);
1728 diameter->SetTextAbsAngle(txtAngle);
1730 aContext->Display( aIO10, Standard_True );
1735 #include <gp_Lin2d.hxx>
1736 static Standard_Integer OCC672_ShortLength (Draw_Interpretor& di, Standard_Integer n,const char ** argv)
1739 di << " wrong parameters !\n";
1740 di << "must be : OCC672_ShortLength x1 y1 x2 y2 str scale_text length_dist angle_arrow length_arrow x3 y3 x4 y4 TxtAngle TxtPosH TxtPosV\n";
1744 Standard_Real x1=atof(argv[1]);
1745 Standard_Real y1=atof(argv[2]);
1746 Standard_Real x2=atof(argv[3]);
1747 Standard_Real y2=atof(argv[4]);
1748 Standard_Real x3=atof(argv[10]);
1749 Standard_Real y3=atof(argv[11]);
1750 Standard_Real x4=atof(argv[12]);
1751 Standard_Real y4=atof(argv[13]);
1752 Standard_Real txtAngle=atof(argv[14]);
1753 Standard_Real txtPosH=atof(argv[15]);
1754 Standard_Real txtPosV=atof(argv[16]);
1758 Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
1759 di<<"Check InteractiveContext\n";
1761 if(aContext.IsNull()) {
1762 di << "use 'v2dinit' command before " << argv[0] << "\n";
1766 di<<"CloseLocalContext\n";
1767 aContext->CloseLocalContext();
1769 di<<"OpenLocalContext\n";
1770 aContext->OpenLocalContext();
1772 Handle(AIS2D_InteractiveObject) aIO10 = new AIS2D_InteractiveObject();
1773 Handle(Graphic2d_Segment) theSegmA, theSegmB, theSegmC, theSegmD;
1774 theSegmB = new Graphic2d_Segment( aIO10, x2, y2, x3, y3 );
1775 theSegmD = new Graphic2d_Segment( aIO10, x4, y4, x1, y1 );
1777 aContext->Display( aIO10, Standard_True );
1779 gp_Pnt2d p3(x3,y3),p2(x2,y2),p1(x1,y1);
1780 gp_Vec2d theVec(p3,p2);
1781 gp_Dir2d theDir(theVec);
1782 gp_Lin2d theLin1(p1,theDir);
1783 gp_Lin2d theLin2(p3,theDir);
1785 Handle(Prs2d_Length) length = new Prs2d_Length(aIO10, p1, theLin2, argv[5],
1786 atof(argv[6]), 5.0, 20.0, 5.,
1787 Prs2d_TOA_CLOSED,Prs2d_AS_BOTHAR,
1791 Handle(Prs2d_AspectLine) theAspect = new Prs2d_AspectLine(Quantity_NOC_WHITE,
1792 Aspect_TOL_SOLID, Aspect_WOL_THIN);
1793 length->SetTextRelPos(txtPosH,txtPosV);
1794 length->SetTextRelAngle(txtAngle);
1796 aIO10->SetAspect( theAspect, length);
1797 aContext->Display( aIO10, Standard_True );
1802 #include <TopoDS_Solid.hxx>
1803 #include <BRepFeat_MakeDPrism.hxx>
1804 //=======================================================================
1806 //purpose : FEATURE OPERATION (BOSS and SLOT)
1807 //=======================================================================
1808 static Standard_Integer OCCN1 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1812 di << "Usage : " << argv[0] << " angle fuse(1 for boss / 0 for slot) length" << "\n";
1816 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1817 if(aContext.IsNull())
1819 di << "use 'vinit' command before " << argv[0] << "\n";
1822 Standard_Real angle = atof(argv[1]);
1823 Standard_Integer fuse = atoi(argv[2]);
1824 Standard_Real length = atof(argv[3]);
1826 BRepBuilderAPI_MakeEdge edge1(gp_Pnt(0, 0, 0), gp_Pnt(50, 0, 0));
1827 BRepBuilderAPI_MakeEdge edge2(gp_Pnt(50, 0, 0), gp_Pnt(50, 50, 0));
1828 BRepBuilderAPI_MakeEdge edge3(gp_Pnt(50, 50, 0), gp_Pnt(0, 50, 0));
1829 BRepBuilderAPI_MakeEdge edge4(gp_Pnt(0, 50, 0), gp_Pnt(0, 0, 0));
1830 TopoDS_Edge ted1 = edge1.Edge();
1831 TopoDS_Edge ted2 = edge2.Edge();
1832 TopoDS_Edge ted3 = edge3.Edge();
1833 TopoDS_Edge ted4 = edge4.Edge();
1835 BRepBuilderAPI_MakeWire wire(ted1, ted2, ted3, ted4);
1836 TopoDS_Wire twire = wire.Wire();
1838 BRepBuilderAPI_MakeFace face(twire);
1839 TopoDS_Face tface = face.Face();
1840 ////////Handle_AIS_Shape face_ais = new AIS_Shape( tface );
1841 ////////aContext->Display(face_ais);
1844 BRepPrimAPI_MakeBox block(gp_Pnt(-50, -50, -150), 150, 150, 100);
1845 box = block.Solid();
1847 TopoDS_Face top_face;
1848 top_face = block.TopFace();
1850 BRepFeat_MakeDPrism slot(box, tface, top_face, angle, fuse,
1853 slot.Perform(length);
1854 TopoDS_Shape S2 = slot.Shape();
1856 DBRep::Set("OCCN1_tface",tface);
1857 DBRep::Set("OCCN1_slot",S2);
1862 #include <BRepPrimAPI_MakeCylinder.hxx>
1863 #include <BRepPrimAPI_MakeSphere.hxx>
1864 #include <BRepAlgoAPI_Section.hxx>
1865 #include <BRepAlgo_Section.hxx>
1866 //=======================================================================
1868 //purpose : BOOLEAN OPERATION
1869 //=======================================================================
1870 static Standard_Integer OCCN2 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1873 di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1876 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1878 Standard_Integer IsB = atoi(argv[1]);
1880 IsBRepAlgoAPI = Standard_False;
1881 #if ! defined(BRepAlgo_def04)
1886 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1887 if(aContext.IsNull())
1889 di << "use 'vinit' command before " << argv[0] << "\n";
1893 BRepPrimAPI_MakeCylinder cylinder(50,200);
1894 TopoDS_Shape cylinder_sh = cylinder.Shape();
1896 BRepPrimAPI_MakeSphere sphere(gp_Pnt(60,0,100),50);
1897 TopoDS_Shape sphere_sh = sphere.Shape();
1899 //BRepAlgoAPI_Section section(cylinder_sh, sphere_sh);
1900 //TopoDS_Shape shape = section.Shape();
1903 if (IsBRepAlgoAPI) {
1904 di << "BRepAlgoAPI_Section section(cylinder_sh, sphere_sh)" <<"\n";
1905 BRepAlgoAPI_Section section(cylinder_sh, sphere_sh);
1907 if(!section.IsDone()){
1908 di << "Error performing intersection: not done." << "\n";
1910 shape = section.Shape();
1912 di << "BRepAlgo_Section section(cylinder_sh, sphere_sh)" <<"\n";
1913 BRepAlgo_Section section(cylinder_sh, sphere_sh);
1915 if(!section.IsDone()){
1916 di << "Error performing intersection: not done." << "\n";
1918 shape = section.Shape();
1921 DBRep::Set("OCCN2_cylinder",cylinder_sh);
1922 DBRep::Set("OCCN2_sphere",sphere_sh);
1923 DBRep::Set("OCCN2_section",shape);
1928 #include <TColgp_Array1OfPnt.hxx>
1929 #include <Geom_BezierCurve.hxx>
1931 static Standard_Integer OCC2569 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1933 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1934 if(aContext.IsNull())
1936 di << "use 'vinit' command before " << argv[0] << "\n";
1940 di << "Usage : " << argv[0] << " nbpoles result" << "\n";
1944 int poles=atoi(argv[1]);
1946 TColgp_Array1OfPnt arr(1, poles);
1947 for(int i=1; i<=poles; i++)
1948 arr.SetValue(i, gp_Pnt(i+10, i*2+20, i*3+45));
1950 Handle_Geom_BezierCurve bez = new Geom_BezierCurve(arr);
1952 di << "\n The curve is not created.\n";
1954 di << "\n Degree = " << bez->Degree() << "\n";
1956 TopoDS_Edge sh = BRepBuilderAPI_MakeEdge(bez).Edge();
1957 Handle_AIS_Shape ais = new AIS_Shape(sh);
1958 aContext->Display(ais);
1959 DrawTrSurf::Set(argv[2],bez);
1963 #include <TopTools_IndexedMapOfShape.hxx>
1964 #include <TopExp.hxx>
1966 static Standard_Integer OCC1642 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1969 di<<"Usage: " << argv[0] << " FinalWare FinalFace InitWare InitFace shape FixReorder FixDegenerated FixConnected FixSelfIntersection"<<"\n";
1973 TopoDS_Shape shape = DBRep::Get(argv[5]);
1975 TopExp_Explorer exp(shape, TopAbs_WIRE);
1976 TopoDS_Shape wire = exp.Current();
1978 Handle(ShapeAnalysis_Wire) advWA = new ShapeAnalysis_Wire;
1979 advWA->Load(TopoDS::Wire(wire));
1981 DBRep::Set(argv[3],wire);
1984 BRepBuilderAPI_MakeFace(TopoDS::Wire(wire),Standard_True);
1986 DBRep::Set(argv[4],face);
1988 advWA->SetFace(face);
1989 float precision_to_ana = 0.0001;
1990 advWA->SetPrecision(precision_to_ana);
1992 TopTools_IndexedMapOfShape M;
1993 TopExp::MapShapes(wire, TopAbs_EDGE, M);
1996 for(j= 1; j<=M.Extent(); ++j) {
1997 Standard_Integer num=1;
1998 IntRes2d_SequenceOfIntersectionPoint points2d;
1999 TColgp_SequenceOfPnt points3d;
2001 cout << "\n j =" << j << ", CheckSelfIntersectingEdge = " <<
2002 advWA->CheckSelfIntersectingEdge(j, points2d, points3d);
2005 ShapeExtend_Status status = ShapeExtend_FAIL1;
2006 if(advWA->StatusSelfIntersection(status))
2008 status = ShapeExtend_FAIL2;
2009 if(advWA->StatusSelfIntersection(status))
2010 di << "\n No Vertices found in the edge";
2012 status = ShapeExtend_DONE1;
2013 if(advWA->StatusSelfIntersection(status))
2014 di << "\n Self-intersection found in the edge";
2016 num = points2d.Length();
2017 di << "\n No. of self-intersecting edges : " << num;
2019 for(int i=1; i<=num; ++i) {
2020 gp_Pnt pt = points3d(i);
2021 di << "\n Intersecting pt : (" << pt.X() << ", " << pt.Y()<< ", " << pt.Z() << ")";
2026 Handle_ShapeFix_Wire sfw = new ShapeFix_Wire;
2027 sfw->Load(TopoDS::Wire(wire));
2029 sfw->SetPrecision(Precision::Confusion());
2031 sfw->FixReorderMode() = 1;
2032 sfw->ClosedWireMode() = 1;
2033 sfw->FixDegeneratedMode() = 1;
2034 sfw->FixConnectedMode() = 1;
2035 sfw->ModifyTopologyMode() = 1;
2036 sfw->ModifyGeometryMode() = 1;
2037 sfw->FixSelfIntersectionMode() = 1;
2038 sfw->FixSelfIntersectingEdgeMode() = 1;
2039 sfw->FixIntersectingEdgesMode() = 1;
2040 sfw->FixNonAdjacentIntersectingEdgesMode() = 1;
2041 sfw->FixEdgeCurvesMode() = 1;
2043 sfw->ModifyRemoveLoopMode() = 1;
2044 sfw->SetMaxTolerance(1.0);
2046 di << "\n FixReorder = " << (Standard_Integer) sfw->FixReorder();
2047 di << "\n FixDegenerated = " << (Standard_Integer) sfw->FixDegenerated();
2048 di << "\n FixConnected = " << (Standard_Integer) sfw->FixConnected();
2050 di << "\n FixSelfIntersection = " << (Standard_Integer) sfw->FixSelfIntersection();
2053 Draw::Set(argv[6],sfw->FixReorder()) ;
2054 Draw::Set(argv[7],sfw->FixDegenerated()) ;
2055 Draw::Set(argv[8],sfw->FixConnected()) ;
2056 Draw::Set(argv[9],sfw->FixSelfIntersection()) ;
2058 ShapeExtend_Status status = ShapeExtend_OK;
2059 if(sfw->StatusSelfIntersection(status))
2060 di << "\n ShapeExtend_OK : No intersection found";
2062 status = ShapeExtend_FAIL1;
2063 if(sfw->StatusSelfIntersection(status))
2064 di << "\n ShapeExtend_FAIL1 : analysis failed (edge has no pcurve,or no vertices etc.)";
2066 status = ShapeExtend_FAIL2;
2067 if(sfw->StatusSelfIntersection(status))
2068 di << "\n ShapeExtend_FAIL2 : self-intersection was found, but not fixed because of limit of increasing tolerance (MaxTolerance)";
2070 status = ShapeExtend_FAIL3;
2071 if(sfw->StatusSelfIntersection(status))
2072 di << "\n ShapeExtend_FAIL3 : intercestion of non adjacent edges found, but not fixed because of limit of increasing tolerance (MaxTolerance)";
2074 status = ShapeExtend_DONE1;
2075 if(sfw->StatusSelfIntersection(status))
2076 di << "\n ShapeExtend_DONE1 : tolerance of vertex was increased to fix self-intersection";
2078 status = ShapeExtend_DONE2;
2079 if(sfw->StatusSelfIntersection(status))
2080 di << "\n ShapeExtend_DONE2 : vertex was moved to fix self-intersection";
2082 status = ShapeExtend_DONE3;
2083 if(sfw->StatusSelfIntersection(status))
2084 di << "\n ShapeExtend_DONE3 : some edges were removed because of intersection";
2086 status = ShapeExtend_DONE4;
2087 if(sfw->StatusSelfIntersection(status))
2088 di << "\n ShapeExtend_DONE4 : pcurve(s) was(were) modified";
2090 status = ShapeExtend_DONE5;
2091 if(sfw->StatusSelfIntersection(status))
2092 di << "\n ShapeExtend_DONE5 : non adjacent intersection fixed by increasing tolerance of vertex(vertices)";
2094 status = ShapeExtend_DONE6;
2095 if(sfw->StatusSelfIntersection(status))
2096 di << "\n ShapeExtend_DONE6 : tolerance of edge was increased to hide intersection";
2098 status = ShapeExtend_DONE7;
2099 if(sfw->StatusSelfIntersection(status))
2100 di << "\n ShapeExtend_DONE7 : range of some edges was decreased to avoid intersection";
2102 TopoDS_Wire finalwire = sfw->Wire();
2104 DBRep::Set(argv[1],finalwire);
2107 advWA->Load(TopoDS::Wire(finalwire));
2110 BRepBuilderAPI_MakeFace(TopoDS::Wire(finalwire),Standard_True);
2112 DBRep::Set(argv[2],fface);
2114 advWA->SetFace(fface);
2116 TopTools_IndexedMapOfShape fM;
2117 TopExp::MapShapes(finalwire, TopAbs_EDGE, fM);
2119 for(j= 1; j<=fM.Extent(); ++j) {
2120 Standard_Integer num=1;
2121 IntRes2d_SequenceOfIntersectionPoint points2d;
2122 TColgp_SequenceOfPnt points3d;
2124 di << "\n j =" << j << ", CheckSelfIntersectingEdge = " <<
2125 (Standard_Integer) advWA->CheckSelfIntersectingEdge(j, points2d, points3d);
2128 ShapeExtend_Status status = ShapeExtend_FAIL1;
2129 if(advWA->StatusSelfIntersection(status))
2131 status = ShapeExtend_FAIL2;
2132 if(advWA->StatusSelfIntersection(status))
2133 di << "\n No Vertices found in the edge";
2135 status = ShapeExtend_DONE1;
2136 if(advWA->StatusSelfIntersection(status))
2137 di << "\n Self-intersection found in the edge";
2139 num = points2d.Length();
2140 di << "\n No. of self-intersecting edges : " << num;
2142 for(int i=1; i<=num; ++i) {
2143 gp_Pnt pt = points3d(i);
2144 di << "\n Intersecting pt : (" << pt.X() << ", " << pt.Y() << ", " << pt.Z() << ")";
2154 Standard_Integer OCC17480(Draw_Interpretor& di, Standard_Integer n, const char ** a)
2157 cout << "Usage: OCC17480 basic_shape <mode[0:1]>" <<endl;
2161 TopoDS_Shape brep_pipe = DBRep::Get(a[1]);
2163 Standard_Boolean mode = Standard_False;
2164 if(n == 3 && atoi(a[2]) == 1)
2165 mode = Standard_True;
2167 Handle_AIS_Shape ais_pipe = new AIS_Shape( brep_pipe );
2168 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
2169 Handle(AIS2D_InteractiveContext) aContext_2d = Viewer2dTest::GetAIS2DContext();
2171 if(!aContext.IsNull())
2172 aContext->Display(ais_pipe);
2174 if(!aContext_2d.IsNull())
2175 aContext_2d->EraseAll(Standard_True);
2177 gp_Ax3 ax3(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1), gp_Dir(0, 1, 0));
2179 gp_Ax2 ax2 = ax3.Ax2();
2181 HLRAlgo_Projector aProjector = HLRAlgo_Projector(ax2);
2182 Handle_AIS2D_ProjShape myDisplayableShape =
2183 new AIS2D_ProjShape(aProjector, 0, mode, Standard_True);
2185 myDisplayableShape->Add( brep_pipe );
2187 di << "\n Total number of primitives : " << myDisplayableShape->Length();
2189 Handle(Graphic2d_Line) mySectProjLines = myDisplayableShape->GetPrimitives();
2190 Handle(Graphic2d_Line) mySectProjLinesHLR = myDisplayableShape->GetHLPrimitives();
2192 Handle_Standard_Type sty = mySectProjLines->DynamicType();
2193 Handle_Standard_Type sty1 = mySectProjLinesHLR->DynamicType();
2195 di << "\n Class Name = " << (char*)sty->Name();
2196 di << "\n HLR Class Name = " << (char*)sty1->Name();
2197 di << "\n mySectProjLines.IsNull = " << (Standard_Integer) mySectProjLines.IsNull();
2198 di << "\n mySectProjLinesHLR.IsNull = " << (Standard_Integer) mySectProjLinesHLR.IsNull();
2200 Handle(GGraphic2d_SetOfCurves) setCurves;
2201 Handle(Graphic2d_SetOfSegments) setSegments;
2203 if(mySectProjLines->IsKind(STANDARD_TYPE(GGraphic2d_SetOfCurves)))
2205 setCurves = Handle(GGraphic2d_SetOfCurves)::DownCast(mySectProjLines);
2206 di << "\n Number of Curves in set = " << setCurves->Length();
2208 if(mySectProjLines->IsKind(STANDARD_TYPE(Graphic2d_SetOfSegments)))
2210 setSegments = Handle(Graphic2d_SetOfSegments)::DownCast(mySectProjLines);
2211 di << "\n Number of Curves in set = " << setSegments->Length();
2214 Handle(GGraphic2d_SetOfCurves) setCurvesHLR;
2215 Handle(Graphic2d_SetOfSegments) setSegmentsHLR;
2217 if(mySectProjLinesHLR->IsKind(STANDARD_TYPE(GGraphic2d_SetOfCurves)))
2219 setCurvesHLR = Handle(GGraphic2d_SetOfCurves)::DownCast(mySectProjLinesHLR);
2220 di << "\n HLR Number of Curves in set = " << setCurvesHLR->Length();
2222 if(mySectProjLinesHLR->IsKind(STANDARD_TYPE(Graphic2d_SetOfSegments)))
2224 setSegmentsHLR = Handle(Graphic2d_SetOfSegments)::DownCast(mySectProjLinesHLR);
2225 di << "\n HLR Number of Curves in set = " << setSegmentsHLR->Length();
2228 aContext_2d->Display( myDisplayableShape,Standard_True );
2232 void QATelco::Commands(Draw_Interpretor& theCommands) {
2233 char *group = "QATelco";
2235 theCommands.Add ("BUC60842", "BUC60842", __FILE__, BUC60842, group);
2236 theCommands.Add ("BUC60843", "BUC60843 result_shape name_of_circle name_of_curve [ par1 [ tol ] ]", __FILE__, BUC60843, group);
2237 theCommands.Add ("BUC60970", "BUC60970 shape result", __FILE__, BUC60970, group);
2238 theCommands.Add ("BUC60818", "BUC60818", __FILE__, BUC60818, group);
2239 theCommands.Add ("BUC60915", "BUC60915", __FILE__, BUC60915_1, group);
2240 theCommands.Add ("OCC138", "OCC138", __FILE__, OCC138, group);
2241 theCommands.Add ("BUC60821","BUC60821",__FILE__,BUC60821,group);
2242 theCommands.Add ("OCC353","OCC353",__FILE__,OCC353,group);
2243 theCommands.Add ("OCC280","OCC280 hlr=0/1 setsurfecedetail=0/1; set perspecrive view",__FILE__,OCC280,group);
2244 theCommands.Add ("OCC232", "OCC232", __FILE__, OCC232 , group);
2245 theCommands.Add ("OCC138LC", "OCC138LC", __FILE__, OCC138LC, group);
2246 theCommands.Add ("OCC189", "OCC189", __FILE__, OCC189, group);
2247 theCommands.Add ("OCC389", "OCC389 name shape1 [shape2] ...", __FILE__, OCC389, group);
2249 theCommands.Add ("OCC566", "OCC566 shape [ xmin ymin zmin xmax ymax zmax] ; print bounding box", __FILE__, OCC566, group);
2250 theCommands.Add ("OCC570", "OCC570 result", __FILE__, OCC570, group);
2252 theCommands.Add("OCC570mkevol",
2253 "OCC570mkevol result object (then use updatevol) [R/Q/P]; mkevol",
2254 __FILE__, MKEVOL,group);
2255 theCommands.Add("OCC570updatevol",
2256 "OCC570updatevol edge u1 rad1 u2 rad2 ...; updatevol",
2257 __FILE__, UPDATEVOL,group);
2258 theCommands.Add("OCC570updatevollaw",
2259 "OCC570updatevollaw edge u1 rad1 u2 rad2 ...; updatevollaw",
2260 __FILE__, UPDATEVOL,group);
2261 theCommands.Add("OCC570buildevol",
2262 "OCC570buildevol; end of the evol fillet computation",
2263 __FILE__, BUILDEVOL,group);
2265 theCommands.Add ("OCC606", "OCC606 result shape [-t]", __FILE__, OCC606, group);
2267 theCommands.Add ("OCC813", "OCC813 U V", __FILE__, OCC813, group);
2268 theCommands.Add ("OCC814", "OCC814", __FILE__, OCC814, group);
2269 theCommands.Add ("OCC884", "OCC884 result shape [toler [maxtoler]]", __FILE__, OCC884, group);
2270 theCommands.Add ("OCC1188", "OCC1188 imagefile [filltype] : Load image as background", __FILE__, OCC1188, group);
2272 theCommands.Add ("OCC1174_1", "OCC1174_1 shape", __FILE__, OCC1174_1, group);
2273 theCommands.Add ("OCC1174_2", "OCC1174_2 shape", __FILE__, OCC1174_2, group);
2275 theCommands.Add("OCC672_Length"," OCC672_Length x1 y1 x2 y2 str scale_text length_dist angle_arrow length_arrow x3 y3 x4 y4 textAngle textPosH textPosV",__FILE__,OCC672_Length,group);
2276 theCommands.Add("OCC672_Angle","OCC672_Angle x1 y1 x2 y2 x3 y3 aRadius aText aTxtScale anArrAngle anArrLength txtAngle txtPosH txtPosV",__FILE__,OCC672_Angle,group);
2277 theCommands.Add("OCC672_Diameter","OCC672_Diameter x1 y1 cx cy radius aText aTxtScale anArrAngle anArrLength txtAngle txtPosH txtPosV",__FILE__,OCC672_Diameter,group);
2278 theCommands.Add("OCC672_ShortLength","",__FILE__,OCC672_ShortLength,group);
2280 theCommands.Add ("OCCN1", "OCCN1 angle fuse(1 for boss / 0 for slot) length", __FILE__, OCCN1, group);
2281 theCommands.Add ("OCCN2", "OCCN2", __FILE__, OCCN2, group);
2283 theCommands.Add ("OCC2569", "OCC2569 nbpoles result", __FILE__, OCC2569, group);
2285 theCommands.Add ("OCC1642", "OCC1642 FinalWare FinalFace InitWare InitFace shape FixReorder FixDegenerated FixConnected FixSelfIntersection", __FILE__, OCC1642, group);
2287 theCommands.Add ("OCC17480", "OCC17480 Shape", __FILE__, OCC17480, group);