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.
24 #include <Draw_Interpretor.hxx>
26 #include <DrawTrSurf.hxx>
27 #include <AIS_InteractiveContext.hxx>
28 #include <ViewerTest.hxx>
29 #include <AIS_Shape.hxx>
30 #include <TopoDS_Shape.hxx>
32 #include <GProp_GProps.hxx>
33 #include <BRepGProp.hxx>
34 #include <TopoDS_Edge.hxx>
35 #include <BRepBuilderAPI_MakeEdge.hxx>
36 #include <AIS_Trihedron.hxx>
37 #include <Geom_Axis2Placement.hxx>
39 #include <Geom_Circle.hxx>
40 #include <AIS_Circle.hxx>
41 #include <V3d_View.hxx>
43 #include <Geom_Plane.hxx>
45 #include <AIS_AngleDimension.hxx>
47 #include <TopExp_Explorer.hxx>
48 #include <BRepAdaptor_Curve.hxx>
49 #include <GC_MakePlane.hxx>
50 #include <AIS_PlaneTrihedron.hxx>
51 #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
53 #include <BRep_Tool.hxx>
54 #include <Geom_BSplineCurve.hxx>
55 #include <GeomConvert_CompCurveToBSplineCurve.hxx>
56 #include <BRepBuilderAPI_MakeEdge.hxx>
57 #include <Precision.hxx>
59 #include <GProp_PrincipalProps.hxx>
61 #include <OSD_Path.hxx>
62 #include <Standard_ProgramError.hxx>
64 //#include <QAModTopOpe_Limitation.hxx>
65 #include <QANewModTopOpe_Limitation.hxx>
67 //#include <QAModTopOpe_Glue.hxx>
68 #include <QANewModTopOpe_Glue.hxx>
70 #include <ShapeFix_Wireframe.hxx>
71 #include <ShapeBuild_ReShape.hxx>
73 #include <ViewerTest_Tool.hxx>
74 #include <BRepBuilderAPI_MakeEdge.hxx>
76 //#include <QAModTopOpe_ReShaper.hxx>
77 #include <QANewModTopOpe_ReShaper.hxx>
79 #include <ViewerTest_EventManager.hxx>
81 #include <TColgp_Array1OfPnt2d.hxx>
83 #include <DDocStd.hxx>
84 #include <TDocStd_Document.hxx>
85 #include <Standard_ErrorHandler.hxx>
88 extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
90 Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
93 static Standard_Integer BUC60848 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
96 di << "Usage : " << argv[0] << " shape " << "\n";
99 TopoDS_Shape S = DBRep::Get( argv[1] );
101 di << "Shape is empty" << "\n";
105 BRepGProp::VolumeProperties( S,G );
109 di << "Result is negative : " << GRes << "\n";
112 di << "Volume : " << GRes << "\n";
118 static Standard_Integer BUC60828 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
120 TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(0.,0.,0.), gp_Pnt(0.,0.,1.));
121 Standard_Boolean aValue;
122 aValue=anEdge.Infinite();
123 di << "Initial flag : " << (Standard_Integer) aValue << "\n";
124 anEdge.Infinite(Standard_True);
125 Standard_Boolean aValue1;
126 aValue1=anEdge.Infinite();
127 di << "Current flag : " << (Standard_Integer) aValue1 << "\n";
128 if(aValue1) di << "Flag was set properly." << "\n";
129 else di << "Faulty : flag was not set properly." << "\n";
133 static Standard_Integer BUC60814(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
137 di << "Usage : " << argv[0] << "\n";
142 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
143 if(myAISContext.IsNull()) {
144 di << "use 'vinit' command before " << argv[0] << "\n";
149 Handle(AIS_Trihedron) aTrihedron;
150 Handle(Geom_Axis2Placement) aTrihedronAxis=new Geom_Axis2Placement(gp::XOY());
151 aTrihedron=new AIS_Trihedron(aTrihedronAxis);
152 myAISContext->Display(aTrihedron);
159 Handle(Geom_Circle) ahCircle=new Geom_Circle(aAx2,20);
160 Handle(AIS_Circle) aCircle=new AIS_Circle(ahCircle);
161 myAISContext->Display(aCircle);
163 myAISContext->SelectionColor(Quantity_NOC_BLUE1);
165 myAISContext->AddOrRemoveSelected(aTrihedron);
166 myAISContext->AddOrRemoveSelected(aCircle);
171 static Standard_Integer BUC60774(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
175 di << "Usage : " << argv[0] << "\n";
179 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
180 if(myAISContext.IsNull())
182 di << "use 'vinit' command before " << argv[0] << "\n";
186 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
188 double Xc,Yc,Width, Height;
189 myV3dView->Center(Xc,Yc);
190 myV3dView-> Size (Width, Height);
199 Standard_Integer XPmin,YPmin;
200 myV3dView->Convert(Xmin,Ymin,XPmin,YPmin);
201 // cout<<Xmin<<"\t"<<Ymin<<endl;
202 // cout<<XPmin<<"\t"<<YPmin<<endl;
204 Standard_Integer XPmax,YPmax;
205 myV3dView->Convert(Xmax,Ymax,XPmax,YPmax);
206 // cout<<Xmax<<"\t"<<Ymax<<endl;
207 // cout<<XPmax<<"\t"<<YPmax<<endl;
209 AIS_StatusOfPick status;
210 if ((status=myAISContext->Select(XPmin,YPmin,XPmax,YPmax,myV3dView))==AIS_SOP_NothingSelected)
211 di << "status = AIS_SOP_NothingSelected : OK" << "\n";
212 else di << "status = AIS_SOP_NothingSelected : bugged - Faulty " << "\n";
214 di.Eval("box b 10 10 10");
215 di.Eval(" vdisplay b");
217 if ((status=myAISContext->Select(XPmin,YPmin,XPmax,YPmax,myV3dView))==AIS_SOP_OneSelected)
218 di << "status = AIS_SOP_OneSelected : OK" << "\n";
219 else di << "status = AIS_SOP_OneSelected : bugged - Faulty " << "\n";
221 di.Eval("box w 20 20 20 20 20 20");
222 di.Eval(" vdisplay w");
224 if ((status=myAISContext->Select(XPmin,YPmin,XPmax,YPmax,myV3dView))==AIS_SOP_SeveralSelected)
225 di << "status = AIS_SOP_SeveralSelected : OK" << "\n";
226 else di << "status = AIS_SOP_SeveralSelected : bugged - Faulty " << "\n";
232 static Standard_Integer BUC60972 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
234 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
235 if(aContext.IsNull()) {
236 di << "use 'vinit' command before " << argv[0] << "\n";
241 di << "Usage : " << argv[0] << " edge edge plane val text" << "\n";
245 TopoDS_Edge aFirst = TopoDS::Edge(DBRep::Get(argv[1],TopAbs_EDGE));
246 TopoDS_Edge aSecond = TopoDS::Edge(DBRep::Get(argv[2],TopAbs_EDGE));
247 Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(DrawTrSurf::GetSurface(argv[3]));
251 di << aPlane->Pln().SquareDistance( gp_Pnt(0,0,0) ) << "\n";
253 TCollection_ExtendedString aText(argv[5]);
254 //Standard_ExtString ExtString_aText = aText.ToExtString();
255 //di << ExtString_aText << " " << atof(argv[4]) << "\n";
256 di << argv[5] << " " << atof(argv[4]) << "\n";
258 Handle(AIS_AngleDimension) aDim = new AIS_AngleDimension(aFirst, aSecond, aPlane, atof(argv[4]), aText);
259 aContext->Display(aDim);
264 static Standard_Integer OCC218bug (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
266 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
267 if(aContext.IsNull()) {
268 di << "use 'vinit' command before " << argv[0] << "\n";
273 di << "Usage : " << argv[0] << " name plane Xlabel Ylabel" << "\n";
277 TopoDS_Shape S = DBRep::Get( argv[2] );
279 di << "Shape is empty" << "\n";
283 TCollection_AsciiString name(argv[1]);
284 TCollection_AsciiString Xlabel(argv[3]);
285 TCollection_AsciiString Ylabel(argv[4]);
287 // Construction de l'AIS_PlaneTrihedron
288 Handle(AIS_PlaneTrihedron) theAISPlaneTri;
290 Standard_Boolean IsBound = GetMapOfAIS().IsBound2(name);
292 // on recupere la shape dans la map des objets displayes
293 Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
295 // On verifie que l'AIS InteraciveObject est bien
296 // un AIS_PlaneTrihedron
297 if (aShape->Type()==AIS_KOI_Datum && aShape->Signature()==4) {
298 // On downcast aShape de AIS_InteractiveObject a AIS_PlaneTrihedron
299 theAISPlaneTri = *(Handle(AIS_PlaneTrihedron)*) &aShape;
301 theAISPlaneTri->SetXLabel(Xlabel);
302 theAISPlaneTri->SetYLabel(Ylabel);
304 aContext->Redisplay(theAISPlaneTri, Standard_False);
305 aContext->UpdateCurrentViewer();
308 TopoDS_Face FaceB=TopoDS::Face(S);
310 // Construction du Plane
311 // recuperation des edges des faces.
312 TopExp_Explorer FaceExpB(FaceB,TopAbs_EDGE);
314 TopoDS_Edge EdgeB=TopoDS::Edge(FaceExpB.Current() );
318 // si il y a plusieurs edges
319 if (FaceExpB.More() ) {
321 TopoDS_Edge EdgeC=TopoDS::Edge(FaceExpB.Current() );
322 BRepAdaptor_Curve theCurveB(EdgeB);
323 BRepAdaptor_Curve theCurveC(EdgeC);
324 A=theCurveC.Value(0.1);
325 B=theCurveC.Value(0.9);
326 C=theCurveB.Value(0.5);
329 // FaceB a 1 unique edge courbe
330 BRepAdaptor_Curve theCurveB(EdgeB);
331 A=theCurveB.Value(0.1);
332 B=theCurveB.Value(0.9);
333 C=theCurveB.Value(0.5);
335 // Construction du Geom_Plane
336 GC_MakePlane MkPlane(A,B,C);
337 Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
339 // on le display & bind
340 theAISPlaneTri= new AIS_PlaneTrihedron(theGeomPlane );
342 theAISPlaneTri->SetXLabel(Xlabel);
343 theAISPlaneTri->SetYLabel(Ylabel);
345 GetMapOfAIS().Bind ( theAISPlaneTri, name);
346 aContext->Display(theAISPlaneTri );
351 static Standard_Integer OCC295(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
354 di << "Usage : " << argv[0] << " edge_result edge1 edge2" << "\n";
358 TopoDS_Shape Sh1 = DBRep::Get(argv[2]);
359 TopoDS_Shape Sh2 = DBRep::Get(argv[3]);
360 if(Sh1.IsNull() || Sh2.IsNull()) return 1;
361 if(Sh1.ShapeType() != TopAbs_EDGE || Sh2.ShapeType() != TopAbs_EDGE) return 1;
362 TopoDS_Edge e1 = TopoDS::Edge(Sh1);
363 TopoDS_Edge e2 = TopoDS::Edge(Sh2);
364 Standard_Real f1,l1,f2,l2;
365 Standard_Boolean After = Standard_True;
366 Handle(Geom_Curve) ac1 = BRep_Tool::Curve(e1,f1,l1);
367 Handle(Geom_Curve) ac2 = BRep_Tool::Curve(e2,f2,l2);
368 Handle(Geom_BSplineCurve) bsplc1 = Handle(Geom_BSplineCurve)::DownCast(ac1);
369 Handle(Geom_BSplineCurve) bsplc2 = Handle(Geom_BSplineCurve)::DownCast(ac2);
370 if(bsplc1.IsNull() || bsplc2.IsNull()) return 1;
371 gp_Pnt pmid = 0.5 * ( bsplc1->Pole(bsplc1->NbPoles()).XYZ() + bsplc2->Pole(1).XYZ() );
372 bsplc1->SetPole(bsplc1->NbPoles(), pmid);
373 bsplc2->SetPole(1, pmid);
374 GeomConvert_CompCurveToBSplineCurve connect3d(bsplc1);
375 if(!connect3d.Add(bsplc2,Precision::Confusion(), After, Standard_False)) return 1;
376 BRepBuilderAPI_MakeEdge MkEdge(connect3d.BSplineCurve());
377 if(MkEdge.IsDone()) {
378 TopoDS_Edge nedge = MkEdge.Edge();
379 DBRep::Set ( argv[1], nedge );
385 static Standard_Integer OCC49 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
389 di << "Usage : " << argv[0] << " name" << "\n";
393 TopoDS_Shape S = DBRep::Get(argv[1]);
394 if (S.IsNull()) return 0;
397 BRepGProp::VolumeProperties(S,G);
398 GProp_PrincipalProps Pr = G.PrincipalProperties();
399 Standard_Boolean Result = Pr.HasSymmetryAxis();
408 static Standard_Integer OCC132 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
414 ... the validation of the name of files in Analyse_DOS and Analyse_UNIX is :
416 characters not allowed in DOS/WNT names are
425 and more than one dot in filename.
429 di << "Usage : " << argv[0] << " DependentName" << "\n";
433 OSD_SysType SysType1 = OSD_OS2;
434 OSD_SysType SysType2 = OSD_WindowsNT;
439 OSD_Path Path (argv[1], SysType1);
441 catch (Standard_ProgramError) {
450 OSD_Path Path (argv[1], SysType2);
452 catch (Standard_ProgramError) {
462 static Standard_Integer OCC405 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
465 di << "Usage : " << argv[0] << " edge_result edge1 edge2; merge two edges" << "\n";
469 TopoDS_Shape Sh1 = DBRep::Get(argv[2]);
470 TopoDS_Shape Sh2 = DBRep::Get(argv[3]);
471 if(Sh1.IsNull() || Sh2.IsNull()) return 1;
472 if(Sh1.ShapeType() != TopAbs_EDGE || Sh2.ShapeType() != TopAbs_EDGE) return 1;
473 TopoDS_Edge e1 = TopoDS::Edge(Sh1);
474 TopoDS_Edge e2 = TopoDS::Edge(Sh2);
475 Standard_Real f1,l1,f2,l2;
476 Standard_Boolean After = Standard_True;
477 Handle(Geom_Curve) ac1 = BRep_Tool::Curve(e1,f1,l1);
478 Handle(Geom_Curve) ac2 = BRep_Tool::Curve(e2,f2,l2);
479 if(e1.Orientation() == TopAbs_REVERSED) {
480 Standard_Real cf = f1;
481 f1 = ac1->ReversedParameter ( l1 );
482 l1 = ac1->ReversedParameter ( cf );
483 ac1 = ac1->Reversed();
485 if(e2.Orientation() == TopAbs_REVERSED) {
486 Standard_Real cf = f2;
487 f2 = ac2->ReversedParameter ( l2 );
488 l2 = ac2->ReversedParameter ( cf );
489 ac2 = ac2->Reversed();
491 Handle(Geom_BSplineCurve) bsplc1 = Handle(Geom_BSplineCurve)::DownCast(ac1);
492 Handle(Geom_BSplineCurve) bsplc2 = Handle(Geom_BSplineCurve)::DownCast(ac2);
493 if(bsplc1.IsNull() || bsplc2.IsNull()) return 1;
494 if(bsplc1->FirstParameter() < f1 - Precision::PConfusion() ||
495 bsplc1->LastParameter() > l1 + Precision::PConfusion()) {
496 Handle(Geom_BSplineCurve) aBstmp = Handle(Geom_BSplineCurve)::DownCast(bsplc1->Copy());
497 aBstmp->Segment(f1,l1);
498 gp_Pnt p1 = aBstmp->Pole(1);
499 gp_Pnt p2 = aBstmp->Pole(aBstmp->NbPoles());
502 if(bsplc2->FirstParameter() < f2 - Precision::PConfusion() ||
503 bsplc2->LastParameter() > l2 + Precision::PConfusion()) {
504 Handle(Geom_BSplineCurve) aBstmp = Handle(Geom_BSplineCurve)::DownCast(bsplc2->Copy());
505 aBstmp->Segment(f2,l2);
506 gp_Pnt p1 = aBstmp->Pole(1);
507 gp_Pnt p2 = aBstmp->Pole(aBstmp->NbPoles());
510 gp_Pnt pmid = 0.5 * ( bsplc1->Pole(bsplc1->NbPoles()).XYZ() + bsplc2->Pole(1).XYZ() );
511 bsplc1->SetPole(bsplc1->NbPoles(), pmid);
512 bsplc2->SetPole(1, pmid);
513 GeomConvert_CompCurveToBSplineCurve connect3d(bsplc1);
514 if(!connect3d.Add(bsplc2,Precision::Confusion(), After, Standard_False)) return 1;
515 BRepBuilderAPI_MakeEdge MkEdge(connect3d.BSplineCurve());
516 if(MkEdge.IsDone()) {
517 TopoDS_Edge nedge = MkEdge.Edge();
518 DBRep::Set ( argv[1], nedge );
524 static Standard_Integer OCC252 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
526 if(!(argc == 4 || argc == 5)) {
527 di << "Usage : " << argv[0] << " result part tool [ModeOfLimitation=0/1/2]" << "\n";
531 TopoDS_Shape s1 = DBRep::Get(argv[2]);
532 TopoDS_Shape s2 = DBRep::Get(argv[3]);
533 if (s1.IsNull() || s2.IsNull()) return 1;
535 //QAModTopOpe_ModeOfLimitation ModeOfLimitation = QAModTopOpe_Forward;
536 QANewModTopOpe_ModeOfLimitation ModeOfLimitation = QANewModTopOpe_Forward;
538 Standard_Integer ModeOfLimitationInteger = atoi(argv[4]);
539 if(!(ModeOfLimitationInteger == 0 || ModeOfLimitationInteger == 1 || ModeOfLimitationInteger == 2)) {
540 di << "Usage : " << argv[0] << " result part tool [ModeOfLimitation=0/1/2]" << "\n";
543 //if (ModeOfLimitationInteger == 1) ModeOfLimitation = QAModTopOpe_Reversed;
544 //if (ModeOfLimitationInteger == 2) ModeOfLimitation = QAModTopOpe_BothParts;
545 if (ModeOfLimitationInteger == 1) ModeOfLimitation = QANewModTopOpe_Reversed;
546 if (ModeOfLimitationInteger == 2) ModeOfLimitation = QANewModTopOpe_BothParts;
549 //TopoDS_Shape res = QAModTopOpe_Limitation(s1,s2,ModeOfLimitation);
550 TopoDS_Shape res = QANewModTopOpe_Limitation(s1,s2,ModeOfLimitation);
552 di << "Error : result is null" << "\n";
556 DBRep::Set(argv[1],res);
561 static Standard_Integer OCC307 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
563 if(!(argc == 4 || argc == 5)) {
564 di << "Usage : " << argv[0] << " result part tool [AllowCutting=0/1]" << "\n";
568 TopoDS_Shape s1 = DBRep::Get(argv[2]);
569 TopoDS_Shape s2 = DBRep::Get(argv[3]);
570 if (s1.IsNull() || s2.IsNull()) return 1;
572 Standard_Boolean AllowCutting = Standard_False;
574 Standard_Integer AllowCuttingInteger = atoi(argv[4]);
575 if(!( AllowCuttingInteger == 0 || AllowCuttingInteger == 1)) {
576 di << "Usage : " << argv[0] << " result part tool [AllowCutting=0/1]" << "\n";
579 if (AllowCuttingInteger == 1) AllowCutting = Standard_True;
582 //TopoDS_Shape res = QAModTopOpe_Glue(s1,s2,AllowCutting);
583 TopoDS_Shape res = QANewModTopOpe_Glue(s1,s2,AllowCutting);
585 di << "Error : result is null" << "\n";
589 DBRep::Set(argv[1],res);
594 static Standard_Integer OCC395 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
597 di << "Usage : " << argv[0] << " edge_result edge1 edge2" << "\n";
600 //TCollection_AsciiString fnom(a[1]);
601 //Standard_Boolean modfic = XSDRAW::FileAndVar(a[1],a[2],a[3],"IGES",fnom,rnom,resnom);
602 TopoDS_Shape Sh1 = DBRep::Get(argv[2]);
603 TopoDS_Shape Sh2 = DBRep::Get(argv[3]);
604 if(Sh1.IsNull() || Sh2.IsNull()) return 1;
605 if(Sh1.ShapeType() != TopAbs_EDGE || Sh2.ShapeType() != TopAbs_EDGE) return 1;
606 TopoDS_Edge e1 = TopoDS::Edge(Sh1);
607 TopoDS_Edge e2 = TopoDS::Edge(Sh2);
608 Standard_Real f1,l1,f2,l2;
609 Standard_Boolean After = Standard_True;
610 Handle(Geom_Curve) ac1 = BRep_Tool::Curve(e1,f1,l1);
611 Handle(Geom_Curve) ac2 = BRep_Tool::Curve(e2,f2,l2);
612 if(e1.Orientation() == TopAbs_REVERSED) {
613 //Standard_Real cf = cf1;
614 //cf1 = ac1->ReversedParameter ( cl1 );
615 //cl1 = ac1->ReversedParameter ( cf );
616 ac1 = ac1->Reversed();
618 if(e2.Orientation() == TopAbs_REVERSED) {
619 //Standard_Real cf = cf2;
620 //ac2 = ac2->ReversedParameter ( cl2 );
621 //ac2 = ac2->ReversedParameter ( cf );
622 ac2 = ac2->Reversed();
624 Handle(Geom_BSplineCurve) bsplc1 = Handle(Geom_BSplineCurve)::DownCast(ac1);
625 Handle(Geom_BSplineCurve) bsplc2 = Handle(Geom_BSplineCurve)::DownCast(ac2);
626 if(bsplc1.IsNull() || bsplc2.IsNull()) return 1;
627 gp_Pnt pmid = 0.5 * ( bsplc1->Pole(bsplc1->NbPoles()).XYZ() + bsplc2->Pole(1).XYZ() );
628 bsplc1->SetPole(bsplc1->NbPoles(), pmid);
629 bsplc2->SetPole(1, pmid);
630 GeomConvert_CompCurveToBSplineCurve connect3d(bsplc1);
631 if(!connect3d.Add(bsplc2,Precision::Confusion(), After, Standard_False)) return 1;
632 BRepBuilderAPI_MakeEdge MkEdge(connect3d.BSplineCurve());
633 if(MkEdge.IsDone()) {
634 TopoDS_Edge nedge = MkEdge.Edge();
635 DBRep::Set ( argv[1], nedge );
641 static Standard_Integer OCC394 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
644 di << "Usage : " << argv[0] << " edge_result edge [tol [mode [tolang]]]" << "\n";
647 TopoDS_Shape Sh = DBRep::Get(argv[2]);
649 Standard_Integer k = 3;
650 Standard_Real tol = 100000;
651 Standard_Integer mode = 2;
652 Standard_Real tolang = M_PI/2;
654 tol = atof(argv[k++]);
657 mode= atoi(argv[k++]);
660 tolang = atof(argv[k++]);
663 Handle(ShapeFix_Wireframe) aSfwr = new ShapeFix_Wireframe();
664 Handle(ShapeBuild_ReShape) aReShape = new ShapeBuild_ReShape;
665 aSfwr->SetContext(aReShape);
667 aSfwr->SetPrecision(tol);
668 Standard_Boolean aModeDrop = Standard_True;
670 aModeDrop = Standard_False;
672 TopTools_MapOfShape theSmallEdges, theMultyEdges;
673 TopTools_DataMapOfShapeListOfShape theEdgeToFaces,theFaceWithSmall;
674 aSfwr->CheckSmallEdges(theSmallEdges,theEdgeToFaces,theFaceWithSmall, theMultyEdges);
675 aSfwr->MergeSmallEdges (theSmallEdges,theEdgeToFaces,theFaceWithSmall, theMultyEdges, aModeDrop,tolang);
676 //aSfwr->FixSmallEdges();
677 TopoDS_Shape resShape = aSfwr->Shape();;
678 DBRep::Set ( argv[1], resShape );
682 static Standard_Integer OCC301 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
684 //Handle(AIS_InteractiveContext) context= ViewerTest_Tool::MakeContext ("OCC301");
685 //ViewerTest_Tool::InitViewerTest (context);
686 Handle(AIS_InteractiveContext) context = ViewerTest::GetAISContext();
687 if(context.IsNull()) {
688 di << "use 'vinit' command before " << argv[0] << "\n";
692 di << "Usage : " << argv[0] << " X Y Z ArrowSize" << "\n";
696 Standard_Real X = atof(argv[1]);
697 Standard_Real Y = atof(argv[2]);
698 Standard_Real Z = atof(argv[3]);
699 Standard_Real ArrowSize = atof(argv[4]);
701 gp_Pnt p1 = gp_Pnt(10.,10.,0.);
702 gp_Pnt p2 = gp_Pnt(50.,10.,0.);
703 gp_Pnt p3 = gp_Pnt(50.,50.,0.);
705 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(p1, p2);
706 TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(p2, p3);
708 context->Display(new AIS_Shape(E1));
709 context->Display(new AIS_Shape(E2));
711 gp_Pnt plnpt(0, 0, 0);
712 gp_Dir plndir(0, 0, 1);
713 Handle(Geom_Plane) pln = new Geom_Plane(plnpt,plndir);
715 Handle(AIS_AngleDimension) AngleDimension = new AIS_AngleDimension(E2, E1, pln, -3.14/2., "Angle");
717 AngleDimension->SetPosition(gp_Pnt(X, Y, Z));
718 AngleDimension->SetArrowSize(ArrowSize);
720 context->Display(AngleDimension);
724 static Standard_Integer OCC294 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
727 di << "Usage : " << argv[0] << " shape_result shape edge" << "\n";
730 TopoDS_Shape Sh1 = DBRep::Get(argv[2]);
731 TopoDS_Shape Sh2 = DBRep::Get(argv[3]);
732 if(Sh1.IsNull() || Sh2.IsNull()) return 1;
733 if(Sh2.ShapeType() != TopAbs_EDGE) return 1;
735 //QAModTopOpe_ReShaper ReShaper(Sh1);
736 QANewModTopOpe_ReShaper ReShaper(Sh1);
737 ReShaper.Remove(Sh2);
738 const TopoDS_Shape& ResultShape = ReShaper.GetResult();
739 if(ResultShape.IsNull()) {
740 di << "Faulty " << argv[0] << " : " << argv[1] << " - shape_result is null" << "\n";
744 DBRep::Set ( argv[1], ResultShape);
748 static Standard_Integer OCC60 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
750 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
751 if(aContext.IsNull()) {
752 di << "use 'vinit' command before " << argv[0] << "\n";
756 di << "Usage : " << argv[0] << " xmin ymin xmax ymax; selection window" << "\n";
760 Standard_Integer xmin = atoi(argv[1]);
761 Standard_Integer ymin = atoi(argv[2]);
762 Standard_Integer xmax = atoi(argv[3]);
763 Standard_Integer ymax = atoi(argv[4]);
765 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
767 Handle(ViewerTest_EventManager) EM = ViewerTest::CurrentEventManager();
768 EM->Select(xmin,ymin,xmax,ymax);
773 static Standard_Integer OCC70 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
775 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
776 if(aContext.IsNull()) {
777 di << "use 'vinit' command before " << argv[0] << "\n";
781 di << "Usage : " << argv[0] << " x1 y1 x2 y2 x3 y3 [x y ...]; polygon of selection" << "\n";
784 if (((argc - 1) % 2) != 0) {
785 di << "Usage : " << argv[0] << " x1 y1 x2 y2 x3 y3 [x y ...]; polygon of selection" << "\n";
789 Standard_Integer i, j, np = (argc-1) / 2;
790 TColgp_Array1OfPnt2d Polyline(1,np);
792 for (i = 1; i <= np; i++) {
793 Polyline(i) = gp_Pnt2d(atof(argv[j]), atof(argv[j+1]));
797 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
799 aContext->Select(Polyline,V3dView);
800 aContext->UpdateCurrentViewer();
805 static Standard_Integer OCC261 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
808 di << "Usage : " << argv[0] << " Doc" << "\n";
812 Handle(TDocStd_Document) Doc;
813 if(DDocStd::GetDocument(argv[1], Doc)) {
820 #include <OSD_File.hxx>
821 static Standard_Integer OCC710 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
824 di << "Usage : " << argv[0] << " path" << "\n";
827 TCollection_AsciiString in(argv[1]);
828 OSD_File* aFile = new OSD_File(in);
829 Standard_Boolean anExists = aFile->Exists();
830 if(anExists == Standard_True)
837 #include <ShapeFix_Shell.hxx>
838 static Standard_Integer OCC904 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
841 di << "Usage : " << argv[0] << " result shape nonmanifoldmode(0/1)" << "\n";
843 TopoDS_Shape S = DBRep::Get(argv[2]);
844 if (S.IsNull() || S.ShapeType() != TopAbs_SHELL) {
845 di << " Shape is null" << "\n";
848 Standard_Boolean nonmanifmode = (atoi(argv[3]) != 0);
849 Handle(ShapeFix_Shell) SFSh = new ShapeFix_Shell;
850 SFSh->FixFaceOrientation(TopoDS::Shell(S),Standard_True,nonmanifmode);
851 DBRep::Set(argv[1],SFSh->Shape());
855 void QABugs::Commands_16(Draw_Interpretor& theCommands) {
856 const char *group = "QABugs";
858 theCommands.Add ("BUC60848", "BUC60848 shape", __FILE__, BUC60848, group);
859 theCommands.Add ("BUC60828", "BUC60828", __FILE__, BUC60828, group);
860 theCommands.Add ("BUC60814", "BUC60814", __FILE__, BUC60814, group);
861 theCommands.Add ("BUC60774", "BUC60774", __FILE__, BUC60774, group);
862 theCommands.Add ("BUC60972", "BUC60972 edge edge plane val text ", __FILE__, BUC60972, group);
863 theCommands.Add ("OCC218", "OCC218 name plane Xlabel Ylabel", __FILE__, OCC218bug, group);
864 theCommands.Add ("OCC295", "OCC295 edge_result edge1 edge2", __FILE__, OCC295, group);
865 theCommands.Add ("OCC49", "OCC49 name", __FILE__, OCC49, group);
866 theCommands.Add ("OCC132", "OCC132 DependentName", __FILE__, OCC132, group);
867 theCommands.Add ("OCC405", "OCC405 edge_result edge1 edge2; merge two edges", __FILE__, OCC405, group);
868 theCommands.Add ("OCC252", "OCC252 result part tool [ModeOfLimitation=0/1/2]", __FILE__, OCC252, group);
869 theCommands.Add ("OCC307", "OCC307 result part tool [AllowCutting=0/1]", __FILE__, OCC307, group);
870 theCommands.Add ("OCC395", "OCC395 edge_result edge1 edge2", __FILE__, OCC395, group);
871 theCommands.Add ("OCC394", "OCC394 edge_result edge [tol [mode [tolang]]]", __FILE__, OCC394, group);
872 theCommands.Add ("OCC301", "OCC301 X Y Z ArrowSize", __FILE__, OCC301, group);
873 theCommands.Add ("OCC294", "OCC294 shape_result shape edge", __FILE__, OCC294, group);
874 theCommands.Add ("OCC60", "OCC60 xmin ymin xmax ymax; selection window", __FILE__, OCC60, group);
875 theCommands.Add ("OCC70", "OCC70 x1 y1 x2 y2 x3 y3 [x y ...]; polygon of selection", __FILE__, OCC70, group);
876 theCommands.Add ("OCC261", "OCC261 Doc", __FILE__, OCC261, group);
877 theCommands.Add ("OCC710", "OCC710 path", __FILE__, OCC710, group);
878 theCommands.Add ("OCC904", "OCC904 result shape nonmanifoldmode(0/1)", __FILE__, OCC904, group);