0024837: Visualization - revise design and implementation of connected Interactive...
[occt.git] / src / QABugs / QABugs_16.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.
b311480e 15
1cd84fee 16#include <QABugs.hxx>
7fd59977 17
91322f44 18#include <Draw.hxx>
7fd59977 19#include <Draw_Interpretor.hxx>
20#include <DBRep.hxx>
21#include <DrawTrSurf.hxx>
22#include <AIS_InteractiveContext.hxx>
23#include <ViewerTest.hxx>
24#include <AIS_Shape.hxx>
25#include <TopoDS_Shape.hxx>
26
27#include <GProp_GProps.hxx>
28#include <BRepGProp.hxx>
29#include <TopoDS_Edge.hxx>
30#include <BRepBuilderAPI_MakeEdge.hxx>
31#include <AIS_Trihedron.hxx>
32#include <Geom_Axis2Placement.hxx>
33#include <gp_Ax2.hxx>
34#include <Geom_Circle.hxx>
35#include <AIS_Circle.hxx>
7fd59977 36#include <TopoDS.hxx>
37#include <Geom_Plane.hxx>
38#include <gp_Pln.hxx>
39#include <AIS_AngleDimension.hxx>
40
197ac94e 41#include <Aspect_Window.hxx>
42#include <V3d_View.hxx>
43
7fd59977 44#include <TopExp_Explorer.hxx>
45#include <BRepAdaptor_Curve.hxx>
46#include <GC_MakePlane.hxx>
47#include <AIS_PlaneTrihedron.hxx>
48#include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
49
50#include <BRep_Tool.hxx>
51#include <Geom_BSplineCurve.hxx>
52#include <GeomConvert_CompCurveToBSplineCurve.hxx>
53#include <BRepBuilderAPI_MakeEdge.hxx>
54#include <Precision.hxx>
55
56#include <GProp_PrincipalProps.hxx>
57
58#include <OSD_Path.hxx>
59#include <Standard_ProgramError.hxx>
60
61//#include <QAModTopOpe_Limitation.hxx>
62#include <QANewModTopOpe_Limitation.hxx>
63
64//#include <QAModTopOpe_Glue.hxx>
65#include <QANewModTopOpe_Glue.hxx>
66
67#include <ShapeFix_Wireframe.hxx>
68#include <ShapeBuild_ReShape.hxx>
69
7fd59977 70#include <BRepBuilderAPI_MakeEdge.hxx>
71
72//#include <QAModTopOpe_ReShaper.hxx>
73#include <QANewModTopOpe_ReShaper.hxx>
74
75#include <ViewerTest_EventManager.hxx>
76
77#include <TColgp_Array1OfPnt2d.hxx>
78
79#include <DDocStd.hxx>
80#include <TDocStd_Document.hxx>
81#include <Standard_ErrorHandler.hxx>
82
83#if ! defined(WNT)
84extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
85#else
86Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
87#endif
88
89static Standard_Integer BUC60848 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
90{
91 if ( argc != 2 ) {
92 di << "Usage : " << argv[0] << " shape " << "\n";
93 return 1;
94 }
95 TopoDS_Shape S = DBRep::Get( argv[1] );
96 if ( S.IsNull() ) {
97 di << "Shape is empty" << "\n";
98 return 1;
99 }
100 GProp_GProps G;
101 BRepGProp::VolumeProperties( S,G );
102 Standard_Real GRes;
103 GRes = G.Mass();
104 if ( GRes < 0 ) {
105 di << "Result is negative : " << GRes << "\n";
106 return 1;
107 } else {
108 di << "Volume : " << GRes << "\n";
109 }
110
111 return 0;
112}
113
114static Standard_Integer BUC60828 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
115{
116 TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(0.,0.,0.), gp_Pnt(0.,0.,1.));
117 Standard_Boolean aValue;
118 aValue=anEdge.Infinite();
119 di << "Initial flag : " << (Standard_Integer) aValue << "\n";
120 anEdge.Infinite(Standard_True);
121 Standard_Boolean aValue1;
122 aValue1=anEdge.Infinite();
123 di << "Current flag : " << (Standard_Integer) aValue1 << "\n";
124 if(aValue1) di << "Flag was set properly." << "\n";
125 else di << "Faulty : flag was not set properly." << "\n";
126 return 0;
127}
128
129static Standard_Integer BUC60814(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
130{
131 if(argc!=1)
132 {
133 di << "Usage : " << argv[0] << "\n";
134 return 1;
135 }
136
137
138 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
139 if(myAISContext.IsNull()) {
140 di << "use 'vinit' command before " << argv[0] << "\n";
141 return 1;
142 }
143
144 // TRIHEDRON
145 Handle(AIS_Trihedron) aTrihedron;
146 Handle(Geom_Axis2Placement) aTrihedronAxis=new Geom_Axis2Placement(gp::XOY());
147 aTrihedron=new AIS_Trihedron(aTrihedronAxis);
148 myAISContext->Display(aTrihedron);
149
150 //Circle
151 gp_Pnt P(10,10,10);
152 gp_Dir V(1,0,0);
153 gp_Ax2 aAx2(P,V);
154
155 Handle(Geom_Circle) ahCircle=new Geom_Circle(aAx2,20);
156 Handle(AIS_Circle) aCircle=new AIS_Circle(ahCircle);
157 myAISContext->Display(aCircle);
158
159 myAISContext->SelectionColor(Quantity_NOC_BLUE1);
160
161 myAISContext->AddOrRemoveSelected(aTrihedron);
162 myAISContext->AddOrRemoveSelected(aCircle);
163
164 return 0;
165}
166
197ac94e 167//=======================================================================
168//function : BUC60774
169//purpose :
170//=======================================================================
171static Standard_Integer BUC60774 (Draw_Interpretor& theDi,
172 Standard_Integer theArgNb,
173 const char** theArgv)
7fd59977 174{
197ac94e 175 if (theArgNb != 1)
7fd59977 176 {
197ac94e 177 std::cout << "Usage : " << theArgv[0] << "\n";
7fd59977 178 return -1;
179 }
180
197ac94e 181 const Handle(AIS_InteractiveContext)& anAISContext = ViewerTest::GetAISContext();
182 if (anAISContext.IsNull())
7fd59977 183 {
197ac94e 184 std::cout << "use 'vinit' command before " << theArgv[0] << "\n";
7fd59977 185 return -1;
186 }
187
197ac94e 188 const Handle(V3d_View)& aV3dView = ViewerTest::CurrentView();
7fd59977 189
197ac94e 190 Standard_Integer aWinWidth = 0;
191 Standard_Integer aWinHeight = 0;
192 aV3dView->Window()->Size (aWinWidth, aWinHeight);
7fd59977 193
197ac94e 194 Standard_Integer aXPixMin = 0;
195 Standard_Integer aYPixMin = 0;
196 Standard_Integer aXPixMax = aWinWidth;
197 Standard_Integer aYPixMax = aWinHeight;
7fd59977 198
197ac94e 199 AIS_StatusOfPick aPickStatus = anAISContext->Select (aXPixMin, aYPixMin, aXPixMax, aYPixMax, aV3dView);
200 theDi << (aPickStatus == AIS_SOP_NothingSelected
201 ? "status = AIS_SOP_NothingSelected : OK"
202 : "status = AIS_SOP_NothingSelected : bugged - Faulty ");
203 theDi << "\n";
204
205 theDi.Eval ("box b 10 10 10");
206 theDi.Eval (" vdisplay b");
7fd59977 207
197ac94e 208 aPickStatus = anAISContext->Select (aXPixMin, aYPixMin, aXPixMax, aYPixMax, aV3dView);
209 theDi << (aPickStatus == AIS_SOP_OneSelected
210 ? "status = AIS_SOP_OneSelected : OK"
211 : "status = AIS_SOP_OneSelected : bugged - Faulty ");
212 theDi << "\n";
213
214 theDi.Eval ("box w 20 20 20 20 20 20");
215 theDi.Eval (" vdisplay w");
216
217 aPickStatus = anAISContext->Select (aXPixMin, aYPixMin, aXPixMax, aYPixMax, aV3dView);
218 theDi << (aPickStatus == AIS_SOP_SeveralSelected
219 ? "status = AIS_SOP_SeveralSelected : OK"
220 : "status = AIS_SOP_SeveralSelected : bugged - Faulty ");
221 theDi << "\n";
222
223 return 0;
224}
7fd59977 225
226static Standard_Integer BUC60972 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
227{
228 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
229 if(aContext.IsNull()) {
230 di << "use 'vinit' command before " << argv[0] << "\n";
231 return 1;
232 }
233
234 if(argc != 6) {
235 di << "Usage : " << argv[0] << " edge edge plane val text" << "\n";
236 return 1;
237 }
238
239 TopoDS_Edge aFirst = TopoDS::Edge(DBRep::Get(argv[1],TopAbs_EDGE));
240 TopoDS_Edge aSecond = TopoDS::Edge(DBRep::Get(argv[2],TopAbs_EDGE));
241 Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(DrawTrSurf::GetSurface(argv[3]));
242 if(aPlane.IsNull())
243 return 1;
244
245 di << aPlane->Pln().SquareDistance( gp_Pnt(0,0,0) ) << "\n";
246
247 TCollection_ExtendedString aText(argv[5]);
248 //Standard_ExtString ExtString_aText = aText.ToExtString();
91322f44 249 //di << ExtString_aText << " " << Draw::Atof(argv[4]) << "\n";
250 di << argv[5] << " " << Draw::Atof(argv[4]) << "\n";
7fd59977 251
60bf98ae 252 Handle(AIS_AngleDimension) aDim = new AIS_AngleDimension(aFirst, aSecond);
7fd59977 253 aContext->Display(aDim);
254
255 return 0;
256}
257
258static Standard_Integer OCC218bug (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
259{
260 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
261 if(aContext.IsNull()) {
262 di << "use 'vinit' command before " << argv[0] << "\n";
263 return 1;
264 }
265
266 if(argc != 5) {
267 di << "Usage : " << argv[0] << " name plane Xlabel Ylabel" << "\n";
268 return 1;
269 }
270
271 TopoDS_Shape S = DBRep::Get( argv[2] );
272 if ( S.IsNull() ) {
273 di << "Shape is empty" << "\n";
274 return 1;
275 }
276
277 TCollection_AsciiString name(argv[1]);
278 TCollection_AsciiString Xlabel(argv[3]);
279 TCollection_AsciiString Ylabel(argv[4]);
280
281 // Construction de l'AIS_PlaneTrihedron
282 Handle(AIS_PlaneTrihedron) theAISPlaneTri;
283
284 Standard_Boolean IsBound = GetMapOfAIS().IsBound2(name);
285 if (IsBound) {
286 // on recupere la shape dans la map des objets displayes
287 Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
288
289 // On verifie que l'AIS InteraciveObject est bien
290 // un AIS_PlaneTrihedron
291 if (aShape->Type()==AIS_KOI_Datum && aShape->Signature()==4) {
292 // On downcast aShape de AIS_InteractiveObject a AIS_PlaneTrihedron
293 theAISPlaneTri = *(Handle(AIS_PlaneTrihedron)*) &aShape;
294
295 theAISPlaneTri->SetXLabel(Xlabel);
296 theAISPlaneTri->SetYLabel(Ylabel);
297
298 aContext->Redisplay(theAISPlaneTri, Standard_False);
299 aContext->UpdateCurrentViewer();
300 }
301 } else {
302 TopoDS_Face FaceB=TopoDS::Face(S);
303
304 // Construction du Plane
305 // recuperation des edges des faces.
306 TopExp_Explorer FaceExpB(FaceB,TopAbs_EDGE);
307
308 TopoDS_Edge EdgeB=TopoDS::Edge(FaceExpB.Current() );
309 // declarations
310 gp_Pnt A,B,C;
311
312 // si il y a plusieurs edges
313 if (FaceExpB.More() ) {
314 FaceExpB.Next();
315 TopoDS_Edge EdgeC=TopoDS::Edge(FaceExpB.Current() );
316 BRepAdaptor_Curve theCurveB(EdgeB);
317 BRepAdaptor_Curve theCurveC(EdgeC);
318 A=theCurveC.Value(0.1);
319 B=theCurveC.Value(0.9);
320 C=theCurveB.Value(0.5);
321 }
322 else {
323 // FaceB a 1 unique edge courbe
324 BRepAdaptor_Curve theCurveB(EdgeB);
325 A=theCurveB.Value(0.1);
326 B=theCurveB.Value(0.9);
327 C=theCurveB.Value(0.5);
328 }
329 // Construction du Geom_Plane
330 GC_MakePlane MkPlane(A,B,C);
331 Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
332
333 // on le display & bind
334 theAISPlaneTri= new AIS_PlaneTrihedron(theGeomPlane );
335
336 theAISPlaneTri->SetXLabel(Xlabel);
337 theAISPlaneTri->SetYLabel(Ylabel);
338
339 GetMapOfAIS().Bind ( theAISPlaneTri, name);
340 aContext->Display(theAISPlaneTri );
341 }
342 return 0;
343}
344
345static Standard_Integer OCC295(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
346{
347 if(argc != 4) {
348 di << "Usage : " << argv[0] << " edge_result edge1 edge2" << "\n";
349 return 1;
350 }
351
352 TopoDS_Shape Sh1 = DBRep::Get(argv[2]);
353 TopoDS_Shape Sh2 = DBRep::Get(argv[3]);
354 if(Sh1.IsNull() || Sh2.IsNull()) return 1;
355 if(Sh1.ShapeType() != TopAbs_EDGE || Sh2.ShapeType() != TopAbs_EDGE) return 1;
356 TopoDS_Edge e1 = TopoDS::Edge(Sh1);
357 TopoDS_Edge e2 = TopoDS::Edge(Sh2);
358 Standard_Real f1,l1,f2,l2;
359 Standard_Boolean After = Standard_True;
360 Handle(Geom_Curve) ac1 = BRep_Tool::Curve(e1,f1,l1);
361 Handle(Geom_Curve) ac2 = BRep_Tool::Curve(e2,f2,l2);
362 Handle(Geom_BSplineCurve) bsplc1 = Handle(Geom_BSplineCurve)::DownCast(ac1);
363 Handle(Geom_BSplineCurve) bsplc2 = Handle(Geom_BSplineCurve)::DownCast(ac2);
364 if(bsplc1.IsNull() || bsplc2.IsNull()) return 1;
365 gp_Pnt pmid = 0.5 * ( bsplc1->Pole(bsplc1->NbPoles()).XYZ() + bsplc2->Pole(1).XYZ() );
366 bsplc1->SetPole(bsplc1->NbPoles(), pmid);
367 bsplc2->SetPole(1, pmid);
368 GeomConvert_CompCurveToBSplineCurve connect3d(bsplc1);
369 if(!connect3d.Add(bsplc2,Precision::Confusion(), After, Standard_False)) return 1;
370 BRepBuilderAPI_MakeEdge MkEdge(connect3d.BSplineCurve());
371 if(MkEdge.IsDone()) {
372 TopoDS_Edge nedge = MkEdge.Edge();
373 DBRep::Set ( argv[1], nedge );
374 return 0;
375 }
376 else return 1;
377}
378
379static Standard_Integer OCC49 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
380{
381
382 if ( argc != 2 ) {
383 di << "Usage : " << argv[0] << " name" << "\n";
384 return 1;
385 }
386
387 TopoDS_Shape S = DBRep::Get(argv[1]);
388 if (S.IsNull()) return 0;
389
390 GProp_GProps G;
391 BRepGProp::VolumeProperties(S,G);
392 GProp_PrincipalProps Pr = G.PrincipalProperties();
393 Standard_Boolean Result = Pr.HasSymmetryAxis();
394 if (Result) {
395 di << "1" << "\n";
396 } else {
397 di << "0" << "\n";
398 }
399 return 0;
400}
401
402static Standard_Integer OCC132 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
403{
404 /*
405 OCC132:
406 =======
407
408 ... the validation of the name of files in Analyse_DOS and Analyse_UNIX is :
409
410 characters not allowed in DOS/WNT names are
411 /
412 :
413 *
414 ?
415 "
416 <
417 >
418 |
419 and more than one dot in filename.
420 */
421
422 if ( argc != 2 ) {
423 di << "Usage : " << argv[0] << " DependentName" << "\n";
424 return 1;
425 }
426
427 OSD_SysType SysType1 = OSD_OS2;
428 OSD_SysType SysType2 = OSD_WindowsNT;
429
430 {
431 try {
432 OCC_CATCH_SIGNALS
433 OSD_Path Path (argv[1], SysType1);
434 }
435 catch (Standard_ProgramError) {
436 di << "1" << "\n";
437 return 0;
438 }
439 }
440
441 {
442 try {
443 OCC_CATCH_SIGNALS
444 OSD_Path Path (argv[1], SysType2);
445 }
446 catch (Standard_ProgramError) {
447 di << "2" << "\n";
448 return 0;
449 }
450 }
451
452 di << "0" << "\n";
453 return 0;
454}
455
456static Standard_Integer OCC405 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
457{
458 if(argc != 4) {
459 di << "Usage : " << argv[0] << " edge_result edge1 edge2; merge two edges" << "\n";
460 return 1;
461 }
462
463 TopoDS_Shape Sh1 = DBRep::Get(argv[2]);
464 TopoDS_Shape Sh2 = DBRep::Get(argv[3]);
465 if(Sh1.IsNull() || Sh2.IsNull()) return 1;
466 if(Sh1.ShapeType() != TopAbs_EDGE || Sh2.ShapeType() != TopAbs_EDGE) return 1;
467 TopoDS_Edge e1 = TopoDS::Edge(Sh1);
468 TopoDS_Edge e2 = TopoDS::Edge(Sh2);
469 Standard_Real f1,l1,f2,l2;
470 Standard_Boolean After = Standard_True;
471 Handle(Geom_Curve) ac1 = BRep_Tool::Curve(e1,f1,l1);
472 Handle(Geom_Curve) ac2 = BRep_Tool::Curve(e2,f2,l2);
473 if(e1.Orientation() == TopAbs_REVERSED) {
474 Standard_Real cf = f1;
475 f1 = ac1->ReversedParameter ( l1 );
476 l1 = ac1->ReversedParameter ( cf );
477 ac1 = ac1->Reversed();
478 }
479 if(e2.Orientation() == TopAbs_REVERSED) {
480 Standard_Real cf = f2;
481 f2 = ac2->ReversedParameter ( l2 );
482 l2 = ac2->ReversedParameter ( cf );
483 ac2 = ac2->Reversed();
484 }
485 Handle(Geom_BSplineCurve) bsplc1 = Handle(Geom_BSplineCurve)::DownCast(ac1);
486 Handle(Geom_BSplineCurve) bsplc2 = Handle(Geom_BSplineCurve)::DownCast(ac2);
487 if(bsplc1.IsNull() || bsplc2.IsNull()) return 1;
488 if(bsplc1->FirstParameter() < f1 - Precision::PConfusion() ||
489 bsplc1->LastParameter() > l1 + Precision::PConfusion()) {
490 Handle(Geom_BSplineCurve) aBstmp = Handle(Geom_BSplineCurve)::DownCast(bsplc1->Copy());
491 aBstmp->Segment(f1,l1);
7fd59977 492 bsplc1 =aBstmp;
493 }
494 if(bsplc2->FirstParameter() < f2 - Precision::PConfusion() ||
495 bsplc2->LastParameter() > l2 + Precision::PConfusion()) {
496 Handle(Geom_BSplineCurve) aBstmp = Handle(Geom_BSplineCurve)::DownCast(bsplc2->Copy());
497 aBstmp->Segment(f2,l2);
7fd59977 498 bsplc2 =aBstmp;
499 }
500 gp_Pnt pmid = 0.5 * ( bsplc1->Pole(bsplc1->NbPoles()).XYZ() + bsplc2->Pole(1).XYZ() );
501 bsplc1->SetPole(bsplc1->NbPoles(), pmid);
502 bsplc2->SetPole(1, pmid);
503 GeomConvert_CompCurveToBSplineCurve connect3d(bsplc1);
504 if(!connect3d.Add(bsplc2,Precision::Confusion(), After, Standard_False)) return 1;
505 BRepBuilderAPI_MakeEdge MkEdge(connect3d.BSplineCurve());
506 if(MkEdge.IsDone()) {
507 TopoDS_Edge nedge = MkEdge.Edge();
508 DBRep::Set ( argv[1], nedge );
509 return 0;
510 }
511 else return 1;
512}
513
514static Standard_Integer OCC252 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
515{
516 if(!(argc == 4 || argc == 5)) {
517 di << "Usage : " << argv[0] << " result part tool [ModeOfLimitation=0/1/2]" << "\n";
518 return 1;
519 }
520
521 TopoDS_Shape s1 = DBRep::Get(argv[2]);
522 TopoDS_Shape s2 = DBRep::Get(argv[3]);
523 if (s1.IsNull() || s2.IsNull()) return 1;
524
525 //QAModTopOpe_ModeOfLimitation ModeOfLimitation = QAModTopOpe_Forward;
526 QANewModTopOpe_ModeOfLimitation ModeOfLimitation = QANewModTopOpe_Forward;
527 if(argc==5) {
91322f44 528 Standard_Integer ModeOfLimitationInteger = Draw::Atoi(argv[4]);
7fd59977 529 if(!(ModeOfLimitationInteger == 0 || ModeOfLimitationInteger == 1 || ModeOfLimitationInteger == 2)) {
530 di << "Usage : " << argv[0] << " result part tool [ModeOfLimitation=0/1/2]" << "\n";
531 return 1;
532 }
533 //if (ModeOfLimitationInteger == 1) ModeOfLimitation = QAModTopOpe_Reversed;
534 //if (ModeOfLimitationInteger == 2) ModeOfLimitation = QAModTopOpe_BothParts;
535 if (ModeOfLimitationInteger == 1) ModeOfLimitation = QANewModTopOpe_Reversed;
536 if (ModeOfLimitationInteger == 2) ModeOfLimitation = QANewModTopOpe_BothParts;
537 }
538
539 //TopoDS_Shape res = QAModTopOpe_Limitation(s1,s2,ModeOfLimitation);
540 TopoDS_Shape res = QANewModTopOpe_Limitation(s1,s2,ModeOfLimitation);
541 if (res.IsNull()) {
542 di << "Error : result is null" << "\n";
543 return 1;
544 }
545
546 DBRep::Set(argv[1],res);
547
548 return 0;
549}
550
551static Standard_Integer OCC307 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
552{
553 if(!(argc == 4 || argc == 5)) {
554 di << "Usage : " << argv[0] << " result part tool [AllowCutting=0/1]" << "\n";
555 return 1;
556 }
557
558 TopoDS_Shape s1 = DBRep::Get(argv[2]);
559 TopoDS_Shape s2 = DBRep::Get(argv[3]);
560 if (s1.IsNull() || s2.IsNull()) return 1;
561
562 Standard_Boolean AllowCutting = Standard_False;
563 if(argc==5) {
91322f44 564 Standard_Integer AllowCuttingInteger = Draw::Atoi(argv[4]);
7fd59977 565 if(!( AllowCuttingInteger == 0 || AllowCuttingInteger == 1)) {
566 di << "Usage : " << argv[0] << " result part tool [AllowCutting=0/1]" << "\n";
567 return 1;
568 }
569 if (AllowCuttingInteger == 1) AllowCutting = Standard_True;
570 }
571
572 //TopoDS_Shape res = QAModTopOpe_Glue(s1,s2,AllowCutting);
573 TopoDS_Shape res = QANewModTopOpe_Glue(s1,s2,AllowCutting);
574 if (res.IsNull()) {
575 di << "Error : result is null" << "\n";
576 return 1;
577 }
578
579 DBRep::Set(argv[1],res);
580
581 return 0;
582}
583
584static Standard_Integer OCC395 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
585{
586 if(argc != 4) {
587 di << "Usage : " << argv[0] << " edge_result edge1 edge2" << "\n";
588 return 1;
589 }
590 //TCollection_AsciiString fnom(a[1]);
591 //Standard_Boolean modfic = XSDRAW::FileAndVar(a[1],a[2],a[3],"IGES",fnom,rnom,resnom);
592 TopoDS_Shape Sh1 = DBRep::Get(argv[2]);
593 TopoDS_Shape Sh2 = DBRep::Get(argv[3]);
594 if(Sh1.IsNull() || Sh2.IsNull()) return 1;
595 if(Sh1.ShapeType() != TopAbs_EDGE || Sh2.ShapeType() != TopAbs_EDGE) return 1;
596 TopoDS_Edge e1 = TopoDS::Edge(Sh1);
597 TopoDS_Edge e2 = TopoDS::Edge(Sh2);
598 Standard_Real f1,l1,f2,l2;
599 Standard_Boolean After = Standard_True;
600 Handle(Geom_Curve) ac1 = BRep_Tool::Curve(e1,f1,l1);
601 Handle(Geom_Curve) ac2 = BRep_Tool::Curve(e2,f2,l2);
602 if(e1.Orientation() == TopAbs_REVERSED) {
603 //Standard_Real cf = cf1;
604 //cf1 = ac1->ReversedParameter ( cl1 );
605 //cl1 = ac1->ReversedParameter ( cf );
606 ac1 = ac1->Reversed();
607 }
608 if(e2.Orientation() == TopAbs_REVERSED) {
609 //Standard_Real cf = cf2;
610 //ac2 = ac2->ReversedParameter ( cl2 );
611 //ac2 = ac2->ReversedParameter ( cf );
612 ac2 = ac2->Reversed();
613 }
614 Handle(Geom_BSplineCurve) bsplc1 = Handle(Geom_BSplineCurve)::DownCast(ac1);
615 Handle(Geom_BSplineCurve) bsplc2 = Handle(Geom_BSplineCurve)::DownCast(ac2);
616 if(bsplc1.IsNull() || bsplc2.IsNull()) return 1;
617 gp_Pnt pmid = 0.5 * ( bsplc1->Pole(bsplc1->NbPoles()).XYZ() + bsplc2->Pole(1).XYZ() );
618 bsplc1->SetPole(bsplc1->NbPoles(), pmid);
619 bsplc2->SetPole(1, pmid);
620 GeomConvert_CompCurveToBSplineCurve connect3d(bsplc1);
621 if(!connect3d.Add(bsplc2,Precision::Confusion(), After, Standard_False)) return 1;
622 BRepBuilderAPI_MakeEdge MkEdge(connect3d.BSplineCurve());
623 if(MkEdge.IsDone()) {
624 TopoDS_Edge nedge = MkEdge.Edge();
625 DBRep::Set ( argv[1], nedge );
626 return 0;
627 }
628 else return 1;
629}
630
631static Standard_Integer OCC394 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
632{
633 if(argc < 3) {
634 di << "Usage : " << argv[0] << " edge_result edge [tol [mode [tolang]]]" << "\n";
635 return 1;
636 }
637 TopoDS_Shape Sh = DBRep::Get(argv[2]);
638
639 Standard_Integer k = 3;
640 Standard_Real tol = 100000;
641 Standard_Integer mode = 2;
c6541a0c 642 Standard_Real tolang = M_PI/2;
7fd59977 643 if(argc > k)
91322f44 644 tol = Draw::Atof(argv[k++]);
7fd59977 645
646 if(argc > k)
91322f44 647 mode= Draw::Atoi(argv[k++]);
7fd59977 648
649 if(argc > k)
91322f44 650 tolang = Draw::Atof(argv[k++]);
7fd59977 651
652
653 Handle(ShapeFix_Wireframe) aSfwr = new ShapeFix_Wireframe();
654 Handle(ShapeBuild_ReShape) aReShape = new ShapeBuild_ReShape;
655 aSfwr->SetContext(aReShape);
656 aSfwr->Load(Sh);
657 aSfwr->SetPrecision(tol);
658 Standard_Boolean aModeDrop = Standard_True;
659 if(mode == 2)
660 aModeDrop = Standard_False;
661
662 TopTools_MapOfShape theSmallEdges, theMultyEdges;
663 TopTools_DataMapOfShapeListOfShape theEdgeToFaces,theFaceWithSmall;
664 aSfwr->CheckSmallEdges(theSmallEdges,theEdgeToFaces,theFaceWithSmall, theMultyEdges);
665 aSfwr->MergeSmallEdges (theSmallEdges,theEdgeToFaces,theFaceWithSmall, theMultyEdges, aModeDrop,tolang);
666 //aSfwr->FixSmallEdges();
667 TopoDS_Shape resShape = aSfwr->Shape();;
668 DBRep::Set ( argv[1], resShape );
669 return 0;
670}
671
672static Standard_Integer OCC301 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
673{
7fd59977 674 Handle(AIS_InteractiveContext) context = ViewerTest::GetAISContext();
675 if(context.IsNull()) {
676 di << "use 'vinit' command before " << argv[0] << "\n";
677 return 1;
678 }
a6eb515f 679 if ( argc != 3 ) {
680 di << "Usage : " << argv[0] << " ArcRadius ArrowSize" << "\n";
7fd59977 681 return 1;
682 }
683
a6eb515f 684 Standard_Real aRadius = Draw::Atof(argv[1]);
685 Standard_Real anArrowSize = Draw::Atof(argv[2]);
7fd59977 686
687 gp_Pnt p1 = gp_Pnt(10.,10.,0.);
688 gp_Pnt p2 = gp_Pnt(50.,10.,0.);
689 gp_Pnt p3 = gp_Pnt(50.,50.,0.);
690
691 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(p1, p2);
692 TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(p2, p3);
693
694 context->Display(new AIS_Shape(E1));
695 context->Display(new AIS_Shape(E2));
696
697 gp_Pnt plnpt(0, 0, 0);
698 gp_Dir plndir(0, 0, 1);
699 Handle(Geom_Plane) pln = new Geom_Plane(plnpt,plndir);
700
a6eb515f 701 Handle(AIS_AngleDimension) anAngleDimension = new AIS_AngleDimension (p1.Mirrored (p2), p2, p3);
702
703 Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect;
704 anAspect->MakeArrows3d (Standard_True);
705 anAspect->ArrowAspect()->SetLength (anArrowSize);
d7bffd44 706 anAspect->SetTextHorizontalPosition (Prs3d_DTHP_Right);
a6eb515f 707 anAspect->TextAspect ()->SetColor (Quantity_NOC_YELLOW);
708 anAngleDimension->SetDimensionAspect (anAspect);
709 // Another position of dimension
710 anAngleDimension->SetFlyout (aRadius);
711 context->Display (anAngleDimension, 0);
7fd59977 712 return 0;
713}
714
715static Standard_Integer OCC294 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
716{
717 if(argc < 4) {
718 di << "Usage : " << argv[0] << " shape_result shape edge" << "\n";
719 return 1;
720 }
721 TopoDS_Shape Sh1 = DBRep::Get(argv[2]);
722 TopoDS_Shape Sh2 = DBRep::Get(argv[3]);
723 if(Sh1.IsNull() || Sh2.IsNull()) return 1;
724 if(Sh2.ShapeType() != TopAbs_EDGE) return 1;
725
726 //QAModTopOpe_ReShaper ReShaper(Sh1);
727 QANewModTopOpe_ReShaper ReShaper(Sh1);
728 ReShaper.Remove(Sh2);
729 const TopoDS_Shape& ResultShape = ReShaper.GetResult();
730 if(ResultShape.IsNull()) {
731 di << "Faulty " << argv[0] << " : " << argv[1] << " - shape_result is null" << "\n";
732 return 1;
733 }
734
735 DBRep::Set ( argv[1], ResultShape);
736 return 0;
737}
738
739static Standard_Integer OCC60 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
740{
741 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
742 if(aContext.IsNull()) {
743 di << "use 'vinit' command before " << argv[0] << "\n";
744 return 1;
745 }
746 if(argc < 5) {
747 di << "Usage : " << argv[0] << " xmin ymin xmax ymax; selection window" << "\n";
748 return 1;
749 }
750
91322f44 751 Standard_Integer xmin = Draw::Atoi(argv[1]);
752 Standard_Integer ymin = Draw::Atoi(argv[2]);
753 Standard_Integer xmax = Draw::Atoi(argv[3]);
754 Standard_Integer ymax = Draw::Atoi(argv[4]);
7fd59977 755
756 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
757
758 Handle(ViewerTest_EventManager) EM = ViewerTest::CurrentEventManager();
759 EM->Select(xmin,ymin,xmax,ymax);
760
761 return 0;
762}
763
764static Standard_Integer OCC70 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
765{
766 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
767 if(aContext.IsNull()) {
768 di << "use 'vinit' command before " << argv[0] << "\n";
769 return 1;
770 }
771 if(argc < 7) {
772 di << "Usage : " << argv[0] << " x1 y1 x2 y2 x3 y3 [x y ...]; polygon of selection" << "\n";
773 return 1;
774 }
775 if (((argc - 1) % 2) != 0) {
776 di << "Usage : " << argv[0] << " x1 y1 x2 y2 x3 y3 [x y ...]; polygon of selection" << "\n";
777 return 1;
778 }
779
780 Standard_Integer i, j, np = (argc-1) / 2;
781 TColgp_Array1OfPnt2d Polyline(1,np);
782 j = 1;
783 for (i = 1; i <= np; i++) {
91322f44 784 Polyline(i) = gp_Pnt2d(Draw::Atof(argv[j]), Draw::Atof(argv[j+1]));
7fd59977 785 j += 2;
786 }
787
788 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
789
790 aContext->Select(Polyline,V3dView);
791 aContext->UpdateCurrentViewer();
792
793 return 0;
794}
795
796static Standard_Integer OCC261 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
797{
798 if(argc != 2) {
799 di << "Usage : " << argv[0] << " Doc" << "\n";
800 return 1;
801 }
802
803 Handle(TDocStd_Document) Doc;
804 if(DDocStd::GetDocument(argv[1], Doc)) {
805 Doc->ClearRedos();
806 return 0;
807 } else
808 return 1;
809}
810
811#include <OSD_File.hxx>
812static Standard_Integer OCC710 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
813{
814 if(argc != 2) {
815 di << "Usage : " << argv[0] << " path" << "\n";
816 }
817
818 TCollection_AsciiString in(argv[1]);
819 OSD_File* aFile = new OSD_File(in);
820 Standard_Boolean anExists = aFile->Exists();
821 if(anExists == Standard_True)
822 di << "1" << "\n";
823 else
824 di << "0" << "\n";
825 return 0;
826}
827
828#include <ShapeFix_Shell.hxx>
829static Standard_Integer OCC904 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
830{
831 if(argc != 4) {
832 di << "Usage : " << argv[0] << " result shape nonmanifoldmode(0/1)" << "\n";
833 }
834 TopoDS_Shape S = DBRep::Get(argv[2]);
835 if (S.IsNull() || S.ShapeType() != TopAbs_SHELL) {
836 di << " Shape is null" << "\n";
837 return 1;
838 }
91322f44 839 Standard_Boolean nonmanifmode = (Draw::Atoi(argv[3]) != 0);
7fd59977 840 Handle(ShapeFix_Shell) SFSh = new ShapeFix_Shell;
841 SFSh->FixFaceOrientation(TopoDS::Shell(S),Standard_True,nonmanifmode);
842 DBRep::Set(argv[1],SFSh->Shape());
843 return 0;
844}
845
1cd84fee 846void QABugs::Commands_16(Draw_Interpretor& theCommands) {
1365140b 847 const char *group = "QABugs";
7fd59977 848
849 theCommands.Add ("BUC60848", "BUC60848 shape", __FILE__, BUC60848, group);
850 theCommands.Add ("BUC60828", "BUC60828", __FILE__, BUC60828, group);
851 theCommands.Add ("BUC60814", "BUC60814", __FILE__, BUC60814, group);
852 theCommands.Add ("BUC60774", "BUC60774", __FILE__, BUC60774, group);
853 theCommands.Add ("BUC60972", "BUC60972 edge edge plane val text ", __FILE__, BUC60972, group);
854 theCommands.Add ("OCC218", "OCC218 name plane Xlabel Ylabel", __FILE__, OCC218bug, group);
855 theCommands.Add ("OCC295", "OCC295 edge_result edge1 edge2", __FILE__, OCC295, group);
856 theCommands.Add ("OCC49", "OCC49 name", __FILE__, OCC49, group);
857 theCommands.Add ("OCC132", "OCC132 DependentName", __FILE__, OCC132, group);
858 theCommands.Add ("OCC405", "OCC405 edge_result edge1 edge2; merge two edges", __FILE__, OCC405, group);
859 theCommands.Add ("OCC252", "OCC252 result part tool [ModeOfLimitation=0/1/2]", __FILE__, OCC252, group);
860 theCommands.Add ("OCC307", "OCC307 result part tool [AllowCutting=0/1]", __FILE__, OCC307, group);
861 theCommands.Add ("OCC395", "OCC395 edge_result edge1 edge2", __FILE__, OCC395, group);
862 theCommands.Add ("OCC394", "OCC394 edge_result edge [tol [mode [tolang]]]", __FILE__, OCC394, group);
a6eb515f 863 theCommands.Add ("OCC301", "OCC301 ArcRadius ArrowSize", __FILE__, OCC301, group);
7fd59977 864 theCommands.Add ("OCC294", "OCC294 shape_result shape edge", __FILE__, OCC294, group);
865 theCommands.Add ("OCC60", "OCC60 xmin ymin xmax ymax; selection window", __FILE__, OCC60, group);
866 theCommands.Add ("OCC70", "OCC70 x1 y1 x2 y2 x3 y3 [x y ...]; polygon of selection", __FILE__, OCC70, group);
867 theCommands.Add ("OCC261", "OCC261 Doc", __FILE__, OCC261, group);
868 theCommands.Add ("OCC710", "OCC710 path", __FILE__, OCC710, group);
869 theCommands.Add ("OCC904", "OCC904 result shape nonmanifoldmode(0/1)", __FILE__, OCC904, group);
870
871 return;
872}