b311480e |
1 | // Created on: 2002-03-18 |
2 | // Created by: QA Admin |
973c2be1 |
3 | // Copyright (c) 2002-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
b311480e |
6 | // |
973c2be1 |
7 | // This library is free software; you can redistribute it and / or modify it |
8 | // under the terms of the GNU Lesser General Public 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. |
b311480e |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
b311480e |
15 | |
1cd84fee |
16 | #include <QABugs.hxx> |
7fd59977 |
17 | |
91322f44 |
18 | #include <Draw.hxx> |
7fd59977 |
19 | #include <Draw_Interpretor.hxx> |
20 | #include <DBRep.hxx> |
21 | #include <DrawTrSurf.hxx> |
22 | #include <AIS_InteractiveContext.hxx> |
23 | #include <ViewerTest.hxx> |
24 | #include <AIS_Shape.hxx> |
25 | #include <TopoDS_Shape.hxx> |
26 | |
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> |
33 | #include <gp_Ax2.hxx> |
34 | #include <Geom_Circle.hxx> |
35 | #include <AIS_Circle.hxx> |
36 | #include <V3d_View.hxx> |
37 | #include <TopoDS.hxx> |
38 | #include <Geom_Plane.hxx> |
39 | #include <gp_Pln.hxx> |
40 | #include <AIS_AngleDimension.hxx> |
41 | |
42 | #include <TopExp_Explorer.hxx> |
43 | #include <BRepAdaptor_Curve.hxx> |
44 | #include <GC_MakePlane.hxx> |
45 | #include <AIS_PlaneTrihedron.hxx> |
46 | #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx> |
47 | |
48 | #include <BRep_Tool.hxx> |
49 | #include <Geom_BSplineCurve.hxx> |
50 | #include <GeomConvert_CompCurveToBSplineCurve.hxx> |
51 | #include <BRepBuilderAPI_MakeEdge.hxx> |
52 | #include <Precision.hxx> |
53 | |
54 | #include <GProp_PrincipalProps.hxx> |
55 | |
56 | #include <OSD_Path.hxx> |
57 | #include <Standard_ProgramError.hxx> |
58 | |
59 | //#include <QAModTopOpe_Limitation.hxx> |
60 | #include <QANewModTopOpe_Limitation.hxx> |
61 | |
62 | //#include <QAModTopOpe_Glue.hxx> |
63 | #include <QANewModTopOpe_Glue.hxx> |
64 | |
65 | #include <ShapeFix_Wireframe.hxx> |
66 | #include <ShapeBuild_ReShape.hxx> |
67 | |
68 | #include <ViewerTest_Tool.hxx> |
69 | #include <BRepBuilderAPI_MakeEdge.hxx> |
70 | |
71 | //#include <QAModTopOpe_ReShaper.hxx> |
72 | #include <QANewModTopOpe_ReShaper.hxx> |
73 | |
74 | #include <ViewerTest_EventManager.hxx> |
75 | |
76 | #include <TColgp_Array1OfPnt2d.hxx> |
77 | |
78 | #include <DDocStd.hxx> |
79 | #include <TDocStd_Document.hxx> |
80 | #include <Standard_ErrorHandler.hxx> |
81 | |
82 | #if ! defined(WNT) |
83 | extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS(); |
84 | #else |
85 | Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS(); |
86 | #endif |
87 | |
88 | static Standard_Integer BUC60848 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
89 | { |
90 | if ( argc != 2 ) { |
91 | di << "Usage : " << argv[0] << " shape " << "\n"; |
92 | return 1; |
93 | } |
94 | TopoDS_Shape S = DBRep::Get( argv[1] ); |
95 | if ( S.IsNull() ) { |
96 | di << "Shape is empty" << "\n"; |
97 | return 1; |
98 | } |
99 | GProp_GProps G; |
100 | BRepGProp::VolumeProperties( S,G ); |
101 | Standard_Real GRes; |
102 | GRes = G.Mass(); |
103 | if ( GRes < 0 ) { |
104 | di << "Result is negative : " << GRes << "\n"; |
105 | return 1; |
106 | } else { |
107 | di << "Volume : " << GRes << "\n"; |
108 | } |
109 | |
110 | return 0; |
111 | } |
112 | |
113 | static Standard_Integer BUC60828 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/) |
114 | { |
115 | TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(0.,0.,0.), gp_Pnt(0.,0.,1.)); |
116 | Standard_Boolean aValue; |
117 | aValue=anEdge.Infinite(); |
118 | di << "Initial flag : " << (Standard_Integer) aValue << "\n"; |
119 | anEdge.Infinite(Standard_True); |
120 | Standard_Boolean aValue1; |
121 | aValue1=anEdge.Infinite(); |
122 | di << "Current flag : " << (Standard_Integer) aValue1 << "\n"; |
123 | if(aValue1) di << "Flag was set properly." << "\n"; |
124 | else di << "Faulty : flag was not set properly." << "\n"; |
125 | return 0; |
126 | } |
127 | |
128 | static Standard_Integer BUC60814(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
129 | { |
130 | if(argc!=1) |
131 | { |
132 | di << "Usage : " << argv[0] << "\n"; |
133 | return 1; |
134 | } |
135 | |
136 | |
137 | Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext(); |
138 | if(myAISContext.IsNull()) { |
139 | di << "use 'vinit' command before " << argv[0] << "\n"; |
140 | return 1; |
141 | } |
142 | |
143 | // TRIHEDRON |
144 | Handle(AIS_Trihedron) aTrihedron; |
145 | Handle(Geom_Axis2Placement) aTrihedronAxis=new Geom_Axis2Placement(gp::XOY()); |
146 | aTrihedron=new AIS_Trihedron(aTrihedronAxis); |
147 | myAISContext->Display(aTrihedron); |
148 | |
149 | //Circle |
150 | gp_Pnt P(10,10,10); |
151 | gp_Dir V(1,0,0); |
152 | gp_Ax2 aAx2(P,V); |
153 | |
154 | Handle(Geom_Circle) ahCircle=new Geom_Circle(aAx2,20); |
155 | Handle(AIS_Circle) aCircle=new AIS_Circle(ahCircle); |
156 | myAISContext->Display(aCircle); |
157 | |
158 | myAISContext->SelectionColor(Quantity_NOC_BLUE1); |
159 | |
160 | myAISContext->AddOrRemoveSelected(aTrihedron); |
161 | myAISContext->AddOrRemoveSelected(aCircle); |
162 | |
163 | return 0; |
164 | } |
165 | |
166 | static Standard_Integer BUC60774(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
167 | { |
168 | if(argc!=1) |
169 | { |
170 | di << "Usage : " << argv[0] << "\n"; |
171 | return -1; |
172 | } |
173 | |
174 | Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext(); |
175 | if(myAISContext.IsNull()) |
176 | { |
177 | di << "use 'vinit' command before " << argv[0] << "\n"; |
178 | return -1; |
179 | } |
180 | |
181 | Handle(V3d_View) myV3dView = ViewerTest::CurrentView(); |
182 | |
183 | double Xc,Yc,Width, Height; |
184 | myV3dView->Center(Xc,Yc); |
185 | myV3dView-> Size (Width, Height); |
186 | |
187 | double Xmin,Ymin; |
188 | Xmin=Xc-Width/2; |
189 | Ymin=Yc-Height/2; |
190 | double Xmax,Ymax; |
191 | Xmax=Xc+Width/2; |
192 | Ymax=Yc+Height/2; |
193 | |
194 | Standard_Integer XPmin,YPmin; |
195 | myV3dView->Convert(Xmin,Ymin,XPmin,YPmin); |
196 | // cout<<Xmin<<"\t"<<Ymin<<endl; |
197 | // cout<<XPmin<<"\t"<<YPmin<<endl; |
198 | |
199 | Standard_Integer XPmax,YPmax; |
200 | myV3dView->Convert(Xmax,Ymax,XPmax,YPmax); |
201 | // cout<<Xmax<<"\t"<<Ymax<<endl; |
202 | // cout<<XPmax<<"\t"<<YPmax<<endl; |
203 | |
204 | AIS_StatusOfPick status; |
205 | if ((status=myAISContext->Select(XPmin,YPmin,XPmax,YPmax,myV3dView))==AIS_SOP_NothingSelected) |
206 | di << "status = AIS_SOP_NothingSelected : OK" << "\n"; |
207 | else di << "status = AIS_SOP_NothingSelected : bugged - Faulty " << "\n"; |
208 | |
209 | di.Eval("box b 10 10 10"); |
210 | di.Eval(" vdisplay b"); |
211 | |
212 | if ((status=myAISContext->Select(XPmin,YPmin,XPmax,YPmax,myV3dView))==AIS_SOP_OneSelected) |
213 | di << "status = AIS_SOP_OneSelected : OK" << "\n"; |
214 | else di << "status = AIS_SOP_OneSelected : bugged - Faulty " << "\n"; |
215 | |
216 | di.Eval("box w 20 20 20 20 20 20"); |
217 | di.Eval(" vdisplay w"); |
218 | |
219 | if ((status=myAISContext->Select(XPmin,YPmin,XPmax,YPmax,myV3dView))==AIS_SOP_SeveralSelected) |
220 | di << "status = AIS_SOP_SeveralSelected : OK" << "\n"; |
221 | else di << "status = AIS_SOP_SeveralSelected : bugged - Faulty " << "\n"; |
222 | |
223 | return 0; |
224 | |
225 | } |
226 | |
227 | static Standard_Integer BUC60972 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
228 | { |
229 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); |
230 | if(aContext.IsNull()) { |
231 | di << "use 'vinit' command before " << argv[0] << "\n"; |
232 | return 1; |
233 | } |
234 | |
235 | if(argc != 6) { |
236 | di << "Usage : " << argv[0] << " edge edge plane val text" << "\n"; |
237 | return 1; |
238 | } |
239 | |
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])); |
243 | if(aPlane.IsNull()) |
244 | return 1; |
245 | |
246 | di << aPlane->Pln().SquareDistance( gp_Pnt(0,0,0) ) << "\n"; |
247 | |
248 | TCollection_ExtendedString aText(argv[5]); |
249 | //Standard_ExtString ExtString_aText = aText.ToExtString(); |
91322f44 |
250 | //di << ExtString_aText << " " << Draw::Atof(argv[4]) << "\n"; |
251 | di << argv[5] << " " << Draw::Atof(argv[4]) << "\n"; |
7fd59977 |
252 | |
60bf98ae |
253 | Handle(AIS_AngleDimension) aDim = new AIS_AngleDimension(aFirst, aSecond); |
7fd59977 |
254 | aContext->Display(aDim); |
255 | |
256 | return 0; |
257 | } |
258 | |
259 | static Standard_Integer OCC218bug (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
260 | { |
261 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); |
262 | if(aContext.IsNull()) { |
263 | di << "use 'vinit' command before " << argv[0] << "\n"; |
264 | return 1; |
265 | } |
266 | |
267 | if(argc != 5) { |
268 | di << "Usage : " << argv[0] << " name plane Xlabel Ylabel" << "\n"; |
269 | return 1; |
270 | } |
271 | |
272 | TopoDS_Shape S = DBRep::Get( argv[2] ); |
273 | if ( S.IsNull() ) { |
274 | di << "Shape is empty" << "\n"; |
275 | return 1; |
276 | } |
277 | |
278 | TCollection_AsciiString name(argv[1]); |
279 | TCollection_AsciiString Xlabel(argv[3]); |
280 | TCollection_AsciiString Ylabel(argv[4]); |
281 | |
282 | // Construction de l'AIS_PlaneTrihedron |
283 | Handle(AIS_PlaneTrihedron) theAISPlaneTri; |
284 | |
285 | Standard_Boolean IsBound = GetMapOfAIS().IsBound2(name); |
286 | if (IsBound) { |
287 | // on recupere la shape dans la map des objets displayes |
288 | Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name)); |
289 | |
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)*) &aShape; |
295 | |
296 | theAISPlaneTri->SetXLabel(Xlabel); |
297 | theAISPlaneTri->SetYLabel(Ylabel); |
298 | |
299 | aContext->Redisplay(theAISPlaneTri, Standard_False); |
300 | aContext->UpdateCurrentViewer(); |
301 | } |
302 | } else { |
303 | TopoDS_Face FaceB=TopoDS::Face(S); |
304 | |
305 | // Construction du Plane |
306 | // recuperation des edges des faces. |
307 | TopExp_Explorer FaceExpB(FaceB,TopAbs_EDGE); |
308 | |
309 | TopoDS_Edge EdgeB=TopoDS::Edge(FaceExpB.Current() ); |
310 | // declarations |
311 | gp_Pnt A,B,C; |
312 | |
313 | // si il y a plusieurs edges |
314 | if (FaceExpB.More() ) { |
315 | FaceExpB.Next(); |
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); |
322 | } |
323 | else { |
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); |
329 | } |
330 | // Construction du Geom_Plane |
331 | GC_MakePlane MkPlane(A,B,C); |
332 | Handle(Geom_Plane) theGeomPlane=MkPlane.Value(); |
333 | |
334 | // on le display & bind |
335 | theAISPlaneTri= new AIS_PlaneTrihedron(theGeomPlane ); |
336 | |
337 | theAISPlaneTri->SetXLabel(Xlabel); |
338 | theAISPlaneTri->SetYLabel(Ylabel); |
339 | |
340 | GetMapOfAIS().Bind ( theAISPlaneTri, name); |
341 | aContext->Display(theAISPlaneTri ); |
342 | } |
343 | return 0; |
344 | } |
345 | |
346 | static Standard_Integer OCC295(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
347 | { |
348 | if(argc != 4) { |
349 | di << "Usage : " << argv[0] << " edge_result edge1 edge2" << "\n"; |
350 | return 1; |
351 | } |
352 | |
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 ); |
375 | return 0; |
376 | } |
377 | else return 1; |
378 | } |
379 | |
380 | static Standard_Integer OCC49 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
381 | { |
382 | |
383 | if ( argc != 2 ) { |
384 | di << "Usage : " << argv[0] << " name" << "\n"; |
385 | return 1; |
386 | } |
387 | |
388 | TopoDS_Shape S = DBRep::Get(argv[1]); |
389 | if (S.IsNull()) return 0; |
390 | |
391 | GProp_GProps G; |
392 | BRepGProp::VolumeProperties(S,G); |
393 | GProp_PrincipalProps Pr = G.PrincipalProperties(); |
394 | Standard_Boolean Result = Pr.HasSymmetryAxis(); |
395 | if (Result) { |
396 | di << "1" << "\n"; |
397 | } else { |
398 | di << "0" << "\n"; |
399 | } |
400 | return 0; |
401 | } |
402 | |
403 | static Standard_Integer OCC132 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
404 | { |
405 | /* |
406 | OCC132: |
407 | ======= |
408 | |
409 | ... the validation of the name of files in Analyse_DOS and Analyse_UNIX is : |
410 | |
411 | characters not allowed in DOS/WNT names are |
412 | / |
413 | : |
414 | * |
415 | ? |
416 | " |
417 | < |
418 | > |
419 | | |
420 | and more than one dot in filename. |
421 | */ |
422 | |
423 | if ( argc != 2 ) { |
424 | di << "Usage : " << argv[0] << " DependentName" << "\n"; |
425 | return 1; |
426 | } |
427 | |
428 | OSD_SysType SysType1 = OSD_OS2; |
429 | OSD_SysType SysType2 = OSD_WindowsNT; |
430 | |
431 | { |
432 | try { |
433 | OCC_CATCH_SIGNALS |
434 | OSD_Path Path (argv[1], SysType1); |
435 | } |
436 | catch (Standard_ProgramError) { |
437 | di << "1" << "\n"; |
438 | return 0; |
439 | } |
440 | } |
441 | |
442 | { |
443 | try { |
444 | OCC_CATCH_SIGNALS |
445 | OSD_Path Path (argv[1], SysType2); |
446 | } |
447 | catch (Standard_ProgramError) { |
448 | di << "2" << "\n"; |
449 | return 0; |
450 | } |
451 | } |
452 | |
453 | di << "0" << "\n"; |
454 | return 0; |
455 | } |
456 | |
457 | static Standard_Integer OCC405 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
458 | { |
459 | if(argc != 4) { |
460 | di << "Usage : " << argv[0] << " edge_result edge1 edge2; merge two edges" << "\n"; |
461 | return 1; |
462 | } |
463 | |
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(); |
479 | } |
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(); |
485 | } |
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); |
7fd59977 |
493 | bsplc1 =aBstmp; |
494 | } |
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); |
7fd59977 |
499 | bsplc2 =aBstmp; |
500 | } |
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 ); |
510 | return 0; |
511 | } |
512 | else return 1; |
513 | } |
514 | |
515 | static Standard_Integer OCC252 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
516 | { |
517 | if(!(argc == 4 || argc == 5)) { |
518 | di << "Usage : " << argv[0] << " result part tool [ModeOfLimitation=0/1/2]" << "\n"; |
519 | return 1; |
520 | } |
521 | |
522 | TopoDS_Shape s1 = DBRep::Get(argv[2]); |
523 | TopoDS_Shape s2 = DBRep::Get(argv[3]); |
524 | if (s1.IsNull() || s2.IsNull()) return 1; |
525 | |
526 | //QAModTopOpe_ModeOfLimitation ModeOfLimitation = QAModTopOpe_Forward; |
527 | QANewModTopOpe_ModeOfLimitation ModeOfLimitation = QANewModTopOpe_Forward; |
528 | if(argc==5) { |
91322f44 |
529 | Standard_Integer ModeOfLimitationInteger = Draw::Atoi(argv[4]); |
7fd59977 |
530 | if(!(ModeOfLimitationInteger == 0 || ModeOfLimitationInteger == 1 || ModeOfLimitationInteger == 2)) { |
531 | di << "Usage : " << argv[0] << " result part tool [ModeOfLimitation=0/1/2]" << "\n"; |
532 | return 1; |
533 | } |
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; |
538 | } |
539 | |
540 | //TopoDS_Shape res = QAModTopOpe_Limitation(s1,s2,ModeOfLimitation); |
541 | TopoDS_Shape res = QANewModTopOpe_Limitation(s1,s2,ModeOfLimitation); |
542 | if (res.IsNull()) { |
543 | di << "Error : result is null" << "\n"; |
544 | return 1; |
545 | } |
546 | |
547 | DBRep::Set(argv[1],res); |
548 | |
549 | return 0; |
550 | } |
551 | |
552 | static Standard_Integer OCC307 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
553 | { |
554 | if(!(argc == 4 || argc == 5)) { |
555 | di << "Usage : " << argv[0] << " result part tool [AllowCutting=0/1]" << "\n"; |
556 | return 1; |
557 | } |
558 | |
559 | TopoDS_Shape s1 = DBRep::Get(argv[2]); |
560 | TopoDS_Shape s2 = DBRep::Get(argv[3]); |
561 | if (s1.IsNull() || s2.IsNull()) return 1; |
562 | |
563 | Standard_Boolean AllowCutting = Standard_False; |
564 | if(argc==5) { |
91322f44 |
565 | Standard_Integer AllowCuttingInteger = Draw::Atoi(argv[4]); |
7fd59977 |
566 | if(!( AllowCuttingInteger == 0 || AllowCuttingInteger == 1)) { |
567 | di << "Usage : " << argv[0] << " result part tool [AllowCutting=0/1]" << "\n"; |
568 | return 1; |
569 | } |
570 | if (AllowCuttingInteger == 1) AllowCutting = Standard_True; |
571 | } |
572 | |
573 | //TopoDS_Shape res = QAModTopOpe_Glue(s1,s2,AllowCutting); |
574 | TopoDS_Shape res = QANewModTopOpe_Glue(s1,s2,AllowCutting); |
575 | if (res.IsNull()) { |
576 | di << "Error : result is null" << "\n"; |
577 | return 1; |
578 | } |
579 | |
580 | DBRep::Set(argv[1],res); |
581 | |
582 | return 0; |
583 | } |
584 | |
585 | static Standard_Integer OCC395 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
586 | { |
587 | if(argc != 4) { |
588 | di << "Usage : " << argv[0] << " edge_result edge1 edge2" << "\n"; |
589 | return 1; |
590 | } |
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(); |
608 | } |
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(); |
614 | } |
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 ); |
627 | return 0; |
628 | } |
629 | else return 1; |
630 | } |
631 | |
632 | static Standard_Integer OCC394 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
633 | { |
634 | if(argc < 3) { |
635 | di << "Usage : " << argv[0] << " edge_result edge [tol [mode [tolang]]]" << "\n"; |
636 | return 1; |
637 | } |
638 | TopoDS_Shape Sh = DBRep::Get(argv[2]); |
639 | |
640 | Standard_Integer k = 3; |
641 | Standard_Real tol = 100000; |
642 | Standard_Integer mode = 2; |
c6541a0c |
643 | Standard_Real tolang = M_PI/2; |
7fd59977 |
644 | if(argc > k) |
91322f44 |
645 | tol = Draw::Atof(argv[k++]); |
7fd59977 |
646 | |
647 | if(argc > k) |
91322f44 |
648 | mode= Draw::Atoi(argv[k++]); |
7fd59977 |
649 | |
650 | if(argc > k) |
91322f44 |
651 | tolang = Draw::Atof(argv[k++]); |
7fd59977 |
652 | |
653 | |
654 | Handle(ShapeFix_Wireframe) aSfwr = new ShapeFix_Wireframe(); |
655 | Handle(ShapeBuild_ReShape) aReShape = new ShapeBuild_ReShape; |
656 | aSfwr->SetContext(aReShape); |
657 | aSfwr->Load(Sh); |
658 | aSfwr->SetPrecision(tol); |
659 | Standard_Boolean aModeDrop = Standard_True; |
660 | if(mode == 2) |
661 | aModeDrop = Standard_False; |
662 | |
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 ); |
670 | return 0; |
671 | } |
672 | |
673 | static Standard_Integer OCC301 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
674 | { |
675 | //Handle(AIS_InteractiveContext) context= ViewerTest_Tool::MakeContext ("OCC301"); |
676 | //ViewerTest_Tool::InitViewerTest (context); |
677 | Handle(AIS_InteractiveContext) context = ViewerTest::GetAISContext(); |
678 | if(context.IsNull()) { |
679 | di << "use 'vinit' command before " << argv[0] << "\n"; |
680 | return 1; |
681 | } |
a6eb515f |
682 | if ( argc != 3 ) { |
683 | di << "Usage : " << argv[0] << " ArcRadius ArrowSize" << "\n"; |
7fd59977 |
684 | return 1; |
685 | } |
686 | |
a6eb515f |
687 | Standard_Real aRadius = Draw::Atof(argv[1]); |
688 | Standard_Real anArrowSize = Draw::Atof(argv[2]); |
7fd59977 |
689 | |
690 | gp_Pnt p1 = gp_Pnt(10.,10.,0.); |
691 | gp_Pnt p2 = gp_Pnt(50.,10.,0.); |
692 | gp_Pnt p3 = gp_Pnt(50.,50.,0.); |
693 | |
694 | TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(p1, p2); |
695 | TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(p2, p3); |
696 | |
697 | context->Display(new AIS_Shape(E1)); |
698 | context->Display(new AIS_Shape(E2)); |
699 | |
700 | gp_Pnt plnpt(0, 0, 0); |
701 | gp_Dir plndir(0, 0, 1); |
702 | Handle(Geom_Plane) pln = new Geom_Plane(plnpt,plndir); |
703 | |
a6eb515f |
704 | Handle(AIS_AngleDimension) anAngleDimension = new AIS_AngleDimension (p1.Mirrored (p2), p2, p3); |
705 | |
706 | Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect; |
707 | anAspect->MakeArrows3d (Standard_True); |
708 | anAspect->ArrowAspect()->SetLength (anArrowSize); |
d7bffd44 |
709 | anAspect->SetTextHorizontalPosition (Prs3d_DTHP_Right); |
a6eb515f |
710 | anAspect->TextAspect ()->SetColor (Quantity_NOC_YELLOW); |
711 | anAngleDimension->SetDimensionAspect (anAspect); |
712 | // Another position of dimension |
713 | anAngleDimension->SetFlyout (aRadius); |
714 | context->Display (anAngleDimension, 0); |
7fd59977 |
715 | return 0; |
716 | } |
717 | |
718 | static Standard_Integer OCC294 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
719 | { |
720 | if(argc < 4) { |
721 | di << "Usage : " << argv[0] << " shape_result shape edge" << "\n"; |
722 | return 1; |
723 | } |
724 | TopoDS_Shape Sh1 = DBRep::Get(argv[2]); |
725 | TopoDS_Shape Sh2 = DBRep::Get(argv[3]); |
726 | if(Sh1.IsNull() || Sh2.IsNull()) return 1; |
727 | if(Sh2.ShapeType() != TopAbs_EDGE) return 1; |
728 | |
729 | //QAModTopOpe_ReShaper ReShaper(Sh1); |
730 | QANewModTopOpe_ReShaper ReShaper(Sh1); |
731 | ReShaper.Remove(Sh2); |
732 | const TopoDS_Shape& ResultShape = ReShaper.GetResult(); |
733 | if(ResultShape.IsNull()) { |
734 | di << "Faulty " << argv[0] << " : " << argv[1] << " - shape_result is null" << "\n"; |
735 | return 1; |
736 | } |
737 | |
738 | DBRep::Set ( argv[1], ResultShape); |
739 | return 0; |
740 | } |
741 | |
742 | static Standard_Integer OCC60 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
743 | { |
744 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); |
745 | if(aContext.IsNull()) { |
746 | di << "use 'vinit' command before " << argv[0] << "\n"; |
747 | return 1; |
748 | } |
749 | if(argc < 5) { |
750 | di << "Usage : " << argv[0] << " xmin ymin xmax ymax; selection window" << "\n"; |
751 | return 1; |
752 | } |
753 | |
91322f44 |
754 | Standard_Integer xmin = Draw::Atoi(argv[1]); |
755 | Standard_Integer ymin = Draw::Atoi(argv[2]); |
756 | Standard_Integer xmax = Draw::Atoi(argv[3]); |
757 | Standard_Integer ymax = Draw::Atoi(argv[4]); |
7fd59977 |
758 | |
759 | Handle(V3d_View) V3dView = ViewerTest::CurrentView(); |
760 | |
761 | Handle(ViewerTest_EventManager) EM = ViewerTest::CurrentEventManager(); |
762 | EM->Select(xmin,ymin,xmax,ymax); |
763 | |
764 | return 0; |
765 | } |
766 | |
767 | static Standard_Integer OCC70 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
768 | { |
769 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); |
770 | if(aContext.IsNull()) { |
771 | di << "use 'vinit' command before " << argv[0] << "\n"; |
772 | return 1; |
773 | } |
774 | if(argc < 7) { |
775 | di << "Usage : " << argv[0] << " x1 y1 x2 y2 x3 y3 [x y ...]; polygon of selection" << "\n"; |
776 | return 1; |
777 | } |
778 | if (((argc - 1) % 2) != 0) { |
779 | di << "Usage : " << argv[0] << " x1 y1 x2 y2 x3 y3 [x y ...]; polygon of selection" << "\n"; |
780 | return 1; |
781 | } |
782 | |
783 | Standard_Integer i, j, np = (argc-1) / 2; |
784 | TColgp_Array1OfPnt2d Polyline(1,np); |
785 | j = 1; |
786 | for (i = 1; i <= np; i++) { |
91322f44 |
787 | Polyline(i) = gp_Pnt2d(Draw::Atof(argv[j]), Draw::Atof(argv[j+1])); |
7fd59977 |
788 | j += 2; |
789 | } |
790 | |
791 | Handle(V3d_View) V3dView = ViewerTest::CurrentView(); |
792 | |
793 | aContext->Select(Polyline,V3dView); |
794 | aContext->UpdateCurrentViewer(); |
795 | |
796 | return 0; |
797 | } |
798 | |
799 | static Standard_Integer OCC261 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
800 | { |
801 | if(argc != 2) { |
802 | di << "Usage : " << argv[0] << " Doc" << "\n"; |
803 | return 1; |
804 | } |
805 | |
806 | Handle(TDocStd_Document) Doc; |
807 | if(DDocStd::GetDocument(argv[1], Doc)) { |
808 | Doc->ClearRedos(); |
809 | return 0; |
810 | } else |
811 | return 1; |
812 | } |
813 | |
814 | #include <OSD_File.hxx> |
815 | static Standard_Integer OCC710 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
816 | { |
817 | if(argc != 2) { |
818 | di << "Usage : " << argv[0] << " path" << "\n"; |
819 | } |
820 | |
821 | TCollection_AsciiString in(argv[1]); |
822 | OSD_File* aFile = new OSD_File(in); |
823 | Standard_Boolean anExists = aFile->Exists(); |
824 | if(anExists == Standard_True) |
825 | di << "1" << "\n"; |
826 | else |
827 | di << "0" << "\n"; |
828 | return 0; |
829 | } |
830 | |
831 | #include <ShapeFix_Shell.hxx> |
832 | static Standard_Integer OCC904 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
833 | { |
834 | if(argc != 4) { |
835 | di << "Usage : " << argv[0] << " result shape nonmanifoldmode(0/1)" << "\n"; |
836 | } |
837 | TopoDS_Shape S = DBRep::Get(argv[2]); |
838 | if (S.IsNull() || S.ShapeType() != TopAbs_SHELL) { |
839 | di << " Shape is null" << "\n"; |
840 | return 1; |
841 | } |
91322f44 |
842 | Standard_Boolean nonmanifmode = (Draw::Atoi(argv[3]) != 0); |
7fd59977 |
843 | Handle(ShapeFix_Shell) SFSh = new ShapeFix_Shell; |
844 | SFSh->FixFaceOrientation(TopoDS::Shell(S),Standard_True,nonmanifmode); |
845 | DBRep::Set(argv[1],SFSh->Shape()); |
846 | return 0; |
847 | } |
848 | |
1cd84fee |
849 | void QABugs::Commands_16(Draw_Interpretor& theCommands) { |
1365140b |
850 | const char *group = "QABugs"; |
7fd59977 |
851 | |
852 | theCommands.Add ("BUC60848", "BUC60848 shape", __FILE__, BUC60848, group); |
853 | theCommands.Add ("BUC60828", "BUC60828", __FILE__, BUC60828, group); |
854 | theCommands.Add ("BUC60814", "BUC60814", __FILE__, BUC60814, group); |
855 | theCommands.Add ("BUC60774", "BUC60774", __FILE__, BUC60774, group); |
856 | theCommands.Add ("BUC60972", "BUC60972 edge edge plane val text ", __FILE__, BUC60972, group); |
857 | theCommands.Add ("OCC218", "OCC218 name plane Xlabel Ylabel", __FILE__, OCC218bug, group); |
858 | theCommands.Add ("OCC295", "OCC295 edge_result edge1 edge2", __FILE__, OCC295, group); |
859 | theCommands.Add ("OCC49", "OCC49 name", __FILE__, OCC49, group); |
860 | theCommands.Add ("OCC132", "OCC132 DependentName", __FILE__, OCC132, group); |
861 | theCommands.Add ("OCC405", "OCC405 edge_result edge1 edge2; merge two edges", __FILE__, OCC405, group); |
862 | theCommands.Add ("OCC252", "OCC252 result part tool [ModeOfLimitation=0/1/2]", __FILE__, OCC252, group); |
863 | theCommands.Add ("OCC307", "OCC307 result part tool [AllowCutting=0/1]", __FILE__, OCC307, group); |
864 | theCommands.Add ("OCC395", "OCC395 edge_result edge1 edge2", __FILE__, OCC395, group); |
865 | theCommands.Add ("OCC394", "OCC394 edge_result edge [tol [mode [tolang]]]", __FILE__, OCC394, group); |
a6eb515f |
866 | theCommands.Add ("OCC301", "OCC301 ArcRadius ArrowSize", __FILE__, OCC301, group); |
7fd59977 |
867 | theCommands.Add ("OCC294", "OCC294 shape_result shape edge", __FILE__, OCC294, group); |
868 | theCommands.Add ("OCC60", "OCC60 xmin ymin xmax ymax; selection window", __FILE__, OCC60, group); |
869 | theCommands.Add ("OCC70", "OCC70 x1 y1 x2 y2 x3 y3 [x y ...]; polygon of selection", __FILE__, OCC70, group); |
870 | theCommands.Add ("OCC261", "OCC261 Doc", __FILE__, OCC261, group); |
871 | theCommands.Add ("OCC710", "OCC710 path", __FILE__, OCC710, group); |
872 | theCommands.Add ("OCC904", "OCC904 result shape nonmanifoldmode(0/1)", __FILE__, OCC904, group); |
873 | |
874 | return; |
875 | } |