1 // Created on: 2002-03-18
2 // Created by: QA Admin
3 // Copyright (c) 2002-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
19 #include <Draw_Interpretor.hxx>
21 #include <DrawTrSurf.hxx>
22 #include <AIS_InteractiveContext.hxx>
23 #include <ViewerTest.hxx>
24 #include <AIS_Shape.hxx>
25 #include <TopoDS_Shape.hxx>
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>
34 #include <Geom_Circle.hxx>
35 #include <AIS_Circle.hxx>
37 #include <Geom_Plane.hxx>
39 #include <AIS_AngleDimension.hxx>
41 #include <Aspect_Window.hxx>
42 #include <V3d_View.hxx>
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>
50 #include <BRep_Tool.hxx>
51 #include <Geom_BSplineCurve.hxx>
52 #include <GeomConvert_CompCurveToBSplineCurve.hxx>
53 #include <BRepBuilderAPI_MakeEdge.hxx>
54 #include <Precision.hxx>
56 #include <GProp_PrincipalProps.hxx>
58 #include <OSD_Path.hxx>
59 #include <Standard_ProgramError.hxx>
61 //#include <QAModTopOpe_Limitation.hxx>
62 #include <QANewModTopOpe_Limitation.hxx>
64 //#include <QAModTopOpe_Glue.hxx>
65 #include <QANewModTopOpe_Glue.hxx>
67 #include <ShapeFix_Wireframe.hxx>
68 #include <ShapeBuild_ReShape.hxx>
70 #include <BRepBuilderAPI_MakeEdge.hxx>
72 //#include <QAModTopOpe_ReShaper.hxx>
73 #include <QANewModTopOpe_ReShaper.hxx>
75 #include <ViewerTest_EventManager.hxx>
77 #include <TColgp_Array1OfPnt2d.hxx>
79 #include <DDocStd.hxx>
80 #include <TDocStd_Document.hxx>
81 #include <Standard_ErrorHandler.hxx>
84 extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
86 Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
89 static Standard_Integer BUC60848 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
92 di << "Usage : " << argv[0] << " shape \n";
95 TopoDS_Shape S = DBRep::Get( argv[1] );
97 di << "Shape is empty\n";
101 BRepGProp::VolumeProperties( S,G );
105 di << "Result is negative : " << GRes << "\n";
108 di << "Volume : " << GRes << "\n";
114 static Standard_Integer BUC60828 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
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";
129 static Standard_Integer BUC60814(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
133 di << "Usage : " << argv[0] << "\n";
138 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
139 if(myAISContext.IsNull()) {
140 di << "use 'vinit' command before " << argv[0] << "\n";
145 Handle(AIS_InteractiveObject) aTrihedron;
146 Handle(Geom_Axis2Placement) aTrihedronAxis=new Geom_Axis2Placement(gp::XOY());
147 aTrihedron=new AIS_Trihedron(aTrihedronAxis);
148 myAISContext->Display(aTrihedron);
155 Handle(Geom_Circle) ahCircle=new Geom_Circle(aAx2,20);
156 Handle(AIS_InteractiveObject) aCircle=new AIS_Circle(ahCircle);
157 myAISContext->Display(aCircle);
159 myAISContext->SelectionColor(Quantity_NOC_BLUE1);
161 myAISContext->AddOrRemoveSelected(aTrihedron);
162 myAISContext->AddOrRemoveSelected(aCircle);
167 //=======================================================================
168 //function : BUC60774
170 //=======================================================================
171 static Standard_Integer BUC60774 (Draw_Interpretor& theDi,
172 Standard_Integer theArgNb,
173 const char** theArgv)
177 std::cout << "Usage : " << theArgv[0] << "\n";
181 const Handle(AIS_InteractiveContext)& anAISContext = ViewerTest::GetAISContext();
182 if (anAISContext.IsNull())
184 std::cout << "use 'vinit' command before " << theArgv[0] << "\n";
188 const Handle(V3d_View)& aV3dView = ViewerTest::CurrentView();
190 Standard_Integer aWinWidth = 0;
191 Standard_Integer aWinHeight = 0;
192 aV3dView->Window()->Size (aWinWidth, aWinHeight);
194 Standard_Integer aXPixMin = 0;
195 Standard_Integer aYPixMin = 0;
196 Standard_Integer aXPixMax = aWinWidth;
197 Standard_Integer aYPixMax = aWinHeight;
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 ");
205 theDi.Eval ("box b 10 10 10");
206 theDi.Eval (" vdisplay b");
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 ");
214 theDi.Eval ("box w 20 20 20 20 20 20");
215 theDi.Eval (" vdisplay w");
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 ");
226 static Standard_Integer BUC60972 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
228 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
229 if(aContext.IsNull()) {
230 di << "use 'vinit' command before " << argv[0] << "\n";
235 di << "Usage : " << argv[0] << " edge edge plane val text\n";
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]));
245 di << aPlane->Pln().SquareDistance( gp_Pnt(0,0,0) ) << "\n";
247 TCollection_ExtendedString aText(argv[5]);
248 //Standard_ExtString ExtString_aText = aText.ToExtString();
249 //di << ExtString_aText << " " << Draw::Atof(argv[4]) << "\n";
250 di << argv[5] << " " << Draw::Atof(argv[4]) << "\n";
252 Handle(AIS_AngleDimension) aDim = new AIS_AngleDimension(aFirst, aSecond);
253 aContext->Display(aDim);
258 static Standard_Integer OCC218bug (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
260 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
261 if(aContext.IsNull()) {
262 di << "use 'vinit' command before " << argv[0] << "\n";
267 di << "Usage : " << argv[0] << " name plane Xlabel Ylabel\n";
271 TopoDS_Shape S = DBRep::Get( argv[2] );
273 di << "Shape is empty\n";
277 TCollection_AsciiString name(argv[1]);
278 TCollection_AsciiString Xlabel(argv[3]);
279 TCollection_AsciiString Ylabel(argv[4]);
281 // Construction de l'AIS_PlaneTrihedron
282 Handle(AIS_PlaneTrihedron) theAISPlaneTri;
284 Standard_Boolean IsBound = GetMapOfAIS().IsBound2(name);
286 // on recupere la shape dans la map des objets displayes
287 Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
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)::DownCast (aShape);
295 theAISPlaneTri->SetXLabel(Xlabel);
296 theAISPlaneTri->SetYLabel(Ylabel);
298 aContext->Redisplay(theAISPlaneTri, Standard_False);
299 aContext->UpdateCurrentViewer();
302 TopoDS_Face FaceB=TopoDS::Face(S);
304 // Construction du Plane
305 // recuperation des edges des faces.
306 TopExp_Explorer FaceExpB(FaceB,TopAbs_EDGE);
308 TopoDS_Edge EdgeB=TopoDS::Edge(FaceExpB.Current() );
312 // si il y a plusieurs edges
313 if (FaceExpB.More() ) {
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);
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);
329 // Construction du Geom_Plane
330 GC_MakePlane MkPlane(A,B,C);
331 Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
333 // on le display & bind
334 theAISPlaneTri= new AIS_PlaneTrihedron(theGeomPlane );
336 theAISPlaneTri->SetXLabel(Xlabel);
337 theAISPlaneTri->SetYLabel(Ylabel);
339 GetMapOfAIS().Bind ( theAISPlaneTri, name);
340 aContext->Display(theAISPlaneTri );
345 static Standard_Integer OCC295(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
348 di << "Usage : " << argv[0] << " edge_result edge1 edge2\n";
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 );
379 static Standard_Integer OCC49 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
383 di << "Usage : " << argv[0] << " name\n";
387 TopoDS_Shape S = DBRep::Get(argv[1]);
388 if (S.IsNull()) return 0;
391 BRepGProp::VolumeProperties(S,G);
392 GProp_PrincipalProps Pr = G.PrincipalProperties();
393 Standard_Boolean Result = Pr.HasSymmetryAxis();
402 static Standard_Integer OCC132 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
408 ... the validation of the name of files in Analyse_DOS and Analyse_UNIX is :
410 characters not allowed in DOS/WNT names are
419 and more than one dot in filename.
423 di << "Usage : " << argv[0] << " DependentName\n";
427 OSD_SysType SysType1 = OSD_OS2;
428 OSD_SysType SysType2 = OSD_WindowsNT;
433 OSD_Path Path (argv[1], SysType1);
435 catch (Standard_ProgramError) {
444 OSD_Path Path (argv[1], SysType2);
446 catch (Standard_ProgramError) {
456 static Standard_Integer OCC405 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
459 di << "Usage : " << argv[0] << " edge_result edge1 edge2; merge two edges\n";
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();
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();
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);
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);
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 );
514 static Standard_Integer OCC252 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
516 if(!(argc == 4 || argc == 5)) {
517 di << "Usage : " << argv[0] << " result part tool [ModeOfLimitation=0/1/2]\n";
521 TopoDS_Shape s1 = DBRep::Get(argv[2]);
522 TopoDS_Shape s2 = DBRep::Get(argv[3]);
523 if (s1.IsNull() || s2.IsNull()) return 1;
525 //QAModTopOpe_ModeOfLimitation ModeOfLimitation = QAModTopOpe_Forward;
526 QANewModTopOpe_ModeOfLimitation ModeOfLimitation = QANewModTopOpe_Forward;
528 Standard_Integer ModeOfLimitationInteger = Draw::Atoi(argv[4]);
529 if(!(ModeOfLimitationInteger == 0 || ModeOfLimitationInteger == 1 || ModeOfLimitationInteger == 2)) {
530 di << "Usage : " << argv[0] << " result part tool [ModeOfLimitation=0/1/2]\n";
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;
539 //TopoDS_Shape res = QAModTopOpe_Limitation(s1,s2,ModeOfLimitation);
540 TopoDS_Shape res = QANewModTopOpe_Limitation(s1,s2,ModeOfLimitation);
542 di << "Error : result is null\n";
546 DBRep::Set(argv[1],res);
551 static Standard_Integer OCC307 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
553 if(!(argc == 4 || argc == 5)) {
554 di << "Usage : " << argv[0] << " result part tool [AllowCutting=0/1]\n";
558 TopoDS_Shape s1 = DBRep::Get(argv[2]);
559 TopoDS_Shape s2 = DBRep::Get(argv[3]);
560 if (s1.IsNull() || s2.IsNull()) return 1;
562 Standard_Boolean AllowCutting = Standard_False;
564 Standard_Integer AllowCuttingInteger = Draw::Atoi(argv[4]);
565 if(!( AllowCuttingInteger == 0 || AllowCuttingInteger == 1)) {
566 di << "Usage : " << argv[0] << " result part tool [AllowCutting=0/1]\n";
569 if (AllowCuttingInteger == 1) AllowCutting = Standard_True;
572 //TopoDS_Shape res = QAModTopOpe_Glue(s1,s2,AllowCutting);
573 TopoDS_Shape res = QANewModTopOpe_Glue(s1,s2,AllowCutting);
575 di << "Error : result is null\n";
579 DBRep::Set(argv[1],res);
584 static Standard_Integer OCC395 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
587 di << "Usage : " << argv[0] << " edge_result edge1 edge2\n";
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();
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();
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 );
631 static Standard_Integer OCC394 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
634 di << "Usage : " << argv[0] << " edge_result edge [tol [mode [tolang]]]\n";
637 TopoDS_Shape Sh = DBRep::Get(argv[2]);
639 Standard_Integer k = 3;
640 Standard_Real tol = 100000;
641 Standard_Integer mode = 2;
642 Standard_Real tolang = M_PI/2;
644 tol = Draw::Atof(argv[k++]);
647 mode= Draw::Atoi(argv[k++]);
650 tolang = Draw::Atof(argv[k++]);
653 Handle(ShapeFix_Wireframe) aSfwr = new ShapeFix_Wireframe();
654 Handle(ShapeBuild_ReShape) aReShape = new ShapeBuild_ReShape;
655 aSfwr->SetContext(aReShape);
657 aSfwr->SetPrecision(tol);
658 Standard_Boolean aModeDrop = Standard_True;
660 aModeDrop = Standard_False;
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 );
672 static Standard_Integer OCC301 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
674 Handle(AIS_InteractiveContext) context = ViewerTest::GetAISContext();
675 if(context.IsNull()) {
676 di << "use 'vinit' command before " << argv[0] << "\n";
680 di << "Usage : " << argv[0] << " ArcRadius ArrowSize\n";
684 Standard_Real aRadius = Draw::Atof(argv[1]);
685 Standard_Real anArrowSize = Draw::Atof(argv[2]);
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.);
691 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(p1, p2);
692 TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(p2, p3);
694 context->Display(new AIS_Shape(E1));
695 context->Display(new AIS_Shape(E2));
697 gp_Pnt plnpt(0, 0, 0);
698 gp_Dir plndir(0, 0, 1);
699 Handle(Geom_Plane) pln = new Geom_Plane(plnpt,plndir);
701 Handle(AIS_AngleDimension) anAngleDimension = new AIS_AngleDimension (p1.Mirrored (p2), p2, p3);
703 Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect;
704 anAspect->MakeArrows3d (Standard_True);
705 anAspect->ArrowAspect()->SetLength (anArrowSize);
706 anAspect->SetTextHorizontalPosition (Prs3d_DTHP_Right);
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);
715 static Standard_Integer OCC294 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
718 di << "Usage : " << argv[0] << " shape_result shape edge\n";
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;
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";
735 DBRep::Set ( argv[1], ResultShape);
739 static Standard_Integer OCC60 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
741 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
742 if(aContext.IsNull()) {
743 di << "use 'vinit' command before " << argv[0] << "\n";
747 di << "Usage : " << argv[0] << " xmin ymin xmax ymax; selection window\n";
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]);
756 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
758 Handle(ViewerTest_EventManager) EM = ViewerTest::CurrentEventManager();
759 EM->Select(xmin,ymin,xmax,ymax);
764 static Standard_Integer OCC70 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
766 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
767 if(aContext.IsNull()) {
768 di << "use 'vinit' command before " << argv[0] << "\n";
772 di << "Usage : " << argv[0] << " x1 y1 x2 y2 x3 y3 [x y ...]; polygon of selection\n";
775 if (((argc - 1) % 2) != 0) {
776 di << "Usage : " << argv[0] << " x1 y1 x2 y2 x3 y3 [x y ...]; polygon of selection\n";
780 Standard_Integer i, j, np = (argc-1) / 2;
781 TColgp_Array1OfPnt2d Polyline(1,np);
783 for (i = 1; i <= np; i++) {
784 Polyline(i) = gp_Pnt2d(Draw::Atof(argv[j]), Draw::Atof(argv[j+1]));
788 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
790 aContext->Select(Polyline,V3dView);
791 aContext->UpdateCurrentViewer();
796 static Standard_Integer OCC261 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
799 di << "Usage : " << argv[0] << " Doc\n";
803 Handle(TDocStd_Document) Doc;
804 if(DDocStd::GetDocument(argv[1], Doc)) {
811 #include <OSD_File.hxx>
812 static Standard_Integer OCC710 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
815 di << "Usage : " << argv[0] << " path\n";
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)
828 #include <ShapeFix_Shell.hxx>
829 #include <AIS_InteractiveObject.hxx>
830 static Standard_Integer OCC904 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
833 di << "Usage : " << argv[0] << " result shape nonmanifoldmode(0/1)\n";
835 TopoDS_Shape S = DBRep::Get(argv[2]);
836 if (S.IsNull() || S.ShapeType() != TopAbs_SHELL) {
837 di << " Shape is null\n";
840 Standard_Boolean nonmanifmode = (Draw::Atoi(argv[3]) != 0);
841 Handle(ShapeFix_Shell) SFSh = new ShapeFix_Shell;
842 SFSh->FixFaceOrientation(TopoDS::Shell(S),Standard_True,nonmanifmode);
843 DBRep::Set(argv[1],SFSh->Shape());
847 void QABugs::Commands_16(Draw_Interpretor& theCommands) {
848 const char *group = "QABugs";
850 theCommands.Add ("BUC60848", "BUC60848 shape", __FILE__, BUC60848, group);
851 theCommands.Add ("BUC60828", "BUC60828", __FILE__, BUC60828, group);
852 theCommands.Add ("BUC60814", "BUC60814", __FILE__, BUC60814, group);
853 theCommands.Add ("BUC60774", "BUC60774", __FILE__, BUC60774, group);
854 theCommands.Add ("BUC60972", "BUC60972 edge edge plane val text ", __FILE__, BUC60972, group);
855 theCommands.Add ("OCC218", "OCC218 name plane Xlabel Ylabel", __FILE__, OCC218bug, group);
856 theCommands.Add ("OCC295", "OCC295 edge_result edge1 edge2", __FILE__, OCC295, group);
857 theCommands.Add ("OCC49", "OCC49 name", __FILE__, OCC49, group);
858 theCommands.Add ("OCC132", "OCC132 DependentName", __FILE__, OCC132, group);
859 theCommands.Add ("OCC405", "OCC405 edge_result edge1 edge2; merge two edges", __FILE__, OCC405, group);
860 theCommands.Add ("OCC252", "OCC252 result part tool [ModeOfLimitation=0/1/2]", __FILE__, OCC252, group);
861 theCommands.Add ("OCC307", "OCC307 result part tool [AllowCutting=0/1]", __FILE__, OCC307, group);
862 theCommands.Add ("OCC395", "OCC395 edge_result edge1 edge2", __FILE__, OCC395, group);
863 theCommands.Add ("OCC394", "OCC394 edge_result edge [tol [mode [tolang]]]", __FILE__, OCC394, group);
864 theCommands.Add ("OCC301", "OCC301 ArcRadius ArrowSize", __FILE__, OCC301, group);
865 theCommands.Add ("OCC294", "OCC294 shape_result shape edge", __FILE__, OCC294, group);
866 theCommands.Add ("OCC60", "OCC60 xmin ymin xmax ymax; selection window", __FILE__, OCC60, group);
867 theCommands.Add ("OCC70", "OCC70 x1 y1 x2 y2 x3 y3 [x y ...]; polygon of selection", __FILE__, OCC70, group);
868 theCommands.Add ("OCC261", "OCC261 Doc", __FILE__, OCC261, group);
869 theCommands.Add ("OCC710", "OCC710 path", __FILE__, OCC710, group);
870 theCommands.Add ("OCC904", "OCC904 result shape nonmanifoldmode(0/1)", __FILE__, OCC904, group);