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
28 #include <QATelco.hxx>
30 #include <Draw_Interpretor.hxx>
32 #include <DrawTrSurf.hxx>
33 #include <AIS_InteractiveContext.hxx>
34 #include <ViewerTest.hxx>
35 #include <AIS_Shape.hxx>
36 #include <TopoDS_Shape.hxx>
38 #include <Geom_Circle.hxx>
39 #include <Geom_Ellipse.hxx>
40 #include <Geom_Plane.hxx>
42 #include <Geom2d_Curve.hxx>
43 #include <GeomAPI.hxx>
44 #include <Geom2dAdaptor_Curve.hxx>
45 #include <Geom2dGcc_QualifiedCurve.hxx>
46 #include <Geom2dGcc_Lin2d2Tan.hxx>
47 #include <Geom2d_Line.hxx>
48 #include <BRepBuilderAPI_MakeEdge.hxx>
49 #include <TopoDS_Edge.hxx>
50 #include <Precision.hxx>
51 #include <Geom2d_Circle.hxx>
52 #include <Geom2dGcc_MyQCurve.hxx>
53 #include <GccEnt_QualifiedCirc.hxx>
54 #include <Geom2dGcc_MyL2d2Tan.hxx>
55 #include <BRepBuilderAPI_MakeWire.hxx>
56 #include <TopExp_Explorer.hxx>
58 #include <TopoDS_Wire.hxx>
59 #include <BRep_Tool.hxx>
60 #include <gp_Circ.hxx>
61 #include <BRepOffsetAPI_MakePipeShell.hxx>
62 #include <AIS_Trihedron.hxx>
63 #include <Geom_Axis2Placement.hxx>
64 #include <V3d_View.hxx>
65 #include <ViewerTest_Tool.hxx>
66 #include <BRepBuilderAPI_MakeVertex.hxx>
67 #include <AIS_LengthDimension.hxx>
68 #include <AIS_RadiusDimension.hxx>
69 #include <BRepPrimAPI_MakeBox.hxx>
70 #include <GeomAdaptor_Surface.hxx>
71 #include <Extrema_ExtPS.hxx>
72 #include <Geom_CartesianPoint.hxx>
73 #include <Geom2d_CartesianPoint.hxx>
74 #include <Geom2dGcc_Circ2d3Tan.hxx>
75 #include <Aspect_Window.hxx>
77 #include <TopoDS_Compound.hxx>
78 #include <TopoDS_CompSolid.hxx>
79 #include <StdSelect_ShapeTypeFilter.hxx>
81 #include <QATelco_MyText.hxx>
84 #include <QAViewer2dTest.hxx>
85 #include <QAViewer2dTest_DoubleMapOfInteractiveAndName.hxx>
87 #include <Viewer2dTest.hxx>
88 #include <Viewer2dTest_DoubleMapOfInteractiveAndName.hxx>
91 #include <Prs3d_Projector.hxx>
92 #include <HLRAlgo_Projector.hxx>
93 #include <AIS2D_ProjShape.hxx>
94 #include <AIS2D_InteractiveContext.hxx>
95 #include <Standard_ErrorHandler.hxx>
99 extern QAViewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D();
101 extern Viewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D();
104 Standard_EXPORT Viewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D();
107 #include <GGraphic2d_SetOfCurves.hxx>
108 #include <Graphic2d_SetOfSegments.hxx>
110 #include <Graphic3d_NameOfFont.hxx>
112 static Standard_Integer BUC60842 (Draw_Interpretor& di, Standard_Integer /*argc*/,const char ** /*argv*/)
114 Standard_Character abuf[16];
115 //Standard_Character * abuf = new Standard_Character[16];
117 Standard_CString st = abuf;
119 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);
120 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);
121 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))));
123 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
125 gp_Pln pln = plne->Pln();
126 Handle(Geom2d_Curve) curve2d = GeomAPI::To2d (ell, pln);
128 DrawTrSurf::Set(st,curve2d);
129 if(!aContext.IsNull()) {
130 Handle(AIS_Shape) aisp =
131 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(curve2d, pln)).Edge());
132 aContext->Display (aisp);
135 Handle(Geom2d_Curve) fromcurve2d = GeomAPI::To2d (cir, pln);
137 DrawTrSurf::Set(st,fromcurve2d);
138 if(!aContext.IsNull()) {
139 Handle(AIS_Shape) aisp =
140 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(fromcurve2d, pln)).Edge());
141 aContext->Display (aisp);
144 Geom2dAdaptor_Curve acur (curve2d), afromcur (fromcurve2d);
145 Geom2dGcc_QualifiedCurve qcur (acur, GccEnt_outside);
146 Geom2dGcc_QualifiedCurve qfromcur (afromcur, GccEnt_outside);
147 Geom2dGcc_Lin2d2Tan lintan (qcur, qfromcur, 0.1, 0.0, 0.0);
148 Standard_Integer i=0;
149 for(i=0;i<lintan.NbSolutions();i++) {
150 sprintf(abuf,"lintan_%d",i);
151 Handle(Geom2d_Line) glin = new Geom2d_Line(lintan.ThisSolution(i));
152 DrawTrSurf::Set(st,glin);
153 if(!aContext.IsNull()) {
154 Handle(AIS_Shape) aisp =
155 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(glin, pln)).Edge()); aContext->Display (aisp);
158 di << " Is Done = \n" << (Standard_Integer) lintan.IsDone();
162 static Standard_Integer BUC60843 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
164 if (argc != 4 && argc != 5 && argc != 6 && argc != 7) {
165 di << "Usage : " << argv[0] << "result_shape name_of_circle name_of_curve [ par1 [ tol ] ]" << "\n";
169 Standard_Real par1 = 0.0, par2 = 0.0;
170 Standard_Real tol = Precision::Angular();
172 par1 = atof(argv[4]);
174 par2 = atof(argv[5]);
177 Handle(Geom2d_Curve) aCur2d1 = DrawTrSurf::GetCurve2d(argv[2]);
178 Handle(Geom2d_Curve) aCur2d2 = DrawTrSurf::GetCurve2d(argv[3]);
179 if (aCur2d1.IsNull() || aCur2d2.IsNull()) {
180 di << "Faulty : not curves" << "\n";
183 Standard_Boolean c1IsCircle = Standard_False;
184 Handle(Geom2d_Circle) aCir2d = Handle(Geom2d_Circle)::DownCast(aCur2d1);
185 if (!aCir2d.IsNull()) {
186 c1IsCircle = Standard_True;
187 if (argc == 6) tol = atof(argv[5]);
190 Geom2dAdaptor_Curve acur(aCur2d2);
191 Geom2dGcc_MyQCurve qcur(acur, GccEnt_unqualified);
192 GccEnt_QualifiedCirc qfromcur(aCir2d->Circ2d(), GccEnt_unqualified);
193 Geom2dGcc_MyL2d2Tan lintan(qfromcur, qcur , par1, tol);
194 if (lintan.IsDone()) {
195 gp_Lin2d lin = lintan.ThisSolution();
196 Handle(Geom2d_Line) glin = new Geom2d_Line(lin);
197 DrawTrSurf::Set(argv[1], glin);
199 di << "Faulty : tangent line is not done." << "\n";
203 Geom2dAdaptor_Curve acur1(aCur2d1);
204 Geom2dAdaptor_Curve acur2(aCur2d2);
205 Geom2dGcc_MyQCurve qcur1(acur1, GccEnt_unqualified);
206 Geom2dGcc_MyQCurve qcur2(acur2, GccEnt_unqualified);
207 Geom2dGcc_MyL2d2Tan lintan(qcur1, qcur2 , par1, par2, tol);
208 if (lintan.IsDone()) {
209 gp_Lin2d lin = lintan.ThisSolution();
210 Handle(Geom2d_Line) glin = new Geom2d_Line(lin);
211 DrawTrSurf::Set(argv[1], glin);
213 di << "Faulty : tangent line is not done." << "\n";
219 static Standard_Integer BUC60970 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
223 di << "Usage : " << argv[0] << " shape result" <<"\n";
227 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
228 if(aContext.IsNull()) {
229 di << "use 'vinit' command before " << argv[0] << "\n";
233 TopoDS_Shape aResult = DBRep::Get(argv[1]);
235 BRepBuilderAPI_MakeWire bRepSpineWire;
236 TopExp_Explorer exp_(aResult, TopAbs_WIRE);
238 Standard_Integer i = 0;
239 for(;exp_.More();exp_.Next()){
241 bRepSpineWire.Add(TopoDS::Wire(exp_.Current()));
244 //printf("total no of wires are ............. %d\n", i);
245 di << "total no of wires are ............. " << i << "\n";
247 TopoDS_Wire spineWire = bRepSpineWire.Wire();
248 aContext->Display(new AIS_Shape(spineWire));
250 DBRep::Set("slineW",spineWire);
252 TopExp_Explorer spineWireExp(spineWire, TopAbs_EDGE);
253 Standard_Real first, last;
254 Handle_Geom_Curve curl_ = BRep_Tool::Curve(TopoDS::Edge(spineWireExp.Current()), first, last);
257 curl_->D1(first, firstPnt, tanVec);
259 gp_Dir tanDir(tanVec.X(), tanVec.Y(), tanVec.Z());
260 gp_Ax2 gpAx2(firstPnt, tanDir);
261 gp_Circ gpCirc(gpAx2, 2.5);
262 BRepBuilderAPI_MakeWire aMWire(BRepBuilderAPI_MakeEdge(new Geom_Circle(gpCirc)).Edge());
263 TopoDS_Wire topoWire(aMWire);
264 aContext->Display(new AIS_Shape(topoWire));
266 DBRep::Set("topoW",topoWire);
268 BRepOffsetAPI_MakePipeShell bRepPipe(spineWire);
269 bRepPipe.Add(topoWire);
272 aContext->Display(new AIS_Shape(bRepPipe.Shape()));
274 DBRep::Set(argv[2],bRepPipe.Shape());
279 static Standard_Integer BUC60818(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
283 di << "Usage : " << argv[0] << "\n";
287 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
288 if(myAISContext.IsNull())
290 di << "use 'vinit' command before " << argv[0] << "\n";
295 Handle(AIS_Trihedron) aTrihedron;
296 Handle(Geom_Axis2Placement) aTrihedronAxis=new Geom_Axis2Placement(gp::XOY());
297 aTrihedron=new AIS_Trihedron(aTrihedronAxis);
298 myAISContext->Display(aTrihedron);
300 myAISContext->OpenLocalContext();
301 myAISContext->Load(aTrihedron,0);
303 myAISContext->SetAutomaticHilight( Standard_False );
305 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
307 myV3dView->Project(0,0,0,Xv,Yv);
309 Standard_Integer Xp,Yp;
310 myV3dView->Convert(Xv,Yv,Xp,Yp);
312 myAISContext->MoveTo( Xp,Yp, myV3dView );
313 myAISContext->MoveTo( Xp,Yp, myV3dView );
315 if (myAISContext->HasDetected( ))
316 di << "has detected shape : OK" << "\n";
317 else di << "has detected shape : bugged - Faulty " << "\n";
319 myAISContext->SetAutomaticHilight( Standard_True );
324 static Standard_Integer BUC60915_1(Draw_Interpretor& di, Standard_Integer argc, const char ** /*argv*/)
327 di<<"Function don't has parameters"<<"\n";
331 Handle(AIS_InteractiveContext) context= ViewerTest_Tool::MakeContext ("buc60915");
332 ViewerTest_Tool::InitViewerTest (context);
334 //The following dimesion code has problems regarding arrow_size. The desired effect is not produced.
335 /***************************************/
337 /***************************************/
338 gp_Pnt p1 = gp_Pnt(602.51,50.,0.);
339 gp_Pnt p2 = gp_Pnt(602.51,200.,0.);
340 gp_Pnt p3 = gp_Pnt(102.51,200.,0.);
341 gp_Pnt p4 = gp_Pnt(102.51,170.,0.);
342 gp_Pnt p5 = gp_Pnt(502.51,170.,0.);
343 gp_Pnt p6 = gp_Pnt(502.51,80.,0.);
344 gp_Pnt p7 = gp_Pnt(102.51,80.,0.);
345 gp_Pnt p8 = gp_Pnt(102.51,50.,0.);
346 TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(p1);
347 TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(p2);
348 TopoDS_Vertex V3 = BRepBuilderAPI_MakeVertex(p3);
349 TopoDS_Vertex V4 = BRepBuilderAPI_MakeVertex(p4);
350 TopoDS_Vertex V5 = BRepBuilderAPI_MakeVertex(p5);
351 TopoDS_Vertex V6 = BRepBuilderAPI_MakeVertex(p6);
352 TopoDS_Vertex V7 = BRepBuilderAPI_MakeVertex(p7);
353 TopoDS_Vertex V8 = BRepBuilderAPI_MakeVertex(p8);
354 gp_Pnt plnpt(0, 0, 0);
355 gp_Dir plndir(0, 0, 1);
356 Handle(Geom_Plane) pln = new Geom_Plane(plnpt,plndir);
357 /***************************************/
358 //dimension "L 502.51"
359 /***************************************/
360 Handle(AIS_LengthDimension) len = new AIS_LengthDimension(V2, V3, pln, 502.51, "502.51");
361 len->SetPosition(gp_Pnt(350, 250, 0));
362 len->SetTypeOfDist(AIS_TOD_Horizontal);
363 len->SetArrowSize(30.0);
364 context->Display(len);
365 /***************************************/
367 /***************************************/
368 Handle(AIS_LengthDimension) len1 = new AIS_LengthDimension(V4, V7, pln, 90, "90");
369 len1->SetPosition(gp_Pnt(70, 120, 0));
370 len1->SetTypeOfDist(AIS_TOD_Vertical);
371 len1->SetArrowSize(100.0);
372 context->Display(len1);
373 /***************************************/
375 /***************************************/
376 Handle(AIS_LengthDimension) len2 = new AIS_LengthDimension(V1, V2, pln, 150, "150",gp_Pnt(650, 120, 0),DsgPrs_AS_BOTHAR,
377 AIS_TOD_Vertical, 100.0 );
378 //len2->SetPosition(gp_Pnt(650, 120, 0));
379 //len2->SetTypeOfDist(AIS_TOD_Vertical);
380 //len1->SetArrowSize(100.0);
381 context->Display(len2);
382 /***************************************/
383 //dimension "R 88.58"
384 /***************************************/
385 gp_Circ cir = gp_Circ(gp_Ax2(gp_Pnt(191.09, -88.58, 0), gp_Dir(0, 0, 1)), 88.58);
386 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(cir,gp_Pnt(191.09,0,0.),gp_Pnt(191.09,-177.16,0.) );
387 Handle(AIS_RadiusDimension) dim1 = new AIS_RadiusDimension(E1,88.58, "R 88.58",gp_Pnt(-30.0, -80.0, 0.0),DsgPrs_AS_BOTHAR,
389 context->Display(dim1);
390 /***************************************/
391 //dimension "R 43.80"
392 /***************************************/
393 gp_Circ cir1 = gp_Circ(gp_Ax2(gp_Pnt(191.09, -88.58, 0), gp_Dir(0, 0, 1)), 43.80);
394 TopoDS_Edge E_cir1 = BRepBuilderAPI_MakeEdge(cir1);
395 dim1 = new AIS_RadiusDimension(E_cir1,43.80, "R 43.80",gp_Pnt(0.0, -50.0, 0.0),DsgPrs_AS_LASTAR, 60.0 );
396 context->Display(dim1);
397 /***************************************/
398 //dimension "R 17.86"
399 /***************************************/
400 gp_Circ cir2 = gp_Circ(gp_Ax2(gp_Pnt(566.11, -88.58, 0), gp_Dir(0, 0, -1)), 17.86);
401 TopoDS_Edge E_cir2 = BRepBuilderAPI_MakeEdge(cir2);
402 dim1 = new AIS_RadiusDimension(E_cir2,17.86, "R 17.86",gp_Pnt(600.0, -50.0, 0.0),DsgPrs_AS_LASTAR, 40.0 );
403 context->Display(dim1);
408 static Standard_Integer OCC138 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
410 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
411 if(aContext.IsNull()) {
412 di << "use 'vinit' command before " << argv[0] << "\n";
416 BRepPrimAPI_MakeBox box1(gp_Pnt(0, 0, 0), gp_Pnt(100, 100, 100));
417 BRepPrimAPI_MakeBox box2(gp_Pnt(120, 120, 120), gp_Pnt(300, 300,300));
418 BRepPrimAPI_MakeBox box3(gp_Pnt(320, 320, 320), gp_Pnt(500, 500,500));
420 Handle_AIS_Shape ais1 = new AIS_Shape(box1.Shape());
421 Handle_AIS_Shape ais2 = new AIS_Shape(box2.Shape());
422 Handle_AIS_Shape ais3 = new AIS_Shape(box3.Shape());
424 aContext->Display(ais1);
425 aContext->Display(ais2);
426 aContext->Display(ais3);
428 aContext->AddOrRemoveCurrentObject(ais1);
429 aContext->AddOrRemoveCurrentObject(ais2);
430 aContext->AddOrRemoveCurrentObject(ais3);
432 di << "\n No of currents = " << aContext->NbCurrents();
434 aContext->InitCurrent();
437 while(aContext->MoreCurrent())
439 di << "\n count is = " << count++;
440 Handle_AIS_InteractiveObject ais = aContext->Current();
441 aContext->AddOrRemoveCurrentObject(ais);
442 aContext->InitCurrent();
448 static Standard_Integer BUC60821(Draw_Interpretor& di, Standard_Integer argc,const char ** argv )
452 di << "Usage: " << argv[0] << " TextHight1 TextHight2 TextHight2";
456 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
458 if(aContext.IsNull())
460 di << "use 'vinit' command before " << argv[0] << "\n";
464 Handle(QATelco_MyText) txt1 = new QATelco_MyText("Gosha1",gp_Pnt(0,0,0),Graphic3d_NOF_ASCII_SIMPLEX,Quantity_NOC_RED,atoi(argv[1]));
465 aContext->Display(txt1);
467 Handle(QATelco_MyText) txt2 = new QATelco_MyText("Gosha2",gp_Pnt(0,0,100),Graphic3d_NOF_ASCII_SIMPLEX,Quantity_NOC_YELLOW,atoi(argv[2]));
468 aContext->Display(txt2);
470 Handle(QATelco_MyText) txt3 = new QATelco_MyText("Gosha3",gp_Pnt(0,100,100),Graphic3d_NOF_ASCII_SIMPLEX,Quantity_NOC_SKYBLUE,atoi(argv[3]));
471 aContext->Display(txt3);
476 static int geom_get_2Dpt_from_3Dpt(const gp_Pnt& pnt3d, const gp_Pln& pln, gp_Pnt2d& pnt2d)
479 Handle_Geom_Plane gpln = new Geom_Plane(pln);
480 GeomAdaptor_Surface adsur(gpln);
481 Extrema_ExtPS extps(pnt3d, adsur, 0.001, 0.001);
485 for(index=1; index<= extps.NbExt(); index++ )
487 Extrema_POnSurf pons = extps.Point(index);
489 pons.Parameter(U, V);
490 pnt2d.SetCoord(U, V);
497 static Standard_Integer OCC353 (Draw_Interpretor& di, Standard_Integer , const char ** )
499 gp_Ax2 ax21( gp_Pnt(100,0,0), gp_Dir(0,0,1) );
500 Handle_Geom_Circle h_cir1 = new Geom_Circle( ax21, 25 );
502 gp_Ax2 ax22( gp_Pnt(-100,0,0), gp_Dir(0,0,1) );
503 Handle_Geom_Circle h_cir2 = new Geom_Circle( ax22, 25 );
505 gp_Pln refpln( gp_Pnt(0,0,0), gp_Dir(0,0,1) );
506 Handle_Geom2d_Curve cir2d1 = GeomAPI::To2d(h_cir1, refpln);
507 Handle_Geom2d_Curve cir2d2 = GeomAPI::To2d(h_cir2, refpln);
509 Geom2dAdaptor_Curve adop1(cir2d1);
510 Geom2dAdaptor_Curve adop2(cir2d2);
512 Geom2dGcc_QualifiedCurve qcur1(adop1, GccEnt_enclosing);
513 Geom2dGcc_QualifiedCurve qcur2(adop2, GccEnt_enclosing);
515 Handle_Geom_CartesianPoint h_carpt = new Geom_CartesianPoint(0,175,0);
517 gp_Pnt pt3d = h_carpt->Pnt();
519 geom_get_2Dpt_from_3Dpt(pt3d, refpln, pt2d);
523 DrawTrSurf::Set(st,cir2d1);
525 DrawTrSurf::Set(st,cir2d2);
527 DrawTrSurf::Set(st,pt2d);
529 Handle_Geom2d_CartesianPoint pt = new Geom2d_CartesianPoint(pt2d);
530 Geom2dGcc_Circ2d3Tan sol( qcur1, qcur2, pt, 0.001, 0.0, 0.0);
533 Standard_Character buf[10];
537 res = sol.NbSolutions();
538 for(Standard_Integer i=1;i<=res;i++) {
539 Handle(Geom2d_Circle) aC = new Geom2d_Circle(sol.ThisSolution(i));
540 sprintf(buf,"Result_%d",i);
542 DrawTrSurf::Set(st,aC);
546 di << "\n Faulty: no solutions found ";
547 //printf("\n Faulty: no solutions found ");
549 //printf("\n Num of solutions are %d ", res );
550 di << "\n Num of solutions are " << res << " ";
555 static Standard_Integer OCC280 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
557 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
558 if(aContext.IsNull())
560 di << "use 'vinit' command before " << argv[0] << "\n";
564 di << "ERROR : Usage : " << argv[0] << " hlr=0/1 setsurfecedetail=0/1; set perspecrive view" << "\n";
568 Standard_Integer HLR = atoi(argv[1]);
573 Handle(V3d_View) aView = ViewerTest::CurrentView();
575 Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
577 aViewer->SetDefaultSurfaceDetail(V3d_TEX_ALL);
579 aViewer->SetDefaultTypeOfView(V3d_PERSPECTIVE);
581 Handle(Aspect_Window) asp = aView->Window();
582 aViewer->SetViewOff(aView);
585 Handle(V3d_View) aNewView = aViewer->CreateView();
586 ViewerTest::CurrentView(aNewView);
588 aNewView->SetWindow(asp);
589 if (!asp->IsMapped()) asp->Map();
595 aNewView->SetDegenerateModeOff();
601 static Standard_Integer OCC232 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
603 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
604 if(aContext.IsNull()) {
605 di << "use 'vinit' command before " << argv[0] << "\n";
609 BRep_Builder builder;
610 TopoDS_Compound comp;
611 TopoDS_CompSolid cs1, cs2;
613 builder.MakeCompound(comp);
614 builder.MakeCompSolid(cs1);
615 builder.MakeCompSolid(cs2);
617 TopoDS_Shape sh1 = BRepPrimAPI_MakeBox(gp_Pnt(0, 0, 0), 100, 100, 100).Shape();
618 TopoDS_Shape sh2 = BRepPrimAPI_MakeBox(gp_Pnt(100, 0, 0), 100, 100, 100).Shape();
619 TopoDS_Shape sh3 = BRepPrimAPI_MakeBox(gp_Pnt(200, 0, 0), 100, 100, 100).Shape();
620 builder.Add(cs1, sh1);
621 builder.Add(cs1, sh2);
622 builder.Add(cs1, sh3);
624 TopoDS_Shape sh4 = BRepPrimAPI_MakeBox(gp_Pnt(0, 500, 0), 100, 100, 100).Shape();
625 TopoDS_Shape sh5 = BRepPrimAPI_MakeBox(gp_Pnt(100, 500, 0), 100, 100, 100).Shape();
626 TopoDS_Shape sh6 = BRepPrimAPI_MakeBox(gp_Pnt(200, 500, 0), 100, 100, 100).Shape();
628 builder.Add(cs2, sh4);
629 builder.Add(cs2, sh5);
630 builder.Add(cs2, sh6);
632 builder.Add(comp, cs1);
633 builder.Add(comp, cs2);
635 Handle_AIS_Shape ais = new AIS_Shape(comp);
636 aContext->Display(ais);
638 TopExp_Explorer exp(comp, TopAbs_COMPSOLID);
641 //printf("\n TopAbs_COMPSOLID is there \n");
642 di << "\n TopAbs_COMPSOLID is there \n";
646 Handle (StdSelect_ShapeTypeFilter) filt = new StdSelect_ShapeTypeFilter(TopAbs_COMPSOLID);
647 aContext->AddFilter(filt);
648 aContext->CloseAllContexts();
649 aContext->OpenLocalContext();
650 aContext->ActivateStandardMode(TopAbs_SOLID);
655 static Standard_Integer OCC138LC (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
657 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
658 if(aContext.IsNull()) {
659 di << "use 'vinit' command before " << argv[0] << "\n";
663 BRepPrimAPI_MakeBox box1(gp_Pnt(0, 0, 0), gp_Pnt(100, 100, 100));
664 BRepPrimAPI_MakeBox box2(gp_Pnt(120, 120, 120), gp_Pnt(300, 300,300));
665 BRepPrimAPI_MakeBox box3(gp_Pnt(320, 320, 320), gp_Pnt(500, 500,500));
667 Handle_AIS_Shape ais1 = new AIS_Shape(box1.Shape());
668 Handle_AIS_Shape ais2 = new AIS_Shape(box2.Shape());
669 Handle_AIS_Shape ais3 = new AIS_Shape(box3.Shape());
671 aContext->Display(ais1);
672 aContext->Display(ais2);
673 aContext->Display(ais3);
675 aContext->AddOrRemoveSelected(ais1);
676 aContext->AddOrRemoveSelected(ais2);
677 aContext->AddOrRemoveSelected(ais3);
679 di << "\n No of selected = " << aContext->NbSelected();
681 aContext->InitSelected();
684 while(aContext->MoreSelected())
686 di << "\n count is = %d" << count++;
687 Handle_AIS_InteractiveObject ais = aContext->SelectedInteractive();
688 aContext->AddOrRemoveSelected(ais);
689 aContext->InitSelected();
695 static Standard_Integer OCC189 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
697 Handle(AIS_InteractiveContext) aContext1 = ViewerTest::GetAISContext();
698 if(aContext1.IsNull()) {
699 di << "use 'vinit' command before " << argv[0] << "\n";
702 Handle(AIS_InteractiveContext) aContext2 = ViewerTest::GetAISContext();
703 if(aContext2.IsNull()) {
704 di << "use 'vinit' command before " << argv[0] << "\n";
708 BRepPrimAPI_MakeBox box1(gp_Pnt(0, 0, 0), gp_Pnt(100, 100, 100));
709 BRepPrimAPI_MakeBox box2(gp_Pnt(120, 120, 120), gp_Pnt(300, 300, 300));
710 BRepPrimAPI_MakeBox box3(gp_Pnt(320, 320, 320), gp_Pnt(500, 500, 500));
712 Handle_AIS_Shape ais1 = new AIS_Shape(box1.Shape());
713 Handle_AIS_Shape ais2 = new AIS_Shape(box2.Shape());
714 Handle_AIS_Shape ais3 = new AIS_Shape(box3.Shape());
716 aContext1->Display(ais1);
717 aContext1->Display(ais2);
718 aContext1->Display(ais3);
720 aContext2->Display(ais1);
721 aContext2->Display(ais2);
722 aContext2->Display(ais3);
724 aContext1->AddOrRemoveCurrentObject(ais1);
725 aContext1->AddOrRemoveCurrentObject(ais2);
726 aContext1->AddOrRemoveCurrentObject(ais3);
728 di << "\n Stage : 1";
729 di << "\n \t No of currents on aContext1 = " << aContext1->NbCurrents();
730 di << "\n \t No of currents on aContext2 = " << aContext2->NbCurrents() << "\n\n";
732 di << "\n aContext1->IsCurrent = " << (Standard_Integer) aContext1->IsCurrent(ais1) << ", aContext2->IsCurrent = " << (Standard_Integer) aContext2->IsCurrent(ais1) << " ";
734 aContext2->AddOrRemoveCurrentObject(ais1);
735 aContext2->AddOrRemoveCurrentObject(ais2);
736 aContext2->AddOrRemoveCurrentObject(ais3);
738 di << "\n Stage : 2";
739 di << "\n \t No of currents on aContext1 = " << aContext1->NbCurrents();
740 di << "\n \t No of currents on aContext2 = " << aContext2->NbCurrents() << "\n\n";
742 aContext1->InitCurrent();
744 while(aContext1->MoreCurrent())
746 di << "\n count1 is = " << count1++;
747 Handle_AIS_InteractiveObject ais = aContext1->Current();
748 aContext1->AddOrRemoveCurrentObject(ais);
749 aContext1->InitCurrent();
752 di << "\n Stage : 3";
753 di << "\n \t No of currents on aContext1 = " << aContext1->NbCurrents();
754 di << "\n \t No of currents on aContext2 = " << aContext2->NbCurrents() << "\n\n";
756 aContext2->InitCurrent();
758 while(aContext2->MoreCurrent())
760 di << "\n count2 is = " << count2++;
761 Handle_AIS_InteractiveObject ais = aContext2->Current();
762 aContext2->AddOrRemoveCurrentObject(ais);
763 aContext2->InitCurrent();
766 di << "\n\n Stage : 4";
767 di << "\n \t No of currents on aContext1 = " << aContext1->NbCurrents();
768 di << "\n \t No of currents on aContext2 = " << aContext2->NbCurrents();
773 static Standard_Integer OCC389 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
777 di<<"Usage: " << argv[0] << " name shape1 [shape2] ..."<<"\n";
781 //if (Viewer2dTest::CurrentView().IsNull())
783 // cout << "2D AIS Viewer Initialization ..." << endl;
784 // Viewer2dTest::ViewerInit();
785 // cout << "Done" << endl;
789 Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
790 di<<"Check InteractiveContext"<<"\n";
792 if(aContext.IsNull()) {
793 di << "use 'v2dinit' command before " << argv[0] << "\n";
797 di<<"CloseLocalContext"<<"\n";
798 aContext->CloseLocalContext();
800 di<<"OpenLocalContext"<<"\n";
801 aContext->OpenLocalContext();
803 TCollection_AsciiString name(argv[1]);
805 di<<"Found name"<<"\n";
806 Standard_Boolean IsBound = GetMapOfAIS2D().IsBound2(name);
809 di<<"Already displayed"<<"\n";
811 else // Create the AIS2D_ProjShape from a name
813 di<<"Create the AIS2D_ProjShape from a name; (1)"<<"\n";
814 Prs3d_Projector aPrs3dProjector(Standard_False, 1, -1.0,0.2,0.3, 0.0, 0.0, 0.0, -0.0,0.0,1.0);
815 di<<"Create the AIS2D_ProjShape from a name; (2)"<<"\n";
816 HLRAlgo_Projector aProjector = aPrs3dProjector.Projector();
817 di<<"Create the AIS2D_ProjShape from a name; (3)"<<"\n";
818 Handle(AIS2D_ProjShape) shp_2d =
819 new AIS2D_ProjShape(aProjector, 0, Standard_False, Standard_True);
820 di<<"Create the AIS2D_ProjShape from a name; (4)"<<"\n";
823 Standard_Boolean isValid = Standard_False;
824 for (i = 2; i < argc; i++)
826 di<<"i="<< i-1 <<"\n";
827 TopoDS_Shape aShape = DBRep::Get(argv[i]);
828 if (!aShape.IsNull())
830 shp_2d->Add( aShape );
831 di<<"Added shape: "<<argv[i]<<"\n";
832 isValid = Standard_True;
838 di<<"Now start displaying..."<<"\n";
839 aContext->Display(shp_2d, 1, 1, Standard_True);
841 GetMapOfAIS2D().Bind(shp_2d, name);
845 aContext->UpdateCurrentViewer();
849 #include <BRepBndLib.hxx>
851 //=======================================================================
854 //=======================================================================
855 static Standard_Integer OCC566(Draw_Interpretor& di,Standard_Integer n,const char ** a)
858 di<<"Usage: " << a[0] << " shape [ xmin ymin zmin xmax ymax zmax]"<<"\n";
861 TopoDS_Shape S = DBRep::Get(a[1]);
862 if (S.IsNull()) return 1;
864 BRepBndLib::AddClose(S,B);
865 Standard_Real axmin,aymin,azmin,axmax,aymax,azmax;
866 B.Get(axmin,aymin,azmin,axmax,aymax,azmax);
867 di << axmin<<" "<< aymin<<" "<< azmin<<" "<< axmax<<" "<< aymax<<" "<< azmax;
869 Draw::Set(a[2],axmin) ;
870 Draw::Set(a[3],aymin) ;
871 Draw::Set(a[4],azmin) ;
872 Draw::Set(a[5],axmax) ;
873 Draw::Set(a[6],aymax) ;
874 Draw::Set(a[7],azmax) ;
879 #include <BRepFilletAPI_MakeFillet.hxx>
880 //=======================================================================
883 //=======================================================================
884 static Standard_Integer OCC570 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
887 di<<"Usage: " << argv[0] << " result"<<"\n";
891 BRepPrimAPI_MakeBox mkBox(100.,100.,100.);
892 TopoDS_Shape aBox = mkBox.Shape();
894 TopExp_Explorer aExp;
895 aExp.Init(aBox,TopAbs_WIRE);
898 TopoDS_Shape aWire = aExp.Current();
900 aExp.Init(aWire,TopAbs_EDGE);
901 TopoDS_Edge e1 = TopoDS::Edge(aExp.Current()); aExp.Next();
902 TopoDS_Edge e2 = TopoDS::Edge(aExp.Current()); aExp.Next();
903 TopoDS_Edge e3 = TopoDS::Edge(aExp.Current()); aExp.Next();
904 TopoDS_Edge e4 = TopoDS::Edge(aExp.Current());
909 BRepFilletAPI_MakeFillet mkFillet(aBox);
910 mkFillet.SetContinuity(GeomAbs_C1,.001);
912 // Setup variable fillet data
913 TColgp_Array1OfPnt2d t_pnt(1,4);
914 t_pnt.SetValue(1,gp_Pnt2d(0.0,5.0));
915 t_pnt.SetValue(2,gp_Pnt2d(0.3,15.0));
916 t_pnt.SetValue(3,gp_Pnt2d(0.7,15.0));
917 t_pnt.SetValue(4,gp_Pnt2d(1.0,5.0));
920 // It is impossible to build fillet if at least one edge
921 // with variable radius is added!!! If all are constant, everything is ok.
922 mkFillet.Add(t_pnt,e1);
923 mkFillet.Add(5.0,e2);
924 mkFillet.Add(t_pnt,e3);
925 mkFillet.Add(5.0,e4);
928 TopoDS_Shape aFinalShape = mkFillet.Shape();
930 DBRep::Set(argv[1],aFinalShape);
932 catch(Standard_Failure)
934 di << argv[0] << ": Exception in fillet"<<"\n";
942 #include <Law_Interpol.hxx>
944 static Standard_Real t3d = 1.e-4;
945 static Standard_Real t2d = 1.e-5;
946 static Standard_Real ta = 1.e-2;
947 static Standard_Real fl = 1.e-3;
948 static Standard_Real tapp_angle = 1.e-2;
949 static GeomAbs_Shape blend_cont = GeomAbs_C1;
951 static BRepFilletAPI_MakeFillet* Rakk = 0;
952 static BRepFilletAPI_MakeFillet* Rake = 0;
953 static char name[100];
955 static void printtolblend(Draw_Interpretor& di)
957 di<<"tolerance ang : "<<ta<<"\n";
958 di<<"tolerance 3d : "<<t3d<<"\n";
959 di<<"tolerance 2d : "<<t2d<<"\n";
960 di<<"fleche : "<<fl<<"\n";
962 di<<"tolblend "<<ta<<" "<<t3d<<" "<<t2d<<" "<<fl<<"\n";
965 static Standard_Integer MKEVOL(Draw_Interpretor& di,
966 Standard_Integer narg,
969 if(Rake != 0) {delete Rake; Rake = 0;}
971 if (narg < 3) return 1;
972 TopoDS_Shape V = DBRep::Get(a[2]);
973 Rake = new BRepFilletAPI_MakeFillet(V);
974 Rake->SetParams(ta,t3d,t2d,t3d,t2d,fl);
975 Rake->SetContinuity(blend_cont, tapp_angle);
977 ChFi3d_FilletShape FSh = ChFi3d_Rational;
978 if (!strcasecmp(a[3], "Q")) {
979 FSh = ChFi3d_QuasiAngular;
981 else if (!strcasecmp(a[3], "P")) {
982 FSh = ChFi3d_Polynomial;
984 Rake->SetFilletShape(FSh);
990 static Standard_Integer UPDATEVOL(Draw_Interpretor& di,
991 Standard_Integer narg,
995 di << "MakeFillet non initialise"<<"\n";
998 if(narg%2 != 0 || narg < 4) return 1;
999 TColgp_Array1OfPnt2d uandr(1,(narg/2)-1);
1000 Standard_Real Rad, Par;
1001 TopoDS_Shape aLocalEdge(DBRep::Get(a[1],TopAbs_EDGE));
1002 TopoDS_Edge E = TopoDS::Edge(aLocalEdge);
1003 for (Standard_Integer ii = 1; ii <= (narg/2)-1; ii++){
1004 Par = atof(a[2*ii]);
1005 Rad = atof(a[2*ii + 1]);
1006 uandr.ChangeValue(ii).SetCoord(Par,Rad);
1008 //HELPDESK: Add law creation
1009 const Standard_Boolean aLawMode = !strcmp(a[0],"OCC570evollaw");
1012 di<<"INFO: Using law to define variable fillet"<<"\n";
1013 Handle(Law_Interpol) law = new Law_Interpol;
1023 static Standard_Integer BUILDEVOL(Draw_Interpretor& di,
1028 di << "MakeFillet non initialise"<<"\n";
1033 TopoDS_Shape result = Rake->Shape();
1034 DBRep::Set(name,result);
1035 if(Rake != 0) {delete Rake; Rake = 0;}
1038 if(Rake != 0) {delete Rake; Rake = 0;}
1042 #include <TColGeom_SequenceOfCurve.hxx>
1043 #include <Geom_TrimmedCurve.hxx>
1044 #include <GeomFill_NSections.hxx>
1045 #include <BRepBuilderAPI_MakeFace.hxx>
1046 //=======================================================================
1049 //=======================================================================
1050 static Standard_Integer OCC606 ( Draw_Interpretor& di, Standard_Integer n, const char ** a )
1052 if (n != 3 && n != 4)
1054 di << "Usage : " << a[0] << " result shape [-t]" << "\n";
1058 Standard_Boolean TrimMode = (n == 4);
1059 if (TrimMode) di<<"INFO: Using trimmed curves..."<<"\n";
1060 else di<<"INFO: Using non trimmed curves..."<<"\n";
1062 TopoDS_Shape S = DBRep::Get(a[2]);
1064 TopExp_Explorer t_exp(S,TopAbs_EDGE);
1065 TColGeom_SequenceOfCurve n_curves1;
1066 TColStd_SequenceOfReal np;
1067 Standard_Real param = 5.0;
1069 for (;t_exp.More();t_exp.Next())
1072 Handle(Geom_Curve) h_cur = BRep_Tool::Curve(TopoDS::Edge(t_exp.Current()),f,l);
1073 if (!h_cur.IsNull())
1075 if (TrimMode) h_cur = new Geom_TrimmedCurve(h_cur,f,l);
1077 n_curves1.Append(h_cur);
1083 if (n_curves1.Length()>1 && !np.IsEmpty())
1088 GeomFill_NSections b_surface1(n_curves1, np);
1089 b_surface1.ComputeSurface();
1090 Handle(Geom_BSplineSurface) result_surf1 = b_surface1.BSplineSurface();
1091 if (!result_surf1.IsNull())
1093 BRepBuilderAPI_MakeFace b_face1(result_surf1, Precision::Confusion());
1094 TopoDS_Face bsp_face1 = b_face1.Face();
1095 DBRep::Set(a[1],bsp_face1);
1098 catch(Standard_Failure)
1100 di<<"ERROR: Exception in GeomFill_NSections"<<"\n";
1108 //=======================================================================
1111 //=======================================================================
1112 static Standard_Integer OCC813 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
1116 di << "Usage : " << argv[0] << " U V" << "\n";
1120 Standard_CString str;
1121 Standard_Real U = atof(argv[1]);
1122 Standard_Real V = atof(argv[2]);
1124 //Between ellipse and point:
1126 Handle(Geom_Ellipse) ell = new Geom_Ellipse(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
1127 gp_Dir(0.173648,0.984808,0.000000),
1128 gp_Dir(-0.932169,0.164367,-0.322560)), 150, 100);
1129 Handle(Geom_Plane) plne = new Geom_Plane(gp_Ax3(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
1130 gp_Dir(0.173648,0.984808,0.000000),
1131 gp_Dir(-0.932169,0.164367,-0.322560))) );
1133 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1136 gp_Pln pln = plne->Pln();
1138 str = "OCC813_pnt"; DrawTrSurf::Set(str,pt2d);
1140 Handle(Geom2d_Curve) curve2d = GeomAPI::To2d(ell,pln);
1141 Geom2dAdaptor_Curve acur(curve2d);
1142 Geom2dGcc_QualifiedCurve qcur(acur, GccEnt_outside);
1144 str = "OCC813_ell"; DrawTrSurf::Set(str,curve2d);
1145 if(!aContext.IsNull()) {
1146 Handle(AIS_Shape) aisp =
1147 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(curve2d, pln)).Edge());
1148 aContext->Display (aisp);
1151 //This does not give any solutions.
1152 Geom2dGcc_Lin2d2Tan lintan(qcur, pt2d, 0.1);
1153 di<<"OCC813 nb of solutions = "<<lintan.NbSolutions()<<"\n";
1155 Standard_Character abuf[16];
1156 Standard_CString st = abuf;
1159 for(i=1;i<=lintan.NbSolutions();i++) {
1160 sprintf(abuf,"lintan_%d",i);
1161 Handle(Geom2d_Line) glin = new Geom2d_Line(lintan.ThisSolution(i));
1162 DrawTrSurf::Set(st,glin);
1163 if(!aContext.IsNull()) {
1164 Handle(AIS_Shape) aisp =
1165 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(glin, pln)).Edge()); aContext->Display (aisp);
1172 //=======================================================================
1175 //=======================================================================
1176 static Standard_Integer OCC814 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
1180 di << "Usage : " << argv[0] << "\n";
1184 Standard_CString str;
1186 //Between Ellipse and Circle:
1188 Handle(Geom_Circle) cir = new Geom_Circle(gp_Ax2(gp_Pnt(823.687192,502.366825,478.960440),
1189 gp_Dir(0.173648,0.984808,0.000000),
1190 gp_Dir(-0.932169,0.164367,-0.322560)), 50);
1191 Handle(Geom_Ellipse) ell = new Geom_Ellipse(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
1192 gp_Dir(0.173648,0.984808,0.000000),
1193 gp_Dir(-0.932169,0.164367,-0.322560)), 150, 100);
1194 Handle(Geom_Plane) plne = new Geom_Plane(gp_Ax3(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
1195 gp_Dir(0.173648,0.984808,0.000000),
1196 gp_Dir(-0.932169,0.164367,-0.322560))) );
1198 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1200 gp_Pln pln = plne->Pln();
1201 Handle(Geom2d_Curve) curve2d = GeomAPI::To2d(ell, pln);
1202 Handle(Geom2d_Curve) fromcurve2d = GeomAPI::To2d(cir, pln);
1204 str = "OCC814_cir"; DrawTrSurf::Set(str,curve2d);
1205 str = "OCC814_ell"; DrawTrSurf::Set(str,fromcurve2d);
1206 if(!aContext.IsNull()) {
1207 Handle(AIS_Shape) aisp =
1208 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(curve2d, pln)).Edge());
1209 aContext->Display (aisp);
1211 if(!aContext.IsNull()) {
1212 Handle(AIS_Shape) aisp =
1213 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(fromcurve2d, pln)).Edge());
1214 aContext->Display (aisp);
1217 Geom2dAdaptor_Curve acur(curve2d), afromcur(fromcurve2d);
1219 Geom2dGcc_QualifiedCurve qcur(acur, GccEnt_outside) ;
1220 Geom2dGcc_QualifiedCurve qfromcur(afromcur, GccEnt_outside) ;
1222 //This does not give any solutions.
1223 Geom2dGcc_Lin2d2Tan lintan(qcur, qfromcur, 0.1);
1224 di<<"OCC814 nb of solutions = "<<lintan.NbSolutions()<<"\n";
1226 Standard_Character abuf[16];
1227 Standard_CString st = abuf;
1230 for(i=1;i<=lintan.NbSolutions();i++) {
1231 sprintf(abuf,"lintan_%d",i);
1232 Handle(Geom2d_Line) glin = new Geom2d_Line(lintan.ThisSolution(i));
1233 DrawTrSurf::Set(st,glin);
1234 if(!aContext.IsNull()) {
1235 Handle(AIS_Shape) aisp =
1236 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(glin, pln)).Edge()); aContext->Display (aisp);
1243 #include <ShapeAnalysis_Wire.hxx>
1244 #include <IntRes2d_SequenceOfIntersectionPoint.hxx>
1245 #include <TColgp_SequenceOfPnt.hxx>
1246 #include <ShapeFix_Wire.hxx>
1247 //=======================================================================
1250 //=======================================================================
1251 static Standard_Integer OCC884 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1253 if (argc < 3 || argc > 5)
1255 di << "Usage : " << argv[0] << " result shape [toler [maxtoler]]" << "\n";
1259 TopoDS_Shape shape = DBRep::Get(argv[2]); //read the shape
1261 TopExp_Explorer exp(shape, TopAbs_EDGE);
1264 di<<"Error: no edge found"<<"\n";
1268 BRep_Builder builder;
1270 builder.MakeWire(wire);
1271 builder.Add(wire, TopoDS::Edge(exp.Current()));
1273 // HelpDesk: Create planar face if possible
1274 TopoDS_Face face = BRepBuilderAPI_MakeFace(wire,Standard_True);
1276 Handle(ShapeAnalysis_Wire) advWA = new ShapeAnalysis_Wire;
1278 advWA->SetFace(face);
1279 advWA->SetPrecision(0.001);
1281 IntRes2d_SequenceOfIntersectionPoint points2d;
1282 TColgp_SequenceOfPnt points3d;
1284 di << "Info: CheckSelfIntersectingEdge = " << (Standard_Integer) advWA->CheckSelfIntersectingEdge(1,points2d,points3d) << "\n";
1286 ShapeExtend_Status status = ShapeExtend_FAIL1;
1287 if (advWA->StatusSelfIntersection(status))
1288 di << "Info: No P Curve found in the edge\n";
1290 status = ShapeExtend_FAIL2;
1291 if (advWA->StatusSelfIntersection(status))
1292 di << "Info: No Vertices found in the edge\n";
1294 status = ShapeExtend_DONE1;
1295 if (advWA->StatusSelfIntersection(status))
1296 di << "Info: Self-intersection found in the edge\n";
1298 Standard_Integer i, num = points2d.Length();
1299 di << "Info: No. of self-intersection points : " << num << "\n";
1302 Standard_CString name = str;
1303 for (i = 1; i <= num; ++i)
1305 gp_Pnt pt = points3d(i);
1306 di << "Info: Intersecting pt : (" << pt.X() << ", " << pt.Y() << ", " << pt.Z() << ")\n";
1307 sprintf(str,"p_%d",i);
1308 DrawTrSurf::Set(name,pt);
1311 Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire;
1315 if (argc > 3) sfw->SetPrecision(atof(argv[3])/*0.1*/);
1316 if (argc > 4) sfw->SetMaxTolerance(atof(argv[4]));
1317 di << "Info: Precision is set to " << sfw->Precision() << "\n";
1318 di << "Info: MaxTolerance is set to " << sfw->MaxTolerance() << "\n";
1320 sfw->ModifyTopologyMode() = 1;
1321 sfw->ModifyGeometryMode() = 1;
1322 sfw->FixSelfIntersectingEdgeMode() = 1;
1323 //printf("Info: FixSelfIntersection = %d\n",sfw->FixSelfIntersection());
1324 di << "Info: FixSelfIntersection = " << (Standard_Integer) sfw->FixSelfIntersection() << "\n";
1326 DBRep::Set(argv[1],sfw->Wire());
1328 status = ShapeExtend_OK;
1329 if (sfw->StatusSelfIntersection(status))
1330 di << "Info: ShapeExtend_OK : No intersection found\n";
1331 //printf("Info: ShapeExtend_OK : No intersection found\n");
1333 status = ShapeExtend_FAIL1;
1334 if (sfw->StatusSelfIntersection(status))
1335 di << "Info: ShapeExtend_FAIL1 : analysis failed (edge has no pcurve, or no vertices etc.)\n";
1337 status = ShapeExtend_FAIL2;
1338 if (sfw->StatusSelfIntersection(status))
1339 di << "Info: ShapeExtend_FAIL2 : self-intersection was found, but not fixed because of limit of increasing tolerance (MaxTolerance)\n";
1341 status = ShapeExtend_FAIL3;
1342 if (sfw->StatusSelfIntersection(status))
1343 di << "Info: ShapeExtend_FAIL3 : intercestion of non adjacent edges found, but not fixed because of limit of increasing tolerance (MaxTolerance)\n";
1345 status = ShapeExtend_DONE1;
1346 if (sfw->StatusSelfIntersection(status))
1347 di << "Info: ShapeExtend_DONE1 : tolerance of vertex was increased to fix self-intersection\n";
1349 status = ShapeExtend_DONE2;
1350 if (sfw->StatusSelfIntersection(status))
1351 di << "Info: ShapeExtend_DONE2 : vertex was moved to fix self-intersection\n";
1353 status = ShapeExtend_DONE3;
1354 if (sfw->StatusSelfIntersection(status))
1355 di << "Info: ShapeExtend_DONE3 : some edges were removed because of intersection\n";
1357 status = ShapeExtend_DONE4;
1358 if (sfw->StatusSelfIntersection(status))
1359 di << "Info: ShapeExtend_DONE4 : pcurve(s) was(were) modified\n";
1361 status = ShapeExtend_DONE5;
1362 if (sfw->StatusSelfIntersection(status))
1363 di << "Info: ShapeExtend_DONE5 : non adjacent intersection fixed by increasing tolerance of vertex(vertices)\n";
1365 status = ShapeExtend_DONE6;
1366 if (sfw->StatusSelfIntersection(status))
1367 di << "Info: ShapeExtend_DONE6 : tolerance of edge was increased to hide intersection\n";
1369 status = ShapeExtend_DONE7;
1370 if (sfw->StatusSelfIntersection(status))
1371 di << "Info: ShapeExtend_DONE7 : range of some edges was decreased to avoid intersection\n";
1376 #include <Aspect_FillMethod.hxx>
1377 //=======================================================================
1378 //function : OCC1188
1380 //=======================================================================
1381 static Standard_Integer OCC1188 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1383 if (argc < 2 || argc > 3)
1385 di << "Usage : " << argv[0] << " imagefile [filltype] : Load image as background" << "\n";
1389 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1390 if(AISContext.IsNull())
1392 di << "use 'vinit' command before " << argv[0] << "\n";
1396 Aspect_FillMethod aFillType = Aspect_FM_CENTERED;
1399 const char* szType = argv[2];
1400 if (strcmp(szType, "NONE" ) == 0) aFillType = Aspect_FM_NONE;
1401 else if (strcmp(szType, "CENTERED") == 0) aFillType = Aspect_FM_CENTERED;
1402 else if (strcmp(szType, "TILED" ) == 0) aFillType = Aspect_FM_TILED;
1403 else if (strcmp(szType, "STRETCH" ) == 0) aFillType = Aspect_FM_STRETCH;
1406 di << "Wrong fill type : " << szType << "\n";
1407 di << "Must be one of CENTERED, TILED, STRETCH, NONE" << "\n";
1412 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
1413 V3dView->SetBackgroundImage(argv[1], aFillType, Standard_True);
1418 #include <AIS_Drawer.hxx>
1419 #include <Graphic3d_MaterialAspect.hxx>
1420 #include <Prs3d_ShadingAspect.hxx>
1421 //=======================================================================
1422 //function : OCC1174_1
1424 //=======================================================================
1425 static Standard_Integer OCC1174_1 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1429 di << "Usage : " << argv[0] << " shape" << "\n";
1433 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1434 if(AISContext.IsNull())
1436 di << "use 'vinit' command before " << argv[0] << "\n";
1440 TopoDS_Shape sh = DBRep::Get(argv[1]);
1442 Handle(AIS_Shape) ais = new AIS_Shape(sh);
1444 Quantity_Color colf(0.0, 0.4, 0.0, Quantity_TOC_RGB);
1445 Quantity_Color colb(0.0, 0.0, 0.6, Quantity_TOC_RGB);
1447 Handle(Prs3d_ShadingAspect) sa = ais->Attributes()->ShadingAspect();
1449 Graphic3d_MaterialAspect front = sa->Material(Aspect_TOFM_FRONT_SIDE);
1450 front.SetAmbientColor(colf);
1451 front.SetDiffuseColor(colf);
1452 front.SetSpecularColor(colf);
1453 front.SetEmissiveColor(colf);
1454 front.SetTransparency(0.0);
1455 sa->SetMaterial(front,Aspect_TOFM_FRONT_SIDE);
1457 Graphic3d_MaterialAspect back = sa->Material(Aspect_TOFM_BACK_SIDE);
1458 back.SetAmbientColor(colb);
1459 back.SetDiffuseColor(colb);
1460 back.SetSpecularColor(colb);
1461 back.SetEmissiveColor(colb);
1462 back.SetTransparency(0.0);
1463 sa->SetMaterial(back,Aspect_TOFM_BACK_SIDE);
1465 AISContext->Display(ais,1,0);
1467 Standard_Real r, g, b;
1468 sa->Color(Aspect_TOFM_FRONT_SIDE).Values(r,g,b, Quantity_TOC_RGB);
1469 di << "Info: color on front side (" << r << "," << g << "," << b << ")\n";
1470 sa->Color(Aspect_TOFM_BACK_SIDE).Values(r,g,b, Quantity_TOC_RGB);
1471 di << "Info: color on back side (" << r << "," << g << "," << b << ")\n";
1476 //=======================================================================
1477 //function : OCC1174_2
1479 //=======================================================================
1480 static Standard_Integer OCC1174_2 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1484 di << "Usage : " << argv[0] << " shape" << "\n";
1488 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1489 if(AISContext.IsNull())
1491 di << "use 'vinit' command before " << argv[0] << "\n";
1495 TopoDS_Shape sh = DBRep::Get(argv[1]);
1497 Handle(AIS_Shape) ais = new AIS_Shape(sh);
1498 AISContext->Display(ais,1,0);
1499 AISContext->SetMaterial(ais,Graphic3d_NOM_SHINY_PLASTIC);
1501 Quantity_Color colf(0.0, 0.4, 0.0, Quantity_TOC_RGB);
1502 Quantity_Color colb(0.0, 0.0, 0.6, Quantity_TOC_RGB);
1503 Handle(Prs3d_ShadingAspect) sa = ais->Attributes()->ShadingAspect();
1505 Graphic3d_MaterialAspect front = sa->Material(Aspect_TOFM_FRONT_SIDE);
1506 front.SetAmbientColor(colf);
1507 front.SetDiffuseColor(colf);
1508 front.SetSpecularColor(colf);
1509 front.SetEmissiveColor(colf);
1510 front.SetTransparency(0.4);
1511 sa->SetMaterial(front,Aspect_TOFM_FRONT_SIDE);
1513 Graphic3d_MaterialAspect back = sa->Material(Aspect_TOFM_BACK_SIDE);
1514 back.SetAmbientColor(colb);
1515 back.SetDiffuseColor(colb);
1516 back.SetSpecularColor(colb);
1517 back.SetEmissiveColor(colb);
1518 back.SetTransparency(0.2);
1519 sa->SetMaterial(back,Aspect_TOFM_BACK_SIDE);
1521 AISContext->Redisplay(ais,1,0);
1526 #include <Graphic2d_Segment.hxx>
1527 #include <Prs2d_Length.hxx>
1528 #include <Prs2d_AspectLine.hxx>
1529 #include <AIS2D_InteractiveObject.hxx>
1530 //=======================================================================
1535 // OCC672_ShortLength
1536 //=======================================================================
1538 static Standard_Integer OCC672_Length (Draw_Interpretor& di, Standard_Integer n,const char ** argv)
1541 di << " wrong parameters !\n";
1542 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";
1546 Standard_Real x1=atof(argv[1]);
1547 Standard_Real y1=atof(argv[2]);
1548 Standard_Real x2=atof(argv[3]);
1549 Standard_Real y2=atof(argv[4]);
1550 Standard_Real x3=atof(argv[10]);
1551 Standard_Real y3=atof(argv[11]);
1552 Standard_Real x4=atof(argv[12]);
1553 Standard_Real y4=atof(argv[13]);
1554 Standard_Real txtAngle=atof(argv[14]);
1555 Standard_Real txtPosH=atof(argv[15]);
1556 Standard_Real txtPosV=atof(argv[16]);
1559 Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
1560 di<<"Check InteractiveContext\n";
1562 if(aContext.IsNull()) {
1563 di << "use 'v2dinit' command before " << argv[0] << "\n";
1567 di<<"CloseLocalContext\n";
1568 aContext->CloseLocalContext();
1570 di<<"OpenLocalContext\n";
1571 aContext->OpenLocalContext();
1573 Handle(AIS2D_InteractiveObject) aIO10 = new AIS2D_InteractiveObject();
1574 Handle(Graphic2d_Segment) theSegmA, theSegmB, theSegmC, theSegmD;
1576 theSegmA = new Graphic2d_Segment( aIO10, x1, y1, x2, y2 );
1577 theSegmB = new Graphic2d_Segment( aIO10, x2, y2, x3, y3 );
1578 theSegmC = new Graphic2d_Segment( aIO10, x3, y3, x4, y4 );
1579 theSegmD = new Graphic2d_Segment( aIO10, x4, y4, x1, y1 );
1581 aContext->Display( aIO10, Standard_True );
1583 Handle(Prs2d_Length) length = new Prs2d_Length(aIO10, gp_Pnt2d(x1, y1), gp_Pnt2d(x2, y2), argv[5],
1584 atof(argv[6]), atof(argv[7]), Prs2d_TOD_AUTOMATIC,
1585 atof(argv[8]), atof(argv[9]), Prs2d_TOA_FILLED,
1588 length->SetTextRelPos(txtPosH,txtPosV);
1589 length->SetTextRelAngle(txtAngle);
1591 Handle(Prs2d_AspectLine) theAspect = new Prs2d_AspectLine(Quantity_NOC_WHITE,
1592 Aspect_TOL_SOLID, Aspect_WOL_THIN);
1593 aIO10->SetAspect( theAspect, length);
1594 aContext->Display( aIO10, Standard_True );
1596 Handle(Prs2d_Length) lengthB = new Prs2d_Length(aIO10, gp_Pnt2d(x2, y2), gp_Pnt2d(x3, y3), argv[5],
1597 atof(argv[6]), atof(argv[7]), Prs2d_TOD_AUTOMATIC,
1598 atof(argv[8]), atof(argv[9]), Prs2d_TOA_FILLED,
1601 lengthB->SetTextRelPos(txtPosH,txtPosV);
1602 lengthB->SetTextRelAngle(txtAngle);
1604 aIO10->SetAspect( theAspect, lengthB);
1605 aContext->Display( aIO10, Standard_True );
1607 Handle(Prs2d_Length) lengthC = new Prs2d_Length(aIO10, gp_Pnt2d(x3, y3), gp_Pnt2d(x4, y4), argv[5],
1608 atof(argv[6]), atof(argv[7]), Prs2d_TOD_AUTOMATIC,
1609 atof(argv[8]), atof(argv[9]), Prs2d_TOA_FILLED,
1612 lengthC->SetTextRelPos(txtPosH,txtPosV);
1613 lengthC->SetTextRelAngle(txtAngle);
1615 aIO10->SetAspect( theAspect, lengthC);
1616 aContext->Display( aIO10, Standard_True );
1618 Handle(Prs2d_Length) lengthD = new Prs2d_Length(aIO10, gp_Pnt2d(x4, y4), gp_Pnt2d(x1, y1), argv[5],
1619 atof(argv[6]), atof(argv[7]), Prs2d_TOD_AUTOMATIC,
1620 atof(argv[8]), atof(argv[9]), Prs2d_TOA_FILLED,
1623 lengthD->SetTextRelPos(txtPosH,txtPosV);
1624 lengthD->SetTextRelAngle(txtAngle);
1626 aIO10->SetAspect( theAspect, lengthD);
1627 aContext->Display( aIO10, Standard_True );
1631 #include <Prs2d_Angle.hxx>
1632 static Standard_Integer OCC672_Angle (Draw_Interpretor& di, Standard_Integer n,const char ** argv)
1635 di << "Wrong parameters !\n";
1636 di << "must be : OCC672_Angle x1 y1 x2 y2 x3 y3 aRadius aText aTxtScale anArrAngle anArrLength txtAngle txtPosH txtPosV \n";
1640 Standard_Real x1=atof(argv[1]);
1641 Standard_Real y1=atof(argv[2]);
1642 Standard_Real x2=atof(argv[3]);
1643 Standard_Real y2=atof(argv[4]);
1644 Standard_Real x3=atof(argv[5]);
1645 Standard_Real y3=atof(argv[6]);
1646 Standard_Real aRadius=atof(argv[7]);
1647 Standard_Real aTxtScale=atof(argv[9]);
1648 Standard_Real anArrAngle=atof(argv[10]);
1649 Standard_Real anArrLength=atof(argv[11]);
1650 Standard_Real txtAngle=atof(argv[12]);
1651 Standard_Real txtPosH=atof(argv[13]);
1652 Standard_Real txtPosV=atof(argv[14]);
1655 Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
1656 di<<"Check InteractiveContext\n";
1658 if(aContext.IsNull()) {
1659 di << "use 'v2dinit' command before " << argv[0] << "\n";
1663 di<<"CloseLocalContext\n";
1664 aContext->CloseLocalContext();
1666 di<<"OpenLocalContext\n";
1667 aContext->OpenLocalContext();
1669 Handle(AIS2D_InteractiveObject) aIO10 = new AIS2D_InteractiveObject();
1670 Handle(Graphic2d_Segment) theSegmA, theSegmB;
1671 theSegmA = new Graphic2d_Segment( aIO10, x1, y1, x2, y2 );
1672 theSegmB = new Graphic2d_Segment( aIO10, x1, y1, x3, y3 );
1673 aContext->Display( aIO10, Standard_True );
1675 Handle(Prs2d_Angle) angle = new Prs2d_Angle(aIO10, gp_Pnt2d(x1, y1), gp_Pnt2d(x2, y2),gp_Pnt2d(x3,y3),
1676 aRadius,argv[8],aTxtScale,anArrAngle,anArrLength,Prs2d_TOA_FILLED,
1679 angle->SetTextRelPos(txtPosH,txtPosV);
1680 angle->SetTextAbsAngle(txtAngle);
1682 aContext->Display( aIO10, Standard_True );
1686 #include <Prs2d_Diameter.hxx>
1687 #include <gp_Circ2d.hxx>
1688 #include <Graphic2d_Circle.hxx>
1689 #include <Prs2d_AspectText.hxx>
1690 static Standard_Integer OCC672_Diameter (Draw_Interpretor& di, Standard_Integer n,const char ** argv)
1693 di << "Wrong parameters !\n";
1694 di << "must be : OCC672_Diameter x1 y1 cx cy radius aText aTxtScale anArrAngle anArrLength txtAngle txtPosH txtPosV\n";
1698 Standard_Real x1=atof(argv[1]);
1699 Standard_Real y1=atof(argv[2]);
1700 Standard_Real cx=atof(argv[3]); //coordinats for circle
1701 Standard_Real cy=atof(argv[4]); //
1702 Standard_Real radius=atof(argv[5]);//radius for circle
1703 Standard_Real aTxtScale=atof(argv[7]);
1704 Standard_Real anArrAngle=atof(argv[8]);
1705 Standard_Real anArrLength=atof(argv[9]);
1707 Standard_Real txtAngle=atof(argv[10]);
1708 Standard_Real txtPosH=atof(argv[11]);
1709 Standard_Real txtPosV=atof(argv[12]);
1713 Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
1714 di<<"Check InteractiveContext\n";
1716 if(aContext.IsNull()) {
1717 di << "use 'v2dinit' command before " << argv[0] << "\n";
1721 di<<"CloseLocalContext\n";
1722 aContext->CloseLocalContext();
1724 di<<"OpenLocalContext\n";
1725 aContext->OpenLocalContext();
1726 Handle(AIS2D_InteractiveObject) aIO10 = new AIS2D_InteractiveObject();
1728 Handle (Graphic2d_Circle) HCirc;
1729 HCirc= new Graphic2d_Circle(aIO10,cx,cy,radius);
1731 gp_Dir2d myDir2d(1,0);
1732 gp_Pnt2d myPnt2d(cx,cy);
1733 gp_Ax2d myAx2d(myPnt2d,myDir2d);
1734 gp_Circ2d myCirc(myAx2d,radius);
1736 Handle(Prs2d_Diameter) diameter = new Prs2d_Diameter(aIO10, gp_Pnt2d(x1, y1),myCirc,
1737 argv[6],aTxtScale,anArrAngle,anArrLength,
1739 Prs2d_AS_BOTHAR,Standard_True);
1741 diameter->SetTextRelPos(txtPosH,txtPosV);
1743 diameter->SetTextAbsAngle(txtAngle);
1745 aContext->Display( aIO10, Standard_True );
1750 #include <gp_Lin2d.hxx>
1751 static Standard_Integer OCC672_ShortLength (Draw_Interpretor& di, Standard_Integer n,const char ** argv)
1754 di << " wrong parameters !\n";
1755 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";
1759 Standard_Real x1=atof(argv[1]);
1760 Standard_Real y1=atof(argv[2]);
1761 Standard_Real x2=atof(argv[3]);
1762 Standard_Real y2=atof(argv[4]);
1763 Standard_Real x3=atof(argv[10]);
1764 Standard_Real y3=atof(argv[11]);
1765 Standard_Real x4=atof(argv[12]);
1766 Standard_Real y4=atof(argv[13]);
1767 Standard_Real txtAngle=atof(argv[14]);
1768 Standard_Real txtPosH=atof(argv[15]);
1769 Standard_Real txtPosV=atof(argv[16]);
1773 Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
1774 di<<"Check InteractiveContext\n";
1776 if(aContext.IsNull()) {
1777 di << "use 'v2dinit' command before " << argv[0] << "\n";
1781 di<<"CloseLocalContext\n";
1782 aContext->CloseLocalContext();
1784 di<<"OpenLocalContext\n";
1785 aContext->OpenLocalContext();
1787 Handle(AIS2D_InteractiveObject) aIO10 = new AIS2D_InteractiveObject();
1788 Handle(Graphic2d_Segment) theSegmA, theSegmB, theSegmC, theSegmD;
1789 theSegmB = new Graphic2d_Segment( aIO10, x2, y2, x3, y3 );
1790 theSegmD = new Graphic2d_Segment( aIO10, x4, y4, x1, y1 );
1792 aContext->Display( aIO10, Standard_True );
1794 gp_Pnt2d p3(x3,y3),p2(x2,y2),p1(x1,y1);
1795 gp_Vec2d theVec(p3,p2);
1796 gp_Dir2d theDir(theVec);
1797 gp_Lin2d theLin1(p1,theDir);
1798 gp_Lin2d theLin2(p3,theDir);
1800 Handle(Prs2d_Length) length = new Prs2d_Length(aIO10, p1, theLin2, argv[5],
1801 atof(argv[6]), 5.0, 20.0, 5.,
1802 Prs2d_TOA_CLOSED,Prs2d_AS_BOTHAR,
1806 Handle(Prs2d_AspectLine) theAspect = new Prs2d_AspectLine(Quantity_NOC_WHITE,
1807 Aspect_TOL_SOLID, Aspect_WOL_THIN);
1808 length->SetTextRelPos(txtPosH,txtPosV);
1809 length->SetTextRelAngle(txtAngle);
1811 aIO10->SetAspect( theAspect, length);
1812 aContext->Display( aIO10, Standard_True );
1817 #include <TopoDS_Solid.hxx>
1818 #include <BRepFeat_MakeDPrism.hxx>
1819 //=======================================================================
1821 //purpose : FEATURE OPERATION (BOSS and SLOT)
1822 //=======================================================================
1823 static Standard_Integer OCCN1 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1827 di << "Usage : " << argv[0] << " angle fuse(1 for boss / 0 for slot) length" << "\n";
1831 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1832 if(aContext.IsNull())
1834 di << "use 'vinit' command before " << argv[0] << "\n";
1837 Standard_Real angle = atof(argv[1]);
1838 Standard_Integer fuse = atoi(argv[2]);
1839 Standard_Real length = atof(argv[3]);
1841 BRepBuilderAPI_MakeEdge edge1(gp_Pnt(0, 0, 0), gp_Pnt(50, 0, 0));
1842 BRepBuilderAPI_MakeEdge edge2(gp_Pnt(50, 0, 0), gp_Pnt(50, 50, 0));
1843 BRepBuilderAPI_MakeEdge edge3(gp_Pnt(50, 50, 0), gp_Pnt(0, 50, 0));
1844 BRepBuilderAPI_MakeEdge edge4(gp_Pnt(0, 50, 0), gp_Pnt(0, 0, 0));
1845 TopoDS_Edge ted1 = edge1.Edge();
1846 TopoDS_Edge ted2 = edge2.Edge();
1847 TopoDS_Edge ted3 = edge3.Edge();
1848 TopoDS_Edge ted4 = edge4.Edge();
1850 BRepBuilderAPI_MakeWire wire(ted1, ted2, ted3, ted4);
1851 TopoDS_Wire twire = wire.Wire();
1853 BRepBuilderAPI_MakeFace face(twire);
1854 TopoDS_Face tface = face.Face();
1855 ////////Handle_AIS_Shape face_ais = new AIS_Shape( tface );
1856 ////////aContext->Display(face_ais);
1859 BRepPrimAPI_MakeBox block(gp_Pnt(-50, -50, -150), 150, 150, 100);
1860 box = block.Solid();
1862 TopoDS_Face top_face;
1863 top_face = block.TopFace();
1865 BRepFeat_MakeDPrism slot(box, tface, top_face, angle, fuse,
1868 slot.Perform(length);
1869 TopoDS_Shape S2 = slot.Shape();
1871 DBRep::Set("OCCN1_tface",tface);
1872 DBRep::Set("OCCN1_slot",S2);
1877 #include <BRepPrimAPI_MakeCylinder.hxx>
1878 #include <BRepPrimAPI_MakeSphere.hxx>
1879 #include <BRepAlgoAPI_Section.hxx>
1880 #include <BRepAlgo_Section.hxx>
1881 //=======================================================================
1883 //purpose : BOOLEAN OPERATION
1884 //=======================================================================
1885 static Standard_Integer OCCN2 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1888 di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1891 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1893 Standard_Integer IsB = atoi(argv[1]);
1895 IsBRepAlgoAPI = Standard_False;
1896 #if ! defined(BRepAlgo_def04)
1901 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1902 if(aContext.IsNull())
1904 di << "use 'vinit' command before " << argv[0] << "\n";
1908 BRepPrimAPI_MakeCylinder cylinder(50,200);
1909 TopoDS_Shape cylinder_sh = cylinder.Shape();
1911 BRepPrimAPI_MakeSphere sphere(gp_Pnt(60,0,100),50);
1912 TopoDS_Shape sphere_sh = sphere.Shape();
1914 //BRepAlgoAPI_Section section(cylinder_sh, sphere_sh);
1915 //TopoDS_Shape shape = section.Shape();
1918 if (IsBRepAlgoAPI) {
1919 di << "BRepAlgoAPI_Section section(cylinder_sh, sphere_sh)" <<"\n";
1920 BRepAlgoAPI_Section section(cylinder_sh, sphere_sh);
1922 if(!section.IsDone()){
1923 di << "Error performing intersection: not done." << "\n";
1925 shape = section.Shape();
1927 di << "BRepAlgo_Section section(cylinder_sh, sphere_sh)" <<"\n";
1928 BRepAlgo_Section section(cylinder_sh, sphere_sh);
1930 if(!section.IsDone()){
1931 di << "Error performing intersection: not done." << "\n";
1933 shape = section.Shape();
1936 DBRep::Set("OCCN2_cylinder",cylinder_sh);
1937 DBRep::Set("OCCN2_sphere",sphere_sh);
1938 DBRep::Set("OCCN2_section",shape);
1943 #include <TColgp_Array1OfPnt.hxx>
1944 #include <Geom_BezierCurve.hxx>
1946 static Standard_Integer OCC2569 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1948 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1949 if(aContext.IsNull())
1951 di << "use 'vinit' command before " << argv[0] << "\n";
1955 di << "Usage : " << argv[0] << " nbpoles result" << "\n";
1959 int poles=atoi(argv[1]);
1961 TColgp_Array1OfPnt arr(1, poles);
1962 for(int i=1; i<=poles; i++)
1963 arr.SetValue(i, gp_Pnt(i+10, i*2+20, i*3+45));
1965 Handle_Geom_BezierCurve bez = new Geom_BezierCurve(arr);
1967 di << "\n The curve is not created.\n";
1969 di << "\n Degree = " << bez->Degree() << "\n";
1971 TopoDS_Edge sh = BRepBuilderAPI_MakeEdge(bez).Edge();
1972 Handle_AIS_Shape ais = new AIS_Shape(sh);
1973 aContext->Display(ais);
1974 DrawTrSurf::Set(argv[2],bez);
1978 #include <TopTools_IndexedMapOfShape.hxx>
1979 #include <TopExp.hxx>
1981 static Standard_Integer OCC1642 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1984 di<<"Usage: " << argv[0] << " FinalWare FinalFace InitWare InitFace shape FixReorder FixDegenerated FixConnected FixSelfIntersection"<<"\n";
1988 TopoDS_Shape shape = DBRep::Get(argv[5]);
1990 TopExp_Explorer exp(shape, TopAbs_WIRE);
1991 TopoDS_Shape wire = exp.Current();
1993 Handle(ShapeAnalysis_Wire) advWA = new ShapeAnalysis_Wire;
1994 advWA->Load(TopoDS::Wire(wire));
1996 DBRep::Set(argv[3],wire);
1999 BRepBuilderAPI_MakeFace(TopoDS::Wire(wire),Standard_True);
2001 DBRep::Set(argv[4],face);
2003 advWA->SetFace(face);
2004 float precision_to_ana = 0.0001;
2005 advWA->SetPrecision(precision_to_ana);
2007 TopTools_IndexedMapOfShape M;
2008 TopExp::MapShapes(wire, TopAbs_EDGE, M);
2011 for(j= 1; j<=M.Extent(); ++j) {
2012 Standard_Integer num=1;
2013 IntRes2d_SequenceOfIntersectionPoint points2d;
2014 TColgp_SequenceOfPnt points3d;
2016 cout << "\n j =" << j << ", CheckSelfIntersectingEdge = " <<
2017 advWA->CheckSelfIntersectingEdge(j, points2d, points3d);
2020 ShapeExtend_Status status = ShapeExtend_FAIL1;
2021 if(advWA->StatusSelfIntersection(status))
2023 status = ShapeExtend_FAIL2;
2024 if(advWA->StatusSelfIntersection(status))
2025 di << "\n No Vertices found in the edge";
2027 status = ShapeExtend_DONE1;
2028 if(advWA->StatusSelfIntersection(status))
2029 di << "\n Self-intersection found in the edge";
2031 num = points2d.Length();
2032 di << "\n No. of self-intersecting edges : " << num;
2034 for(int i=1; i<=num; ++i) {
2035 gp_Pnt pt = points3d(i);
2036 di << "\n Intersecting pt : (" << pt.X() << ", " << pt.Y()<< ", " << pt.Z() << ")";
2041 Handle_ShapeFix_Wire sfw = new ShapeFix_Wire;
2042 sfw->Load(TopoDS::Wire(wire));
2044 sfw->SetPrecision(Precision::Confusion());
2046 sfw->FixReorderMode() = 1;
2047 sfw->ClosedWireMode() = 1;
2048 sfw->FixDegeneratedMode() = 1;
2049 sfw->FixConnectedMode() = 1;
2050 sfw->ModifyTopologyMode() = 1;
2051 sfw->ModifyGeometryMode() = 1;
2052 sfw->FixSelfIntersectionMode() = 1;
2053 sfw->FixSelfIntersectingEdgeMode() = 1;
2054 sfw->FixIntersectingEdgesMode() = 1;
2055 sfw->FixNonAdjacentIntersectingEdgesMode() = 1;
2056 sfw->FixEdgeCurvesMode() = 1;
2058 sfw->ModifyRemoveLoopMode() = 1;
2059 sfw->SetMaxTolerance(1.0);
2061 di << "\n FixReorder = " << (Standard_Integer) sfw->FixReorder();
2062 di << "\n FixDegenerated = " << (Standard_Integer) sfw->FixDegenerated();
2063 di << "\n FixConnected = " << (Standard_Integer) sfw->FixConnected();
2065 di << "\n FixSelfIntersection = " << (Standard_Integer) sfw->FixSelfIntersection();
2068 Draw::Set(argv[6],sfw->FixReorder()) ;
2069 Draw::Set(argv[7],sfw->FixDegenerated()) ;
2070 Draw::Set(argv[8],sfw->FixConnected()) ;
2071 Draw::Set(argv[9],sfw->FixSelfIntersection()) ;
2073 ShapeExtend_Status status = ShapeExtend_OK;
2074 if(sfw->StatusSelfIntersection(status))
2075 di << "\n ShapeExtend_OK : No intersection found";
2077 status = ShapeExtend_FAIL1;
2078 if(sfw->StatusSelfIntersection(status))
2079 di << "\n ShapeExtend_FAIL1 : analysis failed (edge has no pcurve,or no vertices etc.)";
2081 status = ShapeExtend_FAIL2;
2082 if(sfw->StatusSelfIntersection(status))
2083 di << "\n ShapeExtend_FAIL2 : self-intersection was found, but not fixed because of limit of increasing tolerance (MaxTolerance)";
2085 status = ShapeExtend_FAIL3;
2086 if(sfw->StatusSelfIntersection(status))
2087 di << "\n ShapeExtend_FAIL3 : intercestion of non adjacent edges found, but not fixed because of limit of increasing tolerance (MaxTolerance)";
2089 status = ShapeExtend_DONE1;
2090 if(sfw->StatusSelfIntersection(status))
2091 di << "\n ShapeExtend_DONE1 : tolerance of vertex was increased to fix self-intersection";
2093 status = ShapeExtend_DONE2;
2094 if(sfw->StatusSelfIntersection(status))
2095 di << "\n ShapeExtend_DONE2 : vertex was moved to fix self-intersection";
2097 status = ShapeExtend_DONE3;
2098 if(sfw->StatusSelfIntersection(status))
2099 di << "\n ShapeExtend_DONE3 : some edges were removed because of intersection";
2101 status = ShapeExtend_DONE4;
2102 if(sfw->StatusSelfIntersection(status))
2103 di << "\n ShapeExtend_DONE4 : pcurve(s) was(were) modified";
2105 status = ShapeExtend_DONE5;
2106 if(sfw->StatusSelfIntersection(status))
2107 di << "\n ShapeExtend_DONE5 : non adjacent intersection fixed by increasing tolerance of vertex(vertices)";
2109 status = ShapeExtend_DONE6;
2110 if(sfw->StatusSelfIntersection(status))
2111 di << "\n ShapeExtend_DONE6 : tolerance of edge was increased to hide intersection";
2113 status = ShapeExtend_DONE7;
2114 if(sfw->StatusSelfIntersection(status))
2115 di << "\n ShapeExtend_DONE7 : range of some edges was decreased to avoid intersection";
2117 TopoDS_Wire finalwire = sfw->Wire();
2119 DBRep::Set(argv[1],finalwire);
2122 advWA->Load(TopoDS::Wire(finalwire));
2125 BRepBuilderAPI_MakeFace(TopoDS::Wire(finalwire),Standard_True);
2127 DBRep::Set(argv[2],fface);
2129 advWA->SetFace(fface);
2131 TopTools_IndexedMapOfShape fM;
2132 TopExp::MapShapes(finalwire, TopAbs_EDGE, fM);
2134 for(j= 1; j<=fM.Extent(); ++j) {
2135 Standard_Integer num=1;
2136 IntRes2d_SequenceOfIntersectionPoint points2d;
2137 TColgp_SequenceOfPnt points3d;
2139 di << "\n j =" << j << ", CheckSelfIntersectingEdge = " <<
2140 (Standard_Integer) advWA->CheckSelfIntersectingEdge(j, points2d, points3d);
2143 ShapeExtend_Status status = ShapeExtend_FAIL1;
2144 if(advWA->StatusSelfIntersection(status))
2146 status = ShapeExtend_FAIL2;
2147 if(advWA->StatusSelfIntersection(status))
2148 di << "\n No Vertices found in the edge";
2150 status = ShapeExtend_DONE1;
2151 if(advWA->StatusSelfIntersection(status))
2152 di << "\n Self-intersection found in the edge";
2154 num = points2d.Length();
2155 di << "\n No. of self-intersecting edges : " << num;
2157 for(int i=1; i<=num; ++i) {
2158 gp_Pnt pt = points3d(i);
2159 di << "\n Intersecting pt : (" << pt.X() << ", " << pt.Y() << ", " << pt.Z() << ")";
2169 Standard_Integer OCC17480(Draw_Interpretor& di, Standard_Integer n, const char ** a)
2172 cout << "Usage: OCC17480 basic_shape <mode[0:1]>" <<endl;
2176 TopoDS_Shape brep_pipe = DBRep::Get(a[1]);
2178 Standard_Boolean mode = Standard_False;
2179 if(n == 3 && atoi(a[2]) == 1)
2180 mode = Standard_True;
2182 Handle_AIS_Shape ais_pipe = new AIS_Shape( brep_pipe );
2183 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
2184 Handle(AIS2D_InteractiveContext) aContext_2d = Viewer2dTest::GetAIS2DContext();
2186 if(!aContext.IsNull())
2187 aContext->Display(ais_pipe);
2189 if(!aContext_2d.IsNull())
2190 aContext_2d->EraseAll(Standard_True);
2192 gp_Ax3 ax3(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1), gp_Dir(0, 1, 0));
2194 gp_Ax2 ax2 = ax3.Ax2();
2196 HLRAlgo_Projector aProjector = HLRAlgo_Projector(ax2);
2197 Handle_AIS2D_ProjShape myDisplayableShape =
2198 new AIS2D_ProjShape(aProjector, 0, mode, Standard_True);
2200 myDisplayableShape->Add( brep_pipe );
2202 di << "\n Total number of primitives : " << myDisplayableShape->Length();
2204 Handle(Graphic2d_Line) mySectProjLines = myDisplayableShape->GetPrimitives();
2205 Handle(Graphic2d_Line) mySectProjLinesHLR = myDisplayableShape->GetHLPrimitives();
2207 Handle_Standard_Type sty = mySectProjLines->DynamicType();
2208 Handle_Standard_Type sty1 = mySectProjLinesHLR->DynamicType();
2210 di << "\n Class Name = " << (char*)sty->Name();
2211 di << "\n HLR Class Name = " << (char*)sty1->Name();
2212 di << "\n mySectProjLines.IsNull = " << (Standard_Integer) mySectProjLines.IsNull();
2213 di << "\n mySectProjLinesHLR.IsNull = " << (Standard_Integer) mySectProjLinesHLR.IsNull();
2215 Handle(GGraphic2d_SetOfCurves) setCurves;
2216 Handle(Graphic2d_SetOfSegments) setSegments;
2218 if(mySectProjLines->IsKind(STANDARD_TYPE(GGraphic2d_SetOfCurves)))
2220 setCurves = Handle(GGraphic2d_SetOfCurves)::DownCast(mySectProjLines);
2221 di << "\n Number of Curves in set = " << setCurves->Length();
2223 if(mySectProjLines->IsKind(STANDARD_TYPE(Graphic2d_SetOfSegments)))
2225 setSegments = Handle(Graphic2d_SetOfSegments)::DownCast(mySectProjLines);
2226 di << "\n Number of Curves in set = " << setSegments->Length();
2229 Handle(GGraphic2d_SetOfCurves) setCurvesHLR;
2230 Handle(Graphic2d_SetOfSegments) setSegmentsHLR;
2232 if(mySectProjLinesHLR->IsKind(STANDARD_TYPE(GGraphic2d_SetOfCurves)))
2234 setCurvesHLR = Handle(GGraphic2d_SetOfCurves)::DownCast(mySectProjLinesHLR);
2235 di << "\n HLR Number of Curves in set = " << setCurvesHLR->Length();
2237 if(mySectProjLinesHLR->IsKind(STANDARD_TYPE(Graphic2d_SetOfSegments)))
2239 setSegmentsHLR = Handle(Graphic2d_SetOfSegments)::DownCast(mySectProjLinesHLR);
2240 di << "\n HLR Number of Curves in set = " << setSegmentsHLR->Length();
2243 aContext_2d->Display( myDisplayableShape,Standard_True );
2247 void QATelco::Commands(Draw_Interpretor& theCommands) {
2248 char *group = "QATelco";
2250 theCommands.Add ("BUC60842", "BUC60842", __FILE__, BUC60842, group);
2251 theCommands.Add ("BUC60843", "BUC60843 result_shape name_of_circle name_of_curve [ par1 [ tol ] ]", __FILE__, BUC60843, group);
2252 theCommands.Add ("BUC60970", "BUC60970 shape result", __FILE__, BUC60970, group);
2253 theCommands.Add ("BUC60818", "BUC60818", __FILE__, BUC60818, group);
2254 theCommands.Add ("BUC60915", "BUC60915", __FILE__, BUC60915_1, group);
2255 theCommands.Add ("OCC138", "OCC138", __FILE__, OCC138, group);
2256 theCommands.Add ("BUC60821","BUC60821",__FILE__,BUC60821,group);
2257 theCommands.Add ("OCC353","OCC353",__FILE__,OCC353,group);
2258 theCommands.Add ("OCC280","OCC280 hlr=0/1 setsurfecedetail=0/1; set perspecrive view",__FILE__,OCC280,group);
2259 theCommands.Add ("OCC232", "OCC232", __FILE__, OCC232 , group);
2260 theCommands.Add ("OCC138LC", "OCC138LC", __FILE__, OCC138LC, group);
2261 theCommands.Add ("OCC189", "OCC189", __FILE__, OCC189, group);
2262 theCommands.Add ("OCC389", "OCC389 name shape1 [shape2] ...", __FILE__, OCC389, group);
2264 theCommands.Add ("OCC566", "OCC566 shape [ xmin ymin zmin xmax ymax zmax] ; print bounding box", __FILE__, OCC566, group);
2265 theCommands.Add ("OCC570", "OCC570 result", __FILE__, OCC570, group);
2267 theCommands.Add("OCC570mkevol",
2268 "OCC570mkevol result object (then use updatevol) [R/Q/P]; mkevol",
2269 __FILE__, MKEVOL,group);
2270 theCommands.Add("OCC570updatevol",
2271 "OCC570updatevol edge u1 rad1 u2 rad2 ...; updatevol",
2272 __FILE__, UPDATEVOL,group);
2273 theCommands.Add("OCC570updatevollaw",
2274 "OCC570updatevollaw edge u1 rad1 u2 rad2 ...; updatevollaw",
2275 __FILE__, UPDATEVOL,group);
2276 theCommands.Add("OCC570buildevol",
2277 "OCC570buildevol; end of the evol fillet computation",
2278 __FILE__, BUILDEVOL,group);
2280 theCommands.Add ("OCC606", "OCC606 result shape [-t]", __FILE__, OCC606, group);
2282 theCommands.Add ("OCC813", "OCC813 U V", __FILE__, OCC813, group);
2283 theCommands.Add ("OCC814", "OCC814", __FILE__, OCC814, group);
2284 theCommands.Add ("OCC884", "OCC884 result shape [toler [maxtoler]]", __FILE__, OCC884, group);
2285 theCommands.Add ("OCC1188", "OCC1188 imagefile [filltype] : Load image as background", __FILE__, OCC1188, group);
2287 theCommands.Add ("OCC1174_1", "OCC1174_1 shape", __FILE__, OCC1174_1, group);
2288 theCommands.Add ("OCC1174_2", "OCC1174_2 shape", __FILE__, OCC1174_2, group);
2290 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);
2291 theCommands.Add("OCC672_Angle","OCC672_Angle x1 y1 x2 y2 x3 y3 aRadius aText aTxtScale anArrAngle anArrLength txtAngle txtPosH txtPosV",__FILE__,OCC672_Angle,group);
2292 theCommands.Add("OCC672_Diameter","OCC672_Diameter x1 y1 cx cy radius aText aTxtScale anArrAngle anArrLength txtAngle txtPosH txtPosV",__FILE__,OCC672_Diameter,group);
2293 theCommands.Add("OCC672_ShortLength","",__FILE__,OCC672_ShortLength,group);
2295 theCommands.Add ("OCCN1", "OCCN1 angle fuse(1 for boss / 0 for slot) length", __FILE__, OCCN1, group);
2296 theCommands.Add ("OCCN2", "OCCN2", __FILE__, OCCN2, group);
2298 theCommands.Add ("OCC2569", "OCC2569 nbpoles result", __FILE__, OCC2569, group);
2300 theCommands.Add ("OCC1642", "OCC1642 FinalWare FinalFace InitWare InitFace shape FixReorder FixDegenerated FixConnected FixSelfIntersection", __FILE__, OCC1642, group);
2302 theCommands.Add ("OCC17480", "OCC17480 Shape", __FILE__, OCC17480, group);