1 // Created on: 2002-03-18
2 // Created by: QA Admin
3 // Copyright (c) 2002-2012 OPEN CASCADE SAS
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
23 #define Viewer2dTest QAViewer2dTest
30 #include <Draw_Interpretor.hxx>
32 #include <DrawTrSurf.hxx>
33 #include <AIS_InteractiveContext.hxx>
34 #include <ViewerTest.hxx>
35 #include <ViewerTest_EventManager.hxx>
36 #include <AIS_Shape.hxx>
37 #include <TopoDS_Shape.hxx>
39 #include <Geom_Circle.hxx>
40 #include <Geom_Ellipse.hxx>
41 #include <Geom_Plane.hxx>
43 #include <Geom2d_Curve.hxx>
44 #include <GeomAPI.hxx>
45 #include <Geom2dAdaptor_Curve.hxx>
46 #include <Geom2dGcc_QualifiedCurve.hxx>
47 #include <Geom2dGcc_Lin2d2Tan.hxx>
48 #include <Geom2d_Line.hxx>
49 #include <BRepBuilderAPI_MakeEdge.hxx>
50 #include <TopoDS_Edge.hxx>
51 #include <Precision.hxx>
52 #include <Geom2d_Circle.hxx>
53 #include <Geom2dGcc_MyQCurve.hxx>
54 #include <GccEnt_QualifiedCirc.hxx>
55 #include <Geom2dGcc_MyL2d2Tan.hxx>
56 #include <BRepBuilderAPI_MakeWire.hxx>
57 #include <TopExp_Explorer.hxx>
59 #include <TopoDS_Wire.hxx>
60 #include <BRep_Tool.hxx>
61 #include <gp_Circ.hxx>
62 #include <BRepOffsetAPI_MakePipeShell.hxx>
63 #include <AIS_Trihedron.hxx>
64 #include <Geom_Axis2Placement.hxx>
65 #include <V3d_View.hxx>
66 #include <ViewerTest_Tool.hxx>
67 #include <BRepBuilderAPI_MakeVertex.hxx>
68 #include <AIS_LengthDimension.hxx>
69 #include <AIS_RadiusDimension.hxx>
70 #include <BRepPrimAPI_MakeBox.hxx>
71 #include <GeomAdaptor_Surface.hxx>
72 #include <Extrema_ExtPS.hxx>
73 #include <Geom_CartesianPoint.hxx>
74 #include <Geom2d_CartesianPoint.hxx>
75 #include <Geom2dGcc_Circ2d3Tan.hxx>
76 #include <Aspect_Window.hxx>
78 #include <TopoDS_Compound.hxx>
79 #include <TopoDS_CompSolid.hxx>
80 #include <StdSelect_ShapeTypeFilter.hxx>
82 #include <QABugs_MyText.hxx>
85 #include <QAViewer2dTest.hxx>
86 #include <QAViewer2dTest_DoubleMapOfInteractiveAndName.hxx>
88 #include <Viewer2dTest.hxx>
89 #include <Viewer2dTest_DoubleMapOfInteractiveAndName.hxx>
92 #include <Prs3d_Projector.hxx>
93 #include <HLRAlgo_Projector.hxx>
94 #include <AIS2D_ProjShape.hxx>
95 #include <AIS2D_InteractiveContext.hxx>
96 #include <Standard_ErrorHandler.hxx>
100 extern QAViewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D();
102 extern Viewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D();
105 Standard_EXPORT Viewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D();
108 #include <GGraphic2d_SetOfCurves.hxx>
109 #include <Graphic2d_SetOfSegments.hxx>
111 #include <Font_NameOfFont.hxx>
113 static Standard_Integer BUC60842 (Draw_Interpretor& di, Standard_Integer /*argc*/,const char ** /*argv*/)
115 Standard_Character abuf[16];
116 //Standard_Character * abuf = new Standard_Character[16];
118 Standard_CString st = abuf;
120 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);
121 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);
122 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))));
124 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
126 gp_Pln pln = plne->Pln();
127 Handle(Geom2d_Curve) curve2d = GeomAPI::To2d (ell, pln);
129 DrawTrSurf::Set(st,curve2d);
130 if(!aContext.IsNull()) {
131 Handle(AIS_Shape) aisp =
132 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(curve2d, pln)).Edge());
133 aContext->Display (aisp);
136 Handle(Geom2d_Curve) fromcurve2d = GeomAPI::To2d (cir, pln);
138 DrawTrSurf::Set(st,fromcurve2d);
139 if(!aContext.IsNull()) {
140 Handle(AIS_Shape) aisp =
141 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(fromcurve2d, pln)).Edge());
142 aContext->Display (aisp);
145 Geom2dAdaptor_Curve acur (curve2d), afromcur (fromcurve2d);
146 Geom2dGcc_QualifiedCurve qcur (acur, GccEnt_outside);
147 Geom2dGcc_QualifiedCurve qfromcur (afromcur, GccEnt_outside);
148 Geom2dGcc_Lin2d2Tan lintan (qcur, qfromcur, 0.1, 0.0, 0.0);
149 Standard_Integer i=0;
150 for(i=0;i<lintan.NbSolutions();i++) {
151 sprintf(abuf,"lintan_%d",i);
152 Handle(Geom2d_Line) glin = new Geom2d_Line(lintan.ThisSolution(i));
153 DrawTrSurf::Set(st,glin);
154 if(!aContext.IsNull()) {
155 Handle(AIS_Shape) aisp =
156 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(glin, pln)).Edge()); aContext->Display (aisp);
159 di << " Is Done = \n" << (Standard_Integer) lintan.IsDone();
163 static Standard_Integer BUC60843 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
165 if (argc != 4 && argc != 5 && argc != 6 && argc != 7) {
166 di << "Usage : " << argv[0] << "result_shape name_of_circle name_of_curve [ par1 [ tol ] ]" << "\n";
170 Standard_Real par1 = 0.0, par2 = 0.0;
171 Standard_Real tol = Precision::Angular();
173 par1 = atof(argv[4]);
175 par2 = atof(argv[5]);
178 Handle(Geom2d_Curve) aCur2d1 = DrawTrSurf::GetCurve2d(argv[2]);
179 Handle(Geom2d_Curve) aCur2d2 = DrawTrSurf::GetCurve2d(argv[3]);
180 if (aCur2d1.IsNull() || aCur2d2.IsNull()) {
181 di << "Faulty : not curves" << "\n";
184 Standard_Boolean c1IsCircle = Standard_False;
185 Handle(Geom2d_Circle) aCir2d = Handle(Geom2d_Circle)::DownCast(aCur2d1);
186 if (!aCir2d.IsNull()) {
187 c1IsCircle = Standard_True;
188 if (argc == 6) tol = atof(argv[5]);
191 Geom2dAdaptor_Curve acur(aCur2d2);
192 Geom2dGcc_MyQCurve qcur(acur, GccEnt_unqualified);
193 GccEnt_QualifiedCirc qfromcur(aCir2d->Circ2d(), GccEnt_unqualified);
194 Geom2dGcc_MyL2d2Tan lintan(qfromcur, qcur , par1, tol);
195 if (lintan.IsDone()) {
196 gp_Lin2d lin = lintan.ThisSolution();
197 Handle(Geom2d_Line) glin = new Geom2d_Line(lin);
198 DrawTrSurf::Set(argv[1], glin);
200 di << "Faulty : tangent line is not done." << "\n";
204 Geom2dAdaptor_Curve acur1(aCur2d1);
205 Geom2dAdaptor_Curve acur2(aCur2d2);
206 Geom2dGcc_MyQCurve qcur1(acur1, GccEnt_unqualified);
207 Geom2dGcc_MyQCurve qcur2(acur2, GccEnt_unqualified);
208 Geom2dGcc_MyL2d2Tan lintan(qcur1, qcur2 , par1, par2, tol);
209 if (lintan.IsDone()) {
210 gp_Lin2d lin = lintan.ThisSolution();
211 Handle(Geom2d_Line) glin = new Geom2d_Line(lin);
212 DrawTrSurf::Set(argv[1], glin);
214 di << "Faulty : tangent line is not done." << "\n";
220 static Standard_Integer BUC60970 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
224 di << "Usage : " << argv[0] << " shape result" <<"\n";
228 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
229 if(aContext.IsNull()) {
230 di << "use 'vinit' command before " << argv[0] << "\n";
234 TopoDS_Shape aResult = DBRep::Get(argv[1]);
236 BRepBuilderAPI_MakeWire bRepSpineWire;
237 TopExp_Explorer exp_(aResult, TopAbs_WIRE);
239 Standard_Integer i = 0;
240 for(;exp_.More();exp_.Next()){
242 bRepSpineWire.Add(TopoDS::Wire(exp_.Current()));
245 //printf("total no of wires are ............. %d\n", i);
246 di << "total no of wires are ............. " << i << "\n";
248 TopoDS_Wire spineWire = bRepSpineWire.Wire();
249 aContext->Display(new AIS_Shape(spineWire));
251 DBRep::Set("slineW",spineWire);
253 TopExp_Explorer spineWireExp(spineWire, TopAbs_EDGE);
254 Standard_Real first, last;
255 Handle_Geom_Curve curl_ = BRep_Tool::Curve(TopoDS::Edge(spineWireExp.Current()), first, last);
258 curl_->D1(first, firstPnt, tanVec);
260 gp_Dir tanDir(tanVec.X(), tanVec.Y(), tanVec.Z());
261 gp_Ax2 gpAx2(firstPnt, tanDir);
262 gp_Circ gpCirc(gpAx2, 2.5);
263 BRepBuilderAPI_MakeWire aMWire(BRepBuilderAPI_MakeEdge(new Geom_Circle(gpCirc)).Edge());
264 TopoDS_Wire topoWire(aMWire);
265 aContext->Display(new AIS_Shape(topoWire));
267 DBRep::Set("topoW",topoWire);
269 BRepOffsetAPI_MakePipeShell bRepPipe(spineWire);
270 bRepPipe.Add(topoWire);
273 aContext->Display(new AIS_Shape(bRepPipe.Shape()));
275 DBRep::Set(argv[2],bRepPipe.Shape());
280 static Standard_Integer BUC60818(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
284 di << "Usage : " << argv[0] << "\n";
288 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
289 if(myAISContext.IsNull())
291 di << "use 'vinit' command before " << argv[0] << "\n";
296 Handle(AIS_Trihedron) aTrihedron;
297 Handle(Geom_Axis2Placement) aTrihedronAxis=new Geom_Axis2Placement(gp::XOY());
298 aTrihedron=new AIS_Trihedron(aTrihedronAxis);
299 myAISContext->Display(aTrihedron);
301 myAISContext->OpenLocalContext();
302 myAISContext->Load(aTrihedron,0);
304 myAISContext->SetAutomaticHilight( Standard_False );
306 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
308 myV3dView->Project(0,0,0,Xv,Yv);
310 Standard_Integer Xp,Yp;
311 myV3dView->Convert(Xv,Yv,Xp,Yp);
313 myAISContext->MoveTo( Xp,Yp, myV3dView );
314 myAISContext->MoveTo( Xp,Yp, myV3dView );
316 if (myAISContext->HasDetected( ))
317 di << "has detected shape : OK" << "\n";
318 else di << "has detected shape : bugged - Faulty " << "\n";
320 myAISContext->SetAutomaticHilight( Standard_True );
325 static Standard_Integer BUC60915_1(Draw_Interpretor& di, Standard_Integer argc, const char ** /*argv*/)
328 di<<"Function don't has parameters"<<"\n";
332 Handle(AIS_InteractiveContext) context= ViewerTest_Tool::MakeContext ("buc60915");
333 ViewerTest_Tool::InitViewerTest (context);
335 //The following dimesion code has problems regarding arrow_size. The desired effect is not produced.
336 /***************************************/
338 /***************************************/
339 gp_Pnt p1 = gp_Pnt(602.51,50.,0.);
340 gp_Pnt p2 = gp_Pnt(602.51,200.,0.);
341 gp_Pnt p3 = gp_Pnt(102.51,200.,0.);
342 gp_Pnt p4 = gp_Pnt(102.51,170.,0.);
343 gp_Pnt p5 = gp_Pnt(502.51,170.,0.);
344 gp_Pnt p6 = gp_Pnt(502.51,80.,0.);
345 gp_Pnt p7 = gp_Pnt(102.51,80.,0.);
346 gp_Pnt p8 = gp_Pnt(102.51,50.,0.);
347 TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(p1);
348 TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(p2);
349 TopoDS_Vertex V3 = BRepBuilderAPI_MakeVertex(p3);
350 TopoDS_Vertex V4 = BRepBuilderAPI_MakeVertex(p4);
351 TopoDS_Vertex V5 = BRepBuilderAPI_MakeVertex(p5);
352 TopoDS_Vertex V6 = BRepBuilderAPI_MakeVertex(p6);
353 TopoDS_Vertex V7 = BRepBuilderAPI_MakeVertex(p7);
354 TopoDS_Vertex V8 = BRepBuilderAPI_MakeVertex(p8);
355 gp_Pnt plnpt(0, 0, 0);
356 gp_Dir plndir(0, 0, 1);
357 Handle(Geom_Plane) pln = new Geom_Plane(plnpt,plndir);
358 /***************************************/
359 //dimension "L 502.51"
360 /***************************************/
361 Handle(AIS_LengthDimension) len = new AIS_LengthDimension(V2, V3, pln, 502.51, "502.51");
362 len->SetPosition(gp_Pnt(350, 250, 0));
363 len->SetTypeOfDist(AIS_TOD_Horizontal);
364 len->SetArrowSize(30.0);
365 context->Display(len);
366 /***************************************/
368 /***************************************/
369 Handle(AIS_LengthDimension) len1 = new AIS_LengthDimension(V4, V7, pln, 90, "90");
370 len1->SetPosition(gp_Pnt(70, 120, 0));
371 len1->SetTypeOfDist(AIS_TOD_Vertical);
372 len1->SetArrowSize(100.0);
373 context->Display(len1);
374 /***************************************/
376 /***************************************/
377 Handle(AIS_LengthDimension) len2 = new AIS_LengthDimension(V1, V2, pln, 150, "150",gp_Pnt(650, 120, 0),DsgPrs_AS_BOTHAR,
378 AIS_TOD_Vertical, 100.0 );
379 //len2->SetPosition(gp_Pnt(650, 120, 0));
380 //len2->SetTypeOfDist(AIS_TOD_Vertical);
381 //len1->SetArrowSize(100.0);
382 context->Display(len2);
383 /***************************************/
384 //dimension "R 88.58"
385 /***************************************/
386 gp_Circ cir = gp_Circ(gp_Ax2(gp_Pnt(191.09, -88.58, 0), gp_Dir(0, 0, 1)), 88.58);
387 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(cir,gp_Pnt(191.09,0,0.),gp_Pnt(191.09,-177.16,0.) );
388 Handle(AIS_RadiusDimension) dim1 = new AIS_RadiusDimension(E1,88.58, "R 88.58",gp_Pnt(-30.0, -80.0, 0.0),DsgPrs_AS_BOTHAR,
390 context->Display(dim1);
391 /***************************************/
392 //dimension "R 43.80"
393 /***************************************/
394 gp_Circ cir1 = gp_Circ(gp_Ax2(gp_Pnt(191.09, -88.58, 0), gp_Dir(0, 0, 1)), 43.80);
395 TopoDS_Edge E_cir1 = BRepBuilderAPI_MakeEdge(cir1);
396 dim1 = new AIS_RadiusDimension(E_cir1,43.80, "R 43.80",gp_Pnt(0.0, -50.0, 0.0),DsgPrs_AS_LASTAR, 60.0 );
397 context->Display(dim1);
398 /***************************************/
399 //dimension "R 17.86"
400 /***************************************/
401 gp_Circ cir2 = gp_Circ(gp_Ax2(gp_Pnt(566.11, -88.58, 0), gp_Dir(0, 0, -1)), 17.86);
402 TopoDS_Edge E_cir2 = BRepBuilderAPI_MakeEdge(cir2);
403 dim1 = new AIS_RadiusDimension(E_cir2,17.86, "R 17.86",gp_Pnt(600.0, -50.0, 0.0),DsgPrs_AS_LASTAR, 40.0 );
404 context->Display(dim1);
409 static Standard_Integer OCC138 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
411 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
412 if(aContext.IsNull()) {
413 di << "use 'vinit' command before " << argv[0] << "\n";
417 BRepPrimAPI_MakeBox box1(gp_Pnt(0, 0, 0), gp_Pnt(100, 100, 100));
418 BRepPrimAPI_MakeBox box2(gp_Pnt(120, 120, 120), gp_Pnt(300, 300,300));
419 BRepPrimAPI_MakeBox box3(gp_Pnt(320, 320, 320), gp_Pnt(500, 500,500));
421 Handle_AIS_Shape ais1 = new AIS_Shape(box1.Shape());
422 Handle_AIS_Shape ais2 = new AIS_Shape(box2.Shape());
423 Handle_AIS_Shape ais3 = new AIS_Shape(box3.Shape());
425 aContext->Display(ais1);
426 aContext->Display(ais2);
427 aContext->Display(ais3);
429 aContext->AddOrRemoveCurrentObject(ais1);
430 aContext->AddOrRemoveCurrentObject(ais2);
431 aContext->AddOrRemoveCurrentObject(ais3);
433 di << "\n No of currents = " << aContext->NbCurrents();
435 aContext->InitCurrent();
438 while(aContext->MoreCurrent())
440 di << "\n count is = " << count++;
441 Handle_AIS_InteractiveObject ais = aContext->Current();
442 aContext->AddOrRemoveCurrentObject(ais);
443 aContext->InitCurrent();
449 static Standard_Integer BUC60821(Draw_Interpretor& di, Standard_Integer argc,const char ** argv )
453 di << "Usage: " << argv[0] << " TextHight1 TextHight2 TextHight2";
457 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
459 if(aContext.IsNull())
461 di << "use 'vinit' command before " << argv[0] << "\n";
465 Handle(QABugs_MyText) txt1 = new QABugs_MyText("Gosha1",gp_Pnt(0,0,0),Font_NOF_ASCII_SIMPLEX,Quantity_NOC_RED,atoi(argv[1]));
466 aContext->Display(txt1);
468 Handle(QABugs_MyText) txt2 = new QABugs_MyText("Gosha2",gp_Pnt(0,0,100),Font_NOF_ASCII_SIMPLEX,Quantity_NOC_YELLOW,atoi(argv[2]));
469 aContext->Display(txt2);
471 Handle(QABugs_MyText) txt3 = new QABugs_MyText("Gosha3",gp_Pnt(0,100,100),Font_NOF_ASCII_SIMPLEX,Quantity_NOC_SKYBLUE,atoi(argv[3]));
472 aContext->Display(txt3);
477 static int geom_get_2Dpt_from_3Dpt(const gp_Pnt& pnt3d, const gp_Pln& pln, gp_Pnt2d& pnt2d)
480 Handle_Geom_Plane gpln = new Geom_Plane(pln);
481 GeomAdaptor_Surface adsur(gpln);
482 Extrema_ExtPS extps(pnt3d, adsur, 0.001, 0.001);
486 for(index=1; index<= extps.NbExt(); index++ )
488 Extrema_POnSurf pons = extps.Point(index);
490 pons.Parameter(U, V);
491 pnt2d.SetCoord(U, V);
498 static Standard_Integer OCC353 (Draw_Interpretor& di, Standard_Integer , const char ** )
500 gp_Ax2 ax21( gp_Pnt(100,0,0), gp_Dir(0,0,1) );
501 Handle_Geom_Circle h_cir1 = new Geom_Circle( ax21, 25 );
503 gp_Ax2 ax22( gp_Pnt(-100,0,0), gp_Dir(0,0,1) );
504 Handle_Geom_Circle h_cir2 = new Geom_Circle( ax22, 25 );
506 gp_Pln refpln( gp_Pnt(0,0,0), gp_Dir(0,0,1) );
507 Handle_Geom2d_Curve cir2d1 = GeomAPI::To2d(h_cir1, refpln);
508 Handle_Geom2d_Curve cir2d2 = GeomAPI::To2d(h_cir2, refpln);
510 Geom2dAdaptor_Curve adop1(cir2d1);
511 Geom2dAdaptor_Curve adop2(cir2d2);
513 Geom2dGcc_QualifiedCurve qcur1(adop1, GccEnt_enclosing);
514 Geom2dGcc_QualifiedCurve qcur2(adop2, GccEnt_enclosing);
516 Handle_Geom_CartesianPoint h_carpt = new Geom_CartesianPoint(0,175,0);
518 gp_Pnt pt3d = h_carpt->Pnt();
520 geom_get_2Dpt_from_3Dpt(pt3d, refpln, pt2d);
524 DrawTrSurf::Set(st,cir2d1);
526 DrawTrSurf::Set(st,cir2d2);
528 DrawTrSurf::Set(st,pt2d);
530 Handle_Geom2d_CartesianPoint pt = new Geom2d_CartesianPoint(pt2d);
531 Geom2dGcc_Circ2d3Tan sol( qcur1, qcur2, pt, 0.001, 0.0, 0.0);
534 Standard_Character buf[10];
538 res = sol.NbSolutions();
539 for(Standard_Integer i=1;i<=res;i++) {
540 Handle(Geom2d_Circle) aC = new Geom2d_Circle(sol.ThisSolution(i));
541 sprintf(buf,"Result_%d",i);
543 DrawTrSurf::Set(st,aC);
547 di << "\n Faulty: no solutions found ";
548 //printf("\n Faulty: no solutions found ");
550 //printf("\n Num of solutions are %d ", res );
551 di << "\n Num of solutions are " << res << " ";
556 static Standard_Integer OCC280 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
558 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
559 if(aContext.IsNull())
561 di << "use 'vinit' command before " << argv[0] << "\n";
565 di << "ERROR : Usage : " << argv[0] << " hlr=0/1 setsurfecedetail=0/1; set perspecrive view" << "\n";
569 Standard_Integer HLR = atoi(argv[1]);
574 Handle(V3d_View) anOldView = ViewerTest::CurrentView();
575 Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
578 aViewer->SetDefaultSurfaceDetail (V3d_TEX_ALL);
580 aViewer->SetDefaultTypeOfView (V3d_PERSPECTIVE);
582 Handle(Aspect_Window) asp = anOldView->Window();
583 aViewer->SetViewOff (anOldView);
585 Handle(V3d_View) aNewView = aViewer->CreateView();
586 ViewerTest::CurrentView (aNewView);
588 aNewView->SetWindow (asp);
589 if (!asp->IsMapped()) asp->Map();
596 // replace view in event manager
597 ViewerTest::UnsetEventManager();
598 ViewerTest::SetEventManager (new ViewerTest_EventManager (aNewView, ViewerTest::GetAISContext()));
602 aNewView->SetDegenerateModeOff();
608 static Standard_Integer OCC232 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
610 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
611 if(aContext.IsNull()) {
612 di << "use 'vinit' command before " << argv[0] << "\n";
616 BRep_Builder builder;
617 TopoDS_Compound comp;
618 TopoDS_CompSolid cs1, cs2;
620 builder.MakeCompound(comp);
621 builder.MakeCompSolid(cs1);
622 builder.MakeCompSolid(cs2);
624 TopoDS_Shape sh1 = BRepPrimAPI_MakeBox(gp_Pnt(0, 0, 0), 100, 100, 100).Shape();
625 TopoDS_Shape sh2 = BRepPrimAPI_MakeBox(gp_Pnt(100, 0, 0), 100, 100, 100).Shape();
626 TopoDS_Shape sh3 = BRepPrimAPI_MakeBox(gp_Pnt(200, 0, 0), 100, 100, 100).Shape();
627 builder.Add(cs1, sh1);
628 builder.Add(cs1, sh2);
629 builder.Add(cs1, sh3);
631 TopoDS_Shape sh4 = BRepPrimAPI_MakeBox(gp_Pnt(0, 500, 0), 100, 100, 100).Shape();
632 TopoDS_Shape sh5 = BRepPrimAPI_MakeBox(gp_Pnt(100, 500, 0), 100, 100, 100).Shape();
633 TopoDS_Shape sh6 = BRepPrimAPI_MakeBox(gp_Pnt(200, 500, 0), 100, 100, 100).Shape();
635 builder.Add(cs2, sh4);
636 builder.Add(cs2, sh5);
637 builder.Add(cs2, sh6);
639 builder.Add(comp, cs1);
640 builder.Add(comp, cs2);
642 Handle_AIS_Shape ais = new AIS_Shape(comp);
643 aContext->Display(ais);
645 TopExp_Explorer exp(comp, TopAbs_COMPSOLID);
648 //printf("\n TopAbs_COMPSOLID is there \n");
649 di << "\n TopAbs_COMPSOLID is there \n";
653 Handle (StdSelect_ShapeTypeFilter) filt = new StdSelect_ShapeTypeFilter(TopAbs_COMPSOLID);
654 aContext->AddFilter(filt);
655 aContext->CloseAllContexts();
656 aContext->OpenLocalContext();
657 aContext->ActivateStandardMode(TopAbs_SOLID);
662 static Standard_Integer OCC138LC (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
664 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
665 if(aContext.IsNull()) {
666 di << "use 'vinit' command before " << argv[0] << "\n";
670 BRepPrimAPI_MakeBox box1(gp_Pnt(0, 0, 0), gp_Pnt(100, 100, 100));
671 BRepPrimAPI_MakeBox box2(gp_Pnt(120, 120, 120), gp_Pnt(300, 300,300));
672 BRepPrimAPI_MakeBox box3(gp_Pnt(320, 320, 320), gp_Pnt(500, 500,500));
674 Handle_AIS_Shape ais1 = new AIS_Shape(box1.Shape());
675 Handle_AIS_Shape ais2 = new AIS_Shape(box2.Shape());
676 Handle_AIS_Shape ais3 = new AIS_Shape(box3.Shape());
678 aContext->Display(ais1);
679 aContext->Display(ais2);
680 aContext->Display(ais3);
682 aContext->AddOrRemoveSelected(ais1);
683 aContext->AddOrRemoveSelected(ais2);
684 aContext->AddOrRemoveSelected(ais3);
686 di << "\n No of selected = " << aContext->NbSelected();
688 aContext->InitSelected();
691 while(aContext->MoreSelected())
693 di << "\n count is = %d" << count++;
694 Handle_AIS_InteractiveObject ais = aContext->SelectedInteractive();
695 aContext->AddOrRemoveSelected(ais);
696 aContext->InitSelected();
702 static Standard_Integer OCC189 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
704 Handle(AIS_InteractiveContext) aContext1 = ViewerTest::GetAISContext();
705 if(aContext1.IsNull()) {
706 di << "use 'vinit' command before " << argv[0] << "\n";
709 Handle(AIS_InteractiveContext) aContext2 = ViewerTest::GetAISContext();
710 if(aContext2.IsNull()) {
711 di << "use 'vinit' command before " << argv[0] << "\n";
715 BRepPrimAPI_MakeBox box1(gp_Pnt(0, 0, 0), gp_Pnt(100, 100, 100));
716 BRepPrimAPI_MakeBox box2(gp_Pnt(120, 120, 120), gp_Pnt(300, 300, 300));
717 BRepPrimAPI_MakeBox box3(gp_Pnt(320, 320, 320), gp_Pnt(500, 500, 500));
719 Handle_AIS_Shape ais1 = new AIS_Shape(box1.Shape());
720 Handle_AIS_Shape ais2 = new AIS_Shape(box2.Shape());
721 Handle_AIS_Shape ais3 = new AIS_Shape(box3.Shape());
723 aContext1->Display(ais1);
724 aContext1->Display(ais2);
725 aContext1->Display(ais3);
727 aContext2->Display(ais1);
728 aContext2->Display(ais2);
729 aContext2->Display(ais3);
731 aContext1->AddOrRemoveCurrentObject(ais1);
732 aContext1->AddOrRemoveCurrentObject(ais2);
733 aContext1->AddOrRemoveCurrentObject(ais3);
735 di << "\n Stage : 1";
736 di << "\n \t No of currents on aContext1 = " << aContext1->NbCurrents();
737 di << "\n \t No of currents on aContext2 = " << aContext2->NbCurrents() << "\n\n";
739 di << "\n aContext1->IsCurrent = " << (Standard_Integer) aContext1->IsCurrent(ais1) << ", aContext2->IsCurrent = " << (Standard_Integer) aContext2->IsCurrent(ais1) << " ";
741 aContext2->AddOrRemoveCurrentObject(ais1);
742 aContext2->AddOrRemoveCurrentObject(ais2);
743 aContext2->AddOrRemoveCurrentObject(ais3);
745 di << "\n Stage : 2";
746 di << "\n \t No of currents on aContext1 = " << aContext1->NbCurrents();
747 di << "\n \t No of currents on aContext2 = " << aContext2->NbCurrents() << "\n\n";
749 aContext1->InitCurrent();
751 while(aContext1->MoreCurrent())
753 di << "\n count1 is = " << count1++;
754 Handle_AIS_InteractiveObject ais = aContext1->Current();
755 aContext1->AddOrRemoveCurrentObject(ais);
756 aContext1->InitCurrent();
759 di << "\n Stage : 3";
760 di << "\n \t No of currents on aContext1 = " << aContext1->NbCurrents();
761 di << "\n \t No of currents on aContext2 = " << aContext2->NbCurrents() << "\n\n";
763 aContext2->InitCurrent();
765 while(aContext2->MoreCurrent())
767 di << "\n count2 is = " << count2++;
768 Handle_AIS_InteractiveObject ais = aContext2->Current();
769 aContext2->AddOrRemoveCurrentObject(ais);
770 aContext2->InitCurrent();
773 di << "\n\n Stage : 4";
774 di << "\n \t No of currents on aContext1 = " << aContext1->NbCurrents();
775 di << "\n \t No of currents on aContext2 = " << aContext2->NbCurrents();
780 static Standard_Integer OCC389 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
784 di<<"Usage: " << argv[0] << " name shape1 [shape2] ..."<<"\n";
788 //if (Viewer2dTest::CurrentView().IsNull())
790 // cout << "2D AIS Viewer Initialization ..." << endl;
791 // Viewer2dTest::ViewerInit();
792 // cout << "Done" << endl;
796 Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
797 di<<"Check InteractiveContext"<<"\n";
799 if(aContext.IsNull()) {
800 di << "use 'v2dinit' command before " << argv[0] << "\n";
804 di<<"CloseLocalContext"<<"\n";
805 aContext->CloseLocalContext();
807 di<<"OpenLocalContext"<<"\n";
808 aContext->OpenLocalContext();
810 TCollection_AsciiString name(argv[1]);
812 di<<"Found name"<<"\n";
813 Standard_Boolean IsBound = GetMapOfAIS2D().IsBound2(name);
816 di<<"Already displayed"<<"\n";
818 else // Create the AIS2D_ProjShape from a name
820 di<<"Create the AIS2D_ProjShape from a name; (1)"<<"\n";
821 Prs3d_Projector aPrs3dProjector(Standard_False, 1, -1.0,0.2,0.3, 0.0, 0.0, 0.0, -0.0,0.0,1.0);
822 di<<"Create the AIS2D_ProjShape from a name; (2)"<<"\n";
823 HLRAlgo_Projector aProjector = aPrs3dProjector.Projector();
824 di<<"Create the AIS2D_ProjShape from a name; (3)"<<"\n";
825 Handle(AIS2D_ProjShape) shp_2d =
826 new AIS2D_ProjShape(aProjector, 0, Standard_False, Standard_True);
827 di<<"Create the AIS2D_ProjShape from a name; (4)"<<"\n";
830 Standard_Boolean isValid = Standard_False;
831 for (i = 2; i < argc; i++)
833 di<<"i="<< i-1 <<"\n";
834 TopoDS_Shape aShape = DBRep::Get(argv[i]);
835 if (!aShape.IsNull())
837 shp_2d->Add( aShape );
838 di<<"Added shape: "<<argv[i]<<"\n";
839 isValid = Standard_True;
845 di<<"Now start displaying..."<<"\n";
846 aContext->Display(shp_2d, 1, 1, Standard_True);
848 GetMapOfAIS2D().Bind(shp_2d, name);
852 aContext->UpdateCurrentViewer();
856 #include <BRepBndLib.hxx>
858 //=======================================================================
861 //=======================================================================
862 static Standard_Integer OCC566(Draw_Interpretor& di,Standard_Integer n,const char ** a)
865 di<<"Usage: " << a[0] << " shape [ xmin ymin zmin xmax ymax zmax]"<<"\n";
868 TopoDS_Shape S = DBRep::Get(a[1]);
869 if (S.IsNull()) return 1;
871 BRepBndLib::AddClose(S,B);
872 Standard_Real axmin,aymin,azmin,axmax,aymax,azmax;
873 B.Get(axmin,aymin,azmin,axmax,aymax,azmax);
874 di << axmin<<" "<< aymin<<" "<< azmin<<" "<< axmax<<" "<< aymax<<" "<< azmax;
876 Draw::Set(a[2],axmin) ;
877 Draw::Set(a[3],aymin) ;
878 Draw::Set(a[4],azmin) ;
879 Draw::Set(a[5],axmax) ;
880 Draw::Set(a[6],aymax) ;
881 Draw::Set(a[7],azmax) ;
886 #include <BRepFilletAPI_MakeFillet.hxx>
887 //=======================================================================
890 //=======================================================================
891 static Standard_Integer OCC570 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
894 di<<"Usage: " << argv[0] << " result"<<"\n";
898 BRepPrimAPI_MakeBox mkBox(100.,100.,100.);
899 TopoDS_Shape aBox = mkBox.Shape();
901 TopExp_Explorer aExp;
902 aExp.Init(aBox,TopAbs_WIRE);
905 TopoDS_Shape aWire = aExp.Current();
907 aExp.Init(aWire,TopAbs_EDGE);
908 TopoDS_Edge e1 = TopoDS::Edge(aExp.Current()); aExp.Next();
909 TopoDS_Edge e2 = TopoDS::Edge(aExp.Current()); aExp.Next();
910 TopoDS_Edge e3 = TopoDS::Edge(aExp.Current()); aExp.Next();
911 TopoDS_Edge e4 = TopoDS::Edge(aExp.Current());
916 BRepFilletAPI_MakeFillet mkFillet(aBox);
917 mkFillet.SetContinuity(GeomAbs_C1,.001);
919 // Setup variable fillet data
920 TColgp_Array1OfPnt2d t_pnt(1,4);
921 t_pnt.SetValue(1,gp_Pnt2d(0.0,5.0));
922 t_pnt.SetValue(2,gp_Pnt2d(0.3,15.0));
923 t_pnt.SetValue(3,gp_Pnt2d(0.7,15.0));
924 t_pnt.SetValue(4,gp_Pnt2d(1.0,5.0));
927 // It is impossible to build fillet if at least one edge
928 // with variable radius is added!!! If all are constant, everything is ok.
929 mkFillet.Add(t_pnt,e1);
930 mkFillet.Add(5.0,e2);
931 mkFillet.Add(t_pnt,e3);
932 mkFillet.Add(5.0,e4);
935 TopoDS_Shape aFinalShape = mkFillet.Shape();
937 DBRep::Set(argv[1],aFinalShape);
939 catch(Standard_Failure)
941 di << argv[0] << ": Exception in fillet"<<"\n";
949 #include <Law_Interpol.hxx>
951 static Standard_Real t3d = 1.e-4;
952 static Standard_Real t2d = 1.e-5;
953 static Standard_Real ta = 1.e-2;
954 static Standard_Real fl = 1.e-3;
955 static Standard_Real tapp_angle = 1.e-2;
956 static GeomAbs_Shape blend_cont = GeomAbs_C1;
958 static BRepFilletAPI_MakeFillet* Rakk = 0;
959 static BRepFilletAPI_MakeFillet* Rake = 0;
960 static char name[100];
962 static void printtolblend(Draw_Interpretor& di)
964 di<<"tolerance ang : "<<ta<<"\n";
965 di<<"tolerance 3d : "<<t3d<<"\n";
966 di<<"tolerance 2d : "<<t2d<<"\n";
967 di<<"fleche : "<<fl<<"\n";
969 di<<"tolblend "<<ta<<" "<<t3d<<" "<<t2d<<" "<<fl<<"\n";
972 static Standard_Integer MKEVOL(Draw_Interpretor& di,
973 Standard_Integer narg,
976 if(Rake != 0) {delete Rake; Rake = 0;}
978 if (narg < 3) return 1;
979 TopoDS_Shape V = DBRep::Get(a[2]);
980 Rake = new BRepFilletAPI_MakeFillet(V);
981 Rake->SetParams(ta,t3d,t2d,t3d,t2d,fl);
982 Rake->SetContinuity(blend_cont, tapp_angle);
984 ChFi3d_FilletShape FSh = ChFi3d_Rational;
985 if (!strcasecmp(a[3], "Q")) {
986 FSh = ChFi3d_QuasiAngular;
988 else if (!strcasecmp(a[3], "P")) {
989 FSh = ChFi3d_Polynomial;
991 Rake->SetFilletShape(FSh);
997 static Standard_Integer UPDATEVOL(Draw_Interpretor& di,
998 Standard_Integer narg,
1002 di << "MakeFillet non initialise"<<"\n";
1005 if(narg%2 != 0 || narg < 4) return 1;
1006 TColgp_Array1OfPnt2d uandr(1,(narg/2)-1);
1007 Standard_Real Rad, Par;
1008 TopoDS_Shape aLocalEdge(DBRep::Get(a[1],TopAbs_EDGE));
1009 TopoDS_Edge E = TopoDS::Edge(aLocalEdge);
1010 for (Standard_Integer ii = 1; ii <= (narg/2)-1; ii++){
1011 Par = atof(a[2*ii]);
1012 Rad = atof(a[2*ii + 1]);
1013 uandr.ChangeValue(ii).SetCoord(Par,Rad);
1015 //HELPDESK: Add law creation
1016 const Standard_Boolean aLawMode = !strcmp(a[0],"OCC570evollaw");
1019 di<<"INFO: Using law to define variable fillet"<<"\n";
1020 Handle(Law_Interpol) law = new Law_Interpol;
1030 static Standard_Integer BUILDEVOL(Draw_Interpretor& di,
1035 di << "MakeFillet non initialise"<<"\n";
1040 TopoDS_Shape result = Rake->Shape();
1041 DBRep::Set(name,result);
1042 if(Rake != 0) {delete Rake; Rake = 0;}
1045 if(Rake != 0) {delete Rake; Rake = 0;}
1049 #include <TColGeom_SequenceOfCurve.hxx>
1050 #include <Geom_TrimmedCurve.hxx>
1051 #include <GeomFill_NSections.hxx>
1052 #include <BRepBuilderAPI_MakeFace.hxx>
1053 //=======================================================================
1056 //=======================================================================
1057 static Standard_Integer OCC606 ( Draw_Interpretor& di, Standard_Integer n, const char ** a )
1059 if (n != 3 && n != 4)
1061 di << "Usage : " << a[0] << " result shape [-t]" << "\n";
1065 Standard_Boolean TrimMode = (n == 4);
1066 if (TrimMode) di<<"INFO: Using trimmed curves..."<<"\n";
1067 else di<<"INFO: Using non trimmed curves..."<<"\n";
1069 TopoDS_Shape S = DBRep::Get(a[2]);
1071 TopExp_Explorer t_exp(S,TopAbs_EDGE);
1072 TColGeom_SequenceOfCurve n_curves1;
1073 TColStd_SequenceOfReal np;
1074 Standard_Real param = 5.0;
1076 for (;t_exp.More();t_exp.Next())
1079 Handle(Geom_Curve) h_cur = BRep_Tool::Curve(TopoDS::Edge(t_exp.Current()),f,l);
1080 if (!h_cur.IsNull())
1082 if (TrimMode) h_cur = new Geom_TrimmedCurve(h_cur,f,l);
1084 n_curves1.Append(h_cur);
1090 if (n_curves1.Length()>1 && !np.IsEmpty())
1095 GeomFill_NSections b_surface1(n_curves1, np);
1096 b_surface1.ComputeSurface();
1097 Handle(Geom_BSplineSurface) result_surf1 = b_surface1.BSplineSurface();
1098 if (!result_surf1.IsNull())
1100 BRepBuilderAPI_MakeFace b_face1(result_surf1, Precision::Confusion());
1101 TopoDS_Face bsp_face1 = b_face1.Face();
1102 DBRep::Set(a[1],bsp_face1);
1105 catch(Standard_Failure)
1107 di<<"ERROR: Exception in GeomFill_NSections"<<"\n";
1115 //=======================================================================
1118 //=======================================================================
1119 static Standard_Integer OCC813 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
1123 di << "Usage : " << argv[0] << " U V" << "\n";
1127 Standard_CString str;
1128 Standard_Real U = atof(argv[1]);
1129 Standard_Real V = atof(argv[2]);
1131 //Between ellipse and point:
1133 Handle(Geom_Ellipse) ell = new Geom_Ellipse(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
1134 gp_Dir(0.173648,0.984808,0.000000),
1135 gp_Dir(-0.932169,0.164367,-0.322560)), 150, 100);
1136 Handle(Geom_Plane) plne = new Geom_Plane(gp_Ax3(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
1137 gp_Dir(0.173648,0.984808,0.000000),
1138 gp_Dir(-0.932169,0.164367,-0.322560))) );
1140 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1143 gp_Pln pln = plne->Pln();
1145 str = "OCC813_pnt"; DrawTrSurf::Set(str,pt2d);
1147 Handle(Geom2d_Curve) curve2d = GeomAPI::To2d(ell,pln);
1148 Geom2dAdaptor_Curve acur(curve2d);
1149 Geom2dGcc_QualifiedCurve qcur(acur, GccEnt_outside);
1151 str = "OCC813_ell"; DrawTrSurf::Set(str,curve2d);
1152 if(!aContext.IsNull()) {
1153 Handle(AIS_Shape) aisp =
1154 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(curve2d, pln)).Edge());
1155 aContext->Display (aisp);
1158 //This does not give any solutions.
1159 Geom2dGcc_Lin2d2Tan lintan(qcur, pt2d, 0.1);
1160 di<<"OCC813 nb of solutions = "<<lintan.NbSolutions()<<"\n";
1162 Standard_Character abuf[16];
1163 Standard_CString st = abuf;
1166 for(i=1;i<=lintan.NbSolutions();i++) {
1167 sprintf(abuf,"lintan_%d",i);
1168 Handle(Geom2d_Line) glin = new Geom2d_Line(lintan.ThisSolution(i));
1169 DrawTrSurf::Set(st,glin);
1170 if(!aContext.IsNull()) {
1171 Handle(AIS_Shape) aisp =
1172 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(glin, pln)).Edge()); aContext->Display (aisp);
1179 //=======================================================================
1182 //=======================================================================
1183 static Standard_Integer OCC814 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
1187 di << "Usage : " << argv[0] << "\n";
1191 Standard_CString str;
1193 //Between Ellipse and Circle:
1195 Handle(Geom_Circle) cir = new Geom_Circle(gp_Ax2(gp_Pnt(823.687192,502.366825,478.960440),
1196 gp_Dir(0.173648,0.984808,0.000000),
1197 gp_Dir(-0.932169,0.164367,-0.322560)), 50);
1198 Handle(Geom_Ellipse) ell = new Geom_Ellipse(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
1199 gp_Dir(0.173648,0.984808,0.000000),
1200 gp_Dir(-0.932169,0.164367,-0.322560)), 150, 100);
1201 Handle(Geom_Plane) plne = new Geom_Plane(gp_Ax3(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
1202 gp_Dir(0.173648,0.984808,0.000000),
1203 gp_Dir(-0.932169,0.164367,-0.322560))) );
1205 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1207 gp_Pln pln = plne->Pln();
1208 Handle(Geom2d_Curve) curve2d = GeomAPI::To2d(ell, pln);
1209 Handle(Geom2d_Curve) fromcurve2d = GeomAPI::To2d(cir, pln);
1211 str = "OCC814_cir"; DrawTrSurf::Set(str,curve2d);
1212 str = "OCC814_ell"; DrawTrSurf::Set(str,fromcurve2d);
1213 if(!aContext.IsNull()) {
1214 Handle(AIS_Shape) aisp =
1215 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(curve2d, pln)).Edge());
1216 aContext->Display (aisp);
1218 if(!aContext.IsNull()) {
1219 Handle(AIS_Shape) aisp =
1220 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(fromcurve2d, pln)).Edge());
1221 aContext->Display (aisp);
1224 Geom2dAdaptor_Curve acur(curve2d), afromcur(fromcurve2d);
1226 Geom2dGcc_QualifiedCurve qcur(acur, GccEnt_outside) ;
1227 Geom2dGcc_QualifiedCurve qfromcur(afromcur, GccEnt_outside) ;
1229 //This does not give any solutions.
1230 Geom2dGcc_Lin2d2Tan lintan(qcur, qfromcur, 0.1);
1231 di<<"OCC814 nb of solutions = "<<lintan.NbSolutions()<<"\n";
1233 Standard_Character abuf[16];
1234 Standard_CString st = abuf;
1237 for(i=1;i<=lintan.NbSolutions();i++) {
1238 sprintf(abuf,"lintan_%d",i);
1239 Handle(Geom2d_Line) glin = new Geom2d_Line(lintan.ThisSolution(i));
1240 DrawTrSurf::Set(st,glin);
1241 if(!aContext.IsNull()) {
1242 Handle(AIS_Shape) aisp =
1243 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(glin, pln)).Edge()); aContext->Display (aisp);
1250 #include <ShapeAnalysis_Wire.hxx>
1251 #include <IntRes2d_SequenceOfIntersectionPoint.hxx>
1252 #include <TColgp_SequenceOfPnt.hxx>
1253 #include <ShapeFix_Wire.hxx>
1254 //=======================================================================
1257 //=======================================================================
1258 static Standard_Integer OCC884 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1260 if (argc < 3 || argc > 5)
1262 di << "Usage : " << argv[0] << " result shape [toler [maxtoler]]" << "\n";
1266 TopoDS_Shape shape = DBRep::Get(argv[2]); //read the shape
1268 TopExp_Explorer exp(shape, TopAbs_EDGE);
1271 di<<"Error: no edge found"<<"\n";
1275 BRep_Builder builder;
1277 builder.MakeWire(wire);
1278 builder.Add(wire, TopoDS::Edge(exp.Current()));
1280 // HelpDesk: Create planar face if possible
1281 TopoDS_Face face = BRepBuilderAPI_MakeFace(wire,Standard_True);
1283 Handle(ShapeAnalysis_Wire) advWA = new ShapeAnalysis_Wire;
1285 advWA->SetFace(face);
1286 advWA->SetPrecision(0.001);
1288 IntRes2d_SequenceOfIntersectionPoint points2d;
1289 TColgp_SequenceOfPnt points3d;
1291 di << "Info: CheckSelfIntersectingEdge = " << (Standard_Integer) advWA->CheckSelfIntersectingEdge(1,points2d,points3d) << "\n";
1293 ShapeExtend_Status status = ShapeExtend_FAIL1;
1294 if (advWA->StatusSelfIntersection(status))
1295 di << "Info: No P Curve found in the edge\n";
1297 status = ShapeExtend_FAIL2;
1298 if (advWA->StatusSelfIntersection(status))
1299 di << "Info: No Vertices found in the edge\n";
1301 status = ShapeExtend_DONE1;
1302 if (advWA->StatusSelfIntersection(status))
1303 di << "Info: Self-intersection found in the edge\n";
1305 Standard_Integer i, num = points2d.Length();
1306 di << "Info: No. of self-intersection points : " << num << "\n";
1309 Standard_CString name = str;
1310 for (i = 1; i <= num; ++i)
1312 gp_Pnt pt = points3d(i);
1313 di << "Info: Intersecting pt : (" << pt.X() << ", " << pt.Y() << ", " << pt.Z() << ")\n";
1314 sprintf(str,"p_%d",i);
1315 DrawTrSurf::Set(name,pt);
1318 Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire;
1322 if (argc > 3) sfw->SetPrecision(atof(argv[3])/*0.1*/);
1323 if (argc > 4) sfw->SetMaxTolerance(atof(argv[4]));
1324 di << "Info: Precision is set to " << sfw->Precision() << "\n";
1325 di << "Info: MaxTolerance is set to " << sfw->MaxTolerance() << "\n";
1327 sfw->ModifyTopologyMode() = 1;
1328 sfw->ModifyGeometryMode() = 1;
1329 sfw->FixSelfIntersectingEdgeMode() = 1;
1330 //printf("Info: FixSelfIntersection = %d\n",sfw->FixSelfIntersection());
1331 di << "Info: FixSelfIntersection = " << (Standard_Integer) sfw->FixSelfIntersection() << "\n";
1333 DBRep::Set(argv[1],sfw->Wire());
1335 status = ShapeExtend_OK;
1336 if (sfw->StatusSelfIntersection(status))
1337 di << "Info: ShapeExtend_OK : No intersection found\n";
1338 //printf("Info: ShapeExtend_OK : No intersection found\n");
1340 status = ShapeExtend_FAIL1;
1341 if (sfw->StatusSelfIntersection(status))
1342 di << "Info: ShapeExtend_FAIL1 : analysis failed (edge has no pcurve, or no vertices etc.)\n";
1344 status = ShapeExtend_FAIL2;
1345 if (sfw->StatusSelfIntersection(status))
1346 di << "Info: ShapeExtend_FAIL2 : self-intersection was found, but not fixed because of limit of increasing tolerance (MaxTolerance)\n";
1348 status = ShapeExtend_FAIL3;
1349 if (sfw->StatusSelfIntersection(status))
1350 di << "Info: ShapeExtend_FAIL3 : intercestion of non adjacent edges found, but not fixed because of limit of increasing tolerance (MaxTolerance)\n";
1352 status = ShapeExtend_DONE1;
1353 if (sfw->StatusSelfIntersection(status))
1354 di << "Info: ShapeExtend_DONE1 : tolerance of vertex was increased to fix self-intersection\n";
1356 status = ShapeExtend_DONE2;
1357 if (sfw->StatusSelfIntersection(status))
1358 di << "Info: ShapeExtend_DONE2 : vertex was moved to fix self-intersection\n";
1360 status = ShapeExtend_DONE3;
1361 if (sfw->StatusSelfIntersection(status))
1362 di << "Info: ShapeExtend_DONE3 : some edges were removed because of intersection\n";
1364 status = ShapeExtend_DONE4;
1365 if (sfw->StatusSelfIntersection(status))
1366 di << "Info: ShapeExtend_DONE4 : pcurve(s) was(were) modified\n";
1368 status = ShapeExtend_DONE5;
1369 if (sfw->StatusSelfIntersection(status))
1370 di << "Info: ShapeExtend_DONE5 : non adjacent intersection fixed by increasing tolerance of vertex(vertices)\n";
1372 status = ShapeExtend_DONE6;
1373 if (sfw->StatusSelfIntersection(status))
1374 di << "Info: ShapeExtend_DONE6 : tolerance of edge was increased to hide intersection\n";
1376 status = ShapeExtend_DONE7;
1377 if (sfw->StatusSelfIntersection(status))
1378 di << "Info: ShapeExtend_DONE7 : range of some edges was decreased to avoid intersection\n";
1383 #include <Aspect_FillMethod.hxx>
1384 //=======================================================================
1385 //function : OCC1188
1387 //=======================================================================
1388 static Standard_Integer OCC1188 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1390 if (argc < 2 || argc > 3)
1392 di << "Usage : " << argv[0] << " imagefile [filltype] : Load image as background" << "\n";
1396 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1397 if(AISContext.IsNull())
1399 di << "use 'vinit' command before " << argv[0] << "\n";
1403 Aspect_FillMethod aFillType = Aspect_FM_CENTERED;
1406 const char* szType = argv[2];
1407 if (strcmp(szType, "NONE" ) == 0) aFillType = Aspect_FM_NONE;
1408 else if (strcmp(szType, "CENTERED") == 0) aFillType = Aspect_FM_CENTERED;
1409 else if (strcmp(szType, "TILED" ) == 0) aFillType = Aspect_FM_TILED;
1410 else if (strcmp(szType, "STRETCH" ) == 0) aFillType = Aspect_FM_STRETCH;
1413 di << "Wrong fill type : " << szType << "\n";
1414 di << "Must be one of CENTERED, TILED, STRETCH, NONE" << "\n";
1419 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
1420 V3dView->SetBackgroundImage(argv[1], aFillType, Standard_True);
1425 #include <AIS_Drawer.hxx>
1426 #include <Graphic3d_MaterialAspect.hxx>
1427 #include <Prs3d_ShadingAspect.hxx>
1428 //=======================================================================
1429 //function : OCC1174_1
1431 //=======================================================================
1432 static Standard_Integer OCC1174_1 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1436 di << "Usage : " << argv[0] << " shape" << "\n";
1440 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1441 if(AISContext.IsNull())
1443 di << "use 'vinit' command before " << argv[0] << "\n";
1447 TopoDS_Shape sh = DBRep::Get(argv[1]);
1449 Handle(AIS_Shape) ais = new AIS_Shape(sh);
1451 Quantity_Color colf(0.0, 0.4, 0.0, Quantity_TOC_RGB);
1452 Quantity_Color colb(0.0, 0.0, 0.6, Quantity_TOC_RGB);
1454 Handle(Prs3d_ShadingAspect) sa = ais->Attributes()->ShadingAspect();
1456 Graphic3d_MaterialAspect front = sa->Material(Aspect_TOFM_FRONT_SIDE);
1457 front.SetAmbientColor(colf);
1458 front.SetDiffuseColor(colf);
1459 front.SetSpecularColor(colf);
1460 front.SetEmissiveColor(colf);
1461 front.SetTransparency(0.0);
1462 sa->SetMaterial(front,Aspect_TOFM_FRONT_SIDE);
1464 Graphic3d_MaterialAspect back = sa->Material(Aspect_TOFM_BACK_SIDE);
1465 back.SetAmbientColor(colb);
1466 back.SetDiffuseColor(colb);
1467 back.SetSpecularColor(colb);
1468 back.SetEmissiveColor(colb);
1469 back.SetTransparency(0.0);
1470 sa->SetMaterial(back,Aspect_TOFM_BACK_SIDE);
1472 AISContext->Display(ais,1,0);
1474 Standard_Real r, g, b;
1475 sa->Color(Aspect_TOFM_FRONT_SIDE).Values(r,g,b, Quantity_TOC_RGB);
1476 di << "Info: color on front side (" << r << "," << g << "," << b << ")\n";
1477 sa->Color(Aspect_TOFM_BACK_SIDE).Values(r,g,b, Quantity_TOC_RGB);
1478 di << "Info: color on back side (" << r << "," << g << "," << b << ")\n";
1483 //=======================================================================
1484 //function : OCC1174_2
1486 //=======================================================================
1487 static Standard_Integer OCC1174_2 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1491 di << "Usage : " << argv[0] << " shape" << "\n";
1495 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1496 if(AISContext.IsNull())
1498 di << "use 'vinit' command before " << argv[0] << "\n";
1502 TopoDS_Shape sh = DBRep::Get(argv[1]);
1504 Handle(AIS_Shape) ais = new AIS_Shape(sh);
1505 AISContext->Display(ais,1,0);
1506 AISContext->SetMaterial(ais,Graphic3d_NOM_SHINY_PLASTIC);
1508 Quantity_Color colf(0.0, 0.4, 0.0, Quantity_TOC_RGB);
1509 Quantity_Color colb(0.0, 0.0, 0.6, Quantity_TOC_RGB);
1510 Handle(Prs3d_ShadingAspect) sa = ais->Attributes()->ShadingAspect();
1512 Graphic3d_MaterialAspect front = sa->Material(Aspect_TOFM_FRONT_SIDE);
1513 front.SetAmbientColor(colf);
1514 front.SetDiffuseColor(colf);
1515 front.SetSpecularColor(colf);
1516 front.SetEmissiveColor(colf);
1517 front.SetTransparency(0.4);
1518 sa->SetMaterial(front,Aspect_TOFM_FRONT_SIDE);
1520 Graphic3d_MaterialAspect back = sa->Material(Aspect_TOFM_BACK_SIDE);
1521 back.SetAmbientColor(colb);
1522 back.SetDiffuseColor(colb);
1523 back.SetSpecularColor(colb);
1524 back.SetEmissiveColor(colb);
1525 back.SetTransparency(0.2);
1526 sa->SetMaterial(back,Aspect_TOFM_BACK_SIDE);
1528 AISContext->Redisplay(ais,1,0);
1533 #include <Graphic2d_Segment.hxx>
1534 #include <Prs2d_Length.hxx>
1535 #include <Prs2d_AspectLine.hxx>
1536 #include <AIS2D_InteractiveObject.hxx>
1537 //=======================================================================
1542 // OCC672_ShortLength
1543 //=======================================================================
1545 static Standard_Integer OCC672_Length (Draw_Interpretor& di, Standard_Integer n,const char ** argv)
1548 di << " wrong parameters !\n";
1549 di << "must be : OCC672_Length x1 y1 x2 y2 str scale_text length_dist angle_arrow length_arrow x3 y3 x4 y4 TxtAngle TxtPosH TxtPosV\n";
1553 Standard_Real x1=atof(argv[1]);
1554 Standard_Real y1=atof(argv[2]);
1555 Standard_Real x2=atof(argv[3]);
1556 Standard_Real y2=atof(argv[4]);
1557 Standard_Real x3=atof(argv[10]);
1558 Standard_Real y3=atof(argv[11]);
1559 Standard_Real x4=atof(argv[12]);
1560 Standard_Real y4=atof(argv[13]);
1561 Standard_Real txtAngle=atof(argv[14]);
1562 Standard_Real txtPosH=atof(argv[15]);
1563 Standard_Real txtPosV=atof(argv[16]);
1566 Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
1567 di<<"Check InteractiveContext\n";
1569 if(aContext.IsNull()) {
1570 di << "use 'v2dinit' command before " << argv[0] << "\n";
1574 di<<"CloseLocalContext\n";
1575 aContext->CloseLocalContext();
1577 di<<"OpenLocalContext\n";
1578 aContext->OpenLocalContext();
1580 Handle(AIS2D_InteractiveObject) aIO10 = new AIS2D_InteractiveObject();
1581 Handle(Graphic2d_Segment) theSegmA, theSegmB, theSegmC, theSegmD;
1583 theSegmA = new Graphic2d_Segment( aIO10, x1, y1, x2, y2 );
1584 theSegmB = new Graphic2d_Segment( aIO10, x2, y2, x3, y3 );
1585 theSegmC = new Graphic2d_Segment( aIO10, x3, y3, x4, y4 );
1586 theSegmD = new Graphic2d_Segment( aIO10, x4, y4, x1, y1 );
1588 aContext->Display( aIO10, Standard_True );
1590 Handle(Prs2d_Length) length = new Prs2d_Length(aIO10, gp_Pnt2d(x1, y1), gp_Pnt2d(x2, y2), argv[5],
1591 atof(argv[6]), atof(argv[7]), Prs2d_TOD_AUTOMATIC,
1592 atof(argv[8]), atof(argv[9]), Prs2d_TOA_FILLED,
1595 length->SetTextRelPos(txtPosH,txtPosV);
1596 length->SetTextRelAngle(txtAngle);
1598 Handle(Prs2d_AspectLine) theAspect = new Prs2d_AspectLine(Quantity_NOC_WHITE,
1599 Aspect_TOL_SOLID, Aspect_WOL_THIN);
1600 aIO10->SetAspect( theAspect, length);
1601 aContext->Display( aIO10, Standard_True );
1603 Handle(Prs2d_Length) lengthB = new Prs2d_Length(aIO10, gp_Pnt2d(x2, y2), gp_Pnt2d(x3, y3), argv[5],
1604 atof(argv[6]), atof(argv[7]), Prs2d_TOD_AUTOMATIC,
1605 atof(argv[8]), atof(argv[9]), Prs2d_TOA_FILLED,
1608 lengthB->SetTextRelPos(txtPosH,txtPosV);
1609 lengthB->SetTextRelAngle(txtAngle);
1611 aIO10->SetAspect( theAspect, lengthB);
1612 aContext->Display( aIO10, Standard_True );
1614 Handle(Prs2d_Length) lengthC = new Prs2d_Length(aIO10, gp_Pnt2d(x3, y3), gp_Pnt2d(x4, y4), argv[5],
1615 atof(argv[6]), atof(argv[7]), Prs2d_TOD_AUTOMATIC,
1616 atof(argv[8]), atof(argv[9]), Prs2d_TOA_FILLED,
1619 lengthC->SetTextRelPos(txtPosH,txtPosV);
1620 lengthC->SetTextRelAngle(txtAngle);
1622 aIO10->SetAspect( theAspect, lengthC);
1623 aContext->Display( aIO10, Standard_True );
1625 Handle(Prs2d_Length) lengthD = new Prs2d_Length(aIO10, gp_Pnt2d(x4, y4), gp_Pnt2d(x1, y1), argv[5],
1626 atof(argv[6]), atof(argv[7]), Prs2d_TOD_AUTOMATIC,
1627 atof(argv[8]), atof(argv[9]), Prs2d_TOA_FILLED,
1630 lengthD->SetTextRelPos(txtPosH,txtPosV);
1631 lengthD->SetTextRelAngle(txtAngle);
1633 aIO10->SetAspect( theAspect, lengthD);
1634 aContext->Display( aIO10, Standard_True );
1638 #include <Prs2d_Angle.hxx>
1639 static Standard_Integer OCC672_Angle (Draw_Interpretor& di, Standard_Integer n,const char ** argv)
1642 di << "Wrong parameters !\n";
1643 di << "must be : OCC672_Angle x1 y1 x2 y2 x3 y3 aRadius aText aTxtScale anArrAngle anArrLength txtAngle txtPosH txtPosV \n";
1647 Standard_Real x1=atof(argv[1]);
1648 Standard_Real y1=atof(argv[2]);
1649 Standard_Real x2=atof(argv[3]);
1650 Standard_Real y2=atof(argv[4]);
1651 Standard_Real x3=atof(argv[5]);
1652 Standard_Real y3=atof(argv[6]);
1653 Standard_Real aRadius=atof(argv[7]);
1654 Standard_Real aTxtScale=atof(argv[9]);
1655 Standard_Real anArrAngle=atof(argv[10]);
1656 Standard_Real anArrLength=atof(argv[11]);
1657 Standard_Real txtAngle=atof(argv[12]);
1658 Standard_Real txtPosH=atof(argv[13]);
1659 Standard_Real txtPosV=atof(argv[14]);
1662 Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
1663 di<<"Check InteractiveContext\n";
1665 if(aContext.IsNull()) {
1666 di << "use 'v2dinit' command before " << argv[0] << "\n";
1670 di<<"CloseLocalContext\n";
1671 aContext->CloseLocalContext();
1673 di<<"OpenLocalContext\n";
1674 aContext->OpenLocalContext();
1676 Handle(AIS2D_InteractiveObject) aIO10 = new AIS2D_InteractiveObject();
1677 Handle(Graphic2d_Segment) theSegmA, theSegmB;
1678 theSegmA = new Graphic2d_Segment( aIO10, x1, y1, x2, y2 );
1679 theSegmB = new Graphic2d_Segment( aIO10, x1, y1, x3, y3 );
1680 aContext->Display( aIO10, Standard_True );
1682 Handle(Prs2d_Angle) angle = new Prs2d_Angle(aIO10, gp_Pnt2d(x1, y1), gp_Pnt2d(x2, y2),gp_Pnt2d(x3,y3),
1683 aRadius,argv[8],aTxtScale,anArrAngle,anArrLength,Prs2d_TOA_FILLED,
1686 angle->SetTextRelPos(txtPosH,txtPosV);
1687 angle->SetTextAbsAngle(txtAngle);
1689 aContext->Display( aIO10, Standard_True );
1693 #include <Prs2d_Diameter.hxx>
1694 #include <gp_Circ2d.hxx>
1695 #include <Graphic2d_Circle.hxx>
1696 #include <Prs2d_AspectText.hxx>
1697 static Standard_Integer OCC672_Diameter (Draw_Interpretor& di, Standard_Integer n,const char ** argv)
1700 di << "Wrong parameters !\n";
1701 di << "must be : OCC672_Diameter x1 y1 cx cy radius aText aTxtScale anArrAngle anArrLength txtAngle txtPosH txtPosV\n";
1705 Standard_Real x1=atof(argv[1]);
1706 Standard_Real y1=atof(argv[2]);
1707 Standard_Real cx=atof(argv[3]); //coordinats for circle
1708 Standard_Real cy=atof(argv[4]); //
1709 Standard_Real radius=atof(argv[5]);//radius for circle
1710 Standard_Real aTxtScale=atof(argv[7]);
1711 Standard_Real anArrAngle=atof(argv[8]);
1712 Standard_Real anArrLength=atof(argv[9]);
1714 Standard_Real txtAngle=atof(argv[10]);
1715 Standard_Real txtPosH=atof(argv[11]);
1716 Standard_Real txtPosV=atof(argv[12]);
1720 Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
1721 di<<"Check InteractiveContext\n";
1723 if(aContext.IsNull()) {
1724 di << "use 'v2dinit' command before " << argv[0] << "\n";
1728 di<<"CloseLocalContext\n";
1729 aContext->CloseLocalContext();
1731 di<<"OpenLocalContext\n";
1732 aContext->OpenLocalContext();
1733 Handle(AIS2D_InteractiveObject) aIO10 = new AIS2D_InteractiveObject();
1735 Handle (Graphic2d_Circle) HCirc;
1736 HCirc= new Graphic2d_Circle(aIO10,cx,cy,radius);
1738 gp_Dir2d myDir2d(1,0);
1739 gp_Pnt2d myPnt2d(cx,cy);
1740 gp_Ax2d myAx2d(myPnt2d,myDir2d);
1741 gp_Circ2d myCirc(myAx2d,radius);
1743 Handle(Prs2d_Diameter) diameter = new Prs2d_Diameter(aIO10, gp_Pnt2d(x1, y1),myCirc,
1744 argv[6],aTxtScale,anArrAngle,anArrLength,
1746 Prs2d_AS_BOTHAR,Standard_True);
1748 diameter->SetTextRelPos(txtPosH,txtPosV);
1750 diameter->SetTextAbsAngle(txtAngle);
1752 aContext->Display( aIO10, Standard_True );
1757 #include <gp_Lin2d.hxx>
1758 static Standard_Integer OCC672_ShortLength (Draw_Interpretor& di, Standard_Integer n,const char ** argv)
1761 di << " wrong parameters !\n";
1762 di << "must be : OCC672_ShortLength x1 y1 x2 y2 str scale_text length_dist angle_arrow length_arrow x3 y3 x4 y4 TxtAngle TxtPosH TxtPosV\n";
1766 Standard_Real x1=atof(argv[1]);
1767 Standard_Real y1=atof(argv[2]);
1768 Standard_Real x2=atof(argv[3]);
1769 Standard_Real y2=atof(argv[4]);
1770 Standard_Real x3=atof(argv[10]);
1771 Standard_Real y3=atof(argv[11]);
1772 Standard_Real x4=atof(argv[12]);
1773 Standard_Real y4=atof(argv[13]);
1774 Standard_Real txtAngle=atof(argv[14]);
1775 Standard_Real txtPosH=atof(argv[15]);
1776 Standard_Real txtPosV=atof(argv[16]);
1780 Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
1781 di<<"Check InteractiveContext\n";
1783 if(aContext.IsNull()) {
1784 di << "use 'v2dinit' command before " << argv[0] << "\n";
1788 di<<"CloseLocalContext\n";
1789 aContext->CloseLocalContext();
1791 di<<"OpenLocalContext\n";
1792 aContext->OpenLocalContext();
1794 Handle(AIS2D_InteractiveObject) aIO10 = new AIS2D_InteractiveObject();
1795 Handle(Graphic2d_Segment) theSegmA, theSegmB, theSegmC, theSegmD;
1796 theSegmB = new Graphic2d_Segment( aIO10, x2, y2, x3, y3 );
1797 theSegmD = new Graphic2d_Segment( aIO10, x4, y4, x1, y1 );
1799 aContext->Display( aIO10, Standard_True );
1801 gp_Pnt2d p3(x3,y3),p2(x2,y2),p1(x1,y1);
1802 gp_Vec2d theVec(p3,p2);
1803 gp_Dir2d theDir(theVec);
1804 gp_Lin2d theLin1(p1,theDir);
1805 gp_Lin2d theLin2(p3,theDir);
1807 Handle(Prs2d_Length) length = new Prs2d_Length(aIO10, p1, theLin2, argv[5],
1808 atof(argv[6]), 5.0, 20.0, 5.,
1809 Prs2d_TOA_CLOSED,Prs2d_AS_BOTHAR,
1813 Handle(Prs2d_AspectLine) theAspect = new Prs2d_AspectLine(Quantity_NOC_WHITE,
1814 Aspect_TOL_SOLID, Aspect_WOL_THIN);
1815 length->SetTextRelPos(txtPosH,txtPosV);
1816 length->SetTextRelAngle(txtAngle);
1818 aIO10->SetAspect( theAspect, length);
1819 aContext->Display( aIO10, Standard_True );
1824 #include <TopoDS_Solid.hxx>
1825 #include <BRepFeat_MakeDPrism.hxx>
1826 //=======================================================================
1828 //purpose : FEATURE OPERATION (BOSS and SLOT)
1829 //=======================================================================
1830 static Standard_Integer OCCN1 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1834 di << "Usage : " << argv[0] << " angle fuse(1 for boss / 0 for slot) length" << "\n";
1838 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1839 if(aContext.IsNull())
1841 di << "use 'vinit' command before " << argv[0] << "\n";
1844 Standard_Real angle = atof(argv[1]);
1845 Standard_Integer fuse = atoi(argv[2]);
1846 Standard_Real length = atof(argv[3]);
1848 BRepBuilderAPI_MakeEdge edge1(gp_Pnt(0, 0, 0), gp_Pnt(50, 0, 0));
1849 BRepBuilderAPI_MakeEdge edge2(gp_Pnt(50, 0, 0), gp_Pnt(50, 50, 0));
1850 BRepBuilderAPI_MakeEdge edge3(gp_Pnt(50, 50, 0), gp_Pnt(0, 50, 0));
1851 BRepBuilderAPI_MakeEdge edge4(gp_Pnt(0, 50, 0), gp_Pnt(0, 0, 0));
1852 TopoDS_Edge ted1 = edge1.Edge();
1853 TopoDS_Edge ted2 = edge2.Edge();
1854 TopoDS_Edge ted3 = edge3.Edge();
1855 TopoDS_Edge ted4 = edge4.Edge();
1857 BRepBuilderAPI_MakeWire wire(ted1, ted2, ted3, ted4);
1858 TopoDS_Wire twire = wire.Wire();
1860 BRepBuilderAPI_MakeFace face(twire);
1861 TopoDS_Face tface = face.Face();
1862 ////////Handle_AIS_Shape face_ais = new AIS_Shape( tface );
1863 ////////aContext->Display(face_ais);
1866 BRepPrimAPI_MakeBox block(gp_Pnt(-50, -50, -150), 150, 150, 100);
1867 box = block.Solid();
1869 TopoDS_Face top_face;
1870 top_face = block.TopFace();
1872 BRepFeat_MakeDPrism slot(box, tface, top_face, angle, fuse,
1875 slot.Perform(length);
1876 TopoDS_Shape S2 = slot.Shape();
1878 DBRep::Set("OCCN1_tface",tface);
1879 DBRep::Set("OCCN1_slot",S2);
1884 #include <BRepPrimAPI_MakeCylinder.hxx>
1885 #include <BRepPrimAPI_MakeSphere.hxx>
1886 #include <BRepAlgoAPI_Section.hxx>
1887 #include <BRepAlgo_Section.hxx>
1888 //=======================================================================
1890 //purpose : BOOLEAN OPERATION
1891 //=======================================================================
1892 static Standard_Integer OCCN2 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1895 di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1898 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1900 Standard_Integer IsB = atoi(argv[1]);
1902 IsBRepAlgoAPI = Standard_False;
1903 #if ! defined(BRepAlgo_def04)
1908 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1909 if(aContext.IsNull())
1911 di << "use 'vinit' command before " << argv[0] << "\n";
1915 BRepPrimAPI_MakeCylinder cylinder(50,200);
1916 TopoDS_Shape cylinder_sh = cylinder.Shape();
1918 BRepPrimAPI_MakeSphere sphere(gp_Pnt(60,0,100),50);
1919 TopoDS_Shape sphere_sh = sphere.Shape();
1921 //BRepAlgoAPI_Section section(cylinder_sh, sphere_sh);
1922 //TopoDS_Shape shape = section.Shape();
1925 if (IsBRepAlgoAPI) {
1926 di << "BRepAlgoAPI_Section section(cylinder_sh, sphere_sh)" <<"\n";
1927 BRepAlgoAPI_Section section(cylinder_sh, sphere_sh);
1929 if(!section.IsDone()){
1930 di << "Error performing intersection: not done." << "\n";
1932 shape = section.Shape();
1934 di << "BRepAlgo_Section section(cylinder_sh, sphere_sh)" <<"\n";
1935 BRepAlgo_Section section(cylinder_sh, sphere_sh);
1937 if(!section.IsDone()){
1938 di << "Error performing intersection: not done." << "\n";
1940 shape = section.Shape();
1943 DBRep::Set("OCCN2_cylinder",cylinder_sh);
1944 DBRep::Set("OCCN2_sphere",sphere_sh);
1945 DBRep::Set("OCCN2_section",shape);
1950 #include <TColgp_Array1OfPnt.hxx>
1951 #include <Geom_BezierCurve.hxx>
1953 static Standard_Integer OCC2569 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1955 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1956 if(aContext.IsNull())
1958 di << "use 'vinit' command before " << argv[0] << "\n";
1962 di << "Usage : " << argv[0] << " nbpoles result" << "\n";
1966 int poles=atoi(argv[1]);
1968 TColgp_Array1OfPnt arr(1, poles);
1969 for(int i=1; i<=poles; i++)
1970 arr.SetValue(i, gp_Pnt(i+10, i*2+20, i*3+45));
1972 Handle_Geom_BezierCurve bez = new Geom_BezierCurve(arr);
1974 di << "\n The curve is not created.\n";
1976 di << "\n Degree = " << bez->Degree() << "\n";
1978 TopoDS_Edge sh = BRepBuilderAPI_MakeEdge(bez).Edge();
1979 Handle_AIS_Shape ais = new AIS_Shape(sh);
1980 aContext->Display(ais);
1981 DrawTrSurf::Set(argv[2],bez);
1985 #include <TopTools_IndexedMapOfShape.hxx>
1986 #include <TopExp.hxx>
1988 static Standard_Integer OCC1642 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1991 di<<"Usage: " << argv[0] << " FinalWare FinalFace InitWare InitFace shape FixReorder FixDegenerated FixConnected FixSelfIntersection"<<"\n";
1995 TopoDS_Shape shape = DBRep::Get(argv[5]);
1997 TopExp_Explorer exp(shape, TopAbs_WIRE);
1998 TopoDS_Shape wire = exp.Current();
2000 Handle(ShapeAnalysis_Wire) advWA = new ShapeAnalysis_Wire;
2001 advWA->Load(TopoDS::Wire(wire));
2003 DBRep::Set(argv[3],wire);
2006 BRepBuilderAPI_MakeFace(TopoDS::Wire(wire),Standard_True);
2008 DBRep::Set(argv[4],face);
2010 advWA->SetFace(face);
2011 Standard_Real precision_to_ana = 0.0001;
2012 advWA->SetPrecision(precision_to_ana);
2014 TopTools_IndexedMapOfShape M;
2015 TopExp::MapShapes(wire, TopAbs_EDGE, M);
2018 for(j= 1; j<=M.Extent(); ++j) {
2019 Standard_Integer num=1;
2020 IntRes2d_SequenceOfIntersectionPoint points2d;
2021 TColgp_SequenceOfPnt points3d;
2023 cout << "\n j =" << j << ", CheckSelfIntersectingEdge = " <<
2024 advWA->CheckSelfIntersectingEdge(j, points2d, points3d);
2027 ShapeExtend_Status status = ShapeExtend_FAIL1;
2028 if(advWA->StatusSelfIntersection(status))
2030 status = ShapeExtend_FAIL2;
2031 if(advWA->StatusSelfIntersection(status))
2032 di << "\n No Vertices found in the edge";
2034 status = ShapeExtend_DONE1;
2035 if(advWA->StatusSelfIntersection(status))
2036 di << "\n Self-intersection found in the edge";
2038 num = points2d.Length();
2039 di << "\n No. of self-intersecting edges : " << num;
2041 for(int i=1; i<=num; ++i) {
2042 gp_Pnt pt = points3d(i);
2043 di << "\n Intersecting pt : (" << pt.X() << ", " << pt.Y()<< ", " << pt.Z() << ")";
2048 Handle_ShapeFix_Wire sfw = new ShapeFix_Wire;
2049 sfw->Load(TopoDS::Wire(wire));
2051 sfw->SetPrecision(Precision::Confusion());
2053 sfw->FixReorderMode() = 1;
2054 sfw->ClosedWireMode() = 1;
2055 sfw->FixDegeneratedMode() = 1;
2056 sfw->FixConnectedMode() = 1;
2057 sfw->ModifyTopologyMode() = 1;
2058 sfw->ModifyGeometryMode() = 1;
2059 sfw->FixSelfIntersectionMode() = 1;
2060 sfw->FixSelfIntersectingEdgeMode() = 1;
2061 sfw->FixIntersectingEdgesMode() = 1;
2062 sfw->FixNonAdjacentIntersectingEdgesMode() = 1;
2063 sfw->FixEdgeCurvesMode() = 1;
2065 sfw->ModifyRemoveLoopMode() = 1;
2066 sfw->SetMaxTolerance(1.0);
2068 di << "\n FixReorder = " << (Standard_Integer) sfw->FixReorder();
2069 di << "\n FixDegenerated = " << (Standard_Integer) sfw->FixDegenerated();
2070 di << "\n FixConnected = " << (Standard_Integer) sfw->FixConnected();
2072 di << "\n FixSelfIntersection = " << (Standard_Integer) sfw->FixSelfIntersection();
2075 Draw::Set(argv[6],sfw->FixReorder()) ;
2076 Draw::Set(argv[7],sfw->FixDegenerated()) ;
2077 Draw::Set(argv[8],sfw->FixConnected()) ;
2078 Draw::Set(argv[9],sfw->FixSelfIntersection()) ;
2080 ShapeExtend_Status status = ShapeExtend_OK;
2081 if(sfw->StatusSelfIntersection(status))
2082 di << "\n ShapeExtend_OK : No intersection found";
2084 status = ShapeExtend_FAIL1;
2085 if(sfw->StatusSelfIntersection(status))
2086 di << "\n ShapeExtend_FAIL1 : analysis failed (edge has no pcurve,or no vertices etc.)";
2088 status = ShapeExtend_FAIL2;
2089 if(sfw->StatusSelfIntersection(status))
2090 di << "\n ShapeExtend_FAIL2 : self-intersection was found, but not fixed because of limit of increasing tolerance (MaxTolerance)";
2092 status = ShapeExtend_FAIL3;
2093 if(sfw->StatusSelfIntersection(status))
2094 di << "\n ShapeExtend_FAIL3 : intercestion of non adjacent edges found, but not fixed because of limit of increasing tolerance (MaxTolerance)";
2096 status = ShapeExtend_DONE1;
2097 if(sfw->StatusSelfIntersection(status))
2098 di << "\n ShapeExtend_DONE1 : tolerance of vertex was increased to fix self-intersection";
2100 status = ShapeExtend_DONE2;
2101 if(sfw->StatusSelfIntersection(status))
2102 di << "\n ShapeExtend_DONE2 : vertex was moved to fix self-intersection";
2104 status = ShapeExtend_DONE3;
2105 if(sfw->StatusSelfIntersection(status))
2106 di << "\n ShapeExtend_DONE3 : some edges were removed because of intersection";
2108 status = ShapeExtend_DONE4;
2109 if(sfw->StatusSelfIntersection(status))
2110 di << "\n ShapeExtend_DONE4 : pcurve(s) was(were) modified";
2112 status = ShapeExtend_DONE5;
2113 if(sfw->StatusSelfIntersection(status))
2114 di << "\n ShapeExtend_DONE5 : non adjacent intersection fixed by increasing tolerance of vertex(vertices)";
2116 status = ShapeExtend_DONE6;
2117 if(sfw->StatusSelfIntersection(status))
2118 di << "\n ShapeExtend_DONE6 : tolerance of edge was increased to hide intersection";
2120 status = ShapeExtend_DONE7;
2121 if(sfw->StatusSelfIntersection(status))
2122 di << "\n ShapeExtend_DONE7 : range of some edges was decreased to avoid intersection";
2124 TopoDS_Wire finalwire = sfw->Wire();
2126 DBRep::Set(argv[1],finalwire);
2129 advWA->Load(TopoDS::Wire(finalwire));
2132 BRepBuilderAPI_MakeFace(TopoDS::Wire(finalwire),Standard_True);
2134 DBRep::Set(argv[2],fface);
2136 advWA->SetFace(fface);
2138 TopTools_IndexedMapOfShape fM;
2139 TopExp::MapShapes(finalwire, TopAbs_EDGE, fM);
2141 for(j= 1; j<=fM.Extent(); ++j) {
2142 Standard_Integer num=1;
2143 IntRes2d_SequenceOfIntersectionPoint points2d;
2144 TColgp_SequenceOfPnt points3d;
2146 di << "\n j =" << j << ", CheckSelfIntersectingEdge = " <<
2147 (Standard_Integer) advWA->CheckSelfIntersectingEdge(j, points2d, points3d);
2150 ShapeExtend_Status status = ShapeExtend_FAIL1;
2151 if(advWA->StatusSelfIntersection(status))
2153 status = ShapeExtend_FAIL2;
2154 if(advWA->StatusSelfIntersection(status))
2155 di << "\n No Vertices found in the edge";
2157 status = ShapeExtend_DONE1;
2158 if(advWA->StatusSelfIntersection(status))
2159 di << "\n Self-intersection found in the edge";
2161 num = points2d.Length();
2162 di << "\n No. of self-intersecting edges : " << num;
2164 for(int i=1; i<=num; ++i) {
2165 gp_Pnt pt = points3d(i);
2166 di << "\n Intersecting pt : (" << pt.X() << ", " << pt.Y() << ", " << pt.Z() << ")";
2176 Standard_Integer OCC17480(Draw_Interpretor& di, Standard_Integer n, const char ** a)
2179 cout << "Usage: OCC17480 basic_shape <mode[0:1]>" <<endl;
2183 TopoDS_Shape brep_pipe = DBRep::Get(a[1]);
2185 Standard_Boolean mode = Standard_False;
2186 if(n == 3 && atoi(a[2]) == 1)
2187 mode = Standard_True;
2189 Handle_AIS_Shape ais_pipe = new AIS_Shape( brep_pipe );
2190 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
2191 Handle(AIS2D_InteractiveContext) aContext_2d = Viewer2dTest::GetAIS2DContext();
2193 if(!aContext.IsNull())
2194 aContext->Display(ais_pipe);
2196 if(!aContext_2d.IsNull())
2197 aContext_2d->EraseAll(Standard_True);
2199 gp_Ax3 ax3(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1), gp_Dir(0, 1, 0));
2201 gp_Ax2 ax2 = ax3.Ax2();
2203 HLRAlgo_Projector aProjector = HLRAlgo_Projector(ax2);
2204 Handle_AIS2D_ProjShape myDisplayableShape =
2205 new AIS2D_ProjShape(aProjector, 0, mode, Standard_True);
2207 myDisplayableShape->Add( brep_pipe );
2209 di << "\n Total number of primitives : " << myDisplayableShape->Length();
2211 Handle(Graphic2d_Line) mySectProjLines = myDisplayableShape->GetPrimitives();
2212 Handle(Graphic2d_Line) mySectProjLinesHLR = myDisplayableShape->GetHLPrimitives();
2214 Handle_Standard_Type sty = mySectProjLines->DynamicType();
2215 Handle_Standard_Type sty1 = mySectProjLinesHLR->DynamicType();
2217 di << "\n Class Name = " << (char*)sty->Name();
2218 di << "\n HLR Class Name = " << (char*)sty1->Name();
2219 di << "\n mySectProjLines.IsNull = " << (Standard_Integer) mySectProjLines.IsNull();
2220 di << "\n mySectProjLinesHLR.IsNull = " << (Standard_Integer) mySectProjLinesHLR.IsNull();
2222 Handle(GGraphic2d_SetOfCurves) setCurves;
2223 Handle(Graphic2d_SetOfSegments) setSegments;
2225 if(mySectProjLines->IsKind(STANDARD_TYPE(GGraphic2d_SetOfCurves)))
2227 setCurves = Handle(GGraphic2d_SetOfCurves)::DownCast(mySectProjLines);
2228 di << "\n Number of Curves in set = " << setCurves->Length();
2230 if(mySectProjLines->IsKind(STANDARD_TYPE(Graphic2d_SetOfSegments)))
2232 setSegments = Handle(Graphic2d_SetOfSegments)::DownCast(mySectProjLines);
2233 di << "\n Number of Curves in set = " << setSegments->Length();
2236 Handle(GGraphic2d_SetOfCurves) setCurvesHLR;
2237 Handle(Graphic2d_SetOfSegments) setSegmentsHLR;
2239 if(mySectProjLinesHLR->IsKind(STANDARD_TYPE(GGraphic2d_SetOfCurves)))
2241 setCurvesHLR = Handle(GGraphic2d_SetOfCurves)::DownCast(mySectProjLinesHLR);
2242 di << "\n HLR Number of Curves in set = " << setCurvesHLR->Length();
2244 if(mySectProjLinesHLR->IsKind(STANDARD_TYPE(Graphic2d_SetOfSegments)))
2246 setSegmentsHLR = Handle(Graphic2d_SetOfSegments)::DownCast(mySectProjLinesHLR);
2247 di << "\n HLR Number of Curves in set = " << setSegmentsHLR->Length();
2250 aContext_2d->Display( myDisplayableShape,Standard_True );
2254 void QABugs::Commands_17(Draw_Interpretor& theCommands) {
2255 const char *group = "QABugs";
2257 theCommands.Add ("BUC60842", "BUC60842", __FILE__, BUC60842, group);
2258 theCommands.Add ("BUC60843", "BUC60843 result_shape name_of_circle name_of_curve [ par1 [ tol ] ]", __FILE__, BUC60843, group);
2259 theCommands.Add ("BUC60970", "BUC60970 shape result", __FILE__, BUC60970, group);
2260 theCommands.Add ("BUC60818", "BUC60818", __FILE__, BUC60818, group);
2261 theCommands.Add ("BUC60915", "BUC60915", __FILE__, BUC60915_1, group);
2262 theCommands.Add ("OCC138", "OCC138", __FILE__, OCC138, group);
2263 theCommands.Add ("BUC60821","BUC60821",__FILE__,BUC60821,group);
2264 theCommands.Add ("OCC353","OCC353",__FILE__,OCC353,group);
2265 theCommands.Add ("OCC280","OCC280 hlr=0/1 setsurfecedetail=0/1; set perspecrive view",__FILE__,OCC280,group);
2266 theCommands.Add ("OCC232", "OCC232", __FILE__, OCC232 , group);
2267 theCommands.Add ("OCC138LC", "OCC138LC", __FILE__, OCC138LC, group);
2268 theCommands.Add ("OCC189", "OCC189", __FILE__, OCC189, group);
2269 theCommands.Add ("OCC389", "OCC389 name shape1 [shape2] ...", __FILE__, OCC389, group);
2271 theCommands.Add ("OCC566", "OCC566 shape [ xmin ymin zmin xmax ymax zmax] ; print bounding box", __FILE__, OCC566, group);
2272 theCommands.Add ("OCC570", "OCC570 result", __FILE__, OCC570, group);
2274 theCommands.Add("OCC570mkevol",
2275 "OCC570mkevol result object (then use updatevol) [R/Q/P]; mkevol",
2276 __FILE__, MKEVOL,group);
2277 theCommands.Add("OCC570updatevol",
2278 "OCC570updatevol edge u1 rad1 u2 rad2 ...; updatevol",
2279 __FILE__, UPDATEVOL,group);
2280 theCommands.Add("OCC570updatevollaw",
2281 "OCC570updatevollaw edge u1 rad1 u2 rad2 ...; updatevollaw",
2282 __FILE__, UPDATEVOL,group);
2283 theCommands.Add("OCC570buildevol",
2284 "OCC570buildevol; end of the evol fillet computation",
2285 __FILE__, BUILDEVOL,group);
2287 theCommands.Add ("OCC606", "OCC606 result shape [-t]", __FILE__, OCC606, group);
2289 theCommands.Add ("OCC813", "OCC813 U V", __FILE__, OCC813, group);
2290 theCommands.Add ("OCC814", "OCC814", __FILE__, OCC814, group);
2291 theCommands.Add ("OCC884", "OCC884 result shape [toler [maxtoler]]", __FILE__, OCC884, group);
2292 theCommands.Add ("OCC1188", "OCC1188 imagefile [filltype] : Load image as background", __FILE__, OCC1188, group);
2294 theCommands.Add ("OCC1174_1", "OCC1174_1 shape", __FILE__, OCC1174_1, group);
2295 theCommands.Add ("OCC1174_2", "OCC1174_2 shape", __FILE__, OCC1174_2, group);
2297 theCommands.Add("OCC672_Length"," OCC672_Length x1 y1 x2 y2 str scale_text length_dist angle_arrow length_arrow x3 y3 x4 y4 textAngle textPosH textPosV",__FILE__,OCC672_Length,group);
2298 theCommands.Add("OCC672_Angle","OCC672_Angle x1 y1 x2 y2 x3 y3 aRadius aText aTxtScale anArrAngle anArrLength txtAngle txtPosH txtPosV",__FILE__,OCC672_Angle,group);
2299 theCommands.Add("OCC672_Diameter","OCC672_Diameter x1 y1 cx cy radius aText aTxtScale anArrAngle anArrLength txtAngle txtPosH txtPosV",__FILE__,OCC672_Diameter,group);
2300 theCommands.Add("OCC672_ShortLength","",__FILE__,OCC672_ShortLength,group);
2302 theCommands.Add ("OCCN1", "OCCN1 angle fuse(1 for boss / 0 for slot) length", __FILE__, OCCN1, group);
2303 theCommands.Add ("OCCN2", "OCCN2", __FILE__, OCCN2, group);
2305 theCommands.Add ("OCC2569", "OCC2569 nbpoles result", __FILE__, OCC2569, group);
2307 theCommands.Add ("OCC1642", "OCC1642 FinalWare FinalFace InitWare InitFace shape FixReorder FixDegenerated FixConnected FixSelfIntersection", __FILE__, OCC1642, group);
2309 theCommands.Add ("OCC17480", "OCC17480 Shape", __FILE__, OCC17480, group);