0024166: Unable to create file with "Save" menu of voxeldemo Qt sample
[occt.git] / src / QABugs / QABugs_3.cxx
CommitLineData
b311480e 1// Created on: 2002-06-17
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#ifdef HAVE_CONFIG_H
22#include <config.h>
23#endif
91322f44 24#include <Draw.hxx>
25#include <Draw_Interpretor.hxx>
26#include <TopLoc_Location.hxx>
27#include <TopoDS_Face.hxx>
28#include <TopoDS.hxx>
29#include <DBRep.hxx>
30#include <Geom_Surface.hxx>
31#include <BRep_Tool.hxx>
32#include <GeomInt_IntSS.hxx>
33#include <BRepBuilderAPI_MakeEdge.hxx>
7fd59977 34#include <Standard_ErrorHandler.hxx>
4269bd1b 35#include <Graphic3d_ClipPlane.hxx>
7fd59977 36
64531d9c 37#include <fstream>
38
7fd59977 39static int BUC60623(Draw_Interpretor& di, Standard_Integer argc, const char ** a)
40{
41 if(argc!=4)
42 {
43 di << "Usage : " << a[0] << " result Shape1 Shape2" << "\n";
44 return -1;
45 }
46
47 TopLoc_Location L1;
48 TopLoc_Location L2;
49 TopoDS_Face F1 = TopoDS::Face(DBRep::Get(a[2],TopAbs_FACE));
50 TopoDS_Face F2 = TopoDS::Face(DBRep::Get(a[3],TopAbs_FACE));
51 Handle(Geom_Surface) GSF1 = BRep_Tool::Surface(F1, L1);
52 Handle(Geom_Surface) GSF2 = BRep_Tool::Surface(F2, L2);
53 GeomInt_IntSS Inter;
54 Inter.Perform(GSF1,GSF2, BRep_Tool::Tolerance(F1));
55 if (!Inter.IsDone()) {
56 di << "Intersection not done" << "\n";
57 return 1;
58 }
59 Standard_Integer nbsol = Inter.NbLines();
60 if(!nbsol) {
61 di << "The number of solutions is zero!" << "\n";
62 return 0;
63 }
64 Handle(Geom_Curve) Sol = Inter.Line(1);
65 if(!Sol.IsNull()) {
66 DBRep::Set(a[1], BRepBuilderAPI_MakeEdge(Sol));
67 return 0;
68 } else di << "The first solution is Null!" << "\n";
69
70 di << "fini" << "\n";
71 return 0;
72}
73
74#include<ViewerTest.hxx>
75#include<AIS_InteractiveContext.hxx>
76#include<AIS_Shape.hxx>
77
78static int BUC60569(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
79{
80 if(argc!=2)
81 {
82 di << "Usage : " << argv[0] << " shape" << "\n";
83 return -1;
84 }
85
86 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
87 if(myAISContext.IsNull()) {
88 di << "use 'vinit' command before " << argv[0] << "\n";
89 return -1;
90 }
91
92 TopoDS_Shape theShape = DBRep::Get(argv[1]);
93
94 Handle(AIS_Shape) anAISShape = new AIS_Shape( theShape );
95 myAISContext->Display( anAISShape, Standard_True );
96 myAISContext->OpenLocalContext();
97 myAISContext->ActivateStandardMode(TopAbs_FACE);
98 return 0;
99}
100
101static int BUC60614(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
102{
103 if(argc!=2)
104 {
105 di << "Usage : "<< argv[0] << " shape" << "\n";
106 return -1;
107 }
108
109 // di.Eval("vinit");
110
111 TopoDS_Shape theShape = DBRep::Get(argv[1]);
112
113// ViewerTest::GetAISContext();
114 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
115 if(myAISContext.IsNull()) {
116 di << "use 'vinit' command before " << argv[0] << "\n";
117 return -1;
118 }
119 Handle(AIS_Shape) anAISShape = new AIS_Shape( theShape );
120 myAISContext->Display( anAISShape, Standard_True );
121 myAISContext->OpenLocalContext();
122 myAISContext->ActivateStandardMode(TopAbs_COMPOUND);
123// myAISContext->ActivateStandardMode(TopAbs_SOLID);
124// di.Eval("vfit");
125// cout << "vfini" << endl;
126 return 0;
127}
128
129#include<BRep_Builder.hxx>
130#include<BRepTools_ShapeSet.hxx>
131#include<BRepTools.hxx>
132#include<BRepAdaptor_HSurface.hxx>
133#include<TopOpeBRep_PointClassifier.hxx>
134#include<Precision.hxx>
135#ifdef WNT
136#include<stdio.h>
137#endif
138
139static int BUC60609(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
7fd59977 140 gp_Pnt2d uvSurf;
7fd59977 141 TopAbs_State state;
142
ceeaafcb 143 if (argc == 3) {
144 // BUC60609 shape name
145 } else if ( argc == 5 ) {
146 // BUC60609 shape name U V
147 } else {
148 di << "Usage : "<< argv[0] << " shape name [U V]" << "\n";
7fd59977 149 return(-1);
150 }
7fd59977 151
f1e162f2 152 TCollection_AsciiString aFilePath(argv[1]);
7fd59977 153
154 filebuf fic;
155 istream in(&fic);
f1e162f2 156 if (!fic.open(aFilePath.ToCString(),ios::in)) {
157 di << "Cannot open file for reading : " << aFilePath << "\n";
7fd59977 158 return(-1);
159 }
160
161 TopoDS_Shape theShape;
162 char typ[255];
163 in >> typ;
164 if (!in.fail()) {
165 if( !strcmp(typ, "DBRep_DrawableShape") ){
166 BRep_Builder B;
167 BRepTools_ShapeSet S(B);
168 S.Read(in);
169 S.Read(theShape,in);
170 }else{
f1e162f2 171 di << "Wrong entity type in " << aFilePath << "\n";
7fd59977 172 return(-1);
173 }
174 }
175
176 const TopoDS_Face &face = TopoDS::Face (theShape);
177
178 if(argc > 2){
179 DBRep::Set(argv[2],face);
180 }
181
7fd59977 182 Standard_Real faceUMin,faceUMax,faceVMin,faceVMax;
183
184 BRepTools::UVBounds (face, faceUMin,faceUMax,faceVMin,faceVMax);
185
186 di << "The bounds of the trimmed face:" << "\n";
187 di << faceUMin << " <= U <= " << faceUMax << "\n";
188 di << faceVMin << " <= V <= " << faceVMax << "\n";
189
190 Handle(BRepAdaptor_HSurface) hsurfa = new BRepAdaptor_HSurface(face);
191
192 TopOpeBRep_PointClassifier PClass;
193
194 di << "Now test the point classifier by inputting U,V values" << "\n";
195 di << "inside or outside the bounds displayed above" << "\n";
196 di << "Type stop to exit" << "\n";
197
198 // Please register this:
199 // ***********************************************
200 // Note also that for periodic surfaces such as nimpod_1.topo,
201 // the U/V values may be +- 2pi compared to the actual face bounds
202 // (because U,V is probably coming from a Geom package routine).
203 // Hence IT WOULD BE USEFUL IF TopOpeBRep_PointClassifier COULD
204 // COPE WITH PERIODIC SURFACES, i.e. U,V +-Period giving same result.
205 // *************************************************
7fd59977 206
ceeaafcb 207 if (argc == 3) {
208 uvSurf = gp_Pnt2d(0.14,5.1);
209 state = PClass.Classify(face,uvSurf,Precision::PConfusion());
210 if(state == TopAbs_IN || state == TopAbs_ON){
211 di << "U=" << 0.14 << " V=" << 5.1 << " classified INSIDE" << "\n";
212 }else{
213 di << "U=" << 0.14 << " V=" << 5.1 << " classified OUTSIDE" << "\n";
214 }
215
216 uvSurf = gp_Pnt2d(1.28,5.1);
217 state = PClass.Classify(face,uvSurf,Precision::PConfusion());
218 if(state == TopAbs_IN || state == TopAbs_ON){
219 di << "U=" << 1.28 << " V=" << 5.1 << " classified INSIDE" << "\n";
220 }else{
221 di << "U=" << 1.28 << " V=" << 5.1 << " classified OUTSIDE" << "\n";
222 }
223 } else {
91322f44 224 uvSurf = gp_Pnt2d(Draw::Atof(argv[3]),Draw::Atof(argv[4]));
ceeaafcb 225 state = PClass.Classify(face,uvSurf,Precision::PConfusion());
226 if(state == TopAbs_IN || state == TopAbs_ON){
91322f44 227 di << "U=" << Draw::Atof(argv[3]) << " V=" << Draw::Atof(argv[4]) << " classified INSIDE" << "\n";
ceeaafcb 228 }else{
91322f44 229 di << "U=" << Draw::Atof(argv[3]) << " V=" << Draw::Atof(argv[4]) << " classified OUTSIDE" << "\n";
7fd59977 230 }
231 }
232 return 0;
233}
234
7fd59977 235#include<BRepBuilderAPI_MakeVertex.hxx>
236#include<TCollection_ExtendedString.hxx>
237#include<AIS_LengthDimension.hxx>
238
239static Standard_Integer BUC60632(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
240{
241
242 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
243 if(myAIScontext.IsNull()) {
244 di << "use 'vinit' command before " << a[0] << "\n";
245 return -1;
246 }
247 myAIScontext->EraseAll();
248
249 TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(0,0,0));
250 TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10,10,0));
251
252 Handle(AIS_Shape) Ve1 = new AIS_Shape(V1);
253 Handle(AIS_Shape) Ve2 = new AIS_Shape(V2);
254
a6eb515f 255 myAIScontext->Display(Ve1);
256 myAIScontext->Display(Ve2);
7fd59977 257
258 Handle(Geom_Plane) Plane1 = new Geom_Plane(gp_Pnt(0,0,0),gp_Dir(0,0,1));
259 TCollection_ExtendedString Ext1("Dim1");
a6eb515f 260 Handle(AIS_LengthDimension) Dim1 = new AIS_LengthDimension(V1,V2,Plane1->Pln());
261 Dim1->SetCustomValue (Draw::Atof(a[2]));
262
263 Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
264 anAspect->MakeArrows3d (Standard_False);
265 anAspect->MakeText3d (Standard_True);
266 anAspect->MakeTextShaded (Standard_True);
267 anAspect->TextAspect()->SetHeight (2.5);
268 anAspect->ArrowAspect()->SetLength (1.0);
269 Dim1->SetDimensionAspect (anAspect);
270
91322f44 271 myAIScontext->SetDisplayMode(Dim1, Draw::Atoi(a[1]));
7fd59977 272 myAIScontext->Display(Dim1);
273 return 0;
274}
275
276#include<TopoDS_Wire.hxx>
277
278static Standard_Integer BUC60652(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
279{
280 if(argc!=2) {
281 di << "Usage : BUC60652 fase" << "\n";
282 return 1;
283 }
284 TopoDS_Shape shape = DBRep::Get( argv[1] );
285 TopoDS_Face face = TopoDS::Face( shape );
286 TopoDS_Wire ow = BRepTools::OuterWire( face );
287 DBRep::Set( "w", ow );
288 return 0;
289}
290
291#include <BRepAlgo_BooleanOperations.hxx>
292
293static Standard_Integer defNbPntMax = 30;
294static Standard_Real defTol3d = 1.e-7;
295static Standard_Real defTol2d = 1.e-7;
296static Standard_Boolean defRelativeTol=Standard_True;
297Standard_Integer NbPntMax = defNbPntMax;
298Standard_Real Toler3d =defTol3d;
299Standard_Real Toler2d = defTol2d;
300Standard_Boolean RelativeTol= defRelativeTol;
301// //== // ksection : operateur section appelant BRepAlgo_BooleanOperation
302//== // ksection : operateur section appelant BRepAlgo_BooleanOperations
303//=======================================================================
304Standard_Integer ksection(Draw_Interpretor& di, Standard_Integer n, const char ** a) {
305 if (n < 8) {
306 di << "Usage : " << a[0] << " resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol" << "\n";
307 return -1;
308 }
309 // a[1]= resultat
310 // a[2]= shell1
311 // a[3]= shell2
312 // a[4]= NbPntMax
313 // a[5]= Toler3d
314 // a[6]= Toler2d
315 // a[7]= RelativeTol
316 TopoDS_Shape s1 = DBRep::Get(a[2],TopAbs_SHELL);
317 TopoDS_Shape s2 = DBRep::Get(a[3],TopAbs_SHELL);
318 if (s1.IsNull() || s2.IsNull()) return 1;
91322f44 319 NbPntMax=Draw::Atoi(a[4]);
320 Toler3d=Draw::Atof(a[5]);
321 Toler2d=Draw::Atof(a[6]);
322 RelativeTol=Draw::Atoi(a[7]);
7fd59977 323
324 di << "BRepAlgo_BooleanOperations myalgo" << "\n";
325 BRepAlgo_BooleanOperations myalgo;
326
327 myalgo.Shapes(s1, s2);
328 myalgo.SetApproxParameters(NbPntMax,Toler3d,Toler2d,RelativeTol);
329 TopoDS_Shape res; res = myalgo.Section();
330 DBRep::Set(a[1],res);
331 return 0;
332}
333
334#include <Geom_Axis2Placement.hxx>
335#include <AIS_Trihedron.hxx>
336
337static Standard_Integer BUC60574(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
338{
339
340 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
341 if(myAISContext.IsNull()) {
342 di << "use 'vinit' command before " << a[0] << "\n";
343 return -1;
344 }
345
346 Handle(Geom_Axis2Placement) atrihedronAxis = new Geom_Axis2Placement(gp::XOY());
347 Handle(AIS_Trihedron) atri = new AIS_Trihedron(atrihedronAxis);
348 gp_Trsf aTrsf;
349 gp_Vec trans(5,5,5);
350 aTrsf.SetTranslation(trans);
351 TopLoc_Location aLoc(aTrsf);
352 myAISContext->SetLocation(atri,aLoc);
353 myAISContext->Display(atri,0,-1,Standard_True, Standard_True);
354 myAISContext->OpenLocalContext(Standard_False,
355 Standard_True,Standard_False,Standard_False);
356 myAISContext->Load(atri,3,Standard_True);
357
358 return 0;
359}
360
361#include <TopoDS_Solid.hxx>
362#include <BRepPrimAPI_MakeBox.hxx>
363#include <BRepPrimAPI_MakeSphere.hxx>
364
365#include <BRepAlgoAPI_Fuse.hxx>
366#include <BRepAlgo_Fuse.hxx>
367
7fd59977 368#include <V3d_View.hxx>
369#include <gce_MakePln.hxx>
370
7fd59977 371static Standard_Integer BUC60699(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
372{
373
374 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
375 if(myAISContext.IsNull()) {
376 di << "use 'vinit' command before " << a[0] << "\n";
377 return -1;
378 }
379 TopoDS_Solid B1 = BRepPrimAPI_MakeBox (1,1,1).Solid();
380 TopAbs_ShapeEnum theType = B1.ShapeType();
381 if ( theType == TopAbs_SOLID ) {
382 di << "It is a solid." << "\n";
383 } else {
384 di << "It is not solid." << "\n";
385 }
386 myAISContext->Display(new AIS_Shape(B1));
387 myAISContext->OpenLocalContext();
388 TopAbs_ShapeEnum amode = TopAbs_SOLID;
389 myAISContext->ActivateStandardMode(amode);
390 di.Eval("vfit");
391 di.Eval("QAMoveTo 200 200");
392 di.Eval("QASelect 200 200");
393 myAISContext->InitSelected() ;
394 if ( myAISContext->MoreSelected() ) {
395 if (myAISContext->HasSelectedShape() ) {
396 di << "has selected shape : OK" << "\n";
397 } else {
398 di << "has selected shape : bugged - Faulty " << "\n";
399 }
400 }
401 return 0;
402}
403
404static Standard_Integer GER61394(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
405{
406 if(argc > 2) {
407 di << "Usage : " << argv[0] << " [1/0]" << "\n";
408 return -1;
409 }
410
411 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
412 if(myAIScontext.IsNull()) {
413 di << "use 'vinit' command before " << argv[0] << "\n";
414 return -1;
415 }
416 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
417
91322f44 418 if((argc == 2) && (Draw::Atof(argv[1]) == 0))
7fd59977 419 myV3dView->SetAntialiasingOff();
420 else
421 myV3dView->SetAntialiasingOn();
422 myV3dView->Update();
423 return 0;
424}
425
426
427#define DEFAULT_COLOR Quantity_NOC_GOLDENROD
428
429//=======================================================================
430//function : GetColorFromName
431//purpose : get the Quantity_NameOfColor from a string
432//=======================================================================
433
434static Quantity_NameOfColor GetColorFromName( const char *name )
435{
436 Quantity_NameOfColor ret = DEFAULT_COLOR;
437
438 Standard_Boolean Found = Standard_False;
439 Standard_CString colstring;
440 for(Standard_Integer i=0;i<=514 && !Found;i++)
441 {
442 colstring = Quantity_Color::StringName(Quantity_NameOfColor(i));
443 if (!strcasecmp(name,colstring)) {
444 ret = (Quantity_NameOfColor)i;
445 Found = Standard_True;
446 }
447 }
448
449 return ret;
450}
451
452static Standard_Integer setcolor (Draw_Interpretor& di,Standard_Integer argc, const char ** argv )
453{
454
455Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
456if(myAISContext.IsNull()) {
457 di << "use 'vinit' command before " << argv[0] << "\n";
458 return -1;
459 }
460
461Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
462
463switch (argc){
464
465 case 2:
466 {
467 di <<"case 2 : This command will change the background color to " << argv[1]<< "\n";
468// setcolor <name>
469// Change the background color of the view with a predefined name Graphic3d_NOC_<name>
470
471 myV3dView -> SetBackgroundColor(GetColorFromName(argv[1]));
472 myV3dView -> Redraw();
473 break;
474 }
475
476 case 3:
477 {
478 di <<"case 3 : This command will change the color of the objects to "<< argv[2]<< "\n";
479// setcolor <object> <name>
480// Change the object color with a predefined name
481
482 TopoDS_Shape aShape = DBRep::Get(argv[1]);
483 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (aShape);
484 myAISContext->SetColor(myShape,GetColorFromName(argv[2]),Standard_True);
485 myAISContext->Display(myShape,Standard_True);
486 myAISContext->UpdateCurrentViewer();
487// return 0;
488 break;
489 }
490 case 4:
491 {
492 di <<"case 4 : This command will change the background color to <r> <g> <b> :"<< argv[1] << argv[2] << argv[3] << "\n";
493
494// setcolor <r> <g> <b>
495// Change the background color of the view with the color values <r>,<g>,<b>
496// A color value must be defined in the space [0.,1.]
497
91322f44 498 Standard_Real QuantityOfRed = Draw::Atoi(argv[1]);
499 Standard_Real QuantityOfGreen = Draw::Atoi(argv[2]);
500 Standard_Real QuantityOfBlue = Draw::Atoi(argv[3]);
7fd59977 501 myV3dView->SetBackgroundColor(Quantity_TOC_RGB,QuantityOfRed,QuantityOfGreen,QuantityOfBlue);
502 myV3dView->Redraw();
503 break;
504 }
505
506 case 5:
507 {
508 di <<"case 5 : This command will change the color of the objects to <r> <g> <b> : "<<argv[2]<< argv[3]<< argv[4]<< "\n";
509
510// setcolor <object> <r> <g> <b>
511// change the object color with RGB values.
512
513
91322f44 514 Standard_Real QuantityOfRed = Draw::Atof(argv[2]);
515 Standard_Real QuantityOfGreen = Draw::Atof(argv[3]);
516 Standard_Real QuantityOfBlue = Draw::Atof(argv[4]);
7fd59977 517
518 TopoDS_Shape aShape = DBRep::Get(argv[1]);
519 Handle(AIS_InteractiveObject) myShape = new AIS_Shape (aShape);
520 myAISContext->SetColor(myShape,Quantity_Color(QuantityOfRed,QuantityOfGreen,QuantityOfBlue,Quantity_TOC_RGB),Standard_True);
521 myAISContext->Display(myShape,Standard_True);
522 myAISContext->UpdateCurrentViewer();
523// myShape->SetColor(Quantity_Color(QuantityOfRed,QuantityOfGreen,QuantityOfBlue,Quantity_TOC_RGB));
524// myShape->Redisplay();
525 break;
526 }
527 }
528return 0;
529}
530
531static Standard_Integer BUC60726 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv )
532{
533 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
534 if(myAISContext.IsNull()) {
535 di << "use 'vinit' command before " << argv[0] << "\n";
536 return -1;
537 }
538
539 if(argc != 2) {
540 di << "Usage : " << argv[0] << " 0/1" << "\n";
541 }
542
91322f44 543 if(Draw::Atoi(argv[1]) == 0) {
7fd59977 544 myAISContext->CloseAllContexts();
545 BRepPrimAPI_MakeBox B(gp_Pnt(-400.,-400.,-100.),200.,150.,100.);
546 Handle(AIS_Shape) aBox = new AIS_Shape(B.Shape());
547 myAISContext->Display(aBox);
91322f44 548 } else if(Draw::Atoi(argv[1]) == 1) {
7fd59977 549 myAISContext->CloseAllContexts();
550 myAISContext->OpenLocalContext();
551 myAISContext->ActivateStandardMode(TopAbs_EDGE);
91322f44 552 } else if(Draw::Atoi(argv[1]) == 2) {
7fd59977 553 myAISContext->CloseAllContexts();
554 myAISContext->OpenLocalContext();
555 myAISContext->ActivateStandardMode(TopAbs_FACE);
556 } else {
557 di << "Usage : " << argv[0] << " 0/1" << "\n";
558 return -1;
559 }
560
561 return 0;
562}
563
564#include <BRepBndLib.hxx>
565#include <Bnd_HArray1OfBox.hxx>
566
35e08fe8 567static Standard_Integer BUC60729 (Draw_Interpretor& /*di*/,Standard_Integer /*argc*/, const char ** /*argv*/ )
7fd59977 568{
569 Bnd_Box aMainBox;
570 TopoDS_Shape aShape = BRepPrimAPI_MakeBox(1,1,1).Solid();
571
572 BRepBndLib::Add(aShape , aMainBox );
573
574 Standard_Integer siMaxNbrBox = 6;
575 Bnd_BoundSortBox m_BoundSortBox;
576 m_BoundSortBox.Initialize( aMainBox, siMaxNbrBox );
577 TopExp_Explorer aExplorer(aShape,TopAbs_FACE);
578 Standard_Integer i;
579
580
581// Bnd_Box __emptyBox; // Box is void !
582// Handle_Bnd_HArray1OfBox __aSetOfBox = new Bnd_HArray1OfBox( 1, siMaxNbrBox, __emptyBox );
583
584 for (i=1,aExplorer.ReInit(); aExplorer.More(); aExplorer.Next(),i++ )
585 {
586 const TopoDS_Shape& aFace = aExplorer.Current();
587 Bnd_Box aBox;
588 BRepBndLib::Add( aFace, aBox );
589 m_BoundSortBox.Add( aBox, i );
590// __aSetOfBox->SetValue( i, aBox );
591 }
592// m_BoundSortBox.Initialize( aMainBox, siMaxNbrBox );
593
594 return 0;
595}
596
597static Standard_Integer BUC60724(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/ )
598{
599 TCollection_AsciiString as1("");
600 TCollection_AsciiString as2('\0');
5cbfdb41 601 if(as1.ToCString() == NULL || as1.Length() != 0 || as1.ToCString()[0] != '\0')
602 di << "Error : the first string is not zero string : " << as1.ToCString() << "\n";
7fd59977 603
5cbfdb41 604 if(as2.ToCString() == NULL || as2.Length() != 0 || as2.ToCString()[0] != '\0')
605 di << "Error : the second string is not zero string : " << as2.ToCString() << "\n";
7fd59977 606
607 return 0;
608}
609
610#include <UnitsAPI.hxx>
611
612static Standard_Integer BUC60727(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/ )
613{
614di <<"Program Test" << "\n";
615UnitsAPI::SetLocalSystem(UnitsAPI_MDTV); //length is mm
616di <<"AnyToLS (3,mm) = " << UnitsAPI::AnyToLS(3.,"mm") << "\n"; // result was WRONG.
617
618 return 0;
619}
620
621#include <gp_Circ.hxx>
622#include <Geom_Circle.hxx>
623#include <GeomAPI.hxx>
624#include <Geom2d_CartesianPoint.hxx>
625#include <Geom2dGcc_QualifiedCurve.hxx>
626#include <Geom2dGcc_Circ2d2TanRad.hxx>
627#include <Geom2d_Circle.hxx>
628#include <ProjLib.hxx>
629
630static Standard_Integer BUC60792(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv )
631{
632 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
633 if(aContext.IsNull()) {
634 di << "use 'vinit' command before " << argv[0] << "\n";
635 return -1;
636 }
637
638 gp_Pnt pt3d(0, 20, 150);
639 gp_Ax2 anAx2(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0), gp_Dir(0, 0, 1));
640 gp_Circ circ(anAx2, 50.0);
641 Handle_Geom_Circle gcir = new Geom_Circle(circ);
642 Handle_Geom_Plane pln = new Geom_Plane(gp_Ax3(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)));
643 Handle_Geom2d_Curve gcir1 = GeomAPI::To2d(gcir, pln->Pln());
644 TopoDS_Shape sh1 = BRepBuilderAPI_MakeEdge(gcir1, pln).Shape();
645 Handle_AIS_Shape ais1 = new AIS_Shape(sh1);
646 aContext->SetColor(ais1, Quantity_NOC_INDIANRED);
647 aContext->Display(ais1);
648 DBRep::Set("sh0",sh1);
649 gp_Pnt2d thepoint;
650// local_get_2Dpointfrom3Dpoint(pt3d, pln->Pln(), thepoint);
651 thepoint = ProjLib::Project(pln->Pln(),pt3d);
652 Handle_Geom2d_CartesianPoint ThePoint = new Geom2d_CartesianPoint(thepoint);
653 Geom2dAdaptor_Curve acur1(gcir1) ;
654 Geom2dGcc_QualifiedCurve qcur1(acur1, GccEnt_outside) ;
655 Geom2dGcc_Circ2d2TanRad cirtanrad(qcur1, ThePoint, 200.0, 0.0001);
656 printf("\n No. of solutions = %d\n", cirtanrad.NbSolutions());
657 Handle_Geom2d_Circle gccc;
658 if( cirtanrad.NbSolutions() ) {
659 for( int i = 1; i<=cirtanrad.NbSolutions(); i++) {
660 gp_Circ2d ccc = cirtanrad.ThisSolution(i);
661 gccc = new Geom2d_Circle(ccc);
662 TopoDS_Shape sh = BRepBuilderAPI_MakeEdge(gccc, pln).Shape();
663 Standard_Character aStr[5];
91322f44 664 Sprintf(aStr,"sh%d",i);
7fd59977 665 DBRep::Set(aStr,sh);
666 Handle_AIS_Shape ais = new AIS_Shape(sh);
667 if( i ==1 )
668 aContext->SetColor(ais, Quantity_NOC_GREEN);
669 if( i == 2)
670 aContext->SetColor(ais, Quantity_NOC_HOTPINK);
671 aContext->Display(ais);
672 Standard_Real ParSol1, ParSol2, ParArg1, ParArg2;
673 gp_Pnt2d PntSol1, PntSol2;
674 cirtanrad.Tangency1(i, ParSol1, ParArg1, PntSol1);
675 printf("%f\t%f\t\t%f\t%f\n",ParSol1, ParArg1,PntSol1.X(),PntSol1.Y());
676 cirtanrad.Tangency2(i, ParSol2, ParArg2, PntSol2);
677 printf("%f\t%f\t\t%f\t%f\n",ParSol2, ParArg2,PntSol2.X(),PntSol2.Y());
678 }
679 }
680 return 0;
681}
682
683#include <TColgp_Array2OfPnt.hxx>
684#include <Geom_BezierSurface.hxx>
685#include <BRepBuilderAPI_MakeFace.hxx>
686#include <BRepBuilderAPI_MakeWire.hxx>
687#include <Geom_OffsetSurface.hxx>
688#include <BRepFilletAPI_MakeFillet2d.hxx>
689#include <GeomProjLib.hxx>
690#include <Geom_TrimmedCurve.hxx>
691
692static Standard_Integer BUC60811(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
693{
694 if(argc == 4) {
695 TopLoc_Location L1;
696 TopoDS_Edge aEdge = TopoDS::Edge(DBRep::Get(argv[2],TopAbs_EDGE));
697 TopoDS_Face aFace = TopoDS::Face(DBRep::Get(argv[3],TopAbs_FACE));
698 Standard_Real f = 0.0, l = 0.0;
699 Handle(Geom_Curve) GC = BRep_Tool::Curve(aEdge,f,l);
700 Handle(Geom_Surface) GS = BRep_Tool::Surface(aFace, L1);
701 GC = new Geom_TrimmedCurve(GC, f, l);
702 Handle(Geom_Curve) projCurve = GeomProjLib::Project(GC,GS);
703 BRepBuilderAPI_MakeWire *myWire;
704 myWire = new BRepBuilderAPI_MakeWire();
705 myWire->Add((BRepBuilderAPI_MakeEdge(projCurve)).Edge());
706 DBRep::Set(argv[1],myWire->Wire());
707 return 0;
708 }
709
710 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
711 if(aContext.IsNull()) {
712 di << "use 'vinit' command before " << argv[0] << "\n";
713 return -1;
714 }
715
716//step 1. creating a Bezier Surface and a patch
717 TopoDS_Face FP;
718 TopoDS_Shape FP1;
719 TopoDS_Solid solid;
720 Handle(AIS_Shape) ais1;
721 Handle_AIS_Shape ais2;
722 Handle(Geom_BezierSurface) BZ1;
723 TColgp_Array2OfPnt array1(1,3,1,3);
724 array1.SetValue(1,1,gp_Pnt(0,100,0));
725 array1.SetValue(1,2,gp_Pnt(200,100,0));
726 array1.SetValue(1,3,gp_Pnt(400,100,0));
727 array1.SetValue(2,1,gp_Pnt(0,200,100));
728 array1.SetValue(2,2,gp_Pnt(200,200,100));
729 array1.SetValue(2,3,gp_Pnt(400,200,100));
730 array1.SetValue(3,1,gp_Pnt(0,300,0));
731 array1.SetValue(3,2,gp_Pnt(200,300,0));
732 array1.SetValue(3,3,gp_Pnt(400,300,0));
733 BZ1 = new Geom_BezierSurface(array1);
1c72dff6 734 BRepBuilderAPI_MakeFace bzf1( BZ1, Precision::Confusion() );
7fd59977 735 TopoDS_Face F1= bzf1.Face();
736 ais1 = new AIS_Shape(F1);
737 DBRep::Set("F1",F1);
738 aContext->SetMaterial(ais1,Graphic3d_NOM_ALUMINIUM,Standard_False);
739 aContext->Display(ais1);
740 BRep_Builder B;
741 TopoDS_Shell shell;
742 B.MakeShell(shell);
743 B.Add(shell, bzf1);
744 B.MakeSolid(solid);
745 B.Add(solid,shell);
746 gp_Dir D(0, 0, 1.0f);
747 BRepBuilderAPI_MakeWire mkw;
748 gp_Pnt p1 = gp_Pnt(150., 150.0, 260.);
749 gp_Pnt p2 = gp_Pnt(350., 150., 260.);
750 BRepBuilderAPI_MakeEdge* E1 = new BRepBuilderAPI_MakeEdge(p1,p2);
751 mkw.Add(*E1);
752 p1 = gp_Pnt(350., 150., 260.);
753 p2 = gp_Pnt(350., 250., 260.);
754 BRepBuilderAPI_MakeEdge* E2 = new BRepBuilderAPI_MakeEdge(p1,p2);
755 mkw.Add(*E2);
756 p1 = gp_Pnt(350., 250., 260.);
757 p2 = gp_Pnt(300., 250.0, 260.);
758 BRepBuilderAPI_MakeEdge* E3 = new BRepBuilderAPI_MakeEdge(p1,p2);
759 mkw.Add(*E3);
760 p1 = gp_Pnt(300., 250.0, 260.);
761 p2 = gp_Pnt(200., 200.0, 260.);
762 BRepBuilderAPI_MakeEdge* E4 = new BRepBuilderAPI_MakeEdge(p1,p2);
763 mkw.Add(*E4);
764 p1 = gp_Pnt(200., 200.0, 260.);
765 p2 = gp_Pnt(150., 200.0, 260.);
766 BRepBuilderAPI_MakeEdge* E5 = new BRepBuilderAPI_MakeEdge(p1,p2);
767 mkw.Add(*E5);
768 p1 = gp_Pnt(150., 200.0, 260.);
769 p2 = gp_Pnt(150., 150.0, 260.);
770 BRepBuilderAPI_MakeEdge* E6 = new BRepBuilderAPI_MakeEdge(p1,p2);
771 mkw.Add(*E6);
772 FP = BRepBuilderAPI_MakeFace(mkw.Wire());
773 ais2 = new AIS_Shape( FP );
774 aContext->SetMaterial(ais2,Graphic3d_NOM_ALUMINIUM,Standard_False);
775 aContext->Display( ais2 );
776
777 DBRep::Set("FP",FP);
778
779//step 2. offseting the surface.
780 Handle_Geom_OffsetSurface offsurf;
781 offsurf = new Geom_OffsetSurface(BZ1, -100);
1c72dff6 782 BRepBuilderAPI_MakeFace bzf2( offsurf, Precision::Confusion() );
7fd59977 783 TopoDS_Face F2= bzf2.Face();
784 Handle_AIS_Shape ais22 = new AIS_Shape(F2);
785 aContext->Display(ais22);
786 DBRep::Set("F2",F2);
787
788//step 3. filleting the patch.
789//( I want to project wire of this patch on offseted surface above)
790 BRepFilletAPI_MakeFillet2d fillet( FP );
791 TopExp_Explorer Ex;
792 Ex.Init(FP, TopAbs_VERTEX);
793 TopoDS_Vertex v1 = TopoDS::Vertex(Ex.Current());
794 fillet.AddFillet(v1, 20);
c281a4a4 795 di << "\n" << "Error is " << fillet.Status() << "\n";
796// printf("\nError is %d ", fillet.Status());
7fd59977 797 Ex.Next();
798 TopoDS_Vertex V2 = TopoDS::Vertex(Ex.Current());
799 fillet.AddFillet(V2, 20);
c281a4a4 800 di << "\n" << "Error is " << fillet.Status() << "\n";
801// printf("\nError is %d ", fillet.Status());
7fd59977 802 fillet.Build();
803 FP1 = fillet.Shape();
804 ais2 = new AIS_Shape( FP1 );
805 aContext->SetMaterial(ais2,Graphic3d_NOM_ALUMINIUM,Standard_False);
806 aContext->Display( ais2 );
807
808 DBRep::Set("FP1",FP1);
809
810//step 4. Projecting the wire of this patch on offsetted surface.
811// TopExp_Explorer Ex;
812 BRepBuilderAPI_MakeWire *myWire;
813 myWire = new BRepBuilderAPI_MakeWire();
814 for (Ex.Init( FP1, TopAbs_EDGE); Ex.More(); Ex.Next())
815 {
816 TopoDS_Edge e1 = TopoDS::Edge(Ex.Current());
817 Standard_Real f = 0.0, l = 0.0;
818 Handle_Geom_Curve newBSplin = BRep_Tool::Curve(e1, f, l);
819 newBSplin = new Geom_TrimmedCurve(newBSplin, f, l);
820 Handle(Geom_Curve) projCurve = GeomProjLib::Project(newBSplin,offsurf);
821 myWire->Add((BRepBuilderAPI_MakeEdge(projCurve)).Edge());
822 }
823 Handle_AIS_Shape ais33 = new AIS_Shape( myWire->Wire() );
824 aContext->Display(ais33);
825
826 DBRep::Set("Wire",myWire->Wire());
827
828 return 0;
829}
830
831#include<GeomAPI_ExtremaCurveCurve.hxx>
832
833static int BUC60825(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
834
835{
836 if(argc < 3){
837 printf("Usage: %s edge1 edge2",argv[0]);
838 return(-1);
839 }
840
841 TopoDS_Edge E1 = TopoDS::Edge(DBRep::Get(argv[1])),
842 E2 = TopoDS::Edge(DBRep::Get(argv[2]));
843
844 Standard_Real fp , lp;
845
846 Handle(Geom_Curve) C1 = BRep_Tool::Curve(E1 , fp , lp),
847 C2 = BRep_Tool::Curve(E2 , fp , lp);
848
849 GeomAPI_ExtremaCurveCurve aExt(C1 , C2);
850
851 di << "NB RESULTS : " << aExt.NbExtrema() << "\n";
852
853 return 0;
854}
855
856#include <BRepBuilderAPI_MakePolygon.hxx>
857#include <BRepOffsetAPI_ThruSections.hxx>
858
859static int OCC10006(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
860{
861 if(argc > 2) {
862 di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
863 return 1;
864 }
865 Standard_Boolean IsBRepAlgoAPI = Standard_True;
866 if (argc == 2) {
91322f44 867 Standard_Integer IsB = Draw::Atoi(argv[1]);
7fd59977 868 if (IsB != 1) {
869 IsBRepAlgoAPI = Standard_False;
870#if ! defined(BRepAlgo_def01)
871// di << "Error: There is not BRepAlgo_Fuse class" << "\n";
872// return 1;
873#endif
874 }
875 }
876
877 double bottompoints1[12] = { 10, -10, 0, 100, -10, 0, 100, -100, 0, 10, -100, 0};
878 double toppoints1[12] = { 0, 0, 10, 100, 0, 10, 100, -100, 10, 0, -100, 10};
879 double bottompoints2[12] = { 0, 0, 10.00, 100, 0, 10.00, 100, -100, 10.00, 0, -100, 10.00};
880 double toppoints2[12] = { 0, 0, 250, 100, 0, 250, 100, -100, 250, 0, -100, 250};
881 BRepBuilderAPI_MakePolygon bottompolygon1, toppolygon1, bottompolygon2, toppolygon2;
882 gp_Pnt tmppnt;
883 for (int i=0;i<4;i++) {
884 tmppnt.SetCoord(bottompoints1[3*i], bottompoints1[3*i+1], bottompoints1[3*i+2]);
885 bottompolygon1.Add(tmppnt);
886 tmppnt.SetCoord(toppoints1[3*i], toppoints1[3*i+1], toppoints1[3*i+2]);
887 toppolygon1.Add(tmppnt);
888 tmppnt.SetCoord(bottompoints2[3*i], bottompoints2[3*i+1], bottompoints2[3*i+2]);
889 bottompolygon2.Add(tmppnt);
890 tmppnt.SetCoord(toppoints2[3*i], toppoints2[3*i+1], toppoints2[3*i+2]);
891 toppolygon2.Add(tmppnt);
892 }
893 bottompolygon1.Close();
894 DBRep::Set("B1",bottompolygon1.Shape());
895 toppolygon1.Close();
896 DBRep::Set("T1",toppolygon1.Shape());
897 bottompolygon2.Close();
898 DBRep::Set("B2",bottompolygon2.Shape());
899 toppolygon2.Close();
900 DBRep::Set("T2",toppolygon2.Shape());
901 BRepOffsetAPI_ThruSections loft1(Standard_True, Standard_True);
902 loft1.AddWire(bottompolygon1.Wire());
903 loft1.AddWire(toppolygon1.Wire());
904 loft1.Build();
905 BRepOffsetAPI_ThruSections loft2(Standard_True, Standard_True);
906 loft2.AddWire(bottompolygon2.Wire());
907 loft2.AddWire(toppolygon2.Wire());
908 loft2.Build();
909 if (loft1.Shape().IsNull() || loft2.Shape().IsNull())
910 return 1;
911 DBRep::Set("TS1",loft1.Shape());
912 DBRep::Set("TS2",loft2.Shape());
913
914//#if ! defined(BRepAlgoAPI_def01)
915// BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape());
916//#else
917// BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape());
918//#endif
919 if (IsBRepAlgoAPI) {
920 di << "BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape())" <<"\n";
921 BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape());
922 DBRep::Set("F",result.Shape());
923 } else {
924 di << "BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape())" <<"\n";
925 BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape());
926 DBRep::Set("F",result.Shape());
927 }
928
929// DBRep::Set("F",result.Shape());
930 return 0;
931}
932
933#include <Geom_RectangularTrimmedSurface.hxx>
934#include <GC_MakeTrimmedCone.hxx>
935
936static Standard_Integer BUC60856(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv )
937{
938 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
939 if(aContext.IsNull()) {
940 di << "use 'vinit' command before " << argv[0] << "\n";
941 return -1;
942 }
943
944 gp_Ax2 Cone_Ax;
302f96fb 945 double R1=8, R2=16, angle;
7fd59977 946 gp_Pnt P0(0,0,0),
947 P1(0,0,20), P2(0,0,45);
c6541a0c 948 angle = 2*M_PI;
7fd59977 949 Handle(Geom_RectangularTrimmedSurface) S = GC_MakeTrimmedCone (P1, P2, R1, R2).Value();
1c72dff6 950 TopoDS_Shape myshape = BRepBuilderAPI_MakeFace(S, Precision::Confusion()).Shape();
7fd59977 951 Handle(AIS_Shape) ais1 = new AIS_Shape(myshape);
952 aContext->Display(ais1);
953 aContext->SetColor(ais1, Quantity_NOC_BLUE1);
954
955 Handle(Geom_RectangularTrimmedSurface) S2 = GC_MakeTrimmedCone (P1, P2,R1, 0).Value();
1c72dff6 956 TopoDS_Shape myshape2 = BRepBuilderAPI_MakeFace(S2, Precision::Confusion()).Shape();
7fd59977 957 Handle(AIS_Shape) ais2 = new AIS_Shape(myshape2);
958 aContext->Display(ais2);
959 aContext->SetColor(ais2, Quantity_NOC_RED);
960 return 0;
961}
962
7fd59977 963//==========================================================================
964//function : CoordLoad
965// chargement d une face dans l explorer.
966//==========================================================================
64531d9c 967static Standard_Integer coordload (Draw_Interpretor& theDi,
968 Standard_Integer theArgsNb,
969 const char** theArgVec)
7fd59977 970{
64531d9c 971 if (theArgsNb < 3)
972 {
973 return 1;
974 }
975
976 std::ifstream aFile (theArgVec[2], ios::in);
977 if (!aFile)
978 {
979 theDi << "unable to open " << theArgVec[2] << " for input\n";
980 return 2;
981 }
982
983 char aLine[80];
984 memset (aLine, 0, 40);
985 aFile.getline (aLine, 80);
986
987 gp_Pnt aPnt (0.0, 0.0, 0.0);
988 aLine[40] = '\0';
989 aPnt.SetY (Draw::Atof (&aLine[20]));
990 aLine[20] = '\0';
991 aPnt.SetX (Draw::Atof (aLine));
992 TopoDS_Vertex aVert1 = BRepBuilderAPI_MakeVertex (aPnt);
993 BRepBuilderAPI_MakeWire aMakeWire;
994 for (;;)
995 {
996 memset (aLine, 0, 40);
997 aFile.getline (aLine, 80);
998 if (!aFile)
7fd59977 999 {
64531d9c 1000 break;
7fd59977 1001 }
7fd59977 1002
64531d9c 1003 aLine[40] = '\0';
1004 aPnt.SetY (Draw::Atof (&aLine[20]));
1005 aLine[20] = '\0';
1006 aPnt.SetX (Draw::Atof (aLine));
1007 TopoDS_Vertex aVert2 = BRepBuilderAPI_MakeVertex (aPnt);
1008 aMakeWire.Add (BRepBuilderAPI_MakeEdge (aVert1, aVert2));
1009 aVert1 = aVert2;
1010 }
1011 aFile.close();
7fd59977 1012
64531d9c 1013 if (!aMakeWire.IsDone())
1014 {
1015 DBRep::Set (theArgVec[1], TopoDS_Face());
1016 return 0;
7fd59977 1017 }
7fd59977 1018
64531d9c 1019 BRepBuilderAPI_MakeFace aMakeFace (aMakeWire.Wire());
1020 DBRep::Set (theArgVec[1], aMakeFace.IsDone() ? aMakeFace.Face() : TopoDS_Face());
7fd59977 1021 return 0;
1022}
7fd59977 1023
1024static Standard_Integer TestMem (Draw_Interpretor& /*di*/,
1025 Standard_Integer /*nb*/,
1026 const char ** /*arg*/)
1027{
1028 TCollection_ExtendedString aString(1024*1024, 'A');
1029 return 0;
1030}
1031
1032static Standard_Integer BUC60876_ (Draw_Interpretor& di,
1033 Standard_Integer argc,
1034 const char ** argv)
1035{
1036 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1037 if(aContext.IsNull()) {
1038 di << "use 'vinit' command before " << argv[0] << "\n";
1039 return -1;
1040 }
1041 if((argc != 2) && (argc != 3)) {
1042 di<< "usage : " << argv[0] << " shape [mode==1]" << "\n";
1043 return -1;
1044 }
1045 TopoDS_Shape aShape = DBRep::Get(argv[1]);
1046 Handle(AIS_InteractiveObject) anIO = new AIS_Shape(aShape);
1047// Handle(AIS_InteractiveObject) anIOa = ViewerTest::GetAISShapeFromName(argv[1]);
91322f44 1048 anIO->SetHilightMode((argc == 3) ? Draw::Atoi(argv[2]) : 1);
7fd59977 1049 aContext->Display(anIO);
1050 return 0;
1051}
1052
1053//=======================================================================
1054//function : buc60773
1055//purpose :
1056//=======================================================================
1057
1058#include<TCollection_HAsciiString.hxx>
1059
1060static Standard_Integer BUC60773 (Draw_Interpretor& /*di*/, Standard_Integer /*n*/, const char ** /*a*/)
1061{
1062 Handle(TCollection_HAsciiString) hAscii = new TCollection_HAsciiString();
1063 Standard_CString aStr = hAscii->ToCString();
1064 TCollection_AsciiString aAscii(aStr);
1065
1066 return 0;
1067}
1068
1069#include<BRepPrimAPI_MakeCylinder.hxx>
1070#include<BRepPrimAPI_MakeCone.hxx>
1071
1072static int TestCMD(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1073
1074{
1075 if(argc > 2) {
1076 di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1077 return 1;
1078 }
1079 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1080 if (argc == 2) {
91322f44 1081 Standard_Integer IsB = Draw::Atoi(argv[1]);
7fd59977 1082 if (IsB != 1) {
1083 IsBRepAlgoAPI = Standard_False;
1084#if ! defined(BRepAlgo_def01)
1085// di << "Error: There is not BRepAlgo_Fuse class" << "\n";
1086// return 1;
1087#endif
1088 }
1089 }
1090
1091 //Cylindre 36.085182 20.0 8.431413 88.04671 20.0 38.931416 10.0
1092
1093 Standard_Real x11 = 36.085182;
1094 Standard_Real y11 = 20.0;
1095 Standard_Real z11 = 8.431413;
1096 Standard_Real x12 = 88.04671;
1097 Standard_Real y12 = 20.0;
1098 Standard_Real z12 = 38.931416;
1099 Standard_Real radius = 10.0;
1100
1101 gp_Pnt base1(x11, y11, z11);
1102 gp_Dir vect1(x12-x11, y12-y11, z12-z11);
1103 gp_Ax2 axis1(base1, vect1);
1104 Standard_Real height1 = sqrt( ((x12-x11)*(x12-x11)) + ((y12-y11)*(y12-y11)) + ((z12-z11)*(z12-z11)) );
1105 BRepPrimAPI_MakeCylinder cylinder(axis1, radius, height1);
1106
1107 TopoDS_Shape SCyl = cylinder.Shape();
1108 DBRep::Set("cyl", SCyl);
1109
1110
1111 //Cone 70.7262 20.0 28.431412 105.36722 20.0 48.431416 6.0 3.0
1112 Standard_Real x21 = 70.7262;
1113 Standard_Real y21 = 20.0;
1114 Standard_Real z21 = 28.431412;
1115 Standard_Real x22 = 105.36722;
1116 Standard_Real y22 = 20.0;
1117 Standard_Real z22 = 48.431416;
1118 Standard_Real radius1 = 6.0;
1119 Standard_Real radius2 = 3.0;
1120
1121 gp_Pnt base2(x21, y21, z21);
1122 gp_Dir vect2(x22-x21, y22-y21, z22-z21);
1123 gp_Ax2 axis2(base2, vect2);
1124 Standard_Real height2 = sqrt( ((x22-x21)*(x22-x21)) + ((y22-y21)*(y22-y21)) + ((z22-z21)*(z22-z21)) );
1125 BRepPrimAPI_MakeCone cone(axis2, radius1, radius2, height2);
1126
1127 TopoDS_Shape SCon = cone.Shape();
1128 DBRep::Set("con", SCon);
1129
1130//#if ! defined(BRepAlgoAPI_def01)
1131// BRepAlgoAPI_Fuse SFuse(SCyl, SCon);
1132//#else
1133// BRepAlgo_Fuse SFuse(SCyl, SCon);
1134//#endif
1135//
1136// if(! SFuse.IsDone() )
1137// cout<<"Error: Boolean fuse operation failed !"<<endl;
1138//
1139// TopoDS_Shape fuse = SFuse.Shape();
1140
1141 TopoDS_Shape fuse;
1142 if (IsBRepAlgoAPI) {
1143 di << "BRepAlgoAPI_Fuse SFuse(SCyl, SCon)" <<"\n";
1144 BRepAlgoAPI_Fuse SFuse(SCyl, SCon);
1145 if(! SFuse.IsDone() )
1146 di<<"Error: Boolean fuse operation failed !"<<"\n";
1147 fuse = SFuse.Shape();
1148 } else {
1149 di << "BRepAlgo_Fuse SFuse(SCyl, SCon)" <<"\n";
1150 BRepAlgo_Fuse SFuse(SCyl, SCon);
1151 if(! SFuse.IsDone() )
1152 di<<"Error: Boolean fuse operation failed !"<<"\n";
1153 fuse = SFuse.Shape();
1154 }
1155
1156 DBRep::Set("fus", fuse);
1157
1158 return 0;
1159}
1160
1161#include <Dico_DictionaryOfInteger.hxx>
1162#include <TColStd_HSequenceOfAsciiString.hxx>
1163#include <TopExp.hxx>
1164#include <TopoDS_Iterator.hxx>
1165
1166//---------------------------------------------------------------------------------------
1167
1168static Standard_Integer statface (Draw_Interpretor& di,Standard_Integer /*argc*/, const char ** argv )
1169
1170{
1171 TopoDS_Shape aShape = DBRep::Get(argv[1]);
1172 if(aShape.IsNull())
1173 {
1174 di<<"Invalid input shape"<<"\n";
1175 return 1;
1176 }
1177 Handle(Dico_DictionaryOfInteger) aDico = new Dico_DictionaryOfInteger();
1178 Handle(TColStd_HSequenceOfAsciiString) aSequence = new TColStd_HSequenceOfAsciiString;
1179 Standard_CString aString;
302f96fb 1180 Standard_Integer i=1,j=1,l=1,aa=1;
7fd59977 1181 TopExp_Explorer expl;
1182 Standard_Real f3d,l3d;
1183 for(expl.Init(aShape,TopAbs_FACE);expl.More();expl.Next())
1184 {
1185 // SURFACES
1186 TopoDS_Face aFace = TopoDS::Face (expl.Current());
1187 Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace);
1188 aString = aSurface->DynamicType()->Name();
1189
1190 if(aDico->GetItem(aString,aa) != 0)
1191 {
1192 aDico->GetItem(aString,aa);
1193 aDico->SetItem(aString,aa+1);
1194 } else {
1195 aDico->SetItem(aString,1);
1196 aSequence->Append(aString);
1197 aa=1;
1198 i++;
1199 }
1200 }
1201 // PCURVES
1202 for(expl.Init(aShape,TopAbs_FACE);expl.More();expl.Next())
1203 {
1204 TopoDS_Face aFace = TopoDS::Face (expl.Current());
1205 TopoDS_Iterator anIt(aFace);
1206 TopoDS_Wire aWire = TopoDS::Wire (anIt.Value());
1207 TopoDS_Iterator it (aWire);
1208 for (; it.More(); it.Next()) {
1209 TopoDS_Edge Edge = TopoDS::Edge (it.Value());
1210 Handle(Geom2d_Curve) aCurve2d = BRep_Tool::CurveOnSurface(Edge,aFace,f3d,l3d);
1211 aString = aCurve2d->DynamicType()->Name();
1212 if(aDico->GetItem(aString,aa) != 0)
1213 {
1214 aDico->GetItem(aString,aa);
1215 aDico->SetItem(aString,aa+1);
1216 } else {
1217 aDico->SetItem(aString,1);
1218 aSequence->Append(aString);
1219 i++;
1220 aa=1;
1221 }
1222 }
1223 }
1224 // 3d CURVES
1225 TopExp_Explorer exp;
1226 for (exp.Init(aShape,TopAbs_EDGE); exp.More(); exp.Next())
1227 {
1228 TopoDS_Edge Edge = TopoDS::Edge (exp.Current());
1229 Handle(Geom_Curve) aCurve3d = BRep_Tool::Curve (Edge,f3d,l3d);
1230 if(aCurve3d.IsNull())
1231 {
1232 l++;
1233 goto aLabel;
1234 }
1235 aString = aCurve3d->DynamicType()->Name();
1236 if(aDico->GetItem(aString,aa) != 0)
1237 {
1238 aDico->GetItem(aString,aa);
1239 aDico->SetItem(aString,aa+1);
1240 } else {
1241 aDico->SetItem(aString,1);
1242 aSequence->Append(aString);
1243 i++;
1244 aa=1;
1245 }
1246 aLabel:;
1247 }
1248 // Output
1249 di<<"\n";
1250 for(j=1;j<i;j++)
1251 {
1252 aDico->GetItem(aSequence->Value(j),aa);
1253 di<<aa<<" -- "<<aSequence->Value(j).ToCString()<<"\n";
1254 }
1255
1256 di<<"\n";
1257 di<<"Degenerated edges :"<<"\n";
1258 di<<l<<" -- "<<"Degenerated edges "<<"\n";
1259
1260 return 0;
1261
1262}
1263
1264#include <BRepBuilderAPI_Transform.hxx>
1265
1266static Standard_Integer BUC60841(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
1267{
1268 if(argc > 2) {
1269 di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1270 return 1;
1271 }
1272 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1273 if (argc == 2) {
91322f44 1274 Standard_Integer IsB = Draw::Atoi(argv[1]);
7fd59977 1275 if (IsB != 1) {
1276 IsBRepAlgoAPI = Standard_False;
1277#if ! defined(BRepAlgo_def01)
1278// di << "Error: There is not BRepAlgo_Fuse class" << "\n";
1279// return 1;
1280#endif
1281 }
1282 }
1283
1284 gp_Ax2 Ax2 = gp_Ax2(gp_Pnt(0, 621, 78), gp_Dir(0, 1,0));
1285 BRepPrimAPI_MakeCylinder cyl(Ax2, 260, 150);
1286 //BRepPrimAPI_MakeCylinder cyl(gp_Ax2(gp_Pnt(0, 621, 78), gp_Dir(0, 1,0)), 260, 150);
1287
1288 TopoDS_Shape sh1 = cyl.Shape();
1289 DBRep::Set("sh1",sh1);
1290 gp_Trsf trsf1, trsf2;
1291 trsf1.SetTranslation(gp_Pnt(0.000000,700.000000,-170.000000),
1292 gp_Pnt(0.000000,700.000000,-95.000000));
1293 trsf2.SetRotation(gp_Ax1(gp_Pnt(0.000000,700.000000,-170.000000),
1294 gp_Dir(0.000000,0.000000,1.000000)), 0.436111);
1295 BRepBuilderAPI_Transform trans1(sh1, trsf1);
1296 TopoDS_Shape sh2 = trans1.Shape();
1297 DBRep::Set("sh2",sh2);
1298
1299//#if ! defined(BRepAlgoAPI_def01)
1300// BRepAlgoAPI_Fuse fuse1(sh1, sh2);
1301//#else
1302// BRepAlgo_Fuse fuse1(sh1, sh2);
1303//#endif
1304//
1305// TopoDS_Shape fsh1 = fuse1.Shape();
1306
1307 TopoDS_Shape fsh1;
1308 if (IsBRepAlgoAPI) {
1309 di << "BRepAlgoAPI_Fuse fuse1(sh1, sh2)" <<"\n";
1310 BRepAlgoAPI_Fuse fuse1(sh1, sh2);
1311 fsh1 = fuse1.Shape();
1312 } else {
1313 di << "BRepAlgo_Fuse fuse1(sh1, sh2)" <<"\n";
1314 BRepAlgo_Fuse fuse1(sh1, sh2);
1315 fsh1 = fuse1.Shape();
1316 }
1317
1318 DBRep::Set("fsh1",fsh1);
1319 BRepBuilderAPI_Transform trans2(fsh1, trsf2);
1320 TopoDS_Shape sh3 = trans2.Shape();
1321 DBRep::Set("sh3",sh3);
1322
1323//#if ! defined(BRepAlgoAPI_def01)
1324// BRepAlgoAPI_Fuse fuse2(fsh1,sh3);
1325//#else
1326// BRepAlgo_Fuse fuse2(fsh1,sh3);
1327//#endif
1328//
1329// TopoDS_Shape fsh2 = fuse2.Shape();
1330
1331 TopoDS_Shape fsh2;
1332 if (IsBRepAlgoAPI) {
1333 di << "BRepAlgoAPI_Fuse fuse2(fsh1,sh3)" <<"\n";
1334 BRepAlgoAPI_Fuse fuse2(fsh1,sh3);
1335 fsh2 = fuse2.Shape();
1336 } else {
1337 di << "BRepAlgo_Fuse fuse2(fsh1,sh3)" <<"\n";
1338 BRepAlgo_Fuse fuse2(fsh1,sh3);
1339 fsh2 = fuse2.Shape();
1340 }
1341
1342 DBRep::Set("fsh2",fsh2);
1343 Handle_AIS_Shape aisp1 = new AIS_Shape(fsh2);
1344// aContext->Display(aisp1);
1345 return 0;
1346}
1347
1348#include <ShapeBuild_Edge.hxx>
1349
1350static Standard_Integer BUC60874(Draw_Interpretor& /*di*/, Standard_Integer /*argc*/, const char ** argv )
1351{
1352 TopoDS_Edge e = TopoDS::Edge(DBRep::Get(argv[1],TopAbs_EDGE));
1353 ShapeBuild_Edge().BuildCurve3d(e);
1354 DBRep::Set("ED",e);
1355 return 0;
1356}
1357
1358
1359#include<TDF_Label.hxx>
1360#include<TDataStd_TreeNode.hxx>
1361
1362#include<DDocStd.hxx>
1363
1364#include<DDF.hxx>
1365
1366#include<TDocStd_Modified.hxx>
1367#include<TDF_ListIteratorOfDeltaList.hxx>
1368#include<TDocStd_Document.hxx>
1369#include<TDocStd_Application.hxx>
1370#include<TDF_Delta.hxx>
1371#include<TDataXtd_Constraint.hxx>
1372#include<TPrsStd_AISPresentation.hxx>
1373#include<TPrsStd_AISViewer.hxx>
1374#include<TNaming_Builder.hxx>
1375#include<TNaming_Naming.hxx>
1376#include<TNaming_NamedShape.hxx>
1377
1378static int BUC60817(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1379 if(argc!=2) {
1380 di << "Usage : " << argv[0] << " D" << "\n";
1381 di<<1;
1382 return 0;
1383 }
1384
1385 Handle(TDF_Data) DF;
1386 if (!DDF::GetDF(argv[1],DF)) {di<<2;return 0;}
1387
1388 TDF_Label L1,L2;
1389 Handle(TDataStd_TreeNode) TN1,TN2;
1390
1391 DDF::AddLabel(DF,"0:2",L1);
1392 TN1 = TDataStd_TreeNode::Set(L1);
1393
1394 DDF::AddLabel(DF,"0:3",L2);
1395 TN2 = TDataStd_TreeNode::Set(L2);
1396
1397 TN1->Append(TN2);
1398 if(!(TN2->IsDescendant(TN1))) {di<<3;return 0;}
1399 if((TN1->IsDescendant(TN2))) {di<<4;return 0;}
1400
1401 di<<0;
1402 return 0;
1403}
1404
1405static int BUC60831_1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1406 if(argc!=2) {
1407 di << "Usage : " << argv[0] << " D" << "\n";
1408 di<<-1;
1409 return 0;
1410 }
1411
1412 Handle(TDF_Data) DF;
1413 if (!DDF::GetDF(argv[1],DF)) {di<<-2;return 0;}
1414
1415 TDF_Label L;
1416 DDF::FindLabel(DF,"0:1",L,Standard_False);
1417 Handle(TDocStd_Modified) MDF;
1418 if (!L.Root().FindAttribute (TDocStd_Modified::GetID(), MDF)) {
1419 MDF = new TDocStd_Modified();
1420 L.Root().AddAttribute(MDF);
1421 }
1422
1423 di<<!MDF->IsEmpty();
1424 return 0;
1425}
1426
1427static int BUC60831_2(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1428 if(argc!=3) {
1429 di << "Usage : " << argv[0] << " D Label" << "\n";
1430 di<<1;
1431 return 0;
1432 }
1433
1434 Handle(TDF_Data) DF;
1435 if (!DDF::GetDF(argv[1],DF)) {di<<2;return 0;}
1436
1437 TDF_Label L;
1438 DDF::FindLabel(DF,argv[2],L,Standard_False);
1439
1440 TDocStd_Modified::Add(L);
1441
1442 di<<0;
1443 return 0;
1444}
1445
1446static int BUC60836(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1447 if(argc!=2) {
1448 di << "Usage : " << argv[0] << " D" << "\n";
1449 di<<1;
1450 return 0;
1451 }
1452
1453
1454 Handle(TDF_Data) aDF;
1455 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1456
1457 Handle(TDocStd_Document) aDocument;
1458 if (!DDocStd::GetDocument(argv[1], aDocument)) {di<<3;return 0;}
1459
1460 TDF_Label L;
1461 Handle(TDataStd_TreeNode) TN;
1462
1463 aDocument->NewCommand();
1464 DDF::AddLabel(aDF,"0:2",L);
1465 TN = TDataStd_TreeNode::Set(L);
1466
1467 aDocument->NewCommand();
1468 DDF::AddLabel(aDF,"0:3",L);
1469 TN = TDataStd_TreeNode::Set(L);
1470
1471 aDocument->NewCommand();
1472 DDF::AddLabel(aDF,"0:4",L);
1473 TN = TDataStd_TreeNode::Set(L);
1474 aDocument->NewCommand();
1475
1476 TDF_DeltaList Us,Rs;
1477 Us = aDocument->GetUndos();
1478 Rs = aDocument->GetUndos();
1479
1480 Standard_Integer i;
1481 char Names[10][5]={"n1","n2","n3","n4","n5","n6","n7","n8","n9","n10"};
1482
1483 TDF_ListIteratorOfDeltaList IDL;
1484 for(IDL.Initialize(Us),i=1;IDL.More();IDL.Next(),i++){
1485 Handle(TDF_Delta) D = IDL.Value();
1486 TCollection_ExtendedString S(Names[i-1]);
1487 D->SetName(S);
1488// cout<<" U"<<i<<"="<<D->Name()<<endl;
1489 }
1490
1491 aDocument->Undo();
1492 aDocument->Undo();
1493
1494 Us = aDocument->GetUndos();
1495 Rs = aDocument->GetRedos();
1496
1497 for(IDL.Initialize(Us),i=1;IDL.More();IDL.Next(),i++){
1498 Handle(TDF_Delta) D = IDL.Value();
1499// cout<<" U"<<i<<"="<<D->Name()<<endl;
1500 }
1501
1502 TCollection_ExtendedString n2name ("n2");
1503 for(IDL.Initialize(Rs),i=1;IDL.More();IDL.Next(),i++){
1504 Handle(TDF_Delta) D = IDL.Value();
1505 if ( i == 1 && ! D->Name().IsEqual (n2name) )
1506 {
1507 di << 4;
1508 return 0;
1509 }
1510 }
1511
1512 di<<0;
1513 return 0;
1514}
1515
1516static int BUC60847(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1517 if(argc!=3) {
1518 di << "Usage : " << argv[0] << " D Shape" << "\n";
1519 di<<1;
1520 return 0;
1521 }
1522
1523 Handle(TDF_Data) aDF;
1524 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1525
1526 TopoDS_Shape s = DBRep::Get(argv[2]);
1527 if (s.IsNull()) { di <<"shape not found"<< "\n"; di<<3;return 0;}
1528 TDF_Label L;
1529 DDF::AddLabel(aDF, "0:2", L);
1530 TNaming_Builder SI (L);
1531 SI.Generated(s);
1532
1533 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1534
1535 TNaming_Naming aNN;
1536 NS=aNN.Name(L,s,s);
1537// if (!NS->IsEmpty()) {di<<3;return 0;}
1538 if (NS->IsEmpty()) {di<<4;return 0;}
1539 di<<0;
1540 return 0;
1541}
1542
1543static int BUC60862(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1544 if(argc!=3) {
1545 di << "Usage : " << argv[0] << " D Shape" << "\n";
1546 di<<1;
1547 return 0;
1548 }
1549
1550 Handle(TDF_Data) aDF;
1551 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1552
1553 TopoDS_Shape s = DBRep::Get(argv[2]);
1554 if (s.IsNull()) { di <<"shape not found"<< "\n"; di<<3;return 0;}
1555 TDF_Label L;
1556 DDF::AddLabel(aDF, "0:2", L);
1557 TNaming_Builder SI (L);
1558 SI.Generated(s);
1559
1560 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1561
1562 TNaming_Naming aNN;
1563 NS=aNN.Name(L,s,s);
1564 if (NS->IsEmpty()) {di<<4;return 0;}
1565 di<<0;
1566 return 0;
1567}
1568
1569static int BUC60867(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1570 if (argc == 2) {
1571 TCollection_ExtendedString path (argv[1]);
1572 Handle(TDocStd_Application) A;
1573 if (!DDocStd::Find(A)) {di<<1;return 0;}
1574 Handle(TDocStd_Document) D;
1575 Standard_Integer insession = A->IsInSession(path);
1576 if (insession > 0) {
1577 di <<"document " << insession << " is already in session" << "\n";
1578 di<<2;
1579 return 0;
1580 }
15e8b082
M
1581 PCDM_ReaderStatus Result = A->Open(path,D);
1582 if(Result==PCDM_RS_OK){
7fd59977 1583 di<<0;
1584 return 0;
1585 }
1586 }
1587 di<<3;
1588 return 0;
1589}
1590
1591static int BUC60910(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1592 if(argc!=2) {
1593 di << "Usage : " << argv[0] << " D" << "\n";
1594 di<<1;
1595 return 0;
1596 }
1597
1598 Handle(TDF_Data) aDF;
1599 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1600
1601 TDF_Label L;
1602 DDF::AddLabel(aDF, "0:2", L);
1603
1604 Handle(TPrsStd_AISPresentation) AISP = new TPrsStd_AISPresentation;
1605
1606 AISP->Set(L,TDataXtd_Constraint::GetID());
1607
1608 if (AISP->HasOwnMode()) {di<<3;return 0;}
1609 AISP->SetMode(3);
1610 Standard_Integer Mode = AISP->Mode();
1611 if (Mode!=3) {di<<4;return 0;}
1612 if (!AISP->HasOwnMode()) {di<<5;return 0;}
1613 AISP->UnsetMode();
1614 if (AISP->HasOwnMode()) {di<<6;return 0;}
1615 di<<0;
1616 return 0;
1617}
1618
1619static int BUC60925(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1620 if(argc!=2) {
1621 di << "Usage : " << argv[0] << " D" << "\n";
1622 di<<1;
1623 return 0;
1624 }
1625
1626 Handle(TDF_Data) aDF;
1627 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1628
1629 TDF_Label L;
1630 DDF::AddLabel(aDF, "0:2", L);
1631 TDF_LabelMap LM;
1632 LM.Add(L);
1633
1634 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1635// Handle(TNaming_Name) NN = new TNaming_Name;
1636 TNaming_Name NN;
1637
1638 NN.Type(TNaming_IDENTITY);
1639 NN.Append(NS);
1640 Standard_Boolean Res = NN.Solve(L,LM);
1641
1642 if (Res!=Standard_False) {di<<3;return 0;}
1643 di<<0;
1644 return 0;
1645}
1646
1647static int BUC60932(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1648 if(argc!=2) {
1649 di << "Usage : " << argv[0] << " D" << "\n";
1650 di<<1;
1651 return 0;
1652 }
1653
1654
1655 Handle(TDocStd_Document) aDocument;
1656 if (!DDocStd::GetDocument(argv[1], aDocument)) {di<<2;return 0;}
1657
1658 if(!aDocument->InitDeltaCompaction()) {di<<3;return 0;}
1659 if(!aDocument->PerformDeltaCompaction()) {di<<4;return 0;}
1660
1661 di<<0;
1662 return 0;
1663}
1664
1665//=======================================================================
1666//function : AISWidth
1667//purpose : AISWidth (DOC,entry,[width])
1668// abv: testing command for checking bug BUC60917 in TPrsStd_AISPresentation
1669//=======================================================================
1670
1671static int AISWidth(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1672
1673 if (argc >= 3) {
1674 Handle(TDocStd_Document) D;
1675 if (!DDocStd::GetDocument(argv[1],D)) {di<<(-1);return 0;}
1676 TDF_Label L;
1677 if (!DDF::FindLabel(D->GetData(),argv[2],L)) {di<<(-2);return 0;}
1678
1679 Handle(TPrsStd_AISViewer) viewer;
1680 if( !TPrsStd_AISViewer::Find(L, viewer) ) {di<<(-3);return 0;}
1681
1682 Handle(TPrsStd_AISPresentation) prs;
1683 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1684 if( argc == 4 ) {
91322f44 1685 prs->SetWidth(Draw::Atof(argv[3]));
7fd59977 1686 TPrsStd_AISViewer::Update(L);
1687 }
1688 else {
1689 if (prs->HasOwnWidth()){
1690// cout << "Width = " << prs->Width() << endl;
1691 di<<prs->Width();
1692 }
1693 else{
1694 di << "AISWidth: Warning : Width wasn't set" << "\n";
1695 di<<(-4);
1696 }
1697 }
1698 return 0;
1699 }
1700 }
1701 di << "AISWidth : Error" << "\n";
1702 di<<(-5);
1703 return 0;
1704}
1705
1706//=======================================================================
1707//function : BUC60921 ( & BUC60954 )
1708//purpose : Test memory allocation of OCAF in Undo/Redo operations
1709//=======================================================================
1710
1711static Standard_Integer BUC60921 (Draw_Interpretor& di,
1712 Standard_Integer nb,
1713 const char ** arg)
1714{
1715 if (nb >= 4) {
1716 Handle(TDocStd_Document) D;
1717 if (!DDocStd::GetDocument(arg[1],D)) {di<<1;return 0;}
1718 TDF_Label L;
1719 DDF::AddLabel(D->GetData(),arg[2],L);
1720
1721 BRep_Builder B;
1722 TopoDS_Shape S;
1723 BRepTools::Read ( S, arg[3], B );
1724
1725 TNaming_Builder tnBuild(L);
1726 tnBuild.Generated(S);
1727// di << "File " << arg[3] << " added";
1728 di<<0;
1729 return 0;
1730 }
1731 di << "BUC60921 Doc label brep_file: directly read brep file and put shape to the label" << "\n";
1732 di<<2;
1733 return 0;
1734}
1735
1736#include<IGESControl_Reader.hxx>
1737#include<BRepPrimAPI_MakeHalfSpace.hxx>
1738
1739static Standard_Integer BUC60951_(Draw_Interpretor& di, Standard_Integer argc, const char ** a)
1740{
1741 //if(argc!=2)
1742 // {
1743 // cerr << "Usage : " << a[0] << " file.igs" << endl;
1744 // return -1;
1745 // }
1746 if(argc < 2 || argc > 3) {
1747 di << "Usage : " << a[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n";
1748 return 1;
1749 }
1750 Standard_Boolean IsBRepAlgoAPI = Standard_True;
1751 if (argc == 3) {
91322f44 1752 Standard_Integer IsB = Draw::Atoi(a[2]);
7fd59977 1753 if (IsB != 1) {
1754 IsBRepAlgoAPI = Standard_False;
1755#if ! defined(BRepAlgo_def01)
1756// di << "Error: There is not BRepAlgo_Fuse class" << "\n";
1757// return 1;
1758#endif
1759 }
1760 }
1761
1762 Handle(AIS_InteractiveContext) myContext = ViewerTest::GetAISContext();
1763
1764 if(myContext.IsNull()) {
1765 di << "use 'vinit' command before " << a[0] << "\n";
1766 return -1;
1767 }
1768
1769// IGESControlStd_Reader reader;
1770 IGESControl_Reader reader;
1771 reader.ReadFile(a[1]);
1772 reader.TransferRoots();
1773 TopoDS_Shape shape = reader.OneShape();
1774 printf("\n iges1 shape type = %d", shape.ShapeType() );
1775 TopTools_IndexedMapOfShape list;
1776 TopExp::MapShapes(shape, TopAbs_FACE, list);
1777 printf("\n No. of faces = %d", list.Extent());
1778
1779 TopoDS_Shell shell;
1780 BRep_Builder builder;
1781 builder.MakeShell(shell);
1782 for(int i=1;i<=list.Extent(); i++) {
1783 TopoDS_Face face = TopoDS::Face(list.FindKey(i));
1784 builder.Add(shell, face);
1785 }
1786
1787 BRepPrimAPI_MakeHalfSpace half(shell, gp_Pnt(0, 0, 20));
1788 TopoDS_Solid sol = half.Solid();
1789 gp_Ax2 anAx2(gp_Pnt(-800.0, 0.0, 0), gp_Dir(0, 0, -1));
1790 BRepPrimAPI_MakeCylinder cyl(anAx2, 50, 300);
1791 TopoDS_Shape sh = cyl.Shape();
1792
1793//#if ! defined(BRepAlgoAPI_def01)
1794// BRepAlgoAPI_Fuse fuse(sol, sh);
1795//#else
1796// BRepAlgo_Fuse fuse(sol, sh);
1797//#endif
1798//
1799// sh = fuse.Shape();
1800
1801 if (IsBRepAlgoAPI) {
1802 di << "BRepAlgoAPI_Fuse fuse(sol, sh)" <<"\n";
1803 BRepAlgoAPI_Fuse fuse(sol, sh);
1804 sh = fuse.Shape();
1805 } else {
1806 di << "BRepAlgo_Fuse fuse(sol, sh)" <<"\n";
1807 BRepAlgo_Fuse fuse(sol, sh);
1808 sh = fuse.Shape();
1809 }
1810
1811 Handle(AIS_Shape) res = new AIS_Shape(sh);
1812 myContext->Display( res );
1813 return 0;
1814}
1815
1cd84fee 1816void QABugs::Commands_3(Draw_Interpretor& theCommands) {
1817 const char *group = "QABugs";
7fd59977 1818
1819 theCommands.Add("BUC60623","BUC60623 result Shape1 Shape2",__FILE__,BUC60623,group);
1820 theCommands.Add("BUC60569","BUC60569 shape",__FILE__,BUC60569,group);
1821 theCommands.Add("BUC60614","BUC60614 shape",__FILE__,BUC60614,group);
ceeaafcb 1822 theCommands.Add("BUC60609","BUC60609 shape name [U V]",__FILE__,BUC60609,group);
7fd59977 1823 theCommands.Add("BUC60632","BUC60632 mode length",__FILE__,BUC60632,group);
1824 theCommands.Add("BUC60652","BUC60652 face",__FILE__,BUC60652,group);
1825 theCommands.Add("ksection","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);
1826 theCommands.Add("BUC60682","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);
1827 theCommands.Add("BUC60669","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);
1828 theCommands.Add("PRO19626","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group);
1829 theCommands.Add("BUC60574","BUC60574 ",__FILE__,BUC60574,group);
1830
7fd59977 1831 theCommands.Add("BUC60699","BUC60699 ",__FILE__,BUC60699,group);
1832 theCommands.Add("GER61394","GER61394 [1/0]",__FILE__,GER61394,group);
1833 theCommands.Add("GER61351","GER61351 name/object name/r g b/object r g b",__FILE__,setcolor,group);
1834 theCommands.Add("setcolor","setcolor name/object name/r g b/object r g b",__FILE__,setcolor,group);
1835
1836 theCommands.Add("BUC60726","BUC60726 0/1",__FILE__,BUC60726,group);
1837 theCommands.Add("BUC60729","BUC60729",__FILE__,BUC60729,group);
1838 theCommands.Add("BUC60724","BUC60724",__FILE__,BUC60724,group);
1839 theCommands.Add("BUC60727","BUC60727",__FILE__,BUC60727,group);
1840 theCommands.Add("BUC60792","BUC60792",__FILE__,BUC60792,group);
1841 theCommands.Add("BUC60811","BUC60811",__FILE__,BUC60811,group);
1842
1843 theCommands.Add("BUC60825","BUC60825",__FILE__,BUC60825,group);
1844
1845 theCommands.Add("OCC10006","OCC10006 [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,OCC10006,group);
1846
1847 theCommands.Add("BUC60856","BUC60856",__FILE__,BUC60856,group);
1848
7fd59977 1849 theCommands.Add("coordload","load coord from file",__FILE__,coordload);
7fd59977 1850
1851 theCommands.Add("TestMem","TestMem",__FILE__,TestMem,group);
1852 theCommands.Add("BUC60945","BUC60945",__FILE__,TestMem,group);
1853 theCommands.Add("BUC60876","BUC60876 shape",__FILE__,BUC60876_,group);
1854 theCommands.Add("BUC60773","BUC60773",__FILE__,BUC60773,group);
1855
1856 theCommands.Add("TestCMD","TestCMD [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,TestCMD,group);
1857
1858 theCommands.Add("statface","statface face",__FILE__,statface,group);
1859
1860 theCommands.Add("BUC60841","BUC60841 [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,BUC60841,group);
1861
1862 theCommands.Add("BUC60874","BUC60874",__FILE__,BUC60874,group);
1863
1864 theCommands.Add("BUC60817","BUC60817 D",__FILE__,BUC60817,group);
1865 theCommands.Add("BUC60831_1","BUC60831_1 D",__FILE__,BUC60831_1,group);
1866 theCommands.Add("BUC60831_2","BUC60831_2 D Label",__FILE__,BUC60831_2,group);
1867 theCommands.Add("BUC60836","BUC60836 D",__FILE__,BUC60836,group);
1868 theCommands.Add("BUC60847","BUC60847 D Shape",__FILE__,BUC60847,group);
1869 theCommands.Add("BUC60862","BUC60862 D Shape",__FILE__,BUC60862,group);
1870 theCommands.Add("BUC60867","BUC60867",__FILE__,BUC60867,group);
1871 theCommands.Add("BUC60910","BUC60910 D",__FILE__,BUC60910,group);
1872 theCommands.Add("BUC60925","BUC60925 D",__FILE__,BUC60925,group);
1873 theCommands.Add("BUC60932","BUC60932 D",__FILE__,BUC60932,group);
1874 theCommands.Add("AISWidth","AISWidth (DOC,entry,[width])",__FILE__,AISWidth,group);
1875 theCommands.Add("BUC60921","BUC60921 Doc label brep_file",__FILE__,BUC60921,group);
1876
1877 theCommands.Add("BUC60951","BUC60951 file.igs [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,BUC60951_, group );
1878
1879}