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