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