0026586: Eliminate compile warnings obtained by building occt with vc14: declaration...
[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>
543a9964 33#include <Geom_BSplineSurface.hxx>
7fd59977 34#include <gp_Pln.hxx>
35#include <Geom2d_Curve.hxx>
36#include <GeomAPI.hxx>
37#include <Geom2dAdaptor_Curve.hxx>
38#include <Geom2dGcc_QualifiedCurve.hxx>
39#include <Geom2dGcc_Lin2d2Tan.hxx>
40#include <Geom2d_Line.hxx>
41#include <BRepBuilderAPI_MakeEdge.hxx>
42#include <TopoDS_Edge.hxx>
43#include <Precision.hxx>
44#include <Geom2d_Circle.hxx>
0b85f9a6 45#include <Geom2dGcc_QCurve.hxx>
7fd59977 46#include <GccEnt_QualifiedCirc.hxx>
54e37688 47#include <Geom2dGcc_Lin2d2TanIter.hxx>
7fd59977 48#include <BRepBuilderAPI_MakeWire.hxx>
49#include <TopExp_Explorer.hxx>
50#include <TopoDS.hxx>
51#include <TopoDS_Wire.hxx>
52#include <BRep_Tool.hxx>
53#include <gp_Circ.hxx>
54#include <BRepOffsetAPI_MakePipeShell.hxx>
55#include <AIS_Trihedron.hxx>
56#include <Geom_Axis2Placement.hxx>
57#include <V3d_View.hxx>
7fd59977 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;
857ffd5e 220 Handle(Geom_Curve) curl_ = BRep_Tool::Curve(TopoDS::Edge(spineWireExp.Current()), first, last);
7fd59977 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
c3282ec1 394 Handle(AIS_InteractiveObject) ais1 = new AIS_Shape(box1.Shape());
395 Handle(AIS_InteractiveObject) ais2 = new AIS_Shape(box2.Shape());
396 Handle(AIS_InteractiveObject) ais3 = new AIS_Shape(box3.Shape());
7fd59977 397
398 aContext->Display(ais1);
399 aContext->Display(ais2);
400 aContext->Display(ais3);
401
c3282ec1 402 aContext->AddOrRemoveSelected(ais1);
403 aContext->AddOrRemoveSelected(ais2);
404 aContext->AddOrRemoveSelected(ais3);
7fd59977 405
c3282ec1 406 di << "\n No of currents = " << aContext->NbSelected();
7fd59977 407
c3282ec1 408 aContext->InitSelected();
7fd59977 409
410 int count = 1;
c3282ec1 411 while(aContext->MoreSelected())
7fd59977 412 {
413 di << "\n count is = " << count++;
c3282ec1 414 Handle(AIS_InteractiveObject) ais = aContext->SelectedInteractive();
415 aContext->AddOrRemoveSelected(ais);
416 aContext->InitSelected();
7fd59977 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;
857ffd5e 453 Handle(Geom_Plane) gpln = new Geom_Plane(pln);
7fd59977 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) );
857ffd5e 474 Handle(Geom_Circle) h_cir1 = new Geom_Circle( ax21, 25 );
7fd59977 475
476 gp_Ax2 ax22( gp_Pnt(-100,0,0), gp_Dir(0,0,1) );
857ffd5e 477 Handle(Geom_Circle) h_cir2 = new Geom_Circle( ax22, 25 );
7fd59977 478
479 gp_Pln refpln( gp_Pnt(0,0,0), gp_Dir(0,0,1) );
857ffd5e 480 Handle(Geom2d_Curve) cir2d1 = GeomAPI::To2d(h_cir1, refpln);
481 Handle(Geom2d_Curve) cir2d2 = GeomAPI::To2d(h_cir2, refpln);
7fd59977 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
857ffd5e 489 Handle(Geom_CartesianPoint) h_carpt = new Geom_CartesianPoint(0,175,0);
7fd59977 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
857ffd5e 503 Handle(Geom2d_CartesianPoint) pt = new Geom2d_CartesianPoint(pt2d);
7fd59977 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
857ffd5e 609 Handle(AIS_Shape) ais = new AIS_Shape(comp);
7fd59977 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
543a9964 641 Handle(AIS_InteractiveObject) ais1 = new AIS_Shape(box1.Shape());
642 Handle(AIS_InteractiveObject) ais2 = new AIS_Shape(box2.Shape());
643 Handle(AIS_InteractiveObject) ais3 = new AIS_Shape(box3.Shape());
7fd59977 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++;
857ffd5e 661 Handle(AIS_InteractiveObject) ais = aContext->SelectedInteractive();
7fd59977 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
c3282ec1 686 Handle(AIS_InteractiveObject) ais1 = new AIS_Shape(box1.Shape());
687 Handle(AIS_InteractiveObject) ais2 = new AIS_Shape(box2.Shape());
688 Handle(AIS_InteractiveObject) ais3 = new AIS_Shape(box3.Shape());
7fd59977 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
c3282ec1 698 aContext1->AddOrRemoveSelected(ais1);
699 aContext1->AddOrRemoveSelected(ais2);
700 aContext1->AddOrRemoveSelected(ais3);
7fd59977 701
702 di << "\n Stage : 1";
c3282ec1 703 di << "\n \t No of currents on aContext1 = " << aContext1->NbSelected();
704 di << "\n \t No of currents on aContext2 = " << aContext2->NbSelected() << "\n\n";
7fd59977 705
c3282ec1 706 di << "\n aContext1->IsSelected = " << (Standard_Integer) aContext1->IsCurrent(ais1) << ", aContext2->IsCurrent = " << (Standard_Integer) aContext2->IsCurrent(ais1) << " ";
7fd59977 707
c3282ec1 708 aContext2->AddOrRemoveSelected(ais1);
709 aContext2->AddOrRemoveSelected(ais2);
710 aContext2->AddOrRemoveSelected(ais3);
7fd59977 711
712 di << "\n Stage : 2";
c3282ec1 713 di << "\n \t No of currents on aContext1 = " << aContext1->NbSelected();
714 di << "\n \t No of currents on aContext2 = " << aContext2->NbSelected() << "\n\n";
7fd59977 715
c3282ec1 716 aContext1->InitSelected();
7fd59977 717 int count1 = 1;
c3282ec1 718 while(aContext1->MoreSelected())
7fd59977 719 {
720 di << "\n count1 is = " << count1++;
c3282ec1 721 Handle(AIS_InteractiveObject) ais = aContext1->SelectedInteractive();
722 aContext1->AddOrRemoveSelected(ais);
723 aContext1->InitSelected();
7fd59977 724 }
725
726 di << "\n Stage : 3";
c3282ec1 727 di << "\n \t No of currents on aContext1 = " << aContext1->NbSelected();
728 di << "\n \t No of currents on aContext2 = " << aContext2->NbSelected() << "\n\n";
7fd59977 729
c3282ec1 730 aContext2->InitSelected();
7fd59977 731 int count2 = 1;
c3282ec1 732 while(aContext2->MoreSelected())
7fd59977 733 {
734 di << "\n count2 is = " << count2++;
c3282ec1 735 Handle(AIS_InteractiveObject) ais = aContext2->SelectedInteractive();
736 aContext2->AddOrRemoveSelected(ais);
737 aContext2->InitSelected();
7fd59977 738 }
739
740 di << "\n\n Stage : 4";
c3282ec1 741 di << "\n \t No of currents on aContext1 = " << aContext1->NbSelected();
742 di << "\n \t No of currents on aContext2 = " << aContext2->NbSelected();
7fd59977 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
7fd59977 1315#include <Graphic3d_MaterialAspect.hxx>
6262338c 1316#include <Prs3d_Drawer.hxx>
7fd59977 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
6262338c 1330 Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
1331 if(anAISContext.IsNull())
7fd59977 1332 {
1333 di << "use 'vinit' command before " << argv[0] << "\n";
1334 return 1;
1335 }
1336
6262338c 1337 TopoDS_Shape aShape = DBRep::Get(argv[1]);
1338
1339 Handle(AIS_Shape) anAisIO = new AIS_Shape(aShape);
7fd59977 1340
6262338c 1341 Quantity_Color aColF(0.0, 0.4, 0.0, Quantity_TOC_RGB);
1342 Quantity_Color aColB(0.0, 0.0, 0.6, Quantity_TOC_RGB);
7fd59977 1343
6262338c 1344 Handle(Prs3d_Drawer) aDrawer = anAisIO->Attributes();
1345 Handle(Prs3d_ShadingAspect) aShadingAspect = aDrawer->ShadingAspect();
7fd59977 1346
6262338c 1347 Graphic3d_MaterialAspect aFront = aShadingAspect->Material(Aspect_TOFM_FRONT_SIDE);
1348 aFront.SetAmbientColor(aColF);
1349 aFront.SetDiffuseColor(aColF);
1350 aFront.SetSpecularColor(aColF);
1351 aFront.SetEmissiveColor(aColF);
1352 aFront.SetTransparency(0.0);
1353 aShadingAspect->SetMaterial(aFront,Aspect_TOFM_FRONT_SIDE);
7fd59977 1354
6262338c 1355 Graphic3d_MaterialAspect aBack = aShadingAspect->Material(Aspect_TOFM_BACK_SIDE);
1356 aBack.SetAmbientColor(aColB);
1357 aBack.SetDiffuseColor(aColB);
1358 aBack.SetSpecularColor(aColB);
1359 aBack.SetEmissiveColor(aColB);
1360 aBack.SetTransparency(0.0);
1361 aShadingAspect->SetMaterial(aBack,Aspect_TOFM_BACK_SIDE);
7fd59977 1362
6262338c 1363 aDrawer->SetShadingAspect (aShadingAspect);
7fd59977 1364
6262338c 1365 anAISContext->Display(anAisIO, 1, 0);
7fd59977 1366
1367 Standard_Real r, g, b;
6262338c 1368 aShadingAspect->Color(Aspect_TOFM_FRONT_SIDE).Values(r,g,b, Quantity_TOC_RGB);
7fd59977 1369 di << "Info: color on front side (" << r << "," << g << "," << b << ")\n";
6262338c 1370 aShadingAspect->Color(Aspect_TOFM_BACK_SIDE).Values(r,g,b, Quantity_TOC_RGB);
7fd59977 1371 di << "Info: color on back side (" << r << "," << g << "," << b << ")\n";
1372
1373 return 0;
1374}
1375
1376//=======================================================================
1377//function : OCC1174_2
1378//purpose :
1379//=======================================================================
1380static Standard_Integer OCC1174_2 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1381{
1382 if (argc != 2)
1383 {
1384 di << "Usage : " << argv[0] << " shape" << "\n";
1385 return 1;
1386 }
1387
1388 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1389 if(AISContext.IsNull())
1390 {
1391 di << "use 'vinit' command before " << argv[0] << "\n";
1392 return 1;
1393 }
1394
1395 TopoDS_Shape sh = DBRep::Get(argv[1]);
1396
1397 Handle(AIS_Shape) ais = new AIS_Shape(sh);
1398 AISContext->Display(ais,1,0);
1399 AISContext->SetMaterial(ais,Graphic3d_NOM_SHINY_PLASTIC);
1400
1401 Quantity_Color colf(0.0, 0.4, 0.0, Quantity_TOC_RGB);
1402 Quantity_Color colb(0.0, 0.0, 0.6, Quantity_TOC_RGB);
1403 Handle(Prs3d_ShadingAspect) sa = ais->Attributes()->ShadingAspect();
1404
1405 Graphic3d_MaterialAspect front = sa->Material(Aspect_TOFM_FRONT_SIDE);
1406 front.SetAmbientColor(colf);
1407 front.SetDiffuseColor(colf);
1408 front.SetSpecularColor(colf);
1409 front.SetEmissiveColor(colf);
1410 front.SetTransparency(0.4);
1411 sa->SetMaterial(front,Aspect_TOFM_FRONT_SIDE);
1412
1413 Graphic3d_MaterialAspect back = sa->Material(Aspect_TOFM_BACK_SIDE);
1414 back.SetAmbientColor(colb);
1415 back.SetDiffuseColor(colb);
1416 back.SetSpecularColor(colb);
1417 back.SetEmissiveColor(colb);
1418 back.SetTransparency(0.2);
1419 sa->SetMaterial(back,Aspect_TOFM_BACK_SIDE);
1420
1421 AISContext->Redisplay(ais,1,0);
1422
1423 return 0;
1424}
1425
7fd59977 1426#include <TopoDS_Solid.hxx>
1427#include <BRepFeat_MakeDPrism.hxx>
1428//=======================================================================
1429//function : OCCN1
1430//purpose : FEATURE OPERATION (BOSS and SLOT)
1431//=======================================================================
1432static Standard_Integer OCCN1 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1433{
1434 if (argc != 4)
1435 {
1436 di << "Usage : " << argv[0] << " angle fuse(1 for boss / 0 for slot) length" << "\n";
1437 return 1;
1438 }
1439
1440 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1441 if(aContext.IsNull())
1442 {
1443 di << "use 'vinit' command before " << argv[0] << "\n";
1444 return 1;
1445 }
91322f44 1446 Standard_Real angle = Draw::Atof(argv[1]);
1447 Standard_Integer fuse = Draw::Atoi(argv[2]);
1448 Standard_Real length = Draw::Atof(argv[3]);
7fd59977 1449
1450 BRepBuilderAPI_MakeEdge edge1(gp_Pnt(0, 0, 0), gp_Pnt(50, 0, 0));
1451 BRepBuilderAPI_MakeEdge edge2(gp_Pnt(50, 0, 0), gp_Pnt(50, 50, 0));
1452 BRepBuilderAPI_MakeEdge edge3(gp_Pnt(50, 50, 0), gp_Pnt(0, 50, 0));
1453 BRepBuilderAPI_MakeEdge edge4(gp_Pnt(0, 50, 0), gp_Pnt(0, 0, 0));
1454 TopoDS_Edge ted1 = edge1.Edge();
1455 TopoDS_Edge ted2 = edge2.Edge();
1456 TopoDS_Edge ted3 = edge3.Edge();
1457 TopoDS_Edge ted4 = edge4.Edge();
1458
1459 BRepBuilderAPI_MakeWire wire(ted1, ted2, ted3, ted4);
1460 TopoDS_Wire twire = wire.Wire();
1461
1462 BRepBuilderAPI_MakeFace face(twire);
1463 TopoDS_Face tface = face.Face();
857ffd5e 1464 ////////Handle(AIS_Shape) face_ais = new AIS_Shape( tface );
7fd59977 1465 ////////aContext->Display(face_ais);
1466
1467 TopoDS_Solid box;
1468 BRepPrimAPI_MakeBox block(gp_Pnt(-50, -50, -150), 150, 150, 100);
1469 box = block.Solid();
1470
1471 TopoDS_Face top_face;
1472 top_face = block.TopFace();
1473
1474 BRepFeat_MakeDPrism slot(box, tface, top_face, angle, fuse,
1475 Standard_True);
1476
1477 slot.Perform(length);
1478 TopoDS_Shape S2 = slot.Shape();
1479
1480 DBRep::Set("OCCN1_tface",tface);
1481 DBRep::Set("OCCN1_slot",S2);
1482
1483 return 0;
1484}
1485
1486#include <BRepPrimAPI_MakeCylinder.hxx>
1487#include <BRepPrimAPI_MakeSphere.hxx>
1488#include <BRepAlgoAPI_Section.hxx>
1489#include <BRepAlgo_Section.hxx>
1490//=======================================================================
1491//function : OCCN2
1492//purpose : BOOLEAN OPERATION
1493//=======================================================================
1494static Standard_Integer OCCN2 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1495{
1496 if (argc > 2) {
1497 di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1498 return 1;
1499 }
1500 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1501 if (argc == 2) {
91322f44 1502 Standard_Integer IsB = Draw::Atoi(argv[1]);
7fd59977 1503 if (IsB != 1) {
1504 IsBRepAlgoAPI = Standard_False;
1505#if ! defined(BRepAlgo_def04)
1506#endif
1507 }
1508 }
1509
1510 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1511 if(aContext.IsNull())
1512 {
1513 di << "use 'vinit' command before " << argv[0] << "\n";
1514 return 1;
1515 }
1516
1517 BRepPrimAPI_MakeCylinder cylinder(50,200);
1518 TopoDS_Shape cylinder_sh = cylinder.Shape();
1519
1520 BRepPrimAPI_MakeSphere sphere(gp_Pnt(60,0,100),50);
1521 TopoDS_Shape sphere_sh = sphere.Shape();
1522
1523 //BRepAlgoAPI_Section section(cylinder_sh, sphere_sh);
1524 //TopoDS_Shape shape = section.Shape();
1525
1526 TopoDS_Shape shape;
1527 if (IsBRepAlgoAPI) {
1528 di << "BRepAlgoAPI_Section section(cylinder_sh, sphere_sh)" <<"\n";
1529 BRepAlgoAPI_Section section(cylinder_sh, sphere_sh);
1530 section.Build();
1531 if(!section.IsDone()){
1532 di << "Error performing intersection: not done." << "\n";
1533 }
1534 shape = section.Shape();
1535 } else {
1536 di << "BRepAlgo_Section section(cylinder_sh, sphere_sh)" <<"\n";
1537 BRepAlgo_Section section(cylinder_sh, sphere_sh);
1538 section.Build();
1539 if(!section.IsDone()){
1540 di << "Error performing intersection: not done." << "\n";
1541 }
1542 shape = section.Shape();
1543 }
1544
1545 DBRep::Set("OCCN2_cylinder",cylinder_sh);
1546 DBRep::Set("OCCN2_sphere",sphere_sh);
1547 DBRep::Set("OCCN2_section",shape);
1548
1549 return 0;
1550}
1551
1552#include <TColgp_Array1OfPnt.hxx>
1553#include <Geom_BezierCurve.hxx>
1554
1555static Standard_Integer OCC2569 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1556{
1557 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1558 if(aContext.IsNull())
1559 {
1560 di << "use 'vinit' command before " << argv[0] << "\n";
1561 return 1;
1562 }
1563 if(argc != 3) {
1564 di << "Usage : " << argv[0] << " nbpoles result" << "\n";
1565 return 1;
1566 }
1567
91322f44 1568 int poles=Draw::Atoi(argv[1]);
7fd59977 1569
1570 TColgp_Array1OfPnt arr(1, poles);
1571 for(int i=1; i<=poles; i++)
1572 arr.SetValue(i, gp_Pnt(i+10, i*2+20, i*3+45));
1573
857ffd5e 1574 Handle(Geom_BezierCurve) bez = new Geom_BezierCurve(arr);
7fd59977 1575 if(bez.IsNull()) {
1576 di << "\n The curve is not created.\n";
1577 } else {
1578 di << "\n Degree = " << bez->Degree() << "\n";
1579 }
1580 TopoDS_Edge sh = BRepBuilderAPI_MakeEdge(bez).Edge();
857ffd5e 1581 Handle(AIS_Shape) ais = new AIS_Shape(sh);
7fd59977 1582 aContext->Display(ais);
1583 DrawTrSurf::Set(argv[2],bez);
1584 return 0;
1585}
1586
1587#include <TopTools_IndexedMapOfShape.hxx>
1588#include <TopExp.hxx>
1589
1590static Standard_Integer OCC1642 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1591{
1592 if (argc != 10) {
1593 di<<"Usage: " << argv[0] << " FinalWare FinalFace InitWare InitFace shape FixReorder FixDegenerated FixConnected FixSelfIntersection"<<"\n";
1594 return 1;
1595 }
1596
1597 TopoDS_Shape shape = DBRep::Get(argv[5]);
1598
1599 TopExp_Explorer exp(shape, TopAbs_WIRE);
1600 TopoDS_Shape wire = exp.Current();
1601
1602 Handle(ShapeAnalysis_Wire) advWA = new ShapeAnalysis_Wire;
1603 advWA->Load(TopoDS::Wire(wire));
1604
1605 DBRep::Set(argv[3],wire);
1606
1607 TopoDS_Face face =
1608 BRepBuilderAPI_MakeFace(TopoDS::Wire(wire),Standard_True);
1609
1610 DBRep::Set(argv[4],face);
1611
1612 advWA->SetFace(face);
5e27df78 1613 Standard_Real precision_to_ana = 0.0001;
7fd59977 1614 advWA->SetPrecision(precision_to_ana);
1615
1616 TopTools_IndexedMapOfShape M;
1617 TopExp::MapShapes(wire, TopAbs_EDGE, M);
1618
1619 int j= 1;
1620 for(j= 1; j<=M.Extent(); ++j) {
1621 Standard_Integer num=1;
1622 IntRes2d_SequenceOfIntersectionPoint points2d;
1623 TColgp_SequenceOfPnt points3d;
1624
1625 cout << "\n j =" << j << ", CheckSelfIntersectingEdge = " <<
1626 advWA->CheckSelfIntersectingEdge(j, points2d, points3d);
1627
1628
1629 ShapeExtend_Status status = ShapeExtend_FAIL1;
1630 if(advWA->StatusSelfIntersection(status))
1631
1632 status = ShapeExtend_FAIL2;
1633 if(advWA->StatusSelfIntersection(status))
1634 di << "\n No Vertices found in the edge";
1635
1636 status = ShapeExtend_DONE1;
1637 if(advWA->StatusSelfIntersection(status))
1638 di << "\n Self-intersection found in the edge";
1639
1640 num = points2d.Length();
1641 di << "\n No. of self-intersecting edges : " << num;
1642
1643 for(int i=1; i<=num; ++i) {
1644 gp_Pnt pt = points3d(i);
1645 di << "\n Intersecting pt : (" << pt.X() << ", " << pt.Y()<< ", " << pt.Z() << ")";
1646 }
1647
1648 }
1649
857ffd5e 1650 Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire;
7fd59977 1651 sfw->Load(TopoDS::Wire(wire));
1652 sfw->SetFace(face);
1653 sfw->SetPrecision(Precision::Confusion());
1654
1655 sfw->FixReorderMode() = 1;
1656 sfw->ClosedWireMode() = 1;
1657 sfw->FixDegeneratedMode() = 1;
1658 sfw->FixConnectedMode() = 1;
1659 sfw->ModifyTopologyMode() = 1;
1660 sfw->ModifyGeometryMode() = 1;
1661 sfw->FixSelfIntersectionMode() = 1;
1662 sfw->FixSelfIntersectingEdgeMode() = 1;
1663 sfw->FixIntersectingEdgesMode() = 1;
1664 sfw->FixNonAdjacentIntersectingEdgesMode() = 1;
1665 sfw->FixEdgeCurvesMode() = 1;
1666
1667 sfw->ModifyRemoveLoopMode() = 1;
1668 sfw->SetMaxTolerance(1.0);
1669
1670 di << "\n FixReorder = " << (Standard_Integer) sfw->FixReorder();
1671 di << "\n FixDegenerated = " << (Standard_Integer) sfw->FixDegenerated();
1672 di << "\n FixConnected = " << (Standard_Integer) sfw->FixConnected();
1673 di << "\n";
1674 di << "\n FixSelfIntersection = " << (Standard_Integer) sfw->FixSelfIntersection();
1675 di << "\n";
1676
1677 Draw::Set(argv[6],sfw->FixReorder()) ;
1678 Draw::Set(argv[7],sfw->FixDegenerated()) ;
1679 Draw::Set(argv[8],sfw->FixConnected()) ;
1680 Draw::Set(argv[9],sfw->FixSelfIntersection()) ;
1681
1682 ShapeExtend_Status status = ShapeExtend_OK;
1683 if(sfw->StatusSelfIntersection(status))
1684 di << "\n ShapeExtend_OK : No intersection found";
1685
1686 status = ShapeExtend_FAIL1;
1687 if(sfw->StatusSelfIntersection(status))
1688 di << "\n ShapeExtend_FAIL1 : analysis failed (edge has no pcurve,or no vertices etc.)";
1689
1690 status = ShapeExtend_FAIL2;
1691 if(sfw->StatusSelfIntersection(status))
1692 di << "\n ShapeExtend_FAIL2 : self-intersection was found, but not fixed because of limit of increasing tolerance (MaxTolerance)";
1693
1694 status = ShapeExtend_FAIL3;
1695 if(sfw->StatusSelfIntersection(status))
1696 di << "\n ShapeExtend_FAIL3 : intercestion of non adjacent edges found, but not fixed because of limit of increasing tolerance (MaxTolerance)";
1697
1698 status = ShapeExtend_DONE1;
1699 if(sfw->StatusSelfIntersection(status))
1700 di << "\n ShapeExtend_DONE1 : tolerance of vertex was increased to fix self-intersection";
1701
1702 status = ShapeExtend_DONE2;
1703 if(sfw->StatusSelfIntersection(status))
1704 di << "\n ShapeExtend_DONE2 : vertex was moved to fix self-intersection";
1705
1706 status = ShapeExtend_DONE3;
1707 if(sfw->StatusSelfIntersection(status))
1708 di << "\n ShapeExtend_DONE3 : some edges were removed because of intersection";
1709
1710 status = ShapeExtend_DONE4;
1711 if(sfw->StatusSelfIntersection(status))
1712 di << "\n ShapeExtend_DONE4 : pcurve(s) was(were) modified";
1713
1714 status = ShapeExtend_DONE5;
1715 if(sfw->StatusSelfIntersection(status))
1716 di << "\n ShapeExtend_DONE5 : non adjacent intersection fixed by increasing tolerance of vertex(vertices)";
1717
1718 status = ShapeExtend_DONE6;
1719 if(sfw->StatusSelfIntersection(status))
1720 di << "\n ShapeExtend_DONE6 : tolerance of edge was increased to hide intersection";
1721
1722 status = ShapeExtend_DONE7;
1723 if(sfw->StatusSelfIntersection(status))
1724 di << "\n ShapeExtend_DONE7 : range of some edges was decreased to avoid intersection";
1725
1726 TopoDS_Wire finalwire = sfw->Wire();
1727
1728 DBRep::Set(argv[1],finalwire);
1729
1730
1731 advWA->Load(TopoDS::Wire(finalwire));
1732
1733 TopoDS_Face fface =
1734 BRepBuilderAPI_MakeFace(TopoDS::Wire(finalwire),Standard_True);
1735
1736 DBRep::Set(argv[2],fface);
1737
1738 advWA->SetFace(fface);
1739
1740 TopTools_IndexedMapOfShape fM;
1741 TopExp::MapShapes(finalwire, TopAbs_EDGE, fM);
1742
1743 for(j= 1; j<=fM.Extent(); ++j) {
1744 Standard_Integer num=1;
1745 IntRes2d_SequenceOfIntersectionPoint points2d;
1746 TColgp_SequenceOfPnt points3d;
1747
1748 di << "\n j =" << j << ", CheckSelfIntersectingEdge = " <<
1749 (Standard_Integer) advWA->CheckSelfIntersectingEdge(j, points2d, points3d);
1750
1751
51740958 1752 status = ShapeExtend_FAIL1;
7fd59977 1753 if(advWA->StatusSelfIntersection(status))
1754
1755 status = ShapeExtend_FAIL2;
1756 if(advWA->StatusSelfIntersection(status))
1757 di << "\n No Vertices found in the edge";
1758
1759 status = ShapeExtend_DONE1;
1760 if(advWA->StatusSelfIntersection(status))
1761 di << "\n Self-intersection found in the edge";
1762
1763 num = points2d.Length();
1764 di << "\n No. of self-intersecting edges : " << num;
1765
1766 for(int i=1; i<=num; ++i) {
1767 gp_Pnt pt = points3d(i);
1768 di << "\n Intersecting pt : (" << pt.X() << ", " << pt.Y() << ", " << pt.Z() << ")";
1769 }
1770
1771 }
1772
1773 di << "\n";
1774
1775 return 0;
1776}
1777
1cd84fee 1778void QABugs::Commands_17(Draw_Interpretor& theCommands) {
1365140b 1779 const char *group = "QABugs";
7fd59977 1780
1781 theCommands.Add ("BUC60842", "BUC60842", __FILE__, BUC60842, group);
1782 theCommands.Add ("BUC60843", "BUC60843 result_shape name_of_circle name_of_curve [ par1 [ tol ] ]", __FILE__, BUC60843, group);
1783 theCommands.Add ("BUC60970", "BUC60970 shape result", __FILE__, BUC60970, group);
1784 theCommands.Add ("BUC60818", "BUC60818", __FILE__, BUC60818, group);
1785 theCommands.Add ("BUC60915", "BUC60915", __FILE__, BUC60915_1, group);
1786 theCommands.Add ("OCC138", "OCC138", __FILE__, OCC138, group);
1787 theCommands.Add ("BUC60821","BUC60821",__FILE__,BUC60821,group);
1788 theCommands.Add ("OCC353","OCC353",__FILE__,OCC353,group);
1789 theCommands.Add ("OCC280","OCC280 hlr=0/1 setsurfecedetail=0/1; set perspecrive view",__FILE__,OCC280,group);
1790 theCommands.Add ("OCC232", "OCC232", __FILE__, OCC232 , group);
1791 theCommands.Add ("OCC138LC", "OCC138LC", __FILE__, OCC138LC, group);
1792 theCommands.Add ("OCC189", "OCC189", __FILE__, OCC189, group);
7fd59977 1793 theCommands.Add ("OCC566", "OCC566 shape [ xmin ymin zmin xmax ymax zmax] ; print bounding box", __FILE__, OCC566, group);
1794 theCommands.Add ("OCC570", "OCC570 result", __FILE__, OCC570, group);
1795
1796 theCommands.Add("OCC570mkevol",
1797 "OCC570mkevol result object (then use updatevol) [R/Q/P]; mkevol",
1798 __FILE__, MKEVOL,group);
1799 theCommands.Add("OCC570updatevol",
1800 "OCC570updatevol edge u1 rad1 u2 rad2 ...; updatevol",
1801 __FILE__, UPDATEVOL,group);
1802 theCommands.Add("OCC570updatevollaw",
1803 "OCC570updatevollaw edge u1 rad1 u2 rad2 ...; updatevollaw",
1804 __FILE__, UPDATEVOL,group);
1805 theCommands.Add("OCC570buildevol",
1806 "OCC570buildevol; end of the evol fillet computation",
1807 __FILE__, BUILDEVOL,group);
1808
1809 theCommands.Add ("OCC606", "OCC606 result shape [-t]", __FILE__, OCC606, group);
1810
1811 theCommands.Add ("OCC813", "OCC813 U V", __FILE__, OCC813, group);
1812 theCommands.Add ("OCC814", "OCC814", __FILE__, OCC814, group);
1813 theCommands.Add ("OCC884", "OCC884 result shape [toler [maxtoler]]", __FILE__, OCC884, group);
1814 theCommands.Add ("OCC1188", "OCC1188 imagefile [filltype] : Load image as background", __FILE__, OCC1188, group);
1815
1816 theCommands.Add ("OCC1174_1", "OCC1174_1 shape", __FILE__, OCC1174_1, group);
1817 theCommands.Add ("OCC1174_2", "OCC1174_2 shape", __FILE__, OCC1174_2, group);
1818
7fd59977 1819 theCommands.Add ("OCCN1", "OCCN1 angle fuse(1 for boss / 0 for slot) length", __FILE__, OCCN1, group);
1820 theCommands.Add ("OCCN2", "OCCN2", __FILE__, OCCN2, group);
1821
1822 theCommands.Add ("OCC2569", "OCC2569 nbpoles result", __FILE__, OCC2569, group);
1823
1824 theCommands.Add ("OCC1642", "OCC1642 FinalWare FinalFace InitWare InitFace shape FixReorder FixDegenerated FixConnected FixSelfIntersection", __FILE__, OCC1642, group);
1825
7fd59977 1826 return;
1827}