0024326: Get rid of confusing extension line
[occt.git] / src / QABugs / QABugs_16.cxx
CommitLineData
b311480e 1// Created on: 2002-03-18
2// Created by: QA Admin
3// Copyright (c) 2002-2012 OPEN CASCADE SAS
4//
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.
9//
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.
12//
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.
19
1cd84fee 20#include <QABugs.hxx>
7fd59977 21
91322f44 22#include <Draw.hxx>
7fd59977 23#include <Draw_Interpretor.hxx>
24#include <DBRep.hxx>
25#include <DrawTrSurf.hxx>
26#include <AIS_InteractiveContext.hxx>
27#include <ViewerTest.hxx>
28#include <AIS_Shape.hxx>
29#include <TopoDS_Shape.hxx>
30
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>
37#include <gp_Ax2.hxx>
38#include <Geom_Circle.hxx>
39#include <AIS_Circle.hxx>
40#include <V3d_View.hxx>
41#include <TopoDS.hxx>
42#include <Geom_Plane.hxx>
43#include <gp_Pln.hxx>
44#include <AIS_AngleDimension.hxx>
45
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>
51
52#include <BRep_Tool.hxx>
53#include <Geom_BSplineCurve.hxx>
54#include <GeomConvert_CompCurveToBSplineCurve.hxx>
55#include <BRepBuilderAPI_MakeEdge.hxx>
56#include <Precision.hxx>
57
58#include <GProp_PrincipalProps.hxx>
59
60#include <OSD_Path.hxx>
61#include <Standard_ProgramError.hxx>
62
63//#include <QAModTopOpe_Limitation.hxx>
64#include <QANewModTopOpe_Limitation.hxx>
65
66//#include <QAModTopOpe_Glue.hxx>
67#include <QANewModTopOpe_Glue.hxx>
68
69#include <ShapeFix_Wireframe.hxx>
70#include <ShapeBuild_ReShape.hxx>
71
72#include <ViewerTest_Tool.hxx>
73#include <BRepBuilderAPI_MakeEdge.hxx>
74
75//#include <QAModTopOpe_ReShaper.hxx>
76#include <QANewModTopOpe_ReShaper.hxx>
77
78#include <ViewerTest_EventManager.hxx>
79
80#include <TColgp_Array1OfPnt2d.hxx>
81
82#include <DDocStd.hxx>
83#include <TDocStd_Document.hxx>
84#include <Standard_ErrorHandler.hxx>
85
86#if ! defined(WNT)
87extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
88#else
89Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
90#endif
91
92static Standard_Integer BUC60848 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
93{
94 if ( argc != 2 ) {
95 di << "Usage : " << argv[0] << " shape " << "\n";
96 return 1;
97 }
98 TopoDS_Shape S = DBRep::Get( argv[1] );
99 if ( S.IsNull() ) {
100 di << "Shape is empty" << "\n";
101 return 1;
102 }
103 GProp_GProps G;
104 BRepGProp::VolumeProperties( S,G );
105 Standard_Real GRes;
106 GRes = G.Mass();
107 if ( GRes < 0 ) {
108 di << "Result is negative : " << GRes << "\n";
109 return 1;
110 } else {
111 di << "Volume : " << GRes << "\n";
112 }
113
114 return 0;
115}
116
117static Standard_Integer BUC60828 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
118{
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";
129 return 0;
130}
131
132static Standard_Integer BUC60814(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
133{
134 if(argc!=1)
135 {
136 di << "Usage : " << argv[0] << "\n";
137 return 1;
138 }
139
140
141 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
142 if(myAISContext.IsNull()) {
143 di << "use 'vinit' command before " << argv[0] << "\n";
144 return 1;
145 }
146
147 // TRIHEDRON
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);
152
153 //Circle
154 gp_Pnt P(10,10,10);
155 gp_Dir V(1,0,0);
156 gp_Ax2 aAx2(P,V);
157
158 Handle(Geom_Circle) ahCircle=new Geom_Circle(aAx2,20);
159 Handle(AIS_Circle) aCircle=new AIS_Circle(ahCircle);
160 myAISContext->Display(aCircle);
161
162 myAISContext->SelectionColor(Quantity_NOC_BLUE1);
163
164 myAISContext->AddOrRemoveSelected(aTrihedron);
165 myAISContext->AddOrRemoveSelected(aCircle);
166
167 return 0;
168}
169
170static Standard_Integer BUC60774(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
171{
172 if(argc!=1)
173 {
174 di << "Usage : " << argv[0] << "\n";
175 return -1;
176 }
177
178 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
179 if(myAISContext.IsNull())
180 {
181 di << "use 'vinit' command before " << argv[0] << "\n";
182 return -1;
183 }
184
185 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
186
187 double Xc,Yc,Width, Height;
188 myV3dView->Center(Xc,Yc);
189 myV3dView-> Size (Width, Height);
190
191 double Xmin,Ymin;
192 Xmin=Xc-Width/2;
193 Ymin=Yc-Height/2;
194 double Xmax,Ymax;
195 Xmax=Xc+Width/2;
196 Ymax=Yc+Height/2;
197
198 Standard_Integer XPmin,YPmin;
199 myV3dView->Convert(Xmin,Ymin,XPmin,YPmin);
200// cout<<Xmin<<"\t"<<Ymin<<endl;
201// cout<<XPmin<<"\t"<<YPmin<<endl;
202
203 Standard_Integer XPmax,YPmax;
204 myV3dView->Convert(Xmax,Ymax,XPmax,YPmax);
205// cout<<Xmax<<"\t"<<Ymax<<endl;
206// cout<<XPmax<<"\t"<<YPmax<<endl;
207
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";
212
213 di.Eval("box b 10 10 10");
214 di.Eval(" vdisplay b");
215
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";
219
220 di.Eval("box w 20 20 20 20 20 20");
221 di.Eval(" vdisplay w");
222
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";
226
227 return 0;
228
229}
230
231static Standard_Integer BUC60972 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
232{
233 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
234 if(aContext.IsNull()) {
235 di << "use 'vinit' command before " << argv[0] << "\n";
236 return 1;
237 }
238
239 if(argc != 6) {
240 di << "Usage : " << argv[0] << " edge edge plane val text" << "\n";
241 return 1;
242 }
243
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]));
247 if(aPlane.IsNull())
248 return 1;
249
250 di << aPlane->Pln().SquareDistance( gp_Pnt(0,0,0) ) << "\n";
251
252 TCollection_ExtendedString aText(argv[5]);
253 //Standard_ExtString ExtString_aText = aText.ToExtString();
91322f44 254 //di << ExtString_aText << " " << Draw::Atof(argv[4]) << "\n";
255 di << argv[5] << " " << Draw::Atof(argv[4]) << "\n";
7fd59977 256
a6eb515f 257 Handle(AIS_AngleDimension) aDim = new AIS_AngleDimension(aFirst, aSecond, aPlane->Pln());
7fd59977 258 aContext->Display(aDim);
259
260 return 0;
261}
262
263static Standard_Integer OCC218bug (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
264{
265 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
266 if(aContext.IsNull()) {
267 di << "use 'vinit' command before " << argv[0] << "\n";
268 return 1;
269 }
270
271 if(argc != 5) {
272 di << "Usage : " << argv[0] << " name plane Xlabel Ylabel" << "\n";
273 return 1;
274 }
275
276 TopoDS_Shape S = DBRep::Get( argv[2] );
277 if ( S.IsNull() ) {
278 di << "Shape is empty" << "\n";
279 return 1;
280 }
281
282 TCollection_AsciiString name(argv[1]);
283 TCollection_AsciiString Xlabel(argv[3]);
284 TCollection_AsciiString Ylabel(argv[4]);
285
286 // Construction de l'AIS_PlaneTrihedron
287 Handle(AIS_PlaneTrihedron) theAISPlaneTri;
288
289 Standard_Boolean IsBound = GetMapOfAIS().IsBound2(name);
290 if (IsBound) {
291 // on recupere la shape dans la map des objets displayes
292 Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
293
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;
299
300 theAISPlaneTri->SetXLabel(Xlabel);
301 theAISPlaneTri->SetYLabel(Ylabel);
302
303 aContext->Redisplay(theAISPlaneTri, Standard_False);
304 aContext->UpdateCurrentViewer();
305 }
306 } else {
307 TopoDS_Face FaceB=TopoDS::Face(S);
308
309 // Construction du Plane
310 // recuperation des edges des faces.
311 TopExp_Explorer FaceExpB(FaceB,TopAbs_EDGE);
312
313 TopoDS_Edge EdgeB=TopoDS::Edge(FaceExpB.Current() );
314 // declarations
315 gp_Pnt A,B,C;
316
317 // si il y a plusieurs edges
318 if (FaceExpB.More() ) {
319 FaceExpB.Next();
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);
326 }
327 else {
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);
333 }
334 // Construction du Geom_Plane
335 GC_MakePlane MkPlane(A,B,C);
336 Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
337
338 // on le display & bind
339 theAISPlaneTri= new AIS_PlaneTrihedron(theGeomPlane );
340
341 theAISPlaneTri->SetXLabel(Xlabel);
342 theAISPlaneTri->SetYLabel(Ylabel);
343
344 GetMapOfAIS().Bind ( theAISPlaneTri, name);
345 aContext->Display(theAISPlaneTri );
346 }
347 return 0;
348}
349
350static Standard_Integer OCC295(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
351{
352 if(argc != 4) {
353 di << "Usage : " << argv[0] << " edge_result edge1 edge2" << "\n";
354 return 1;
355 }
356
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 );
379 return 0;
380 }
381 else return 1;
382}
383
384static Standard_Integer OCC49 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
385{
386
387 if ( argc != 2 ) {
388 di << "Usage : " << argv[0] << " name" << "\n";
389 return 1;
390 }
391
392 TopoDS_Shape S = DBRep::Get(argv[1]);
393 if (S.IsNull()) return 0;
394
395 GProp_GProps G;
396 BRepGProp::VolumeProperties(S,G);
397 GProp_PrincipalProps Pr = G.PrincipalProperties();
398 Standard_Boolean Result = Pr.HasSymmetryAxis();
399 if (Result) {
400 di << "1" << "\n";
401 } else {
402 di << "0" << "\n";
403 }
404 return 0;
405}
406
407static Standard_Integer OCC132 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
408{
409 /*
410 OCC132:
411 =======
412
413 ... the validation of the name of files in Analyse_DOS and Analyse_UNIX is :
414
415 characters not allowed in DOS/WNT names are
416 /
417 :
418 *
419 ?
420 "
421 <
422 >
423 |
424 and more than one dot in filename.
425 */
426
427 if ( argc != 2 ) {
428 di << "Usage : " << argv[0] << " DependentName" << "\n";
429 return 1;
430 }
431
432 OSD_SysType SysType1 = OSD_OS2;
433 OSD_SysType SysType2 = OSD_WindowsNT;
434
435 {
436 try {
437 OCC_CATCH_SIGNALS
438 OSD_Path Path (argv[1], SysType1);
439 }
440 catch (Standard_ProgramError) {
441 di << "1" << "\n";
442 return 0;
443 }
444 }
445
446 {
447 try {
448 OCC_CATCH_SIGNALS
449 OSD_Path Path (argv[1], SysType2);
450 }
451 catch (Standard_ProgramError) {
452 di << "2" << "\n";
453 return 0;
454 }
455 }
456
457 di << "0" << "\n";
458 return 0;
459}
460
461static Standard_Integer OCC405 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
462{
463 if(argc != 4) {
464 di << "Usage : " << argv[0] << " edge_result edge1 edge2; merge two edges" << "\n";
465 return 1;
466 }
467
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();
483 }
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();
489 }
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);
7fd59977 497 bsplc1 =aBstmp;
498 }
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);
7fd59977 503 bsplc2 =aBstmp;
504 }
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 );
514 return 0;
515 }
516 else return 1;
517}
518
519static Standard_Integer OCC252 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
520{
521 if(!(argc == 4 || argc == 5)) {
522 di << "Usage : " << argv[0] << " result part tool [ModeOfLimitation=0/1/2]" << "\n";
523 return 1;
524 }
525
526 TopoDS_Shape s1 = DBRep::Get(argv[2]);
527 TopoDS_Shape s2 = DBRep::Get(argv[3]);
528 if (s1.IsNull() || s2.IsNull()) return 1;
529
530 //QAModTopOpe_ModeOfLimitation ModeOfLimitation = QAModTopOpe_Forward;
531 QANewModTopOpe_ModeOfLimitation ModeOfLimitation = QANewModTopOpe_Forward;
532 if(argc==5) {
91322f44 533 Standard_Integer ModeOfLimitationInteger = Draw::Atoi(argv[4]);
7fd59977 534 if(!(ModeOfLimitationInteger == 0 || ModeOfLimitationInteger == 1 || ModeOfLimitationInteger == 2)) {
535 di << "Usage : " << argv[0] << " result part tool [ModeOfLimitation=0/1/2]" << "\n";
536 return 1;
537 }
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;
542 }
543
544 //TopoDS_Shape res = QAModTopOpe_Limitation(s1,s2,ModeOfLimitation);
545 TopoDS_Shape res = QANewModTopOpe_Limitation(s1,s2,ModeOfLimitation);
546 if (res.IsNull()) {
547 di << "Error : result is null" << "\n";
548 return 1;
549 }
550
551 DBRep::Set(argv[1],res);
552
553 return 0;
554}
555
556static Standard_Integer OCC307 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
557{
558 if(!(argc == 4 || argc == 5)) {
559 di << "Usage : " << argv[0] << " result part tool [AllowCutting=0/1]" << "\n";
560 return 1;
561 }
562
563 TopoDS_Shape s1 = DBRep::Get(argv[2]);
564 TopoDS_Shape s2 = DBRep::Get(argv[3]);
565 if (s1.IsNull() || s2.IsNull()) return 1;
566
567 Standard_Boolean AllowCutting = Standard_False;
568 if(argc==5) {
91322f44 569 Standard_Integer AllowCuttingInteger = Draw::Atoi(argv[4]);
7fd59977 570 if(!( AllowCuttingInteger == 0 || AllowCuttingInteger == 1)) {
571 di << "Usage : " << argv[0] << " result part tool [AllowCutting=0/1]" << "\n";
572 return 1;
573 }
574 if (AllowCuttingInteger == 1) AllowCutting = Standard_True;
575 }
576
577 //TopoDS_Shape res = QAModTopOpe_Glue(s1,s2,AllowCutting);
578 TopoDS_Shape res = QANewModTopOpe_Glue(s1,s2,AllowCutting);
579 if (res.IsNull()) {
580 di << "Error : result is null" << "\n";
581 return 1;
582 }
583
584 DBRep::Set(argv[1],res);
585
586 return 0;
587}
588
589static Standard_Integer OCC395 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
590{
591 if(argc != 4) {
592 di << "Usage : " << argv[0] << " edge_result edge1 edge2" << "\n";
593 return 1;
594 }
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();
612 }
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();
618 }
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 );
631 return 0;
632 }
633 else return 1;
634}
635
636static Standard_Integer OCC394 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
637{
638 if(argc < 3) {
639 di << "Usage : " << argv[0] << " edge_result edge [tol [mode [tolang]]]" << "\n";
640 return 1;
641 }
642 TopoDS_Shape Sh = DBRep::Get(argv[2]);
643
644 Standard_Integer k = 3;
645 Standard_Real tol = 100000;
646 Standard_Integer mode = 2;
c6541a0c 647 Standard_Real tolang = M_PI/2;
7fd59977 648 if(argc > k)
91322f44 649 tol = Draw::Atof(argv[k++]);
7fd59977 650
651 if(argc > k)
91322f44 652 mode= Draw::Atoi(argv[k++]);
7fd59977 653
654 if(argc > k)
91322f44 655 tolang = Draw::Atof(argv[k++]);
7fd59977 656
657
658 Handle(ShapeFix_Wireframe) aSfwr = new ShapeFix_Wireframe();
659 Handle(ShapeBuild_ReShape) aReShape = new ShapeBuild_ReShape;
660 aSfwr->SetContext(aReShape);
661 aSfwr->Load(Sh);
662 aSfwr->SetPrecision(tol);
663 Standard_Boolean aModeDrop = Standard_True;
664 if(mode == 2)
665 aModeDrop = Standard_False;
666
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 );
674 return 0;
675}
676
677static Standard_Integer OCC301 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
678{
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";
684 return 1;
685 }
a6eb515f 686 if ( argc != 3 ) {
687 di << "Usage : " << argv[0] << " ArcRadius ArrowSize" << "\n";
7fd59977 688 return 1;
689 }
690
a6eb515f 691 Standard_Real aRadius = Draw::Atof(argv[1]);
692 Standard_Real anArrowSize = Draw::Atof(argv[2]);
7fd59977 693
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.);
697
698 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(p1, p2);
699 TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(p2, p3);
700
701 context->Display(new AIS_Shape(E1));
702 context->Display(new AIS_Shape(E2));
703
704 gp_Pnt plnpt(0, 0, 0);
705 gp_Dir plndir(0, 0, 1);
706 Handle(Geom_Plane) pln = new Geom_Plane(plnpt,plndir);
707
a6eb515f 708 Handle(AIS_AngleDimension) anAngleDimension = new AIS_AngleDimension (p1.Mirrored (p2), p2, p3);
709
710 Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect;
711 anAspect->MakeArrows3d (Standard_True);
712 anAspect->ArrowAspect()->SetLength (anArrowSize);
d7bffd44 713 anAspect->SetTextHorizontalPosition (Prs3d_DTHP_Right);
a6eb515f 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);
7fd59977 719 return 0;
720}
721
722static Standard_Integer OCC294 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
723{
724 if(argc < 4) {
725 di << "Usage : " << argv[0] << " shape_result shape edge" << "\n";
726 return 1;
727 }
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;
732
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";
739 return 1;
740 }
741
742 DBRep::Set ( argv[1], ResultShape);
743 return 0;
744}
745
746static Standard_Integer OCC60 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
747{
748 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
749 if(aContext.IsNull()) {
750 di << "use 'vinit' command before " << argv[0] << "\n";
751 return 1;
752 }
753 if(argc < 5) {
754 di << "Usage : " << argv[0] << " xmin ymin xmax ymax; selection window" << "\n";
755 return 1;
756 }
757
91322f44 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]);
7fd59977 762
763 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
764
765 Handle(ViewerTest_EventManager) EM = ViewerTest::CurrentEventManager();
766 EM->Select(xmin,ymin,xmax,ymax);
767
768 return 0;
769}
770
771static Standard_Integer OCC70 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
772{
773 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
774 if(aContext.IsNull()) {
775 di << "use 'vinit' command before " << argv[0] << "\n";
776 return 1;
777 }
778 if(argc < 7) {
779 di << "Usage : " << argv[0] << " x1 y1 x2 y2 x3 y3 [x y ...]; polygon of selection" << "\n";
780 return 1;
781 }
782 if (((argc - 1) % 2) != 0) {
783 di << "Usage : " << argv[0] << " x1 y1 x2 y2 x3 y3 [x y ...]; polygon of selection" << "\n";
784 return 1;
785 }
786
787 Standard_Integer i, j, np = (argc-1) / 2;
788 TColgp_Array1OfPnt2d Polyline(1,np);
789 j = 1;
790 for (i = 1; i <= np; i++) {
91322f44 791 Polyline(i) = gp_Pnt2d(Draw::Atof(argv[j]), Draw::Atof(argv[j+1]));
7fd59977 792 j += 2;
793 }
794
795 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
796
797 aContext->Select(Polyline,V3dView);
798 aContext->UpdateCurrentViewer();
799
800 return 0;
801}
802
803static Standard_Integer OCC261 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
804{
805 if(argc != 2) {
806 di << "Usage : " << argv[0] << " Doc" << "\n";
807 return 1;
808 }
809
810 Handle(TDocStd_Document) Doc;
811 if(DDocStd::GetDocument(argv[1], Doc)) {
812 Doc->ClearRedos();
813 return 0;
814 } else
815 return 1;
816}
817
818#include <OSD_File.hxx>
819static Standard_Integer OCC710 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
820{
821 if(argc != 2) {
822 di << "Usage : " << argv[0] << " path" << "\n";
823 }
824
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)
829 di << "1" << "\n";
830 else
831 di << "0" << "\n";
832 return 0;
833}
834
835#include <ShapeFix_Shell.hxx>
836static Standard_Integer OCC904 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
837{
838 if(argc != 4) {
839 di << "Usage : " << argv[0] << " result shape nonmanifoldmode(0/1)" << "\n";
840 }
841 TopoDS_Shape S = DBRep::Get(argv[2]);
842 if (S.IsNull() || S.ShapeType() != TopAbs_SHELL) {
843 di << " Shape is null" << "\n";
844 return 1;
845 }
91322f44 846 Standard_Boolean nonmanifmode = (Draw::Atoi(argv[3]) != 0);
7fd59977 847 Handle(ShapeFix_Shell) SFSh = new ShapeFix_Shell;
848 SFSh->FixFaceOrientation(TopoDS::Shell(S),Standard_True,nonmanifmode);
849 DBRep::Set(argv[1],SFSh->Shape());
850 return 0;
851}
852
1cd84fee 853void QABugs::Commands_16(Draw_Interpretor& theCommands) {
1365140b 854 const char *group = "QABugs";
7fd59977 855
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);
a6eb515f 870 theCommands.Add ("OCC301", "OCC301 ArcRadius ArrowSize", __FILE__, OCC301, group);
7fd59977 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);
877
878 return;
879}