Integration of OCCT 6.5.0 from SVN
[occt.git] / src / QATelco / QATelco.cxx
CommitLineData
7fd59977 1// File: QATelco.cxx
2// Created: Mon Mar 18 16:17:15 2002
3// Author: QA Admin
4// <qa@umnox.nnov.matra-dtv.fr>
5
6#if defined(WOKC40)
7#define V2D
8#define Viewer2dTest QAViewer2dTest
9#endif
10
11#include <stdio.h>
12
13#include <QATelco.hxx>
14
15#include <Draw_Interpretor.hxx>
16#include <DBRep.hxx>
17#include <DrawTrSurf.hxx>
18#include <AIS_InteractiveContext.hxx>
19#include <ViewerTest.hxx>
20#include <AIS_Shape.hxx>
21#include <TopoDS_Shape.hxx>
22
23#include <Geom_Circle.hxx>
24#include <Geom_Ellipse.hxx>
25#include <Geom_Plane.hxx>
26#include <gp_Pln.hxx>
27#include <Geom2d_Curve.hxx>
28#include <GeomAPI.hxx>
29#include <Geom2dAdaptor_Curve.hxx>
30#include <Geom2dGcc_QualifiedCurve.hxx>
31#include <Geom2dGcc_Lin2d2Tan.hxx>
32#include <Geom2d_Line.hxx>
33#include <BRepBuilderAPI_MakeEdge.hxx>
34#include <TopoDS_Edge.hxx>
35#include <Precision.hxx>
36#include <Geom2d_Circle.hxx>
37#include <Geom2dGcc_MyQCurve.hxx>
38#include <GccEnt_QualifiedCirc.hxx>
39#include <Geom2dGcc_MyL2d2Tan.hxx>
40#include <BRepBuilderAPI_MakeWire.hxx>
41#include <TopExp_Explorer.hxx>
42#include <TopoDS.hxx>
43#include <TopoDS_Wire.hxx>
44#include <BRep_Tool.hxx>
45#include <gp_Circ.hxx>
46#include <BRepOffsetAPI_MakePipeShell.hxx>
47#include <AIS_Trihedron.hxx>
48#include <Geom_Axis2Placement.hxx>
49#include <V3d_View.hxx>
50#include <ViewerTest_Tool.hxx>
51#include <BRepBuilderAPI_MakeVertex.hxx>
52#include <AIS_LengthDimension.hxx>
53#include <AIS_RadiusDimension.hxx>
54#include <BRepPrimAPI_MakeBox.hxx>
55#include <GeomAdaptor_Surface.hxx>
56#include <Extrema_ExtPS.hxx>
57#include <Geom_CartesianPoint.hxx>
58#include <Geom2d_CartesianPoint.hxx>
59#include <Geom2dGcc_Circ2d3Tan.hxx>
60#include <Aspect_Window.hxx>
61
62#include <TopoDS_Compound.hxx>
63#include <TopoDS_CompSolid.hxx>
64#include <StdSelect_ShapeTypeFilter.hxx>
65
66#include <QATelco_MyText.hxx>
67
68#if defined(WOKC40)
69#include <QAViewer2dTest.hxx>
70#include <QAViewer2dTest_DoubleMapOfInteractiveAndName.hxx>
71#else
72#include <Viewer2dTest.hxx>
73#include <Viewer2dTest_DoubleMapOfInteractiveAndName.hxx>
74#endif
75
76#include <Prs3d_Projector.hxx>
77#include <HLRAlgo_Projector.hxx>
78#include <AIS2D_ProjShape.hxx>
79#include <AIS2D_InteractiveContext.hxx>
80#include <Standard_ErrorHandler.hxx>
81
82#if ! defined(WNT)
83#if defined(WOKC40)
84extern QAViewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D();
85#else
86extern Viewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D();
87#endif
88#else
89Standard_EXPORT Viewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D();
90#endif
91
92#include <GGraphic2d_SetOfCurves.hxx>
93#include <Graphic2d_SetOfSegments.hxx>
94
95#include <Graphic3d_NameOfFont.hxx>
96
97static Standard_Integer BUC60842 (Draw_Interpretor& di, Standard_Integer /*argc*/,const char ** /*argv*/)
98{
99 Standard_Character abuf[16];
100 //Standard_Character * abuf = new Standard_Character[16];
101
102 Standard_CString st = abuf;
103
104 Handle(Geom_Circle) cir = new Geom_Circle (gp_Ax2 (gp_Pnt (823.687192, 502.366825, 478.960440), gp_Dir (0.173648, 0.984808, 0.000000), gp_Dir (-0.932169, 0.164367, -0.322560)), 50);
105 Handle(Geom_Ellipse) ell = new Geom_Ellipse (gp_Ax2 (gp_Pnt (1262.224429, 425.040878, 363.609716), gp_Dir (0.173648, 0.984808, 0.000000), gp_Dir (-0.932169, 0.164367, -0.322560)), 150, 100);
106 Handle(Geom_Plane) plne = new Geom_Plane (gp_Ax3 (gp_Ax2 (gp_Pnt (1262.224429, 425.040878, 363.609716), gp_Dir (0.173648, 0.984808, 0.000000), gp_Dir (-0.932169, 0.164367, -0.322560))));
107
108 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
109
110 gp_Pln pln = plne->Pln();
111 Handle(Geom2d_Curve) curve2d = GeomAPI::To2d (ell, pln);
112 sprintf(abuf,"ell");
113 DrawTrSurf::Set(st,curve2d);
114 if(!aContext.IsNull()) {
115 Handle(AIS_Shape) aisp =
116 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(curve2d, pln)).Edge());
117 aContext->Display (aisp);
118 }
119
120 Handle(Geom2d_Curve) fromcurve2d = GeomAPI::To2d (cir, pln);
121 sprintf(abuf,"cil");
122 DrawTrSurf::Set(st,fromcurve2d);
123 if(!aContext.IsNull()) {
124 Handle(AIS_Shape) aisp =
125 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(fromcurve2d, pln)).Edge());
126 aContext->Display (aisp);
127 }
128
129 Geom2dAdaptor_Curve acur (curve2d), afromcur (fromcurve2d);
130 Geom2dGcc_QualifiedCurve qcur (acur, GccEnt_outside);
131 Geom2dGcc_QualifiedCurve qfromcur (afromcur, GccEnt_outside);
132 Geom2dGcc_Lin2d2Tan lintan (qcur, qfromcur, 0.1, 0.0, 0.0);
133 Standard_Integer i=0;
134 for(i=0;i<lintan.NbSolutions();i++) {
135 sprintf(abuf,"lintan_%d",i);
136 Handle(Geom2d_Line) glin = new Geom2d_Line(lintan.ThisSolution(i));
137 DrawTrSurf::Set(st,glin);
138 if(!aContext.IsNull()) {
139 Handle(AIS_Shape) aisp =
140 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(glin, pln)).Edge()); aContext->Display (aisp);
141 }
142 }
143 di << " Is Done = \n" << (Standard_Integer) lintan.IsDone();
144 return 0;
145}
146
147static Standard_Integer BUC60843 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
148{
149 if (argc != 4 && argc != 5 && argc != 6 && argc != 7) {
150 di << "Usage : " << argv[0] << "result_shape name_of_circle name_of_curve [ par1 [ tol ] ]" << "\n";
151 return 1;
152 }
153
154 Standard_Real par1 = 0.0, par2 = 0.0;
155 Standard_Real tol = Precision::Angular();
156 if (argc >= 5)
157 par1 = atof(argv[4]);
158 if (argc == 6)
159 par2 = atof(argv[5]);
160 if (argc == 7)
161 tol = atof(argv[6]);
162 Handle(Geom2d_Curve) aCur2d1 = DrawTrSurf::GetCurve2d(argv[2]);
163 Handle(Geom2d_Curve) aCur2d2 = DrawTrSurf::GetCurve2d(argv[3]);
164 if (aCur2d1.IsNull() || aCur2d2.IsNull()) {
165 di << "Faulty : not curves" << "\n";
166 return 1;
167 }
168 Standard_Boolean c1IsCircle = Standard_False;
169 Handle(Geom2d_Circle) aCir2d = Handle(Geom2d_Circle)::DownCast(aCur2d1);
170 if (!aCir2d.IsNull()) {
171 c1IsCircle = Standard_True;
172 if (argc == 6) tol = atof(argv[5]);
173 }
174 if(c1IsCircle) {
175 Geom2dAdaptor_Curve acur(aCur2d2);
176 Geom2dGcc_MyQCurve qcur(acur, GccEnt_unqualified);
177 GccEnt_QualifiedCirc qfromcur(aCir2d->Circ2d(), GccEnt_unqualified);
178 Geom2dGcc_MyL2d2Tan lintan(qfromcur, qcur , par1, tol);
179 if (lintan.IsDone()) {
180 gp_Lin2d lin = lintan.ThisSolution();
181 Handle(Geom2d_Line) glin = new Geom2d_Line(lin);
182 DrawTrSurf::Set(argv[1], glin);
183 } else {
184 di << "Faulty : tangent line is not done." << "\n";
185 }
186 }
187 else {
188 Geom2dAdaptor_Curve acur1(aCur2d1);
189 Geom2dAdaptor_Curve acur2(aCur2d2);
190 Geom2dGcc_MyQCurve qcur1(acur1, GccEnt_unqualified);
191 Geom2dGcc_MyQCurve qcur2(acur2, GccEnt_unqualified);
192 Geom2dGcc_MyL2d2Tan lintan(qcur1, qcur2 , par1, par2, tol);
193 if (lintan.IsDone()) {
194 gp_Lin2d lin = lintan.ThisSolution();
195 Handle(Geom2d_Line) glin = new Geom2d_Line(lin);
196 DrawTrSurf::Set(argv[1], glin);
197 } else {
198 di << "Faulty : tangent line is not done." << "\n";
199 }
200 }
201 return 0;
202}
203
204static Standard_Integer BUC60970 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
205{
206 if(argc!=3)
207 {
208 di << "Usage : " << argv[0] << " shape result" <<"\n";
209 return 1;
210 }
211
212 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
213 if(aContext.IsNull()) {
214 di << "use 'vinit' command before " << argv[0] << "\n";
215 return 1;
216 }
217
218 TopoDS_Shape aResult = DBRep::Get(argv[1]);
219
220 BRepBuilderAPI_MakeWire bRepSpineWire;
221 TopExp_Explorer exp_(aResult, TopAbs_WIRE);
222
223 Standard_Integer i = 0;
224 for(;exp_.More();exp_.Next()){
225 i++;
226 bRepSpineWire.Add(TopoDS::Wire(exp_.Current()));
227 }
228
229 //printf("total no of wires are ............. %d\n", i);
230 di << "total no of wires are ............. " << i << "\n";
231
232 TopoDS_Wire spineWire = bRepSpineWire.Wire();
233 aContext->Display(new AIS_Shape(spineWire));
234
235 DBRep::Set("slineW",spineWire);
236
237 TopExp_Explorer spineWireExp(spineWire, TopAbs_EDGE);
238 Standard_Real first, last;
239 Handle_Geom_Curve curl_ = BRep_Tool::Curve(TopoDS::Edge(spineWireExp.Current()), first, last);
240 gp_Pnt firstPnt;
241 gp_Vec tanVec;
242 curl_->D1(first, firstPnt, tanVec);
243 tanVec.Normalize();
244 gp_Dir tanDir(tanVec.X(), tanVec.Y(), tanVec.Z());
245 gp_Ax2 gpAx2(firstPnt, tanDir);
246 gp_Circ gpCirc(gpAx2, 2.5);
247 BRepBuilderAPI_MakeWire aMWire(BRepBuilderAPI_MakeEdge(new Geom_Circle(gpCirc)).Edge());
248 TopoDS_Wire topoWire(aMWire);
249 aContext->Display(new AIS_Shape(topoWire));
250
251 DBRep::Set("topoW",topoWire);
252
253 BRepOffsetAPI_MakePipeShell bRepPipe(spineWire);
254 bRepPipe.Add(topoWire);
255 bRepPipe.Build();
256
257 aContext->Display(new AIS_Shape(bRepPipe.Shape()));
258
259 DBRep::Set(argv[2],bRepPipe.Shape());
260
261 return 0;
262}
263
264static Standard_Integer BUC60818(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
265{
266 if(argc!=1)
267 {
268 di << "Usage : " << argv[0] << "\n";
269 return -1;
270 }
271
272 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
273 if(myAISContext.IsNull())
274 {
275 di << "use 'vinit' command before " << argv[0] << "\n";
276 return -1;
277 }
278
279 // TRIHEDRON
280 Handle(AIS_Trihedron) aTrihedron;
281 Handle(Geom_Axis2Placement) aTrihedronAxis=new Geom_Axis2Placement(gp::XOY());
282 aTrihedron=new AIS_Trihedron(aTrihedronAxis);
283 myAISContext->Display(aTrihedron);
284
285 myAISContext->OpenLocalContext();
286 myAISContext->Load(aTrihedron,0);
287
288 myAISContext->SetAutomaticHilight( Standard_False );
289
290 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
291 double Xv,Yv;
292 myV3dView->Project(0,0,0,Xv,Yv);
293
294 Standard_Integer Xp,Yp;
295 myV3dView->Convert(Xv,Yv,Xp,Yp);
296
297 myAISContext->MoveTo( Xp,Yp, myV3dView );
298 myAISContext->MoveTo( Xp,Yp, myV3dView );
299
300 if (myAISContext->HasDetected( ))
301 di << "has detected shape : OK" << "\n";
302 else di << "has detected shape : bugged - Faulty " << "\n";
303
304 myAISContext->SetAutomaticHilight( Standard_True );
305
306 return 0;
307}
308
309static Standard_Integer BUC60915_1(Draw_Interpretor& di, Standard_Integer argc, const char ** /*argv*/)
310{
311 if (argc > 1) {
312 di<<"Function don't has parameters"<<"\n";
313 return 1;
314 }
315
316 Handle(AIS_InteractiveContext) context= ViewerTest_Tool::MakeContext ("buc60915");
317 ViewerTest_Tool::InitViewerTest (context);
318
319 //The following dimesion code has problems regarding arrow_size. The desired effect is not produced.
320 /***************************************/
321 //First view
322 /***************************************/
323 gp_Pnt p1 = gp_Pnt(602.51,50.,0.);
324 gp_Pnt p2 = gp_Pnt(602.51,200.,0.);
325 gp_Pnt p3 = gp_Pnt(102.51,200.,0.);
326 gp_Pnt p4 = gp_Pnt(102.51,170.,0.);
327 gp_Pnt p5 = gp_Pnt(502.51,170.,0.);
328 gp_Pnt p6 = gp_Pnt(502.51,80.,0.);
329 gp_Pnt p7 = gp_Pnt(102.51,80.,0.);
330 gp_Pnt p8 = gp_Pnt(102.51,50.,0.);
331 TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(p1);
332 TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(p2);
333 TopoDS_Vertex V3 = BRepBuilderAPI_MakeVertex(p3);
334 TopoDS_Vertex V4 = BRepBuilderAPI_MakeVertex(p4);
335 TopoDS_Vertex V5 = BRepBuilderAPI_MakeVertex(p5);
336 TopoDS_Vertex V6 = BRepBuilderAPI_MakeVertex(p6);
337 TopoDS_Vertex V7 = BRepBuilderAPI_MakeVertex(p7);
338 TopoDS_Vertex V8 = BRepBuilderAPI_MakeVertex(p8);
339 gp_Pnt plnpt(0, 0, 0);
340 gp_Dir plndir(0, 0, 1);
341 Handle(Geom_Plane) pln = new Geom_Plane(plnpt,plndir);
342 /***************************************/
343 //dimension "L 502.51"
344 /***************************************/
345 Handle(AIS_LengthDimension) len = new AIS_LengthDimension(V2, V3, pln, 502.51, "502.51");
346 len->SetPosition(gp_Pnt(350, 250, 0));
347 len->SetTypeOfDist(AIS_TOD_Horizontal);
348 len->SetArrowSize(30.0);
349 context->Display(len);
350 /***************************************/
351 //dimension "L 90"
352 /***************************************/
353 Handle(AIS_LengthDimension) len1 = new AIS_LengthDimension(V4, V7, pln, 90, "90");
354 len1->SetPosition(gp_Pnt(70, 120, 0));
355 len1->SetTypeOfDist(AIS_TOD_Vertical);
356 len1->SetArrowSize(100.0);
357 context->Display(len1);
358 /***************************************/
359 //dimension "L 150"
360 /***************************************/
361 Handle(AIS_LengthDimension) len2 = new AIS_LengthDimension(V1, V2, pln, 150, "150",gp_Pnt(650, 120, 0),DsgPrs_AS_BOTHAR,
362 AIS_TOD_Vertical, 100.0 );
363 //len2->SetPosition(gp_Pnt(650, 120, 0));
364 //len2->SetTypeOfDist(AIS_TOD_Vertical);
365 //len1->SetArrowSize(100.0);
366 context->Display(len2);
367 /***************************************/
368 //dimension "R 88.58"
369 /***************************************/
370 gp_Circ cir = gp_Circ(gp_Ax2(gp_Pnt(191.09, -88.58, 0), gp_Dir(0, 0, 1)), 88.58);
371 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(cir,gp_Pnt(191.09,0,0.),gp_Pnt(191.09,-177.16,0.) );
372 Handle(AIS_RadiusDimension) dim1 = new AIS_RadiusDimension(E1,88.58, "R 88.58",gp_Pnt(-30.0, -80.0, 0.0),DsgPrs_AS_BOTHAR,
373 100.0 );
374 context->Display(dim1);
375 /***************************************/
376 //dimension "R 43.80"
377 /***************************************/
378 gp_Circ cir1 = gp_Circ(gp_Ax2(gp_Pnt(191.09, -88.58, 0), gp_Dir(0, 0, 1)), 43.80);
379 TopoDS_Edge E_cir1 = BRepBuilderAPI_MakeEdge(cir1);
380 dim1 = new AIS_RadiusDimension(E_cir1,43.80, "R 43.80",gp_Pnt(0.0, -50.0, 0.0),DsgPrs_AS_LASTAR, 60.0 );
381 context->Display(dim1);
382 /***************************************/
383 //dimension "R 17.86"
384 /***************************************/
385 gp_Circ cir2 = gp_Circ(gp_Ax2(gp_Pnt(566.11, -88.58, 0), gp_Dir(0, 0, -1)), 17.86);
386 TopoDS_Edge E_cir2 = BRepBuilderAPI_MakeEdge(cir2);
387 dim1 = new AIS_RadiusDimension(E_cir2,17.86, "R 17.86",gp_Pnt(600.0, -50.0, 0.0),DsgPrs_AS_LASTAR, 40.0 );
388 context->Display(dim1);
389
390 return 0;
391}
392
393static Standard_Integer OCC138 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
394{
395 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
396 if(aContext.IsNull()) {
397 di << "use 'vinit' command before " << argv[0] << "\n";
398 return 1;
399 }
400
401 BRepPrimAPI_MakeBox box1(gp_Pnt(0, 0, 0), gp_Pnt(100, 100, 100));
402 BRepPrimAPI_MakeBox box2(gp_Pnt(120, 120, 120), gp_Pnt(300, 300,300));
403 BRepPrimAPI_MakeBox box3(gp_Pnt(320, 320, 320), gp_Pnt(500, 500,500));
404
405 Handle_AIS_Shape ais1 = new AIS_Shape(box1.Shape());
406 Handle_AIS_Shape ais2 = new AIS_Shape(box2.Shape());
407 Handle_AIS_Shape ais3 = new AIS_Shape(box3.Shape());
408
409 aContext->Display(ais1);
410 aContext->Display(ais2);
411 aContext->Display(ais3);
412
413 aContext->AddOrRemoveCurrentObject(ais1);
414 aContext->AddOrRemoveCurrentObject(ais2);
415 aContext->AddOrRemoveCurrentObject(ais3);
416
417 di << "\n No of currents = " << aContext->NbCurrents();
418
419 aContext->InitCurrent();
420
421 int count = 1;
422 while(aContext->MoreCurrent())
423 {
424 di << "\n count is = " << count++;
425 Handle_AIS_InteractiveObject ais = aContext->Current();
426 aContext->AddOrRemoveCurrentObject(ais);
427 aContext->InitCurrent();
428 }
429
430 return 0;
431}
432
433static Standard_Integer BUC60821(Draw_Interpretor& di, Standard_Integer argc,const char ** argv )
434{
435
436 if(argc < 3){
437 di << "Usage: " << argv[0] << " TextHight1 TextHight2 TextHight2";
438 return(-1);
439 }
440
441 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
442
443 if(aContext.IsNull())
444 {
445 di << "use 'vinit' command before " << argv[0] << "\n";
446 return -1;
447 }
448
449 Handle(QATelco_MyText) txt1 = new QATelco_MyText("Gosha1",gp_Pnt(0,0,0),Graphic3d_NOF_ASCII_SIMPLEX,Quantity_NOC_RED,atoi(argv[1]));
450 aContext->Display(txt1);
451
452 Handle(QATelco_MyText) txt2 = new QATelco_MyText("Gosha2",gp_Pnt(0,0,100),Graphic3d_NOF_ASCII_SIMPLEX,Quantity_NOC_YELLOW,atoi(argv[2]));
453 aContext->Display(txt2);
454
455 Handle(QATelco_MyText) txt3 = new QATelco_MyText("Gosha3",gp_Pnt(0,100,100),Graphic3d_NOF_ASCII_SIMPLEX,Quantity_NOC_SKYBLUE,atoi(argv[3]));
456 aContext->Display(txt3);
457
458 return 0;
459}
460
461static int geom_get_2Dpt_from_3Dpt(const gp_Pnt& pnt3d, const gp_Pln& pln, gp_Pnt2d& pnt2d)
462{
463 int ret = 0;
464 Handle_Geom_Plane gpln = new Geom_Plane(pln);
465 GeomAdaptor_Surface adsur(gpln);
466 Extrema_ExtPS extps(pnt3d, adsur, 0.001, 0.001);
467 if( extps.IsDone() )
468 {
469 int index;
470 for(index=1; index<= extps.NbExt(); index++ )
471 {
472 Extrema_POnSurf pons = extps.Point(index);
473 Standard_Real U, V;
474 pons.Parameter(U, V);
475 pnt2d.SetCoord(U, V);
476 ret = 1;
477 }
478 }
479 return ret;
480}
481
482static Standard_Integer OCC353 (Draw_Interpretor& di, Standard_Integer , const char ** )
483{
484 gp_Ax2 ax21( gp_Pnt(100,0,0), gp_Dir(0,0,1) );
485 Handle_Geom_Circle h_cir1 = new Geom_Circle( ax21, 25 );
486
487 gp_Ax2 ax22( gp_Pnt(-100,0,0), gp_Dir(0,0,1) );
488 Handle_Geom_Circle h_cir2 = new Geom_Circle( ax22, 25 );
489
490 gp_Pln refpln( gp_Pnt(0,0,0), gp_Dir(0,0,1) );
491 Handle_Geom2d_Curve cir2d1 = GeomAPI::To2d(h_cir1, refpln);
492 Handle_Geom2d_Curve cir2d2 = GeomAPI::To2d(h_cir2, refpln);
493
494 Geom2dAdaptor_Curve adop1(cir2d1);
495 Geom2dAdaptor_Curve adop2(cir2d2);
496
497 Geom2dGcc_QualifiedCurve qcur1(adop1, GccEnt_enclosing);
498 Geom2dGcc_QualifiedCurve qcur2(adop2, GccEnt_enclosing);
499
500 Handle_Geom_CartesianPoint h_carpt = new Geom_CartesianPoint(0,175,0);
501
502 gp_Pnt pt3d = h_carpt->Pnt();
503 gp_Pnt2d pt2d;
504 geom_get_2Dpt_from_3Dpt(pt3d, refpln, pt2d);
505
506 Standard_CString st;
507 st = "cir2d1";
508 DrawTrSurf::Set(st,cir2d1);
509 st = "cir2d2";
510 DrawTrSurf::Set(st,cir2d2);
511 st = "pt2d";
512 DrawTrSurf::Set(st,pt2d);
513
514 Handle_Geom2d_CartesianPoint pt = new Geom2d_CartesianPoint(pt2d);
515 Geom2dGcc_Circ2d3Tan sol( qcur1, qcur2, pt, 0.001, 0.0, 0.0);
516
517 int res = 0;
518 Standard_Character buf[10];
519 buf[0] = '\0';
520
521 if( sol.IsDone() ) {
522 res = sol.NbSolutions();
523 for(Standard_Integer i=1;i<=res;i++) {
524 Handle(Geom2d_Circle) aC = new Geom2d_Circle(sol.ThisSolution(i));
525 sprintf(buf,"Result_%d",i);
526 st = buf;
527 DrawTrSurf::Set(st,aC);
528 }
529 }
530 else
531 di << "\n Faulty: no solutions found ";
532 //printf("\n Faulty: no solutions found ");
533
534 //printf("\n Num of solutions are %d ", res );
535 di << "\n Num of solutions are " << res << " ";
536
537 return 0;
538}
539
540static Standard_Integer OCC280 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
541{
542 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
543 if(aContext.IsNull())
544 {
545 di << "use 'vinit' command before " << argv[0] << "\n";
546 return -1;
547 }
548 if ( argc != 3) {
549 di << "ERROR : Usage : " << argv[0] << " hlr=0/1 setsurfecedetail=0/1; set perspecrive view" << "\n";
550 return 1;
551 }
552
553 Standard_Integer HLR = atoi(argv[1]);
554 if (HLR != 0) {
555 HLR = 1;
556 }
557
558 Handle(V3d_View) aView = ViewerTest::CurrentView();
559
560 Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
561 if(atoi(argv[2])) {
562 aViewer->SetDefaultSurfaceDetail(V3d_TEX_ALL);
563 }
564 aViewer->SetDefaultTypeOfView(V3d_PERSPECTIVE);
565
566 Handle(Aspect_Window) asp = aView->Window();
567 aViewer->SetViewOff(aView);
568 aView->Remove();
569
570 Handle(V3d_View) aNewView = aViewer->CreateView();
571 ViewerTest::CurrentView(aNewView);
572
573 aNewView->SetWindow(asp);
574 if (!asp->IsMapped()) asp->Map();
575
576 aNewView->Update();
577
578 if (HLR == 1) {
579 di << "HLR" << "\n";
580 aNewView->SetDegenerateModeOff();
581 }
582
583 return 0;
584}
585
586static Standard_Integer OCC232 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
587{
588 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
589 if(aContext.IsNull()) {
590 di << "use 'vinit' command before " << argv[0] << "\n";
591 return 1;
592 }
593
594 BRep_Builder builder;
595 TopoDS_Compound comp;
596 TopoDS_CompSolid cs1, cs2;
597
598 builder.MakeCompound(comp);
599 builder.MakeCompSolid(cs1);
600 builder.MakeCompSolid(cs2);
601
602 TopoDS_Shape sh1 = BRepPrimAPI_MakeBox(gp_Pnt(0, 0, 0), 100, 100, 100).Shape();
603 TopoDS_Shape sh2 = BRepPrimAPI_MakeBox(gp_Pnt(100, 0, 0), 100, 100, 100).Shape();
604 TopoDS_Shape sh3 = BRepPrimAPI_MakeBox(gp_Pnt(200, 0, 0), 100, 100, 100).Shape();
605 builder.Add(cs1, sh1);
606 builder.Add(cs1, sh2);
607 builder.Add(cs1, sh3);
608
609 TopoDS_Shape sh4 = BRepPrimAPI_MakeBox(gp_Pnt(0, 500, 0), 100, 100, 100).Shape();
610 TopoDS_Shape sh5 = BRepPrimAPI_MakeBox(gp_Pnt(100, 500, 0), 100, 100, 100).Shape();
611 TopoDS_Shape sh6 = BRepPrimAPI_MakeBox(gp_Pnt(200, 500, 0), 100, 100, 100).Shape();
612
613 builder.Add(cs2, sh4);
614 builder.Add(cs2, sh5);
615 builder.Add(cs2, sh6);
616
617 builder.Add(comp, cs1);
618 builder.Add(comp, cs2);
619
620 Handle_AIS_Shape ais = new AIS_Shape(comp);
621 aContext->Display(ais);
622
623 TopExp_Explorer exp(comp, TopAbs_COMPSOLID);
624 while(exp.More())
625 {
626 //printf("\n TopAbs_COMPSOLID is there \n");
627 di << "\n TopAbs_COMPSOLID is there \n";
628 exp.Next();
629 }
630
631 Handle (StdSelect_ShapeTypeFilter) filt = new StdSelect_ShapeTypeFilter(TopAbs_COMPSOLID);
632 aContext->AddFilter(filt);
633 aContext->CloseAllContexts();
634 aContext->OpenLocalContext();
635 aContext->ActivateStandardMode(TopAbs_SOLID);
636
637 return 0;
638}
639
640static Standard_Integer OCC138LC (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
641{
642 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
643 if(aContext.IsNull()) {
644 di << "use 'vinit' command before " << argv[0] << "\n";
645 return 1;
646 }
647
648 BRepPrimAPI_MakeBox box1(gp_Pnt(0, 0, 0), gp_Pnt(100, 100, 100));
649 BRepPrimAPI_MakeBox box2(gp_Pnt(120, 120, 120), gp_Pnt(300, 300,300));
650 BRepPrimAPI_MakeBox box3(gp_Pnt(320, 320, 320), gp_Pnt(500, 500,500));
651
652 Handle_AIS_Shape ais1 = new AIS_Shape(box1.Shape());
653 Handle_AIS_Shape ais2 = new AIS_Shape(box2.Shape());
654 Handle_AIS_Shape ais3 = new AIS_Shape(box3.Shape());
655
656 aContext->Display(ais1);
657 aContext->Display(ais2);
658 aContext->Display(ais3);
659
660 aContext->AddOrRemoveSelected(ais1);
661 aContext->AddOrRemoveSelected(ais2);
662 aContext->AddOrRemoveSelected(ais3);
663
664 di << "\n No of selected = " << aContext->NbSelected();
665
666 aContext->InitSelected();
667
668 int count = 1;
669 while(aContext->MoreSelected())
670 {
671 di << "\n count is = %d" << count++;
672 Handle_AIS_InteractiveObject ais = aContext->SelectedInteractive();
673 aContext->AddOrRemoveSelected(ais);
674 aContext->InitSelected();
675 }
676
677 return 0;
678}
679
680static Standard_Integer OCC189 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
681{
682 Handle(AIS_InteractiveContext) aContext1 = ViewerTest::GetAISContext();
683 if(aContext1.IsNull()) {
684 di << "use 'vinit' command before " << argv[0] << "\n";
685 return 1;
686 }
687 Handle(AIS_InteractiveContext) aContext2 = ViewerTest::GetAISContext();
688 if(aContext2.IsNull()) {
689 di << "use 'vinit' command before " << argv[0] << "\n";
690 return 1;
691 }
692
693 BRepPrimAPI_MakeBox box1(gp_Pnt(0, 0, 0), gp_Pnt(100, 100, 100));
694 BRepPrimAPI_MakeBox box2(gp_Pnt(120, 120, 120), gp_Pnt(300, 300, 300));
695 BRepPrimAPI_MakeBox box3(gp_Pnt(320, 320, 320), gp_Pnt(500, 500, 500));
696
697 Handle_AIS_Shape ais1 = new AIS_Shape(box1.Shape());
698 Handle_AIS_Shape ais2 = new AIS_Shape(box2.Shape());
699 Handle_AIS_Shape ais3 = new AIS_Shape(box3.Shape());
700
701 aContext1->Display(ais1);
702 aContext1->Display(ais2);
703 aContext1->Display(ais3);
704
705 aContext2->Display(ais1);
706 aContext2->Display(ais2);
707 aContext2->Display(ais3);
708
709 aContext1->AddOrRemoveCurrentObject(ais1);
710 aContext1->AddOrRemoveCurrentObject(ais2);
711 aContext1->AddOrRemoveCurrentObject(ais3);
712
713 di << "\n Stage : 1";
714 di << "\n \t No of currents on aContext1 = " << aContext1->NbCurrents();
715 di << "\n \t No of currents on aContext2 = " << aContext2->NbCurrents() << "\n\n";
716
717 di << "\n aContext1->IsCurrent = " << (Standard_Integer) aContext1->IsCurrent(ais1) << ", aContext2->IsCurrent = " << (Standard_Integer) aContext2->IsCurrent(ais1) << " ";
718
719 aContext2->AddOrRemoveCurrentObject(ais1);
720 aContext2->AddOrRemoveCurrentObject(ais2);
721 aContext2->AddOrRemoveCurrentObject(ais3);
722
723 di << "\n Stage : 2";
724 di << "\n \t No of currents on aContext1 = " << aContext1->NbCurrents();
725 di << "\n \t No of currents on aContext2 = " << aContext2->NbCurrents() << "\n\n";
726
727 aContext1->InitCurrent();
728 int count1 = 1;
729 while(aContext1->MoreCurrent())
730 {
731 di << "\n count1 is = " << count1++;
732 Handle_AIS_InteractiveObject ais = aContext1->Current();
733 aContext1->AddOrRemoveCurrentObject(ais);
734 aContext1->InitCurrent();
735 }
736
737 di << "\n Stage : 3";
738 di << "\n \t No of currents on aContext1 = " << aContext1->NbCurrents();
739 di << "\n \t No of currents on aContext2 = " << aContext2->NbCurrents() << "\n\n";
740
741 aContext2->InitCurrent();
742 int count2 = 1;
743 while(aContext2->MoreCurrent())
744 {
745 di << "\n count2 is = " << count2++;
746 Handle_AIS_InteractiveObject ais = aContext2->Current();
747 aContext2->AddOrRemoveCurrentObject(ais);
748 aContext2->InitCurrent();
749 }
750
751 di << "\n\n Stage : 4";
752 di << "\n \t No of currents on aContext1 = " << aContext1->NbCurrents();
753 di << "\n \t No of currents on aContext2 = " << aContext2->NbCurrents();
754
755 return 0;
756}
757
758static Standard_Integer OCC389 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
759{
760 if (argc < 3)
761 {
762 di<<"Usage: " << argv[0] << " name shape1 [shape2] ..."<<"\n";
763 return 1;
764 }
765
766 //if (Viewer2dTest::CurrentView().IsNull())
767 //{
768 // cout << "2D AIS Viewer Initialization ..." << endl;
769 // Viewer2dTest::ViewerInit();
770 // cout << "Done" << endl;
771 //}
772
773 di<<"Begin!"<<"\n";
774 Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
775 di<<"Check InteractiveContext"<<"\n";
776
777 if(aContext.IsNull()) {
778 di << "use 'v2dinit' command before " << argv[0] << "\n";
779 return 1;
780 }
781
782 di<<"CloseLocalContext"<<"\n";
783 aContext->CloseLocalContext();
784
785 di<<"OpenLocalContext"<<"\n";
786 aContext->OpenLocalContext();
787
788 TCollection_AsciiString name(argv[1]);
789
790 di<<"Found name"<<"\n";
791 Standard_Boolean IsBound = GetMapOfAIS2D().IsBound2(name);
792 if (IsBound)
793 {
794 di<<"Already displayed"<<"\n";
795 }
796 else // Create the AIS2D_ProjShape from a name
797 {
798 di<<"Create the AIS2D_ProjShape from a name; (1)"<<"\n";
799 Prs3d_Projector aPrs3dProjector(Standard_False, 1, -1.0,0.2,0.3, 0.0, 0.0, 0.0, -0.0,0.0,1.0);
800 di<<"Create the AIS2D_ProjShape from a name; (2)"<<"\n";
801 HLRAlgo_Projector aProjector = aPrs3dProjector.Projector();
802 di<<"Create the AIS2D_ProjShape from a name; (3)"<<"\n";
803 Handle(AIS2D_ProjShape) shp_2d =
804 new AIS2D_ProjShape(aProjector, 0, Standard_False, Standard_True);
805 di<<"Create the AIS2D_ProjShape from a name; (4)"<<"\n";
806
807 Standard_Integer i;
808 Standard_Boolean isValid = Standard_False;
809 for (i = 2; i < argc; i++)
810 {
811 di<<"i="<< i-1 <<"\n";
812 TopoDS_Shape aShape = DBRep::Get(argv[i]);
813 if (!aShape.IsNull())
814 {
815 shp_2d->Add( aShape );
816 di<<"Added shape: "<<argv[i]<<"\n";
817 isValid = Standard_True;
818 }
819 }
820
821 if (isValid)
822 {
823 di<<"Now start displaying..."<<"\n";
824 aContext->Display(shp_2d, 1, 1, Standard_True);
825
826 GetMapOfAIS2D().Bind(shp_2d, name);
827 }
828 }
829
830 aContext->UpdateCurrentViewer();
831 return 0;
832}
833
834#include <BRepBndLib.hxx>
835#include <Draw.hxx>
836//=======================================================================
837//function : OCC566
838//purpose :
839//=======================================================================
840static Standard_Integer OCC566(Draw_Interpretor& di,Standard_Integer n,const char ** a)
841{
842 if (n < 2) {
843 di<<"Usage: " << a[0] << " shape [ xmin ymin zmin xmax ymax zmax]"<<"\n";
844 return 1;
845 }
846 TopoDS_Shape S = DBRep::Get(a[1]);
847 if (S.IsNull()) return 1;
848 Bnd_Box B;
849 BRepBndLib::AddClose(S,B);
850 Standard_Real axmin,aymin,azmin,axmax,aymax,azmax;
851 B.Get(axmin,aymin,azmin,axmax,aymax,azmax);
852 di << axmin<<" "<< aymin<<" "<< azmin<<" "<< axmax<<" "<< aymax<<" "<< azmax;
853 if (n >= 8) {
854 Draw::Set(a[2],axmin) ;
855 Draw::Set(a[3],aymin) ;
856 Draw::Set(a[4],azmin) ;
857 Draw::Set(a[5],axmax) ;
858 Draw::Set(a[6],aymax) ;
859 Draw::Set(a[7],azmax) ;
860 }
861 return 0;
862}
863
864#include <BRepFilletAPI_MakeFillet.hxx>
865//=======================================================================
866//function : OCC570
867//purpose :
868//=======================================================================
869static Standard_Integer OCC570 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
870{
871 if (argc < 2) {
872 di<<"Usage: " << argv[0] << " result"<<"\n";
873 return 1;
874 }
875
876 BRepPrimAPI_MakeBox mkBox(100.,100.,100.);
877 TopoDS_Shape aBox = mkBox.Shape();
878
879 TopExp_Explorer aExp;
880 aExp.Init(aBox,TopAbs_WIRE);
881 if (aExp.More())
882 {
883 TopoDS_Shape aWire = aExp.Current();
884
885 aExp.Init(aWire,TopAbs_EDGE);
886 TopoDS_Edge e1 = TopoDS::Edge(aExp.Current()); aExp.Next();
887 TopoDS_Edge e2 = TopoDS::Edge(aExp.Current()); aExp.Next();
888 TopoDS_Edge e3 = TopoDS::Edge(aExp.Current()); aExp.Next();
889 TopoDS_Edge e4 = TopoDS::Edge(aExp.Current());
890
891 try
892 {
893 OCC_CATCH_SIGNALS
894 BRepFilletAPI_MakeFillet mkFillet(aBox);
895 mkFillet.SetContinuity(GeomAbs_C1,.001);
896
897 // Setup variable fillet data
898 TColgp_Array1OfPnt2d t_pnt(1,4);
899 t_pnt.SetValue(1,gp_Pnt2d(0.0,5.0));
900 t_pnt.SetValue(2,gp_Pnt2d(0.3,15.0));
901 t_pnt.SetValue(3,gp_Pnt2d(0.7,15.0));
902 t_pnt.SetValue(4,gp_Pnt2d(1.0,5.0));
903
904 // HERE:
905 // It is impossible to build fillet if at least one edge
906 // with variable radius is added!!! If all are constant, everything is ok.
907 mkFillet.Add(t_pnt,e1);
908 mkFillet.Add(5.0,e2);
909 mkFillet.Add(t_pnt,e3);
910 mkFillet.Add(5.0,e4);
911
912 mkFillet.Build();
913 TopoDS_Shape aFinalShape = mkFillet.Shape();
914
915 DBRep::Set(argv[1],aFinalShape);
916 }
917 catch(Standard_Failure)
918 {
919 di << argv[0] << ": Exception in fillet"<<"\n";
920 return 2;
921 }
922 }
923
924 return 0;
925}
926
927#include <Law_Interpol.hxx>
928
929static Standard_Real t3d = 1.e-4;
930static Standard_Real t2d = 1.e-5;
931static Standard_Real ta = 1.e-2;
932static Standard_Real fl = 1.e-3;
933static Standard_Real tapp_angle = 1.e-2;
934static GeomAbs_Shape blend_cont = GeomAbs_C1;
935
936static BRepFilletAPI_MakeFillet* Rakk = 0;
937static BRepFilletAPI_MakeFillet* Rake = 0;
938static char name[100];
939
940static void printtolblend(Draw_Interpretor& di)
941{
942 di<<"tolerance ang : "<<ta<<"\n";
943 di<<"tolerance 3d : "<<t3d<<"\n";
944 di<<"tolerance 2d : "<<t2d<<"\n";
945 di<<"fleche : "<<fl<<"\n";
946
947 di<<"tolblend "<<ta<<" "<<t3d<<" "<<t2d<<" "<<fl<<"\n";
948}
949
950static Standard_Integer MKEVOL(Draw_Interpretor& di,
951 Standard_Integer narg,
952 const char ** a)
953{
954 if(Rake != 0) {delete Rake; Rake = 0;}
955 printtolblend(di);
956 if (narg < 3) return 1;
957 TopoDS_Shape V = DBRep::Get(a[2]);
958 Rake = new BRepFilletAPI_MakeFillet(V);
959 Rake->SetParams(ta,t3d,t2d,t3d,t2d,fl);
960 Rake->SetContinuity(blend_cont, tapp_angle);
961 if (narg == 4) {
962 ChFi3d_FilletShape FSh = ChFi3d_Rational;
963 if (!strcasecmp(a[3], "Q")) {
964 FSh = ChFi3d_QuasiAngular;
965 }
966 else if (!strcasecmp(a[3], "P")) {
967 FSh = ChFi3d_Polynomial;
968 }
969 Rake->SetFilletShape(FSh);
970 }
971 strcpy(name, a[1]);
972 return 0;
973}
974
975static Standard_Integer UPDATEVOL(Draw_Interpretor& di,
976 Standard_Integer narg,
977 const char ** a)
978{
979 if(Rake == 0){
980 di << "MakeFillet non initialise"<<"\n";
981 return 1 ;
982 }
983 if(narg%2 != 0 || narg < 4) return 1;
984 TColgp_Array1OfPnt2d uandr(1,(narg/2)-1);
985 Standard_Real Rad, Par;
986 TopoDS_Shape aLocalEdge(DBRep::Get(a[1],TopAbs_EDGE));
987 TopoDS_Edge E = TopoDS::Edge(aLocalEdge);
988 for (Standard_Integer ii = 1; ii <= (narg/2)-1; ii++){
989 Par = atof(a[2*ii]);
990 Rad = atof(a[2*ii + 1]);
991 uandr.ChangeValue(ii).SetCoord(Par,Rad);
992 }
993 //HELPDESK: Add law creation
994 const Standard_Boolean aLawMode = !strcmp(a[0],"OCC570evollaw");
995 if (aLawMode)
996 {
997 di<<"INFO: Using law to define variable fillet"<<"\n";
998 Handle(Law_Interpol) law = new Law_Interpol;
999 law->Set(uandr);
1000 Rake->Add(law,E);
1001 }
1002 else
1003 Rake->Add(uandr,E);
1004
1005 return 0;
1006}
1007
1008static Standard_Integer BUILDEVOL(Draw_Interpretor& di,
1009 Standard_Integer,
1010 const char **)
1011{
1012 if(Rake == 0){
1013 di << "MakeFillet non initialise"<<"\n";
1014 return 1 ;
1015 }
1016 Rake->Build();
1017 if(Rake->IsDone()){
1018 TopoDS_Shape result = Rake->Shape();
1019 DBRep::Set(name,result);
1020 if(Rake != 0) {delete Rake; Rake = 0;}
1021 return 0;
1022 }
1023 if(Rake != 0) {delete Rake; Rake = 0;}
1024 return 1;
1025}
1026
1027#include <TColGeom_SequenceOfCurve.hxx>
1028#include <Geom_TrimmedCurve.hxx>
1029#include <GeomFill_NSections.hxx>
1030#include <BRepBuilderAPI_MakeFace.hxx>
1031//=======================================================================
1032//function : OCC606
1033//purpose :
1034//=======================================================================
1035static Standard_Integer OCC606 ( Draw_Interpretor& di, Standard_Integer n, const char ** a )
1036{
1037 if (n != 3 && n != 4)
1038 {
1039 di << "Usage : " << a[0] << " result shape [-t]" << "\n";
1040 return 0;
1041 }
1042
1043 Standard_Boolean TrimMode = (n == 4);
1044 if (TrimMode) di<<"INFO: Using trimmed curves..."<<"\n";
1045 else di<<"INFO: Using non trimmed curves..."<<"\n";
1046
1047 TopoDS_Shape S = DBRep::Get(a[2]);
1048
1049 TopExp_Explorer t_exp(S,TopAbs_EDGE);
1050 TColGeom_SequenceOfCurve n_curves1;
1051 TColStd_SequenceOfReal np;
1052 Standard_Real param = 5.0;
1053
1054 for (;t_exp.More();t_exp.Next())
1055 {
1056 Standard_Real f,l;
1057 Handle(Geom_Curve) h_cur = BRep_Tool::Curve(TopoDS::Edge(t_exp.Current()),f,l);
1058 if (!h_cur.IsNull())
1059 {
1060 if (TrimMode) h_cur = new Geom_TrimmedCurve(h_cur,f,l);
1061
1062 n_curves1.Append(h_cur);
1063 np.Append(param);
1064 param += 1.0;
1065 }
1066 }
1067
1068 if (n_curves1.Length()>1 && !np.IsEmpty())
1069 {
1070 try
1071 {
1072 OCC_CATCH_SIGNALS
1073 GeomFill_NSections b_surface1(n_curves1, np);
1074 b_surface1.ComputeSurface();
1075 Handle(Geom_BSplineSurface) result_surf1 = b_surface1.BSplineSurface();
1076 if (!result_surf1.IsNull())
1077 {
1078 BRepBuilderAPI_MakeFace b_face1(result_surf1);
1079 TopoDS_Face bsp_face1 = b_face1.Face();
1080 DBRep::Set(a[1],bsp_face1);
1081 }
1082 }
1083 catch(Standard_Failure)
1084 {
1085 di<<"ERROR: Exception in GeomFill_NSections"<<"\n";
1086 }
1087 }
1088
1089
1090 return 0;
1091}
1092
1093//=======================================================================
1094//function : OCC813
1095//purpose :
1096//=======================================================================
1097static Standard_Integer OCC813 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
1098{
1099 if (argc < 3)
1100 {
1101 di << "Usage : " << argv[0] << " U V" << "\n";
1102 return 1;
1103 }
1104
1105 Standard_CString str;
1106 Standard_Real U = atof(argv[1]);
1107 Standard_Real V = atof(argv[2]);
1108
1109 //Between ellipse and point:
1110
1111 Handle(Geom_Ellipse) ell = new Geom_Ellipse(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
1112 gp_Dir(0.173648,0.984808,0.000000),
1113 gp_Dir(-0.932169,0.164367,-0.322560)), 150, 100);
1114 Handle(Geom_Plane) plne = new Geom_Plane(gp_Ax3(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
1115 gp_Dir(0.173648,0.984808,0.000000),
1116 gp_Dir(-0.932169,0.164367,-0.322560))) );
1117
1118 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1119
1120 gp_Pnt2d pt2d(U,V);
1121 gp_Pln pln = plne->Pln();
1122
1123 str = "OCC813_pnt"; DrawTrSurf::Set(str,pt2d);
1124
1125 Handle(Geom2d_Curve) curve2d = GeomAPI::To2d(ell,pln);
1126 Geom2dAdaptor_Curve acur(curve2d);
1127 Geom2dGcc_QualifiedCurve qcur(acur, GccEnt_outside);
1128
1129 str = "OCC813_ell"; DrawTrSurf::Set(str,curve2d);
1130 if(!aContext.IsNull()) {
1131 Handle(AIS_Shape) aisp =
1132 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(curve2d, pln)).Edge());
1133 aContext->Display (aisp);
1134 }
1135
1136 //This does not give any solutions.
1137 Geom2dGcc_Lin2d2Tan lintan(qcur, pt2d, 0.1);
1138 di<<"OCC813 nb of solutions = "<<lintan.NbSolutions()<<"\n";
1139
1140 Standard_Character abuf[16];
1141 Standard_CString st = abuf;
1142
1143 Standard_Integer i;
1144 for(i=1;i<=lintan.NbSolutions();i++) {
1145 sprintf(abuf,"lintan_%d",i);
1146 Handle(Geom2d_Line) glin = new Geom2d_Line(lintan.ThisSolution(i));
1147 DrawTrSurf::Set(st,glin);
1148 if(!aContext.IsNull()) {
1149 Handle(AIS_Shape) aisp =
1150 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(glin, pln)).Edge()); aContext->Display (aisp);
1151 }
1152 }
1153
1154 return 0;
1155}
1156
1157//=======================================================================
1158//function : OCC814
1159//purpose :
1160//=======================================================================
1161static Standard_Integer OCC814 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
1162{
1163 if (argc > 1)
1164 {
1165 di << "Usage : " << argv[0] << "\n";
1166 return 1;
1167 }
1168
1169 Standard_CString str;
1170
1171 //Between Ellipse and Circle:
1172
1173 Handle(Geom_Circle) cir = new Geom_Circle(gp_Ax2(gp_Pnt(823.687192,502.366825,478.960440),
1174 gp_Dir(0.173648,0.984808,0.000000),
1175 gp_Dir(-0.932169,0.164367,-0.322560)), 50);
1176 Handle(Geom_Ellipse) ell = new Geom_Ellipse(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
1177 gp_Dir(0.173648,0.984808,0.000000),
1178 gp_Dir(-0.932169,0.164367,-0.322560)), 150, 100);
1179 Handle(Geom_Plane) plne = new Geom_Plane(gp_Ax3(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
1180 gp_Dir(0.173648,0.984808,0.000000),
1181 gp_Dir(-0.932169,0.164367,-0.322560))) );
1182
1183 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1184
1185 gp_Pln pln = plne->Pln();
1186 Handle(Geom2d_Curve) curve2d = GeomAPI::To2d(ell, pln);
1187 Handle(Geom2d_Curve) fromcurve2d = GeomAPI::To2d(cir, pln);
1188
1189 str = "OCC814_cir"; DrawTrSurf::Set(str,curve2d);
1190 str = "OCC814_ell"; DrawTrSurf::Set(str,fromcurve2d);
1191 if(!aContext.IsNull()) {
1192 Handle(AIS_Shape) aisp =
1193 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(curve2d, pln)).Edge());
1194 aContext->Display (aisp);
1195 }
1196 if(!aContext.IsNull()) {
1197 Handle(AIS_Shape) aisp =
1198 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(fromcurve2d, pln)).Edge());
1199 aContext->Display (aisp);
1200 }
1201
1202 Geom2dAdaptor_Curve acur(curve2d), afromcur(fromcurve2d);
1203
1204 Geom2dGcc_QualifiedCurve qcur(acur, GccEnt_outside) ;
1205 Geom2dGcc_QualifiedCurve qfromcur(afromcur, GccEnt_outside) ;
1206
1207 //This does not give any solutions.
1208 Geom2dGcc_Lin2d2Tan lintan(qcur, qfromcur, 0.1);
1209 di<<"OCC814 nb of solutions = "<<lintan.NbSolutions()<<"\n";
1210
1211 Standard_Character abuf[16];
1212 Standard_CString st = abuf;
1213
1214 Standard_Integer i;
1215 for(i=1;i<=lintan.NbSolutions();i++) {
1216 sprintf(abuf,"lintan_%d",i);
1217 Handle(Geom2d_Line) glin = new Geom2d_Line(lintan.ThisSolution(i));
1218 DrawTrSurf::Set(st,glin);
1219 if(!aContext.IsNull()) {
1220 Handle(AIS_Shape) aisp =
1221 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(glin, pln)).Edge()); aContext->Display (aisp);
1222 }
1223 }
1224
1225 return 0;
1226}
1227
1228#include <ShapeAnalysis_Wire.hxx>
1229#include <IntRes2d_SequenceOfIntersectionPoint.hxx>
1230#include <TColgp_SequenceOfPnt.hxx>
1231#include <ShapeFix_Wire.hxx>
1232//=======================================================================
1233//function : OCC884
1234//purpose :
1235//=======================================================================
1236static Standard_Integer OCC884 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1237{
1238 if (argc < 3 || argc > 5)
1239 {
1240 di << "Usage : " << argv[0] << " result shape [toler [maxtoler]]" << "\n";
1241 return 1;
1242 }
1243
1244 TopoDS_Shape shape = DBRep::Get(argv[2]); //read the shape
1245
1246 TopExp_Explorer exp(shape, TopAbs_EDGE);
1247 if (!exp.More())
1248 {
1249 di<<"Error: no edge found"<<"\n";
1250 return 1;
1251 }
1252
1253 BRep_Builder builder;
1254 TopoDS_Wire wire;
1255 builder.MakeWire(wire);
1256 builder.Add(wire, TopoDS::Edge(exp.Current()));
1257
1258 // HelpDesk: Create planar face if possible
1259 TopoDS_Face face = BRepBuilderAPI_MakeFace(wire,Standard_True);
1260
1261 Handle(ShapeAnalysis_Wire) advWA = new ShapeAnalysis_Wire;
1262 advWA->Load(wire);
1263 advWA->SetFace(face);
1264 advWA->SetPrecision(0.001);
1265
1266 IntRes2d_SequenceOfIntersectionPoint points2d;
1267 TColgp_SequenceOfPnt points3d;
1268
1269 di << "Info: CheckSelfIntersectingEdge = " << (Standard_Integer) advWA->CheckSelfIntersectingEdge(1,points2d,points3d) << "\n";
1270
1271 ShapeExtend_Status status = ShapeExtend_FAIL1;
1272 if (advWA->StatusSelfIntersection(status))
1273 di << "Info: No P Curve found in the edge\n";
1274
1275 status = ShapeExtend_FAIL2;
1276 if (advWA->StatusSelfIntersection(status))
1277 di << "Info: No Vertices found in the edge\n";
1278
1279 status = ShapeExtend_DONE1;
1280 if (advWA->StatusSelfIntersection(status))
1281 di << "Info: Self-intersection found in the edge\n";
1282
1283 Standard_Integer i, num = points2d.Length();
1284 di << "Info: No. of self-intersection points : " << num << "\n";
1285
1286 char str[80];
1287 Standard_CString name = str;
1288 for (i = 1; i <= num; ++i)
1289 {
1290 gp_Pnt pt = points3d(i);
1291 di << "Info: Intersecting pt : (" << pt.X() << ", " << pt.Y() << ", " << pt.Z() << ")\n";
1292 sprintf(str,"p_%d",i);
1293 DrawTrSurf::Set(name,pt);
1294 }
1295
1296 Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire;
1297 sfw->Load(wire);
1298 sfw->SetFace(face);
1299
1300 if (argc > 3) sfw->SetPrecision(atof(argv[3])/*0.1*/);
1301 if (argc > 4) sfw->SetMaxTolerance(atof(argv[4]));
1302 di << "Info: Precision is set to " << sfw->Precision() << "\n";
1303 di << "Info: MaxTolerance is set to " << sfw->MaxTolerance() << "\n";
1304
1305 sfw->ModifyTopologyMode() = 1;
1306 sfw->ModifyGeometryMode() = 1;
1307 sfw->FixSelfIntersectingEdgeMode() = 1;
1308 //printf("Info: FixSelfIntersection = %d\n",sfw->FixSelfIntersection());
1309 di << "Info: FixSelfIntersection = " << (Standard_Integer) sfw->FixSelfIntersection() << "\n";
1310
1311 DBRep::Set(argv[1],sfw->Wire());
1312
1313 status = ShapeExtend_OK;
1314 if (sfw->StatusSelfIntersection(status))
1315 di << "Info: ShapeExtend_OK : No intersection found\n";
1316 //printf("Info: ShapeExtend_OK : No intersection found\n");
1317
1318 status = ShapeExtend_FAIL1;
1319 if (sfw->StatusSelfIntersection(status))
1320 di << "Info: ShapeExtend_FAIL1 : analysis failed (edge has no pcurve, or no vertices etc.)\n";
1321
1322 status = ShapeExtend_FAIL2;
1323 if (sfw->StatusSelfIntersection(status))
1324 di << "Info: ShapeExtend_FAIL2 : self-intersection was found, but not fixed because of limit of increasing tolerance (MaxTolerance)\n";
1325
1326 status = ShapeExtend_FAIL3;
1327 if (sfw->StatusSelfIntersection(status))
1328 di << "Info: ShapeExtend_FAIL3 : intercestion of non adjacent edges found, but not fixed because of limit of increasing tolerance (MaxTolerance)\n";
1329
1330 status = ShapeExtend_DONE1;
1331 if (sfw->StatusSelfIntersection(status))
1332 di << "Info: ShapeExtend_DONE1 : tolerance of vertex was increased to fix self-intersection\n";
1333
1334 status = ShapeExtend_DONE2;
1335 if (sfw->StatusSelfIntersection(status))
1336 di << "Info: ShapeExtend_DONE2 : vertex was moved to fix self-intersection\n";
1337
1338 status = ShapeExtend_DONE3;
1339 if (sfw->StatusSelfIntersection(status))
1340 di << "Info: ShapeExtend_DONE3 : some edges were removed because of intersection\n";
1341
1342 status = ShapeExtend_DONE4;
1343 if (sfw->StatusSelfIntersection(status))
1344 di << "Info: ShapeExtend_DONE4 : pcurve(s) was(were) modified\n";
1345
1346 status = ShapeExtend_DONE5;
1347 if (sfw->StatusSelfIntersection(status))
1348 di << "Info: ShapeExtend_DONE5 : non adjacent intersection fixed by increasing tolerance of vertex(vertices)\n";
1349
1350 status = ShapeExtend_DONE6;
1351 if (sfw->StatusSelfIntersection(status))
1352 di << "Info: ShapeExtend_DONE6 : tolerance of edge was increased to hide intersection\n";
1353
1354 status = ShapeExtend_DONE7;
1355 if (sfw->StatusSelfIntersection(status))
1356 di << "Info: ShapeExtend_DONE7 : range of some edges was decreased to avoid intersection\n";
1357
1358 return 0;
1359}
1360
1361#include <Aspect_FillMethod.hxx>
1362//=======================================================================
1363//function : OCC1188
1364//purpose :
1365//=======================================================================
1366static Standard_Integer OCC1188 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1367{
1368 if (argc < 2 || argc > 3)
1369 {
1370 di << "Usage : " << argv[0] << " imagefile [filltype] : Load image as background" << "\n";
1371 return 1;
1372 }
1373
1374 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1375 if(AISContext.IsNull())
1376 {
1377 di << "use 'vinit' command before " << argv[0] << "\n";
1378 return 1;
1379 }
1380
1381 Aspect_FillMethod aFillType = Aspect_FM_CENTERED;
1382 if (argc == 3)
1383 {
1384 const char* szType = argv[2];
1385 if (strcmp(szType, "NONE" ) == 0) aFillType = Aspect_FM_NONE;
1386 else if (strcmp(szType, "CENTERED") == 0) aFillType = Aspect_FM_CENTERED;
1387 else if (strcmp(szType, "TILED" ) == 0) aFillType = Aspect_FM_TILED;
1388 else if (strcmp(szType, "STRETCH" ) == 0) aFillType = Aspect_FM_STRETCH;
1389 else
1390 {
1391 di << "Wrong fill type : " << szType << "\n";
1392 di << "Must be one of CENTERED, TILED, STRETCH, NONE" << "\n";
1393 return 1;
1394 }
1395 }
1396
1397 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
1398 V3dView->SetBackgroundImage(argv[1], aFillType, Standard_True);
1399
1400 return 0;
1401}
1402
1403#include <AIS_Drawer.hxx>
1404#include <Graphic3d_MaterialAspect.hxx>
1405#include <Prs3d_ShadingAspect.hxx>
1406//=======================================================================
1407//function : OCC1174_1
1408//purpose :
1409//=======================================================================
1410static Standard_Integer OCC1174_1 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1411{
1412 if (argc != 2)
1413 {
1414 di << "Usage : " << argv[0] << " shape" << "\n";
1415 return 1;
1416 }
1417
1418 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1419 if(AISContext.IsNull())
1420 {
1421 di << "use 'vinit' command before " << argv[0] << "\n";
1422 return 1;
1423 }
1424
1425 TopoDS_Shape sh = DBRep::Get(argv[1]);
1426
1427 Handle(AIS_Shape) ais = new AIS_Shape(sh);
1428
1429 Quantity_Color colf(0.0, 0.4, 0.0, Quantity_TOC_RGB);
1430 Quantity_Color colb(0.0, 0.0, 0.6, Quantity_TOC_RGB);
1431
1432 Handle(Prs3d_ShadingAspect) sa = ais->Attributes()->ShadingAspect();
1433
1434 Graphic3d_MaterialAspect front = sa->Material(Aspect_TOFM_FRONT_SIDE);
1435 front.SetAmbientColor(colf);
1436 front.SetDiffuseColor(colf);
1437 front.SetSpecularColor(colf);
1438 front.SetEmissiveColor(colf);
1439 front.SetTransparency(0.0);
1440 sa->SetMaterial(front,Aspect_TOFM_FRONT_SIDE);
1441
1442 Graphic3d_MaterialAspect back = sa->Material(Aspect_TOFM_BACK_SIDE);
1443 back.SetAmbientColor(colb);
1444 back.SetDiffuseColor(colb);
1445 back.SetSpecularColor(colb);
1446 back.SetEmissiveColor(colb);
1447 back.SetTransparency(0.0);
1448 sa->SetMaterial(back,Aspect_TOFM_BACK_SIDE);
1449
1450 AISContext->Display(ais,1,0);
1451
1452 Standard_Real r, g, b;
1453 sa->Color(Aspect_TOFM_FRONT_SIDE).Values(r,g,b, Quantity_TOC_RGB);
1454 di << "Info: color on front side (" << r << "," << g << "," << b << ")\n";
1455 sa->Color(Aspect_TOFM_BACK_SIDE).Values(r,g,b, Quantity_TOC_RGB);
1456 di << "Info: color on back side (" << r << "," << g << "," << b << ")\n";
1457
1458 return 0;
1459}
1460
1461//=======================================================================
1462//function : OCC1174_2
1463//purpose :
1464//=======================================================================
1465static Standard_Integer OCC1174_2 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1466{
1467 if (argc != 2)
1468 {
1469 di << "Usage : " << argv[0] << " shape" << "\n";
1470 return 1;
1471 }
1472
1473 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1474 if(AISContext.IsNull())
1475 {
1476 di << "use 'vinit' command before " << argv[0] << "\n";
1477 return 1;
1478 }
1479
1480 TopoDS_Shape sh = DBRep::Get(argv[1]);
1481
1482 Handle(AIS_Shape) ais = new AIS_Shape(sh);
1483 AISContext->Display(ais,1,0);
1484 AISContext->SetMaterial(ais,Graphic3d_NOM_SHINY_PLASTIC);
1485
1486 Quantity_Color colf(0.0, 0.4, 0.0, Quantity_TOC_RGB);
1487 Quantity_Color colb(0.0, 0.0, 0.6, Quantity_TOC_RGB);
1488 Handle(Prs3d_ShadingAspect) sa = ais->Attributes()->ShadingAspect();
1489
1490 Graphic3d_MaterialAspect front = sa->Material(Aspect_TOFM_FRONT_SIDE);
1491 front.SetAmbientColor(colf);
1492 front.SetDiffuseColor(colf);
1493 front.SetSpecularColor(colf);
1494 front.SetEmissiveColor(colf);
1495 front.SetTransparency(0.4);
1496 sa->SetMaterial(front,Aspect_TOFM_FRONT_SIDE);
1497
1498 Graphic3d_MaterialAspect back = sa->Material(Aspect_TOFM_BACK_SIDE);
1499 back.SetAmbientColor(colb);
1500 back.SetDiffuseColor(colb);
1501 back.SetSpecularColor(colb);
1502 back.SetEmissiveColor(colb);
1503 back.SetTransparency(0.2);
1504 sa->SetMaterial(back,Aspect_TOFM_BACK_SIDE);
1505
1506 AISContext->Redisplay(ais,1,0);
1507
1508 return 0;
1509}
1510
1511#include <Graphic2d_Segment.hxx>
1512#include <Prs2d_Length.hxx>
1513#include <Prs2d_AspectLine.hxx>
1514#include <AIS2D_InteractiveObject.hxx>
1515//=======================================================================
1516// OCC672:
1517// OCC672_Length
1518// OCC672_Angle
1519// OCC672_Diameter
1520// OCC672_ShortLength
1521//=======================================================================
1522
1523static Standard_Integer OCC672_Length (Draw_Interpretor& di, Standard_Integer n,const char ** argv)
1524{
1525 if (n != 17) {
1526 di << " wrong parameters !\n";
1527 di << "must be : OCC672_Length x1 y1 x2 y2 str scale_text length_dist angle_arrow length_arrow x3 y3 x4 y4 TxtAngle TxtPosH TxtPosV\n";
1528 return 1;
1529 }
1530
1531 Standard_Real x1=atof(argv[1]);
1532 Standard_Real y1=atof(argv[2]);
1533 Standard_Real x2=atof(argv[3]);
1534 Standard_Real y2=atof(argv[4]);
1535 Standard_Real x3=atof(argv[10]);
1536 Standard_Real y3=atof(argv[11]);
1537 Standard_Real x4=atof(argv[12]);
1538 Standard_Real y4=atof(argv[13]);
1539 Standard_Real txtAngle=atof(argv[14]);
1540 Standard_Real txtPosH=atof(argv[15]);
1541 Standard_Real txtPosV=atof(argv[16]);
1542
1543 di<<"Begin!\n";
1544 Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
1545 di<<"Check InteractiveContext\n";
1546
1547 if(aContext.IsNull()) {
1548 di << "use 'v2dinit' command before " << argv[0] << "\n";
1549 return 1;
1550 }
1551
1552 di<<"CloseLocalContext\n";
1553 aContext->CloseLocalContext();
1554
1555 di<<"OpenLocalContext\n";
1556 aContext->OpenLocalContext();
1557 //step0 end
1558 Handle(AIS2D_InteractiveObject) aIO10 = new AIS2D_InteractiveObject();
1559 Handle(Graphic2d_Segment) theSegmA, theSegmB, theSegmC, theSegmD;
1560
1561 theSegmA = new Graphic2d_Segment( aIO10, x1, y1, x2, y2 );
1562 theSegmB = new Graphic2d_Segment( aIO10, x2, y2, x3, y3 );
1563 theSegmC = new Graphic2d_Segment( aIO10, x3, y3, x4, y4 );
1564 theSegmD = new Graphic2d_Segment( aIO10, x4, y4, x1, y1 );
1565
1566 aContext->Display( aIO10, Standard_True );
1567
1568 Handle(Prs2d_Length) length = new Prs2d_Length(aIO10, gp_Pnt2d(x1, y1), gp_Pnt2d(x2, y2), argv[5],
1569 atof(argv[6]), atof(argv[7]), Prs2d_TOD_AUTOMATIC,
1570 atof(argv[8]), atof(argv[9]), Prs2d_TOA_FILLED,
1571 Prs2d_AS_BOTHAR);
1572
1573 length->SetTextRelPos(txtPosH,txtPosV);
1574 length->SetTextRelAngle(txtAngle);
1575
1576 Handle(Prs2d_AspectLine) theAspect = new Prs2d_AspectLine(Quantity_NOC_WHITE,
1577 Aspect_TOL_SOLID, Aspect_WOL_THIN);
1578 aIO10->SetAspect( theAspect, length);
1579 aContext->Display( aIO10, Standard_True );
1580
1581 Handle(Prs2d_Length) lengthB = new Prs2d_Length(aIO10, gp_Pnt2d(x2, y2), gp_Pnt2d(x3, y3), argv[5],
1582 atof(argv[6]), atof(argv[7]), Prs2d_TOD_AUTOMATIC,
1583 atof(argv[8]), atof(argv[9]), Prs2d_TOA_FILLED,
1584 Prs2d_AS_BOTHAR);
1585
1586 lengthB->SetTextRelPos(txtPosH,txtPosV);
1587 lengthB->SetTextRelAngle(txtAngle);
1588
1589 aIO10->SetAspect( theAspect, lengthB);
1590 aContext->Display( aIO10, Standard_True );
1591
1592 Handle(Prs2d_Length) lengthC = new Prs2d_Length(aIO10, gp_Pnt2d(x3, y3), gp_Pnt2d(x4, y4), argv[5],
1593 atof(argv[6]), atof(argv[7]), Prs2d_TOD_AUTOMATIC,
1594 atof(argv[8]), atof(argv[9]), Prs2d_TOA_FILLED,
1595 Prs2d_AS_BOTHAR);
1596
1597 lengthC->SetTextRelPos(txtPosH,txtPosV);
1598 lengthC->SetTextRelAngle(txtAngle);
1599
1600 aIO10->SetAspect( theAspect, lengthC);
1601 aContext->Display( aIO10, Standard_True );
1602
1603 Handle(Prs2d_Length) lengthD = new Prs2d_Length(aIO10, gp_Pnt2d(x4, y4), gp_Pnt2d(x1, y1), argv[5],
1604 atof(argv[6]), atof(argv[7]), Prs2d_TOD_AUTOMATIC,
1605 atof(argv[8]), atof(argv[9]), Prs2d_TOA_FILLED,
1606 Prs2d_AS_BOTHAR);
1607
1608 lengthD->SetTextRelPos(txtPosH,txtPosV);
1609 lengthD->SetTextRelAngle(txtAngle);
1610
1611 aIO10->SetAspect( theAspect, lengthD);
1612 aContext->Display( aIO10, Standard_True );
1613 return 0;
1614}
1615
1616#include <Prs2d_Angle.hxx>
1617static Standard_Integer OCC672_Angle (Draw_Interpretor& di, Standard_Integer n,const char ** argv)
1618{
1619 if (n != 15) {
1620 di << "Wrong parameters !\n";
1621 di << "must be : OCC672_Angle x1 y1 x2 y2 x3 y3 aRadius aText aTxtScale anArrAngle anArrLength txtAngle txtPosH txtPosV \n";
1622 return 1;
1623 }
1624
1625 Standard_Real x1=atof(argv[1]);
1626 Standard_Real y1=atof(argv[2]);
1627 Standard_Real x2=atof(argv[3]);
1628 Standard_Real y2=atof(argv[4]);
1629 Standard_Real x3=atof(argv[5]);
1630 Standard_Real y3=atof(argv[6]);
1631 Standard_Real aRadius=atof(argv[7]);
1632 Standard_Real aTxtScale=atof(argv[9]);
1633 Standard_Real anArrAngle=atof(argv[10]);
1634 Standard_Real anArrLength=atof(argv[11]);
1635 Standard_Real txtAngle=atof(argv[12]);
1636 Standard_Real txtPosH=atof(argv[13]);
1637 Standard_Real txtPosV=atof(argv[14]);
1638
1639 di<<"Begin!\n";
1640 Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
1641 di<<"Check InteractiveContext\n";
1642
1643 if(aContext.IsNull()) {
1644 di << "use 'v2dinit' command before " << argv[0] << "\n";
1645 return 1;
1646 }
1647
1648 di<<"CloseLocalContext\n";
1649 aContext->CloseLocalContext();
1650
1651 di<<"OpenLocalContext\n";
1652 aContext->OpenLocalContext();
1653
1654 Handle(AIS2D_InteractiveObject) aIO10 = new AIS2D_InteractiveObject();
1655 Handle(Graphic2d_Segment) theSegmA, theSegmB;
1656 theSegmA = new Graphic2d_Segment( aIO10, x1, y1, x2, y2 );
1657 theSegmB = new Graphic2d_Segment( aIO10, x1, y1, x3, y3 );
1658 aContext->Display( aIO10, Standard_True );
1659
1660 Handle(Prs2d_Angle) angle = new Prs2d_Angle(aIO10, gp_Pnt2d(x1, y1), gp_Pnt2d(x2, y2),gp_Pnt2d(x3,y3),
1661 aRadius,argv[8],aTxtScale,anArrAngle,anArrLength,Prs2d_TOA_FILLED,
1662 Prs2d_AS_BOTHAR);
1663
1664 angle->SetTextRelPos(txtPosH,txtPosV);
1665 angle->SetTextAbsAngle(txtAngle);
1666
1667 aContext->Display( aIO10, Standard_True );
1668 return 0;
1669}
1670
1671#include <Prs2d_Diameter.hxx>
1672#include <gp_Circ2d.hxx>
1673#include <Graphic2d_Circle.hxx>
1674#include <Prs2d_AspectText.hxx>
1675static Standard_Integer OCC672_Diameter (Draw_Interpretor& di, Standard_Integer n,const char ** argv)
1676{
1677 if (n != 13) {
1678 di << "Wrong parameters !\n";
1679 di << "must be : OCC672_Diameter x1 y1 cx cy radius aText aTxtScale anArrAngle anArrLength txtAngle txtPosH txtPosV\n";
1680 return 1;
1681 }
1682
1683 Standard_Real x1=atof(argv[1]);
1684 Standard_Real y1=atof(argv[2]);
1685 Standard_Real cx=atof(argv[3]); //coordinats for circle
1686 Standard_Real cy=atof(argv[4]); //
1687 Standard_Real radius=atof(argv[5]);//radius for circle
1688 Standard_Real aTxtScale=atof(argv[7]);
1689 Standard_Real anArrAngle=atof(argv[8]);
1690 Standard_Real anArrLength=atof(argv[9]);
1691
1692 Standard_Real txtAngle=atof(argv[10]);
1693 Standard_Real txtPosH=atof(argv[11]);
1694 Standard_Real txtPosV=atof(argv[12]);
1695
1696
1697 di<<"Begin!\n";
1698 Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
1699 di<<"Check InteractiveContext\n";
1700
1701 if(aContext.IsNull()) {
1702 di << "use 'v2dinit' command before " << argv[0] << "\n";
1703 return 1;
1704 }
1705
1706 di<<"CloseLocalContext\n";
1707 aContext->CloseLocalContext();
1708
1709 di<<"OpenLocalContext\n";
1710 aContext->OpenLocalContext();
1711 Handle(AIS2D_InteractiveObject) aIO10 = new AIS2D_InteractiveObject();
1712
1713 Handle (Graphic2d_Circle) HCirc;
1714 HCirc= new Graphic2d_Circle(aIO10,cx,cy,radius);
1715
1716 gp_Dir2d myDir2d(1,0);
1717 gp_Pnt2d myPnt2d(cx,cy);
1718 gp_Ax2d myAx2d(myPnt2d,myDir2d);
1719 gp_Circ2d myCirc(myAx2d,radius);
1720
1721 Handle(Prs2d_Diameter) diameter = new Prs2d_Diameter(aIO10, gp_Pnt2d(x1, y1),myCirc,
1722 argv[6],aTxtScale,anArrAngle,anArrLength,
1723 Prs2d_TOA_FILLED,
1724 Prs2d_AS_BOTHAR,Standard_True);
1725
1726 diameter->SetTextRelPos(txtPosH,txtPosV);
1727
1728 diameter->SetTextAbsAngle(txtAngle);
1729
1730 aContext->Display( aIO10, Standard_True );
1731
1732 return 0;
1733}
1734
1735#include <gp_Lin2d.hxx>
1736static Standard_Integer OCC672_ShortLength (Draw_Interpretor& di, Standard_Integer n,const char ** argv)
1737{
1738 if (n != 17) {
1739 di << " wrong parameters !\n";
1740 di << "must be : OCC672_ShortLength x1 y1 x2 y2 str scale_text length_dist angle_arrow length_arrow x3 y3 x4 y4 TxtAngle TxtPosH TxtPosV\n";
1741 return 1;
1742 }
1743
1744 Standard_Real x1=atof(argv[1]);
1745 Standard_Real y1=atof(argv[2]);
1746 Standard_Real x2=atof(argv[3]);
1747 Standard_Real y2=atof(argv[4]);
1748 Standard_Real x3=atof(argv[10]);
1749 Standard_Real y3=atof(argv[11]);
1750 Standard_Real x4=atof(argv[12]);
1751 Standard_Real y4=atof(argv[13]);
1752 Standard_Real txtAngle=atof(argv[14]);
1753 Standard_Real txtPosH=atof(argv[15]);
1754 Standard_Real txtPosV=atof(argv[16]);
1755
1756
1757 di<<"Begin!\n";
1758 Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
1759 di<<"Check InteractiveContext\n";
1760
1761 if(aContext.IsNull()) {
1762 di << "use 'v2dinit' command before " << argv[0] << "\n";
1763 return 1;
1764 }
1765
1766 di<<"CloseLocalContext\n";
1767 aContext->CloseLocalContext();
1768
1769 di<<"OpenLocalContext\n";
1770 aContext->OpenLocalContext();
1771
1772 Handle(AIS2D_InteractiveObject) aIO10 = new AIS2D_InteractiveObject();
1773 Handle(Graphic2d_Segment) theSegmA, theSegmB, theSegmC, theSegmD;
1774 theSegmB = new Graphic2d_Segment( aIO10, x2, y2, x3, y3 );
1775 theSegmD = new Graphic2d_Segment( aIO10, x4, y4, x1, y1 );
1776
1777 aContext->Display( aIO10, Standard_True );
1778
1779 gp_Pnt2d p3(x3,y3),p2(x2,y2),p1(x1,y1);
1780 gp_Vec2d theVec(p3,p2);
1781 gp_Dir2d theDir(theVec);
1782 gp_Lin2d theLin1(p1,theDir);
1783 gp_Lin2d theLin2(p3,theDir);
1784
1785 Handle(Prs2d_Length) length = new Prs2d_Length(aIO10, p1, theLin2, argv[5],
1786 atof(argv[6]), 5.0, 20.0, 5.,
1787 Prs2d_TOA_CLOSED,Prs2d_AS_BOTHAR,
1788 Standard_True);
1789
1790
1791 Handle(Prs2d_AspectLine) theAspect = new Prs2d_AspectLine(Quantity_NOC_WHITE,
1792 Aspect_TOL_SOLID, Aspect_WOL_THIN);
1793 length->SetTextRelPos(txtPosH,txtPosV);
1794 length->SetTextRelAngle(txtAngle);
1795
1796 aIO10->SetAspect( theAspect, length);
1797 aContext->Display( aIO10, Standard_True );
1798
1799 return 0;
1800}
1801
1802#include <TopoDS_Solid.hxx>
1803#include <BRepFeat_MakeDPrism.hxx>
1804//=======================================================================
1805//function : OCCN1
1806//purpose : FEATURE OPERATION (BOSS and SLOT)
1807//=======================================================================
1808static Standard_Integer OCCN1 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1809{
1810 if (argc != 4)
1811 {
1812 di << "Usage : " << argv[0] << " angle fuse(1 for boss / 0 for slot) length" << "\n";
1813 return 1;
1814 }
1815
1816 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1817 if(aContext.IsNull())
1818 {
1819 di << "use 'vinit' command before " << argv[0] << "\n";
1820 return 1;
1821 }
1822 Standard_Real angle = atof(argv[1]);
1823 Standard_Integer fuse = atoi(argv[2]);
1824 Standard_Real length = atof(argv[3]);
1825
1826 BRepBuilderAPI_MakeEdge edge1(gp_Pnt(0, 0, 0), gp_Pnt(50, 0, 0));
1827 BRepBuilderAPI_MakeEdge edge2(gp_Pnt(50, 0, 0), gp_Pnt(50, 50, 0));
1828 BRepBuilderAPI_MakeEdge edge3(gp_Pnt(50, 50, 0), gp_Pnt(0, 50, 0));
1829 BRepBuilderAPI_MakeEdge edge4(gp_Pnt(0, 50, 0), gp_Pnt(0, 0, 0));
1830 TopoDS_Edge ted1 = edge1.Edge();
1831 TopoDS_Edge ted2 = edge2.Edge();
1832 TopoDS_Edge ted3 = edge3.Edge();
1833 TopoDS_Edge ted4 = edge4.Edge();
1834
1835 BRepBuilderAPI_MakeWire wire(ted1, ted2, ted3, ted4);
1836 TopoDS_Wire twire = wire.Wire();
1837
1838 BRepBuilderAPI_MakeFace face(twire);
1839 TopoDS_Face tface = face.Face();
1840 ////////Handle_AIS_Shape face_ais = new AIS_Shape( tface );
1841 ////////aContext->Display(face_ais);
1842
1843 TopoDS_Solid box;
1844 BRepPrimAPI_MakeBox block(gp_Pnt(-50, -50, -150), 150, 150, 100);
1845 box = block.Solid();
1846
1847 TopoDS_Face top_face;
1848 top_face = block.TopFace();
1849
1850 BRepFeat_MakeDPrism slot(box, tface, top_face, angle, fuse,
1851 Standard_True);
1852
1853 slot.Perform(length);
1854 TopoDS_Shape S2 = slot.Shape();
1855
1856 DBRep::Set("OCCN1_tface",tface);
1857 DBRep::Set("OCCN1_slot",S2);
1858
1859 return 0;
1860}
1861
1862#include <BRepPrimAPI_MakeCylinder.hxx>
1863#include <BRepPrimAPI_MakeSphere.hxx>
1864#include <BRepAlgoAPI_Section.hxx>
1865#include <BRepAlgo_Section.hxx>
1866//=======================================================================
1867//function : OCCN2
1868//purpose : BOOLEAN OPERATION
1869//=======================================================================
1870static Standard_Integer OCCN2 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1871{
1872 if (argc > 2) {
1873 di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1874 return 1;
1875 }
1876 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1877 if (argc == 2) {
1878 Standard_Integer IsB = atoi(argv[1]);
1879 if (IsB != 1) {
1880 IsBRepAlgoAPI = Standard_False;
1881#if ! defined(BRepAlgo_def04)
1882#endif
1883 }
1884 }
1885
1886 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1887 if(aContext.IsNull())
1888 {
1889 di << "use 'vinit' command before " << argv[0] << "\n";
1890 return 1;
1891 }
1892
1893 BRepPrimAPI_MakeCylinder cylinder(50,200);
1894 TopoDS_Shape cylinder_sh = cylinder.Shape();
1895
1896 BRepPrimAPI_MakeSphere sphere(gp_Pnt(60,0,100),50);
1897 TopoDS_Shape sphere_sh = sphere.Shape();
1898
1899 //BRepAlgoAPI_Section section(cylinder_sh, sphere_sh);
1900 //TopoDS_Shape shape = section.Shape();
1901
1902 TopoDS_Shape shape;
1903 if (IsBRepAlgoAPI) {
1904 di << "BRepAlgoAPI_Section section(cylinder_sh, sphere_sh)" <<"\n";
1905 BRepAlgoAPI_Section section(cylinder_sh, sphere_sh);
1906 section.Build();
1907 if(!section.IsDone()){
1908 di << "Error performing intersection: not done." << "\n";
1909 }
1910 shape = section.Shape();
1911 } else {
1912 di << "BRepAlgo_Section section(cylinder_sh, sphere_sh)" <<"\n";
1913 BRepAlgo_Section section(cylinder_sh, sphere_sh);
1914 section.Build();
1915 if(!section.IsDone()){
1916 di << "Error performing intersection: not done." << "\n";
1917 }
1918 shape = section.Shape();
1919 }
1920
1921 DBRep::Set("OCCN2_cylinder",cylinder_sh);
1922 DBRep::Set("OCCN2_sphere",sphere_sh);
1923 DBRep::Set("OCCN2_section",shape);
1924
1925 return 0;
1926}
1927
1928#include <TColgp_Array1OfPnt.hxx>
1929#include <Geom_BezierCurve.hxx>
1930
1931static Standard_Integer OCC2569 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1932{
1933 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1934 if(aContext.IsNull())
1935 {
1936 di << "use 'vinit' command before " << argv[0] << "\n";
1937 return 1;
1938 }
1939 if(argc != 3) {
1940 di << "Usage : " << argv[0] << " nbpoles result" << "\n";
1941 return 1;
1942 }
1943
1944 int poles=atoi(argv[1]);
1945
1946 TColgp_Array1OfPnt arr(1, poles);
1947 for(int i=1; i<=poles; i++)
1948 arr.SetValue(i, gp_Pnt(i+10, i*2+20, i*3+45));
1949
1950 Handle_Geom_BezierCurve bez = new Geom_BezierCurve(arr);
1951 if(bez.IsNull()) {
1952 di << "\n The curve is not created.\n";
1953 } else {
1954 di << "\n Degree = " << bez->Degree() << "\n";
1955 }
1956 TopoDS_Edge sh = BRepBuilderAPI_MakeEdge(bez).Edge();
1957 Handle_AIS_Shape ais = new AIS_Shape(sh);
1958 aContext->Display(ais);
1959 DrawTrSurf::Set(argv[2],bez);
1960 return 0;
1961}
1962
1963#include <TopTools_IndexedMapOfShape.hxx>
1964#include <TopExp.hxx>
1965
1966static Standard_Integer OCC1642 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1967{
1968 if (argc != 10) {
1969 di<<"Usage: " << argv[0] << " FinalWare FinalFace InitWare InitFace shape FixReorder FixDegenerated FixConnected FixSelfIntersection"<<"\n";
1970 return 1;
1971 }
1972
1973 TopoDS_Shape shape = DBRep::Get(argv[5]);
1974
1975 TopExp_Explorer exp(shape, TopAbs_WIRE);
1976 TopoDS_Shape wire = exp.Current();
1977
1978 Handle(ShapeAnalysis_Wire) advWA = new ShapeAnalysis_Wire;
1979 advWA->Load(TopoDS::Wire(wire));
1980
1981 DBRep::Set(argv[3],wire);
1982
1983 TopoDS_Face face =
1984 BRepBuilderAPI_MakeFace(TopoDS::Wire(wire),Standard_True);
1985
1986 DBRep::Set(argv[4],face);
1987
1988 advWA->SetFace(face);
1989 float precision_to_ana = 0.0001;
1990 advWA->SetPrecision(precision_to_ana);
1991
1992 TopTools_IndexedMapOfShape M;
1993 TopExp::MapShapes(wire, TopAbs_EDGE, M);
1994
1995 int j= 1;
1996 for(j= 1; j<=M.Extent(); ++j) {
1997 Standard_Integer num=1;
1998 IntRes2d_SequenceOfIntersectionPoint points2d;
1999 TColgp_SequenceOfPnt points3d;
2000
2001 cout << "\n j =" << j << ", CheckSelfIntersectingEdge = " <<
2002 advWA->CheckSelfIntersectingEdge(j, points2d, points3d);
2003
2004
2005 ShapeExtend_Status status = ShapeExtend_FAIL1;
2006 if(advWA->StatusSelfIntersection(status))
2007
2008 status = ShapeExtend_FAIL2;
2009 if(advWA->StatusSelfIntersection(status))
2010 di << "\n No Vertices found in the edge";
2011
2012 status = ShapeExtend_DONE1;
2013 if(advWA->StatusSelfIntersection(status))
2014 di << "\n Self-intersection found in the edge";
2015
2016 num = points2d.Length();
2017 di << "\n No. of self-intersecting edges : " << num;
2018
2019 for(int i=1; i<=num; ++i) {
2020 gp_Pnt pt = points3d(i);
2021 di << "\n Intersecting pt : (" << pt.X() << ", " << pt.Y()<< ", " << pt.Z() << ")";
2022 }
2023
2024 }
2025
2026 Handle_ShapeFix_Wire sfw = new ShapeFix_Wire;
2027 sfw->Load(TopoDS::Wire(wire));
2028 sfw->SetFace(face);
2029 sfw->SetPrecision(Precision::Confusion());
2030
2031 sfw->FixReorderMode() = 1;
2032 sfw->ClosedWireMode() = 1;
2033 sfw->FixDegeneratedMode() = 1;
2034 sfw->FixConnectedMode() = 1;
2035 sfw->ModifyTopologyMode() = 1;
2036 sfw->ModifyGeometryMode() = 1;
2037 sfw->FixSelfIntersectionMode() = 1;
2038 sfw->FixSelfIntersectingEdgeMode() = 1;
2039 sfw->FixIntersectingEdgesMode() = 1;
2040 sfw->FixNonAdjacentIntersectingEdgesMode() = 1;
2041 sfw->FixEdgeCurvesMode() = 1;
2042
2043 sfw->ModifyRemoveLoopMode() = 1;
2044 sfw->SetMaxTolerance(1.0);
2045
2046 di << "\n FixReorder = " << (Standard_Integer) sfw->FixReorder();
2047 di << "\n FixDegenerated = " << (Standard_Integer) sfw->FixDegenerated();
2048 di << "\n FixConnected = " << (Standard_Integer) sfw->FixConnected();
2049 di << "\n";
2050 di << "\n FixSelfIntersection = " << (Standard_Integer) sfw->FixSelfIntersection();
2051 di << "\n";
2052
2053 Draw::Set(argv[6],sfw->FixReorder()) ;
2054 Draw::Set(argv[7],sfw->FixDegenerated()) ;
2055 Draw::Set(argv[8],sfw->FixConnected()) ;
2056 Draw::Set(argv[9],sfw->FixSelfIntersection()) ;
2057
2058 ShapeExtend_Status status = ShapeExtend_OK;
2059 if(sfw->StatusSelfIntersection(status))
2060 di << "\n ShapeExtend_OK : No intersection found";
2061
2062 status = ShapeExtend_FAIL1;
2063 if(sfw->StatusSelfIntersection(status))
2064 di << "\n ShapeExtend_FAIL1 : analysis failed (edge has no pcurve,or no vertices etc.)";
2065
2066 status = ShapeExtend_FAIL2;
2067 if(sfw->StatusSelfIntersection(status))
2068 di << "\n ShapeExtend_FAIL2 : self-intersection was found, but not fixed because of limit of increasing tolerance (MaxTolerance)";
2069
2070 status = ShapeExtend_FAIL3;
2071 if(sfw->StatusSelfIntersection(status))
2072 di << "\n ShapeExtend_FAIL3 : intercestion of non adjacent edges found, but not fixed because of limit of increasing tolerance (MaxTolerance)";
2073
2074 status = ShapeExtend_DONE1;
2075 if(sfw->StatusSelfIntersection(status))
2076 di << "\n ShapeExtend_DONE1 : tolerance of vertex was increased to fix self-intersection";
2077
2078 status = ShapeExtend_DONE2;
2079 if(sfw->StatusSelfIntersection(status))
2080 di << "\n ShapeExtend_DONE2 : vertex was moved to fix self-intersection";
2081
2082 status = ShapeExtend_DONE3;
2083 if(sfw->StatusSelfIntersection(status))
2084 di << "\n ShapeExtend_DONE3 : some edges were removed because of intersection";
2085
2086 status = ShapeExtend_DONE4;
2087 if(sfw->StatusSelfIntersection(status))
2088 di << "\n ShapeExtend_DONE4 : pcurve(s) was(were) modified";
2089
2090 status = ShapeExtend_DONE5;
2091 if(sfw->StatusSelfIntersection(status))
2092 di << "\n ShapeExtend_DONE5 : non adjacent intersection fixed by increasing tolerance of vertex(vertices)";
2093
2094 status = ShapeExtend_DONE6;
2095 if(sfw->StatusSelfIntersection(status))
2096 di << "\n ShapeExtend_DONE6 : tolerance of edge was increased to hide intersection";
2097
2098 status = ShapeExtend_DONE7;
2099 if(sfw->StatusSelfIntersection(status))
2100 di << "\n ShapeExtend_DONE7 : range of some edges was decreased to avoid intersection";
2101
2102 TopoDS_Wire finalwire = sfw->Wire();
2103
2104 DBRep::Set(argv[1],finalwire);
2105
2106
2107 advWA->Load(TopoDS::Wire(finalwire));
2108
2109 TopoDS_Face fface =
2110 BRepBuilderAPI_MakeFace(TopoDS::Wire(finalwire),Standard_True);
2111
2112 DBRep::Set(argv[2],fface);
2113
2114 advWA->SetFace(fface);
2115
2116 TopTools_IndexedMapOfShape fM;
2117 TopExp::MapShapes(finalwire, TopAbs_EDGE, fM);
2118
2119 for(j= 1; j<=fM.Extent(); ++j) {
2120 Standard_Integer num=1;
2121 IntRes2d_SequenceOfIntersectionPoint points2d;
2122 TColgp_SequenceOfPnt points3d;
2123
2124 di << "\n j =" << j << ", CheckSelfIntersectingEdge = " <<
2125 (Standard_Integer) advWA->CheckSelfIntersectingEdge(j, points2d, points3d);
2126
2127
2128 ShapeExtend_Status status = ShapeExtend_FAIL1;
2129 if(advWA->StatusSelfIntersection(status))
2130
2131 status = ShapeExtend_FAIL2;
2132 if(advWA->StatusSelfIntersection(status))
2133 di << "\n No Vertices found in the edge";
2134
2135 status = ShapeExtend_DONE1;
2136 if(advWA->StatusSelfIntersection(status))
2137 di << "\n Self-intersection found in the edge";
2138
2139 num = points2d.Length();
2140 di << "\n No. of self-intersecting edges : " << num;
2141
2142 for(int i=1; i<=num; ++i) {
2143 gp_Pnt pt = points3d(i);
2144 di << "\n Intersecting pt : (" << pt.X() << ", " << pt.Y() << ", " << pt.Z() << ")";
2145 }
2146
2147 }
2148
2149 di << "\n";
2150
2151 return 0;
2152}
2153
2154Standard_Integer OCC17480(Draw_Interpretor& di, Standard_Integer n, const char ** a)
2155{
2156 if ( n < 2 ) {
2157 cout << "Usage: OCC17480 basic_shape <mode[0:1]>" <<endl;
2158 return 0;
2159 }
2160
2161 TopoDS_Shape brep_pipe = DBRep::Get(a[1]);
2162
2163 Standard_Boolean mode = Standard_False;
2164 if(n == 3 && atoi(a[2]) == 1)
2165 mode = Standard_True;
2166
2167 Handle_AIS_Shape ais_pipe = new AIS_Shape( brep_pipe );
2168 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
2169 Handle(AIS2D_InteractiveContext) aContext_2d = Viewer2dTest::GetAIS2DContext();
2170
2171 if(!aContext.IsNull())
2172 aContext->Display(ais_pipe);
2173
2174 if(!aContext_2d.IsNull())
2175 aContext_2d->EraseAll(Standard_True);
2176
2177 gp_Ax3 ax3(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1), gp_Dir(0, 1, 0));
2178 gp_Pln plane(ax3);
2179 gp_Ax2 ax2 = ax3.Ax2();
2180
2181 HLRAlgo_Projector aProjector = HLRAlgo_Projector(ax2);
2182 Handle_AIS2D_ProjShape myDisplayableShape =
2183 new AIS2D_ProjShape(aProjector, 0, mode, Standard_True);
2184
2185 myDisplayableShape->Add( brep_pipe );
2186
2187 di << "\n Total number of primitives : " << myDisplayableShape->Length();
2188
2189 Handle(Graphic2d_Line) mySectProjLines = myDisplayableShape->GetPrimitives();
2190 Handle(Graphic2d_Line) mySectProjLinesHLR = myDisplayableShape->GetHLPrimitives();
2191
2192 Handle_Standard_Type sty = mySectProjLines->DynamicType();
2193 Handle_Standard_Type sty1 = mySectProjLinesHLR->DynamicType();
2194
2195 di << "\n Class Name = " << (char*)sty->Name();
2196 di << "\n HLR Class Name = " << (char*)sty1->Name();
2197 di << "\n mySectProjLines.IsNull = " << (Standard_Integer) mySectProjLines.IsNull();
2198 di << "\n mySectProjLinesHLR.IsNull = " << (Standard_Integer) mySectProjLinesHLR.IsNull();
2199
2200 Handle(GGraphic2d_SetOfCurves) setCurves;
2201 Handle(Graphic2d_SetOfSegments) setSegments;
2202
2203 if(mySectProjLines->IsKind(STANDARD_TYPE(GGraphic2d_SetOfCurves)))
2204 {
2205 setCurves = Handle(GGraphic2d_SetOfCurves)::DownCast(mySectProjLines);
2206 di << "\n Number of Curves in set = " << setCurves->Length();
2207 }
2208 if(mySectProjLines->IsKind(STANDARD_TYPE(Graphic2d_SetOfSegments)))
2209 {
2210 setSegments = Handle(Graphic2d_SetOfSegments)::DownCast(mySectProjLines);
2211 di << "\n Number of Curves in set = " << setSegments->Length();
2212 }
2213
2214 Handle(GGraphic2d_SetOfCurves) setCurvesHLR;
2215 Handle(Graphic2d_SetOfSegments) setSegmentsHLR;
2216
2217 if(mySectProjLinesHLR->IsKind(STANDARD_TYPE(GGraphic2d_SetOfCurves)))
2218 {
2219 setCurvesHLR = Handle(GGraphic2d_SetOfCurves)::DownCast(mySectProjLinesHLR);
2220 di << "\n HLR Number of Curves in set = " << setCurvesHLR->Length();
2221 }
2222 if(mySectProjLinesHLR->IsKind(STANDARD_TYPE(Graphic2d_SetOfSegments)))
2223 {
2224 setSegmentsHLR = Handle(Graphic2d_SetOfSegments)::DownCast(mySectProjLinesHLR);
2225 di << "\n HLR Number of Curves in set = " << setSegmentsHLR->Length();
2226 }
2227
2228 aContext_2d->Display( myDisplayableShape,Standard_True );
2229 return 0;
2230}
2231
2232void QATelco::Commands(Draw_Interpretor& theCommands) {
2233 char *group = "QATelco";
2234
2235 theCommands.Add ("BUC60842", "BUC60842", __FILE__, BUC60842, group);
2236 theCommands.Add ("BUC60843", "BUC60843 result_shape name_of_circle name_of_curve [ par1 [ tol ] ]", __FILE__, BUC60843, group);
2237 theCommands.Add ("BUC60970", "BUC60970 shape result", __FILE__, BUC60970, group);
2238 theCommands.Add ("BUC60818", "BUC60818", __FILE__, BUC60818, group);
2239 theCommands.Add ("BUC60915", "BUC60915", __FILE__, BUC60915_1, group);
2240 theCommands.Add ("OCC138", "OCC138", __FILE__, OCC138, group);
2241 theCommands.Add ("BUC60821","BUC60821",__FILE__,BUC60821,group);
2242 theCommands.Add ("OCC353","OCC353",__FILE__,OCC353,group);
2243 theCommands.Add ("OCC280","OCC280 hlr=0/1 setsurfecedetail=0/1; set perspecrive view",__FILE__,OCC280,group);
2244 theCommands.Add ("OCC232", "OCC232", __FILE__, OCC232 , group);
2245 theCommands.Add ("OCC138LC", "OCC138LC", __FILE__, OCC138LC, group);
2246 theCommands.Add ("OCC189", "OCC189", __FILE__, OCC189, group);
2247 theCommands.Add ("OCC389", "OCC389 name shape1 [shape2] ...", __FILE__, OCC389, group);
2248
2249 theCommands.Add ("OCC566", "OCC566 shape [ xmin ymin zmin xmax ymax zmax] ; print bounding box", __FILE__, OCC566, group);
2250 theCommands.Add ("OCC570", "OCC570 result", __FILE__, OCC570, group);
2251
2252 theCommands.Add("OCC570mkevol",
2253 "OCC570mkevol result object (then use updatevol) [R/Q/P]; mkevol",
2254 __FILE__, MKEVOL,group);
2255 theCommands.Add("OCC570updatevol",
2256 "OCC570updatevol edge u1 rad1 u2 rad2 ...; updatevol",
2257 __FILE__, UPDATEVOL,group);
2258 theCommands.Add("OCC570updatevollaw",
2259 "OCC570updatevollaw edge u1 rad1 u2 rad2 ...; updatevollaw",
2260 __FILE__, UPDATEVOL,group);
2261 theCommands.Add("OCC570buildevol",
2262 "OCC570buildevol; end of the evol fillet computation",
2263 __FILE__, BUILDEVOL,group);
2264
2265 theCommands.Add ("OCC606", "OCC606 result shape [-t]", __FILE__, OCC606, group);
2266
2267 theCommands.Add ("OCC813", "OCC813 U V", __FILE__, OCC813, group);
2268 theCommands.Add ("OCC814", "OCC814", __FILE__, OCC814, group);
2269 theCommands.Add ("OCC884", "OCC884 result shape [toler [maxtoler]]", __FILE__, OCC884, group);
2270 theCommands.Add ("OCC1188", "OCC1188 imagefile [filltype] : Load image as background", __FILE__, OCC1188, group);
2271
2272 theCommands.Add ("OCC1174_1", "OCC1174_1 shape", __FILE__, OCC1174_1, group);
2273 theCommands.Add ("OCC1174_2", "OCC1174_2 shape", __FILE__, OCC1174_2, group);
2274
2275 theCommands.Add("OCC672_Length"," OCC672_Length x1 y1 x2 y2 str scale_text length_dist angle_arrow length_arrow x3 y3 x4 y4 textAngle textPosH textPosV",__FILE__,OCC672_Length,group);
2276 theCommands.Add("OCC672_Angle","OCC672_Angle x1 y1 x2 y2 x3 y3 aRadius aText aTxtScale anArrAngle anArrLength txtAngle txtPosH txtPosV",__FILE__,OCC672_Angle,group);
2277 theCommands.Add("OCC672_Diameter","OCC672_Diameter x1 y1 cx cy radius aText aTxtScale anArrAngle anArrLength txtAngle txtPosH txtPosV",__FILE__,OCC672_Diameter,group);
2278 theCommands.Add("OCC672_ShortLength","",__FILE__,OCC672_ShortLength,group);
2279
2280 theCommands.Add ("OCCN1", "OCCN1 angle fuse(1 for boss / 0 for slot) length", __FILE__, OCCN1, group);
2281 theCommands.Add ("OCCN2", "OCCN2", __FILE__, OCCN2, group);
2282
2283 theCommands.Add ("OCC2569", "OCC2569 nbpoles result", __FILE__, OCC2569, group);
2284
2285 theCommands.Add ("OCC1642", "OCC1642 FinalWare FinalFace InitWare InitFace shape FixReorder FixDegenerated FixConnected FixSelfIntersection", __FILE__, OCC1642, group);
2286
2287 theCommands.Add ("OCC17480", "OCC17480 Shape", __FILE__, OCC17480, group);
2288
2289 return;
2290}