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 Handle(Graphic3d_HighlightStyle)& aSelStyle = myAISContext->ChangeSelectionStyle();
160 aSelStyle->SetColor (Quantity_NOC_BLUE1);
162 myAISContext->AddOrRemoveSelected(aTrihedron);
163 myAISContext->AddOrRemoveSelected(aCircle);
168 //=======================================================================
169 //function : BUC60774
171 //=======================================================================
172 static Standard_Integer BUC60774 (Draw_Interpretor& theDi,
173 Standard_Integer theArgNb,
174 const char** theArgv)
178 std::cout << "Usage : " << theArgv[0] << "\n";
182 const Handle(AIS_InteractiveContext)& anAISContext = ViewerTest::GetAISContext();
183 if (anAISContext.IsNull())
185 std::cout << "use 'vinit' command before " << theArgv[0] << "\n";
189 const Handle(V3d_View)& aV3dView = ViewerTest::CurrentView();
191 Standard_Integer aWinWidth = 0;
192 Standard_Integer aWinHeight = 0;
193 aV3dView->Window()->Size (aWinWidth, aWinHeight);
195 Standard_Integer aXPixMin = 0;
196 Standard_Integer aYPixMin = 0;
197 Standard_Integer aXPixMax = aWinWidth;
198 Standard_Integer aYPixMax = aWinHeight;
200 AIS_StatusOfPick aPickStatus = anAISContext->Select (aXPixMin, aYPixMin, aXPixMax, aYPixMax, aV3dView);
201 theDi << (aPickStatus == AIS_SOP_NothingSelected
202 ? "status = AIS_SOP_NothingSelected : OK"
203 : "status = AIS_SOP_NothingSelected : bugged - Faulty ");
206 theDi.Eval ("box b 10 10 10");
207 theDi.Eval (" vdisplay b");
209 aPickStatus = anAISContext->Select (aXPixMin, aYPixMin, aXPixMax, aYPixMax, aV3dView);
210 theDi << (aPickStatus == AIS_SOP_OneSelected
211 ? "status = AIS_SOP_OneSelected : OK"
212 : "status = AIS_SOP_OneSelected : bugged - Faulty ");
215 theDi.Eval ("box w 20 20 20 20 20 20");
216 theDi.Eval (" vdisplay w");
218 aPickStatus = anAISContext->Select (aXPixMin, aYPixMin, aXPixMax, aYPixMax, aV3dView);
219 theDi << (aPickStatus == AIS_SOP_SeveralSelected
220 ? "status = AIS_SOP_SeveralSelected : OK"
221 : "status = AIS_SOP_SeveralSelected : bugged - Faulty ");
227 static Standard_Integer BUC60972 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
229 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
230 if(aContext.IsNull()) {
231 di << "use 'vinit' command before " << argv[0] << "\n";
236 di << "Usage : " << argv[0] << " edge edge plane val text\n";
240 TopoDS_Edge aFirst = TopoDS::Edge(DBRep::Get(argv[1],TopAbs_EDGE));
241 TopoDS_Edge aSecond = TopoDS::Edge(DBRep::Get(argv[2],TopAbs_EDGE));
242 Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(DrawTrSurf::GetSurface(argv[3]));
246 di << aPlane->Pln().SquareDistance( gp_Pnt(0,0,0) ) << "\n";
248 TCollection_ExtendedString aText(argv[5]);
249 //Standard_ExtString ExtString_aText = aText.ToExtString();
250 //di << ExtString_aText << " " << Draw::Atof(argv[4]) << "\n";
251 di << argv[5] << " " << Draw::Atof(argv[4]) << "\n";
253 Handle(AIS_AngleDimension) aDim = new AIS_AngleDimension(aFirst, aSecond);
254 aContext->Display(aDim);
259 static Standard_Integer OCC218bug (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
261 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
262 if(aContext.IsNull()) {
263 di << "use 'vinit' command before " << argv[0] << "\n";
268 di << "Usage : " << argv[0] << " name plane Xlabel Ylabel\n";
272 TopoDS_Shape S = DBRep::Get( argv[2] );
274 di << "Shape is empty\n";
278 TCollection_AsciiString name(argv[1]);
279 TCollection_AsciiString Xlabel(argv[3]);
280 TCollection_AsciiString Ylabel(argv[4]);
282 // Construction de l'AIS_PlaneTrihedron
283 Handle(AIS_PlaneTrihedron) theAISPlaneTri;
285 Standard_Boolean IsBound = GetMapOfAIS().IsBound2(name);
287 // on recupere la shape dans la map des objets displayes
288 Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
290 // On verifie que l'AIS InteraciveObject est bien
291 // un AIS_PlaneTrihedron
292 if (aShape->Type()==AIS_KOI_Datum && aShape->Signature()==4) {
293 // On downcast aShape de AIS_InteractiveObject a AIS_PlaneTrihedron
294 theAISPlaneTri = Handle(AIS_PlaneTrihedron)::DownCast (aShape);
296 theAISPlaneTri->SetXLabel(Xlabel);
297 theAISPlaneTri->SetYLabel(Ylabel);
299 aContext->Redisplay(theAISPlaneTri, Standard_False);
300 aContext->UpdateCurrentViewer();
303 TopoDS_Face FaceB=TopoDS::Face(S);
305 // Construction du Plane
306 // recuperation des edges des faces.
307 TopExp_Explorer FaceExpB(FaceB,TopAbs_EDGE);
309 TopoDS_Edge EdgeB=TopoDS::Edge(FaceExpB.Current() );
313 // si il y a plusieurs edges
314 if (FaceExpB.More() ) {
316 TopoDS_Edge EdgeC=TopoDS::Edge(FaceExpB.Current() );
317 BRepAdaptor_Curve theCurveB(EdgeB);
318 BRepAdaptor_Curve theCurveC(EdgeC);
319 A=theCurveC.Value(0.1);
320 B=theCurveC.Value(0.9);
321 C=theCurveB.Value(0.5);
324 // FaceB a 1 unique edge courbe
325 BRepAdaptor_Curve theCurveB(EdgeB);
326 A=theCurveB.Value(0.1);
327 B=theCurveB.Value(0.9);
328 C=theCurveB.Value(0.5);
330 // Construction du Geom_Plane
331 GC_MakePlane MkPlane(A,B,C);
332 Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
334 // on le display & bind
335 theAISPlaneTri= new AIS_PlaneTrihedron(theGeomPlane );
337 theAISPlaneTri->SetXLabel(Xlabel);
338 theAISPlaneTri->SetYLabel(Ylabel);
340 GetMapOfAIS().Bind ( theAISPlaneTri, name);
341 aContext->Display(theAISPlaneTri );
346 static Standard_Integer OCC295(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
349 di << "Usage : " << argv[0] << " edge_result edge1 edge2\n";
353 TopoDS_Shape Sh1 = DBRep::Get(argv[2]);
354 TopoDS_Shape Sh2 = DBRep::Get(argv[3]);
355 if(Sh1.IsNull() || Sh2.IsNull()) return 1;
356 if(Sh1.ShapeType() != TopAbs_EDGE || Sh2.ShapeType() != TopAbs_EDGE) return 1;
357 TopoDS_Edge e1 = TopoDS::Edge(Sh1);
358 TopoDS_Edge e2 = TopoDS::Edge(Sh2);
359 Standard_Real f1,l1,f2,l2;
360 Standard_Boolean After = Standard_True;
361 Handle(Geom_Curve) ac1 = BRep_Tool::Curve(e1,f1,l1);
362 Handle(Geom_Curve) ac2 = BRep_Tool::Curve(e2,f2,l2);
363 Handle(Geom_BSplineCurve) bsplc1 = Handle(Geom_BSplineCurve)::DownCast(ac1);
364 Handle(Geom_BSplineCurve) bsplc2 = Handle(Geom_BSplineCurve)::DownCast(ac2);
365 if(bsplc1.IsNull() || bsplc2.IsNull()) return 1;
366 gp_Pnt pmid = 0.5 * ( bsplc1->Pole(bsplc1->NbPoles()).XYZ() + bsplc2->Pole(1).XYZ() );
367 bsplc1->SetPole(bsplc1->NbPoles(), pmid);
368 bsplc2->SetPole(1, pmid);
369 GeomConvert_CompCurveToBSplineCurve connect3d(bsplc1);
370 if(!connect3d.Add(bsplc2,Precision::Confusion(), After, Standard_False)) return 1;
371 BRepBuilderAPI_MakeEdge MkEdge(connect3d.BSplineCurve());
372 if(MkEdge.IsDone()) {
373 TopoDS_Edge nedge = MkEdge.Edge();
374 DBRep::Set ( argv[1], nedge );
380 static Standard_Integer OCC49 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
384 di << "Usage : " << argv[0] << " name\n";
388 TopoDS_Shape S = DBRep::Get(argv[1]);
389 if (S.IsNull()) return 0;
392 BRepGProp::VolumeProperties(S,G);
393 GProp_PrincipalProps Pr = G.PrincipalProperties();
394 Standard_Boolean Result = Pr.HasSymmetryAxis();
403 static Standard_Integer OCC132 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
409 ... the validation of the name of files in Analyse_DOS and Analyse_UNIX is :
411 characters not allowed in DOS/WNT names are
420 and more than one dot in filename.
424 di << "Usage : " << argv[0] << " DependentName\n";
428 OSD_SysType SysType1 = OSD_OS2;
429 OSD_SysType SysType2 = OSD_WindowsNT;
434 OSD_Path Path (argv[1], SysType1);
436 catch (Standard_ProgramError) {
445 OSD_Path Path (argv[1], SysType2);
447 catch (Standard_ProgramError) {
457 static Standard_Integer OCC405 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
460 di << "Usage : " << argv[0] << " edge_result edge1 edge2; merge two edges\n";
464 TopoDS_Shape Sh1 = DBRep::Get(argv[2]);
465 TopoDS_Shape Sh2 = DBRep::Get(argv[3]);
466 if(Sh1.IsNull() || Sh2.IsNull()) return 1;
467 if(Sh1.ShapeType() != TopAbs_EDGE || Sh2.ShapeType() != TopAbs_EDGE) return 1;
468 TopoDS_Edge e1 = TopoDS::Edge(Sh1);
469 TopoDS_Edge e2 = TopoDS::Edge(Sh2);
470 Standard_Real f1,l1,f2,l2;
471 Standard_Boolean After = Standard_True;
472 Handle(Geom_Curve) ac1 = BRep_Tool::Curve(e1,f1,l1);
473 Handle(Geom_Curve) ac2 = BRep_Tool::Curve(e2,f2,l2);
474 if(e1.Orientation() == TopAbs_REVERSED) {
475 Standard_Real cf = f1;
476 f1 = ac1->ReversedParameter ( l1 );
477 l1 = ac1->ReversedParameter ( cf );
478 ac1 = ac1->Reversed();
480 if(e2.Orientation() == TopAbs_REVERSED) {
481 Standard_Real cf = f2;
482 f2 = ac2->ReversedParameter ( l2 );
483 l2 = ac2->ReversedParameter ( cf );
484 ac2 = ac2->Reversed();
486 Handle(Geom_BSplineCurve) bsplc1 = Handle(Geom_BSplineCurve)::DownCast(ac1);
487 Handle(Geom_BSplineCurve) bsplc2 = Handle(Geom_BSplineCurve)::DownCast(ac2);
488 if(bsplc1.IsNull() || bsplc2.IsNull()) return 1;
489 if(bsplc1->FirstParameter() < f1 - Precision::PConfusion() ||
490 bsplc1->LastParameter() > l1 + Precision::PConfusion()) {
491 Handle(Geom_BSplineCurve) aBstmp = Handle(Geom_BSplineCurve)::DownCast(bsplc1->Copy());
492 aBstmp->Segment(f1,l1);
495 if(bsplc2->FirstParameter() < f2 - Precision::PConfusion() ||
496 bsplc2->LastParameter() > l2 + Precision::PConfusion()) {
497 Handle(Geom_BSplineCurve) aBstmp = Handle(Geom_BSplineCurve)::DownCast(bsplc2->Copy());
498 aBstmp->Segment(f2,l2);
501 gp_Pnt pmid = 0.5 * ( bsplc1->Pole(bsplc1->NbPoles()).XYZ() + bsplc2->Pole(1).XYZ() );
502 bsplc1->SetPole(bsplc1->NbPoles(), pmid);
503 bsplc2->SetPole(1, pmid);
504 GeomConvert_CompCurveToBSplineCurve connect3d(bsplc1);
505 if(!connect3d.Add(bsplc2,Precision::Confusion(), After, Standard_False)) return 1;
506 BRepBuilderAPI_MakeEdge MkEdge(connect3d.BSplineCurve());
507 if(MkEdge.IsDone()) {
508 TopoDS_Edge nedge = MkEdge.Edge();
509 DBRep::Set ( argv[1], nedge );
515 static Standard_Integer OCC252 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
517 if(!(argc == 4 || argc == 5)) {
518 di << "Usage : " << argv[0] << " result part tool [ModeOfLimitation=0/1/2]\n";
522 TopoDS_Shape s1 = DBRep::Get(argv[2]);
523 TopoDS_Shape s2 = DBRep::Get(argv[3]);
524 if (s1.IsNull() || s2.IsNull()) return 1;
526 //QAModTopOpe_ModeOfLimitation ModeOfLimitation = QAModTopOpe_Forward;
527 QANewModTopOpe_ModeOfLimitation ModeOfLimitation = QANewModTopOpe_Forward;
529 Standard_Integer ModeOfLimitationInteger = Draw::Atoi(argv[4]);
530 if(!(ModeOfLimitationInteger == 0 || ModeOfLimitationInteger == 1 || ModeOfLimitationInteger == 2)) {
531 di << "Usage : " << argv[0] << " result part tool [ModeOfLimitation=0/1/2]\n";
534 //if (ModeOfLimitationInteger == 1) ModeOfLimitation = QAModTopOpe_Reversed;
535 //if (ModeOfLimitationInteger == 2) ModeOfLimitation = QAModTopOpe_BothParts;
536 if (ModeOfLimitationInteger == 1) ModeOfLimitation = QANewModTopOpe_Reversed;
537 if (ModeOfLimitationInteger == 2) ModeOfLimitation = QANewModTopOpe_BothParts;
540 //TopoDS_Shape res = QAModTopOpe_Limitation(s1,s2,ModeOfLimitation);
541 TopoDS_Shape res = QANewModTopOpe_Limitation(s1,s2,ModeOfLimitation);
543 di << "Error : result is null\n";
547 DBRep::Set(argv[1],res);
552 static Standard_Integer OCC307 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
554 if(!(argc == 4 || argc == 5)) {
555 di << "Usage : " << argv[0] << " result part tool [AllowCutting=0/1]\n";
559 TopoDS_Shape s1 = DBRep::Get(argv[2]);
560 TopoDS_Shape s2 = DBRep::Get(argv[3]);
561 if (s1.IsNull() || s2.IsNull()) return 1;
563 Standard_Boolean AllowCutting = Standard_False;
565 Standard_Integer AllowCuttingInteger = Draw::Atoi(argv[4]);
566 if(!( AllowCuttingInteger == 0 || AllowCuttingInteger == 1)) {
567 di << "Usage : " << argv[0] << " result part tool [AllowCutting=0/1]\n";
570 if (AllowCuttingInteger == 1) AllowCutting = Standard_True;
573 //TopoDS_Shape res = QAModTopOpe_Glue(s1,s2,AllowCutting);
574 TopoDS_Shape res = QANewModTopOpe_Glue(s1,s2,AllowCutting);
576 di << "Error : result is null\n";
580 DBRep::Set(argv[1],res);
585 static Standard_Integer OCC395 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
588 di << "Usage : " << argv[0] << " edge_result edge1 edge2\n";
591 //TCollection_AsciiString fnom(a[1]);
592 //Standard_Boolean modfic = XSDRAW::FileAndVar(a[1],a[2],a[3],"IGES",fnom,rnom,resnom);
593 TopoDS_Shape Sh1 = DBRep::Get(argv[2]);
594 TopoDS_Shape Sh2 = DBRep::Get(argv[3]);
595 if(Sh1.IsNull() || Sh2.IsNull()) return 1;
596 if(Sh1.ShapeType() != TopAbs_EDGE || Sh2.ShapeType() != TopAbs_EDGE) return 1;
597 TopoDS_Edge e1 = TopoDS::Edge(Sh1);
598 TopoDS_Edge e2 = TopoDS::Edge(Sh2);
599 Standard_Real f1,l1,f2,l2;
600 Standard_Boolean After = Standard_True;
601 Handle(Geom_Curve) ac1 = BRep_Tool::Curve(e1,f1,l1);
602 Handle(Geom_Curve) ac2 = BRep_Tool::Curve(e2,f2,l2);
603 if(e1.Orientation() == TopAbs_REVERSED) {
604 //Standard_Real cf = cf1;
605 //cf1 = ac1->ReversedParameter ( cl1 );
606 //cl1 = ac1->ReversedParameter ( cf );
607 ac1 = ac1->Reversed();
609 if(e2.Orientation() == TopAbs_REVERSED) {
610 //Standard_Real cf = cf2;
611 //ac2 = ac2->ReversedParameter ( cl2 );
612 //ac2 = ac2->ReversedParameter ( cf );
613 ac2 = ac2->Reversed();
615 Handle(Geom_BSplineCurve) bsplc1 = Handle(Geom_BSplineCurve)::DownCast(ac1);
616 Handle(Geom_BSplineCurve) bsplc2 = Handle(Geom_BSplineCurve)::DownCast(ac2);
617 if(bsplc1.IsNull() || bsplc2.IsNull()) return 1;
618 gp_Pnt pmid = 0.5 * ( bsplc1->Pole(bsplc1->NbPoles()).XYZ() + bsplc2->Pole(1).XYZ() );
619 bsplc1->SetPole(bsplc1->NbPoles(), pmid);
620 bsplc2->SetPole(1, pmid);
621 GeomConvert_CompCurveToBSplineCurve connect3d(bsplc1);
622 if(!connect3d.Add(bsplc2,Precision::Confusion(), After, Standard_False)) return 1;
623 BRepBuilderAPI_MakeEdge MkEdge(connect3d.BSplineCurve());
624 if(MkEdge.IsDone()) {
625 TopoDS_Edge nedge = MkEdge.Edge();
626 DBRep::Set ( argv[1], nedge );
632 static Standard_Integer OCC394 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
635 di << "Usage : " << argv[0] << " edge_result edge [tol [mode [tolang]]]\n";
638 TopoDS_Shape Sh = DBRep::Get(argv[2]);
640 Standard_Integer k = 3;
641 Standard_Real tol = 100000;
642 Standard_Integer mode = 2;
643 Standard_Real tolang = M_PI/2;
645 tol = Draw::Atof(argv[k++]);
648 mode= Draw::Atoi(argv[k++]);
651 tolang = Draw::Atof(argv[k++]);
654 Handle(ShapeFix_Wireframe) aSfwr = new ShapeFix_Wireframe();
655 Handle(ShapeBuild_ReShape) aReShape = new ShapeBuild_ReShape;
656 aSfwr->SetContext(aReShape);
658 aSfwr->SetPrecision(tol);
659 Standard_Boolean aModeDrop = Standard_True;
661 aModeDrop = Standard_False;
663 TopTools_MapOfShape theSmallEdges, theMultyEdges;
664 TopTools_DataMapOfShapeListOfShape theEdgeToFaces,theFaceWithSmall;
665 aSfwr->CheckSmallEdges(theSmallEdges,theEdgeToFaces,theFaceWithSmall, theMultyEdges);
666 aSfwr->MergeSmallEdges (theSmallEdges,theEdgeToFaces,theFaceWithSmall, theMultyEdges, aModeDrop,tolang);
667 //aSfwr->FixSmallEdges();
668 TopoDS_Shape resShape = aSfwr->Shape();;
669 DBRep::Set ( argv[1], resShape );
673 static Standard_Integer OCC301 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
675 Handle(AIS_InteractiveContext) context = ViewerTest::GetAISContext();
676 if(context.IsNull()) {
677 di << "use 'vinit' command before " << argv[0] << "\n";
681 di << "Usage : " << argv[0] << " ArcRadius ArrowSize\n";
685 Standard_Real aRadius = Draw::Atof(argv[1]);
686 Standard_Real anArrowSize = Draw::Atof(argv[2]);
688 gp_Pnt p1 = gp_Pnt(10.,10.,0.);
689 gp_Pnt p2 = gp_Pnt(50.,10.,0.);
690 gp_Pnt p3 = gp_Pnt(50.,50.,0.);
692 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(p1, p2);
693 TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(p2, p3);
695 context->Display(new AIS_Shape(E1));
696 context->Display(new AIS_Shape(E2));
698 gp_Pnt plnpt(0, 0, 0);
699 gp_Dir plndir(0, 0, 1);
700 Handle(Geom_Plane) pln = new Geom_Plane(plnpt,plndir);
702 Handle(AIS_AngleDimension) anAngleDimension = new AIS_AngleDimension (p1.Mirrored (p2), p2, p3);
704 Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect;
705 anAspect->MakeArrows3d (Standard_True);
706 anAspect->ArrowAspect()->SetLength (anArrowSize);
707 anAspect->SetTextHorizontalPosition (Prs3d_DTHP_Right);
708 anAspect->TextAspect ()->SetColor (Quantity_NOC_YELLOW);
709 anAngleDimension->SetDimensionAspect (anAspect);
710 // Another position of dimension
711 anAngleDimension->SetFlyout (aRadius);
712 context->Display (anAngleDimension, 0);
716 static Standard_Integer OCC294 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
719 di << "Usage : " << argv[0] << " shape_result shape edge\n";
722 TopoDS_Shape Sh1 = DBRep::Get(argv[2]);
723 TopoDS_Shape Sh2 = DBRep::Get(argv[3]);
724 if(Sh1.IsNull() || Sh2.IsNull()) return 1;
725 if(Sh2.ShapeType() != TopAbs_EDGE) return 1;
727 //QAModTopOpe_ReShaper ReShaper(Sh1);
728 QANewModTopOpe_ReShaper ReShaper(Sh1);
729 ReShaper.Remove(Sh2);
730 const TopoDS_Shape& ResultShape = ReShaper.GetResult();
731 if(ResultShape.IsNull()) {
732 di << "Faulty " << argv[0] << " : " << argv[1] << " - shape_result is null\n";
736 DBRep::Set ( argv[1], ResultShape);
740 static Standard_Integer OCC60 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
742 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
743 if(aContext.IsNull()) {
744 di << "use 'vinit' command before " << argv[0] << "\n";
748 di << "Usage : " << argv[0] << " xmin ymin xmax ymax; selection window\n";
752 Standard_Integer xmin = Draw::Atoi(argv[1]);
753 Standard_Integer ymin = Draw::Atoi(argv[2]);
754 Standard_Integer xmax = Draw::Atoi(argv[3]);
755 Standard_Integer ymax = Draw::Atoi(argv[4]);
757 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
759 Handle(ViewerTest_EventManager) EM = ViewerTest::CurrentEventManager();
760 EM->Select(xmin,ymin,xmax,ymax);
765 static Standard_Integer OCC70 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
767 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
768 if(aContext.IsNull()) {
769 di << "use 'vinit' command before " << argv[0] << "\n";
773 di << "Usage : " << argv[0] << " x1 y1 x2 y2 x3 y3 [x y ...]; polygon of selection\n";
776 if (((argc - 1) % 2) != 0) {
777 di << "Usage : " << argv[0] << " x1 y1 x2 y2 x3 y3 [x y ...]; polygon of selection\n";
781 Standard_Integer i, j, np = (argc-1) / 2;
782 TColgp_Array1OfPnt2d Polyline(1,np);
784 for (i = 1; i <= np; i++) {
785 Polyline(i) = gp_Pnt2d(Draw::Atof(argv[j]), Draw::Atof(argv[j+1]));
789 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
791 aContext->Select(Polyline,V3dView);
792 aContext->UpdateCurrentViewer();
797 static Standard_Integer OCC261 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
800 di << "Usage : " << argv[0] << " Doc\n";
804 Handle(TDocStd_Document) Doc;
805 if(DDocStd::GetDocument(argv[1], Doc)) {
812 #include <OSD_File.hxx>
813 static Standard_Integer OCC710 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
816 di << "Usage : " << argv[0] << " path\n";
819 TCollection_AsciiString in(argv[1]);
820 OSD_File* aFile = new OSD_File(in);
821 Standard_Boolean anExists = aFile->Exists();
822 if(anExists == Standard_True)
829 #include <ShapeFix_Shell.hxx>
830 #include <AIS_InteractiveObject.hxx>
831 static Standard_Integer OCC904 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
834 di << "Usage : " << argv[0] << " result shape nonmanifoldmode(0/1)\n";
836 TopoDS_Shape S = DBRep::Get(argv[2]);
837 if (S.IsNull() || S.ShapeType() != TopAbs_SHELL) {
838 di << " Shape is null\n";
841 Standard_Boolean nonmanifmode = (Draw::Atoi(argv[3]) != 0);
842 Handle(ShapeFix_Shell) SFSh = new ShapeFix_Shell;
843 SFSh->FixFaceOrientation(TopoDS::Shell(S),Standard_True,nonmanifmode);
844 DBRep::Set(argv[1],SFSh->Shape());
848 void QABugs::Commands_16(Draw_Interpretor& theCommands) {
849 const char *group = "QABugs";
851 theCommands.Add ("BUC60848", "BUC60848 shape", __FILE__, BUC60848, group);
852 theCommands.Add ("BUC60828", "BUC60828", __FILE__, BUC60828, group);
853 theCommands.Add ("BUC60814", "BUC60814", __FILE__, BUC60814, group);
854 theCommands.Add ("BUC60774", "BUC60774", __FILE__, BUC60774, group);
855 theCommands.Add ("BUC60972", "BUC60972 edge edge plane val text ", __FILE__, BUC60972, group);
856 theCommands.Add ("OCC218", "OCC218 name plane Xlabel Ylabel", __FILE__, OCC218bug, group);
857 theCommands.Add ("OCC295", "OCC295 edge_result edge1 edge2", __FILE__, OCC295, group);
858 theCommands.Add ("OCC49", "OCC49 name", __FILE__, OCC49, group);
859 theCommands.Add ("OCC132", "OCC132 DependentName", __FILE__, OCC132, group);
860 theCommands.Add ("OCC405", "OCC405 edge_result edge1 edge2; merge two edges", __FILE__, OCC405, group);
861 theCommands.Add ("OCC252", "OCC252 result part tool [ModeOfLimitation=0/1/2]", __FILE__, OCC252, group);
862 theCommands.Add ("OCC307", "OCC307 result part tool [AllowCutting=0/1]", __FILE__, OCC307, group);
863 theCommands.Add ("OCC395", "OCC395 edge_result edge1 edge2", __FILE__, OCC395, group);
864 theCommands.Add ("OCC394", "OCC394 edge_result edge [tol [mode [tolang]]]", __FILE__, OCC394, group);
865 theCommands.Add ("OCC301", "OCC301 ArcRadius ArrowSize", __FILE__, OCC301, group);
866 theCommands.Add ("OCC294", "OCC294 shape_result shape edge", __FILE__, OCC294, group);
867 theCommands.Add ("OCC60", "OCC60 xmin ymin xmax ymax; selection window", __FILE__, OCC60, group);
868 theCommands.Add ("OCC70", "OCC70 x1 y1 x2 y2 x3 y3 [x y ...]; polygon of selection", __FILE__, OCC70, group);
869 theCommands.Add ("OCC261", "OCC261 Doc", __FILE__, OCC261, group);
870 theCommands.Add ("OCC710", "OCC710 path", __FILE__, OCC710, group);
871 theCommands.Add ("OCC904", "OCC904 result shape nonmanifoldmode(0/1)", __FILE__, OCC904, group);