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