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