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