0024778: Convertation of the generic classes to the non-generic. Part 9
[occt.git] / src / QABugs / QABugs_17.cxx
CommitLineData
b311480e 1// Created on: 2002-03-18
2// Created by: QA Admin
973c2be1 3// Copyright (c) 2002-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
7fd59977 15
7fd59977 16#include <stdio.h>
17
1cd84fee 18#include <QABugs.hxx>
7fd59977 19
91322f44 20#include <Draw.hxx>
7fd59977 21#include <Draw_Interpretor.hxx>
22#include <DBRep.hxx>
23#include <DrawTrSurf.hxx>
24#include <AIS_InteractiveContext.hxx>
25#include <ViewerTest.hxx>
5e27df78 26#include <ViewerTest_EventManager.hxx>
7fd59977 27#include <AIS_Shape.hxx>
28#include <TopoDS_Shape.hxx>
29
30#include <Geom_Circle.hxx>
31#include <Geom_Ellipse.hxx>
32#include <Geom_Plane.hxx>
33#include <gp_Pln.hxx>
34#include <Geom2d_Curve.hxx>
35#include <GeomAPI.hxx>
36#include <Geom2dAdaptor_Curve.hxx>
37#include <Geom2dGcc_QualifiedCurve.hxx>
38#include <Geom2dGcc_Lin2d2Tan.hxx>
39#include <Geom2d_Line.hxx>
40#include <BRepBuilderAPI_MakeEdge.hxx>
41#include <TopoDS_Edge.hxx>
42#include <Precision.hxx>
43#include <Geom2d_Circle.hxx>
0b85f9a6 44#include <Geom2dGcc_QCurve.hxx>
7fd59977 45#include <GccEnt_QualifiedCirc.hxx>
54e37688 46#include <Geom2dGcc_Lin2d2TanIter.hxx>
7fd59977 47#include <BRepBuilderAPI_MakeWire.hxx>
48#include <TopExp_Explorer.hxx>
49#include <TopoDS.hxx>
50#include <TopoDS_Wire.hxx>
51#include <BRep_Tool.hxx>
52#include <gp_Circ.hxx>
53#include <BRepOffsetAPI_MakePipeShell.hxx>
54#include <AIS_Trihedron.hxx>
55#include <Geom_Axis2Placement.hxx>
56#include <V3d_View.hxx>
57#include <ViewerTest_Tool.hxx>
58#include <BRepBuilderAPI_MakeVertex.hxx>
59#include <AIS_LengthDimension.hxx>
60#include <AIS_RadiusDimension.hxx>
61#include <BRepPrimAPI_MakeBox.hxx>
62#include <GeomAdaptor_Surface.hxx>
63#include <Extrema_ExtPS.hxx>
64#include <Geom_CartesianPoint.hxx>
65#include <Geom2d_CartesianPoint.hxx>
66#include <Geom2dGcc_Circ2d3Tan.hxx>
67#include <Aspect_Window.hxx>
68
69#include <TopoDS_Compound.hxx>
70#include <TopoDS_CompSolid.hxx>
71#include <StdSelect_ShapeTypeFilter.hxx>
1cd84fee 72#include <QABugs_MyText.hxx>
7fd59977 73#include <Prs3d_Projector.hxx>
74#include <HLRAlgo_Projector.hxx>
7fd59977 75#include <Standard_ErrorHandler.hxx>
aff395a3 76#include <Font_NameOfFont.hxx>
7fd59977 77
78static Standard_Integer BUC60842 (Draw_Interpretor& di, Standard_Integer /*argc*/,const char ** /*argv*/)
79{
80 Standard_Character abuf[16];
81 //Standard_Character * abuf = new Standard_Character[16];
82
83 Standard_CString st = abuf;
84
85 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);
86 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);
87 Handle(Geom_Plane) plne = new Geom_Plane (gp_Ax3 (gp_Ax2 (gp_Pnt (1262.224429, 425.040878, 363.609716), gp_Dir (0.173648, 0.984808, 0.000000), gp_Dir (-0.932169, 0.164367, -0.322560))));
88
89 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
90
91 gp_Pln pln = plne->Pln();
92 Handle(Geom2d_Curve) curve2d = GeomAPI::To2d (ell, pln);
91322f44 93 Sprintf(abuf,"ell");
7fd59977 94 DrawTrSurf::Set(st,curve2d);
95 if(!aContext.IsNull()) {
96 Handle(AIS_Shape) aisp =
97 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(curve2d, pln)).Edge());
98 aContext->Display (aisp);
99 }
100
101 Handle(Geom2d_Curve) fromcurve2d = GeomAPI::To2d (cir, pln);
91322f44 102 Sprintf(abuf,"cil");
7fd59977 103 DrawTrSurf::Set(st,fromcurve2d);
104 if(!aContext.IsNull()) {
105 Handle(AIS_Shape) aisp =
106 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(fromcurve2d, pln)).Edge());
107 aContext->Display (aisp);
108 }
109
110 Geom2dAdaptor_Curve acur (curve2d), afromcur (fromcurve2d);
111 Geom2dGcc_QualifiedCurve qcur (acur, GccEnt_outside);
112 Geom2dGcc_QualifiedCurve qfromcur (afromcur, GccEnt_outside);
113 Geom2dGcc_Lin2d2Tan lintan (qcur, qfromcur, 0.1, 0.0, 0.0);
114 Standard_Integer i=0;
115 for(i=0;i<lintan.NbSolutions();i++) {
91322f44 116 Sprintf(abuf,"lintan_%d",i);
7fd59977 117 Handle(Geom2d_Line) glin = new Geom2d_Line(lintan.ThisSolution(i));
118 DrawTrSurf::Set(st,glin);
119 if(!aContext.IsNull()) {
120 Handle(AIS_Shape) aisp =
121 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(glin, pln)).Edge()); aContext->Display (aisp);
122 }
123 }
124 di << " Is Done = \n" << (Standard_Integer) lintan.IsDone();
125 return 0;
126}
127
128static Standard_Integer BUC60843 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
129{
130 if (argc != 4 && argc != 5 && argc != 6 && argc != 7) {
131 di << "Usage : " << argv[0] << "result_shape name_of_circle name_of_curve [ par1 [ tol ] ]" << "\n";
132 return 1;
133 }
134
135 Standard_Real par1 = 0.0, par2 = 0.0;
136 Standard_Real tol = Precision::Angular();
137 if (argc >= 5)
91322f44 138 par1 = Draw::Atof(argv[4]);
7fd59977 139 if (argc == 6)
91322f44 140 par2 = Draw::Atof(argv[5]);
7fd59977 141 if (argc == 7)
91322f44 142 tol = Draw::Atof(argv[6]);
7fd59977 143 Handle(Geom2d_Curve) aCur2d1 = DrawTrSurf::GetCurve2d(argv[2]);
144 Handle(Geom2d_Curve) aCur2d2 = DrawTrSurf::GetCurve2d(argv[3]);
145 if (aCur2d1.IsNull() || aCur2d2.IsNull()) {
146 di << "Faulty : not curves" << "\n";
147 return 1;
148 }
149 Standard_Boolean c1IsCircle = Standard_False;
150 Handle(Geom2d_Circle) aCir2d = Handle(Geom2d_Circle)::DownCast(aCur2d1);
151 if (!aCir2d.IsNull()) {
152 c1IsCircle = Standard_True;
91322f44 153 if (argc == 6) tol = Draw::Atof(argv[5]);
7fd59977 154 }
155 if(c1IsCircle) {
156 Geom2dAdaptor_Curve acur(aCur2d2);
0b85f9a6 157 Geom2dGcc_QCurve qcur(acur, GccEnt_unqualified);
7fd59977 158 GccEnt_QualifiedCirc qfromcur(aCir2d->Circ2d(), GccEnt_unqualified);
54e37688 159 Geom2dGcc_Lin2d2TanIter lintan(qfromcur, qcur , par1, tol);
7fd59977 160 if (lintan.IsDone()) {
161 gp_Lin2d lin = lintan.ThisSolution();
162 Handle(Geom2d_Line) glin = new Geom2d_Line(lin);
163 DrawTrSurf::Set(argv[1], glin);
164 } else {
165 di << "Faulty : tangent line is not done." << "\n";
166 }
167 }
168 else {
169 Geom2dAdaptor_Curve acur1(aCur2d1);
170 Geom2dAdaptor_Curve acur2(aCur2d2);
0b85f9a6 171 Geom2dGcc_QCurve qcur1(acur1, GccEnt_unqualified);
172 Geom2dGcc_QCurve qcur2(acur2, GccEnt_unqualified);
54e37688 173 Geom2dGcc_Lin2d2TanIter lintan(qcur1, qcur2 , par1, par2, tol);
7fd59977 174 if (lintan.IsDone()) {
175 gp_Lin2d lin = lintan.ThisSolution();
176 Handle(Geom2d_Line) glin = new Geom2d_Line(lin);
177 DrawTrSurf::Set(argv[1], glin);
178 } else {
179 di << "Faulty : tangent line is not done." << "\n";
180 }
181 }
182 return 0;
183}
184
185static Standard_Integer BUC60970 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
186{
187 if(argc!=3)
188 {
189 di << "Usage : " << argv[0] << " shape result" <<"\n";
190 return 1;
191 }
192
193 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
194 if(aContext.IsNull()) {
195 di << "use 'vinit' command before " << argv[0] << "\n";
196 return 1;
197 }
198
199 TopoDS_Shape aResult = DBRep::Get(argv[1]);
200
201 BRepBuilderAPI_MakeWire bRepSpineWire;
202 TopExp_Explorer exp_(aResult, TopAbs_WIRE);
203
204 Standard_Integer i = 0;
205 for(;exp_.More();exp_.Next()){
206 i++;
207 bRepSpineWire.Add(TopoDS::Wire(exp_.Current()));
208 }
209
210 //printf("total no of wires are ............. %d\n", i);
211 di << "total no of wires are ............. " << i << "\n";
212
213 TopoDS_Wire spineWire = bRepSpineWire.Wire();
214 aContext->Display(new AIS_Shape(spineWire));
215
216 DBRep::Set("slineW",spineWire);
217
218 TopExp_Explorer spineWireExp(spineWire, TopAbs_EDGE);
219 Standard_Real first, last;
220 Handle_Geom_Curve curl_ = BRep_Tool::Curve(TopoDS::Edge(spineWireExp.Current()), first, last);
221 gp_Pnt firstPnt;
222 gp_Vec tanVec;
223 curl_->D1(first, firstPnt, tanVec);
224 tanVec.Normalize();
225 gp_Dir tanDir(tanVec.X(), tanVec.Y(), tanVec.Z());
226 gp_Ax2 gpAx2(firstPnt, tanDir);
227 gp_Circ gpCirc(gpAx2, 2.5);
228 BRepBuilderAPI_MakeWire aMWire(BRepBuilderAPI_MakeEdge(new Geom_Circle(gpCirc)).Edge());
229 TopoDS_Wire topoWire(aMWire);
230 aContext->Display(new AIS_Shape(topoWire));
231
232 DBRep::Set("topoW",topoWire);
233
234 BRepOffsetAPI_MakePipeShell bRepPipe(spineWire);
235 bRepPipe.Add(topoWire);
236 bRepPipe.Build();
237
238 aContext->Display(new AIS_Shape(bRepPipe.Shape()));
239
240 DBRep::Set(argv[2],bRepPipe.Shape());
241
242 return 0;
243}
244
245static Standard_Integer BUC60818(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
246{
247 if(argc!=1)
248 {
249 di << "Usage : " << argv[0] << "\n";
250 return -1;
251 }
252
253 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
254 if(myAISContext.IsNull())
255 {
256 di << "use 'vinit' command before " << argv[0] << "\n";
257 return -1;
258 }
259
260 // TRIHEDRON
261 Handle(AIS_Trihedron) aTrihedron;
262 Handle(Geom_Axis2Placement) aTrihedronAxis=new Geom_Axis2Placement(gp::XOY());
263 aTrihedron=new AIS_Trihedron(aTrihedronAxis);
264 myAISContext->Display(aTrihedron);
265
266 myAISContext->OpenLocalContext();
267 myAISContext->Load(aTrihedron,0);
268
269 myAISContext->SetAutomaticHilight( Standard_False );
270
271 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
272 double Xv,Yv;
273 myV3dView->Project(0,0,0,Xv,Yv);
274
275 Standard_Integer Xp,Yp;
276 myV3dView->Convert(Xv,Yv,Xp,Yp);
277
278 myAISContext->MoveTo( Xp,Yp, myV3dView );
279 myAISContext->MoveTo( Xp,Yp, myV3dView );
280
281 if (myAISContext->HasDetected( ))
282 di << "has detected shape : OK" << "\n";
283 else di << "has detected shape : bugged - Faulty " << "\n";
284
285 myAISContext->SetAutomaticHilight( Standard_True );
286
287 return 0;
288}
289
60bf98ae 290static Standard_Integer BUC60915_1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
7fd59977 291{
292 if (argc > 1) {
293 di<<"Function don't has parameters"<<"\n";
294 return 1;
295 }
296
60bf98ae 297 if(ViewerTest::GetAISContext().IsNull())
298 {
299 di << "View was not created. Use 'vinit' command before "
300 << argv[0] << "\n";
301 return 1;
302 }
303 Handle(AIS_InteractiveContext) context = ViewerTest::GetAISContext();
7fd59977 304
305 //The following dimesion code has problems regarding arrow_size. The desired effect is not produced.
306 /***************************************/
307 //First view
308 /***************************************/
309 gp_Pnt p1 = gp_Pnt(602.51,50.,0.);
310 gp_Pnt p2 = gp_Pnt(602.51,200.,0.);
311 gp_Pnt p3 = gp_Pnt(102.51,200.,0.);
312 gp_Pnt p4 = gp_Pnt(102.51,170.,0.);
313 gp_Pnt p5 = gp_Pnt(502.51,170.,0.);
314 gp_Pnt p6 = gp_Pnt(502.51,80.,0.);
315 gp_Pnt p7 = gp_Pnt(102.51,80.,0.);
316 gp_Pnt p8 = gp_Pnt(102.51,50.,0.);
317 TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(p1);
318 TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(p2);
319 TopoDS_Vertex V3 = BRepBuilderAPI_MakeVertex(p3);
320 TopoDS_Vertex V4 = BRepBuilderAPI_MakeVertex(p4);
321 TopoDS_Vertex V5 = BRepBuilderAPI_MakeVertex(p5);
322 TopoDS_Vertex V6 = BRepBuilderAPI_MakeVertex(p6);
323 TopoDS_Vertex V7 = BRepBuilderAPI_MakeVertex(p7);
324 TopoDS_Vertex V8 = BRepBuilderAPI_MakeVertex(p8);
325 gp_Pnt plnpt(0, 0, 0);
326 gp_Dir plndir(0, 0, 1);
327 Handle(Geom_Plane) pln = new Geom_Plane(plnpt,plndir);
60bf98ae 328 Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
329 anAspect->MakeArrows3d (Standard_True);
330 anAspect->ArrowAspect()->SetAngle (M_PI/180.0 * 10.0);
7fd59977 331 /***************************************/
332 //dimension "L 502.51"
333 /***************************************/
a6eb515f 334 Handle(AIS_LengthDimension) len = new AIS_LengthDimension(V2, V3, pln->Pln());
60bf98ae 335 anAspect->ArrowAspect()->SetLength (30.0);
336 len->SetDimensionAspect (anAspect);
7fd59977 337 context->Display(len);
338 /***************************************/
339 //dimension "L 90"
340 /***************************************/
60bf98ae 341 Handle(AIS_LengthDimension) len1 = new AIS_LengthDimension(V7, V4, pln->Pln());
342 len1->SetDimensionAspect (anAspect);
343 len1->SetFlyout (30.0);
344 anAspect->ArrowAspect()->SetLength (100.0);
7fd59977 345 context->Display(len1);
346 /***************************************/
347 //dimension "L 150"
348 /***************************************/
a6eb515f 349 Handle(AIS_LengthDimension) len2 = new AIS_LengthDimension(V1, V2, pln->Pln());
60bf98ae 350 len2->SetDimensionAspect (anAspect);
7fd59977 351 context->Display(len2);
352 /***************************************/
353 //dimension "R 88.58"
354 /***************************************/
355 gp_Circ cir = gp_Circ(gp_Ax2(gp_Pnt(191.09, -88.58, 0), gp_Dir(0, 0, 1)), 88.58);
356 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(cir,gp_Pnt(191.09,0,0.),gp_Pnt(191.09,-177.16,0.) );
a6eb515f 357 Handle(AIS_RadiusDimension) dim1 = new AIS_RadiusDimension(E1);
60bf98ae 358 dim1->SetDimensionAspect (anAspect);
7fd59977 359 context->Display(dim1);
360 /***************************************/
361 //dimension "R 43.80"
362 /***************************************/
363 gp_Circ cir1 = gp_Circ(gp_Ax2(gp_Pnt(191.09, -88.58, 0), gp_Dir(0, 0, 1)), 43.80);
364 TopoDS_Edge E_cir1 = BRepBuilderAPI_MakeEdge(cir1);
a6eb515f 365 dim1 = new AIS_RadiusDimension(E_cir1);
60bf98ae 366 anAspect->ArrowAspect()->SetLength (60.0);
367 dim1->SetDimensionAspect (anAspect);
7fd59977 368 context->Display(dim1);
369 /***************************************/
370 //dimension "R 17.86"
371 /***************************************/
372 gp_Circ cir2 = gp_Circ(gp_Ax2(gp_Pnt(566.11, -88.58, 0), gp_Dir(0, 0, -1)), 17.86);
373 TopoDS_Edge E_cir2 = BRepBuilderAPI_MakeEdge(cir2);
a6eb515f 374 dim1 = new AIS_RadiusDimension(E_cir2);
60bf98ae 375 anAspect->ArrowAspect()->SetLength (40.0);
376 dim1->SetDimensionAspect (anAspect);
7fd59977 377 context->Display(dim1);
378
379 return 0;
380}
381
382static Standard_Integer OCC138 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
383{
384 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
385 if(aContext.IsNull()) {
386 di << "use 'vinit' command before " << argv[0] << "\n";
387 return 1;
388 }
389
390 BRepPrimAPI_MakeBox box1(gp_Pnt(0, 0, 0), gp_Pnt(100, 100, 100));
391 BRepPrimAPI_MakeBox box2(gp_Pnt(120, 120, 120), gp_Pnt(300, 300,300));
392 BRepPrimAPI_MakeBox box3(gp_Pnt(320, 320, 320), gp_Pnt(500, 500,500));
393
394 Handle_AIS_Shape ais1 = new AIS_Shape(box1.Shape());
395 Handle_AIS_Shape ais2 = new AIS_Shape(box2.Shape());
396 Handle_AIS_Shape ais3 = new AIS_Shape(box3.Shape());
397
398 aContext->Display(ais1);
399 aContext->Display(ais2);
400 aContext->Display(ais3);
401
402 aContext->AddOrRemoveCurrentObject(ais1);
403 aContext->AddOrRemoveCurrentObject(ais2);
404 aContext->AddOrRemoveCurrentObject(ais3);
405
406 di << "\n No of currents = " << aContext->NbCurrents();
407
408 aContext->InitCurrent();
409
410 int count = 1;
411 while(aContext->MoreCurrent())
412 {
413 di << "\n count is = " << count++;
414 Handle_AIS_InteractiveObject ais = aContext->Current();
415 aContext->AddOrRemoveCurrentObject(ais);
416 aContext->InitCurrent();
417 }
418
419 return 0;
420}
421
422static Standard_Integer BUC60821(Draw_Interpretor& di, Standard_Integer argc,const char ** argv )
423{
424
425 if(argc < 3){
426 di << "Usage: " << argv[0] << " TextHight1 TextHight2 TextHight2";
427 return(-1);
428 }
429
430 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
431
432 if(aContext.IsNull())
433 {
434 di << "use 'vinit' command before " << argv[0] << "\n";
435 return -1;
436 }
437
91322f44 438 Handle(QABugs_MyText) txt1 = new QABugs_MyText("Gosha1",gp_Pnt(0,0,0),Font_NOF_ASCII_SIMPLEX,Quantity_NOC_RED,Draw::Atoi(argv[1]));
7fd59977 439 aContext->Display(txt1);
440
91322f44 441 Handle(QABugs_MyText) txt2 = new QABugs_MyText("Gosha2",gp_Pnt(0,0,100),Font_NOF_ASCII_SIMPLEX,Quantity_NOC_YELLOW,Draw::Atoi(argv[2]));
7fd59977 442 aContext->Display(txt2);
443
91322f44 444 Handle(QABugs_MyText) txt3 = new QABugs_MyText("Gosha3",gp_Pnt(0,100,100),Font_NOF_ASCII_SIMPLEX,Quantity_NOC_SKYBLUE,Draw::Atoi(argv[3]));
7fd59977 445 aContext->Display(txt3);
446
447 return 0;
448}
449
450static int geom_get_2Dpt_from_3Dpt(const gp_Pnt& pnt3d, const gp_Pln& pln, gp_Pnt2d& pnt2d)
451{
452 int ret = 0;
453 Handle_Geom_Plane gpln = new Geom_Plane(pln);
454 GeomAdaptor_Surface adsur(gpln);
455 Extrema_ExtPS extps(pnt3d, adsur, 0.001, 0.001);
456 if( extps.IsDone() )
457 {
458 int index;
459 for(index=1; index<= extps.NbExt(); index++ )
460 {
461 Extrema_POnSurf pons = extps.Point(index);
462 Standard_Real U, V;
463 pons.Parameter(U, V);
464 pnt2d.SetCoord(U, V);
465 ret = 1;
466 }
467 }
468 return ret;
469}
470
471static Standard_Integer OCC353 (Draw_Interpretor& di, Standard_Integer , const char ** )
472{
473 gp_Ax2 ax21( gp_Pnt(100,0,0), gp_Dir(0,0,1) );
474 Handle_Geom_Circle h_cir1 = new Geom_Circle( ax21, 25 );
475
476 gp_Ax2 ax22( gp_Pnt(-100,0,0), gp_Dir(0,0,1) );
477 Handle_Geom_Circle h_cir2 = new Geom_Circle( ax22, 25 );
478
479 gp_Pln refpln( gp_Pnt(0,0,0), gp_Dir(0,0,1) );
480 Handle_Geom2d_Curve cir2d1 = GeomAPI::To2d(h_cir1, refpln);
481 Handle_Geom2d_Curve cir2d2 = GeomAPI::To2d(h_cir2, refpln);
482
483 Geom2dAdaptor_Curve adop1(cir2d1);
484 Geom2dAdaptor_Curve adop2(cir2d2);
485
486 Geom2dGcc_QualifiedCurve qcur1(adop1, GccEnt_enclosing);
487 Geom2dGcc_QualifiedCurve qcur2(adop2, GccEnt_enclosing);
488
489 Handle_Geom_CartesianPoint h_carpt = new Geom_CartesianPoint(0,175,0);
490
491 gp_Pnt pt3d = h_carpt->Pnt();
492 gp_Pnt2d pt2d;
493 geom_get_2Dpt_from_3Dpt(pt3d, refpln, pt2d);
494
495 Standard_CString st;
496 st = "cir2d1";
497 DrawTrSurf::Set(st,cir2d1);
498 st = "cir2d2";
499 DrawTrSurf::Set(st,cir2d2);
500 st = "pt2d";
501 DrawTrSurf::Set(st,pt2d);
502
503 Handle_Geom2d_CartesianPoint pt = new Geom2d_CartesianPoint(pt2d);
504 Geom2dGcc_Circ2d3Tan sol( qcur1, qcur2, pt, 0.001, 0.0, 0.0);
505
506 int res = 0;
507 Standard_Character buf[10];
508 buf[0] = '\0';
509
510 if( sol.IsDone() ) {
511 res = sol.NbSolutions();
512 for(Standard_Integer i=1;i<=res;i++) {
513 Handle(Geom2d_Circle) aC = new Geom2d_Circle(sol.ThisSolution(i));
91322f44 514 Sprintf(buf,"Result_%d",i);
7fd59977 515 st = buf;
516 DrawTrSurf::Set(st,aC);
517 }
518 }
519 else
520 di << "\n Faulty: no solutions found ";
521 //printf("\n Faulty: no solutions found ");
522
523 //printf("\n Num of solutions are %d ", res );
524 di << "\n Num of solutions are " << res << " ";
525
526 return 0;
527}
528
529static Standard_Integer OCC280 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
530{
531 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
532 if(aContext.IsNull())
533 {
534 di << "use 'vinit' command before " << argv[0] << "\n";
535 return -1;
536 }
537 if ( argc != 3) {
538 di << "ERROR : Usage : " << argv[0] << " hlr=0/1 setsurfecedetail=0/1; set perspecrive view" << "\n";
539 return 1;
540 }
541
91322f44 542 Standard_Integer HLR = Draw::Atoi(argv[1]);
7fd59977 543 if (HLR != 0) {
544 HLR = 1;
545 }
546
18d715bd 547 TCollection_AsciiString anOldName = ViewerTest::GetCurrentViewName();
7fd59977 548 Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
91322f44 549 if (Draw::Atoi (argv[2]))
5e27df78 550 {
551 aViewer->SetDefaultSurfaceDetail (V3d_TEX_ALL);
7fd59977 552 }
5e27df78 553 aViewer->SetDefaultTypeOfView (V3d_PERSPECTIVE);
18d715bd 554 Handle(Aspect_Window) asp = ViewerTest::CurrentView()->Window();
7fd59977 555 Handle(V3d_View) aNewView = aViewer->CreateView();
5e27df78 556 ViewerTest::CurrentView (aNewView);
18d715bd 557 TCollection_AsciiString aNewName=anOldName + "_new";
558 ViewerTest::InitViewName(aNewName,ViewerTest::CurrentView());
5e27df78 559 aNewView->SetWindow (asp);
7fd59977 560 if (!asp->IsMapped()) asp->Map();
18d715bd 561 aNewView->Redraw();
562 ViewerTest::RemoveView(anOldName,false);
5e27df78 563 ViewerTest::UnsetEventManager();
564 ViewerTest::SetEventManager (new ViewerTest_EventManager (aNewView, ViewerTest::GetAISContext()));
565
de75ed09 566 if (HLR == 1)
567 {
568 di << "HLR\n";
18d715bd 569 ViewerTest::CurrentView()->SetComputedMode (Standard_True);
7fd59977 570 }
571
572 return 0;
573}
574
35e08fe8 575static Standard_Integer OCC232 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
7fd59977 576{
577 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
578 if(aContext.IsNull()) {
579 di << "use 'vinit' command before " << argv[0] << "\n";
580 return 1;
581 }
582
583 BRep_Builder builder;
584 TopoDS_Compound comp;
585 TopoDS_CompSolid cs1, cs2;
586
587 builder.MakeCompound(comp);
588 builder.MakeCompSolid(cs1);
589 builder.MakeCompSolid(cs2);
590
591 TopoDS_Shape sh1 = BRepPrimAPI_MakeBox(gp_Pnt(0, 0, 0), 100, 100, 100).Shape();
592 TopoDS_Shape sh2 = BRepPrimAPI_MakeBox(gp_Pnt(100, 0, 0), 100, 100, 100).Shape();
593 TopoDS_Shape sh3 = BRepPrimAPI_MakeBox(gp_Pnt(200, 0, 0), 100, 100, 100).Shape();
594 builder.Add(cs1, sh1);
595 builder.Add(cs1, sh2);
596 builder.Add(cs1, sh3);
597
598 TopoDS_Shape sh4 = BRepPrimAPI_MakeBox(gp_Pnt(0, 500, 0), 100, 100, 100).Shape();
599 TopoDS_Shape sh5 = BRepPrimAPI_MakeBox(gp_Pnt(100, 500, 0), 100, 100, 100).Shape();
600 TopoDS_Shape sh6 = BRepPrimAPI_MakeBox(gp_Pnt(200, 500, 0), 100, 100, 100).Shape();
601
602 builder.Add(cs2, sh4);
603 builder.Add(cs2, sh5);
604 builder.Add(cs2, sh6);
605
606 builder.Add(comp, cs1);
607 builder.Add(comp, cs2);
608
609 Handle_AIS_Shape ais = new AIS_Shape(comp);
610 aContext->Display(ais);
611
612 TopExp_Explorer exp(comp, TopAbs_COMPSOLID);
613 while(exp.More())
614 {
615 //printf("\n TopAbs_COMPSOLID is there \n");
616 di << "\n TopAbs_COMPSOLID is there \n";
617 exp.Next();
618 }
619
620 Handle (StdSelect_ShapeTypeFilter) filt = new StdSelect_ShapeTypeFilter(TopAbs_COMPSOLID);
621 aContext->AddFilter(filt);
622 aContext->CloseAllContexts();
623 aContext->OpenLocalContext();
624 aContext->ActivateStandardMode(TopAbs_SOLID);
625
626 return 0;
627}
628
629static Standard_Integer OCC138LC (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
630{
631 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
632 if(aContext.IsNull()) {
633 di << "use 'vinit' command before " << argv[0] << "\n";
634 return 1;
635 }
636
637 BRepPrimAPI_MakeBox box1(gp_Pnt(0, 0, 0), gp_Pnt(100, 100, 100));
638 BRepPrimAPI_MakeBox box2(gp_Pnt(120, 120, 120), gp_Pnt(300, 300,300));
639 BRepPrimAPI_MakeBox box3(gp_Pnt(320, 320, 320), gp_Pnt(500, 500,500));
640
641 Handle_AIS_Shape ais1 = new AIS_Shape(box1.Shape());
642 Handle_AIS_Shape ais2 = new AIS_Shape(box2.Shape());
643 Handle_AIS_Shape ais3 = new AIS_Shape(box3.Shape());
644
645 aContext->Display(ais1);
646 aContext->Display(ais2);
647 aContext->Display(ais3);
648
649 aContext->AddOrRemoveSelected(ais1);
650 aContext->AddOrRemoveSelected(ais2);
651 aContext->AddOrRemoveSelected(ais3);
652
653 di << "\n No of selected = " << aContext->NbSelected();
654
655 aContext->InitSelected();
656
657 int count = 1;
658 while(aContext->MoreSelected())
659 {
660 di << "\n count is = %d" << count++;
661 Handle_AIS_InteractiveObject ais = aContext->SelectedInteractive();
662 aContext->AddOrRemoveSelected(ais);
663 aContext->InitSelected();
664 }
665
666 return 0;
667}
668
669static Standard_Integer OCC189 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
670{
671 Handle(AIS_InteractiveContext) aContext1 = ViewerTest::GetAISContext();
672 if(aContext1.IsNull()) {
673 di << "use 'vinit' command before " << argv[0] << "\n";
674 return 1;
675 }
676 Handle(AIS_InteractiveContext) aContext2 = ViewerTest::GetAISContext();
677 if(aContext2.IsNull()) {
678 di << "use 'vinit' command before " << argv[0] << "\n";
679 return 1;
680 }
681
682 BRepPrimAPI_MakeBox box1(gp_Pnt(0, 0, 0), gp_Pnt(100, 100, 100));
683 BRepPrimAPI_MakeBox box2(gp_Pnt(120, 120, 120), gp_Pnt(300, 300, 300));
684 BRepPrimAPI_MakeBox box3(gp_Pnt(320, 320, 320), gp_Pnt(500, 500, 500));
685
686 Handle_AIS_Shape ais1 = new AIS_Shape(box1.Shape());
687 Handle_AIS_Shape ais2 = new AIS_Shape(box2.Shape());
688 Handle_AIS_Shape ais3 = new AIS_Shape(box3.Shape());
689
690 aContext1->Display(ais1);
691 aContext1->Display(ais2);
692 aContext1->Display(ais3);
693
694 aContext2->Display(ais1);
695 aContext2->Display(ais2);
696 aContext2->Display(ais3);
697
698 aContext1->AddOrRemoveCurrentObject(ais1);
699 aContext1->AddOrRemoveCurrentObject(ais2);
700 aContext1->AddOrRemoveCurrentObject(ais3);
701
702 di << "\n Stage : 1";
703 di << "\n \t No of currents on aContext1 = " << aContext1->NbCurrents();
704 di << "\n \t No of currents on aContext2 = " << aContext2->NbCurrents() << "\n\n";
705
706 di << "\n aContext1->IsCurrent = " << (Standard_Integer) aContext1->IsCurrent(ais1) << ", aContext2->IsCurrent = " << (Standard_Integer) aContext2->IsCurrent(ais1) << " ";
707
708 aContext2->AddOrRemoveCurrentObject(ais1);
709 aContext2->AddOrRemoveCurrentObject(ais2);
710 aContext2->AddOrRemoveCurrentObject(ais3);
711
712 di << "\n Stage : 2";
713 di << "\n \t No of currents on aContext1 = " << aContext1->NbCurrents();
714 di << "\n \t No of currents on aContext2 = " << aContext2->NbCurrents() << "\n\n";
715
716 aContext1->InitCurrent();
717 int count1 = 1;
718 while(aContext1->MoreCurrent())
719 {
720 di << "\n count1 is = " << count1++;
721 Handle_AIS_InteractiveObject ais = aContext1->Current();
722 aContext1->AddOrRemoveCurrentObject(ais);
723 aContext1->InitCurrent();
724 }
725
726 di << "\n Stage : 3";
727 di << "\n \t No of currents on aContext1 = " << aContext1->NbCurrents();
728 di << "\n \t No of currents on aContext2 = " << aContext2->NbCurrents() << "\n\n";
729
730 aContext2->InitCurrent();
731 int count2 = 1;
732 while(aContext2->MoreCurrent())
733 {
734 di << "\n count2 is = " << count2++;
735 Handle_AIS_InteractiveObject ais = aContext2->Current();
736 aContext2->AddOrRemoveCurrentObject(ais);
737 aContext2->InitCurrent();
738 }
739
740 di << "\n\n Stage : 4";
741 di << "\n \t No of currents on aContext1 = " << aContext1->NbCurrents();
742 di << "\n \t No of currents on aContext2 = " << aContext2->NbCurrents();
743
744 return 0;
745}
746
7fd59977 747#include <BRepBndLib.hxx>
748#include <Draw.hxx>
749//=======================================================================
750//function : OCC566
751//purpose :
752//=======================================================================
753static Standard_Integer OCC566(Draw_Interpretor& di,Standard_Integer n,const char ** a)
754{
755 if (n < 2) {
756 di<<"Usage: " << a[0] << " shape [ xmin ymin zmin xmax ymax zmax]"<<"\n";
757 return 1;
758 }
759 TopoDS_Shape S = DBRep::Get(a[1]);
760 if (S.IsNull()) return 1;
761 Bnd_Box B;
762 BRepBndLib::AddClose(S,B);
763 Standard_Real axmin,aymin,azmin,axmax,aymax,azmax;
764 B.Get(axmin,aymin,azmin,axmax,aymax,azmax);
765 di << axmin<<" "<< aymin<<" "<< azmin<<" "<< axmax<<" "<< aymax<<" "<< azmax;
766 if (n >= 8) {
767 Draw::Set(a[2],axmin) ;
768 Draw::Set(a[3],aymin) ;
769 Draw::Set(a[4],azmin) ;
770 Draw::Set(a[5],axmax) ;
771 Draw::Set(a[6],aymax) ;
772 Draw::Set(a[7],azmax) ;
773 }
774 return 0;
775}
776
777#include <BRepFilletAPI_MakeFillet.hxx>
778//=======================================================================
779//function : OCC570
780//purpose :
781//=======================================================================
782static Standard_Integer OCC570 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
783{
784 if (argc < 2) {
785 di<<"Usage: " << argv[0] << " result"<<"\n";
786 return 1;
787 }
788
789 BRepPrimAPI_MakeBox mkBox(100.,100.,100.);
790 TopoDS_Shape aBox = mkBox.Shape();
791
792 TopExp_Explorer aExp;
793 aExp.Init(aBox,TopAbs_WIRE);
794 if (aExp.More())
795 {
796 TopoDS_Shape aWire = aExp.Current();
797
798 aExp.Init(aWire,TopAbs_EDGE);
799 TopoDS_Edge e1 = TopoDS::Edge(aExp.Current()); aExp.Next();
800 TopoDS_Edge e2 = TopoDS::Edge(aExp.Current()); aExp.Next();
801 TopoDS_Edge e3 = TopoDS::Edge(aExp.Current()); aExp.Next();
802 TopoDS_Edge e4 = TopoDS::Edge(aExp.Current());
803
804 try
805 {
806 OCC_CATCH_SIGNALS
807 BRepFilletAPI_MakeFillet mkFillet(aBox);
808 mkFillet.SetContinuity(GeomAbs_C1,.001);
809
810 // Setup variable fillet data
811 TColgp_Array1OfPnt2d t_pnt(1,4);
812 t_pnt.SetValue(1,gp_Pnt2d(0.0,5.0));
813 t_pnt.SetValue(2,gp_Pnt2d(0.3,15.0));
814 t_pnt.SetValue(3,gp_Pnt2d(0.7,15.0));
815 t_pnt.SetValue(4,gp_Pnt2d(1.0,5.0));
816
817 // HERE:
818 // It is impossible to build fillet if at least one edge
819 // with variable radius is added!!! If all are constant, everything is ok.
820 mkFillet.Add(t_pnt,e1);
821 mkFillet.Add(5.0,e2);
822 mkFillet.Add(t_pnt,e3);
823 mkFillet.Add(5.0,e4);
824
825 mkFillet.Build();
826 TopoDS_Shape aFinalShape = mkFillet.Shape();
827
828 DBRep::Set(argv[1],aFinalShape);
829 }
830 catch(Standard_Failure)
831 {
832 di << argv[0] << ": Exception in fillet"<<"\n";
833 return 2;
834 }
835 }
836
837 return 0;
838}
839
840#include <Law_Interpol.hxx>
841
842static Standard_Real t3d = 1.e-4;
843static Standard_Real t2d = 1.e-5;
844static Standard_Real ta = 1.e-2;
845static Standard_Real fl = 1.e-3;
846static Standard_Real tapp_angle = 1.e-2;
847static GeomAbs_Shape blend_cont = GeomAbs_C1;
848
7fd59977 849static BRepFilletAPI_MakeFillet* Rake = 0;
850static char name[100];
851
852static void printtolblend(Draw_Interpretor& di)
853{
854 di<<"tolerance ang : "<<ta<<"\n";
855 di<<"tolerance 3d : "<<t3d<<"\n";
856 di<<"tolerance 2d : "<<t2d<<"\n";
857 di<<"fleche : "<<fl<<"\n";
858
859 di<<"tolblend "<<ta<<" "<<t3d<<" "<<t2d<<" "<<fl<<"\n";
860}
861
862static Standard_Integer MKEVOL(Draw_Interpretor& di,
863 Standard_Integer narg,
864 const char ** a)
865{
866 if(Rake != 0) {delete Rake; Rake = 0;}
867 printtolblend(di);
868 if (narg < 3) return 1;
869 TopoDS_Shape V = DBRep::Get(a[2]);
870 Rake = new BRepFilletAPI_MakeFillet(V);
871 Rake->SetParams(ta,t3d,t2d,t3d,t2d,fl);
872 Rake->SetContinuity(blend_cont, tapp_angle);
873 if (narg == 4) {
874 ChFi3d_FilletShape FSh = ChFi3d_Rational;
875 if (!strcasecmp(a[3], "Q")) {
876 FSh = ChFi3d_QuasiAngular;
877 }
878 else if (!strcasecmp(a[3], "P")) {
879 FSh = ChFi3d_Polynomial;
880 }
881 Rake->SetFilletShape(FSh);
882 }
883 strcpy(name, a[1]);
884 return 0;
885}
886
887static Standard_Integer UPDATEVOL(Draw_Interpretor& di,
888 Standard_Integer narg,
889 const char ** a)
890{
891 if(Rake == 0){
892 di << "MakeFillet non initialise"<<"\n";
893 return 1 ;
894 }
895 if(narg%2 != 0 || narg < 4) return 1;
896 TColgp_Array1OfPnt2d uandr(1,(narg/2)-1);
897 Standard_Real Rad, Par;
898 TopoDS_Shape aLocalEdge(DBRep::Get(a[1],TopAbs_EDGE));
899 TopoDS_Edge E = TopoDS::Edge(aLocalEdge);
900 for (Standard_Integer ii = 1; ii <= (narg/2)-1; ii++){
91322f44 901 Par = Draw::Atof(a[2*ii]);
902 Rad = Draw::Atof(a[2*ii + 1]);
7fd59977 903 uandr.ChangeValue(ii).SetCoord(Par,Rad);
904 }
905 //HELPDESK: Add law creation
906 const Standard_Boolean aLawMode = !strcmp(a[0],"OCC570evollaw");
907 if (aLawMode)
908 {
909 di<<"INFO: Using law to define variable fillet"<<"\n";
910 Handle(Law_Interpol) law = new Law_Interpol;
911 law->Set(uandr);
912 Rake->Add(law,E);
913 }
914 else
915 Rake->Add(uandr,E);
916
917 return 0;
918}
919
920static Standard_Integer BUILDEVOL(Draw_Interpretor& di,
921 Standard_Integer,
922 const char **)
923{
924 if(Rake == 0){
925 di << "MakeFillet non initialise"<<"\n";
926 return 1 ;
927 }
928 Rake->Build();
929 if(Rake->IsDone()){
930 TopoDS_Shape result = Rake->Shape();
931 DBRep::Set(name,result);
932 if(Rake != 0) {delete Rake; Rake = 0;}
933 return 0;
934 }
935 if(Rake != 0) {delete Rake; Rake = 0;}
936 return 1;
937}
938
939#include <TColGeom_SequenceOfCurve.hxx>
940#include <Geom_TrimmedCurve.hxx>
941#include <GeomFill_NSections.hxx>
942#include <BRepBuilderAPI_MakeFace.hxx>
943//=======================================================================
944//function : OCC606
945//purpose :
946//=======================================================================
947static Standard_Integer OCC606 ( Draw_Interpretor& di, Standard_Integer n, const char ** a )
948{
949 if (n != 3 && n != 4)
950 {
951 di << "Usage : " << a[0] << " result shape [-t]" << "\n";
952 return 0;
953 }
954
955 Standard_Boolean TrimMode = (n == 4);
956 if (TrimMode) di<<"INFO: Using trimmed curves..."<<"\n";
957 else di<<"INFO: Using non trimmed curves..."<<"\n";
958
959 TopoDS_Shape S = DBRep::Get(a[2]);
960
961 TopExp_Explorer t_exp(S,TopAbs_EDGE);
962 TColGeom_SequenceOfCurve n_curves1;
963 TColStd_SequenceOfReal np;
964 Standard_Real param = 5.0;
965
966 for (;t_exp.More();t_exp.Next())
967 {
968 Standard_Real f,l;
969 Handle(Geom_Curve) h_cur = BRep_Tool::Curve(TopoDS::Edge(t_exp.Current()),f,l);
970 if (!h_cur.IsNull())
971 {
972 if (TrimMode) h_cur = new Geom_TrimmedCurve(h_cur,f,l);
973
974 n_curves1.Append(h_cur);
975 np.Append(param);
976 param += 1.0;
977 }
978 }
979
980 if (n_curves1.Length()>1 && !np.IsEmpty())
981 {
982 try
983 {
984 OCC_CATCH_SIGNALS
985 GeomFill_NSections b_surface1(n_curves1, np);
986 b_surface1.ComputeSurface();
987 Handle(Geom_BSplineSurface) result_surf1 = b_surface1.BSplineSurface();
988 if (!result_surf1.IsNull())
989 {
1c72dff6 990 BRepBuilderAPI_MakeFace b_face1(result_surf1, Precision::Confusion());
7fd59977 991 TopoDS_Face bsp_face1 = b_face1.Face();
992 DBRep::Set(a[1],bsp_face1);
993 }
994 }
995 catch(Standard_Failure)
996 {
997 di<<"ERROR: Exception in GeomFill_NSections"<<"\n";
998 }
999 }
1000
1001
1002 return 0;
1003}
1004
1005//=======================================================================
1006//function : OCC813
1007//purpose :
1008//=======================================================================
1009static Standard_Integer OCC813 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
1010{
1011 if (argc < 3)
1012 {
1013 di << "Usage : " << argv[0] << " U V" << "\n";
1014 return 1;
1015 }
1016
1017 Standard_CString str;
91322f44 1018 Standard_Real U = Draw::Atof(argv[1]);
1019 Standard_Real V = Draw::Atof(argv[2]);
7fd59977 1020
1021 //Between ellipse and point:
1022
1023 Handle(Geom_Ellipse) ell = new Geom_Ellipse(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
1024 gp_Dir(0.173648,0.984808,0.000000),
1025 gp_Dir(-0.932169,0.164367,-0.322560)), 150, 100);
1026 Handle(Geom_Plane) plne = new Geom_Plane(gp_Ax3(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
1027 gp_Dir(0.173648,0.984808,0.000000),
1028 gp_Dir(-0.932169,0.164367,-0.322560))) );
1029
1030 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1031
1032 gp_Pnt2d pt2d(U,V);
1033 gp_Pln pln = plne->Pln();
1034
1035 str = "OCC813_pnt"; DrawTrSurf::Set(str,pt2d);
1036
1037 Handle(Geom2d_Curve) curve2d = GeomAPI::To2d(ell,pln);
1038 Geom2dAdaptor_Curve acur(curve2d);
1039 Geom2dGcc_QualifiedCurve qcur(acur, GccEnt_outside);
1040
1041 str = "OCC813_ell"; DrawTrSurf::Set(str,curve2d);
1042 if(!aContext.IsNull()) {
1043 Handle(AIS_Shape) aisp =
1044 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(curve2d, pln)).Edge());
1045 aContext->Display (aisp);
1046 }
1047
1048 //This does not give any solutions.
1049 Geom2dGcc_Lin2d2Tan lintan(qcur, pt2d, 0.1);
1050 di<<"OCC813 nb of solutions = "<<lintan.NbSolutions()<<"\n";
1051
1052 Standard_Character abuf[16];
1053 Standard_CString st = abuf;
1054
1055 Standard_Integer i;
1056 for(i=1;i<=lintan.NbSolutions();i++) {
91322f44 1057 Sprintf(abuf,"lintan_%d",i);
7fd59977 1058 Handle(Geom2d_Line) glin = new Geom2d_Line(lintan.ThisSolution(i));
1059 DrawTrSurf::Set(st,glin);
1060 if(!aContext.IsNull()) {
1061 Handle(AIS_Shape) aisp =
1062 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(glin, pln)).Edge()); aContext->Display (aisp);
1063 }
1064 }
1065
1066 return 0;
1067}
1068
1069//=======================================================================
1070//function : OCC814
1071//purpose :
1072//=======================================================================
1073static Standard_Integer OCC814 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
1074{
1075 if (argc > 1)
1076 {
1077 di << "Usage : " << argv[0] << "\n";
1078 return 1;
1079 }
1080
1081 Standard_CString str;
1082
1083 //Between Ellipse and Circle:
1084
1085 Handle(Geom_Circle) cir = new Geom_Circle(gp_Ax2(gp_Pnt(823.687192,502.366825,478.960440),
1086 gp_Dir(0.173648,0.984808,0.000000),
1087 gp_Dir(-0.932169,0.164367,-0.322560)), 50);
1088 Handle(Geom_Ellipse) ell = new Geom_Ellipse(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
1089 gp_Dir(0.173648,0.984808,0.000000),
1090 gp_Dir(-0.932169,0.164367,-0.322560)), 150, 100);
1091 Handle(Geom_Plane) plne = new Geom_Plane(gp_Ax3(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
1092 gp_Dir(0.173648,0.984808,0.000000),
1093 gp_Dir(-0.932169,0.164367,-0.322560))) );
1094
1095 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1096
1097 gp_Pln pln = plne->Pln();
1098 Handle(Geom2d_Curve) curve2d = GeomAPI::To2d(ell, pln);
1099 Handle(Geom2d_Curve) fromcurve2d = GeomAPI::To2d(cir, pln);
1100
1101 str = "OCC814_cir"; DrawTrSurf::Set(str,curve2d);
1102 str = "OCC814_ell"; DrawTrSurf::Set(str,fromcurve2d);
1103 if(!aContext.IsNull()) {
1104 Handle(AIS_Shape) aisp =
1105 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(curve2d, pln)).Edge());
1106 aContext->Display (aisp);
1107 }
1108 if(!aContext.IsNull()) {
1109 Handle(AIS_Shape) aisp =
1110 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(fromcurve2d, pln)).Edge());
1111 aContext->Display (aisp);
1112 }
1113
1114 Geom2dAdaptor_Curve acur(curve2d), afromcur(fromcurve2d);
1115
1116 Geom2dGcc_QualifiedCurve qcur(acur, GccEnt_outside) ;
1117 Geom2dGcc_QualifiedCurve qfromcur(afromcur, GccEnt_outside) ;
1118
1119 //This does not give any solutions.
1120 Geom2dGcc_Lin2d2Tan lintan(qcur, qfromcur, 0.1);
1121 di<<"OCC814 nb of solutions = "<<lintan.NbSolutions()<<"\n";
1122
1123 Standard_Character abuf[16];
1124 Standard_CString st = abuf;
1125
1126 Standard_Integer i;
1127 for(i=1;i<=lintan.NbSolutions();i++) {
91322f44 1128 Sprintf(abuf,"lintan_%d",i);
7fd59977 1129 Handle(Geom2d_Line) glin = new Geom2d_Line(lintan.ThisSolution(i));
1130 DrawTrSurf::Set(st,glin);
1131 if(!aContext.IsNull()) {
1132 Handle(AIS_Shape) aisp =
1133 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(glin, pln)).Edge()); aContext->Display (aisp);
1134 }
1135 }
1136
1137 return 0;
1138}
1139
1140#include <ShapeAnalysis_Wire.hxx>
1141#include <IntRes2d_SequenceOfIntersectionPoint.hxx>
1142#include <TColgp_SequenceOfPnt.hxx>
1143#include <ShapeFix_Wire.hxx>
1144//=======================================================================
1145//function : OCC884
1146//purpose :
1147//=======================================================================
1148static Standard_Integer OCC884 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1149{
1150 if (argc < 3 || argc > 5)
1151 {
1152 di << "Usage : " << argv[0] << " result shape [toler [maxtoler]]" << "\n";
1153 return 1;
1154 }
1155
1156 TopoDS_Shape shape = DBRep::Get(argv[2]); //read the shape
1157
1158 TopExp_Explorer exp(shape, TopAbs_EDGE);
1159 if (!exp.More())
1160 {
1161 di<<"Error: no edge found"<<"\n";
1162 return 1;
1163 }
1164
1165 BRep_Builder builder;
1166 TopoDS_Wire wire;
1167 builder.MakeWire(wire);
1168 builder.Add(wire, TopoDS::Edge(exp.Current()));
1169
1170 // HelpDesk: Create planar face if possible
1171 TopoDS_Face face = BRepBuilderAPI_MakeFace(wire,Standard_True);
1172
1173 Handle(ShapeAnalysis_Wire) advWA = new ShapeAnalysis_Wire;
1174 advWA->Load(wire);
1175 advWA->SetFace(face);
1176 advWA->SetPrecision(0.001);
1177
1178 IntRes2d_SequenceOfIntersectionPoint points2d;
1179 TColgp_SequenceOfPnt points3d;
1180
1181 di << "Info: CheckSelfIntersectingEdge = " << (Standard_Integer) advWA->CheckSelfIntersectingEdge(1,points2d,points3d) << "\n";
1182
1183 ShapeExtend_Status status = ShapeExtend_FAIL1;
1184 if (advWA->StatusSelfIntersection(status))
1185 di << "Info: No P Curve found in the edge\n";
1186
1187 status = ShapeExtend_FAIL2;
1188 if (advWA->StatusSelfIntersection(status))
1189 di << "Info: No Vertices found in the edge\n";
1190
1191 status = ShapeExtend_DONE1;
1192 if (advWA->StatusSelfIntersection(status))
1193 di << "Info: Self-intersection found in the edge\n";
1194
1195 Standard_Integer i, num = points2d.Length();
1196 di << "Info: No. of self-intersection points : " << num << "\n";
1197
1198 char str[80];
75259fc5 1199 Standard_CString aName = str;
7fd59977 1200 for (i = 1; i <= num; ++i)
1201 {
1202 gp_Pnt pt = points3d(i);
1203 di << "Info: Intersecting pt : (" << pt.X() << ", " << pt.Y() << ", " << pt.Z() << ")\n";
91322f44 1204 Sprintf(str,"p_%d",i);
75259fc5 1205 DrawTrSurf::Set(aName,pt);
7fd59977 1206 }
1207
1208 Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire;
1209 sfw->Load(wire);
1210 sfw->SetFace(face);
1211
91322f44 1212 if (argc > 3) sfw->SetPrecision(Draw::Atof(argv[3])/*0.1*/);
1213 if (argc > 4) sfw->SetMaxTolerance(Draw::Atof(argv[4]));
7fd59977 1214 di << "Info: Precision is set to " << sfw->Precision() << "\n";
1215 di << "Info: MaxTolerance is set to " << sfw->MaxTolerance() << "\n";
1216
1217 sfw->ModifyTopologyMode() = 1;
1218 sfw->ModifyGeometryMode() = 1;
1219 sfw->FixSelfIntersectingEdgeMode() = 1;
1220 //printf("Info: FixSelfIntersection = %d\n",sfw->FixSelfIntersection());
1221 di << "Info: FixSelfIntersection = " << (Standard_Integer) sfw->FixSelfIntersection() << "\n";
1222
1223 DBRep::Set(argv[1],sfw->Wire());
1224
1225 status = ShapeExtend_OK;
1226 if (sfw->StatusSelfIntersection(status))
1227 di << "Info: ShapeExtend_OK : No intersection found\n";
1228 //printf("Info: ShapeExtend_OK : No intersection found\n");
1229
1230 status = ShapeExtend_FAIL1;
1231 if (sfw->StatusSelfIntersection(status))
1232 di << "Info: ShapeExtend_FAIL1 : analysis failed (edge has no pcurve, or no vertices etc.)\n";
1233
1234 status = ShapeExtend_FAIL2;
1235 if (sfw->StatusSelfIntersection(status))
1236 di << "Info: ShapeExtend_FAIL2 : self-intersection was found, but not fixed because of limit of increasing tolerance (MaxTolerance)\n";
1237
1238 status = ShapeExtend_FAIL3;
1239 if (sfw->StatusSelfIntersection(status))
1240 di << "Info: ShapeExtend_FAIL3 : intercestion of non adjacent edges found, but not fixed because of limit of increasing tolerance (MaxTolerance)\n";
1241
1242 status = ShapeExtend_DONE1;
1243 if (sfw->StatusSelfIntersection(status))
1244 di << "Info: ShapeExtend_DONE1 : tolerance of vertex was increased to fix self-intersection\n";
1245
1246 status = ShapeExtend_DONE2;
1247 if (sfw->StatusSelfIntersection(status))
1248 di << "Info: ShapeExtend_DONE2 : vertex was moved to fix self-intersection\n";
1249
1250 status = ShapeExtend_DONE3;
1251 if (sfw->StatusSelfIntersection(status))
1252 di << "Info: ShapeExtend_DONE3 : some edges were removed because of intersection\n";
1253
1254 status = ShapeExtend_DONE4;
1255 if (sfw->StatusSelfIntersection(status))
1256 di << "Info: ShapeExtend_DONE4 : pcurve(s) was(were) modified\n";
1257
1258 status = ShapeExtend_DONE5;
1259 if (sfw->StatusSelfIntersection(status))
1260 di << "Info: ShapeExtend_DONE5 : non adjacent intersection fixed by increasing tolerance of vertex(vertices)\n";
1261
1262 status = ShapeExtend_DONE6;
1263 if (sfw->StatusSelfIntersection(status))
1264 di << "Info: ShapeExtend_DONE6 : tolerance of edge was increased to hide intersection\n";
1265
1266 status = ShapeExtend_DONE7;
1267 if (sfw->StatusSelfIntersection(status))
1268 di << "Info: ShapeExtend_DONE7 : range of some edges was decreased to avoid intersection\n";
1269
1270 return 0;
1271}
1272
1273#include <Aspect_FillMethod.hxx>
1274//=======================================================================
1275//function : OCC1188
1276//purpose :
1277//=======================================================================
1278static Standard_Integer OCC1188 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1279{
1280 if (argc < 2 || argc > 3)
1281 {
1282 di << "Usage : " << argv[0] << " imagefile [filltype] : Load image as background" << "\n";
1283 return 1;
1284 }
1285
1286 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1287 if(AISContext.IsNull())
1288 {
1289 di << "use 'vinit' command before " << argv[0] << "\n";
1290 return 1;
1291 }
1292
1293 Aspect_FillMethod aFillType = Aspect_FM_CENTERED;
1294 if (argc == 3)
1295 {
1296 const char* szType = argv[2];
1297 if (strcmp(szType, "NONE" ) == 0) aFillType = Aspect_FM_NONE;
1298 else if (strcmp(szType, "CENTERED") == 0) aFillType = Aspect_FM_CENTERED;
1299 else if (strcmp(szType, "TILED" ) == 0) aFillType = Aspect_FM_TILED;
1300 else if (strcmp(szType, "STRETCH" ) == 0) aFillType = Aspect_FM_STRETCH;
1301 else
1302 {
1303 di << "Wrong fill type : " << szType << "\n";
1304 di << "Must be one of CENTERED, TILED, STRETCH, NONE" << "\n";
1305 return 1;
1306 }
1307 }
1308
1309 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
1310 V3dView->SetBackgroundImage(argv[1], aFillType, Standard_True);
1311
1312 return 0;
1313}
1314
1315#include <AIS_Drawer.hxx>
1316#include <Graphic3d_MaterialAspect.hxx>
1317#include <Prs3d_ShadingAspect.hxx>
1318//=======================================================================
1319//function : OCC1174_1
1320//purpose :
1321//=======================================================================
1322static Standard_Integer OCC1174_1 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1323{
1324 if (argc != 2)
1325 {
1326 di << "Usage : " << argv[0] << " shape" << "\n";
1327 return 1;
1328 }
1329
1330 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1331 if(AISContext.IsNull())
1332 {
1333 di << "use 'vinit' command before " << argv[0] << "\n";
1334 return 1;
1335 }
1336
1337 TopoDS_Shape sh = DBRep::Get(argv[1]);
1338
1339 Handle(AIS_Shape) ais = new AIS_Shape(sh);
1340
1341 Quantity_Color colf(0.0, 0.4, 0.0, Quantity_TOC_RGB);
1342 Quantity_Color colb(0.0, 0.0, 0.6, Quantity_TOC_RGB);
1343
1344 Handle(Prs3d_ShadingAspect) sa = ais->Attributes()->ShadingAspect();
1345
1346 Graphic3d_MaterialAspect front = sa->Material(Aspect_TOFM_FRONT_SIDE);
1347 front.SetAmbientColor(colf);
1348 front.SetDiffuseColor(colf);
1349 front.SetSpecularColor(colf);
1350 front.SetEmissiveColor(colf);
1351 front.SetTransparency(0.0);
1352 sa->SetMaterial(front,Aspect_TOFM_FRONT_SIDE);
1353
1354 Graphic3d_MaterialAspect back = sa->Material(Aspect_TOFM_BACK_SIDE);
1355 back.SetAmbientColor(colb);
1356 back.SetDiffuseColor(colb);
1357 back.SetSpecularColor(colb);
1358 back.SetEmissiveColor(colb);
1359 back.SetTransparency(0.0);
1360 sa->SetMaterial(back,Aspect_TOFM_BACK_SIDE);
1361
1362 AISContext->Display(ais,1,0);
1363
1364 Standard_Real r, g, b;
1365 sa->Color(Aspect_TOFM_FRONT_SIDE).Values(r,g,b, Quantity_TOC_RGB);
1366 di << "Info: color on front side (" << r << "," << g << "," << b << ")\n";
1367 sa->Color(Aspect_TOFM_BACK_SIDE).Values(r,g,b, Quantity_TOC_RGB);
1368 di << "Info: color on back side (" << r << "," << g << "," << b << ")\n";
1369
1370 return 0;
1371}
1372
1373//=======================================================================
1374//function : OCC1174_2
1375//purpose :
1376//=======================================================================
1377static Standard_Integer OCC1174_2 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1378{
1379 if (argc != 2)
1380 {
1381 di << "Usage : " << argv[0] << " shape" << "\n";
1382 return 1;
1383 }
1384
1385 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1386 if(AISContext.IsNull())
1387 {
1388 di << "use 'vinit' command before " << argv[0] << "\n";
1389 return 1;
1390 }
1391
1392 TopoDS_Shape sh = DBRep::Get(argv[1]);
1393
1394 Handle(AIS_Shape) ais = new AIS_Shape(sh);
1395 AISContext->Display(ais,1,0);
1396 AISContext->SetMaterial(ais,Graphic3d_NOM_SHINY_PLASTIC);
1397
1398 Quantity_Color colf(0.0, 0.4, 0.0, Quantity_TOC_RGB);
1399 Quantity_Color colb(0.0, 0.0, 0.6, Quantity_TOC_RGB);
1400 Handle(Prs3d_ShadingAspect) sa = ais->Attributes()->ShadingAspect();
1401
1402 Graphic3d_MaterialAspect front = sa->Material(Aspect_TOFM_FRONT_SIDE);
1403 front.SetAmbientColor(colf);
1404 front.SetDiffuseColor(colf);
1405 front.SetSpecularColor(colf);
1406 front.SetEmissiveColor(colf);
1407 front.SetTransparency(0.4);
1408 sa->SetMaterial(front,Aspect_TOFM_FRONT_SIDE);
1409
1410 Graphic3d_MaterialAspect back = sa->Material(Aspect_TOFM_BACK_SIDE);
1411 back.SetAmbientColor(colb);
1412 back.SetDiffuseColor(colb);
1413 back.SetSpecularColor(colb);
1414 back.SetEmissiveColor(colb);
1415 back.SetTransparency(0.2);
1416 sa->SetMaterial(back,Aspect_TOFM_BACK_SIDE);
1417
1418 AISContext->Redisplay(ais,1,0);
1419
1420 return 0;
1421}
1422
7fd59977 1423#include <TopoDS_Solid.hxx>
1424#include <BRepFeat_MakeDPrism.hxx>
1425//=======================================================================
1426//function : OCCN1
1427//purpose : FEATURE OPERATION (BOSS and SLOT)
1428//=======================================================================
1429static Standard_Integer OCCN1 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1430{
1431 if (argc != 4)
1432 {
1433 di << "Usage : " << argv[0] << " angle fuse(1 for boss / 0 for slot) length" << "\n";
1434 return 1;
1435 }
1436
1437 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1438 if(aContext.IsNull())
1439 {
1440 di << "use 'vinit' command before " << argv[0] << "\n";
1441 return 1;
1442 }
91322f44 1443 Standard_Real angle = Draw::Atof(argv[1]);
1444 Standard_Integer fuse = Draw::Atoi(argv[2]);
1445 Standard_Real length = Draw::Atof(argv[3]);
7fd59977 1446
1447 BRepBuilderAPI_MakeEdge edge1(gp_Pnt(0, 0, 0), gp_Pnt(50, 0, 0));
1448 BRepBuilderAPI_MakeEdge edge2(gp_Pnt(50, 0, 0), gp_Pnt(50, 50, 0));
1449 BRepBuilderAPI_MakeEdge edge3(gp_Pnt(50, 50, 0), gp_Pnt(0, 50, 0));
1450 BRepBuilderAPI_MakeEdge edge4(gp_Pnt(0, 50, 0), gp_Pnt(0, 0, 0));
1451 TopoDS_Edge ted1 = edge1.Edge();
1452 TopoDS_Edge ted2 = edge2.Edge();
1453 TopoDS_Edge ted3 = edge3.Edge();
1454 TopoDS_Edge ted4 = edge4.Edge();
1455
1456 BRepBuilderAPI_MakeWire wire(ted1, ted2, ted3, ted4);
1457 TopoDS_Wire twire = wire.Wire();
1458
1459 BRepBuilderAPI_MakeFace face(twire);
1460 TopoDS_Face tface = face.Face();
1461 ////////Handle_AIS_Shape face_ais = new AIS_Shape( tface );
1462 ////////aContext->Display(face_ais);
1463
1464 TopoDS_Solid box;
1465 BRepPrimAPI_MakeBox block(gp_Pnt(-50, -50, -150), 150, 150, 100);
1466 box = block.Solid();
1467
1468 TopoDS_Face top_face;
1469 top_face = block.TopFace();
1470
1471 BRepFeat_MakeDPrism slot(box, tface, top_face, angle, fuse,
1472 Standard_True);
1473
1474 slot.Perform(length);
1475 TopoDS_Shape S2 = slot.Shape();
1476
1477 DBRep::Set("OCCN1_tface",tface);
1478 DBRep::Set("OCCN1_slot",S2);
1479
1480 return 0;
1481}
1482
1483#include <BRepPrimAPI_MakeCylinder.hxx>
1484#include <BRepPrimAPI_MakeSphere.hxx>
1485#include <BRepAlgoAPI_Section.hxx>
1486#include <BRepAlgo_Section.hxx>
1487//=======================================================================
1488//function : OCCN2
1489//purpose : BOOLEAN OPERATION
1490//=======================================================================
1491static Standard_Integer OCCN2 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1492{
1493 if (argc > 2) {
1494 di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1495 return 1;
1496 }
1497 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1498 if (argc == 2) {
91322f44 1499 Standard_Integer IsB = Draw::Atoi(argv[1]);
7fd59977 1500 if (IsB != 1) {
1501 IsBRepAlgoAPI = Standard_False;
1502#if ! defined(BRepAlgo_def04)
1503#endif
1504 }
1505 }
1506
1507 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1508 if(aContext.IsNull())
1509 {
1510 di << "use 'vinit' command before " << argv[0] << "\n";
1511 return 1;
1512 }
1513
1514 BRepPrimAPI_MakeCylinder cylinder(50,200);
1515 TopoDS_Shape cylinder_sh = cylinder.Shape();
1516
1517 BRepPrimAPI_MakeSphere sphere(gp_Pnt(60,0,100),50);
1518 TopoDS_Shape sphere_sh = sphere.Shape();
1519
1520 //BRepAlgoAPI_Section section(cylinder_sh, sphere_sh);
1521 //TopoDS_Shape shape = section.Shape();
1522
1523 TopoDS_Shape shape;
1524 if (IsBRepAlgoAPI) {
1525 di << "BRepAlgoAPI_Section section(cylinder_sh, sphere_sh)" <<"\n";
1526 BRepAlgoAPI_Section section(cylinder_sh, sphere_sh);
1527 section.Build();
1528 if(!section.IsDone()){
1529 di << "Error performing intersection: not done." << "\n";
1530 }
1531 shape = section.Shape();
1532 } else {
1533 di << "BRepAlgo_Section section(cylinder_sh, sphere_sh)" <<"\n";
1534 BRepAlgo_Section section(cylinder_sh, sphere_sh);
1535 section.Build();
1536 if(!section.IsDone()){
1537 di << "Error performing intersection: not done." << "\n";
1538 }
1539 shape = section.Shape();
1540 }
1541
1542 DBRep::Set("OCCN2_cylinder",cylinder_sh);
1543 DBRep::Set("OCCN2_sphere",sphere_sh);
1544 DBRep::Set("OCCN2_section",shape);
1545
1546 return 0;
1547}
1548
1549#include <TColgp_Array1OfPnt.hxx>
1550#include <Geom_BezierCurve.hxx>
1551
1552static Standard_Integer OCC2569 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1553{
1554 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1555 if(aContext.IsNull())
1556 {
1557 di << "use 'vinit' command before " << argv[0] << "\n";
1558 return 1;
1559 }
1560 if(argc != 3) {
1561 di << "Usage : " << argv[0] << " nbpoles result" << "\n";
1562 return 1;
1563 }
1564
91322f44 1565 int poles=Draw::Atoi(argv[1]);
7fd59977 1566
1567 TColgp_Array1OfPnt arr(1, poles);
1568 for(int i=1; i<=poles; i++)
1569 arr.SetValue(i, gp_Pnt(i+10, i*2+20, i*3+45));
1570
1571 Handle_Geom_BezierCurve bez = new Geom_BezierCurve(arr);
1572 if(bez.IsNull()) {
1573 di << "\n The curve is not created.\n";
1574 } else {
1575 di << "\n Degree = " << bez->Degree() << "\n";
1576 }
1577 TopoDS_Edge sh = BRepBuilderAPI_MakeEdge(bez).Edge();
1578 Handle_AIS_Shape ais = new AIS_Shape(sh);
1579 aContext->Display(ais);
1580 DrawTrSurf::Set(argv[2],bez);
1581 return 0;
1582}
1583
1584#include <TopTools_IndexedMapOfShape.hxx>
1585#include <TopExp.hxx>
1586
1587static Standard_Integer OCC1642 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1588{
1589 if (argc != 10) {
1590 di<<"Usage: " << argv[0] << " FinalWare FinalFace InitWare InitFace shape FixReorder FixDegenerated FixConnected FixSelfIntersection"<<"\n";
1591 return 1;
1592 }
1593
1594 TopoDS_Shape shape = DBRep::Get(argv[5]);
1595
1596 TopExp_Explorer exp(shape, TopAbs_WIRE);
1597 TopoDS_Shape wire = exp.Current();
1598
1599 Handle(ShapeAnalysis_Wire) advWA = new ShapeAnalysis_Wire;
1600 advWA->Load(TopoDS::Wire(wire));
1601
1602 DBRep::Set(argv[3],wire);
1603
1604 TopoDS_Face face =
1605 BRepBuilderAPI_MakeFace(TopoDS::Wire(wire),Standard_True);
1606
1607 DBRep::Set(argv[4],face);
1608
1609 advWA->SetFace(face);
5e27df78 1610 Standard_Real precision_to_ana = 0.0001;
7fd59977 1611 advWA->SetPrecision(precision_to_ana);
1612
1613 TopTools_IndexedMapOfShape M;
1614 TopExp::MapShapes(wire, TopAbs_EDGE, M);
1615
1616 int j= 1;
1617 for(j= 1; j<=M.Extent(); ++j) {
1618 Standard_Integer num=1;
1619 IntRes2d_SequenceOfIntersectionPoint points2d;
1620 TColgp_SequenceOfPnt points3d;
1621
1622 cout << "\n j =" << j << ", CheckSelfIntersectingEdge = " <<
1623 advWA->CheckSelfIntersectingEdge(j, points2d, points3d);
1624
1625
1626 ShapeExtend_Status status = ShapeExtend_FAIL1;
1627 if(advWA->StatusSelfIntersection(status))
1628
1629 status = ShapeExtend_FAIL2;
1630 if(advWA->StatusSelfIntersection(status))
1631 di << "\n No Vertices found in the edge";
1632
1633 status = ShapeExtend_DONE1;
1634 if(advWA->StatusSelfIntersection(status))
1635 di << "\n Self-intersection found in the edge";
1636
1637 num = points2d.Length();
1638 di << "\n No. of self-intersecting edges : " << num;
1639
1640 for(int i=1; i<=num; ++i) {
1641 gp_Pnt pt = points3d(i);
1642 di << "\n Intersecting pt : (" << pt.X() << ", " << pt.Y()<< ", " << pt.Z() << ")";
1643 }
1644
1645 }
1646
1647 Handle_ShapeFix_Wire sfw = new ShapeFix_Wire;
1648 sfw->Load(TopoDS::Wire(wire));
1649 sfw->SetFace(face);
1650 sfw->SetPrecision(Precision::Confusion());
1651
1652 sfw->FixReorderMode() = 1;
1653 sfw->ClosedWireMode() = 1;
1654 sfw->FixDegeneratedMode() = 1;
1655 sfw->FixConnectedMode() = 1;
1656 sfw->ModifyTopologyMode() = 1;
1657 sfw->ModifyGeometryMode() = 1;
1658 sfw->FixSelfIntersectionMode() = 1;
1659 sfw->FixSelfIntersectingEdgeMode() = 1;
1660 sfw->FixIntersectingEdgesMode() = 1;
1661 sfw->FixNonAdjacentIntersectingEdgesMode() = 1;
1662 sfw->FixEdgeCurvesMode() = 1;
1663
1664 sfw->ModifyRemoveLoopMode() = 1;
1665 sfw->SetMaxTolerance(1.0);
1666
1667 di << "\n FixReorder = " << (Standard_Integer) sfw->FixReorder();
1668 di << "\n FixDegenerated = " << (Standard_Integer) sfw->FixDegenerated();
1669 di << "\n FixConnected = " << (Standard_Integer) sfw->FixConnected();
1670 di << "\n";
1671 di << "\n FixSelfIntersection = " << (Standard_Integer) sfw->FixSelfIntersection();
1672 di << "\n";
1673
1674 Draw::Set(argv[6],sfw->FixReorder()) ;
1675 Draw::Set(argv[7],sfw->FixDegenerated()) ;
1676 Draw::Set(argv[8],sfw->FixConnected()) ;
1677 Draw::Set(argv[9],sfw->FixSelfIntersection()) ;
1678
1679 ShapeExtend_Status status = ShapeExtend_OK;
1680 if(sfw->StatusSelfIntersection(status))
1681 di << "\n ShapeExtend_OK : No intersection found";
1682
1683 status = ShapeExtend_FAIL1;
1684 if(sfw->StatusSelfIntersection(status))
1685 di << "\n ShapeExtend_FAIL1 : analysis failed (edge has no pcurve,or no vertices etc.)";
1686
1687 status = ShapeExtend_FAIL2;
1688 if(sfw->StatusSelfIntersection(status))
1689 di << "\n ShapeExtend_FAIL2 : self-intersection was found, but not fixed because of limit of increasing tolerance (MaxTolerance)";
1690
1691 status = ShapeExtend_FAIL3;
1692 if(sfw->StatusSelfIntersection(status))
1693 di << "\n ShapeExtend_FAIL3 : intercestion of non adjacent edges found, but not fixed because of limit of increasing tolerance (MaxTolerance)";
1694
1695 status = ShapeExtend_DONE1;
1696 if(sfw->StatusSelfIntersection(status))
1697 di << "\n ShapeExtend_DONE1 : tolerance of vertex was increased to fix self-intersection";
1698
1699 status = ShapeExtend_DONE2;
1700 if(sfw->StatusSelfIntersection(status))
1701 di << "\n ShapeExtend_DONE2 : vertex was moved to fix self-intersection";
1702
1703 status = ShapeExtend_DONE3;
1704 if(sfw->StatusSelfIntersection(status))
1705 di << "\n ShapeExtend_DONE3 : some edges were removed because of intersection";
1706
1707 status = ShapeExtend_DONE4;
1708 if(sfw->StatusSelfIntersection(status))
1709 di << "\n ShapeExtend_DONE4 : pcurve(s) was(were) modified";
1710
1711 status = ShapeExtend_DONE5;
1712 if(sfw->StatusSelfIntersection(status))
1713 di << "\n ShapeExtend_DONE5 : non adjacent intersection fixed by increasing tolerance of vertex(vertices)";
1714
1715 status = ShapeExtend_DONE6;
1716 if(sfw->StatusSelfIntersection(status))
1717 di << "\n ShapeExtend_DONE6 : tolerance of edge was increased to hide intersection";
1718
1719 status = ShapeExtend_DONE7;
1720 if(sfw->StatusSelfIntersection(status))
1721 di << "\n ShapeExtend_DONE7 : range of some edges was decreased to avoid intersection";
1722
1723 TopoDS_Wire finalwire = sfw->Wire();
1724
1725 DBRep::Set(argv[1],finalwire);
1726
1727
1728 advWA->Load(TopoDS::Wire(finalwire));
1729
1730 TopoDS_Face fface =
1731 BRepBuilderAPI_MakeFace(TopoDS::Wire(finalwire),Standard_True);
1732
1733 DBRep::Set(argv[2],fface);
1734
1735 advWA->SetFace(fface);
1736
1737 TopTools_IndexedMapOfShape fM;
1738 TopExp::MapShapes(finalwire, TopAbs_EDGE, fM);
1739
1740 for(j= 1; j<=fM.Extent(); ++j) {
1741 Standard_Integer num=1;
1742 IntRes2d_SequenceOfIntersectionPoint points2d;
1743 TColgp_SequenceOfPnt points3d;
1744
1745 di << "\n j =" << j << ", CheckSelfIntersectingEdge = " <<
1746 (Standard_Integer) advWA->CheckSelfIntersectingEdge(j, points2d, points3d);
1747
1748
1749 ShapeExtend_Status status = ShapeExtend_FAIL1;
1750 if(advWA->StatusSelfIntersection(status))
1751
1752 status = ShapeExtend_FAIL2;
1753 if(advWA->StatusSelfIntersection(status))
1754 di << "\n No Vertices found in the edge";
1755
1756 status = ShapeExtend_DONE1;
1757 if(advWA->StatusSelfIntersection(status))
1758 di << "\n Self-intersection found in the edge";
1759
1760 num = points2d.Length();
1761 di << "\n No. of self-intersecting edges : " << num;
1762
1763 for(int i=1; i<=num; ++i) {
1764 gp_Pnt pt = points3d(i);
1765 di << "\n Intersecting pt : (" << pt.X() << ", " << pt.Y() << ", " << pt.Z() << ")";
1766 }
1767
1768 }
1769
1770 di << "\n";
1771
1772 return 0;
1773}
1774
1cd84fee 1775void QABugs::Commands_17(Draw_Interpretor& theCommands) {
1365140b 1776 const char *group = "QABugs";
7fd59977 1777
1778 theCommands.Add ("BUC60842", "BUC60842", __FILE__, BUC60842, group);
1779 theCommands.Add ("BUC60843", "BUC60843 result_shape name_of_circle name_of_curve [ par1 [ tol ] ]", __FILE__, BUC60843, group);
1780 theCommands.Add ("BUC60970", "BUC60970 shape result", __FILE__, BUC60970, group);
1781 theCommands.Add ("BUC60818", "BUC60818", __FILE__, BUC60818, group);
1782 theCommands.Add ("BUC60915", "BUC60915", __FILE__, BUC60915_1, group);
1783 theCommands.Add ("OCC138", "OCC138", __FILE__, OCC138, group);
1784 theCommands.Add ("BUC60821","BUC60821",__FILE__,BUC60821,group);
1785 theCommands.Add ("OCC353","OCC353",__FILE__,OCC353,group);
1786 theCommands.Add ("OCC280","OCC280 hlr=0/1 setsurfecedetail=0/1; set perspecrive view",__FILE__,OCC280,group);
1787 theCommands.Add ("OCC232", "OCC232", __FILE__, OCC232 , group);
1788 theCommands.Add ("OCC138LC", "OCC138LC", __FILE__, OCC138LC, group);
1789 theCommands.Add ("OCC189", "OCC189", __FILE__, OCC189, group);
7fd59977 1790 theCommands.Add ("OCC566", "OCC566 shape [ xmin ymin zmin xmax ymax zmax] ; print bounding box", __FILE__, OCC566, group);
1791 theCommands.Add ("OCC570", "OCC570 result", __FILE__, OCC570, group);
1792
1793 theCommands.Add("OCC570mkevol",
1794 "OCC570mkevol result object (then use updatevol) [R/Q/P]; mkevol",
1795 __FILE__, MKEVOL,group);
1796 theCommands.Add("OCC570updatevol",
1797 "OCC570updatevol edge u1 rad1 u2 rad2 ...; updatevol",
1798 __FILE__, UPDATEVOL,group);
1799 theCommands.Add("OCC570updatevollaw",
1800 "OCC570updatevollaw edge u1 rad1 u2 rad2 ...; updatevollaw",
1801 __FILE__, UPDATEVOL,group);
1802 theCommands.Add("OCC570buildevol",
1803 "OCC570buildevol; end of the evol fillet computation",
1804 __FILE__, BUILDEVOL,group);
1805
1806 theCommands.Add ("OCC606", "OCC606 result shape [-t]", __FILE__, OCC606, group);
1807
1808 theCommands.Add ("OCC813", "OCC813 U V", __FILE__, OCC813, group);
1809 theCommands.Add ("OCC814", "OCC814", __FILE__, OCC814, group);
1810 theCommands.Add ("OCC884", "OCC884 result shape [toler [maxtoler]]", __FILE__, OCC884, group);
1811 theCommands.Add ("OCC1188", "OCC1188 imagefile [filltype] : Load image as background", __FILE__, OCC1188, group);
1812
1813 theCommands.Add ("OCC1174_1", "OCC1174_1 shape", __FILE__, OCC1174_1, group);
1814 theCommands.Add ("OCC1174_2", "OCC1174_2 shape", __FILE__, OCC1174_2, group);
1815
7fd59977 1816 theCommands.Add ("OCCN1", "OCCN1 angle fuse(1 for boss / 0 for slot) length", __FILE__, OCCN1, group);
1817 theCommands.Add ("OCCN2", "OCCN2", __FILE__, OCCN2, group);
1818
1819 theCommands.Add ("OCC2569", "OCC2569 nbpoles result", __FILE__, OCC2569, group);
1820
1821 theCommands.Add ("OCC1642", "OCC1642 FinalWare FinalFace InitWare InitFace shape FixReorder FixDegenerated FixConnected FixSelfIntersection", __FILE__, OCC1642, group);
1822
7fd59977 1823 return;
1824}