1 // Created on: 2002-03-18
2 // Created by: QA Admin
3 // Copyright (c) 2002-2012 OPEN CASCADE SAS
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
23 #include <Draw_Interpretor.hxx>
25 #include <DrawTrSurf.hxx>
26 #include <AIS_InteractiveContext.hxx>
27 #include <ViewerTest.hxx>
28 #include <AIS_Shape.hxx>
29 #include <TopoDS_Shape.hxx>
31 #include <GProp_GProps.hxx>
32 #include <BRepGProp.hxx>
33 #include <TopoDS_Edge.hxx>
34 #include <BRepBuilderAPI_MakeEdge.hxx>
35 #include <AIS_Trihedron.hxx>
36 #include <Geom_Axis2Placement.hxx>
38 #include <Geom_Circle.hxx>
39 #include <AIS_Circle.hxx>
40 #include <V3d_View.hxx>
42 #include <Geom_Plane.hxx>
44 #include <AIS_AngleDimension.hxx>
46 #include <TopExp_Explorer.hxx>
47 #include <BRepAdaptor_Curve.hxx>
48 #include <GC_MakePlane.hxx>
49 #include <AIS_PlaneTrihedron.hxx>
50 #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
52 #include <BRep_Tool.hxx>
53 #include <Geom_BSplineCurve.hxx>
54 #include <GeomConvert_CompCurveToBSplineCurve.hxx>
55 #include <BRepBuilderAPI_MakeEdge.hxx>
56 #include <Precision.hxx>
58 #include <GProp_PrincipalProps.hxx>
60 #include <OSD_Path.hxx>
61 #include <Standard_ProgramError.hxx>
63 //#include <QAModTopOpe_Limitation.hxx>
64 #include <QANewModTopOpe_Limitation.hxx>
66 //#include <QAModTopOpe_Glue.hxx>
67 #include <QANewModTopOpe_Glue.hxx>
69 #include <ShapeFix_Wireframe.hxx>
70 #include <ShapeBuild_ReShape.hxx>
72 #include <ViewerTest_Tool.hxx>
73 #include <BRepBuilderAPI_MakeEdge.hxx>
75 //#include <QAModTopOpe_ReShaper.hxx>
76 #include <QANewModTopOpe_ReShaper.hxx>
78 #include <ViewerTest_EventManager.hxx>
80 #include <TColgp_Array1OfPnt2d.hxx>
82 #include <DDocStd.hxx>
83 #include <TDocStd_Document.hxx>
84 #include <Standard_ErrorHandler.hxx>
87 extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
89 Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
92 static Standard_Integer BUC60848 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
95 di << "Usage : " << argv[0] << " shape " << "\n";
98 TopoDS_Shape S = DBRep::Get( argv[1] );
100 di << "Shape is empty" << "\n";
104 BRepGProp::VolumeProperties( S,G );
108 di << "Result is negative : " << GRes << "\n";
111 di << "Volume : " << GRes << "\n";
117 static Standard_Integer BUC60828 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
119 TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(0.,0.,0.), gp_Pnt(0.,0.,1.));
120 Standard_Boolean aValue;
121 aValue=anEdge.Infinite();
122 di << "Initial flag : " << (Standard_Integer) aValue << "\n";
123 anEdge.Infinite(Standard_True);
124 Standard_Boolean aValue1;
125 aValue1=anEdge.Infinite();
126 di << "Current flag : " << (Standard_Integer) aValue1 << "\n";
127 if(aValue1) di << "Flag was set properly." << "\n";
128 else di << "Faulty : flag was not set properly." << "\n";
132 static Standard_Integer BUC60814(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
136 di << "Usage : " << argv[0] << "\n";
141 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
142 if(myAISContext.IsNull()) {
143 di << "use 'vinit' command before " << argv[0] << "\n";
148 Handle(AIS_Trihedron) aTrihedron;
149 Handle(Geom_Axis2Placement) aTrihedronAxis=new Geom_Axis2Placement(gp::XOY());
150 aTrihedron=new AIS_Trihedron(aTrihedronAxis);
151 myAISContext->Display(aTrihedron);
158 Handle(Geom_Circle) ahCircle=new Geom_Circle(aAx2,20);
159 Handle(AIS_Circle) aCircle=new AIS_Circle(ahCircle);
160 myAISContext->Display(aCircle);
162 myAISContext->SelectionColor(Quantity_NOC_BLUE1);
164 myAISContext->AddOrRemoveSelected(aTrihedron);
165 myAISContext->AddOrRemoveSelected(aCircle);
170 static Standard_Integer BUC60774(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
174 di << "Usage : " << argv[0] << "\n";
178 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
179 if(myAISContext.IsNull())
181 di << "use 'vinit' command before " << argv[0] << "\n";
185 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
187 double Xc,Yc,Width, Height;
188 myV3dView->Center(Xc,Yc);
189 myV3dView-> Size (Width, Height);
198 Standard_Integer XPmin,YPmin;
199 myV3dView->Convert(Xmin,Ymin,XPmin,YPmin);
200 // cout<<Xmin<<"\t"<<Ymin<<endl;
201 // cout<<XPmin<<"\t"<<YPmin<<endl;
203 Standard_Integer XPmax,YPmax;
204 myV3dView->Convert(Xmax,Ymax,XPmax,YPmax);
205 // cout<<Xmax<<"\t"<<Ymax<<endl;
206 // cout<<XPmax<<"\t"<<YPmax<<endl;
208 AIS_StatusOfPick status;
209 if ((status=myAISContext->Select(XPmin,YPmin,XPmax,YPmax,myV3dView))==AIS_SOP_NothingSelected)
210 di << "status = AIS_SOP_NothingSelected : OK" << "\n";
211 else di << "status = AIS_SOP_NothingSelected : bugged - Faulty " << "\n";
213 di.Eval("box b 10 10 10");
214 di.Eval(" vdisplay b");
216 if ((status=myAISContext->Select(XPmin,YPmin,XPmax,YPmax,myV3dView))==AIS_SOP_OneSelected)
217 di << "status = AIS_SOP_OneSelected : OK" << "\n";
218 else di << "status = AIS_SOP_OneSelected : bugged - Faulty " << "\n";
220 di.Eval("box w 20 20 20 20 20 20");
221 di.Eval(" vdisplay w");
223 if ((status=myAISContext->Select(XPmin,YPmin,XPmax,YPmax,myV3dView))==AIS_SOP_SeveralSelected)
224 di << "status = AIS_SOP_SeveralSelected : OK" << "\n";
225 else di << "status = AIS_SOP_SeveralSelected : bugged - Faulty " << "\n";
231 static Standard_Integer BUC60972 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
233 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
234 if(aContext.IsNull()) {
235 di << "use 'vinit' command before " << argv[0] << "\n";
240 di << "Usage : " << argv[0] << " edge edge plane val text" << "\n";
244 TopoDS_Edge aFirst = TopoDS::Edge(DBRep::Get(argv[1],TopAbs_EDGE));
245 TopoDS_Edge aSecond = TopoDS::Edge(DBRep::Get(argv[2],TopAbs_EDGE));
246 Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(DrawTrSurf::GetSurface(argv[3]));
250 di << aPlane->Pln().SquareDistance( gp_Pnt(0,0,0) ) << "\n";
252 TCollection_ExtendedString aText(argv[5]);
253 //Standard_ExtString ExtString_aText = aText.ToExtString();
254 //di << ExtString_aText << " " << Draw::Atof(argv[4]) << "\n";
255 di << argv[5] << " " << Draw::Atof(argv[4]) << "\n";
257 Handle(AIS_AngleDimension) aDim = new AIS_AngleDimension(aFirst, aSecond, aPlane->Pln());
258 aContext->Display(aDim);
263 static Standard_Integer OCC218bug (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
265 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
266 if(aContext.IsNull()) {
267 di << "use 'vinit' command before " << argv[0] << "\n";
272 di << "Usage : " << argv[0] << " name plane Xlabel Ylabel" << "\n";
276 TopoDS_Shape S = DBRep::Get( argv[2] );
278 di << "Shape is empty" << "\n";
282 TCollection_AsciiString name(argv[1]);
283 TCollection_AsciiString Xlabel(argv[3]);
284 TCollection_AsciiString Ylabel(argv[4]);
286 // Construction de l'AIS_PlaneTrihedron
287 Handle(AIS_PlaneTrihedron) theAISPlaneTri;
289 Standard_Boolean IsBound = GetMapOfAIS().IsBound2(name);
291 // on recupere la shape dans la map des objets displayes
292 Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
294 // On verifie que l'AIS InteraciveObject est bien
295 // un AIS_PlaneTrihedron
296 if (aShape->Type()==AIS_KOI_Datum && aShape->Signature()==4) {
297 // On downcast aShape de AIS_InteractiveObject a AIS_PlaneTrihedron
298 theAISPlaneTri = *(Handle(AIS_PlaneTrihedron)*) &aShape;
300 theAISPlaneTri->SetXLabel(Xlabel);
301 theAISPlaneTri->SetYLabel(Ylabel);
303 aContext->Redisplay(theAISPlaneTri, Standard_False);
304 aContext->UpdateCurrentViewer();
307 TopoDS_Face FaceB=TopoDS::Face(S);
309 // Construction du Plane
310 // recuperation des edges des faces.
311 TopExp_Explorer FaceExpB(FaceB,TopAbs_EDGE);
313 TopoDS_Edge EdgeB=TopoDS::Edge(FaceExpB.Current() );
317 // si il y a plusieurs edges
318 if (FaceExpB.More() ) {
320 TopoDS_Edge EdgeC=TopoDS::Edge(FaceExpB.Current() );
321 BRepAdaptor_Curve theCurveB(EdgeB);
322 BRepAdaptor_Curve theCurveC(EdgeC);
323 A=theCurveC.Value(0.1);
324 B=theCurveC.Value(0.9);
325 C=theCurveB.Value(0.5);
328 // FaceB a 1 unique edge courbe
329 BRepAdaptor_Curve theCurveB(EdgeB);
330 A=theCurveB.Value(0.1);
331 B=theCurveB.Value(0.9);
332 C=theCurveB.Value(0.5);
334 // Construction du Geom_Plane
335 GC_MakePlane MkPlane(A,B,C);
336 Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
338 // on le display & bind
339 theAISPlaneTri= new AIS_PlaneTrihedron(theGeomPlane );
341 theAISPlaneTri->SetXLabel(Xlabel);
342 theAISPlaneTri->SetYLabel(Ylabel);
344 GetMapOfAIS().Bind ( theAISPlaneTri, name);
345 aContext->Display(theAISPlaneTri );
350 static Standard_Integer OCC295(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
353 di << "Usage : " << argv[0] << " edge_result edge1 edge2" << "\n";
357 TopoDS_Shape Sh1 = DBRep::Get(argv[2]);
358 TopoDS_Shape Sh2 = DBRep::Get(argv[3]);
359 if(Sh1.IsNull() || Sh2.IsNull()) return 1;
360 if(Sh1.ShapeType() != TopAbs_EDGE || Sh2.ShapeType() != TopAbs_EDGE) return 1;
361 TopoDS_Edge e1 = TopoDS::Edge(Sh1);
362 TopoDS_Edge e2 = TopoDS::Edge(Sh2);
363 Standard_Real f1,l1,f2,l2;
364 Standard_Boolean After = Standard_True;
365 Handle(Geom_Curve) ac1 = BRep_Tool::Curve(e1,f1,l1);
366 Handle(Geom_Curve) ac2 = BRep_Tool::Curve(e2,f2,l2);
367 Handle(Geom_BSplineCurve) bsplc1 = Handle(Geom_BSplineCurve)::DownCast(ac1);
368 Handle(Geom_BSplineCurve) bsplc2 = Handle(Geom_BSplineCurve)::DownCast(ac2);
369 if(bsplc1.IsNull() || bsplc2.IsNull()) return 1;
370 gp_Pnt pmid = 0.5 * ( bsplc1->Pole(bsplc1->NbPoles()).XYZ() + bsplc2->Pole(1).XYZ() );
371 bsplc1->SetPole(bsplc1->NbPoles(), pmid);
372 bsplc2->SetPole(1, pmid);
373 GeomConvert_CompCurveToBSplineCurve connect3d(bsplc1);
374 if(!connect3d.Add(bsplc2,Precision::Confusion(), After, Standard_False)) return 1;
375 BRepBuilderAPI_MakeEdge MkEdge(connect3d.BSplineCurve());
376 if(MkEdge.IsDone()) {
377 TopoDS_Edge nedge = MkEdge.Edge();
378 DBRep::Set ( argv[1], nedge );
384 static Standard_Integer OCC49 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
388 di << "Usage : " << argv[0] << " name" << "\n";
392 TopoDS_Shape S = DBRep::Get(argv[1]);
393 if (S.IsNull()) return 0;
396 BRepGProp::VolumeProperties(S,G);
397 GProp_PrincipalProps Pr = G.PrincipalProperties();
398 Standard_Boolean Result = Pr.HasSymmetryAxis();
407 static Standard_Integer OCC132 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
413 ... the validation of the name of files in Analyse_DOS and Analyse_UNIX is :
415 characters not allowed in DOS/WNT names are
424 and more than one dot in filename.
428 di << "Usage : " << argv[0] << " DependentName" << "\n";
432 OSD_SysType SysType1 = OSD_OS2;
433 OSD_SysType SysType2 = OSD_WindowsNT;
438 OSD_Path Path (argv[1], SysType1);
440 catch (Standard_ProgramError) {
449 OSD_Path Path (argv[1], SysType2);
451 catch (Standard_ProgramError) {
461 static Standard_Integer OCC405 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
464 di << "Usage : " << argv[0] << " edge_result edge1 edge2; merge two edges" << "\n";
468 TopoDS_Shape Sh1 = DBRep::Get(argv[2]);
469 TopoDS_Shape Sh2 = DBRep::Get(argv[3]);
470 if(Sh1.IsNull() || Sh2.IsNull()) return 1;
471 if(Sh1.ShapeType() != TopAbs_EDGE || Sh2.ShapeType() != TopAbs_EDGE) return 1;
472 TopoDS_Edge e1 = TopoDS::Edge(Sh1);
473 TopoDS_Edge e2 = TopoDS::Edge(Sh2);
474 Standard_Real f1,l1,f2,l2;
475 Standard_Boolean After = Standard_True;
476 Handle(Geom_Curve) ac1 = BRep_Tool::Curve(e1,f1,l1);
477 Handle(Geom_Curve) ac2 = BRep_Tool::Curve(e2,f2,l2);
478 if(e1.Orientation() == TopAbs_REVERSED) {
479 Standard_Real cf = f1;
480 f1 = ac1->ReversedParameter ( l1 );
481 l1 = ac1->ReversedParameter ( cf );
482 ac1 = ac1->Reversed();
484 if(e2.Orientation() == TopAbs_REVERSED) {
485 Standard_Real cf = f2;
486 f2 = ac2->ReversedParameter ( l2 );
487 l2 = ac2->ReversedParameter ( cf );
488 ac2 = ac2->Reversed();
490 Handle(Geom_BSplineCurve) bsplc1 = Handle(Geom_BSplineCurve)::DownCast(ac1);
491 Handle(Geom_BSplineCurve) bsplc2 = Handle(Geom_BSplineCurve)::DownCast(ac2);
492 if(bsplc1.IsNull() || bsplc2.IsNull()) return 1;
493 if(bsplc1->FirstParameter() < f1 - Precision::PConfusion() ||
494 bsplc1->LastParameter() > l1 + Precision::PConfusion()) {
495 Handle(Geom_BSplineCurve) aBstmp = Handle(Geom_BSplineCurve)::DownCast(bsplc1->Copy());
496 aBstmp->Segment(f1,l1);
499 if(bsplc2->FirstParameter() < f2 - Precision::PConfusion() ||
500 bsplc2->LastParameter() > l2 + Precision::PConfusion()) {
501 Handle(Geom_BSplineCurve) aBstmp = Handle(Geom_BSplineCurve)::DownCast(bsplc2->Copy());
502 aBstmp->Segment(f2,l2);
505 gp_Pnt pmid = 0.5 * ( bsplc1->Pole(bsplc1->NbPoles()).XYZ() + bsplc2->Pole(1).XYZ() );
506 bsplc1->SetPole(bsplc1->NbPoles(), pmid);
507 bsplc2->SetPole(1, pmid);
508 GeomConvert_CompCurveToBSplineCurve connect3d(bsplc1);
509 if(!connect3d.Add(bsplc2,Precision::Confusion(), After, Standard_False)) return 1;
510 BRepBuilderAPI_MakeEdge MkEdge(connect3d.BSplineCurve());
511 if(MkEdge.IsDone()) {
512 TopoDS_Edge nedge = MkEdge.Edge();
513 DBRep::Set ( argv[1], nedge );
519 static Standard_Integer OCC252 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
521 if(!(argc == 4 || argc == 5)) {
522 di << "Usage : " << argv[0] << " result part tool [ModeOfLimitation=0/1/2]" << "\n";
526 TopoDS_Shape s1 = DBRep::Get(argv[2]);
527 TopoDS_Shape s2 = DBRep::Get(argv[3]);
528 if (s1.IsNull() || s2.IsNull()) return 1;
530 //QAModTopOpe_ModeOfLimitation ModeOfLimitation = QAModTopOpe_Forward;
531 QANewModTopOpe_ModeOfLimitation ModeOfLimitation = QANewModTopOpe_Forward;
533 Standard_Integer ModeOfLimitationInteger = Draw::Atoi(argv[4]);
534 if(!(ModeOfLimitationInteger == 0 || ModeOfLimitationInteger == 1 || ModeOfLimitationInteger == 2)) {
535 di << "Usage : " << argv[0] << " result part tool [ModeOfLimitation=0/1/2]" << "\n";
538 //if (ModeOfLimitationInteger == 1) ModeOfLimitation = QAModTopOpe_Reversed;
539 //if (ModeOfLimitationInteger == 2) ModeOfLimitation = QAModTopOpe_BothParts;
540 if (ModeOfLimitationInteger == 1) ModeOfLimitation = QANewModTopOpe_Reversed;
541 if (ModeOfLimitationInteger == 2) ModeOfLimitation = QANewModTopOpe_BothParts;
544 //TopoDS_Shape res = QAModTopOpe_Limitation(s1,s2,ModeOfLimitation);
545 TopoDS_Shape res = QANewModTopOpe_Limitation(s1,s2,ModeOfLimitation);
547 di << "Error : result is null" << "\n";
551 DBRep::Set(argv[1],res);
556 static Standard_Integer OCC307 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
558 if(!(argc == 4 || argc == 5)) {
559 di << "Usage : " << argv[0] << " result part tool [AllowCutting=0/1]" << "\n";
563 TopoDS_Shape s1 = DBRep::Get(argv[2]);
564 TopoDS_Shape s2 = DBRep::Get(argv[3]);
565 if (s1.IsNull() || s2.IsNull()) return 1;
567 Standard_Boolean AllowCutting = Standard_False;
569 Standard_Integer AllowCuttingInteger = Draw::Atoi(argv[4]);
570 if(!( AllowCuttingInteger == 0 || AllowCuttingInteger == 1)) {
571 di << "Usage : " << argv[0] << " result part tool [AllowCutting=0/1]" << "\n";
574 if (AllowCuttingInteger == 1) AllowCutting = Standard_True;
577 //TopoDS_Shape res = QAModTopOpe_Glue(s1,s2,AllowCutting);
578 TopoDS_Shape res = QANewModTopOpe_Glue(s1,s2,AllowCutting);
580 di << "Error : result is null" << "\n";
584 DBRep::Set(argv[1],res);
589 static Standard_Integer OCC395 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
592 di << "Usage : " << argv[0] << " edge_result edge1 edge2" << "\n";
595 //TCollection_AsciiString fnom(a[1]);
596 //Standard_Boolean modfic = XSDRAW::FileAndVar(a[1],a[2],a[3],"IGES",fnom,rnom,resnom);
597 TopoDS_Shape Sh1 = DBRep::Get(argv[2]);
598 TopoDS_Shape Sh2 = DBRep::Get(argv[3]);
599 if(Sh1.IsNull() || Sh2.IsNull()) return 1;
600 if(Sh1.ShapeType() != TopAbs_EDGE || Sh2.ShapeType() != TopAbs_EDGE) return 1;
601 TopoDS_Edge e1 = TopoDS::Edge(Sh1);
602 TopoDS_Edge e2 = TopoDS::Edge(Sh2);
603 Standard_Real f1,l1,f2,l2;
604 Standard_Boolean After = Standard_True;
605 Handle(Geom_Curve) ac1 = BRep_Tool::Curve(e1,f1,l1);
606 Handle(Geom_Curve) ac2 = BRep_Tool::Curve(e2,f2,l2);
607 if(e1.Orientation() == TopAbs_REVERSED) {
608 //Standard_Real cf = cf1;
609 //cf1 = ac1->ReversedParameter ( cl1 );
610 //cl1 = ac1->ReversedParameter ( cf );
611 ac1 = ac1->Reversed();
613 if(e2.Orientation() == TopAbs_REVERSED) {
614 //Standard_Real cf = cf2;
615 //ac2 = ac2->ReversedParameter ( cl2 );
616 //ac2 = ac2->ReversedParameter ( cf );
617 ac2 = ac2->Reversed();
619 Handle(Geom_BSplineCurve) bsplc1 = Handle(Geom_BSplineCurve)::DownCast(ac1);
620 Handle(Geom_BSplineCurve) bsplc2 = Handle(Geom_BSplineCurve)::DownCast(ac2);
621 if(bsplc1.IsNull() || bsplc2.IsNull()) return 1;
622 gp_Pnt pmid = 0.5 * ( bsplc1->Pole(bsplc1->NbPoles()).XYZ() + bsplc2->Pole(1).XYZ() );
623 bsplc1->SetPole(bsplc1->NbPoles(), pmid);
624 bsplc2->SetPole(1, pmid);
625 GeomConvert_CompCurveToBSplineCurve connect3d(bsplc1);
626 if(!connect3d.Add(bsplc2,Precision::Confusion(), After, Standard_False)) return 1;
627 BRepBuilderAPI_MakeEdge MkEdge(connect3d.BSplineCurve());
628 if(MkEdge.IsDone()) {
629 TopoDS_Edge nedge = MkEdge.Edge();
630 DBRep::Set ( argv[1], nedge );
636 static Standard_Integer OCC394 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
639 di << "Usage : " << argv[0] << " edge_result edge [tol [mode [tolang]]]" << "\n";
642 TopoDS_Shape Sh = DBRep::Get(argv[2]);
644 Standard_Integer k = 3;
645 Standard_Real tol = 100000;
646 Standard_Integer mode = 2;
647 Standard_Real tolang = M_PI/2;
649 tol = Draw::Atof(argv[k++]);
652 mode= Draw::Atoi(argv[k++]);
655 tolang = Draw::Atof(argv[k++]);
658 Handle(ShapeFix_Wireframe) aSfwr = new ShapeFix_Wireframe();
659 Handle(ShapeBuild_ReShape) aReShape = new ShapeBuild_ReShape;
660 aSfwr->SetContext(aReShape);
662 aSfwr->SetPrecision(tol);
663 Standard_Boolean aModeDrop = Standard_True;
665 aModeDrop = Standard_False;
667 TopTools_MapOfShape theSmallEdges, theMultyEdges;
668 TopTools_DataMapOfShapeListOfShape theEdgeToFaces,theFaceWithSmall;
669 aSfwr->CheckSmallEdges(theSmallEdges,theEdgeToFaces,theFaceWithSmall, theMultyEdges);
670 aSfwr->MergeSmallEdges (theSmallEdges,theEdgeToFaces,theFaceWithSmall, theMultyEdges, aModeDrop,tolang);
671 //aSfwr->FixSmallEdges();
672 TopoDS_Shape resShape = aSfwr->Shape();;
673 DBRep::Set ( argv[1], resShape );
677 static Standard_Integer OCC301 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
679 //Handle(AIS_InteractiveContext) context= ViewerTest_Tool::MakeContext ("OCC301");
680 //ViewerTest_Tool::InitViewerTest (context);
681 Handle(AIS_InteractiveContext) context = ViewerTest::GetAISContext();
682 if(context.IsNull()) {
683 di << "use 'vinit' command before " << argv[0] << "\n";
687 di << "Usage : " << argv[0] << " ArcRadius ArrowSize" << "\n";
691 Standard_Real aRadius = Draw::Atof(argv[1]);
692 Standard_Real anArrowSize = Draw::Atof(argv[2]);
694 gp_Pnt p1 = gp_Pnt(10.,10.,0.);
695 gp_Pnt p2 = gp_Pnt(50.,10.,0.);
696 gp_Pnt p3 = gp_Pnt(50.,50.,0.);
698 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(p1, p2);
699 TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(p2, p3);
701 context->Display(new AIS_Shape(E1));
702 context->Display(new AIS_Shape(E2));
704 gp_Pnt plnpt(0, 0, 0);
705 gp_Dir plndir(0, 0, 1);
706 Handle(Geom_Plane) pln = new Geom_Plane(plnpt,plndir);
708 Handle(AIS_AngleDimension) anAngleDimension = new AIS_AngleDimension (p1.Mirrored (p2), p2, p3);
710 Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect;
711 anAspect->MakeArrows3d (Standard_True);
712 anAspect->ArrowAspect()->SetLength (anArrowSize);
713 anAspect->SetTextHorizontalPosition (Prs3d_DTHP_Right);
714 anAspect->TextAspect ()->SetColor (Quantity_NOC_YELLOW);
715 anAngleDimension->SetDimensionAspect (anAspect);
716 // Another position of dimension
717 anAngleDimension->SetFlyout (aRadius);
718 context->Display (anAngleDimension, 0);
722 static Standard_Integer OCC294 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
725 di << "Usage : " << argv[0] << " shape_result shape edge" << "\n";
728 TopoDS_Shape Sh1 = DBRep::Get(argv[2]);
729 TopoDS_Shape Sh2 = DBRep::Get(argv[3]);
730 if(Sh1.IsNull() || Sh2.IsNull()) return 1;
731 if(Sh2.ShapeType() != TopAbs_EDGE) return 1;
733 //QAModTopOpe_ReShaper ReShaper(Sh1);
734 QANewModTopOpe_ReShaper ReShaper(Sh1);
735 ReShaper.Remove(Sh2);
736 const TopoDS_Shape& ResultShape = ReShaper.GetResult();
737 if(ResultShape.IsNull()) {
738 di << "Faulty " << argv[0] << " : " << argv[1] << " - shape_result is null" << "\n";
742 DBRep::Set ( argv[1], ResultShape);
746 static Standard_Integer OCC60 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
748 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
749 if(aContext.IsNull()) {
750 di << "use 'vinit' command before " << argv[0] << "\n";
754 di << "Usage : " << argv[0] << " xmin ymin xmax ymax; selection window" << "\n";
758 Standard_Integer xmin = Draw::Atoi(argv[1]);
759 Standard_Integer ymin = Draw::Atoi(argv[2]);
760 Standard_Integer xmax = Draw::Atoi(argv[3]);
761 Standard_Integer ymax = Draw::Atoi(argv[4]);
763 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
765 Handle(ViewerTest_EventManager) EM = ViewerTest::CurrentEventManager();
766 EM->Select(xmin,ymin,xmax,ymax);
771 static Standard_Integer OCC70 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
773 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
774 if(aContext.IsNull()) {
775 di << "use 'vinit' command before " << argv[0] << "\n";
779 di << "Usage : " << argv[0] << " x1 y1 x2 y2 x3 y3 [x y ...]; polygon of selection" << "\n";
782 if (((argc - 1) % 2) != 0) {
783 di << "Usage : " << argv[0] << " x1 y1 x2 y2 x3 y3 [x y ...]; polygon of selection" << "\n";
787 Standard_Integer i, j, np = (argc-1) / 2;
788 TColgp_Array1OfPnt2d Polyline(1,np);
790 for (i = 1; i <= np; i++) {
791 Polyline(i) = gp_Pnt2d(Draw::Atof(argv[j]), Draw::Atof(argv[j+1]));
795 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
797 aContext->Select(Polyline,V3dView);
798 aContext->UpdateCurrentViewer();
803 static Standard_Integer OCC261 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
806 di << "Usage : " << argv[0] << " Doc" << "\n";
810 Handle(TDocStd_Document) Doc;
811 if(DDocStd::GetDocument(argv[1], Doc)) {
818 #include <OSD_File.hxx>
819 static Standard_Integer OCC710 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
822 di << "Usage : " << argv[0] << " path" << "\n";
825 TCollection_AsciiString in(argv[1]);
826 OSD_File* aFile = new OSD_File(in);
827 Standard_Boolean anExists = aFile->Exists();
828 if(anExists == Standard_True)
835 #include <ShapeFix_Shell.hxx>
836 static Standard_Integer OCC904 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
839 di << "Usage : " << argv[0] << " result shape nonmanifoldmode(0/1)" << "\n";
841 TopoDS_Shape S = DBRep::Get(argv[2]);
842 if (S.IsNull() || S.ShapeType() != TopAbs_SHELL) {
843 di << " Shape is null" << "\n";
846 Standard_Boolean nonmanifmode = (Draw::Atoi(argv[3]) != 0);
847 Handle(ShapeFix_Shell) SFSh = new ShapeFix_Shell;
848 SFSh->FixFaceOrientation(TopoDS::Shell(S),Standard_True,nonmanifmode);
849 DBRep::Set(argv[1],SFSh->Shape());
853 void QABugs::Commands_16(Draw_Interpretor& theCommands) {
854 const char *group = "QABugs";
856 theCommands.Add ("BUC60848", "BUC60848 shape", __FILE__, BUC60848, group);
857 theCommands.Add ("BUC60828", "BUC60828", __FILE__, BUC60828, group);
858 theCommands.Add ("BUC60814", "BUC60814", __FILE__, BUC60814, group);
859 theCommands.Add ("BUC60774", "BUC60774", __FILE__, BUC60774, group);
860 theCommands.Add ("BUC60972", "BUC60972 edge edge plane val text ", __FILE__, BUC60972, group);
861 theCommands.Add ("OCC218", "OCC218 name plane Xlabel Ylabel", __FILE__, OCC218bug, group);
862 theCommands.Add ("OCC295", "OCC295 edge_result edge1 edge2", __FILE__, OCC295, group);
863 theCommands.Add ("OCC49", "OCC49 name", __FILE__, OCC49, group);
864 theCommands.Add ("OCC132", "OCC132 DependentName", __FILE__, OCC132, group);
865 theCommands.Add ("OCC405", "OCC405 edge_result edge1 edge2; merge two edges", __FILE__, OCC405, group);
866 theCommands.Add ("OCC252", "OCC252 result part tool [ModeOfLimitation=0/1/2]", __FILE__, OCC252, group);
867 theCommands.Add ("OCC307", "OCC307 result part tool [AllowCutting=0/1]", __FILE__, OCC307, group);
868 theCommands.Add ("OCC395", "OCC395 edge_result edge1 edge2", __FILE__, OCC395, group);
869 theCommands.Add ("OCC394", "OCC394 edge_result edge [tol [mode [tolang]]]", __FILE__, OCC394, group);
870 theCommands.Add ("OCC301", "OCC301 ArcRadius ArrowSize", __FILE__, OCC301, group);
871 theCommands.Add ("OCC294", "OCC294 shape_result shape edge", __FILE__, OCC294, group);
872 theCommands.Add ("OCC60", "OCC60 xmin ymin xmax ymax; selection window", __FILE__, OCC60, group);
873 theCommands.Add ("OCC70", "OCC70 x1 y1 x2 y2 x3 y3 [x y ...]; polygon of selection", __FILE__, OCC70, group);
874 theCommands.Add ("OCC261", "OCC261 Doc", __FILE__, OCC261, group);
875 theCommands.Add ("OCC710", "OCC710 path", __FILE__, OCC710, group);
876 theCommands.Add ("OCC904", "OCC904 result shape nonmanifoldmode(0/1)", __FILE__, OCC904, group);