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