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 BUC60915_1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
249 di<<"Function don't has parameters\n";
253 if(ViewerTest::GetAISContext().IsNull())
255 di << "View was not created. Use 'vinit' command before "
259 Handle(AIS_InteractiveContext) context = ViewerTest::GetAISContext();
261 //The following dimesion code has problems regarding arrow_size. The desired effect is not produced.
262 /***************************************/
264 /***************************************/
265 gp_Pnt p1 = gp_Pnt(602.51,50.,0.);
266 gp_Pnt p2 = gp_Pnt(602.51,200.,0.);
267 gp_Pnt p3 = gp_Pnt(102.51,200.,0.);
268 gp_Pnt p4 = gp_Pnt(102.51,170.,0.);
269 gp_Pnt p5 = gp_Pnt(502.51,170.,0.);
270 gp_Pnt p6 = gp_Pnt(502.51,80.,0.);
271 gp_Pnt p7 = gp_Pnt(102.51,80.,0.);
272 gp_Pnt p8 = gp_Pnt(102.51,50.,0.);
273 TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(p1);
274 TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(p2);
275 TopoDS_Vertex V3 = BRepBuilderAPI_MakeVertex(p3);
276 TopoDS_Vertex V4 = BRepBuilderAPI_MakeVertex(p4);
277 TopoDS_Vertex V5 = BRepBuilderAPI_MakeVertex(p5);
278 TopoDS_Vertex V6 = BRepBuilderAPI_MakeVertex(p6);
279 TopoDS_Vertex V7 = BRepBuilderAPI_MakeVertex(p7);
280 TopoDS_Vertex V8 = BRepBuilderAPI_MakeVertex(p8);
281 gp_Pnt plnpt(0, 0, 0);
282 gp_Dir plndir(0, 0, 1);
283 Handle(Geom_Plane) pln = new Geom_Plane(plnpt,plndir);
284 Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
285 anAspect->MakeArrows3d (Standard_True);
286 anAspect->ArrowAspect()->SetAngle (M_PI/180.0 * 10.0);
287 /***************************************/
288 //dimension "L 502.51"
289 /***************************************/
290 Handle(AIS_LengthDimension) len = new AIS_LengthDimension(V2, V3, pln->Pln());
291 anAspect->ArrowAspect()->SetLength (30.0);
292 len->SetDimensionAspect (anAspect);
293 context->Display (len, Standard_False);
294 /***************************************/
296 /***************************************/
297 Handle(AIS_LengthDimension) len1 = new AIS_LengthDimension(V7, V4, pln->Pln());
298 len1->SetDimensionAspect (anAspect);
299 len1->SetFlyout (30.0);
300 anAspect->ArrowAspect()->SetLength (100.0);
301 context->Display (len1, Standard_False);
302 /***************************************/
304 /***************************************/
305 Handle(AIS_LengthDimension) len2 = new AIS_LengthDimension(V1, V2, pln->Pln());
306 len2->SetDimensionAspect (anAspect);
307 context->Display (len2, Standard_False);
308 /***************************************/
309 //dimension "R 88.58"
310 /***************************************/
311 gp_Circ cir = gp_Circ(gp_Ax2(gp_Pnt(191.09, -88.58, 0), gp_Dir(0, 0, 1)), 88.58);
312 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(cir,gp_Pnt(191.09,0,0.),gp_Pnt(191.09,-177.16,0.) );
313 Handle(AIS_RadiusDimension) dim1 = new AIS_RadiusDimension(E1);
314 dim1->SetDimensionAspect (anAspect);
315 context->Display (dim1, Standard_False);
316 /***************************************/
317 //dimension "R 43.80"
318 /***************************************/
319 gp_Circ cir1 = gp_Circ(gp_Ax2(gp_Pnt(191.09, -88.58, 0), gp_Dir(0, 0, 1)), 43.80);
320 TopoDS_Edge E_cir1 = BRepBuilderAPI_MakeEdge(cir1);
321 dim1 = new AIS_RadiusDimension(E_cir1);
322 anAspect->ArrowAspect()->SetLength (60.0);
323 dim1->SetDimensionAspect (anAspect);
324 context->Display (dim1, Standard_False);
325 /***************************************/
326 //dimension "R 17.86"
327 /***************************************/
328 gp_Circ cir2 = gp_Circ(gp_Ax2(gp_Pnt(566.11, -88.58, 0), gp_Dir(0, 0, -1)), 17.86);
329 TopoDS_Edge E_cir2 = BRepBuilderAPI_MakeEdge(cir2);
330 dim1 = new AIS_RadiusDimension(E_cir2);
331 anAspect->ArrowAspect()->SetLength (40.0);
332 dim1->SetDimensionAspect (anAspect);
333 context->Display (dim1, Standard_True);
338 static Standard_Integer OCC138 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
340 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
341 if(aContext.IsNull()) {
342 di << "use 'vinit' command before " << argv[0] << "\n";
346 BRepPrimAPI_MakeBox box1(gp_Pnt(0, 0, 0), gp_Pnt(100, 100, 100));
347 BRepPrimAPI_MakeBox box2(gp_Pnt(120, 120, 120), gp_Pnt(300, 300,300));
348 BRepPrimAPI_MakeBox box3(gp_Pnt(320, 320, 320), gp_Pnt(500, 500,500));
350 Handle(AIS_InteractiveObject) ais1 = new AIS_Shape(box1.Shape());
351 Handle(AIS_InteractiveObject) ais2 = new AIS_Shape(box2.Shape());
352 Handle(AIS_InteractiveObject) ais3 = new AIS_Shape(box3.Shape());
354 aContext->Display (ais1, Standard_False);
355 aContext->Display (ais2, Standard_False);
356 aContext->Display (ais3, Standard_False);
358 aContext->AddOrRemoveSelected (ais1, Standard_False);
359 aContext->AddOrRemoveSelected (ais2, Standard_False);
360 aContext->AddOrRemoveSelected (ais3, Standard_False);
362 di << "\n No of currents = " << aContext->NbSelected();
364 aContext->InitSelected();
367 while(aContext->MoreSelected())
369 di << "\n count is = " << count++;
370 Handle(AIS_InteractiveObject) ais = aContext->SelectedInteractive();
371 aContext->AddOrRemoveSelected (ais, Standard_False);
372 aContext->InitSelected();
375 aContext->UpdateCurrentViewer();
380 static int geom_get_2Dpt_from_3Dpt(const gp_Pnt& pnt3d, const gp_Pln& pln, gp_Pnt2d& pnt2d)
383 Handle(Geom_Plane) gpln = new Geom_Plane(pln);
384 GeomAdaptor_Surface adsur(gpln);
385 Extrema_ExtPS extps(pnt3d, adsur, 0.001, 0.001);
389 for(index=1; index<= extps.NbExt(); index++ )
391 Extrema_POnSurf pons = extps.Point(index);
393 pons.Parameter(U, V);
394 pnt2d.SetCoord(U, V);
401 static Standard_Integer OCC353 (Draw_Interpretor& di, Standard_Integer , const char ** )
403 gp_Ax2 ax21( gp_Pnt(100,0,0), gp_Dir(0,0,1) );
404 Handle(Geom_Circle) h_cir1 = new Geom_Circle( ax21, 25 );
406 gp_Ax2 ax22( gp_Pnt(-100,0,0), gp_Dir(0,0,1) );
407 Handle(Geom_Circle) h_cir2 = new Geom_Circle( ax22, 25 );
409 gp_Pln refpln( gp_Pnt(0,0,0), gp_Dir(0,0,1) );
410 Handle(Geom2d_Curve) cir2d1 = GeomAPI::To2d(h_cir1, refpln);
411 Handle(Geom2d_Curve) cir2d2 = GeomAPI::To2d(h_cir2, refpln);
413 Geom2dAdaptor_Curve adop1(cir2d1);
414 Geom2dAdaptor_Curve adop2(cir2d2);
416 Geom2dGcc_QualifiedCurve qcur1(adop1, GccEnt_enclosing);
417 Geom2dGcc_QualifiedCurve qcur2(adop2, GccEnt_enclosing);
419 Handle(Geom_CartesianPoint) h_carpt = new Geom_CartesianPoint(0,175,0);
421 gp_Pnt pt3d = h_carpt->Pnt();
423 geom_get_2Dpt_from_3Dpt(pt3d, refpln, pt2d);
427 DrawTrSurf::Set(st,cir2d1);
429 DrawTrSurf::Set(st,cir2d2);
431 DrawTrSurf::Set(st,pt2d);
433 Handle(Geom2d_CartesianPoint) pt = new Geom2d_CartesianPoint(pt2d);
434 Geom2dGcc_Circ2d3Tan sol( qcur1, qcur2, pt, 0.001, 0.0, 0.0);
437 Standard_Character buf[10];
441 res = sol.NbSolutions();
442 for(Standard_Integer i=1;i<=res;i++) {
443 Handle(Geom2d_Circle) aC = new Geom2d_Circle(sol.ThisSolution(i));
444 Sprintf(buf,"Result_%d",i);
446 DrawTrSurf::Set(st,aC);
450 di << "\n Faulty: no solutions found ";
451 //printf("\n Faulty: no solutions found ");
453 //printf("\n Num of solutions are %d ", res );
454 di << "\n Num of solutions are " << res << " ";
459 static Standard_Integer OCC280 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
461 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
462 if(aContext.IsNull())
464 di << "use 'vinit' command before " << argv[0] << "\n";
468 di << "ERROR : Usage : " << argv[0] << " hlr=0/1 setsurfecedetail=0/1; set perspecrive view\n";
472 Standard_Integer HLR = Draw::Atoi(argv[1]);
477 TCollection_AsciiString anOldName = ViewerTest::GetCurrentViewName();
478 Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
479 aViewer->SetDefaultTypeOfView (V3d_PERSPECTIVE);
480 Handle(Aspect_Window) asp = ViewerTest::CurrentView()->Window();
481 Handle(V3d_View) aNewView = aViewer->CreateView();
482 ViewerTest::CurrentView (aNewView);
483 TCollection_AsciiString aNewName=anOldName + "_new";
484 ViewerTest::InitViewName(aNewName,ViewerTest::CurrentView());
485 aNewView->SetWindow (asp);
486 if (!asp->IsMapped()) asp->Map();
488 ViewerTest::RemoveView(anOldName,false);
489 ViewerTest::UnsetEventManager();
490 ViewerTest::SetEventManager (new ViewerTest_EventManager (aNewView, ViewerTest::GetAISContext()));
495 ViewerTest::CurrentView()->SetComputedMode (Standard_True);
501 static Standard_Integer OCC138LC (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
503 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
504 if(aContext.IsNull()) {
505 di << "use 'vinit' command before " << argv[0] << "\n";
509 BRepPrimAPI_MakeBox box1(gp_Pnt(0, 0, 0), gp_Pnt(100, 100, 100));
510 BRepPrimAPI_MakeBox box2(gp_Pnt(120, 120, 120), gp_Pnt(300, 300,300));
511 BRepPrimAPI_MakeBox box3(gp_Pnt(320, 320, 320), gp_Pnt(500, 500,500));
513 Handle(AIS_InteractiveObject) ais1 = new AIS_Shape(box1.Shape());
514 Handle(AIS_InteractiveObject) ais2 = new AIS_Shape(box2.Shape());
515 Handle(AIS_InteractiveObject) ais3 = new AIS_Shape(box3.Shape());
517 aContext->Display (ais1, Standard_False);
518 aContext->Display (ais2, Standard_False);
519 aContext->Display (ais3, Standard_False);
521 aContext->AddOrRemoveSelected (ais1, Standard_False);
522 aContext->AddOrRemoveSelected (ais2, Standard_False);
523 aContext->AddOrRemoveSelected (ais3, Standard_False);
525 di << "\n No of selected = " << aContext->NbSelected();
527 aContext->InitSelected();
530 while(aContext->MoreSelected())
532 di << "\n count is = %d" << count++;
533 Handle(AIS_InteractiveObject) ais = aContext->SelectedInteractive();
534 aContext->AddOrRemoveSelected (ais, Standard_False);
535 aContext->InitSelected();
538 aContext->UpdateCurrentViewer();
543 #include <BRepBndLib.hxx>
545 //=======================================================================
548 //=======================================================================
549 static Standard_Integer OCC566(Draw_Interpretor& di,Standard_Integer n,const char ** a)
552 di<<"Usage: " << a[0] << " shape [ xmin ymin zmin xmax ymax zmax]\n";
555 TopoDS_Shape S = DBRep::Get(a[1]);
556 if (S.IsNull()) return 1;
558 BRepBndLib::AddClose(S,B);
559 Standard_Real axmin,aymin,azmin,axmax,aymax,azmax;
560 B.Get(axmin,aymin,azmin,axmax,aymax,azmax);
561 di << axmin<<" "<< aymin<<" "<< azmin<<" "<< axmax<<" "<< aymax<<" "<< azmax;
563 Draw::Set(a[2],axmin) ;
564 Draw::Set(a[3],aymin) ;
565 Draw::Set(a[4],azmin) ;
566 Draw::Set(a[5],axmax) ;
567 Draw::Set(a[6],aymax) ;
568 Draw::Set(a[7],azmax) ;
573 #include <BRepFilletAPI_MakeFillet.hxx>
574 //=======================================================================
577 //=======================================================================
578 static Standard_Integer OCC570 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
581 di<<"Usage: " << argv[0] << " result\n";
585 BRepPrimAPI_MakeBox mkBox(100.,100.,100.);
586 TopoDS_Shape aBox = mkBox.Shape();
588 TopExp_Explorer aExp;
589 aExp.Init(aBox,TopAbs_WIRE);
592 TopoDS_Shape aWire = aExp.Current();
594 aExp.Init(aWire,TopAbs_EDGE);
595 TopoDS_Edge e1 = TopoDS::Edge(aExp.Current()); aExp.Next();
596 TopoDS_Edge e2 = TopoDS::Edge(aExp.Current()); aExp.Next();
597 TopoDS_Edge e3 = TopoDS::Edge(aExp.Current()); aExp.Next();
598 TopoDS_Edge e4 = TopoDS::Edge(aExp.Current());
603 BRepFilletAPI_MakeFillet mkFillet(aBox);
604 mkFillet.SetContinuity(GeomAbs_C1,.001);
606 // Setup variable fillet data
607 TColgp_Array1OfPnt2d t_pnt(1,4);
608 t_pnt.SetValue(1,gp_Pnt2d(0.0,5.0));
609 t_pnt.SetValue(2,gp_Pnt2d(0.3,15.0));
610 t_pnt.SetValue(3,gp_Pnt2d(0.7,15.0));
611 t_pnt.SetValue(4,gp_Pnt2d(1.0,5.0));
614 // It is impossible to build fillet if at least one edge
615 // with variable radius is added!!! If all are constant, everything is ok.
616 mkFillet.Add(t_pnt,e1);
617 mkFillet.Add(5.0,e2);
618 mkFillet.Add(t_pnt,e3);
619 mkFillet.Add(5.0,e4);
622 TopoDS_Shape aFinalShape = mkFillet.Shape();
624 DBRep::Set(argv[1],aFinalShape);
626 catch(Standard_Failure)
628 di << argv[0] << ": Exception in fillet\n";
636 #include <Law_Interpol.hxx>
638 static Standard_Real t3d = 1.e-4;
639 static Standard_Real t2d = 1.e-5;
640 static Standard_Real ta = 1.e-2;
641 static Standard_Real fl = 1.e-3;
642 static Standard_Real tapp_angle = 1.e-2;
643 static GeomAbs_Shape blend_cont = GeomAbs_C1;
645 static BRepFilletAPI_MakeFillet* Rake = 0;
646 static char name[100];
648 static void printtolblend(Draw_Interpretor& di)
650 di<<"tolerance ang : "<<ta<<"\n";
651 di<<"tolerance 3d : "<<t3d<<"\n";
652 di<<"tolerance 2d : "<<t2d<<"\n";
653 di<<"fleche : "<<fl<<"\n";
655 di<<"tolblend "<<ta<<" "<<t3d<<" "<<t2d<<" "<<fl<<"\n";
658 static Standard_Integer MKEVOL(Draw_Interpretor& di,
659 Standard_Integer narg,
662 if(Rake != 0) {delete Rake; Rake = 0;}
664 if (narg < 3) return 1;
665 TopoDS_Shape V = DBRep::Get(a[2]);
666 Rake = new BRepFilletAPI_MakeFillet(V);
667 Rake->SetParams(ta,t3d,t2d,t3d,t2d,fl);
668 Rake->SetContinuity(blend_cont, tapp_angle);
670 ChFi3d_FilletShape FSh = ChFi3d_Rational;
671 if (!strcasecmp(a[3], "Q")) {
672 FSh = ChFi3d_QuasiAngular;
674 else if (!strcasecmp(a[3], "P")) {
675 FSh = ChFi3d_Polynomial;
677 Rake->SetFilletShape(FSh);
683 static Standard_Integer UPDATEVOL(Draw_Interpretor& di,
684 Standard_Integer narg,
688 di << "MakeFillet non initialise\n";
691 if(narg%2 != 0 || narg < 4) return 1;
692 TColgp_Array1OfPnt2d uandr(1,(narg/2)-1);
693 Standard_Real Rad, Par;
694 TopoDS_Shape aLocalEdge(DBRep::Get(a[1],TopAbs_EDGE));
695 TopoDS_Edge E = TopoDS::Edge(aLocalEdge);
696 for (Standard_Integer ii = 1; ii <= (narg/2)-1; ii++){
697 Par = Draw::Atof(a[2*ii]);
698 Rad = Draw::Atof(a[2*ii + 1]);
699 uandr.ChangeValue(ii).SetCoord(Par,Rad);
701 //HELPDESK: Add law creation
702 const Standard_Boolean aLawMode = !strcmp(a[0],"OCC570evollaw");
705 di<<"INFO: Using law to define variable fillet\n";
706 Handle(Law_Interpol) law = new Law_Interpol;
716 static Standard_Integer BUILDEVOL(Draw_Interpretor& di,
721 di << "MakeFillet non initialise\n";
726 TopoDS_Shape result = Rake->Shape();
727 DBRep::Set(name,result);
728 if(Rake != 0) {delete Rake; Rake = 0;}
731 if(Rake != 0) {delete Rake; Rake = 0;}
735 #include <TColGeom_SequenceOfCurve.hxx>
736 #include <Geom_TrimmedCurve.hxx>
737 #include <GeomFill_NSections.hxx>
738 #include <BRepBuilderAPI_MakeFace.hxx>
739 //=======================================================================
742 //=======================================================================
743 static Standard_Integer OCC606 ( Draw_Interpretor& di, Standard_Integer n, const char ** a )
745 if (n != 3 && n != 4)
747 di << "Usage : " << a[0] << " result shape [-t]\n";
751 Standard_Boolean TrimMode = (n == 4);
752 if (TrimMode) di<<"INFO: Using trimmed curves...\n";
753 else di<<"INFO: Using non trimmed curves...\n";
755 TopoDS_Shape S = DBRep::Get(a[2]);
757 TopExp_Explorer t_exp(S,TopAbs_EDGE);
758 TColGeom_SequenceOfCurve n_curves1;
759 TColStd_SequenceOfReal np;
760 Standard_Real param = 5.0;
762 for (;t_exp.More();t_exp.Next())
765 Handle(Geom_Curve) h_cur = BRep_Tool::Curve(TopoDS::Edge(t_exp.Current()),f,l);
768 if (TrimMode) h_cur = new Geom_TrimmedCurve(h_cur,f,l);
770 n_curves1.Append(h_cur);
776 if (n_curves1.Length()>1 && !np.IsEmpty())
781 GeomFill_NSections b_surface1(n_curves1, np);
782 b_surface1.ComputeSurface();
783 Handle(Geom_BSplineSurface) result_surf1 = b_surface1.BSplineSurface();
784 if (!result_surf1.IsNull())
786 BRepBuilderAPI_MakeFace b_face1(result_surf1, Precision::Confusion());
787 TopoDS_Face bsp_face1 = b_face1.Face();
788 DBRep::Set(a[1],bsp_face1);
791 catch(Standard_Failure)
793 di<<"ERROR: Exception in GeomFill_NSections\n";
801 //=======================================================================
804 //=======================================================================
805 static Standard_Integer OCC813 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
809 di << "Usage : " << argv[0] << " U V\n";
813 Standard_CString str;
814 Standard_Real U = Draw::Atof(argv[1]);
815 Standard_Real V = Draw::Atof(argv[2]);
817 //Between ellipse and point:
819 Handle(Geom_Ellipse) ell = new Geom_Ellipse(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
820 gp_Dir(0.173648,0.984808,0.000000),
821 gp_Dir(-0.932169,0.164367,-0.322560)), 150, 100);
822 Handle(Geom_Plane) plne = new Geom_Plane(gp_Ax3(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
823 gp_Dir(0.173648,0.984808,0.000000),
824 gp_Dir(-0.932169,0.164367,-0.322560))) );
826 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
829 gp_Pln pln = plne->Pln();
831 str = "OCC813_pnt"; DrawTrSurf::Set(str,pt2d);
833 Handle(Geom2d_Curve) curve2d = GeomAPI::To2d(ell,pln);
834 Geom2dAdaptor_Curve acur(curve2d);
835 Geom2dGcc_QualifiedCurve qcur(acur, GccEnt_outside);
837 str = "OCC813_ell"; DrawTrSurf::Set(str,curve2d);
838 if(!aContext.IsNull()) {
839 Handle(AIS_Shape) aisp =
840 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(curve2d, pln)).Edge());
841 aContext->Display (aisp, Standard_False);
844 //This does not give any solutions.
845 Geom2dGcc_Lin2d2Tan lintan(qcur, pt2d, 0.1);
846 di<<"OCC813 nb of solutions = "<<lintan.NbSolutions()<<"\n";
848 Standard_Character abuf[16];
849 Standard_CString st = abuf;
852 for(i=1;i<=lintan.NbSolutions();i++) {
853 Sprintf(abuf,"lintan_%d",i);
854 Handle(Geom2d_Line) glin = new Geom2d_Line(lintan.ThisSolution(i));
855 DrawTrSurf::Set(st,glin);
856 if(!aContext.IsNull()) {
857 Handle(AIS_Shape) aisp =
858 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(glin, pln)).Edge());
859 aContext->Display (aisp, Standard_False);
863 if (!aContext.IsNull())
865 aContext->UpdateCurrentViewer();
871 //=======================================================================
874 //=======================================================================
875 static Standard_Integer OCC814 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
879 di << "Usage : " << argv[0] << "\n";
883 Standard_CString str;
885 //Between Ellipse and Circle:
887 Handle(Geom_Circle) cir = new Geom_Circle(gp_Ax2(gp_Pnt(823.687192,502.366825,478.960440),
888 gp_Dir(0.173648,0.984808,0.000000),
889 gp_Dir(-0.932169,0.164367,-0.322560)), 50);
890 Handle(Geom_Ellipse) ell = new Geom_Ellipse(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
891 gp_Dir(0.173648,0.984808,0.000000),
892 gp_Dir(-0.932169,0.164367,-0.322560)), 150, 100);
893 Handle(Geom_Plane) plne = new Geom_Plane(gp_Ax3(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
894 gp_Dir(0.173648,0.984808,0.000000),
895 gp_Dir(-0.932169,0.164367,-0.322560))) );
897 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
899 gp_Pln pln = plne->Pln();
900 Handle(Geom2d_Curve) curve2d = GeomAPI::To2d(ell, pln);
901 Handle(Geom2d_Curve) fromcurve2d = GeomAPI::To2d(cir, pln);
903 str = "OCC814_cir"; DrawTrSurf::Set(str,curve2d);
904 str = "OCC814_ell"; DrawTrSurf::Set(str,fromcurve2d);
905 if(!aContext.IsNull()) {
906 Handle(AIS_Shape) aisp =
907 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(curve2d, pln)).Edge());
908 aContext->Display (aisp, Standard_False);
910 if(!aContext.IsNull()) {
911 Handle(AIS_Shape) aisp =
912 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(fromcurve2d, pln)).Edge());
913 aContext->Display (aisp, Standard_False);
916 Geom2dAdaptor_Curve acur(curve2d), afromcur(fromcurve2d);
918 Geom2dGcc_QualifiedCurve qcur(acur, GccEnt_outside) ;
919 Geom2dGcc_QualifiedCurve qfromcur(afromcur, GccEnt_outside) ;
921 //This does not give any solutions.
922 Geom2dGcc_Lin2d2Tan lintan(qcur, qfromcur, 0.1);
923 di<<"OCC814 nb of solutions = "<<lintan.NbSolutions()<<"\n";
925 Standard_Character abuf[16];
926 Standard_CString st = abuf;
929 for(i=1;i<=lintan.NbSolutions();i++) {
930 Sprintf(abuf,"lintan_%d",i);
931 Handle(Geom2d_Line) glin = new Geom2d_Line(lintan.ThisSolution(i));
932 DrawTrSurf::Set(st,glin);
933 if(!aContext.IsNull()) {
934 Handle(AIS_Shape) aisp =
935 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(glin, pln)).Edge());
936 aContext->Display (aisp, Standard_False);
940 if (!aContext.IsNull())
942 aContext->UpdateCurrentViewer();
948 #include <ShapeAnalysis_Wire.hxx>
949 #include <IntRes2d_SequenceOfIntersectionPoint.hxx>
950 #include <TColgp_SequenceOfPnt.hxx>
951 #include <ShapeFix_Wire.hxx>
952 //=======================================================================
955 //=======================================================================
956 static Standard_Integer OCC884 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
958 if (argc < 3 || argc > 5)
960 di << "Usage : " << argv[0] << " result shape [toler [maxtoler]]\n";
964 TopoDS_Shape shape = DBRep::Get(argv[2]); //read the shape
966 TopExp_Explorer exp(shape, TopAbs_EDGE);
969 di<<"Error: no edge found\n";
973 BRep_Builder builder;
975 builder.MakeWire(wire);
976 builder.Add(wire, TopoDS::Edge(exp.Current()));
978 // HelpDesk: Create planar face if possible
979 TopoDS_Face face = BRepBuilderAPI_MakeFace(wire,Standard_True);
981 Handle(ShapeAnalysis_Wire) advWA = new ShapeAnalysis_Wire;
983 advWA->SetFace(face);
984 advWA->SetPrecision(0.001);
986 IntRes2d_SequenceOfIntersectionPoint points2d;
987 TColgp_SequenceOfPnt points3d;
989 di << "Info: CheckSelfIntersectingEdge = " << (Standard_Integer) advWA->CheckSelfIntersectingEdge(1,points2d,points3d) << "\n";
991 ShapeExtend_Status status = ShapeExtend_FAIL1;
992 if (advWA->StatusSelfIntersection(status))
993 di << "Info: No P Curve found in the edge\n";
995 status = ShapeExtend_FAIL2;
996 if (advWA->StatusSelfIntersection(status))
997 di << "Info: No Vertices found in the edge\n";
999 status = ShapeExtend_DONE1;
1000 if (advWA->StatusSelfIntersection(status))
1001 di << "Info: Self-intersection found in the edge\n";
1003 Standard_Integer i, num = points2d.Length();
1004 di << "Info: No. of self-intersection points : " << num << "\n";
1007 Standard_CString aName = str;
1008 for (i = 1; i <= num; ++i)
1010 gp_Pnt pt = points3d(i);
1011 di << "Info: Intersecting pt : (" << pt.X() << ", " << pt.Y() << ", " << pt.Z() << ")\n";
1012 Sprintf(str,"p_%d",i);
1013 DrawTrSurf::Set(aName,pt);
1016 Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire;
1020 if (argc > 3) sfw->SetPrecision(Draw::Atof(argv[3])/*0.1*/);
1021 if (argc > 4) sfw->SetMaxTolerance(Draw::Atof(argv[4]));
1022 di << "Info: Precision is set to " << sfw->Precision() << "\n";
1023 di << "Info: MaxTolerance is set to " << sfw->MaxTolerance() << "\n";
1025 sfw->ModifyTopologyMode() = 1;
1026 sfw->ModifyGeometryMode() = 1;
1027 sfw->FixSelfIntersectingEdgeMode() = 1;
1028 //printf("Info: FixSelfIntersection = %d\n",sfw->FixSelfIntersection());
1029 di << "Info: FixSelfIntersection = " << (Standard_Integer) sfw->FixSelfIntersection() << "\n";
1031 DBRep::Set(argv[1],sfw->Wire());
1033 status = ShapeExtend_OK;
1034 if (sfw->StatusSelfIntersection(status))
1035 di << "Info: ShapeExtend_OK : No intersection found\n";
1036 //printf("Info: ShapeExtend_OK : No intersection found\n");
1038 status = ShapeExtend_FAIL1;
1039 if (sfw->StatusSelfIntersection(status))
1040 di << "Info: ShapeExtend_FAIL1 : analysis failed (edge has no pcurve, or no vertices etc.)\n";
1042 status = ShapeExtend_FAIL2;
1043 if (sfw->StatusSelfIntersection(status))
1044 di << "Info: ShapeExtend_FAIL2 : self-intersection was found, but not fixed because of limit of increasing tolerance (MaxTolerance)\n";
1046 status = ShapeExtend_FAIL3;
1047 if (sfw->StatusSelfIntersection(status))
1048 di << "Info: ShapeExtend_FAIL3 : intercestion of non adjacent edges found, but not fixed because of limit of increasing tolerance (MaxTolerance)\n";
1050 status = ShapeExtend_DONE1;
1051 if (sfw->StatusSelfIntersection(status))
1052 di << "Info: ShapeExtend_DONE1 : tolerance of vertex was increased to fix self-intersection\n";
1054 status = ShapeExtend_DONE2;
1055 if (sfw->StatusSelfIntersection(status))
1056 di << "Info: ShapeExtend_DONE2 : vertex was moved to fix self-intersection\n";
1058 status = ShapeExtend_DONE3;
1059 if (sfw->StatusSelfIntersection(status))
1060 di << "Info: ShapeExtend_DONE3 : some edges were removed because of intersection\n";
1062 status = ShapeExtend_DONE4;
1063 if (sfw->StatusSelfIntersection(status))
1064 di << "Info: ShapeExtend_DONE4 : pcurve(s) was(were) modified\n";
1066 status = ShapeExtend_DONE5;
1067 if (sfw->StatusSelfIntersection(status))
1068 di << "Info: ShapeExtend_DONE5 : non adjacent intersection fixed by increasing tolerance of vertex(vertices)\n";
1070 status = ShapeExtend_DONE6;
1071 if (sfw->StatusSelfIntersection(status))
1072 di << "Info: ShapeExtend_DONE6 : tolerance of edge was increased to hide intersection\n";
1074 status = ShapeExtend_DONE7;
1075 if (sfw->StatusSelfIntersection(status))
1076 di << "Info: ShapeExtend_DONE7 : range of some edges was decreased to avoid intersection\n";
1081 #include <Aspect_FillMethod.hxx>
1082 //=======================================================================
1083 //function : OCC1188
1085 //=======================================================================
1086 static Standard_Integer OCC1188 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1088 if (argc < 2 || argc > 3)
1090 di << "Usage : " << argv[0] << " imagefile [filltype] : Load image as background\n";
1094 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1095 if(AISContext.IsNull())
1097 di << "use 'vinit' command before " << argv[0] << "\n";
1101 Aspect_FillMethod aFillType = Aspect_FM_CENTERED;
1104 const char* szType = argv[2];
1105 if (strcmp(szType, "NONE" ) == 0) aFillType = Aspect_FM_NONE;
1106 else if (strcmp(szType, "CENTERED") == 0) aFillType = Aspect_FM_CENTERED;
1107 else if (strcmp(szType, "TILED" ) == 0) aFillType = Aspect_FM_TILED;
1108 else if (strcmp(szType, "STRETCH" ) == 0) aFillType = Aspect_FM_STRETCH;
1111 di << "Wrong fill type : " << szType << "\n";
1112 di << "Must be one of CENTERED, TILED, STRETCH, NONE\n";
1117 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
1118 V3dView->SetBackgroundImage(argv[1], aFillType, Standard_True);
1123 #include <Graphic3d_MaterialAspect.hxx>
1124 #include <Prs3d_Drawer.hxx>
1125 #include <Prs3d_ShadingAspect.hxx>
1126 //=======================================================================
1127 //function : OCC1174_1
1129 //=======================================================================
1130 static Standard_Integer OCC1174_1 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1134 di << "Usage : " << argv[0] << " shape\n";
1138 Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
1139 if(anAISContext.IsNull())
1141 di << "use 'vinit' command before " << argv[0] << "\n";
1145 TopoDS_Shape aShape = DBRep::Get(argv[1]);
1147 Handle(AIS_Shape) anAisIO = new AIS_Shape(aShape);
1149 Quantity_Color aColF(0.0, 0.4, 0.0, Quantity_TOC_RGB);
1150 Quantity_Color aColB(0.0, 0.0, 0.6, Quantity_TOC_RGB);
1152 Handle(Prs3d_Drawer) aDrawer = anAisIO->Attributes();
1153 Handle(Prs3d_ShadingAspect) aShadingAspect = aDrawer->ShadingAspect();
1155 Graphic3d_MaterialAspect aFront = aShadingAspect->Material(Aspect_TOFM_FRONT_SIDE);
1156 aFront.SetAmbientColor(aColF);
1157 aFront.SetDiffuseColor(aColF);
1158 aFront.SetSpecularColor(aColF);
1159 aFront.SetEmissiveColor(aColF);
1160 aFront.SetTransparency(0.0);
1161 aShadingAspect->SetMaterial(aFront,Aspect_TOFM_FRONT_SIDE);
1163 Graphic3d_MaterialAspect aBack = aShadingAspect->Material(Aspect_TOFM_BACK_SIDE);
1164 aBack.SetAmbientColor(aColB);
1165 aBack.SetDiffuseColor(aColB);
1166 aBack.SetSpecularColor(aColB);
1167 aBack.SetEmissiveColor(aColB);
1168 aBack.SetTransparency(0.0);
1169 aShadingAspect->SetMaterial(aBack,Aspect_TOFM_BACK_SIDE);
1171 aDrawer->SetShadingAspect (aShadingAspect);
1173 anAISContext->Display (anAisIO, 1, 0, Standard_True);
1175 Standard_Real r, g, b;
1176 aShadingAspect->Color(Aspect_TOFM_FRONT_SIDE).Values(r,g,b, Quantity_TOC_RGB);
1177 di << "Info: color on front side (" << r << "," << g << "," << b << ")\n";
1178 aShadingAspect->Color(Aspect_TOFM_BACK_SIDE).Values(r,g,b, Quantity_TOC_RGB);
1179 di << "Info: color on back side (" << r << "," << g << "," << b << ")\n";
1184 //=======================================================================
1185 //function : OCC1174_2
1187 //=======================================================================
1188 static Standard_Integer OCC1174_2 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1192 di << "Usage : " << argv[0] << " shape\n";
1196 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1197 if(AISContext.IsNull())
1199 di << "use 'vinit' command before " << argv[0] << "\n";
1203 TopoDS_Shape sh = DBRep::Get(argv[1]);
1205 Handle(AIS_Shape) ais = new AIS_Shape(sh);
1206 AISContext->Display (ais, 1, 0, Standard_False);
1207 AISContext->SetMaterial (ais, Graphic3d_NOM_SHINY_PLASTIC, Standard_False);
1209 Quantity_Color colf(0.0, 0.4, 0.0, Quantity_TOC_RGB);
1210 Quantity_Color colb(0.0, 0.0, 0.6, Quantity_TOC_RGB);
1211 Handle(Prs3d_ShadingAspect) sa = ais->Attributes()->ShadingAspect();
1213 Graphic3d_MaterialAspect front = sa->Material(Aspect_TOFM_FRONT_SIDE);
1214 front.SetAmbientColor(colf);
1215 front.SetDiffuseColor(colf);
1216 front.SetSpecularColor(colf);
1217 front.SetEmissiveColor(colf);
1218 front.SetTransparency (0.4f);
1219 sa->SetMaterial(front,Aspect_TOFM_FRONT_SIDE);
1221 Graphic3d_MaterialAspect back = sa->Material(Aspect_TOFM_BACK_SIDE);
1222 back.SetAmbientColor(colb);
1223 back.SetDiffuseColor(colb);
1224 back.SetSpecularColor(colb);
1225 back.SetEmissiveColor(colb);
1226 back.SetTransparency (0.2f);
1227 sa->SetMaterial(back,Aspect_TOFM_BACK_SIDE);
1229 AISContext->Redisplay (ais, 1, 0);
1234 #include <TopoDS_Solid.hxx>
1235 #include <BRepFeat_MakeDPrism.hxx>
1236 //=======================================================================
1238 //purpose : FEATURE OPERATION (BOSS and SLOT)
1239 //=======================================================================
1240 static Standard_Integer OCCN1 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1244 di << "Usage : " << argv[0] << " angle fuse(1 for boss / 0 for slot) length\n";
1248 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1249 if(aContext.IsNull())
1251 di << "use 'vinit' command before " << argv[0] << "\n";
1254 Standard_Real angle = Draw::Atof(argv[1]);
1255 Standard_Integer fuse = Draw::Atoi(argv[2]);
1256 Standard_Real length = Draw::Atof(argv[3]);
1258 BRepBuilderAPI_MakeEdge edge1(gp_Pnt(0, 0, 0), gp_Pnt(50, 0, 0));
1259 BRepBuilderAPI_MakeEdge edge2(gp_Pnt(50, 0, 0), gp_Pnt(50, 50, 0));
1260 BRepBuilderAPI_MakeEdge edge3(gp_Pnt(50, 50, 0), gp_Pnt(0, 50, 0));
1261 BRepBuilderAPI_MakeEdge edge4(gp_Pnt(0, 50, 0), gp_Pnt(0, 0, 0));
1262 TopoDS_Edge ted1 = edge1.Edge();
1263 TopoDS_Edge ted2 = edge2.Edge();
1264 TopoDS_Edge ted3 = edge3.Edge();
1265 TopoDS_Edge ted4 = edge4.Edge();
1267 BRepBuilderAPI_MakeWire wire(ted1, ted2, ted3, ted4);
1268 TopoDS_Wire twire = wire.Wire();
1270 BRepBuilderAPI_MakeFace face(twire);
1271 TopoDS_Face tface = face.Face();
1272 ////////Handle(AIS_Shape) face_ais = new AIS_Shape( tface );
1273 ////////aContext->Display(face_ais);
1276 BRepPrimAPI_MakeBox block(gp_Pnt(-50, -50, -150), 150, 150, 100);
1277 box = block.Solid();
1279 TopoDS_Face top_face;
1280 top_face = block.TopFace();
1282 BRepFeat_MakeDPrism slot(box, tface, top_face, angle, fuse,
1285 slot.Perform(length);
1286 TopoDS_Shape S2 = slot.Shape();
1288 DBRep::Set("OCCN1_tface",tface);
1289 DBRep::Set("OCCN1_slot",S2);
1294 #include <BRepPrimAPI_MakeCylinder.hxx>
1295 #include <BRepPrimAPI_MakeSphere.hxx>
1296 #include <BRepAlgoAPI_Section.hxx>
1297 //=======================================================================
1299 //purpose : BOOLEAN OPERATION
1300 //=======================================================================
1301 static Standard_Integer OCCN2 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1304 di << "Usage : " << argv[0] << "\n";
1308 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1309 if(aContext.IsNull())
1311 di << "use 'vinit' command before " << argv[0] << "\n";
1315 BRepPrimAPI_MakeCylinder cylinder(50,200);
1316 TopoDS_Shape cylinder_sh = cylinder.Shape();
1318 BRepPrimAPI_MakeSphere sphere(gp_Pnt(60,0,100),50);
1319 TopoDS_Shape sphere_sh = sphere.Shape();
1321 di << "BRepAlgoAPI_Section section(cylinder_sh, sphere_sh)\n";
1322 BRepAlgoAPI_Section section(cylinder_sh, sphere_sh);
1323 if (!section.IsDone()){
1324 di << "Error performing intersection: not done.\n";
1326 const TopoDS_Shape& shape = section.Shape();
1328 DBRep::Set("OCCN2_cylinder",cylinder_sh);
1329 DBRep::Set("OCCN2_sphere",sphere_sh);
1330 DBRep::Set("OCCN2_section",shape);
1335 #include <TColgp_Array1OfPnt.hxx>
1336 #include <Geom_BezierCurve.hxx>
1338 static Standard_Integer OCC2569 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1340 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1341 if(aContext.IsNull())
1343 di << "use 'vinit' command before " << argv[0] << "\n";
1347 di << "Usage : " << argv[0] << " nbpoles result\n";
1351 int poles=Draw::Atoi(argv[1]);
1353 TColgp_Array1OfPnt arr(1, poles);
1354 for(int i=1; i<=poles; i++)
1355 arr.SetValue(i, gp_Pnt(i+10, i*2+20, i*3+45));
1357 Handle(Geom_BezierCurve) bez = new Geom_BezierCurve(arr);
1359 di << "\n The curve is not created.\n";
1361 di << "\n Degree = " << bez->Degree() << "\n";
1363 TopoDS_Edge sh = BRepBuilderAPI_MakeEdge(bez).Edge();
1364 Handle(AIS_Shape) ais = new AIS_Shape(sh);
1365 aContext->Display (ais, Standard_True);
1366 DrawTrSurf::Set(argv[2],bez);
1370 #include <TopTools_IndexedMapOfShape.hxx>
1371 #include <TopExp.hxx>
1373 static Standard_Integer OCC1642 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1376 di<<"Usage: " << argv[0] << " FinalWare FinalFace InitWare InitFace shape FixReorder FixDegenerated FixConnected FixSelfIntersection\n";
1380 TopoDS_Shape shape = DBRep::Get(argv[5]);
1382 TopExp_Explorer exp(shape, TopAbs_WIRE);
1383 TopoDS_Shape wire = exp.Current();
1385 Handle(ShapeAnalysis_Wire) advWA = new ShapeAnalysis_Wire;
1386 advWA->Load(TopoDS::Wire(wire));
1388 DBRep::Set(argv[3],wire);
1391 BRepBuilderAPI_MakeFace(TopoDS::Wire(wire),Standard_True);
1393 DBRep::Set(argv[4],face);
1395 advWA->SetFace(face);
1396 Standard_Real precision_to_ana = 0.0001;
1397 advWA->SetPrecision(precision_to_ana);
1399 TopTools_IndexedMapOfShape M;
1400 TopExp::MapShapes(wire, TopAbs_EDGE, M);
1403 for(j= 1; j<=M.Extent(); ++j) {
1404 Standard_Integer num=1;
1405 IntRes2d_SequenceOfIntersectionPoint points2d;
1406 TColgp_SequenceOfPnt points3d;
1408 cout << "\n j =" << j << ", CheckSelfIntersectingEdge = " <<
1409 advWA->CheckSelfIntersectingEdge(j, points2d, points3d);
1412 ShapeExtend_Status status = ShapeExtend_FAIL1;
1413 if(advWA->StatusSelfIntersection(status))
1415 status = ShapeExtend_FAIL2;
1416 if(advWA->StatusSelfIntersection(status))
1417 di << "\n No Vertices found in the edge";
1419 status = ShapeExtend_DONE1;
1420 if(advWA->StatusSelfIntersection(status))
1421 di << "\n Self-intersection found in the edge";
1423 num = points2d.Length();
1424 di << "\n No. of self-intersecting edges : " << num;
1426 for(int i=1; i<=num; ++i) {
1427 gp_Pnt pt = points3d(i);
1428 di << "\n Intersecting pt : (" << pt.X() << ", " << pt.Y()<< ", " << pt.Z() << ")";
1433 Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire;
1434 sfw->Load(TopoDS::Wire(wire));
1436 sfw->SetPrecision(Precision::Confusion());
1438 sfw->FixReorderMode() = 1;
1439 sfw->ClosedWireMode() = 1;
1440 sfw->FixDegeneratedMode() = 1;
1441 sfw->FixConnectedMode() = 1;
1442 sfw->ModifyTopologyMode() = 1;
1443 sfw->ModifyGeometryMode() = 1;
1444 sfw->FixSelfIntersectionMode() = 1;
1445 sfw->FixSelfIntersectingEdgeMode() = 1;
1446 sfw->FixIntersectingEdgesMode() = 1;
1447 sfw->FixNonAdjacentIntersectingEdgesMode() = 1;
1448 sfw->FixEdgeCurvesMode() = 1;
1450 sfw->ModifyRemoveLoopMode() = 1;
1451 sfw->SetMaxTolerance(1.0);
1453 di << "\n FixReorder = " << (Standard_Integer) sfw->FixReorder();
1454 di << "\n FixDegenerated = " << (Standard_Integer) sfw->FixDegenerated();
1455 di << "\n FixConnected = " << (Standard_Integer) sfw->FixConnected();
1457 di << "\n FixSelfIntersection = " << (Standard_Integer) sfw->FixSelfIntersection();
1460 Draw::Set(argv[6],sfw->FixReorder()) ;
1461 Draw::Set(argv[7],sfw->FixDegenerated()) ;
1462 Draw::Set(argv[8],sfw->FixConnected()) ;
1463 Draw::Set(argv[9],sfw->FixSelfIntersection()) ;
1465 ShapeExtend_Status status = ShapeExtend_OK;
1466 if(sfw->StatusSelfIntersection(status))
1467 di << "\n ShapeExtend_OK : No intersection found";
1469 status = ShapeExtend_FAIL1;
1470 if(sfw->StatusSelfIntersection(status))
1471 di << "\n ShapeExtend_FAIL1 : analysis failed (edge has no pcurve,or no vertices etc.)";
1473 status = ShapeExtend_FAIL2;
1474 if(sfw->StatusSelfIntersection(status))
1475 di << "\n ShapeExtend_FAIL2 : self-intersection was found, but not fixed because of limit of increasing tolerance (MaxTolerance)";
1477 status = ShapeExtend_FAIL3;
1478 if(sfw->StatusSelfIntersection(status))
1479 di << "\n ShapeExtend_FAIL3 : intercestion of non adjacent edges found, but not fixed because of limit of increasing tolerance (MaxTolerance)";
1481 status = ShapeExtend_DONE1;
1482 if(sfw->StatusSelfIntersection(status))
1483 di << "\n ShapeExtend_DONE1 : tolerance of vertex was increased to fix self-intersection";
1485 status = ShapeExtend_DONE2;
1486 if(sfw->StatusSelfIntersection(status))
1487 di << "\n ShapeExtend_DONE2 : vertex was moved to fix self-intersection";
1489 status = ShapeExtend_DONE3;
1490 if(sfw->StatusSelfIntersection(status))
1491 di << "\n ShapeExtend_DONE3 : some edges were removed because of intersection";
1493 status = ShapeExtend_DONE4;
1494 if(sfw->StatusSelfIntersection(status))
1495 di << "\n ShapeExtend_DONE4 : pcurve(s) was(were) modified";
1497 status = ShapeExtend_DONE5;
1498 if(sfw->StatusSelfIntersection(status))
1499 di << "\n ShapeExtend_DONE5 : non adjacent intersection fixed by increasing tolerance of vertex(vertices)";
1501 status = ShapeExtend_DONE6;
1502 if(sfw->StatusSelfIntersection(status))
1503 di << "\n ShapeExtend_DONE6 : tolerance of edge was increased to hide intersection";
1505 status = ShapeExtend_DONE7;
1506 if(sfw->StatusSelfIntersection(status))
1507 di << "\n ShapeExtend_DONE7 : range of some edges was decreased to avoid intersection";
1509 TopoDS_Wire finalwire = sfw->Wire();
1511 DBRep::Set(argv[1],finalwire);
1514 advWA->Load(TopoDS::Wire(finalwire));
1517 BRepBuilderAPI_MakeFace(TopoDS::Wire(finalwire),Standard_True);
1519 DBRep::Set(argv[2],fface);
1521 advWA->SetFace(fface);
1523 TopTools_IndexedMapOfShape fM;
1524 TopExp::MapShapes(finalwire, TopAbs_EDGE, fM);
1526 for(j= 1; j<=fM.Extent(); ++j) {
1527 Standard_Integer num=1;
1528 IntRes2d_SequenceOfIntersectionPoint points2d;
1529 TColgp_SequenceOfPnt points3d;
1531 di << "\n j =" << j << ", CheckSelfIntersectingEdge = " <<
1532 (Standard_Integer) advWA->CheckSelfIntersectingEdge(j, points2d, points3d);
1535 status = ShapeExtend_FAIL1;
1536 if(advWA->StatusSelfIntersection(status))
1538 status = ShapeExtend_FAIL2;
1539 if(advWA->StatusSelfIntersection(status))
1540 di << "\n No Vertices found in the edge";
1542 status = ShapeExtend_DONE1;
1543 if(advWA->StatusSelfIntersection(status))
1544 di << "\n Self-intersection found in the edge";
1546 num = points2d.Length();
1547 di << "\n No. of self-intersecting edges : " << num;
1549 for(int i=1; i<=num; ++i) {
1550 gp_Pnt pt = points3d(i);
1551 di << "\n Intersecting pt : (" << pt.X() << ", " << pt.Y() << ", " << pt.Z() << ")";
1561 void QABugs::Commands_17(Draw_Interpretor& theCommands) {
1562 const char *group = "QABugs";
1564 theCommands.Add ("BUC60842", "BUC60842", __FILE__, BUC60842, group);
1565 theCommands.Add ("BUC60843", "BUC60843 result_shape name_of_circle name_of_curve [ par1 [ tol ] ]", __FILE__, BUC60843, group);
1566 theCommands.Add ("BUC60970", "BUC60970 shape result", __FILE__, BUC60970, group);
1567 theCommands.Add ("BUC60915", "BUC60915", __FILE__, BUC60915_1, group);
1568 theCommands.Add ("OCC138", "OCC138", __FILE__, OCC138, group);
1569 theCommands.Add ("OCC353","OCC353",__FILE__,OCC353,group);
1570 theCommands.Add ("OCC280","OCC280 hlr=0/1 setsurfecedetail=0/1; set perspecrive view",__FILE__,OCC280,group);
1571 theCommands.Add ("OCC138LC", "OCC138LC", __FILE__, OCC138LC, group);
1572 theCommands.Add ("OCC566", "OCC566 shape [ xmin ymin zmin xmax ymax zmax] ; print bounding box", __FILE__, OCC566, group);
1573 theCommands.Add ("OCC570", "OCC570 result", __FILE__, OCC570, group);
1575 theCommands.Add("OCC570mkevol",
1576 "OCC570mkevol result object (then use updatevol) [R/Q/P]; mkevol",
1577 __FILE__, MKEVOL,group);
1578 theCommands.Add("OCC570updatevol",
1579 "OCC570updatevol edge u1 rad1 u2 rad2 ...; updatevol",
1580 __FILE__, UPDATEVOL,group);
1581 theCommands.Add("OCC570updatevollaw",
1582 "OCC570updatevollaw edge u1 rad1 u2 rad2 ...; updatevollaw",
1583 __FILE__, UPDATEVOL,group);
1584 theCommands.Add("OCC570buildevol",
1585 "OCC570buildevol; end of the evol fillet computation",
1586 __FILE__, BUILDEVOL,group);
1588 theCommands.Add ("OCC606", "OCC606 result shape [-t]", __FILE__, OCC606, group);
1590 theCommands.Add ("OCC813", "OCC813 U V", __FILE__, OCC813, group);
1591 theCommands.Add ("OCC814", "OCC814", __FILE__, OCC814, group);
1592 theCommands.Add ("OCC884", "OCC884 result shape [toler [maxtoler]]", __FILE__, OCC884, group);
1593 theCommands.Add ("OCC1188", "OCC1188 imagefile [filltype] : Load image as background", __FILE__, OCC1188, group);
1595 theCommands.Add ("OCC1174_1", "OCC1174_1 shape", __FILE__, OCC1174_1, group);
1596 theCommands.Add ("OCC1174_2", "OCC1174_2 shape", __FILE__, OCC1174_2, group);
1598 theCommands.Add ("OCCN1", "OCCN1 angle fuse(1 for boss / 0 for slot) length", __FILE__, OCCN1, group);
1599 theCommands.Add ("OCCN2", "OCCN2", __FILE__, OCCN2, group);
1601 theCommands.Add ("OCC2569", "OCC2569 nbpoles result", __FILE__, OCC2569, group);
1603 theCommands.Add ("OCC1642", "OCC1642 FinalWare FinalFace InitWare InitFace shape FixReorder FixDegenerated FixConnected FixSelfIntersection", __FILE__, OCC1642, group);