7fd59977 |
1 | // File: QASamtech.cxx |
2 | // Created: Mon Mar 18 18:38:02 2002 |
3 | // Author: QA Admin |
4 | // <qa@umnox.nnov.matra-dtv.fr> |
5 | |
6 | |
7 | #include <QASamtech.hxx> |
8 | |
9 | #include <Draw_Interpretor.hxx> |
10 | #include <DBRep.hxx> |
11 | #include <DrawTrSurf.hxx> |
12 | #include <AIS_InteractiveContext.hxx> |
13 | #include <ViewerTest.hxx> |
14 | #include <AIS_Shape.hxx> |
15 | #include <TopoDS_Shape.hxx> |
16 | |
17 | #include <GProp_GProps.hxx> |
18 | #include <BRepGProp.hxx> |
19 | #include <TopoDS_Edge.hxx> |
20 | #include <BRepBuilderAPI_MakeEdge.hxx> |
21 | #include <AIS_Trihedron.hxx> |
22 | #include <Geom_Axis2Placement.hxx> |
23 | #include <gp_Ax2.hxx> |
24 | #include <Geom_Circle.hxx> |
25 | #include <AIS_Circle.hxx> |
26 | #include <V3d_View.hxx> |
27 | #include <TopoDS.hxx> |
28 | #include <Geom_Plane.hxx> |
29 | #include <gp_Pln.hxx> |
30 | #include <AIS_AngleDimension.hxx> |
31 | |
32 | #include <TopExp_Explorer.hxx> |
33 | #include <BRepAdaptor_Curve.hxx> |
34 | #include <GC_MakePlane.hxx> |
35 | #include <AIS_PlaneTrihedron.hxx> |
36 | #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx> |
37 | |
38 | #include <BRep_Tool.hxx> |
39 | #include <Geom_BSplineCurve.hxx> |
40 | #include <GeomConvert_CompCurveToBSplineCurve.hxx> |
41 | #include <BRepBuilderAPI_MakeEdge.hxx> |
42 | #include <Precision.hxx> |
43 | |
44 | #include <GProp_PrincipalProps.hxx> |
45 | |
46 | #include <OSD_Path.hxx> |
47 | #include <Standard_ProgramError.hxx> |
48 | |
49 | //#include <QAModTopOpe_Limitation.hxx> |
50 | #include <QANewModTopOpe_Limitation.hxx> |
51 | |
52 | //#include <QAModTopOpe_Glue.hxx> |
53 | #include <QANewModTopOpe_Glue.hxx> |
54 | |
55 | #include <ShapeFix_Wireframe.hxx> |
56 | #include <ShapeBuild_ReShape.hxx> |
57 | |
58 | #include <ViewerTest_Tool.hxx> |
59 | #include <BRepBuilderAPI_MakeEdge.hxx> |
60 | |
61 | //#include <QAModTopOpe_ReShaper.hxx> |
62 | #include <QANewModTopOpe_ReShaper.hxx> |
63 | |
64 | #include <ViewerTest_EventManager.hxx> |
65 | |
66 | #include <TColgp_Array1OfPnt2d.hxx> |
67 | |
68 | #include <DDocStd.hxx> |
69 | #include <TDocStd_Document.hxx> |
70 | #include <Standard_ErrorHandler.hxx> |
71 | |
72 | #if ! defined(WNT) |
73 | extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS(); |
74 | #else |
75 | Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS(); |
76 | #endif |
77 | |
78 | static Standard_Integer BUC60848 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
79 | { |
80 | if ( argc != 2 ) { |
81 | di << "Usage : " << argv[0] << " shape " << "\n"; |
82 | return 1; |
83 | } |
84 | TopoDS_Shape S = DBRep::Get( argv[1] ); |
85 | if ( S.IsNull() ) { |
86 | di << "Shape is empty" << "\n"; |
87 | return 1; |
88 | } |
89 | GProp_GProps G; |
90 | BRepGProp::VolumeProperties( S,G ); |
91 | Standard_Real GRes; |
92 | GRes = G.Mass(); |
93 | if ( GRes < 0 ) { |
94 | di << "Result is negative : " << GRes << "\n"; |
95 | return 1; |
96 | } else { |
97 | di << "Volume : " << GRes << "\n"; |
98 | } |
99 | |
100 | return 0; |
101 | } |
102 | |
103 | static Standard_Integer BUC60828 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/) |
104 | { |
105 | TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(0.,0.,0.), gp_Pnt(0.,0.,1.)); |
106 | Standard_Boolean aValue; |
107 | aValue=anEdge.Infinite(); |
108 | di << "Initial flag : " << (Standard_Integer) aValue << "\n"; |
109 | anEdge.Infinite(Standard_True); |
110 | Standard_Boolean aValue1; |
111 | aValue1=anEdge.Infinite(); |
112 | di << "Current flag : " << (Standard_Integer) aValue1 << "\n"; |
113 | if(aValue1) di << "Flag was set properly." << "\n"; |
114 | else di << "Faulty : flag was not set properly." << "\n"; |
115 | return 0; |
116 | } |
117 | |
118 | static Standard_Integer BUC60814(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
119 | { |
120 | if(argc!=1) |
121 | { |
122 | di << "Usage : " << argv[0] << "\n"; |
123 | return 1; |
124 | } |
125 | |
126 | |
127 | Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext(); |
128 | if(myAISContext.IsNull()) { |
129 | di << "use 'vinit' command before " << argv[0] << "\n"; |
130 | return 1; |
131 | } |
132 | |
133 | // TRIHEDRON |
134 | Handle(AIS_Trihedron) aTrihedron; |
135 | Handle(Geom_Axis2Placement) aTrihedronAxis=new Geom_Axis2Placement(gp::XOY()); |
136 | aTrihedron=new AIS_Trihedron(aTrihedronAxis); |
137 | myAISContext->Display(aTrihedron); |
138 | |
139 | //Circle |
140 | gp_Pnt P(10,10,10); |
141 | gp_Dir V(1,0,0); |
142 | gp_Ax2 aAx2(P,V); |
143 | |
144 | Handle(Geom_Circle) ahCircle=new Geom_Circle(aAx2,20); |
145 | Handle(AIS_Circle) aCircle=new AIS_Circle(ahCircle); |
146 | myAISContext->Display(aCircle); |
147 | |
148 | myAISContext->SelectionColor(Quantity_NOC_BLUE1); |
149 | |
150 | myAISContext->AddOrRemoveSelected(aTrihedron); |
151 | myAISContext->AddOrRemoveSelected(aCircle); |
152 | |
153 | return 0; |
154 | } |
155 | |
156 | static Standard_Integer BUC60774(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
157 | { |
158 | if(argc!=1) |
159 | { |
160 | di << "Usage : " << argv[0] << "\n"; |
161 | return -1; |
162 | } |
163 | |
164 | Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext(); |
165 | if(myAISContext.IsNull()) |
166 | { |
167 | di << "use 'vinit' command before " << argv[0] << "\n"; |
168 | return -1; |
169 | } |
170 | |
171 | Handle(V3d_View) myV3dView = ViewerTest::CurrentView(); |
172 | |
173 | double Xc,Yc,Width, Height; |
174 | myV3dView->Center(Xc,Yc); |
175 | myV3dView-> Size (Width, Height); |
176 | |
177 | double Xmin,Ymin; |
178 | Xmin=Xc-Width/2; |
179 | Ymin=Yc-Height/2; |
180 | double Xmax,Ymax; |
181 | Xmax=Xc+Width/2; |
182 | Ymax=Yc+Height/2; |
183 | |
184 | Standard_Integer XPmin,YPmin; |
185 | myV3dView->Convert(Xmin,Ymin,XPmin,YPmin); |
186 | // cout<<Xmin<<"\t"<<Ymin<<endl; |
187 | // cout<<XPmin<<"\t"<<YPmin<<endl; |
188 | |
189 | Standard_Integer XPmax,YPmax; |
190 | myV3dView->Convert(Xmax,Ymax,XPmax,YPmax); |
191 | // cout<<Xmax<<"\t"<<Ymax<<endl; |
192 | // cout<<XPmax<<"\t"<<YPmax<<endl; |
193 | |
194 | AIS_StatusOfPick status; |
195 | if ((status=myAISContext->Select(XPmin,YPmin,XPmax,YPmax,myV3dView))==AIS_SOP_NothingSelected) |
196 | di << "status = AIS_SOP_NothingSelected : OK" << "\n"; |
197 | else di << "status = AIS_SOP_NothingSelected : bugged - Faulty " << "\n"; |
198 | |
199 | di.Eval("box b 10 10 10"); |
200 | di.Eval(" vdisplay b"); |
201 | |
202 | if ((status=myAISContext->Select(XPmin,YPmin,XPmax,YPmax,myV3dView))==AIS_SOP_OneSelected) |
203 | di << "status = AIS_SOP_OneSelected : OK" << "\n"; |
204 | else di << "status = AIS_SOP_OneSelected : bugged - Faulty " << "\n"; |
205 | |
206 | di.Eval("box w 20 20 20 20 20 20"); |
207 | di.Eval(" vdisplay w"); |
208 | |
209 | if ((status=myAISContext->Select(XPmin,YPmin,XPmax,YPmax,myV3dView))==AIS_SOP_SeveralSelected) |
210 | di << "status = AIS_SOP_SeveralSelected : OK" << "\n"; |
211 | else di << "status = AIS_SOP_SeveralSelected : bugged - Faulty " << "\n"; |
212 | |
213 | return 0; |
214 | |
215 | } |
216 | |
217 | static Standard_Integer BUC60972 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
218 | { |
219 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); |
220 | if(aContext.IsNull()) { |
221 | di << "use 'vinit' command before " << argv[0] << "\n"; |
222 | return 1; |
223 | } |
224 | |
225 | if(argc != 6) { |
226 | di << "Usage : " << argv[0] << " edge edge plane val text" << "\n"; |
227 | return 1; |
228 | } |
229 | |
230 | TopoDS_Edge aFirst = TopoDS::Edge(DBRep::Get(argv[1],TopAbs_EDGE)); |
231 | TopoDS_Edge aSecond = TopoDS::Edge(DBRep::Get(argv[2],TopAbs_EDGE)); |
232 | Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(DrawTrSurf::GetSurface(argv[3])); |
233 | if(aPlane.IsNull()) |
234 | return 1; |
235 | |
236 | di << aPlane->Pln().SquareDistance( gp_Pnt(0,0,0) ) << "\n"; |
237 | |
238 | TCollection_ExtendedString aText(argv[5]); |
239 | //Standard_ExtString ExtString_aText = aText.ToExtString(); |
240 | //di << ExtString_aText << " " << atof(argv[4]) << "\n"; |
241 | di << argv[5] << " " << atof(argv[4]) << "\n"; |
242 | |
243 | Handle(AIS_AngleDimension) aDim = new AIS_AngleDimension(aFirst, aSecond, aPlane, atof(argv[4]), aText); |
244 | aContext->Display(aDim); |
245 | |
246 | return 0; |
247 | } |
248 | |
249 | static Standard_Integer OCC218bug (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
250 | { |
251 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); |
252 | if(aContext.IsNull()) { |
253 | di << "use 'vinit' command before " << argv[0] << "\n"; |
254 | return 1; |
255 | } |
256 | |
257 | if(argc != 5) { |
258 | di << "Usage : " << argv[0] << " name plane Xlabel Ylabel" << "\n"; |
259 | return 1; |
260 | } |
261 | |
262 | TopoDS_Shape S = DBRep::Get( argv[2] ); |
263 | if ( S.IsNull() ) { |
264 | di << "Shape is empty" << "\n"; |
265 | return 1; |
266 | } |
267 | |
268 | TCollection_AsciiString name(argv[1]); |
269 | TCollection_AsciiString Xlabel(argv[3]); |
270 | TCollection_AsciiString Ylabel(argv[4]); |
271 | |
272 | // Construction de l'AIS_PlaneTrihedron |
273 | Handle(AIS_PlaneTrihedron) theAISPlaneTri; |
274 | |
275 | Standard_Boolean IsBound = GetMapOfAIS().IsBound2(name); |
276 | if (IsBound) { |
277 | // on recupere la shape dans la map des objets displayes |
278 | Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name)); |
279 | |
280 | // On verifie que l'AIS InteraciveObject est bien |
281 | // un AIS_PlaneTrihedron |
282 | if (aShape->Type()==AIS_KOI_Datum && aShape->Signature()==4) { |
283 | // On downcast aShape de AIS_InteractiveObject a AIS_PlaneTrihedron |
284 | theAISPlaneTri = *(Handle(AIS_PlaneTrihedron)*) &aShape; |
285 | |
286 | theAISPlaneTri->SetXLabel(Xlabel); |
287 | theAISPlaneTri->SetYLabel(Ylabel); |
288 | |
289 | aContext->Redisplay(theAISPlaneTri, Standard_False); |
290 | aContext->UpdateCurrentViewer(); |
291 | } |
292 | } else { |
293 | TopoDS_Face FaceB=TopoDS::Face(S); |
294 | |
295 | // Construction du Plane |
296 | // recuperation des edges des faces. |
297 | TopExp_Explorer FaceExpB(FaceB,TopAbs_EDGE); |
298 | |
299 | TopoDS_Edge EdgeB=TopoDS::Edge(FaceExpB.Current() ); |
300 | // declarations |
301 | gp_Pnt A,B,C; |
302 | |
303 | // si il y a plusieurs edges |
304 | if (FaceExpB.More() ) { |
305 | FaceExpB.Next(); |
306 | TopoDS_Edge EdgeC=TopoDS::Edge(FaceExpB.Current() ); |
307 | BRepAdaptor_Curve theCurveB(EdgeB); |
308 | BRepAdaptor_Curve theCurveC(EdgeC); |
309 | A=theCurveC.Value(0.1); |
310 | B=theCurveC.Value(0.9); |
311 | C=theCurveB.Value(0.5); |
312 | } |
313 | else { |
314 | // FaceB a 1 unique edge courbe |
315 | BRepAdaptor_Curve theCurveB(EdgeB); |
316 | A=theCurveB.Value(0.1); |
317 | B=theCurveB.Value(0.9); |
318 | C=theCurveB.Value(0.5); |
319 | } |
320 | // Construction du Geom_Plane |
321 | GC_MakePlane MkPlane(A,B,C); |
322 | Handle(Geom_Plane) theGeomPlane=MkPlane.Value(); |
323 | |
324 | // on le display & bind |
325 | theAISPlaneTri= new AIS_PlaneTrihedron(theGeomPlane ); |
326 | |
327 | theAISPlaneTri->SetXLabel(Xlabel); |
328 | theAISPlaneTri->SetYLabel(Ylabel); |
329 | |
330 | GetMapOfAIS().Bind ( theAISPlaneTri, name); |
331 | aContext->Display(theAISPlaneTri ); |
332 | } |
333 | return 0; |
334 | } |
335 | |
336 | static Standard_Integer OCC295(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
337 | { |
338 | if(argc != 4) { |
339 | di << "Usage : " << argv[0] << " edge_result edge1 edge2" << "\n"; |
340 | return 1; |
341 | } |
342 | |
343 | TopoDS_Shape Sh1 = DBRep::Get(argv[2]); |
344 | TopoDS_Shape Sh2 = DBRep::Get(argv[3]); |
345 | if(Sh1.IsNull() || Sh2.IsNull()) return 1; |
346 | if(Sh1.ShapeType() != TopAbs_EDGE || Sh2.ShapeType() != TopAbs_EDGE) return 1; |
347 | TopoDS_Edge e1 = TopoDS::Edge(Sh1); |
348 | TopoDS_Edge e2 = TopoDS::Edge(Sh2); |
349 | Standard_Real f1,l1,f2,l2; |
350 | Standard_Boolean After = Standard_True; |
351 | Handle(Geom_Curve) ac1 = BRep_Tool::Curve(e1,f1,l1); |
352 | Handle(Geom_Curve) ac2 = BRep_Tool::Curve(e2,f2,l2); |
353 | Handle(Geom_BSplineCurve) bsplc1 = Handle(Geom_BSplineCurve)::DownCast(ac1); |
354 | Handle(Geom_BSplineCurve) bsplc2 = Handle(Geom_BSplineCurve)::DownCast(ac2); |
355 | if(bsplc1.IsNull() || bsplc2.IsNull()) return 1; |
356 | gp_Pnt pmid = 0.5 * ( bsplc1->Pole(bsplc1->NbPoles()).XYZ() + bsplc2->Pole(1).XYZ() ); |
357 | bsplc1->SetPole(bsplc1->NbPoles(), pmid); |
358 | bsplc2->SetPole(1, pmid); |
359 | GeomConvert_CompCurveToBSplineCurve connect3d(bsplc1); |
360 | if(!connect3d.Add(bsplc2,Precision::Confusion(), After, Standard_False)) return 1; |
361 | BRepBuilderAPI_MakeEdge MkEdge(connect3d.BSplineCurve()); |
362 | if(MkEdge.IsDone()) { |
363 | TopoDS_Edge nedge = MkEdge.Edge(); |
364 | DBRep::Set ( argv[1], nedge ); |
365 | return 0; |
366 | } |
367 | else return 1; |
368 | } |
369 | |
370 | static Standard_Integer OCC49 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
371 | { |
372 | |
373 | if ( argc != 2 ) { |
374 | di << "Usage : " << argv[0] << " name" << "\n"; |
375 | return 1; |
376 | } |
377 | |
378 | TopoDS_Shape S = DBRep::Get(argv[1]); |
379 | if (S.IsNull()) return 0; |
380 | |
381 | GProp_GProps G; |
382 | BRepGProp::VolumeProperties(S,G); |
383 | GProp_PrincipalProps Pr = G.PrincipalProperties(); |
384 | Standard_Boolean Result = Pr.HasSymmetryAxis(); |
385 | if (Result) { |
386 | di << "1" << "\n"; |
387 | } else { |
388 | di << "0" << "\n"; |
389 | } |
390 | return 0; |
391 | } |
392 | |
393 | static Standard_Integer OCC132 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
394 | { |
395 | /* |
396 | OCC132: |
397 | ======= |
398 | |
399 | ... the validation of the name of files in Analyse_DOS and Analyse_UNIX is : |
400 | |
401 | characters not allowed in DOS/WNT names are |
402 | / |
403 | : |
404 | * |
405 | ? |
406 | " |
407 | < |
408 | > |
409 | | |
410 | and more than one dot in filename. |
411 | */ |
412 | |
413 | if ( argc != 2 ) { |
414 | di << "Usage : " << argv[0] << " DependentName" << "\n"; |
415 | return 1; |
416 | } |
417 | |
418 | OSD_SysType SysType1 = OSD_OS2; |
419 | OSD_SysType SysType2 = OSD_WindowsNT; |
420 | |
421 | { |
422 | try { |
423 | OCC_CATCH_SIGNALS |
424 | OSD_Path Path (argv[1], SysType1); |
425 | } |
426 | catch (Standard_ProgramError) { |
427 | di << "1" << "\n"; |
428 | return 0; |
429 | } |
430 | } |
431 | |
432 | { |
433 | try { |
434 | OCC_CATCH_SIGNALS |
435 | OSD_Path Path (argv[1], SysType2); |
436 | } |
437 | catch (Standard_ProgramError) { |
438 | di << "2" << "\n"; |
439 | return 0; |
440 | } |
441 | } |
442 | |
443 | di << "0" << "\n"; |
444 | return 0; |
445 | } |
446 | |
447 | static Standard_Integer OCC405 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
448 | { |
449 | if(argc != 4) { |
450 | di << "Usage : " << argv[0] << " edge_result edge1 edge2; merge two edges" << "\n"; |
451 | return 1; |
452 | } |
453 | |
454 | TopoDS_Shape Sh1 = DBRep::Get(argv[2]); |
455 | TopoDS_Shape Sh2 = DBRep::Get(argv[3]); |
456 | if(Sh1.IsNull() || Sh2.IsNull()) return 1; |
457 | if(Sh1.ShapeType() != TopAbs_EDGE || Sh2.ShapeType() != TopAbs_EDGE) return 1; |
458 | TopoDS_Edge e1 = TopoDS::Edge(Sh1); |
459 | TopoDS_Edge e2 = TopoDS::Edge(Sh2); |
460 | Standard_Real f1,l1,f2,l2; |
461 | Standard_Boolean After = Standard_True; |
462 | Handle(Geom_Curve) ac1 = BRep_Tool::Curve(e1,f1,l1); |
463 | Handle(Geom_Curve) ac2 = BRep_Tool::Curve(e2,f2,l2); |
464 | if(e1.Orientation() == TopAbs_REVERSED) { |
465 | Standard_Real cf = f1; |
466 | f1 = ac1->ReversedParameter ( l1 ); |
467 | l1 = ac1->ReversedParameter ( cf ); |
468 | ac1 = ac1->Reversed(); |
469 | } |
470 | if(e2.Orientation() == TopAbs_REVERSED) { |
471 | Standard_Real cf = f2; |
472 | f2 = ac2->ReversedParameter ( l2 ); |
473 | l2 = ac2->ReversedParameter ( cf ); |
474 | ac2 = ac2->Reversed(); |
475 | } |
476 | Handle(Geom_BSplineCurve) bsplc1 = Handle(Geom_BSplineCurve)::DownCast(ac1); |
477 | Handle(Geom_BSplineCurve) bsplc2 = Handle(Geom_BSplineCurve)::DownCast(ac2); |
478 | if(bsplc1.IsNull() || bsplc2.IsNull()) return 1; |
479 | if(bsplc1->FirstParameter() < f1 - Precision::PConfusion() || |
480 | bsplc1->LastParameter() > l1 + Precision::PConfusion()) { |
481 | Handle(Geom_BSplineCurve) aBstmp = Handle(Geom_BSplineCurve)::DownCast(bsplc1->Copy()); |
482 | aBstmp->Segment(f1,l1); |
483 | gp_Pnt p1 = aBstmp->Pole(1); |
484 | gp_Pnt p2 = aBstmp->Pole(aBstmp->NbPoles()); |
485 | bsplc1 =aBstmp; |
486 | } |
487 | if(bsplc2->FirstParameter() < f2 - Precision::PConfusion() || |
488 | bsplc2->LastParameter() > l2 + Precision::PConfusion()) { |
489 | Handle(Geom_BSplineCurve) aBstmp = Handle(Geom_BSplineCurve)::DownCast(bsplc2->Copy()); |
490 | aBstmp->Segment(f2,l2); |
491 | gp_Pnt p1 = aBstmp->Pole(1); |
492 | gp_Pnt p2 = aBstmp->Pole(aBstmp->NbPoles()); |
493 | bsplc2 =aBstmp; |
494 | } |
495 | gp_Pnt pmid = 0.5 * ( bsplc1->Pole(bsplc1->NbPoles()).XYZ() + bsplc2->Pole(1).XYZ() ); |
496 | bsplc1->SetPole(bsplc1->NbPoles(), pmid); |
497 | bsplc2->SetPole(1, pmid); |
498 | GeomConvert_CompCurveToBSplineCurve connect3d(bsplc1); |
499 | if(!connect3d.Add(bsplc2,Precision::Confusion(), After, Standard_False)) return 1; |
500 | BRepBuilderAPI_MakeEdge MkEdge(connect3d.BSplineCurve()); |
501 | if(MkEdge.IsDone()) { |
502 | TopoDS_Edge nedge = MkEdge.Edge(); |
503 | DBRep::Set ( argv[1], nedge ); |
504 | return 0; |
505 | } |
506 | else return 1; |
507 | } |
508 | |
509 | static Standard_Integer OCC252 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
510 | { |
511 | if(!(argc == 4 || argc == 5)) { |
512 | di << "Usage : " << argv[0] << " result part tool [ModeOfLimitation=0/1/2]" << "\n"; |
513 | return 1; |
514 | } |
515 | |
516 | TopoDS_Shape s1 = DBRep::Get(argv[2]); |
517 | TopoDS_Shape s2 = DBRep::Get(argv[3]); |
518 | if (s1.IsNull() || s2.IsNull()) return 1; |
519 | |
520 | //QAModTopOpe_ModeOfLimitation ModeOfLimitation = QAModTopOpe_Forward; |
521 | QANewModTopOpe_ModeOfLimitation ModeOfLimitation = QANewModTopOpe_Forward; |
522 | if(argc==5) { |
523 | Standard_Integer ModeOfLimitationInteger = atoi(argv[4]); |
524 | if(!(ModeOfLimitationInteger == 0 || ModeOfLimitationInteger == 1 || ModeOfLimitationInteger == 2)) { |
525 | di << "Usage : " << argv[0] << " result part tool [ModeOfLimitation=0/1/2]" << "\n"; |
526 | return 1; |
527 | } |
528 | //if (ModeOfLimitationInteger == 1) ModeOfLimitation = QAModTopOpe_Reversed; |
529 | //if (ModeOfLimitationInteger == 2) ModeOfLimitation = QAModTopOpe_BothParts; |
530 | if (ModeOfLimitationInteger == 1) ModeOfLimitation = QANewModTopOpe_Reversed; |
531 | if (ModeOfLimitationInteger == 2) ModeOfLimitation = QANewModTopOpe_BothParts; |
532 | } |
533 | |
534 | //TopoDS_Shape res = QAModTopOpe_Limitation(s1,s2,ModeOfLimitation); |
535 | TopoDS_Shape res = QANewModTopOpe_Limitation(s1,s2,ModeOfLimitation); |
536 | if (res.IsNull()) { |
537 | di << "Error : result is null" << "\n"; |
538 | return 1; |
539 | } |
540 | |
541 | DBRep::Set(argv[1],res); |
542 | |
543 | return 0; |
544 | } |
545 | |
546 | static Standard_Integer OCC307 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
547 | { |
548 | if(!(argc == 4 || argc == 5)) { |
549 | di << "Usage : " << argv[0] << " result part tool [AllowCutting=0/1]" << "\n"; |
550 | return 1; |
551 | } |
552 | |
553 | TopoDS_Shape s1 = DBRep::Get(argv[2]); |
554 | TopoDS_Shape s2 = DBRep::Get(argv[3]); |
555 | if (s1.IsNull() || s2.IsNull()) return 1; |
556 | |
557 | Standard_Boolean AllowCutting = Standard_False; |
558 | if(argc==5) { |
559 | Standard_Integer AllowCuttingInteger = atoi(argv[4]); |
560 | if(!( AllowCuttingInteger == 0 || AllowCuttingInteger == 1)) { |
561 | di << "Usage : " << argv[0] << " result part tool [AllowCutting=0/1]" << "\n"; |
562 | return 1; |
563 | } |
564 | if (AllowCuttingInteger == 1) AllowCutting = Standard_True; |
565 | } |
566 | |
567 | //TopoDS_Shape res = QAModTopOpe_Glue(s1,s2,AllowCutting); |
568 | TopoDS_Shape res = QANewModTopOpe_Glue(s1,s2,AllowCutting); |
569 | if (res.IsNull()) { |
570 | di << "Error : result is null" << "\n"; |
571 | return 1; |
572 | } |
573 | |
574 | DBRep::Set(argv[1],res); |
575 | |
576 | return 0; |
577 | } |
578 | |
579 | static Standard_Integer OCC395 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
580 | { |
581 | if(argc != 4) { |
582 | di << "Usage : " << argv[0] << " edge_result edge1 edge2" << "\n"; |
583 | return 1; |
584 | } |
585 | //TCollection_AsciiString fnom(a[1]); |
586 | //Standard_Boolean modfic = XSDRAW::FileAndVar(a[1],a[2],a[3],"IGES",fnom,rnom,resnom); |
587 | TopoDS_Shape Sh1 = DBRep::Get(argv[2]); |
588 | TopoDS_Shape Sh2 = DBRep::Get(argv[3]); |
589 | if(Sh1.IsNull() || Sh2.IsNull()) return 1; |
590 | if(Sh1.ShapeType() != TopAbs_EDGE || Sh2.ShapeType() != TopAbs_EDGE) return 1; |
591 | TopoDS_Edge e1 = TopoDS::Edge(Sh1); |
592 | TopoDS_Edge e2 = TopoDS::Edge(Sh2); |
593 | Standard_Real f1,l1,f2,l2; |
594 | Standard_Boolean After = Standard_True; |
595 | Handle(Geom_Curve) ac1 = BRep_Tool::Curve(e1,f1,l1); |
596 | Handle(Geom_Curve) ac2 = BRep_Tool::Curve(e2,f2,l2); |
597 | if(e1.Orientation() == TopAbs_REVERSED) { |
598 | //Standard_Real cf = cf1; |
599 | //cf1 = ac1->ReversedParameter ( cl1 ); |
600 | //cl1 = ac1->ReversedParameter ( cf ); |
601 | ac1 = ac1->Reversed(); |
602 | } |
603 | if(e2.Orientation() == TopAbs_REVERSED) { |
604 | //Standard_Real cf = cf2; |
605 | //ac2 = ac2->ReversedParameter ( cl2 ); |
606 | //ac2 = ac2->ReversedParameter ( cf ); |
607 | ac2 = ac2->Reversed(); |
608 | } |
609 | Handle(Geom_BSplineCurve) bsplc1 = Handle(Geom_BSplineCurve)::DownCast(ac1); |
610 | Handle(Geom_BSplineCurve) bsplc2 = Handle(Geom_BSplineCurve)::DownCast(ac2); |
611 | if(bsplc1.IsNull() || bsplc2.IsNull()) return 1; |
612 | gp_Pnt pmid = 0.5 * ( bsplc1->Pole(bsplc1->NbPoles()).XYZ() + bsplc2->Pole(1).XYZ() ); |
613 | bsplc1->SetPole(bsplc1->NbPoles(), pmid); |
614 | bsplc2->SetPole(1, pmid); |
615 | GeomConvert_CompCurveToBSplineCurve connect3d(bsplc1); |
616 | if(!connect3d.Add(bsplc2,Precision::Confusion(), After, Standard_False)) return 1; |
617 | BRepBuilderAPI_MakeEdge MkEdge(connect3d.BSplineCurve()); |
618 | if(MkEdge.IsDone()) { |
619 | TopoDS_Edge nedge = MkEdge.Edge(); |
620 | DBRep::Set ( argv[1], nedge ); |
621 | return 0; |
622 | } |
623 | else return 1; |
624 | } |
625 | |
626 | static Standard_Integer OCC394 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
627 | { |
628 | if(argc < 3) { |
629 | di << "Usage : " << argv[0] << " edge_result edge [tol [mode [tolang]]]" << "\n"; |
630 | return 1; |
631 | } |
632 | TopoDS_Shape Sh = DBRep::Get(argv[2]); |
633 | |
634 | Standard_Integer k = 3; |
635 | Standard_Real tol = 100000; |
636 | Standard_Integer mode = 2; |
c6541a0c |
637 | Standard_Real tolang = M_PI/2; |
7fd59977 |
638 | if(argc > k) |
639 | tol = atof(argv[k++]); |
640 | |
641 | if(argc > k) |
642 | mode= atoi(argv[k++]); |
643 | |
644 | if(argc > k) |
645 | tolang = atof(argv[k++]); |
646 | |
647 | |
648 | Handle(ShapeFix_Wireframe) aSfwr = new ShapeFix_Wireframe(); |
649 | Handle(ShapeBuild_ReShape) aReShape = new ShapeBuild_ReShape; |
650 | aSfwr->SetContext(aReShape); |
651 | aSfwr->Load(Sh); |
652 | aSfwr->SetPrecision(tol); |
653 | Standard_Boolean aModeDrop = Standard_True; |
654 | if(mode == 2) |
655 | aModeDrop = Standard_False; |
656 | |
657 | TopTools_MapOfShape theSmallEdges, theMultyEdges; |
658 | TopTools_DataMapOfShapeListOfShape theEdgeToFaces,theFaceWithSmall; |
659 | aSfwr->CheckSmallEdges(theSmallEdges,theEdgeToFaces,theFaceWithSmall, theMultyEdges); |
660 | aSfwr->MergeSmallEdges (theSmallEdges,theEdgeToFaces,theFaceWithSmall, theMultyEdges, aModeDrop,tolang); |
661 | //aSfwr->FixSmallEdges(); |
662 | TopoDS_Shape resShape = aSfwr->Shape();; |
663 | DBRep::Set ( argv[1], resShape ); |
664 | return 0; |
665 | } |
666 | |
667 | static Standard_Integer OCC301 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
668 | { |
669 | //Handle(AIS_InteractiveContext) context= ViewerTest_Tool::MakeContext ("OCC301"); |
670 | //ViewerTest_Tool::InitViewerTest (context); |
671 | Handle(AIS_InteractiveContext) context = ViewerTest::GetAISContext(); |
672 | if(context.IsNull()) { |
673 | di << "use 'vinit' command before " << argv[0] << "\n"; |
674 | return 1; |
675 | } |
676 | if ( argc != 5 ) { |
677 | di << "Usage : " << argv[0] << " X Y Z ArrowSize" << "\n"; |
678 | return 1; |
679 | } |
680 | |
681 | Standard_Real X = atof(argv[1]); |
682 | Standard_Real Y = atof(argv[2]); |
683 | Standard_Real Z = atof(argv[3]); |
684 | Standard_Real ArrowSize = atof(argv[4]); |
685 | |
686 | gp_Pnt p1 = gp_Pnt(10.,10.,0.); |
687 | gp_Pnt p2 = gp_Pnt(50.,10.,0.); |
688 | gp_Pnt p3 = gp_Pnt(50.,50.,0.); |
689 | |
690 | TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(p1, p2); |
691 | TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(p2, p3); |
692 | |
693 | context->Display(new AIS_Shape(E1)); |
694 | context->Display(new AIS_Shape(E2)); |
695 | |
696 | gp_Pnt plnpt(0, 0, 0); |
697 | gp_Dir plndir(0, 0, 1); |
698 | Handle(Geom_Plane) pln = new Geom_Plane(plnpt,plndir); |
699 | |
700 | Handle(AIS_AngleDimension) AngleDimension = new AIS_AngleDimension(E2, E1, pln, -3.14/2., "Angle"); |
701 | |
702 | AngleDimension->SetPosition(gp_Pnt(X, Y, Z)); |
703 | AngleDimension->SetArrowSize(ArrowSize); |
704 | |
705 | context->Display(AngleDimension); |
706 | return 0; |
707 | } |
708 | |
709 | static Standard_Integer OCC294 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
710 | { |
711 | if(argc < 4) { |
712 | di << "Usage : " << argv[0] << " shape_result shape edge" << "\n"; |
713 | return 1; |
714 | } |
715 | TopoDS_Shape Sh1 = DBRep::Get(argv[2]); |
716 | TopoDS_Shape Sh2 = DBRep::Get(argv[3]); |
717 | if(Sh1.IsNull() || Sh2.IsNull()) return 1; |
718 | if(Sh2.ShapeType() != TopAbs_EDGE) return 1; |
719 | |
720 | //QAModTopOpe_ReShaper ReShaper(Sh1); |
721 | QANewModTopOpe_ReShaper ReShaper(Sh1); |
722 | ReShaper.Remove(Sh2); |
723 | const TopoDS_Shape& ResultShape = ReShaper.GetResult(); |
724 | if(ResultShape.IsNull()) { |
725 | di << "Faulty " << argv[0] << " : " << argv[1] << " - shape_result is null" << "\n"; |
726 | return 1; |
727 | } |
728 | |
729 | DBRep::Set ( argv[1], ResultShape); |
730 | return 0; |
731 | } |
732 | |
733 | static Standard_Integer OCC60 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
734 | { |
735 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); |
736 | if(aContext.IsNull()) { |
737 | di << "use 'vinit' command before " << argv[0] << "\n"; |
738 | return 1; |
739 | } |
740 | if(argc < 5) { |
741 | di << "Usage : " << argv[0] << " xmin ymin xmax ymax; selection window" << "\n"; |
742 | return 1; |
743 | } |
744 | |
745 | Standard_Integer xmin = atoi(argv[1]); |
746 | Standard_Integer ymin = atoi(argv[2]); |
747 | Standard_Integer xmax = atoi(argv[3]); |
748 | Standard_Integer ymax = atoi(argv[4]); |
749 | |
750 | Handle(V3d_View) V3dView = ViewerTest::CurrentView(); |
751 | |
752 | Handle(ViewerTest_EventManager) EM = ViewerTest::CurrentEventManager(); |
753 | EM->Select(xmin,ymin,xmax,ymax); |
754 | |
755 | return 0; |
756 | } |
757 | |
758 | static Standard_Integer OCC70 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
759 | { |
760 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); |
761 | if(aContext.IsNull()) { |
762 | di << "use 'vinit' command before " << argv[0] << "\n"; |
763 | return 1; |
764 | } |
765 | if(argc < 7) { |
766 | di << "Usage : " << argv[0] << " x1 y1 x2 y2 x3 y3 [x y ...]; polygon of selection" << "\n"; |
767 | return 1; |
768 | } |
769 | if (((argc - 1) % 2) != 0) { |
770 | di << "Usage : " << argv[0] << " x1 y1 x2 y2 x3 y3 [x y ...]; polygon of selection" << "\n"; |
771 | return 1; |
772 | } |
773 | |
774 | Standard_Integer i, j, np = (argc-1) / 2; |
775 | TColgp_Array1OfPnt2d Polyline(1,np); |
776 | j = 1; |
777 | for (i = 1; i <= np; i++) { |
778 | Polyline(i) = gp_Pnt2d(atof(argv[j]), atof(argv[j+1])); |
779 | j += 2; |
780 | } |
781 | |
782 | Handle(V3d_View) V3dView = ViewerTest::CurrentView(); |
783 | |
784 | aContext->Select(Polyline,V3dView); |
785 | aContext->UpdateCurrentViewer(); |
786 | |
787 | return 0; |
788 | } |
789 | |
790 | static Standard_Integer OCC261 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
791 | { |
792 | if(argc != 2) { |
793 | di << "Usage : " << argv[0] << " Doc" << "\n"; |
794 | return 1; |
795 | } |
796 | |
797 | Handle(TDocStd_Document) Doc; |
798 | if(DDocStd::GetDocument(argv[1], Doc)) { |
799 | Doc->ClearRedos(); |
800 | return 0; |
801 | } else |
802 | return 1; |
803 | } |
804 | |
805 | #include <OSD_File.hxx> |
806 | static Standard_Integer OCC710 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
807 | { |
808 | if(argc != 2) { |
809 | di << "Usage : " << argv[0] << " path" << "\n"; |
810 | } |
811 | |
812 | TCollection_AsciiString in(argv[1]); |
813 | OSD_File* aFile = new OSD_File(in); |
814 | Standard_Boolean anExists = aFile->Exists(); |
815 | if(anExists == Standard_True) |
816 | di << "1" << "\n"; |
817 | else |
818 | di << "0" << "\n"; |
819 | return 0; |
820 | } |
821 | |
822 | #include <ShapeFix_Shell.hxx> |
823 | static Standard_Integer OCC904 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
824 | { |
825 | if(argc != 4) { |
826 | di << "Usage : " << argv[0] << " result shape nonmanifoldmode(0/1)" << "\n"; |
827 | } |
828 | TopoDS_Shape S = DBRep::Get(argv[2]); |
829 | if (S.IsNull() || S.ShapeType() != TopAbs_SHELL) { |
830 | di << " Shape is null" << "\n"; |
831 | return 1; |
832 | } |
833 | Standard_Boolean nonmanifmode = (atoi(argv[3]) != 0); |
834 | Handle(ShapeFix_Shell) SFSh = new ShapeFix_Shell; |
835 | SFSh->FixFaceOrientation(TopoDS::Shell(S),Standard_True,nonmanifmode); |
836 | DBRep::Set(argv[1],SFSh->Shape()); |
837 | return 0; |
838 | } |
839 | |
840 | void QASamtech::Commands(Draw_Interpretor& theCommands) { |
841 | char *group = "QASamtech"; |
842 | |
843 | theCommands.Add ("BUC60848", "BUC60848 shape", __FILE__, BUC60848, group); |
844 | theCommands.Add ("BUC60828", "BUC60828", __FILE__, BUC60828, group); |
845 | theCommands.Add ("BUC60814", "BUC60814", __FILE__, BUC60814, group); |
846 | theCommands.Add ("BUC60774", "BUC60774", __FILE__, BUC60774, group); |
847 | theCommands.Add ("BUC60972", "BUC60972 edge edge plane val text ", __FILE__, BUC60972, group); |
848 | theCommands.Add ("OCC218", "OCC218 name plane Xlabel Ylabel", __FILE__, OCC218bug, group); |
849 | theCommands.Add ("OCC295", "OCC295 edge_result edge1 edge2", __FILE__, OCC295, group); |
850 | theCommands.Add ("OCC49", "OCC49 name", __FILE__, OCC49, group); |
851 | theCommands.Add ("OCC132", "OCC132 DependentName", __FILE__, OCC132, group); |
852 | theCommands.Add ("OCC405", "OCC405 edge_result edge1 edge2; merge two edges", __FILE__, OCC405, group); |
853 | theCommands.Add ("OCC252", "OCC252 result part tool [ModeOfLimitation=0/1/2]", __FILE__, OCC252, group); |
854 | theCommands.Add ("OCC307", "OCC307 result part tool [AllowCutting=0/1]", __FILE__, OCC307, group); |
855 | theCommands.Add ("OCC395", "OCC395 edge_result edge1 edge2", __FILE__, OCC395, group); |
856 | theCommands.Add ("OCC394", "OCC394 edge_result edge [tol [mode [tolang]]]", __FILE__, OCC394, group); |
857 | theCommands.Add ("OCC301", "OCC301 X Y Z ArrowSize", __FILE__, OCC301, group); |
858 | theCommands.Add ("OCC294", "OCC294 shape_result shape edge", __FILE__, OCC294, group); |
859 | theCommands.Add ("OCC60", "OCC60 xmin ymin xmax ymax; selection window", __FILE__, OCC60, group); |
860 | theCommands.Add ("OCC70", "OCC70 x1 y1 x2 y2 x3 y3 [x y ...]; polygon of selection", __FILE__, OCC70, group); |
861 | theCommands.Add ("OCC261", "OCC261 Doc", __FILE__, OCC261, group); |
862 | theCommands.Add ("OCC710", "OCC710 path", __FILE__, OCC710, group); |
863 | theCommands.Add ("OCC904", "OCC904 result shape nonmanifoldmode(0/1)", __FILE__, OCC904, group); |
864 | |
865 | return; |
866 | } |