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