0031459: Visualization, AIS_TextLabel - add missing getters
[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>
68dcee02 29#include <ViewerTest.hxx>
30#include <AIS_Shape.hxx>
7fd59977 31
64531d9c 32#include <fstream>
33
7fd59977 34static int BUC60623(Draw_Interpretor& di, Standard_Integer argc, const char ** a)
35{
36 if(argc!=4)
37 {
586db386 38 di << "Usage : " << a[0] << " result Shape1 Shape2\n";
7fd59977 39 return -1;
40 }
41
42 TopLoc_Location L1;
43 TopLoc_Location L2;
44 TopoDS_Face F1 = TopoDS::Face(DBRep::Get(a[2],TopAbs_FACE));
45 TopoDS_Face F2 = TopoDS::Face(DBRep::Get(a[3],TopAbs_FACE));
46 Handle(Geom_Surface) GSF1 = BRep_Tool::Surface(F1, L1);
47 Handle(Geom_Surface) GSF2 = BRep_Tool::Surface(F2, L2);
48 GeomInt_IntSS Inter;
49 Inter.Perform(GSF1,GSF2, BRep_Tool::Tolerance(F1));
50 if (!Inter.IsDone()) {
586db386 51 di << "Intersection not done\n";
7fd59977 52 return 1;
53 }
54 Standard_Integer nbsol = Inter.NbLines();
55 if(!nbsol) {
56 di << "The number of solutions is zero!" << "\n";
57 return 0;
58 }
59 Handle(Geom_Curve) Sol = Inter.Line(1);
60 if(!Sol.IsNull()) {
61 DBRep::Set(a[1], BRepBuilderAPI_MakeEdge(Sol));
62 return 0;
63 } else di << "The first solution is Null!" << "\n";
64
586db386 65 di << "fini\n";
7fd59977 66 return 0;
67}
68
7fd59977 69#include<BRepBuilderAPI_MakeVertex.hxx>
70#include<TCollection_ExtendedString.hxx>
68dcee02 71#include<AIS_InteractiveContext.hxx>
7fd59977 72#include<AIS_LengthDimension.hxx>
73
74static Standard_Integer BUC60632(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
75{
76
77 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
78 if(myAIScontext.IsNull()) {
79 di << "use 'vinit' command before " << a[0] << "\n";
80 return -1;
81 }
0577ae8c 82 myAIScontext->EraseAll (Standard_False);
7fd59977 83
84 TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(0,0,0));
85 TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10,10,0));
86
87 Handle(AIS_Shape) Ve1 = new AIS_Shape(V1);
88 Handle(AIS_Shape) Ve2 = new AIS_Shape(V2);
89
0577ae8c 90 myAIScontext->Display (Ve1, Standard_False);
91 myAIScontext->Display (Ve2, Standard_False);
7fd59977 92
93 Handle(Geom_Plane) Plane1 = new Geom_Plane(gp_Pnt(0,0,0),gp_Dir(0,0,1));
94 TCollection_ExtendedString Ext1("Dim1");
a6eb515f 95 Handle(AIS_LengthDimension) Dim1 = new AIS_LengthDimension(V1,V2,Plane1->Pln());
96 Dim1->SetCustomValue (Draw::Atof(a[2]));
97
98 Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
99 anAspect->MakeArrows3d (Standard_False);
100 anAspect->MakeText3d (Standard_True);
101 anAspect->MakeTextShaded (Standard_True);
102 anAspect->TextAspect()->SetHeight (2.5);
103 anAspect->ArrowAspect()->SetLength (1.0);
104 Dim1->SetDimensionAspect (anAspect);
105
0577ae8c 106 myAIScontext->SetDisplayMode (Dim1, Draw::Atoi(a[1]), Standard_False);
107 myAIScontext->Display (Dim1, Standard_True);
7fd59977 108 return 0;
109}
110
111#include<TopoDS_Wire.hxx>
2d0621bf 112#include <BRepTools.hxx>
7fd59977 113
114static Standard_Integer BUC60652(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
115{
116 if(argc!=2) {
117 di << "Usage : BUC60652 fase" << "\n";
118 return 1;
119 }
120 TopoDS_Shape shape = DBRep::Get( argv[1] );
121 TopoDS_Face face = TopoDS::Face( shape );
122 TopoDS_Wire ow = BRepTools::OuterWire( face );
123 DBRep::Set( "w", ow );
124 return 0;
125}
126
7fd59977 127#include <TopoDS_Solid.hxx>
128#include <BRepPrimAPI_MakeBox.hxx>
129#include <BRepPrimAPI_MakeSphere.hxx>
130
131#include <BRepAlgoAPI_Fuse.hxx>
7fd59977 132
7fd59977 133#include <V3d_View.hxx>
134#include <gce_MakePln.hxx>
135
e45b5ff7 136#include <Bnd_BoundSortBox.hxx>
7fd59977 137#include <BRepBndLib.hxx>
138#include <Bnd_HArray1OfBox.hxx>
2d0621bf 139#include <TopExp_Explorer.hxx>
140
35e08fe8 141static Standard_Integer BUC60729 (Draw_Interpretor& /*di*/,Standard_Integer /*argc*/, const char ** /*argv*/ )
7fd59977 142{
143 Bnd_Box aMainBox;
144 TopoDS_Shape aShape = BRepPrimAPI_MakeBox(1,1,1).Solid();
145
146 BRepBndLib::Add(aShape , aMainBox );
147
148 Standard_Integer siMaxNbrBox = 6;
149 Bnd_BoundSortBox m_BoundSortBox;
150 m_BoundSortBox.Initialize( aMainBox, siMaxNbrBox );
151 TopExp_Explorer aExplorer(aShape,TopAbs_FACE);
152 Standard_Integer i;
153
154
155// Bnd_Box __emptyBox; // Box is void !
857ffd5e 156// Handle(Bnd_HArray1OfBox) __aSetOfBox = new Bnd_HArray1OfBox( 1, siMaxNbrBox, __emptyBox );
7fd59977 157
158 for (i=1,aExplorer.ReInit(); aExplorer.More(); aExplorer.Next(),i++ )
159 {
160 const TopoDS_Shape& aFace = aExplorer.Current();
161 Bnd_Box aBox;
162 BRepBndLib::Add( aFace, aBox );
163 m_BoundSortBox.Add( aBox, i );
164// __aSetOfBox->SetValue( i, aBox );
165 }
166// m_BoundSortBox.Initialize( aMainBox, siMaxNbrBox );
167
168 return 0;
169}
170
171static Standard_Integer BUC60724(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/ )
172{
173 TCollection_AsciiString as1("");
174 TCollection_AsciiString as2('\0');
5cbfdb41 175 if(as1.ToCString() == NULL || as1.Length() != 0 || as1.ToCString()[0] != '\0')
176 di << "Error : the first string is not zero string : " << as1.ToCString() << "\n";
7fd59977 177
5cbfdb41 178 if(as2.ToCString() == NULL || as2.Length() != 0 || as2.ToCString()[0] != '\0')
179 di << "Error : the second string is not zero string : " << as2.ToCString() << "\n";
7fd59977 180
181 return 0;
182}
183
184#include <UnitsAPI.hxx>
185
186static Standard_Integer BUC60727(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/ )
187{
586db386 188di <<"Program Test\n";
7fd59977 189UnitsAPI::SetLocalSystem(UnitsAPI_MDTV); //length is mm
190di <<"AnyToLS (3,mm) = " << UnitsAPI::AnyToLS(3.,"mm") << "\n"; // result was WRONG.
191
192 return 0;
193}
194
195#include <gp_Circ.hxx>
196#include <Geom_Circle.hxx>
197#include <GeomAPI.hxx>
198#include <Geom2d_CartesianPoint.hxx>
199#include <Geom2dGcc_QualifiedCurve.hxx>
200#include <Geom2dGcc_Circ2d2TanRad.hxx>
201#include <Geom2d_Circle.hxx>
202#include <ProjLib.hxx>
203
204static Standard_Integer BUC60792(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv )
205{
206 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
207 if(aContext.IsNull()) {
208 di << "use 'vinit' command before " << argv[0] << "\n";
209 return -1;
210 }
211
212 gp_Pnt pt3d(0, 20, 150);
213 gp_Ax2 anAx2(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0), gp_Dir(0, 0, 1));
214 gp_Circ circ(anAx2, 50.0);
857ffd5e 215 Handle(Geom_Circle) gcir = new Geom_Circle(circ);
216 Handle(Geom_Plane) pln = new Geom_Plane(gp_Ax3(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)));
217 Handle(Geom2d_Curve) gcir1 = GeomAPI::To2d(gcir, pln->Pln());
7fd59977 218 TopoDS_Shape sh1 = BRepBuilderAPI_MakeEdge(gcir1, pln).Shape();
857ffd5e 219 Handle(AIS_Shape) ais1 = new AIS_Shape(sh1);
0577ae8c 220 aContext->SetColor (ais1, Quantity_NOC_INDIANRED, Standard_False);
221 aContext->Display (ais1, Standard_False);
7fd59977 222 DBRep::Set("sh0",sh1);
223 gp_Pnt2d thepoint;
224// local_get_2Dpointfrom3Dpoint(pt3d, pln->Pln(), thepoint);
225 thepoint = ProjLib::Project(pln->Pln(),pt3d);
857ffd5e 226 Handle(Geom2d_CartesianPoint) ThePoint = new Geom2d_CartesianPoint(thepoint);
7fd59977 227 Geom2dAdaptor_Curve acur1(gcir1) ;
228 Geom2dGcc_QualifiedCurve qcur1(acur1, GccEnt_outside) ;
229 Geom2dGcc_Circ2d2TanRad cirtanrad(qcur1, ThePoint, 200.0, 0.0001);
230 printf("\n No. of solutions = %d\n", cirtanrad.NbSolutions());
857ffd5e 231 Handle(Geom2d_Circle) gccc;
7fd59977 232 if( cirtanrad.NbSolutions() ) {
233 for( int i = 1; i<=cirtanrad.NbSolutions(); i++) {
234 gp_Circ2d ccc = cirtanrad.ThisSolution(i);
235 gccc = new Geom2d_Circle(ccc);
236 TopoDS_Shape sh = BRepBuilderAPI_MakeEdge(gccc, pln).Shape();
237 Standard_Character aStr[5];
91322f44 238 Sprintf(aStr,"sh%d",i);
7fd59977 239 DBRep::Set(aStr,sh);
857ffd5e 240 Handle(AIS_Shape) ais = new AIS_Shape(sh);
7fd59977 241 if( i ==1 )
0577ae8c 242 aContext->SetColor (ais, Quantity_NOC_GREEN, Standard_False);
7fd59977 243 if( i == 2)
0577ae8c 244 aContext->SetColor (ais, Quantity_NOC_HOTPINK, Standard_False);
245 aContext->Display (ais, Standard_False);
7fd59977 246 Standard_Real ParSol1, ParSol2, ParArg1, ParArg2;
247 gp_Pnt2d PntSol1, PntSol2;
248 cirtanrad.Tangency1(i, ParSol1, ParArg1, PntSol1);
249 printf("%f\t%f\t\t%f\t%f\n",ParSol1, ParArg1,PntSol1.X(),PntSol1.Y());
250 cirtanrad.Tangency2(i, ParSol2, ParArg2, PntSol2);
251 printf("%f\t%f\t\t%f\t%f\n",ParSol2, ParArg2,PntSol2.X(),PntSol2.Y());
252 }
253 }
0577ae8c 254 aContext->UpdateCurrentViewer();
7fd59977 255 return 0;
256}
257
258#include <TColgp_Array2OfPnt.hxx>
259#include <Geom_BezierSurface.hxx>
260#include <BRepBuilderAPI_MakeFace.hxx>
261#include <BRepBuilderAPI_MakeWire.hxx>
262#include <Geom_OffsetSurface.hxx>
263#include <BRepFilletAPI_MakeFillet2d.hxx>
264#include <GeomProjLib.hxx>
265#include <Geom_TrimmedCurve.hxx>
266
267static Standard_Integer BUC60811(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
268{
269 if(argc == 4) {
270 TopLoc_Location L1;
271 TopoDS_Edge aEdge = TopoDS::Edge(DBRep::Get(argv[2],TopAbs_EDGE));
272 TopoDS_Face aFace = TopoDS::Face(DBRep::Get(argv[3],TopAbs_FACE));
273 Standard_Real f = 0.0, l = 0.0;
274 Handle(Geom_Curve) GC = BRep_Tool::Curve(aEdge,f,l);
275 Handle(Geom_Surface) GS = BRep_Tool::Surface(aFace, L1);
276 GC = new Geom_TrimmedCurve(GC, f, l);
277 Handle(Geom_Curve) projCurve = GeomProjLib::Project(GC,GS);
278 BRepBuilderAPI_MakeWire *myWire;
279 myWire = new BRepBuilderAPI_MakeWire();
280 myWire->Add((BRepBuilderAPI_MakeEdge(projCurve)).Edge());
281 DBRep::Set(argv[1],myWire->Wire());
282 return 0;
283 }
284
285 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
286 if(aContext.IsNull()) {
287 di << "use 'vinit' command before " << argv[0] << "\n";
288 return -1;
289 }
290
291//step 1. creating a Bezier Surface and a patch
292 TopoDS_Face FP;
293 TopoDS_Shape FP1;
294 TopoDS_Solid solid;
295 Handle(AIS_Shape) ais1;
857ffd5e 296 Handle(AIS_Shape) ais2;
7fd59977 297 Handle(Geom_BezierSurface) BZ1;
298 TColgp_Array2OfPnt array1(1,3,1,3);
299 array1.SetValue(1,1,gp_Pnt(0,100,0));
300 array1.SetValue(1,2,gp_Pnt(200,100,0));
301 array1.SetValue(1,3,gp_Pnt(400,100,0));
302 array1.SetValue(2,1,gp_Pnt(0,200,100));
303 array1.SetValue(2,2,gp_Pnt(200,200,100));
304 array1.SetValue(2,3,gp_Pnt(400,200,100));
305 array1.SetValue(3,1,gp_Pnt(0,300,0));
306 array1.SetValue(3,2,gp_Pnt(200,300,0));
307 array1.SetValue(3,3,gp_Pnt(400,300,0));
308 BZ1 = new Geom_BezierSurface(array1);
1c72dff6 309 BRepBuilderAPI_MakeFace bzf1( BZ1, Precision::Confusion() );
7fd59977 310 TopoDS_Face F1= bzf1.Face();
311 ais1 = new AIS_Shape(F1);
312 DBRep::Set("F1",F1);
313 aContext->SetMaterial(ais1,Graphic3d_NOM_ALUMINIUM,Standard_False);
0577ae8c 314 aContext->Display (ais1, Standard_False);
7fd59977 315 BRep_Builder B;
316 TopoDS_Shell shell;
317 B.MakeShell(shell);
318 B.Add(shell, bzf1);
ab860031 319 shell.Closed (BRep_Tool::IsClosed (shell));
7fd59977 320 B.MakeSolid(solid);
321 B.Add(solid,shell);
322 gp_Dir D(0, 0, 1.0f);
323 BRepBuilderAPI_MakeWire mkw;
324 gp_Pnt p1 = gp_Pnt(150., 150.0, 260.);
325 gp_Pnt p2 = gp_Pnt(350., 150., 260.);
326 BRepBuilderAPI_MakeEdge* E1 = new BRepBuilderAPI_MakeEdge(p1,p2);
327 mkw.Add(*E1);
328 p1 = gp_Pnt(350., 150., 260.);
329 p2 = gp_Pnt(350., 250., 260.);
330 BRepBuilderAPI_MakeEdge* E2 = new BRepBuilderAPI_MakeEdge(p1,p2);
331 mkw.Add(*E2);
332 p1 = gp_Pnt(350., 250., 260.);
333 p2 = gp_Pnt(300., 250.0, 260.);
334 BRepBuilderAPI_MakeEdge* E3 = new BRepBuilderAPI_MakeEdge(p1,p2);
335 mkw.Add(*E3);
336 p1 = gp_Pnt(300., 250.0, 260.);
337 p2 = gp_Pnt(200., 200.0, 260.);
338 BRepBuilderAPI_MakeEdge* E4 = new BRepBuilderAPI_MakeEdge(p1,p2);
339 mkw.Add(*E4);
340 p1 = gp_Pnt(200., 200.0, 260.);
341 p2 = gp_Pnt(150., 200.0, 260.);
342 BRepBuilderAPI_MakeEdge* E5 = new BRepBuilderAPI_MakeEdge(p1,p2);
343 mkw.Add(*E5);
344 p1 = gp_Pnt(150., 200.0, 260.);
345 p2 = gp_Pnt(150., 150.0, 260.);
346 BRepBuilderAPI_MakeEdge* E6 = new BRepBuilderAPI_MakeEdge(p1,p2);
347 mkw.Add(*E6);
348 FP = BRepBuilderAPI_MakeFace(mkw.Wire());
349 ais2 = new AIS_Shape( FP );
350 aContext->SetMaterial(ais2,Graphic3d_NOM_ALUMINIUM,Standard_False);
0577ae8c 351 aContext->Display (ais2, Standard_False);
7fd59977 352
353 DBRep::Set("FP",FP);
354
355//step 2. offseting the surface.
857ffd5e 356 Handle(Geom_OffsetSurface) offsurf;
7fd59977 357 offsurf = new Geom_OffsetSurface(BZ1, -100);
1c72dff6 358 BRepBuilderAPI_MakeFace bzf2( offsurf, Precision::Confusion() );
7fd59977 359 TopoDS_Face F2= bzf2.Face();
857ffd5e 360 Handle(AIS_Shape) ais22 = new AIS_Shape(F2);
0577ae8c 361 aContext->Display (ais22, Standard_False);
7fd59977 362 DBRep::Set("F2",F2);
363
364//step 3. filleting the patch.
365//( I want to project wire of this patch on offseted surface above)
366 BRepFilletAPI_MakeFillet2d fillet( FP );
367 TopExp_Explorer Ex;
368 Ex.Init(FP, TopAbs_VERTEX);
369 TopoDS_Vertex v1 = TopoDS::Vertex(Ex.Current());
370 fillet.AddFillet(v1, 20);
586db386 371 di << "\nError is " << fillet.Status() << "\n";
c281a4a4 372// printf("\nError is %d ", fillet.Status());
7fd59977 373 Ex.Next();
374 TopoDS_Vertex V2 = TopoDS::Vertex(Ex.Current());
375 fillet.AddFillet(V2, 20);
586db386 376 di << "\nError is " << fillet.Status() << "\n";
c281a4a4 377// printf("\nError is %d ", fillet.Status());
7fd59977 378 fillet.Build();
379 FP1 = fillet.Shape();
380 ais2 = new AIS_Shape( FP1 );
381 aContext->SetMaterial(ais2,Graphic3d_NOM_ALUMINIUM,Standard_False);
0577ae8c 382 aContext->Display (ais2, Standard_False);
7fd59977 383
384 DBRep::Set("FP1",FP1);
385
386//step 4. Projecting the wire of this patch on offsetted surface.
387// TopExp_Explorer Ex;
388 BRepBuilderAPI_MakeWire *myWire;
389 myWire = new BRepBuilderAPI_MakeWire();
390 for (Ex.Init( FP1, TopAbs_EDGE); Ex.More(); Ex.Next())
391 {
392 TopoDS_Edge e1 = TopoDS::Edge(Ex.Current());
393 Standard_Real f = 0.0, l = 0.0;
857ffd5e 394 Handle(Geom_Curve) newBSplin = BRep_Tool::Curve(e1, f, l);
7fd59977 395 newBSplin = new Geom_TrimmedCurve(newBSplin, f, l);
396 Handle(Geom_Curve) projCurve = GeomProjLib::Project(newBSplin,offsurf);
397 myWire->Add((BRepBuilderAPI_MakeEdge(projCurve)).Edge());
398 }
857ffd5e 399 Handle(AIS_Shape) ais33 = new AIS_Shape( myWire->Wire() );
0577ae8c 400 aContext->Display (ais33, Standard_True);
7fd59977 401
402 DBRep::Set("Wire",myWire->Wire());
403
404 return 0;
405}
406
407#include<GeomAPI_ExtremaCurveCurve.hxx>
408
409static int BUC60825(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
410
411{
412 if(argc < 3){
413 printf("Usage: %s edge1 edge2",argv[0]);
414 return(-1);
415 }
416
417 TopoDS_Edge E1 = TopoDS::Edge(DBRep::Get(argv[1])),
418 E2 = TopoDS::Edge(DBRep::Get(argv[2]));
419
420 Standard_Real fp , lp;
421
422 Handle(Geom_Curve) C1 = BRep_Tool::Curve(E1 , fp , lp),
423 C2 = BRep_Tool::Curve(E2 , fp , lp);
424
425 GeomAPI_ExtremaCurveCurve aExt(C1 , C2);
426
427 di << "NB RESULTS : " << aExt.NbExtrema() << "\n";
428
429 return 0;
430}
431
432#include <BRepBuilderAPI_MakePolygon.hxx>
433#include <BRepOffsetAPI_ThruSections.hxx>
434
435static int OCC10006(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
436{
431d0f18 437 if(argc != 1) {
438 di << "Usage : " << argv[0] << "\n";
7fd59977 439 return 1;
440 }
7fd59977 441
442 double bottompoints1[12] = { 10, -10, 0, 100, -10, 0, 100, -100, 0, 10, -100, 0};
443 double toppoints1[12] = { 0, 0, 10, 100, 0, 10, 100, -100, 10, 0, -100, 10};
444 double bottompoints2[12] = { 0, 0, 10.00, 100, 0, 10.00, 100, -100, 10.00, 0, -100, 10.00};
445 double toppoints2[12] = { 0, 0, 250, 100, 0, 250, 100, -100, 250, 0, -100, 250};
446 BRepBuilderAPI_MakePolygon bottompolygon1, toppolygon1, bottompolygon2, toppolygon2;
447 gp_Pnt tmppnt;
448 for (int i=0;i<4;i++) {
449 tmppnt.SetCoord(bottompoints1[3*i], bottompoints1[3*i+1], bottompoints1[3*i+2]);
450 bottompolygon1.Add(tmppnt);
451 tmppnt.SetCoord(toppoints1[3*i], toppoints1[3*i+1], toppoints1[3*i+2]);
452 toppolygon1.Add(tmppnt);
453 tmppnt.SetCoord(bottompoints2[3*i], bottompoints2[3*i+1], bottompoints2[3*i+2]);
454 bottompolygon2.Add(tmppnt);
455 tmppnt.SetCoord(toppoints2[3*i], toppoints2[3*i+1], toppoints2[3*i+2]);
456 toppolygon2.Add(tmppnt);
457 }
458 bottompolygon1.Close();
459 DBRep::Set("B1",bottompolygon1.Shape());
460 toppolygon1.Close();
461 DBRep::Set("T1",toppolygon1.Shape());
462 bottompolygon2.Close();
463 DBRep::Set("B2",bottompolygon2.Shape());
464 toppolygon2.Close();
465 DBRep::Set("T2",toppolygon2.Shape());
466 BRepOffsetAPI_ThruSections loft1(Standard_True, Standard_True);
467 loft1.AddWire(bottompolygon1.Wire());
468 loft1.AddWire(toppolygon1.Wire());
469 loft1.Build();
470 BRepOffsetAPI_ThruSections loft2(Standard_True, Standard_True);
471 loft2.AddWire(bottompolygon2.Wire());
472 loft2.AddWire(toppolygon2.Wire());
473 loft2.Build();
474 if (loft1.Shape().IsNull() || loft2.Shape().IsNull())
475 return 1;
476 DBRep::Set("TS1",loft1.Shape());
477 DBRep::Set("TS2",loft2.Shape());
478
431d0f18 479 di << "BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape())\n";
480 BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape());
481 DBRep::Set("F", result.Shape());
7fd59977 482
7fd59977 483 return 0;
484}
485
486#include <Geom_RectangularTrimmedSurface.hxx>
487#include <GC_MakeTrimmedCone.hxx>
488
489static Standard_Integer BUC60856(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv )
490{
491 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
492 if(aContext.IsNull()) {
493 di << "use 'vinit' command before " << argv[0] << "\n";
494 return -1;
495 }
496
497 gp_Ax2 Cone_Ax;
96a95605 498 double R1=8, R2=16;
7fd59977 499 gp_Pnt P0(0,0,0),
500 P1(0,0,20), P2(0,0,45);
7fd59977 501 Handle(Geom_RectangularTrimmedSurface) S = GC_MakeTrimmedCone (P1, P2, R1, R2).Value();
1c72dff6 502 TopoDS_Shape myshape = BRepBuilderAPI_MakeFace(S, Precision::Confusion()).Shape();
7fd59977 503 Handle(AIS_Shape) ais1 = new AIS_Shape(myshape);
0577ae8c 504 aContext->Display (ais1, Standard_False);
505 aContext->SetColor (ais1, Quantity_NOC_BLUE1, Standard_False);
7fd59977 506
507 Handle(Geom_RectangularTrimmedSurface) S2 = GC_MakeTrimmedCone (P1, P2,R1, 0).Value();
1c72dff6 508 TopoDS_Shape myshape2 = BRepBuilderAPI_MakeFace(S2, Precision::Confusion()).Shape();
7fd59977 509 Handle(AIS_Shape) ais2 = new AIS_Shape(myshape2);
0577ae8c 510 aContext->Display (ais2, Standard_False);
511 aContext->SetColor (ais2, Quantity_NOC_RED, Standard_False);
7fd59977 512 return 0;
513}
514
7fd59977 515//==========================================================================
516//function : CoordLoad
517// chargement d une face dans l explorer.
518//==========================================================================
64531d9c 519static Standard_Integer coordload (Draw_Interpretor& theDi,
520 Standard_Integer theArgsNb,
521 const char** theArgVec)
7fd59977 522{
64531d9c 523 if (theArgsNb < 3)
524 {
525 return 1;
526 }
527
04232180 528 std::ifstream aFile (theArgVec[2], std::ios::in);
64531d9c 529 if (!aFile)
530 {
531 theDi << "unable to open " << theArgVec[2] << " for input\n";
532 return 2;
533 }
534
535 char aLine[80];
536 memset (aLine, 0, 40);
537 aFile.getline (aLine, 80);
538
539 gp_Pnt aPnt (0.0, 0.0, 0.0);
540 aLine[40] = '\0';
541 aPnt.SetY (Draw::Atof (&aLine[20]));
542 aLine[20] = '\0';
543 aPnt.SetX (Draw::Atof (aLine));
544 TopoDS_Vertex aVert1 = BRepBuilderAPI_MakeVertex (aPnt);
545 BRepBuilderAPI_MakeWire aMakeWire;
546 for (;;)
547 {
548 memset (aLine, 0, 40);
549 aFile.getline (aLine, 80);
550 if (!aFile)
7fd59977 551 {
64531d9c 552 break;
7fd59977 553 }
7fd59977 554
64531d9c 555 aLine[40] = '\0';
556 aPnt.SetY (Draw::Atof (&aLine[20]));
557 aLine[20] = '\0';
558 aPnt.SetX (Draw::Atof (aLine));
559 TopoDS_Vertex aVert2 = BRepBuilderAPI_MakeVertex (aPnt);
560 aMakeWire.Add (BRepBuilderAPI_MakeEdge (aVert1, aVert2));
561 aVert1 = aVert2;
562 }
563 aFile.close();
7fd59977 564
64531d9c 565 if (!aMakeWire.IsDone())
566 {
567 DBRep::Set (theArgVec[1], TopoDS_Face());
568 return 0;
7fd59977 569 }
7fd59977 570
64531d9c 571 BRepBuilderAPI_MakeFace aMakeFace (aMakeWire.Wire());
572 DBRep::Set (theArgVec[1], aMakeFace.IsDone() ? aMakeFace.Face() : TopoDS_Face());
7fd59977 573 return 0;
574}
7fd59977 575
576static Standard_Integer TestMem (Draw_Interpretor& /*di*/,
577 Standard_Integer /*nb*/,
578 const char ** /*arg*/)
579{
580 TCollection_ExtendedString aString(1024*1024, 'A');
581 return 0;
582}
583
584static Standard_Integer BUC60876_ (Draw_Interpretor& di,
585 Standard_Integer argc,
586 const char ** argv)
587{
588 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
589 if(aContext.IsNull()) {
590 di << "use 'vinit' command before " << argv[0] << "\n";
591 return -1;
592 }
593 if((argc != 2) && (argc != 3)) {
586db386 594 di<< "usage : " << argv[0] << " shape [mode==1]\n";
7fd59977 595 return -1;
596 }
597 TopoDS_Shape aShape = DBRep::Get(argv[1]);
598 Handle(AIS_InteractiveObject) anIO = new AIS_Shape(aShape);
91322f44 599 anIO->SetHilightMode((argc == 3) ? Draw::Atoi(argv[2]) : 1);
0577ae8c 600 aContext->Display (anIO, Standard_True);
7fd59977 601 return 0;
602}
603
604//=======================================================================
605//function : buc60773
606//purpose :
607//=======================================================================
608
609#include<TCollection_HAsciiString.hxx>
610
611static Standard_Integer BUC60773 (Draw_Interpretor& /*di*/, Standard_Integer /*n*/, const char ** /*a*/)
612{
613 Handle(TCollection_HAsciiString) hAscii = new TCollection_HAsciiString();
614 Standard_CString aStr = hAscii->ToCString();
615 TCollection_AsciiString aAscii(aStr);
616
617 return 0;
618}
619
620#include<BRepPrimAPI_MakeCylinder.hxx>
621#include<BRepPrimAPI_MakeCone.hxx>
622
623static int TestCMD(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
624
625{
431d0f18 626 if(argc != 1) {
627 di << "Usage : " << argv[0] << "\n";
7fd59977 628 return 1;
629 }
7fd59977 630
631 //Cylindre 36.085182 20.0 8.431413 88.04671 20.0 38.931416 10.0
632
633 Standard_Real x11 = 36.085182;
634 Standard_Real y11 = 20.0;
635 Standard_Real z11 = 8.431413;
636 Standard_Real x12 = 88.04671;
637 Standard_Real y12 = 20.0;
638 Standard_Real z12 = 38.931416;
639 Standard_Real radius = 10.0;
640
641 gp_Pnt base1(x11, y11, z11);
642 gp_Dir vect1(x12-x11, y12-y11, z12-z11);
643 gp_Ax2 axis1(base1, vect1);
644 Standard_Real height1 = sqrt( ((x12-x11)*(x12-x11)) + ((y12-y11)*(y12-y11)) + ((z12-z11)*(z12-z11)) );
645 BRepPrimAPI_MakeCylinder cylinder(axis1, radius, height1);
646
647 TopoDS_Shape SCyl = cylinder.Shape();
648 DBRep::Set("cyl", SCyl);
649
650
651 //Cone 70.7262 20.0 28.431412 105.36722 20.0 48.431416 6.0 3.0
652 Standard_Real x21 = 70.7262;
653 Standard_Real y21 = 20.0;
654 Standard_Real z21 = 28.431412;
655 Standard_Real x22 = 105.36722;
656 Standard_Real y22 = 20.0;
657 Standard_Real z22 = 48.431416;
658 Standard_Real radius1 = 6.0;
659 Standard_Real radius2 = 3.0;
660
661 gp_Pnt base2(x21, y21, z21);
662 gp_Dir vect2(x22-x21, y22-y21, z22-z21);
663 gp_Ax2 axis2(base2, vect2);
664 Standard_Real height2 = sqrt( ((x22-x21)*(x22-x21)) + ((y22-y21)*(y22-y21)) + ((z22-z21)*(z22-z21)) );
665 BRepPrimAPI_MakeCone cone(axis2, radius1, radius2, height2);
666
667 TopoDS_Shape SCon = cone.Shape();
668 DBRep::Set("con", SCon);
669
431d0f18 670 di << "BRepAlgoAPI_Fuse SFuse(SCyl, SCon)\n";
671 BRepAlgoAPI_Fuse SFuse(SCyl, SCon);
672 if (!SFuse.IsDone()) {
673 di << "Error: Boolean fuse operation failed !\n";
674 }
675 else {
676 const TopoDS_Shape& fuse = SFuse.Shape();
677 DBRep::Set("fus", fuse);
7fd59977 678 }
7fd59977 679 return 0;
680}
681
997e128f 682#include <NCollection_DataMap.hxx>
7fd59977 683#include <TColStd_HSequenceOfAsciiString.hxx>
684#include <TopExp.hxx>
685#include <TopoDS_Iterator.hxx>
686
687//---------------------------------------------------------------------------------------
688
689static Standard_Integer statface (Draw_Interpretor& di,Standard_Integer /*argc*/, const char ** argv )
690
691{
692 TopoDS_Shape aShape = DBRep::Get(argv[1]);
693 if(aShape.IsNull())
694 {
586db386 695 di<<"Invalid input shape\n";
7fd59977 696 return 1;
697 }
997e128f 698 NCollection_DataMap<TCollection_AsciiString, Standard_Integer> aMap;
7fd59977 699 Handle(TColStd_HSequenceOfAsciiString) aSequence = new TColStd_HSequenceOfAsciiString;
700 Standard_CString aString;
997e128f 701 Standard_Integer l=0;
7fd59977 702 TopExp_Explorer expl;
703 Standard_Real f3d,l3d;
704 for(expl.Init(aShape,TopAbs_FACE);expl.More();expl.Next())
705 {
706 // SURFACES
707 TopoDS_Face aFace = TopoDS::Face (expl.Current());
708 Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace);
709 aString = aSurface->DynamicType()->Name();
710
997e128f 711 if (aMap.IsBound(aString))
712 aMap.ChangeFind(aString)++;
713 else {
714 aMap.Bind(aString, 1);
7fd59977 715 aSequence->Append(aString);
7fd59977 716 }
717 }
718 // PCURVES
719 for(expl.Init(aShape,TopAbs_FACE);expl.More();expl.Next())
720 {
721 TopoDS_Face aFace = TopoDS::Face (expl.Current());
722 TopoDS_Iterator anIt(aFace);
723 TopoDS_Wire aWire = TopoDS::Wire (anIt.Value());
724 TopoDS_Iterator it (aWire);
725 for (; it.More(); it.Next()) {
726 TopoDS_Edge Edge = TopoDS::Edge (it.Value());
997e128f 727 Handle(Geom2d_Curve) aCurve2d = BRep_Tool::CurveOnSurface(Edge,aFace,f3d,l3d);
728 aString = aCurve2d->DynamicType()->Name();
729 if(aMap.IsBound(aString))
730 aMap.ChangeFind(aString)++;
731 else {
732 aMap.Bind(aString, 1);
733 aSequence->Append(aString);
734 }
7fd59977 735 }
736 }
737 // 3d CURVES
738 TopExp_Explorer exp;
739 for (exp.Init(aShape,TopAbs_EDGE); exp.More(); exp.Next())
740 {
997e128f 741 TopoDS_Edge Edge = TopoDS::Edge (exp.Current());
742 Handle(Geom_Curve) aCurve3d = BRep_Tool::Curve (Edge,f3d,l3d);
743 if(aCurve3d.IsNull())
744 {
745 l++;
746 } else {
747 aString = aCurve3d->DynamicType()->Name();
748 if (aMap.IsBound(aString))
7fd59977 749 {
997e128f 750 aMap.ChangeFind(aString)++;
751 } else {
752 aMap.Bind(aString, 1);
753 aSequence->Append(aString);
7fd59977 754 }
7fd59977 755 }
997e128f 756 }
7fd59977 757 // Output
758 di<<"\n";
997e128f 759
760 for (Standard_Integer i = 1; i <= aSequence->Length(); i++) {
761 di << aMap.Find(aSequence->Value(i)) << " -- " << aSequence->Value(i).ToCString() << "\n";
762 }
7fd59977 763
764 di<<"\n";
586db386 765 di<<"Degenerated edges :\n";
766 di<<l<<" -- Degenerated edges \n";
7fd59977 767
768 return 0;
769
770}
771
772#include <BRepBuilderAPI_Transform.hxx>
773
774static Standard_Integer BUC60841(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
775{
431d0f18 776 if(argc != 1) {
777 di << "Usage : " << argv[0] << "\n";
7fd59977 778 return 1;
779 }
7fd59977 780
781 gp_Ax2 Ax2 = gp_Ax2(gp_Pnt(0, 621, 78), gp_Dir(0, 1,0));
782 BRepPrimAPI_MakeCylinder cyl(Ax2, 260, 150);
783 //BRepPrimAPI_MakeCylinder cyl(gp_Ax2(gp_Pnt(0, 621, 78), gp_Dir(0, 1,0)), 260, 150);
784
785 TopoDS_Shape sh1 = cyl.Shape();
786 DBRep::Set("sh1",sh1);
787 gp_Trsf trsf1, trsf2;
788 trsf1.SetTranslation(gp_Pnt(0.000000,700.000000,-170.000000),
789 gp_Pnt(0.000000,700.000000,-95.000000));
790 trsf2.SetRotation(gp_Ax1(gp_Pnt(0.000000,700.000000,-170.000000),
791 gp_Dir(0.000000,0.000000,1.000000)), 0.436111);
792 BRepBuilderAPI_Transform trans1(sh1, trsf1);
793 TopoDS_Shape sh2 = trans1.Shape();
794 DBRep::Set("sh2",sh2);
795
431d0f18 796 di << "BRepAlgoAPI_Fuse fuse1(sh1, sh2)\n";
797 BRepAlgoAPI_Fuse fuse1(sh1, sh2);
798 TopoDS_Shape fsh1 = fuse1.Shape();
7fd59977 799 DBRep::Set("fsh1",fsh1);
431d0f18 800
7fd59977 801 BRepBuilderAPI_Transform trans2(fsh1, trsf2);
802 TopoDS_Shape sh3 = trans2.Shape();
803 DBRep::Set("sh3",sh3);
804
431d0f18 805 di << "BRepAlgoAPI_Fuse fuse2(fsh1,sh3)\n";
806 BRepAlgoAPI_Fuse fuse2(fsh1, sh3);
807 const TopoDS_Shape& fsh2 = fuse2.Shape();
7fd59977 808 DBRep::Set("fsh2",fsh2);
431d0f18 809
857ffd5e 810 Handle(AIS_Shape) aisp1 = new AIS_Shape(fsh2);
7fd59977 811 return 0;
812}
813
814#include <ShapeBuild_Edge.hxx>
815
816static Standard_Integer BUC60874(Draw_Interpretor& /*di*/, Standard_Integer /*argc*/, const char ** argv )
817{
818 TopoDS_Edge e = TopoDS::Edge(DBRep::Get(argv[1],TopAbs_EDGE));
819 ShapeBuild_Edge().BuildCurve3d(e);
820 DBRep::Set("ED",e);
821 return 0;
822}
823
824
825#include<TDF_Label.hxx>
826#include<TDataStd_TreeNode.hxx>
827
828#include<DDocStd.hxx>
829
830#include<DDF.hxx>
831
832#include<TDocStd_Modified.hxx>
833#include<TDF_ListIteratorOfDeltaList.hxx>
834#include<TDocStd_Document.hxx>
835#include<TDocStd_Application.hxx>
836#include<TDF_Delta.hxx>
837#include<TDataXtd_Constraint.hxx>
838#include<TPrsStd_AISPresentation.hxx>
839#include<TPrsStd_AISViewer.hxx>
840#include<TNaming_Builder.hxx>
841#include<TNaming_Naming.hxx>
842#include<TNaming_NamedShape.hxx>
843
844static int BUC60817(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
845 if(argc!=2) {
586db386 846 di << "Usage : " << argv[0] << " D\n";
7fd59977 847 di<<1;
848 return 0;
849 }
850
851 Handle(TDF_Data) DF;
852 if (!DDF::GetDF(argv[1],DF)) {di<<2;return 0;}
853
854 TDF_Label L1,L2;
855 Handle(TDataStd_TreeNode) TN1,TN2;
856
857 DDF::AddLabel(DF,"0:2",L1);
858 TN1 = TDataStd_TreeNode::Set(L1);
859
860 DDF::AddLabel(DF,"0:3",L2);
861 TN2 = TDataStd_TreeNode::Set(L2);
862
863 TN1->Append(TN2);
864 if(!(TN2->IsDescendant(TN1))) {di<<3;return 0;}
865 if((TN1->IsDescendant(TN2))) {di<<4;return 0;}
866
867 di<<0;
868 return 0;
869}
870
871static int BUC60831_1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
872 if(argc!=2) {
586db386 873 di << "Usage : " << argv[0] << " D\n";
7fd59977 874 di<<-1;
875 return 0;
876 }
877
878 Handle(TDF_Data) DF;
879 if (!DDF::GetDF(argv[1],DF)) {di<<-2;return 0;}
880
881 TDF_Label L;
882 DDF::FindLabel(DF,"0:1",L,Standard_False);
883 Handle(TDocStd_Modified) MDF;
884 if (!L.Root().FindAttribute (TDocStd_Modified::GetID(), MDF)) {
885 MDF = new TDocStd_Modified();
886 L.Root().AddAttribute(MDF);
887 }
888
889 di<<!MDF->IsEmpty();
890 return 0;
891}
892
893static int BUC60831_2(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
894 if(argc!=3) {
586db386 895 di << "Usage : " << argv[0] << " D Label\n";
7fd59977 896 di<<1;
897 return 0;
898 }
899
900 Handle(TDF_Data) DF;
901 if (!DDF::GetDF(argv[1],DF)) {di<<2;return 0;}
902
903 TDF_Label L;
904 DDF::FindLabel(DF,argv[2],L,Standard_False);
905
906 TDocStd_Modified::Add(L);
907
908 di<<0;
909 return 0;
910}
911
912static int BUC60836(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
913 if(argc!=2) {
586db386 914 di << "Usage : " << argv[0] << " D\n";
7fd59977 915 di<<1;
916 return 0;
917 }
918
919
920 Handle(TDF_Data) aDF;
921 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
922
923 Handle(TDocStd_Document) aDocument;
924 if (!DDocStd::GetDocument(argv[1], aDocument)) {di<<3;return 0;}
925
926 TDF_Label L;
927 Handle(TDataStd_TreeNode) TN;
928
929 aDocument->NewCommand();
930 DDF::AddLabel(aDF,"0:2",L);
931 TN = TDataStd_TreeNode::Set(L);
932
933 aDocument->NewCommand();
934 DDF::AddLabel(aDF,"0:3",L);
935 TN = TDataStd_TreeNode::Set(L);
936
937 aDocument->NewCommand();
938 DDF::AddLabel(aDF,"0:4",L);
939 TN = TDataStd_TreeNode::Set(L);
940 aDocument->NewCommand();
941
942 TDF_DeltaList Us,Rs;
943 Us = aDocument->GetUndos();
944 Rs = aDocument->GetUndos();
945
946 Standard_Integer i;
947 char Names[10][5]={"n1","n2","n3","n4","n5","n6","n7","n8","n9","n10"};
948
949 TDF_ListIteratorOfDeltaList IDL;
950 for(IDL.Initialize(Us),i=1;IDL.More();IDL.Next(),i++){
951 Handle(TDF_Delta) D = IDL.Value();
952 TCollection_ExtendedString S(Names[i-1]);
953 D->SetName(S);
04232180 954// std::cout<<" U"<<i<<"="<<D->Name()<<std::endl;
7fd59977 955 }
956
957 aDocument->Undo();
958 aDocument->Undo();
959
960 Us = aDocument->GetUndos();
961 Rs = aDocument->GetRedos();
962
963 for(IDL.Initialize(Us),i=1;IDL.More();IDL.Next(),i++){
964 Handle(TDF_Delta) D = IDL.Value();
04232180 965// std::cout<<" U"<<i<<"="<<D->Name()<<std::endl;
7fd59977 966 }
967
968 TCollection_ExtendedString n2name ("n2");
969 for(IDL.Initialize(Rs),i=1;IDL.More();IDL.Next(),i++){
970 Handle(TDF_Delta) D = IDL.Value();
971 if ( i == 1 && ! D->Name().IsEqual (n2name) )
972 {
973 di << 4;
974 return 0;
975 }
976 }
977
978 di<<0;
979 return 0;
980}
981
982static int BUC60847(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
983 if(argc!=3) {
586db386 984 di << "Usage : " << argv[0] << " D Shape\n";
7fd59977 985 di<<1;
986 return 0;
987 }
988
989 Handle(TDF_Data) aDF;
990 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
991
992 TopoDS_Shape s = DBRep::Get(argv[2]);
586db386 993 if (s.IsNull()) { di <<"shape not found\n"; di<<3;return 0;}
7fd59977 994 TDF_Label L;
995 DDF::AddLabel(aDF, "0:2", L);
996 TNaming_Builder SI (L);
997 SI.Generated(s);
998
999 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1000
1001 TNaming_Naming aNN;
1002 NS=aNN.Name(L,s,s);
1003// if (!NS->IsEmpty()) {di<<3;return 0;}
1004 if (NS->IsEmpty()) {di<<4;return 0;}
1005 di<<0;
1006 return 0;
1007}
1008
1009static int BUC60862(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1010 if(argc!=3) {
586db386 1011 di << "Usage : " << argv[0] << " D Shape\n";
7fd59977 1012 di<<1;
1013 return 0;
1014 }
1015
1016 Handle(TDF_Data) aDF;
1017 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1018
1019 TopoDS_Shape s = DBRep::Get(argv[2]);
586db386 1020 if (s.IsNull()) { di <<"shape not found\n"; di<<3;return 0;}
7fd59977 1021 TDF_Label L;
1022 DDF::AddLabel(aDF, "0:2", L);
1023 TNaming_Builder SI (L);
1024 SI.Generated(s);
1025
1026 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1027
1028 TNaming_Naming aNN;
1029 NS=aNN.Name(L,s,s);
1030 if (NS->IsEmpty()) {di<<4;return 0;}
1031 di<<0;
1032 return 0;
1033}
1034
1035static int BUC60867(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1036 if (argc == 2) {
1037 TCollection_ExtendedString path (argv[1]);
6fe96f84 1038 Handle(TDocStd_Application) A = DDocStd::GetApplication();
7fd59977 1039 Handle(TDocStd_Document) D;
1040 Standard_Integer insession = A->IsInSession(path);
1041 if (insession > 0) {
586db386 1042 di <<"document " << insession << " is already in session\n";
7fd59977 1043 di<<2;
1044 return 0;
1045 }
15e8b082
M
1046 PCDM_ReaderStatus Result = A->Open(path,D);
1047 if(Result==PCDM_RS_OK){
7fd59977 1048 di<<0;
1049 return 0;
1050 }
1051 }
1052 di<<3;
1053 return 0;
1054}
1055
1056static int BUC60910(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1057 if(argc!=2) {
586db386 1058 di << "Usage : " << argv[0] << " D\n";
7fd59977 1059 di<<1;
1060 return 0;
1061 }
1062
1063 Handle(TDF_Data) aDF;
1064 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1065
1066 TDF_Label L;
1067 DDF::AddLabel(aDF, "0:2", L);
1068
f47afe53 1069 Handle(TPrsStd_AISPresentation) AISP =
1070 TPrsStd_AISPresentation::Set(L,TDataXtd_Constraint::GetID());
7fd59977 1071
1072 if (AISP->HasOwnMode()) {di<<3;return 0;}
1073 AISP->SetMode(3);
1074 Standard_Integer Mode = AISP->Mode();
1075 if (Mode!=3) {di<<4;return 0;}
1076 if (!AISP->HasOwnMode()) {di<<5;return 0;}
1077 AISP->UnsetMode();
1078 if (AISP->HasOwnMode()) {di<<6;return 0;}
1079 di<<0;
1080 return 0;
1081}
1082
1083static int BUC60925(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1084 if(argc!=2) {
586db386 1085 di << "Usage : " << argv[0] << " D\n";
7fd59977 1086 di<<1;
1087 return 0;
1088 }
1089
1090 Handle(TDF_Data) aDF;
1091 if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;}
1092
1093 TDF_Label L;
1094 DDF::AddLabel(aDF, "0:2", L);
1095 TDF_LabelMap LM;
1096 LM.Add(L);
1097
1098 Handle(TNaming_NamedShape) NS = new TNaming_NamedShape;
1099// Handle(TNaming_Name) NN = new TNaming_Name;
1100 TNaming_Name NN;
1101
1102 NN.Type(TNaming_IDENTITY);
1103 NN.Append(NS);
1104 Standard_Boolean Res = NN.Solve(L,LM);
1105
1106 if (Res!=Standard_False) {di<<3;return 0;}
1107 di<<0;
1108 return 0;
1109}
1110
1111static int BUC60932(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1112 if(argc!=2) {
586db386 1113 di << "Usage : " << argv[0] << " D\n";
7fd59977 1114 di<<1;
1115 return 0;
1116 }
1117
1118
1119 Handle(TDocStd_Document) aDocument;
1120 if (!DDocStd::GetDocument(argv[1], aDocument)) {di<<2;return 0;}
1121
1122 if(!aDocument->InitDeltaCompaction()) {di<<3;return 0;}
1123 if(!aDocument->PerformDeltaCompaction()) {di<<4;return 0;}
1124
1125 di<<0;
1126 return 0;
1127}
1128
1129//=======================================================================
1130//function : AISWidth
1131//purpose : AISWidth (DOC,entry,[width])
1132// abv: testing command for checking bug BUC60917 in TPrsStd_AISPresentation
1133//=======================================================================
1134
1135static int AISWidth(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1136
1137 if (argc >= 3) {
1138 Handle(TDocStd_Document) D;
1139 if (!DDocStd::GetDocument(argv[1],D)) {di<<(-1);return 0;}
1140 TDF_Label L;
1141 if (!DDF::FindLabel(D->GetData(),argv[2],L)) {di<<(-2);return 0;}
1142
1143 Handle(TPrsStd_AISViewer) viewer;
1144 if( !TPrsStd_AISViewer::Find(L, viewer) ) {di<<(-3);return 0;}
1145
1146 Handle(TPrsStd_AISPresentation) prs;
1147 if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) {
1148 if( argc == 4 ) {
91322f44 1149 prs->SetWidth(Draw::Atof(argv[3]));
7fd59977 1150 TPrsStd_AISViewer::Update(L);
1151 }
1152 else {
1153 if (prs->HasOwnWidth()){
04232180 1154// std::cout << "Width = " << prs->Width() << std::endl;
7fd59977 1155 di<<prs->Width();
1156 }
1157 else{
586db386 1158 di << "AISWidth: Warning : Width wasn't set\n";
7fd59977 1159 di<<(-4);
1160 }
1161 }
1162 return 0;
1163 }
1164 }
1165 di << "AISWidth : Error" << "\n";
1166 di<<(-5);
1167 return 0;
1168}
1169
1170//=======================================================================
1171//function : BUC60921 ( & BUC60954 )
1172//purpose : Test memory allocation of OCAF in Undo/Redo operations
1173//=======================================================================
1174
1175static Standard_Integer BUC60921 (Draw_Interpretor& di,
1176 Standard_Integer nb,
1177 const char ** arg)
1178{
1179 if (nb >= 4) {
1180 Handle(TDocStd_Document) D;
1181 if (!DDocStd::GetDocument(arg[1],D)) {di<<1;return 0;}
1182 TDF_Label L;
1183 DDF::AddLabel(D->GetData(),arg[2],L);
1184
1185 BRep_Builder B;
1186 TopoDS_Shape S;
1187 BRepTools::Read ( S, arg[3], B );
1188
1189 TNaming_Builder tnBuild(L);
1190 tnBuild.Generated(S);
1191// di << "File " << arg[3] << " added";
1192 di<<0;
1193 return 0;
1194 }
1195 di << "BUC60921 Doc label brep_file: directly read brep file and put shape to the label" << "\n";
1196 di<<2;
1197 return 0;
1198}
1199
1200#include<IGESControl_Reader.hxx>
1201#include<BRepPrimAPI_MakeHalfSpace.hxx>
1202
1203static Standard_Integer BUC60951_(Draw_Interpretor& di, Standard_Integer argc, const char ** a)
1204{
431d0f18 1205 if (argc != 2) {
1206 di << "Usage : " << a[0] << " file.igs\n";
7fd59977 1207 return 1;
1208 }
431d0f18 1209
7fd59977 1210 Handle(AIS_InteractiveContext) myContext = ViewerTest::GetAISContext();
1211
1212 if(myContext.IsNull()) {
1213 di << "use 'vinit' command before " << a[0] << "\n";
1214 return -1;
1215 }
1216
1217// IGESControlStd_Reader reader;
1218 IGESControl_Reader reader;
1219 reader.ReadFile(a[1]);
1220 reader.TransferRoots();
1221 TopoDS_Shape shape = reader.OneShape();
1222 printf("\n iges1 shape type = %d", shape.ShapeType() );
1223 TopTools_IndexedMapOfShape list;
1224 TopExp::MapShapes(shape, TopAbs_FACE, list);
1225 printf("\n No. of faces = %d", list.Extent());
1226
1227 TopoDS_Shell shell;
1228 BRep_Builder builder;
1229 builder.MakeShell(shell);
1230 for(int i=1;i<=list.Extent(); i++) {
1231 TopoDS_Face face = TopoDS::Face(list.FindKey(i));
1232 builder.Add(shell, face);
1233 }
ab860031 1234 shell.Closed (BRep_Tool::IsClosed (shell));
7fd59977 1235
1236 BRepPrimAPI_MakeHalfSpace half(shell, gp_Pnt(0, 0, 20));
1237 TopoDS_Solid sol = half.Solid();
1238 gp_Ax2 anAx2(gp_Pnt(-800.0, 0.0, 0), gp_Dir(0, 0, -1));
1239 BRepPrimAPI_MakeCylinder cyl(anAx2, 50, 300);
1240 TopoDS_Shape sh = cyl.Shape();
1241
431d0f18 1242 di << "BRepAlgoAPI_Fuse fuse(sol, sh)\n";
1243 BRepAlgoAPI_Fuse fuse(sol, sh);
1244 sh = fuse.Shape();
7fd59977 1245
1246 Handle(AIS_Shape) res = new AIS_Shape(sh);
0577ae8c 1247 myContext->Display (res, Standard_True);
7fd59977 1248 return 0;
1249}
1250
1cd84fee 1251void QABugs::Commands_3(Draw_Interpretor& theCommands) {
1252 const char *group = "QABugs";
7fd59977 1253
1254 theCommands.Add("BUC60623","BUC60623 result Shape1 Shape2",__FILE__,BUC60623,group);
7fd59977 1255 theCommands.Add("BUC60632","BUC60632 mode length",__FILE__,BUC60632,group);
1256 theCommands.Add("BUC60652","BUC60652 face",__FILE__,BUC60652,group);
68dcee02 1257
7fd59977 1258 theCommands.Add("BUC60729","BUC60729",__FILE__,BUC60729,group);
1259 theCommands.Add("BUC60724","BUC60724",__FILE__,BUC60724,group);
1260 theCommands.Add("BUC60727","BUC60727",__FILE__,BUC60727,group);
1261 theCommands.Add("BUC60792","BUC60792",__FILE__,BUC60792,group);
1262 theCommands.Add("BUC60811","BUC60811",__FILE__,BUC60811,group);
1263
1264 theCommands.Add("BUC60825","BUC60825",__FILE__,BUC60825,group);
1265
431d0f18 1266 theCommands.Add("OCC10006","OCC10006",__FILE__,OCC10006,group);
7fd59977 1267
1268 theCommands.Add("BUC60856","BUC60856",__FILE__,BUC60856,group);
1269
7fd59977 1270 theCommands.Add("coordload","load coord from file",__FILE__,coordload);
7fd59977 1271
1272 theCommands.Add("TestMem","TestMem",__FILE__,TestMem,group);
1273 theCommands.Add("BUC60945","BUC60945",__FILE__,TestMem,group);
1274 theCommands.Add("BUC60876","BUC60876 shape",__FILE__,BUC60876_,group);
1275 theCommands.Add("BUC60773","BUC60773",__FILE__,BUC60773,group);
1276
431d0f18 1277 theCommands.Add("TestCMD","TestCMD",__FILE__,TestCMD,group);
7fd59977 1278
1279 theCommands.Add("statface","statface face",__FILE__,statface,group);
1280
431d0f18 1281 theCommands.Add("BUC60841","BUC60841",__FILE__,BUC60841,group);
7fd59977 1282
1283 theCommands.Add("BUC60874","BUC60874",__FILE__,BUC60874,group);
1284
1285 theCommands.Add("BUC60817","BUC60817 D",__FILE__,BUC60817,group);
1286 theCommands.Add("BUC60831_1","BUC60831_1 D",__FILE__,BUC60831_1,group);
1287 theCommands.Add("BUC60831_2","BUC60831_2 D Label",__FILE__,BUC60831_2,group);
1288 theCommands.Add("BUC60836","BUC60836 D",__FILE__,BUC60836,group);
1289 theCommands.Add("BUC60847","BUC60847 D Shape",__FILE__,BUC60847,group);
1290 theCommands.Add("BUC60862","BUC60862 D Shape",__FILE__,BUC60862,group);
1291 theCommands.Add("BUC60867","BUC60867",__FILE__,BUC60867,group);
1292 theCommands.Add("BUC60910","BUC60910 D",__FILE__,BUC60910,group);
1293 theCommands.Add("BUC60925","BUC60925 D",__FILE__,BUC60925,group);
1294 theCommands.Add("BUC60932","BUC60932 D",__FILE__,BUC60932,group);
1295 theCommands.Add("AISWidth","AISWidth (DOC,entry,[width])",__FILE__,AISWidth,group);
1296 theCommands.Add("BUC60921","BUC60921 Doc label brep_file",__FILE__,BUC60921,group);
1297
431d0f18 1298 theCommands.Add("BUC60951","BUC60951 file.igs",__FILE__,BUC60951_, group );
7fd59977 1299
1300}