1 // Created on: 2002-03-18
2 // Created by: QA Admin
3 // Copyright (c) 2002-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
21 #include <Draw_Interpretor.hxx>
23 #include <DrawTrSurf.hxx>
24 #include <AIS_InteractiveContext.hxx>
25 #include <ViewerTest.hxx>
26 #include <ViewerTest_EventManager.hxx>
27 #include <AIS_Shape.hxx>
28 #include <TopoDS_Shape.hxx>
30 #include <Geom_Circle.hxx>
31 #include <Geom_Ellipse.hxx>
32 #include <Geom_Plane.hxx>
33 #include <Geom_BSplineSurface.hxx>
35 #include <Geom2d_Curve.hxx>
36 #include <GeomAPI.hxx>
37 #include <Geom2dAdaptor_Curve.hxx>
38 #include <Geom2dGcc_QualifiedCurve.hxx>
39 #include <Geom2dGcc_Lin2d2Tan.hxx>
40 #include <Geom2d_Line.hxx>
41 #include <BRepBuilderAPI_MakeEdge.hxx>
42 #include <TopoDS_Edge.hxx>
43 #include <Precision.hxx>
44 #include <Geom2d_Circle.hxx>
45 #include <Geom2dGcc_QCurve.hxx>
46 #include <GccEnt_QualifiedCirc.hxx>
47 #include <Geom2dGcc_Lin2d2TanIter.hxx>
48 #include <BRepBuilderAPI_MakeWire.hxx>
49 #include <TopExp_Explorer.hxx>
51 #include <TopoDS_Wire.hxx>
52 #include <BRep_Tool.hxx>
53 #include <gp_Circ.hxx>
54 #include <BRepOffsetAPI_MakePipeShell.hxx>
55 #include <AIS_Trihedron.hxx>
56 #include <Geom_Axis2Placement.hxx>
57 #include <V3d_View.hxx>
58 #include <BRepBuilderAPI_MakeVertex.hxx>
59 #include <AIS_LengthDimension.hxx>
60 #include <AIS_RadiusDimension.hxx>
61 #include <BRepPrimAPI_MakeBox.hxx>
62 #include <GeomAdaptor_Surface.hxx>
63 #include <Extrema_ExtPS.hxx>
64 #include <Geom_CartesianPoint.hxx>
65 #include <Geom2d_CartesianPoint.hxx>
66 #include <Geom2dGcc_Circ2d3Tan.hxx>
67 #include <Aspect_Window.hxx>
69 #include <TopoDS_Compound.hxx>
70 #include <TopoDS_CompSolid.hxx>
71 #include <StdSelect_ShapeTypeFilter.hxx>
72 #include <Prs3d_Projector.hxx>
73 #include <HLRAlgo_Projector.hxx>
74 #include <Standard_ErrorHandler.hxx>
75 #include <Font_NameOfFont.hxx>
77 static Standard_Integer BUC60842 (Draw_Interpretor& di, Standard_Integer /*argc*/,const char ** /*argv*/)
79 Standard_Character abuf[16];
80 //Standard_Character * abuf = new Standard_Character[16];
82 Standard_CString st = abuf;
84 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);
85 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);
86 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))));
88 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
90 gp_Pln pln = plne->Pln();
91 Handle(Geom2d_Curve) curve2d = GeomAPI::To2d (ell, pln);
93 DrawTrSurf::Set(st,curve2d);
94 if(!aContext.IsNull()) {
95 Handle(AIS_Shape) aisp =
96 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(curve2d, pln)).Edge());
97 aContext->Display (aisp, Standard_False);
100 Handle(Geom2d_Curve) fromcurve2d = GeomAPI::To2d (cir, pln);
102 DrawTrSurf::Set(st,fromcurve2d);
103 if(!aContext.IsNull()) {
104 Handle(AIS_Shape) aisp =
105 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(fromcurve2d, pln)).Edge());
106 aContext->Display (aisp, Standard_False);
109 Geom2dAdaptor_Curve acur (curve2d), afromcur (fromcurve2d);
110 Geom2dGcc_QualifiedCurve qcur (acur, GccEnt_outside);
111 Geom2dGcc_QualifiedCurve qfromcur (afromcur, GccEnt_outside);
112 Geom2dGcc_Lin2d2Tan lintan (qcur, qfromcur, 0.1, 0.0, 0.0);
113 Standard_Integer i=0;
114 for(i=0;i<lintan.NbSolutions();i++) {
115 Sprintf(abuf,"lintan_%d",i);
116 Handle(Geom2d_Line) glin = new Geom2d_Line(lintan.ThisSolution(i));
117 DrawTrSurf::Set(st,glin);
118 if(!aContext.IsNull()) {
119 Handle(AIS_Shape) aisp =
120 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(glin, pln)).Edge());
121 aContext->Display (aisp, Standard_False);
124 aContext->UpdateCurrentViewer();
125 di << " Is Done = \n" << (Standard_Integer) lintan.IsDone();
129 static Standard_Integer BUC60843 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
131 if (argc != 4 && argc != 5 && argc != 6 && argc != 7) {
132 di << "Usage : " << argv[0] << "result_shape name_of_circle name_of_curve [ par1 [ tol ] ]\n";
136 Standard_Real par1 = 0.0, par2 = 0.0;
137 Standard_Real tol = Precision::Angular();
139 par1 = Draw::Atof(argv[4]);
141 par2 = Draw::Atof(argv[5]);
143 tol = Draw::Atof(argv[6]);
144 Handle(Geom2d_Curve) aCur2d1 = DrawTrSurf::GetCurve2d(argv[2]);
145 Handle(Geom2d_Curve) aCur2d2 = DrawTrSurf::GetCurve2d(argv[3]);
146 if (aCur2d1.IsNull() || aCur2d2.IsNull()) {
147 di << "Faulty : not curves\n";
150 Standard_Boolean c1IsCircle = Standard_False;
151 Handle(Geom2d_Circle) aCir2d = Handle(Geom2d_Circle)::DownCast(aCur2d1);
152 if (!aCir2d.IsNull()) {
153 c1IsCircle = Standard_True;
154 if (argc == 6) tol = Draw::Atof(argv[5]);
157 Geom2dAdaptor_Curve acur(aCur2d2);
158 Geom2dGcc_QCurve qcur(acur, GccEnt_unqualified);
159 GccEnt_QualifiedCirc qfromcur(aCir2d->Circ2d(), GccEnt_unqualified);
160 Geom2dGcc_Lin2d2TanIter lintan(qfromcur, qcur , par1, tol);
161 if (lintan.IsDone()) {
162 gp_Lin2d lin = lintan.ThisSolution();
163 Handle(Geom2d_Line) glin = new Geom2d_Line(lin);
164 DrawTrSurf::Set(argv[1], glin);
166 di << "Faulty : tangent line is not done.\n";
170 Geom2dAdaptor_Curve acur1(aCur2d1);
171 Geom2dAdaptor_Curve acur2(aCur2d2);
172 Geom2dGcc_QCurve qcur1(acur1, GccEnt_unqualified);
173 Geom2dGcc_QCurve qcur2(acur2, GccEnt_unqualified);
174 Geom2dGcc_Lin2d2TanIter lintan(qcur1, qcur2 , par1, par2, tol);
175 if (lintan.IsDone()) {
176 gp_Lin2d lin = lintan.ThisSolution();
177 Handle(Geom2d_Line) glin = new Geom2d_Line(lin);
178 DrawTrSurf::Set(argv[1], glin);
180 di << "Faulty : tangent line is not done.\n";
186 static Standard_Integer BUC60970 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
190 di << "Usage : " << argv[0] << " shape result\n";
194 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
195 if(aContext.IsNull()) {
196 di << "use 'vinit' command before " << argv[0] << "\n";
200 TopoDS_Shape aResult = DBRep::Get(argv[1]);
202 BRepBuilderAPI_MakeWire bRepSpineWire;
203 TopExp_Explorer exp_(aResult, TopAbs_WIRE);
205 Standard_Integer i = 0;
206 for(;exp_.More();exp_.Next()){
208 bRepSpineWire.Add(TopoDS::Wire(exp_.Current()));
211 //printf("total no of wires are ............. %d\n", i);
212 di << "total no of wires are ............. " << i << "\n";
214 TopoDS_Wire spineWire = bRepSpineWire.Wire();
215 aContext->Display (new AIS_Shape(spineWire), Standard_False);
217 DBRep::Set("slineW",spineWire);
219 TopExp_Explorer spineWireExp(spineWire, TopAbs_EDGE);
220 Standard_Real first, last;
221 Handle(Geom_Curve) curl_ = BRep_Tool::Curve(TopoDS::Edge(spineWireExp.Current()), first, last);
224 curl_->D1(first, firstPnt, tanVec);
226 gp_Dir tanDir(tanVec.X(), tanVec.Y(), tanVec.Z());
227 gp_Ax2 gpAx2(firstPnt, tanDir);
228 gp_Circ gpCirc(gpAx2, 2.5);
229 BRepBuilderAPI_MakeWire aMWire(BRepBuilderAPI_MakeEdge(new Geom_Circle(gpCirc)).Edge());
230 TopoDS_Wire topoWire(aMWire);
231 aContext->Display (new AIS_Shape(topoWire), Standard_False);
233 DBRep::Set("topoW",topoWire);
235 BRepOffsetAPI_MakePipeShell bRepPipe(spineWire);
236 bRepPipe.Add(topoWire);
239 aContext->Display (new AIS_Shape(bRepPipe.Shape()), Standard_True);
241 DBRep::Set(argv[2],bRepPipe.Shape());
246 static Standard_Integer BUC60818(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
250 di << "Usage : " << argv[0] << "\n";
254 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
255 if(myAISContext.IsNull())
257 di << "use 'vinit' command before " << argv[0] << "\n";
262 Handle(AIS_Trihedron) aTrihedron;
263 Handle(Geom_Axis2Placement) aTrihedronAxis=new Geom_Axis2Placement(gp::XOY());
264 aTrihedron=new AIS_Trihedron(aTrihedronAxis);
265 myAISContext->Display (aTrihedron, Standard_True);
267 Standard_DISABLE_DEPRECATION_WARNINGS
268 myAISContext->OpenLocalContext();
269 Standard_ENABLE_DEPRECATION_WARNINGS
270 myAISContext->Load(aTrihedron,0);
272 myAISContext->SetAutomaticHilight( Standard_False );
274 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
276 myV3dView->Project(0,0,0,Xv,Yv);
278 Standard_Integer Xp,Yp;
279 myV3dView->Convert(Xv,Yv,Xp,Yp);
281 myAISContext->MoveTo (Xp,Yp, myV3dView, Standard_False);
282 myAISContext->MoveTo (Xp,Yp, myV3dView, Standard_True);
284 if (myAISContext->HasDetected( ))
285 di << "has detected shape : OK" << "\n";
286 else di << "has detected shape : bugged - Faulty " << "\n";
288 myAISContext->SetAutomaticHilight( Standard_True );
293 static Standard_Integer BUC60915_1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
296 di<<"Function don't has parameters\n";
300 if(ViewerTest::GetAISContext().IsNull())
302 di << "View was not created. Use 'vinit' command before "
306 Handle(AIS_InteractiveContext) context = ViewerTest::GetAISContext();
308 //The following dimesion code has problems regarding arrow_size. The desired effect is not produced.
309 /***************************************/
311 /***************************************/
312 gp_Pnt p1 = gp_Pnt(602.51,50.,0.);
313 gp_Pnt p2 = gp_Pnt(602.51,200.,0.);
314 gp_Pnt p3 = gp_Pnt(102.51,200.,0.);
315 gp_Pnt p4 = gp_Pnt(102.51,170.,0.);
316 gp_Pnt p5 = gp_Pnt(502.51,170.,0.);
317 gp_Pnt p6 = gp_Pnt(502.51,80.,0.);
318 gp_Pnt p7 = gp_Pnt(102.51,80.,0.);
319 gp_Pnt p8 = gp_Pnt(102.51,50.,0.);
320 TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(p1);
321 TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(p2);
322 TopoDS_Vertex V3 = BRepBuilderAPI_MakeVertex(p3);
323 TopoDS_Vertex V4 = BRepBuilderAPI_MakeVertex(p4);
324 TopoDS_Vertex V5 = BRepBuilderAPI_MakeVertex(p5);
325 TopoDS_Vertex V6 = BRepBuilderAPI_MakeVertex(p6);
326 TopoDS_Vertex V7 = BRepBuilderAPI_MakeVertex(p7);
327 TopoDS_Vertex V8 = BRepBuilderAPI_MakeVertex(p8);
328 gp_Pnt plnpt(0, 0, 0);
329 gp_Dir plndir(0, 0, 1);
330 Handle(Geom_Plane) pln = new Geom_Plane(plnpt,plndir);
331 Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
332 anAspect->MakeArrows3d (Standard_True);
333 anAspect->ArrowAspect()->SetAngle (M_PI/180.0 * 10.0);
334 /***************************************/
335 //dimension "L 502.51"
336 /***************************************/
337 Handle(AIS_LengthDimension) len = new AIS_LengthDimension(V2, V3, pln->Pln());
338 anAspect->ArrowAspect()->SetLength (30.0);
339 len->SetDimensionAspect (anAspect);
340 context->Display (len, Standard_False);
341 /***************************************/
343 /***************************************/
344 Handle(AIS_LengthDimension) len1 = new AIS_LengthDimension(V7, V4, pln->Pln());
345 len1->SetDimensionAspect (anAspect);
346 len1->SetFlyout (30.0);
347 anAspect->ArrowAspect()->SetLength (100.0);
348 context->Display (len1, Standard_False);
349 /***************************************/
351 /***************************************/
352 Handle(AIS_LengthDimension) len2 = new AIS_LengthDimension(V1, V2, pln->Pln());
353 len2->SetDimensionAspect (anAspect);
354 context->Display (len2, Standard_False);
355 /***************************************/
356 //dimension "R 88.58"
357 /***************************************/
358 gp_Circ cir = gp_Circ(gp_Ax2(gp_Pnt(191.09, -88.58, 0), gp_Dir(0, 0, 1)), 88.58);
359 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(cir,gp_Pnt(191.09,0,0.),gp_Pnt(191.09,-177.16,0.) );
360 Handle(AIS_RadiusDimension) dim1 = new AIS_RadiusDimension(E1);
361 dim1->SetDimensionAspect (anAspect);
362 context->Display (dim1, Standard_False);
363 /***************************************/
364 //dimension "R 43.80"
365 /***************************************/
366 gp_Circ cir1 = gp_Circ(gp_Ax2(gp_Pnt(191.09, -88.58, 0), gp_Dir(0, 0, 1)), 43.80);
367 TopoDS_Edge E_cir1 = BRepBuilderAPI_MakeEdge(cir1);
368 dim1 = new AIS_RadiusDimension(E_cir1);
369 anAspect->ArrowAspect()->SetLength (60.0);
370 dim1->SetDimensionAspect (anAspect);
371 context->Display (dim1, Standard_False);
372 /***************************************/
373 //dimension "R 17.86"
374 /***************************************/
375 gp_Circ cir2 = gp_Circ(gp_Ax2(gp_Pnt(566.11, -88.58, 0), gp_Dir(0, 0, -1)), 17.86);
376 TopoDS_Edge E_cir2 = BRepBuilderAPI_MakeEdge(cir2);
377 dim1 = new AIS_RadiusDimension(E_cir2);
378 anAspect->ArrowAspect()->SetLength (40.0);
379 dim1->SetDimensionAspect (anAspect);
380 context->Display (dim1, Standard_True);
385 static Standard_Integer OCC138 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
387 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
388 if(aContext.IsNull()) {
389 di << "use 'vinit' command before " << argv[0] << "\n";
393 BRepPrimAPI_MakeBox box1(gp_Pnt(0, 0, 0), gp_Pnt(100, 100, 100));
394 BRepPrimAPI_MakeBox box2(gp_Pnt(120, 120, 120), gp_Pnt(300, 300,300));
395 BRepPrimAPI_MakeBox box3(gp_Pnt(320, 320, 320), gp_Pnt(500, 500,500));
397 Handle(AIS_InteractiveObject) ais1 = new AIS_Shape(box1.Shape());
398 Handle(AIS_InteractiveObject) ais2 = new AIS_Shape(box2.Shape());
399 Handle(AIS_InteractiveObject) ais3 = new AIS_Shape(box3.Shape());
401 aContext->Display (ais1, Standard_False);
402 aContext->Display (ais2, Standard_False);
403 aContext->Display (ais3, Standard_False);
405 aContext->AddOrRemoveSelected (ais1, Standard_False);
406 aContext->AddOrRemoveSelected (ais2, Standard_False);
407 aContext->AddOrRemoveSelected (ais3, Standard_False);
409 di << "\n No of currents = " << aContext->NbSelected();
411 aContext->InitSelected();
414 while(aContext->MoreSelected())
416 di << "\n count is = " << count++;
417 Handle(AIS_InteractiveObject) ais = aContext->SelectedInteractive();
418 aContext->AddOrRemoveSelected (ais, Standard_False);
419 aContext->InitSelected();
422 aContext->UpdateCurrentViewer();
427 static int geom_get_2Dpt_from_3Dpt(const gp_Pnt& pnt3d, const gp_Pln& pln, gp_Pnt2d& pnt2d)
430 Handle(Geom_Plane) gpln = new Geom_Plane(pln);
431 GeomAdaptor_Surface adsur(gpln);
432 Extrema_ExtPS extps(pnt3d, adsur, 0.001, 0.001);
436 for(index=1; index<= extps.NbExt(); index++ )
438 Extrema_POnSurf pons = extps.Point(index);
440 pons.Parameter(U, V);
441 pnt2d.SetCoord(U, V);
448 static Standard_Integer OCC353 (Draw_Interpretor& di, Standard_Integer , const char ** )
450 gp_Ax2 ax21( gp_Pnt(100,0,0), gp_Dir(0,0,1) );
451 Handle(Geom_Circle) h_cir1 = new Geom_Circle( ax21, 25 );
453 gp_Ax2 ax22( gp_Pnt(-100,0,0), gp_Dir(0,0,1) );
454 Handle(Geom_Circle) h_cir2 = new Geom_Circle( ax22, 25 );
456 gp_Pln refpln( gp_Pnt(0,0,0), gp_Dir(0,0,1) );
457 Handle(Geom2d_Curve) cir2d1 = GeomAPI::To2d(h_cir1, refpln);
458 Handle(Geom2d_Curve) cir2d2 = GeomAPI::To2d(h_cir2, refpln);
460 Geom2dAdaptor_Curve adop1(cir2d1);
461 Geom2dAdaptor_Curve adop2(cir2d2);
463 Geom2dGcc_QualifiedCurve qcur1(adop1, GccEnt_enclosing);
464 Geom2dGcc_QualifiedCurve qcur2(adop2, GccEnt_enclosing);
466 Handle(Geom_CartesianPoint) h_carpt = new Geom_CartesianPoint(0,175,0);
468 gp_Pnt pt3d = h_carpt->Pnt();
470 geom_get_2Dpt_from_3Dpt(pt3d, refpln, pt2d);
474 DrawTrSurf::Set(st,cir2d1);
476 DrawTrSurf::Set(st,cir2d2);
478 DrawTrSurf::Set(st,pt2d);
480 Handle(Geom2d_CartesianPoint) pt = new Geom2d_CartesianPoint(pt2d);
481 Geom2dGcc_Circ2d3Tan sol( qcur1, qcur2, pt, 0.001, 0.0, 0.0);
484 Standard_Character buf[10];
488 res = sol.NbSolutions();
489 for(Standard_Integer i=1;i<=res;i++) {
490 Handle(Geom2d_Circle) aC = new Geom2d_Circle(sol.ThisSolution(i));
491 Sprintf(buf,"Result_%d",i);
493 DrawTrSurf::Set(st,aC);
497 di << "\n Faulty: no solutions found ";
498 //printf("\n Faulty: no solutions found ");
500 //printf("\n Num of solutions are %d ", res );
501 di << "\n Num of solutions are " << res << " ";
506 static Standard_Integer OCC280 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
508 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
509 if(aContext.IsNull())
511 di << "use 'vinit' command before " << argv[0] << "\n";
515 di << "ERROR : Usage : " << argv[0] << " hlr=0/1 setsurfecedetail=0/1; set perspecrive view\n";
519 Standard_Integer HLR = Draw::Atoi(argv[1]);
524 TCollection_AsciiString anOldName = ViewerTest::GetCurrentViewName();
525 Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
526 aViewer->SetDefaultTypeOfView (V3d_PERSPECTIVE);
527 Handle(Aspect_Window) asp = ViewerTest::CurrentView()->Window();
528 Handle(V3d_View) aNewView = aViewer->CreateView();
529 ViewerTest::CurrentView (aNewView);
530 TCollection_AsciiString aNewName=anOldName + "_new";
531 ViewerTest::InitViewName(aNewName,ViewerTest::CurrentView());
532 aNewView->SetWindow (asp);
533 if (!asp->IsMapped()) asp->Map();
535 ViewerTest::RemoveView(anOldName,false);
536 ViewerTest::UnsetEventManager();
537 ViewerTest::SetEventManager (new ViewerTest_EventManager (aNewView, ViewerTest::GetAISContext()));
542 ViewerTest::CurrentView()->SetComputedMode (Standard_True);
548 static Standard_Integer OCC232 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
550 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
551 if(aContext.IsNull()) {
552 di << "use 'vinit' command before " << argv[0] << "\n";
556 BRep_Builder builder;
557 TopoDS_Compound comp;
558 TopoDS_CompSolid cs1, cs2;
560 builder.MakeCompound(comp);
561 builder.MakeCompSolid(cs1);
562 builder.MakeCompSolid(cs2);
564 TopoDS_Shape sh1 = BRepPrimAPI_MakeBox(gp_Pnt(0, 0, 0), 100, 100, 100).Shape();
565 TopoDS_Shape sh2 = BRepPrimAPI_MakeBox(gp_Pnt(100, 0, 0), 100, 100, 100).Shape();
566 TopoDS_Shape sh3 = BRepPrimAPI_MakeBox(gp_Pnt(200, 0, 0), 100, 100, 100).Shape();
567 builder.Add(cs1, sh1);
568 builder.Add(cs1, sh2);
569 builder.Add(cs1, sh3);
571 TopoDS_Shape sh4 = BRepPrimAPI_MakeBox(gp_Pnt(0, 500, 0), 100, 100, 100).Shape();
572 TopoDS_Shape sh5 = BRepPrimAPI_MakeBox(gp_Pnt(100, 500, 0), 100, 100, 100).Shape();
573 TopoDS_Shape sh6 = BRepPrimAPI_MakeBox(gp_Pnt(200, 500, 0), 100, 100, 100).Shape();
575 builder.Add(cs2, sh4);
576 builder.Add(cs2, sh5);
577 builder.Add(cs2, sh6);
579 builder.Add(comp, cs1);
580 builder.Add(comp, cs2);
582 Handle(AIS_Shape) ais = new AIS_Shape(comp);
583 aContext->Display (ais, Standard_False);
585 TopExp_Explorer exp(comp, TopAbs_COMPSOLID);
588 //printf("\n TopAbs_COMPSOLID is there \n");
589 di << "\n TopAbs_COMPSOLID is there \n";
593 Handle (StdSelect_ShapeTypeFilter) filt = new StdSelect_ShapeTypeFilter(TopAbs_COMPSOLID);
594 aContext->AddFilter(filt);
595 Standard_DISABLE_DEPRECATION_WARNINGS
596 aContext->CloseAllContexts (Standard_False);
597 aContext->OpenLocalContext();
598 aContext->ActivateStandardMode(TopAbs_SOLID);
599 Standard_ENABLE_DEPRECATION_WARNINGS
601 aContext->UpdateCurrentViewer();
606 static Standard_Integer OCC138LC (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
608 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
609 if(aContext.IsNull()) {
610 di << "use 'vinit' command before " << argv[0] << "\n";
614 BRepPrimAPI_MakeBox box1(gp_Pnt(0, 0, 0), gp_Pnt(100, 100, 100));
615 BRepPrimAPI_MakeBox box2(gp_Pnt(120, 120, 120), gp_Pnt(300, 300,300));
616 BRepPrimAPI_MakeBox box3(gp_Pnt(320, 320, 320), gp_Pnt(500, 500,500));
618 Handle(AIS_InteractiveObject) ais1 = new AIS_Shape(box1.Shape());
619 Handle(AIS_InteractiveObject) ais2 = new AIS_Shape(box2.Shape());
620 Handle(AIS_InteractiveObject) ais3 = new AIS_Shape(box3.Shape());
622 aContext->Display (ais1, Standard_False);
623 aContext->Display (ais2, Standard_False);
624 aContext->Display (ais3, Standard_False);
626 aContext->AddOrRemoveSelected (ais1, Standard_False);
627 aContext->AddOrRemoveSelected (ais2, Standard_False);
628 aContext->AddOrRemoveSelected (ais3, Standard_False);
630 di << "\n No of selected = " << aContext->NbSelected();
632 aContext->InitSelected();
635 while(aContext->MoreSelected())
637 di << "\n count is = %d" << count++;
638 Handle(AIS_InteractiveObject) ais = aContext->SelectedInteractive();
639 aContext->AddOrRemoveSelected (ais, Standard_False);
640 aContext->InitSelected();
643 aContext->UpdateCurrentViewer();
648 #include <BRepBndLib.hxx>
650 //=======================================================================
653 //=======================================================================
654 static Standard_Integer OCC566(Draw_Interpretor& di,Standard_Integer n,const char ** a)
657 di<<"Usage: " << a[0] << " shape [ xmin ymin zmin xmax ymax zmax]\n";
660 TopoDS_Shape S = DBRep::Get(a[1]);
661 if (S.IsNull()) return 1;
663 BRepBndLib::AddClose(S,B);
664 Standard_Real axmin,aymin,azmin,axmax,aymax,azmax;
665 B.Get(axmin,aymin,azmin,axmax,aymax,azmax);
666 di << axmin<<" "<< aymin<<" "<< azmin<<" "<< axmax<<" "<< aymax<<" "<< azmax;
668 Draw::Set(a[2],axmin) ;
669 Draw::Set(a[3],aymin) ;
670 Draw::Set(a[4],azmin) ;
671 Draw::Set(a[5],axmax) ;
672 Draw::Set(a[6],aymax) ;
673 Draw::Set(a[7],azmax) ;
678 #include <BRepFilletAPI_MakeFillet.hxx>
679 //=======================================================================
682 //=======================================================================
683 static Standard_Integer OCC570 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
686 di<<"Usage: " << argv[0] << " result\n";
690 BRepPrimAPI_MakeBox mkBox(100.,100.,100.);
691 TopoDS_Shape aBox = mkBox.Shape();
693 TopExp_Explorer aExp;
694 aExp.Init(aBox,TopAbs_WIRE);
697 TopoDS_Shape aWire = aExp.Current();
699 aExp.Init(aWire,TopAbs_EDGE);
700 TopoDS_Edge e1 = TopoDS::Edge(aExp.Current()); aExp.Next();
701 TopoDS_Edge e2 = TopoDS::Edge(aExp.Current()); aExp.Next();
702 TopoDS_Edge e3 = TopoDS::Edge(aExp.Current()); aExp.Next();
703 TopoDS_Edge e4 = TopoDS::Edge(aExp.Current());
708 BRepFilletAPI_MakeFillet mkFillet(aBox);
709 mkFillet.SetContinuity(GeomAbs_C1,.001);
711 // Setup variable fillet data
712 TColgp_Array1OfPnt2d t_pnt(1,4);
713 t_pnt.SetValue(1,gp_Pnt2d(0.0,5.0));
714 t_pnt.SetValue(2,gp_Pnt2d(0.3,15.0));
715 t_pnt.SetValue(3,gp_Pnt2d(0.7,15.0));
716 t_pnt.SetValue(4,gp_Pnt2d(1.0,5.0));
719 // It is impossible to build fillet if at least one edge
720 // with variable radius is added!!! If all are constant, everything is ok.
721 mkFillet.Add(t_pnt,e1);
722 mkFillet.Add(5.0,e2);
723 mkFillet.Add(t_pnt,e3);
724 mkFillet.Add(5.0,e4);
727 TopoDS_Shape aFinalShape = mkFillet.Shape();
729 DBRep::Set(argv[1],aFinalShape);
731 catch(Standard_Failure)
733 di << argv[0] << ": Exception in fillet\n";
741 #include <Law_Interpol.hxx>
743 static Standard_Real t3d = 1.e-4;
744 static Standard_Real t2d = 1.e-5;
745 static Standard_Real ta = 1.e-2;
746 static Standard_Real fl = 1.e-3;
747 static Standard_Real tapp_angle = 1.e-2;
748 static GeomAbs_Shape blend_cont = GeomAbs_C1;
750 static BRepFilletAPI_MakeFillet* Rake = 0;
751 static char name[100];
753 static void printtolblend(Draw_Interpretor& di)
755 di<<"tolerance ang : "<<ta<<"\n";
756 di<<"tolerance 3d : "<<t3d<<"\n";
757 di<<"tolerance 2d : "<<t2d<<"\n";
758 di<<"fleche : "<<fl<<"\n";
760 di<<"tolblend "<<ta<<" "<<t3d<<" "<<t2d<<" "<<fl<<"\n";
763 static Standard_Integer MKEVOL(Draw_Interpretor& di,
764 Standard_Integer narg,
767 if(Rake != 0) {delete Rake; Rake = 0;}
769 if (narg < 3) return 1;
770 TopoDS_Shape V = DBRep::Get(a[2]);
771 Rake = new BRepFilletAPI_MakeFillet(V);
772 Rake->SetParams(ta,t3d,t2d,t3d,t2d,fl);
773 Rake->SetContinuity(blend_cont, tapp_angle);
775 ChFi3d_FilletShape FSh = ChFi3d_Rational;
776 if (!strcasecmp(a[3], "Q")) {
777 FSh = ChFi3d_QuasiAngular;
779 else if (!strcasecmp(a[3], "P")) {
780 FSh = ChFi3d_Polynomial;
782 Rake->SetFilletShape(FSh);
788 static Standard_Integer UPDATEVOL(Draw_Interpretor& di,
789 Standard_Integer narg,
793 di << "MakeFillet non initialise\n";
796 if(narg%2 != 0 || narg < 4) return 1;
797 TColgp_Array1OfPnt2d uandr(1,(narg/2)-1);
798 Standard_Real Rad, Par;
799 TopoDS_Shape aLocalEdge(DBRep::Get(a[1],TopAbs_EDGE));
800 TopoDS_Edge E = TopoDS::Edge(aLocalEdge);
801 for (Standard_Integer ii = 1; ii <= (narg/2)-1; ii++){
802 Par = Draw::Atof(a[2*ii]);
803 Rad = Draw::Atof(a[2*ii + 1]);
804 uandr.ChangeValue(ii).SetCoord(Par,Rad);
806 //HELPDESK: Add law creation
807 const Standard_Boolean aLawMode = !strcmp(a[0],"OCC570evollaw");
810 di<<"INFO: Using law to define variable fillet\n";
811 Handle(Law_Interpol) law = new Law_Interpol;
821 static Standard_Integer BUILDEVOL(Draw_Interpretor& di,
826 di << "MakeFillet non initialise\n";
831 TopoDS_Shape result = Rake->Shape();
832 DBRep::Set(name,result);
833 if(Rake != 0) {delete Rake; Rake = 0;}
836 if(Rake != 0) {delete Rake; Rake = 0;}
840 #include <TColGeom_SequenceOfCurve.hxx>
841 #include <Geom_TrimmedCurve.hxx>
842 #include <GeomFill_NSections.hxx>
843 #include <BRepBuilderAPI_MakeFace.hxx>
844 //=======================================================================
847 //=======================================================================
848 static Standard_Integer OCC606 ( Draw_Interpretor& di, Standard_Integer n, const char ** a )
850 if (n != 3 && n != 4)
852 di << "Usage : " << a[0] << " result shape [-t]\n";
856 Standard_Boolean TrimMode = (n == 4);
857 if (TrimMode) di<<"INFO: Using trimmed curves...\n";
858 else di<<"INFO: Using non trimmed curves...\n";
860 TopoDS_Shape S = DBRep::Get(a[2]);
862 TopExp_Explorer t_exp(S,TopAbs_EDGE);
863 TColGeom_SequenceOfCurve n_curves1;
864 TColStd_SequenceOfReal np;
865 Standard_Real param = 5.0;
867 for (;t_exp.More();t_exp.Next())
870 Handle(Geom_Curve) h_cur = BRep_Tool::Curve(TopoDS::Edge(t_exp.Current()),f,l);
873 if (TrimMode) h_cur = new Geom_TrimmedCurve(h_cur,f,l);
875 n_curves1.Append(h_cur);
881 if (n_curves1.Length()>1 && !np.IsEmpty())
886 GeomFill_NSections b_surface1(n_curves1, np);
887 b_surface1.ComputeSurface();
888 Handle(Geom_BSplineSurface) result_surf1 = b_surface1.BSplineSurface();
889 if (!result_surf1.IsNull())
891 BRepBuilderAPI_MakeFace b_face1(result_surf1, Precision::Confusion());
892 TopoDS_Face bsp_face1 = b_face1.Face();
893 DBRep::Set(a[1],bsp_face1);
896 catch(Standard_Failure)
898 di<<"ERROR: Exception in GeomFill_NSections\n";
906 //=======================================================================
909 //=======================================================================
910 static Standard_Integer OCC813 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
914 di << "Usage : " << argv[0] << " U V\n";
918 Standard_CString str;
919 Standard_Real U = Draw::Atof(argv[1]);
920 Standard_Real V = Draw::Atof(argv[2]);
922 //Between ellipse and point:
924 Handle(Geom_Ellipse) ell = new Geom_Ellipse(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
925 gp_Dir(0.173648,0.984808,0.000000),
926 gp_Dir(-0.932169,0.164367,-0.322560)), 150, 100);
927 Handle(Geom_Plane) plne = new Geom_Plane(gp_Ax3(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
928 gp_Dir(0.173648,0.984808,0.000000),
929 gp_Dir(-0.932169,0.164367,-0.322560))) );
931 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
934 gp_Pln pln = plne->Pln();
936 str = "OCC813_pnt"; DrawTrSurf::Set(str,pt2d);
938 Handle(Geom2d_Curve) curve2d = GeomAPI::To2d(ell,pln);
939 Geom2dAdaptor_Curve acur(curve2d);
940 Geom2dGcc_QualifiedCurve qcur(acur, GccEnt_outside);
942 str = "OCC813_ell"; DrawTrSurf::Set(str,curve2d);
943 if(!aContext.IsNull()) {
944 Handle(AIS_Shape) aisp =
945 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(curve2d, pln)).Edge());
946 aContext->Display (aisp, Standard_False);
949 //This does not give any solutions.
950 Geom2dGcc_Lin2d2Tan lintan(qcur, pt2d, 0.1);
951 di<<"OCC813 nb of solutions = "<<lintan.NbSolutions()<<"\n";
953 Standard_Character abuf[16];
954 Standard_CString st = abuf;
957 for(i=1;i<=lintan.NbSolutions();i++) {
958 Sprintf(abuf,"lintan_%d",i);
959 Handle(Geom2d_Line) glin = new Geom2d_Line(lintan.ThisSolution(i));
960 DrawTrSurf::Set(st,glin);
961 if(!aContext.IsNull()) {
962 Handle(AIS_Shape) aisp =
963 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(glin, pln)).Edge());
964 aContext->Display (aisp, Standard_False);
968 if (!aContext.IsNull())
970 aContext->UpdateCurrentViewer();
976 //=======================================================================
979 //=======================================================================
980 static Standard_Integer OCC814 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
984 di << "Usage : " << argv[0] << "\n";
988 Standard_CString str;
990 //Between Ellipse and Circle:
992 Handle(Geom_Circle) cir = new Geom_Circle(gp_Ax2(gp_Pnt(823.687192,502.366825,478.960440),
993 gp_Dir(0.173648,0.984808,0.000000),
994 gp_Dir(-0.932169,0.164367,-0.322560)), 50);
995 Handle(Geom_Ellipse) ell = new Geom_Ellipse(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
996 gp_Dir(0.173648,0.984808,0.000000),
997 gp_Dir(-0.932169,0.164367,-0.322560)), 150, 100);
998 Handle(Geom_Plane) plne = new Geom_Plane(gp_Ax3(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
999 gp_Dir(0.173648,0.984808,0.000000),
1000 gp_Dir(-0.932169,0.164367,-0.322560))) );
1002 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1004 gp_Pln pln = plne->Pln();
1005 Handle(Geom2d_Curve) curve2d = GeomAPI::To2d(ell, pln);
1006 Handle(Geom2d_Curve) fromcurve2d = GeomAPI::To2d(cir, pln);
1008 str = "OCC814_cir"; DrawTrSurf::Set(str,curve2d);
1009 str = "OCC814_ell"; DrawTrSurf::Set(str,fromcurve2d);
1010 if(!aContext.IsNull()) {
1011 Handle(AIS_Shape) aisp =
1012 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(curve2d, pln)).Edge());
1013 aContext->Display (aisp, Standard_False);
1015 if(!aContext.IsNull()) {
1016 Handle(AIS_Shape) aisp =
1017 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(fromcurve2d, pln)).Edge());
1018 aContext->Display (aisp, Standard_False);
1021 Geom2dAdaptor_Curve acur(curve2d), afromcur(fromcurve2d);
1023 Geom2dGcc_QualifiedCurve qcur(acur, GccEnt_outside) ;
1024 Geom2dGcc_QualifiedCurve qfromcur(afromcur, GccEnt_outside) ;
1026 //This does not give any solutions.
1027 Geom2dGcc_Lin2d2Tan lintan(qcur, qfromcur, 0.1);
1028 di<<"OCC814 nb of solutions = "<<lintan.NbSolutions()<<"\n";
1030 Standard_Character abuf[16];
1031 Standard_CString st = abuf;
1034 for(i=1;i<=lintan.NbSolutions();i++) {
1035 Sprintf(abuf,"lintan_%d",i);
1036 Handle(Geom2d_Line) glin = new Geom2d_Line(lintan.ThisSolution(i));
1037 DrawTrSurf::Set(st,glin);
1038 if(!aContext.IsNull()) {
1039 Handle(AIS_Shape) aisp =
1040 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(glin, pln)).Edge());
1041 aContext->Display (aisp, Standard_False);
1045 if (!aContext.IsNull())
1047 aContext->UpdateCurrentViewer();
1053 #include <ShapeAnalysis_Wire.hxx>
1054 #include <IntRes2d_SequenceOfIntersectionPoint.hxx>
1055 #include <TColgp_SequenceOfPnt.hxx>
1056 #include <ShapeFix_Wire.hxx>
1057 //=======================================================================
1060 //=======================================================================
1061 static Standard_Integer OCC884 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1063 if (argc < 3 || argc > 5)
1065 di << "Usage : " << argv[0] << " result shape [toler [maxtoler]]\n";
1069 TopoDS_Shape shape = DBRep::Get(argv[2]); //read the shape
1071 TopExp_Explorer exp(shape, TopAbs_EDGE);
1074 di<<"Error: no edge found\n";
1078 BRep_Builder builder;
1080 builder.MakeWire(wire);
1081 builder.Add(wire, TopoDS::Edge(exp.Current()));
1083 // HelpDesk: Create planar face if possible
1084 TopoDS_Face face = BRepBuilderAPI_MakeFace(wire,Standard_True);
1086 Handle(ShapeAnalysis_Wire) advWA = new ShapeAnalysis_Wire;
1088 advWA->SetFace(face);
1089 advWA->SetPrecision(0.001);
1091 IntRes2d_SequenceOfIntersectionPoint points2d;
1092 TColgp_SequenceOfPnt points3d;
1094 di << "Info: CheckSelfIntersectingEdge = " << (Standard_Integer) advWA->CheckSelfIntersectingEdge(1,points2d,points3d) << "\n";
1096 ShapeExtend_Status status = ShapeExtend_FAIL1;
1097 if (advWA->StatusSelfIntersection(status))
1098 di << "Info: No P Curve found in the edge\n";
1100 status = ShapeExtend_FAIL2;
1101 if (advWA->StatusSelfIntersection(status))
1102 di << "Info: No Vertices found in the edge\n";
1104 status = ShapeExtend_DONE1;
1105 if (advWA->StatusSelfIntersection(status))
1106 di << "Info: Self-intersection found in the edge\n";
1108 Standard_Integer i, num = points2d.Length();
1109 di << "Info: No. of self-intersection points : " << num << "\n";
1112 Standard_CString aName = str;
1113 for (i = 1; i <= num; ++i)
1115 gp_Pnt pt = points3d(i);
1116 di << "Info: Intersecting pt : (" << pt.X() << ", " << pt.Y() << ", " << pt.Z() << ")\n";
1117 Sprintf(str,"p_%d",i);
1118 DrawTrSurf::Set(aName,pt);
1121 Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire;
1125 if (argc > 3) sfw->SetPrecision(Draw::Atof(argv[3])/*0.1*/);
1126 if (argc > 4) sfw->SetMaxTolerance(Draw::Atof(argv[4]));
1127 di << "Info: Precision is set to " << sfw->Precision() << "\n";
1128 di << "Info: MaxTolerance is set to " << sfw->MaxTolerance() << "\n";
1130 sfw->ModifyTopologyMode() = 1;
1131 sfw->ModifyGeometryMode() = 1;
1132 sfw->FixSelfIntersectingEdgeMode() = 1;
1133 //printf("Info: FixSelfIntersection = %d\n",sfw->FixSelfIntersection());
1134 di << "Info: FixSelfIntersection = " << (Standard_Integer) sfw->FixSelfIntersection() << "\n";
1136 DBRep::Set(argv[1],sfw->Wire());
1138 status = ShapeExtend_OK;
1139 if (sfw->StatusSelfIntersection(status))
1140 di << "Info: ShapeExtend_OK : No intersection found\n";
1141 //printf("Info: ShapeExtend_OK : No intersection found\n");
1143 status = ShapeExtend_FAIL1;
1144 if (sfw->StatusSelfIntersection(status))
1145 di << "Info: ShapeExtend_FAIL1 : analysis failed (edge has no pcurve, or no vertices etc.)\n";
1147 status = ShapeExtend_FAIL2;
1148 if (sfw->StatusSelfIntersection(status))
1149 di << "Info: ShapeExtend_FAIL2 : self-intersection was found, but not fixed because of limit of increasing tolerance (MaxTolerance)\n";
1151 status = ShapeExtend_FAIL3;
1152 if (sfw->StatusSelfIntersection(status))
1153 di << "Info: ShapeExtend_FAIL3 : intercestion of non adjacent edges found, but not fixed because of limit of increasing tolerance (MaxTolerance)\n";
1155 status = ShapeExtend_DONE1;
1156 if (sfw->StatusSelfIntersection(status))
1157 di << "Info: ShapeExtend_DONE1 : tolerance of vertex was increased to fix self-intersection\n";
1159 status = ShapeExtend_DONE2;
1160 if (sfw->StatusSelfIntersection(status))
1161 di << "Info: ShapeExtend_DONE2 : vertex was moved to fix self-intersection\n";
1163 status = ShapeExtend_DONE3;
1164 if (sfw->StatusSelfIntersection(status))
1165 di << "Info: ShapeExtend_DONE3 : some edges were removed because of intersection\n";
1167 status = ShapeExtend_DONE4;
1168 if (sfw->StatusSelfIntersection(status))
1169 di << "Info: ShapeExtend_DONE4 : pcurve(s) was(were) modified\n";
1171 status = ShapeExtend_DONE5;
1172 if (sfw->StatusSelfIntersection(status))
1173 di << "Info: ShapeExtend_DONE5 : non adjacent intersection fixed by increasing tolerance of vertex(vertices)\n";
1175 status = ShapeExtend_DONE6;
1176 if (sfw->StatusSelfIntersection(status))
1177 di << "Info: ShapeExtend_DONE6 : tolerance of edge was increased to hide intersection\n";
1179 status = ShapeExtend_DONE7;
1180 if (sfw->StatusSelfIntersection(status))
1181 di << "Info: ShapeExtend_DONE7 : range of some edges was decreased to avoid intersection\n";
1186 #include <Aspect_FillMethod.hxx>
1187 //=======================================================================
1188 //function : OCC1188
1190 //=======================================================================
1191 static Standard_Integer OCC1188 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1193 if (argc < 2 || argc > 3)
1195 di << "Usage : " << argv[0] << " imagefile [filltype] : Load image as background\n";
1199 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1200 if(AISContext.IsNull())
1202 di << "use 'vinit' command before " << argv[0] << "\n";
1206 Aspect_FillMethod aFillType = Aspect_FM_CENTERED;
1209 const char* szType = argv[2];
1210 if (strcmp(szType, "NONE" ) == 0) aFillType = Aspect_FM_NONE;
1211 else if (strcmp(szType, "CENTERED") == 0) aFillType = Aspect_FM_CENTERED;
1212 else if (strcmp(szType, "TILED" ) == 0) aFillType = Aspect_FM_TILED;
1213 else if (strcmp(szType, "STRETCH" ) == 0) aFillType = Aspect_FM_STRETCH;
1216 di << "Wrong fill type : " << szType << "\n";
1217 di << "Must be one of CENTERED, TILED, STRETCH, NONE\n";
1222 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
1223 V3dView->SetBackgroundImage(argv[1], aFillType, Standard_True);
1228 #include <Graphic3d_MaterialAspect.hxx>
1229 #include <Prs3d_Drawer.hxx>
1230 #include <Prs3d_ShadingAspect.hxx>
1231 //=======================================================================
1232 //function : OCC1174_1
1234 //=======================================================================
1235 static Standard_Integer OCC1174_1 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1239 di << "Usage : " << argv[0] << " shape\n";
1243 Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
1244 if(anAISContext.IsNull())
1246 di << "use 'vinit' command before " << argv[0] << "\n";
1250 TopoDS_Shape aShape = DBRep::Get(argv[1]);
1252 Handle(AIS_Shape) anAisIO = new AIS_Shape(aShape);
1254 Quantity_Color aColF(0.0, 0.4, 0.0, Quantity_TOC_RGB);
1255 Quantity_Color aColB(0.0, 0.0, 0.6, Quantity_TOC_RGB);
1257 Handle(Prs3d_Drawer) aDrawer = anAisIO->Attributes();
1258 Handle(Prs3d_ShadingAspect) aShadingAspect = aDrawer->ShadingAspect();
1260 Graphic3d_MaterialAspect aFront = aShadingAspect->Material(Aspect_TOFM_FRONT_SIDE);
1261 aFront.SetAmbientColor(aColF);
1262 aFront.SetDiffuseColor(aColF);
1263 aFront.SetSpecularColor(aColF);
1264 aFront.SetEmissiveColor(aColF);
1265 aFront.SetTransparency(0.0);
1266 aShadingAspect->SetMaterial(aFront,Aspect_TOFM_FRONT_SIDE);
1268 Graphic3d_MaterialAspect aBack = aShadingAspect->Material(Aspect_TOFM_BACK_SIDE);
1269 aBack.SetAmbientColor(aColB);
1270 aBack.SetDiffuseColor(aColB);
1271 aBack.SetSpecularColor(aColB);
1272 aBack.SetEmissiveColor(aColB);
1273 aBack.SetTransparency(0.0);
1274 aShadingAspect->SetMaterial(aBack,Aspect_TOFM_BACK_SIDE);
1276 aDrawer->SetShadingAspect (aShadingAspect);
1278 anAISContext->Display (anAisIO, 1, 0, Standard_True);
1280 Standard_Real r, g, b;
1281 aShadingAspect->Color(Aspect_TOFM_FRONT_SIDE).Values(r,g,b, Quantity_TOC_RGB);
1282 di << "Info: color on front side (" << r << "," << g << "," << b << ")\n";
1283 aShadingAspect->Color(Aspect_TOFM_BACK_SIDE).Values(r,g,b, Quantity_TOC_RGB);
1284 di << "Info: color on back side (" << r << "," << g << "," << b << ")\n";
1289 //=======================================================================
1290 //function : OCC1174_2
1292 //=======================================================================
1293 static Standard_Integer OCC1174_2 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1297 di << "Usage : " << argv[0] << " shape\n";
1301 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1302 if(AISContext.IsNull())
1304 di << "use 'vinit' command before " << argv[0] << "\n";
1308 TopoDS_Shape sh = DBRep::Get(argv[1]);
1310 Handle(AIS_Shape) ais = new AIS_Shape(sh);
1311 AISContext->Display (ais, 1, 0, Standard_False);
1312 AISContext->SetMaterial (ais, Graphic3d_NOM_SHINY_PLASTIC, Standard_False);
1314 Quantity_Color colf(0.0, 0.4, 0.0, Quantity_TOC_RGB);
1315 Quantity_Color colb(0.0, 0.0, 0.6, Quantity_TOC_RGB);
1316 Handle(Prs3d_ShadingAspect) sa = ais->Attributes()->ShadingAspect();
1318 Graphic3d_MaterialAspect front = sa->Material(Aspect_TOFM_FRONT_SIDE);
1319 front.SetAmbientColor(colf);
1320 front.SetDiffuseColor(colf);
1321 front.SetSpecularColor(colf);
1322 front.SetEmissiveColor(colf);
1323 front.SetTransparency (0.4f);
1324 sa->SetMaterial(front,Aspect_TOFM_FRONT_SIDE);
1326 Graphic3d_MaterialAspect back = sa->Material(Aspect_TOFM_BACK_SIDE);
1327 back.SetAmbientColor(colb);
1328 back.SetDiffuseColor(colb);
1329 back.SetSpecularColor(colb);
1330 back.SetEmissiveColor(colb);
1331 back.SetTransparency (0.2f);
1332 sa->SetMaterial(back,Aspect_TOFM_BACK_SIDE);
1334 AISContext->Redisplay (ais, 1, 0);
1339 #include <TopoDS_Solid.hxx>
1340 #include <BRepFeat_MakeDPrism.hxx>
1341 //=======================================================================
1343 //purpose : FEATURE OPERATION (BOSS and SLOT)
1344 //=======================================================================
1345 static Standard_Integer OCCN1 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1349 di << "Usage : " << argv[0] << " angle fuse(1 for boss / 0 for slot) length\n";
1353 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1354 if(aContext.IsNull())
1356 di << "use 'vinit' command before " << argv[0] << "\n";
1359 Standard_Real angle = Draw::Atof(argv[1]);
1360 Standard_Integer fuse = Draw::Atoi(argv[2]);
1361 Standard_Real length = Draw::Atof(argv[3]);
1363 BRepBuilderAPI_MakeEdge edge1(gp_Pnt(0, 0, 0), gp_Pnt(50, 0, 0));
1364 BRepBuilderAPI_MakeEdge edge2(gp_Pnt(50, 0, 0), gp_Pnt(50, 50, 0));
1365 BRepBuilderAPI_MakeEdge edge3(gp_Pnt(50, 50, 0), gp_Pnt(0, 50, 0));
1366 BRepBuilderAPI_MakeEdge edge4(gp_Pnt(0, 50, 0), gp_Pnt(0, 0, 0));
1367 TopoDS_Edge ted1 = edge1.Edge();
1368 TopoDS_Edge ted2 = edge2.Edge();
1369 TopoDS_Edge ted3 = edge3.Edge();
1370 TopoDS_Edge ted4 = edge4.Edge();
1372 BRepBuilderAPI_MakeWire wire(ted1, ted2, ted3, ted4);
1373 TopoDS_Wire twire = wire.Wire();
1375 BRepBuilderAPI_MakeFace face(twire);
1376 TopoDS_Face tface = face.Face();
1377 ////////Handle(AIS_Shape) face_ais = new AIS_Shape( tface );
1378 ////////aContext->Display(face_ais);
1381 BRepPrimAPI_MakeBox block(gp_Pnt(-50, -50, -150), 150, 150, 100);
1382 box = block.Solid();
1384 TopoDS_Face top_face;
1385 top_face = block.TopFace();
1387 BRepFeat_MakeDPrism slot(box, tface, top_face, angle, fuse,
1390 slot.Perform(length);
1391 TopoDS_Shape S2 = slot.Shape();
1393 DBRep::Set("OCCN1_tface",tface);
1394 DBRep::Set("OCCN1_slot",S2);
1399 #include <BRepPrimAPI_MakeCylinder.hxx>
1400 #include <BRepPrimAPI_MakeSphere.hxx>
1401 #include <BRepAlgoAPI_Section.hxx>
1402 #include <BRepAlgo_Section.hxx>
1403 //=======================================================================
1405 //purpose : BOOLEAN OPERATION
1406 //=======================================================================
1407 static Standard_Integer OCCN2 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1410 di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]\n";
1413 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1415 Standard_Integer IsB = Draw::Atoi(argv[1]);
1417 IsBRepAlgoAPI = Standard_False;
1418 #if ! defined(BRepAlgo_def04)
1423 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1424 if(aContext.IsNull())
1426 di << "use 'vinit' command before " << argv[0] << "\n";
1430 BRepPrimAPI_MakeCylinder cylinder(50,200);
1431 TopoDS_Shape cylinder_sh = cylinder.Shape();
1433 BRepPrimAPI_MakeSphere sphere(gp_Pnt(60,0,100),50);
1434 TopoDS_Shape sphere_sh = sphere.Shape();
1436 //BRepAlgoAPI_Section section(cylinder_sh, sphere_sh);
1437 //TopoDS_Shape shape = section.Shape();
1440 if (IsBRepAlgoAPI) {
1441 di << "BRepAlgoAPI_Section section(cylinder_sh, sphere_sh)\n";
1442 BRepAlgoAPI_Section section(cylinder_sh, sphere_sh);
1444 if(!section.IsDone()){
1445 di << "Error performing intersection: not done.\n";
1447 shape = section.Shape();
1449 di << "BRepAlgo_Section section(cylinder_sh, sphere_sh)\n";
1450 BRepAlgo_Section section(cylinder_sh, sphere_sh);
1452 if(!section.IsDone()){
1453 di << "Error performing intersection: not done.\n";
1455 shape = section.Shape();
1458 DBRep::Set("OCCN2_cylinder",cylinder_sh);
1459 DBRep::Set("OCCN2_sphere",sphere_sh);
1460 DBRep::Set("OCCN2_section",shape);
1465 #include <TColgp_Array1OfPnt.hxx>
1466 #include <Geom_BezierCurve.hxx>
1468 static Standard_Integer OCC2569 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1470 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1471 if(aContext.IsNull())
1473 di << "use 'vinit' command before " << argv[0] << "\n";
1477 di << "Usage : " << argv[0] << " nbpoles result\n";
1481 int poles=Draw::Atoi(argv[1]);
1483 TColgp_Array1OfPnt arr(1, poles);
1484 for(int i=1; i<=poles; i++)
1485 arr.SetValue(i, gp_Pnt(i+10, i*2+20, i*3+45));
1487 Handle(Geom_BezierCurve) bez = new Geom_BezierCurve(arr);
1489 di << "\n The curve is not created.\n";
1491 di << "\n Degree = " << bez->Degree() << "\n";
1493 TopoDS_Edge sh = BRepBuilderAPI_MakeEdge(bez).Edge();
1494 Handle(AIS_Shape) ais = new AIS_Shape(sh);
1495 aContext->Display (ais, Standard_True);
1496 DrawTrSurf::Set(argv[2],bez);
1500 #include <TopTools_IndexedMapOfShape.hxx>
1501 #include <TopExp.hxx>
1503 static Standard_Integer OCC1642 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1506 di<<"Usage: " << argv[0] << " FinalWare FinalFace InitWare InitFace shape FixReorder FixDegenerated FixConnected FixSelfIntersection\n";
1510 TopoDS_Shape shape = DBRep::Get(argv[5]);
1512 TopExp_Explorer exp(shape, TopAbs_WIRE);
1513 TopoDS_Shape wire = exp.Current();
1515 Handle(ShapeAnalysis_Wire) advWA = new ShapeAnalysis_Wire;
1516 advWA->Load(TopoDS::Wire(wire));
1518 DBRep::Set(argv[3],wire);
1521 BRepBuilderAPI_MakeFace(TopoDS::Wire(wire),Standard_True);
1523 DBRep::Set(argv[4],face);
1525 advWA->SetFace(face);
1526 Standard_Real precision_to_ana = 0.0001;
1527 advWA->SetPrecision(precision_to_ana);
1529 TopTools_IndexedMapOfShape M;
1530 TopExp::MapShapes(wire, TopAbs_EDGE, M);
1533 for(j= 1; j<=M.Extent(); ++j) {
1534 Standard_Integer num=1;
1535 IntRes2d_SequenceOfIntersectionPoint points2d;
1536 TColgp_SequenceOfPnt points3d;
1538 cout << "\n j =" << j << ", CheckSelfIntersectingEdge = " <<
1539 advWA->CheckSelfIntersectingEdge(j, points2d, points3d);
1542 ShapeExtend_Status status = ShapeExtend_FAIL1;
1543 if(advWA->StatusSelfIntersection(status))
1545 status = ShapeExtend_FAIL2;
1546 if(advWA->StatusSelfIntersection(status))
1547 di << "\n No Vertices found in the edge";
1549 status = ShapeExtend_DONE1;
1550 if(advWA->StatusSelfIntersection(status))
1551 di << "\n Self-intersection found in the edge";
1553 num = points2d.Length();
1554 di << "\n No. of self-intersecting edges : " << num;
1556 for(int i=1; i<=num; ++i) {
1557 gp_Pnt pt = points3d(i);
1558 di << "\n Intersecting pt : (" << pt.X() << ", " << pt.Y()<< ", " << pt.Z() << ")";
1563 Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire;
1564 sfw->Load(TopoDS::Wire(wire));
1566 sfw->SetPrecision(Precision::Confusion());
1568 sfw->FixReorderMode() = 1;
1569 sfw->ClosedWireMode() = 1;
1570 sfw->FixDegeneratedMode() = 1;
1571 sfw->FixConnectedMode() = 1;
1572 sfw->ModifyTopologyMode() = 1;
1573 sfw->ModifyGeometryMode() = 1;
1574 sfw->FixSelfIntersectionMode() = 1;
1575 sfw->FixSelfIntersectingEdgeMode() = 1;
1576 sfw->FixIntersectingEdgesMode() = 1;
1577 sfw->FixNonAdjacentIntersectingEdgesMode() = 1;
1578 sfw->FixEdgeCurvesMode() = 1;
1580 sfw->ModifyRemoveLoopMode() = 1;
1581 sfw->SetMaxTolerance(1.0);
1583 di << "\n FixReorder = " << (Standard_Integer) sfw->FixReorder();
1584 di << "\n FixDegenerated = " << (Standard_Integer) sfw->FixDegenerated();
1585 di << "\n FixConnected = " << (Standard_Integer) sfw->FixConnected();
1587 di << "\n FixSelfIntersection = " << (Standard_Integer) sfw->FixSelfIntersection();
1590 Draw::Set(argv[6],sfw->FixReorder()) ;
1591 Draw::Set(argv[7],sfw->FixDegenerated()) ;
1592 Draw::Set(argv[8],sfw->FixConnected()) ;
1593 Draw::Set(argv[9],sfw->FixSelfIntersection()) ;
1595 ShapeExtend_Status status = ShapeExtend_OK;
1596 if(sfw->StatusSelfIntersection(status))
1597 di << "\n ShapeExtend_OK : No intersection found";
1599 status = ShapeExtend_FAIL1;
1600 if(sfw->StatusSelfIntersection(status))
1601 di << "\n ShapeExtend_FAIL1 : analysis failed (edge has no pcurve,or no vertices etc.)";
1603 status = ShapeExtend_FAIL2;
1604 if(sfw->StatusSelfIntersection(status))
1605 di << "\n ShapeExtend_FAIL2 : self-intersection was found, but not fixed because of limit of increasing tolerance (MaxTolerance)";
1607 status = ShapeExtend_FAIL3;
1608 if(sfw->StatusSelfIntersection(status))
1609 di << "\n ShapeExtend_FAIL3 : intercestion of non adjacent edges found, but not fixed because of limit of increasing tolerance (MaxTolerance)";
1611 status = ShapeExtend_DONE1;
1612 if(sfw->StatusSelfIntersection(status))
1613 di << "\n ShapeExtend_DONE1 : tolerance of vertex was increased to fix self-intersection";
1615 status = ShapeExtend_DONE2;
1616 if(sfw->StatusSelfIntersection(status))
1617 di << "\n ShapeExtend_DONE2 : vertex was moved to fix self-intersection";
1619 status = ShapeExtend_DONE3;
1620 if(sfw->StatusSelfIntersection(status))
1621 di << "\n ShapeExtend_DONE3 : some edges were removed because of intersection";
1623 status = ShapeExtend_DONE4;
1624 if(sfw->StatusSelfIntersection(status))
1625 di << "\n ShapeExtend_DONE4 : pcurve(s) was(were) modified";
1627 status = ShapeExtend_DONE5;
1628 if(sfw->StatusSelfIntersection(status))
1629 di << "\n ShapeExtend_DONE5 : non adjacent intersection fixed by increasing tolerance of vertex(vertices)";
1631 status = ShapeExtend_DONE6;
1632 if(sfw->StatusSelfIntersection(status))
1633 di << "\n ShapeExtend_DONE6 : tolerance of edge was increased to hide intersection";
1635 status = ShapeExtend_DONE7;
1636 if(sfw->StatusSelfIntersection(status))
1637 di << "\n ShapeExtend_DONE7 : range of some edges was decreased to avoid intersection";
1639 TopoDS_Wire finalwire = sfw->Wire();
1641 DBRep::Set(argv[1],finalwire);
1644 advWA->Load(TopoDS::Wire(finalwire));
1647 BRepBuilderAPI_MakeFace(TopoDS::Wire(finalwire),Standard_True);
1649 DBRep::Set(argv[2],fface);
1651 advWA->SetFace(fface);
1653 TopTools_IndexedMapOfShape fM;
1654 TopExp::MapShapes(finalwire, TopAbs_EDGE, fM);
1656 for(j= 1; j<=fM.Extent(); ++j) {
1657 Standard_Integer num=1;
1658 IntRes2d_SequenceOfIntersectionPoint points2d;
1659 TColgp_SequenceOfPnt points3d;
1661 di << "\n j =" << j << ", CheckSelfIntersectingEdge = " <<
1662 (Standard_Integer) advWA->CheckSelfIntersectingEdge(j, points2d, points3d);
1665 status = ShapeExtend_FAIL1;
1666 if(advWA->StatusSelfIntersection(status))
1668 status = ShapeExtend_FAIL2;
1669 if(advWA->StatusSelfIntersection(status))
1670 di << "\n No Vertices found in the edge";
1672 status = ShapeExtend_DONE1;
1673 if(advWA->StatusSelfIntersection(status))
1674 di << "\n Self-intersection found in the edge";
1676 num = points2d.Length();
1677 di << "\n No. of self-intersecting edges : " << num;
1679 for(int i=1; i<=num; ++i) {
1680 gp_Pnt pt = points3d(i);
1681 di << "\n Intersecting pt : (" << pt.X() << ", " << pt.Y() << ", " << pt.Z() << ")";
1691 void QABugs::Commands_17(Draw_Interpretor& theCommands) {
1692 const char *group = "QABugs";
1694 theCommands.Add ("BUC60842", "BUC60842", __FILE__, BUC60842, group);
1695 theCommands.Add ("BUC60843", "BUC60843 result_shape name_of_circle name_of_curve [ par1 [ tol ] ]", __FILE__, BUC60843, group);
1696 theCommands.Add ("BUC60970", "BUC60970 shape result", __FILE__, BUC60970, group);
1697 theCommands.Add ("BUC60818", "BUC60818", __FILE__, BUC60818, group);
1698 theCommands.Add ("BUC60915", "BUC60915", __FILE__, BUC60915_1, group);
1699 theCommands.Add ("OCC138", "OCC138", __FILE__, OCC138, group);
1700 theCommands.Add ("OCC353","OCC353",__FILE__,OCC353,group);
1701 theCommands.Add ("OCC280","OCC280 hlr=0/1 setsurfecedetail=0/1; set perspecrive view",__FILE__,OCC280,group);
1702 theCommands.Add ("OCC232", "OCC232", __FILE__, OCC232 , group);
1703 theCommands.Add ("OCC138LC", "OCC138LC", __FILE__, OCC138LC, group);
1704 theCommands.Add ("OCC566", "OCC566 shape [ xmin ymin zmin xmax ymax zmax] ; print bounding box", __FILE__, OCC566, group);
1705 theCommands.Add ("OCC570", "OCC570 result", __FILE__, OCC570, group);
1707 theCommands.Add("OCC570mkevol",
1708 "OCC570mkevol result object (then use updatevol) [R/Q/P]; mkevol",
1709 __FILE__, MKEVOL,group);
1710 theCommands.Add("OCC570updatevol",
1711 "OCC570updatevol edge u1 rad1 u2 rad2 ...; updatevol",
1712 __FILE__, UPDATEVOL,group);
1713 theCommands.Add("OCC570updatevollaw",
1714 "OCC570updatevollaw edge u1 rad1 u2 rad2 ...; updatevollaw",
1715 __FILE__, UPDATEVOL,group);
1716 theCommands.Add("OCC570buildevol",
1717 "OCC570buildevol; end of the evol fillet computation",
1718 __FILE__, BUILDEVOL,group);
1720 theCommands.Add ("OCC606", "OCC606 result shape [-t]", __FILE__, OCC606, group);
1722 theCommands.Add ("OCC813", "OCC813 U V", __FILE__, OCC813, group);
1723 theCommands.Add ("OCC814", "OCC814", __FILE__, OCC814, group);
1724 theCommands.Add ("OCC884", "OCC884 result shape [toler [maxtoler]]", __FILE__, OCC884, group);
1725 theCommands.Add ("OCC1188", "OCC1188 imagefile [filltype] : Load image as background", __FILE__, OCC1188, group);
1727 theCommands.Add ("OCC1174_1", "OCC1174_1 shape", __FILE__, OCC1174_1, group);
1728 theCommands.Add ("OCC1174_2", "OCC1174_2 shape", __FILE__, OCC1174_2, group);
1730 theCommands.Add ("OCCN1", "OCCN1 angle fuse(1 for boss / 0 for slot) length", __FILE__, OCCN1, group);
1731 theCommands.Add ("OCCN2", "OCCN2", __FILE__, OCCN2, group);
1733 theCommands.Add ("OCC2569", "OCC2569 nbpoles result", __FILE__, OCC2569, group);
1735 theCommands.Add ("OCC1642", "OCC1642 FinalWare FinalFace InitWare InitFace shape FixReorder FixDegenerated FixConnected FixSelfIntersection", __FILE__, OCC1642, group);