0028643: Coding rules - eliminate GCC compiler warnings -Wmisleading-indentation
[occt.git] / src / QABugs / QABugs_17.cxx
CommitLineData
b311480e 1// Created on: 2002-03-18
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.
7fd59977 15
7fd59977 16#include <stdio.h>
17
1cd84fee 18#include <QABugs.hxx>
7fd59977 19
91322f44 20#include <Draw.hxx>
7fd59977 21#include <Draw_Interpretor.hxx>
22#include <DBRep.hxx>
23#include <DrawTrSurf.hxx>
24#include <AIS_InteractiveContext.hxx>
25#include <ViewerTest.hxx>
5e27df78 26#include <ViewerTest_EventManager.hxx>
7fd59977 27#include <AIS_Shape.hxx>
28#include <TopoDS_Shape.hxx>
29
30#include <Geom_Circle.hxx>
31#include <Geom_Ellipse.hxx>
32#include <Geom_Plane.hxx>
543a9964 33#include <Geom_BSplineSurface.hxx>
7fd59977 34#include <gp_Pln.hxx>
35#include <Geom2d_Curve.hxx>
36#include <GeomAPI.hxx>
37#include <Geom2dAdaptor_Curve.hxx>
38#include <Geom2dGcc_QualifiedCurve.hxx>
39#include <Geom2dGcc_Lin2d2Tan.hxx>
40#include <Geom2d_Line.hxx>
41#include <BRepBuilderAPI_MakeEdge.hxx>
42#include <TopoDS_Edge.hxx>
43#include <Precision.hxx>
44#include <Geom2d_Circle.hxx>
0b85f9a6 45#include <Geom2dGcc_QCurve.hxx>
7fd59977 46#include <GccEnt_QualifiedCirc.hxx>
54e37688 47#include <Geom2dGcc_Lin2d2TanIter.hxx>
7fd59977 48#include <BRepBuilderAPI_MakeWire.hxx>
49#include <TopExp_Explorer.hxx>
50#include <TopoDS.hxx>
51#include <TopoDS_Wire.hxx>
52#include <BRep_Tool.hxx>
53#include <gp_Circ.hxx>
54#include <BRepOffsetAPI_MakePipeShell.hxx>
55#include <AIS_Trihedron.hxx>
56#include <Geom_Axis2Placement.hxx>
57#include <V3d_View.hxx>
7fd59977 58#include <BRepBuilderAPI_MakeVertex.hxx>
59#include <AIS_LengthDimension.hxx>
60#include <AIS_RadiusDimension.hxx>
61#include <BRepPrimAPI_MakeBox.hxx>
62#include <GeomAdaptor_Surface.hxx>
63#include <Extrema_ExtPS.hxx>
64#include <Geom_CartesianPoint.hxx>
65#include <Geom2d_CartesianPoint.hxx>
66#include <Geom2dGcc_Circ2d3Tan.hxx>
67#include <Aspect_Window.hxx>
68
69#include <TopoDS_Compound.hxx>
70#include <TopoDS_CompSolid.hxx>
71#include <StdSelect_ShapeTypeFilter.hxx>
7fd59977 72#include <Prs3d_Projector.hxx>
73#include <HLRAlgo_Projector.hxx>
7fd59977 74#include <Standard_ErrorHandler.hxx>
aff395a3 75#include <Font_NameOfFont.hxx>
7fd59977 76
77static Standard_Integer BUC60842 (Draw_Interpretor& di, Standard_Integer /*argc*/,const char ** /*argv*/)
78{
79 Standard_Character abuf[16];
80 //Standard_Character * abuf = new Standard_Character[16];
81
82 Standard_CString st = abuf;
83
84 Handle(Geom_Circle) cir = new Geom_Circle (gp_Ax2 (gp_Pnt (823.687192, 502.366825, 478.960440), gp_Dir (0.173648, 0.984808, 0.000000), gp_Dir (-0.932169, 0.164367, -0.322560)), 50);
85 Handle(Geom_Ellipse) ell = new Geom_Ellipse (gp_Ax2 (gp_Pnt (1262.224429, 425.040878, 363.609716), gp_Dir (0.173648, 0.984808, 0.000000), gp_Dir (-0.932169, 0.164367, -0.322560)), 150, 100);
86 Handle(Geom_Plane) plne = new Geom_Plane (gp_Ax3 (gp_Ax2 (gp_Pnt (1262.224429, 425.040878, 363.609716), gp_Dir (0.173648, 0.984808, 0.000000), gp_Dir (-0.932169, 0.164367, -0.322560))));
87
88 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
89
90 gp_Pln pln = plne->Pln();
91 Handle(Geom2d_Curve) curve2d = GeomAPI::To2d (ell, pln);
91322f44 92 Sprintf(abuf,"ell");
7fd59977 93 DrawTrSurf::Set(st,curve2d);
94 if(!aContext.IsNull()) {
95 Handle(AIS_Shape) aisp =
96 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(curve2d, pln)).Edge());
0577ae8c 97 aContext->Display (aisp, Standard_False);
7fd59977 98 }
99
100 Handle(Geom2d_Curve) fromcurve2d = GeomAPI::To2d (cir, pln);
91322f44 101 Sprintf(abuf,"cil");
7fd59977 102 DrawTrSurf::Set(st,fromcurve2d);
103 if(!aContext.IsNull()) {
104 Handle(AIS_Shape) aisp =
105 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(fromcurve2d, pln)).Edge());
0577ae8c 106 aContext->Display (aisp, Standard_False);
7fd59977 107 }
108
109 Geom2dAdaptor_Curve acur (curve2d), afromcur (fromcurve2d);
110 Geom2dGcc_QualifiedCurve qcur (acur, GccEnt_outside);
111 Geom2dGcc_QualifiedCurve qfromcur (afromcur, GccEnt_outside);
112 Geom2dGcc_Lin2d2Tan lintan (qcur, qfromcur, 0.1, 0.0, 0.0);
113 Standard_Integer i=0;
114 for(i=0;i<lintan.NbSolutions();i++) {
91322f44 115 Sprintf(abuf,"lintan_%d",i);
7fd59977 116 Handle(Geom2d_Line) glin = new Geom2d_Line(lintan.ThisSolution(i));
117 DrawTrSurf::Set(st,glin);
118 if(!aContext.IsNull()) {
119 Handle(AIS_Shape) aisp =
0577ae8c 120 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(glin, pln)).Edge());
121 aContext->Display (aisp, Standard_False);
7fd59977 122 }
123 }
0577ae8c 124 aContext->UpdateCurrentViewer();
7fd59977 125 di << " Is Done = \n" << (Standard_Integer) lintan.IsDone();
126 return 0;
127}
128
129static Standard_Integer BUC60843 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
130{
131 if (argc != 4 && argc != 5 && argc != 6 && argc != 7) {
586db386 132 di << "Usage : " << argv[0] << "result_shape name_of_circle name_of_curve [ par1 [ tol ] ]\n";
7fd59977 133 return 1;
134 }
135
136 Standard_Real par1 = 0.0, par2 = 0.0;
137 Standard_Real tol = Precision::Angular();
138 if (argc >= 5)
91322f44 139 par1 = Draw::Atof(argv[4]);
7fd59977 140 if (argc == 6)
91322f44 141 par2 = Draw::Atof(argv[5]);
7fd59977 142 if (argc == 7)
91322f44 143 tol = Draw::Atof(argv[6]);
7fd59977 144 Handle(Geom2d_Curve) aCur2d1 = DrawTrSurf::GetCurve2d(argv[2]);
145 Handle(Geom2d_Curve) aCur2d2 = DrawTrSurf::GetCurve2d(argv[3]);
146 if (aCur2d1.IsNull() || aCur2d2.IsNull()) {
586db386 147 di << "Faulty : not curves\n";
7fd59977 148 return 1;
149 }
150 Standard_Boolean c1IsCircle = Standard_False;
151 Handle(Geom2d_Circle) aCir2d = Handle(Geom2d_Circle)::DownCast(aCur2d1);
152 if (!aCir2d.IsNull()) {
153 c1IsCircle = Standard_True;
91322f44 154 if (argc == 6) tol = Draw::Atof(argv[5]);
7fd59977 155 }
156 if(c1IsCircle) {
157 Geom2dAdaptor_Curve acur(aCur2d2);
0b85f9a6 158 Geom2dGcc_QCurve qcur(acur, GccEnt_unqualified);
7fd59977 159 GccEnt_QualifiedCirc qfromcur(aCir2d->Circ2d(), GccEnt_unqualified);
54e37688 160 Geom2dGcc_Lin2d2TanIter lintan(qfromcur, qcur , par1, tol);
7fd59977 161 if (lintan.IsDone()) {
162 gp_Lin2d lin = lintan.ThisSolution();
163 Handle(Geom2d_Line) glin = new Geom2d_Line(lin);
164 DrawTrSurf::Set(argv[1], glin);
165 } else {
586db386 166 di << "Faulty : tangent line is not done.\n";
7fd59977 167 }
168 }
169 else {
170 Geom2dAdaptor_Curve acur1(aCur2d1);
171 Geom2dAdaptor_Curve acur2(aCur2d2);
0b85f9a6 172 Geom2dGcc_QCurve qcur1(acur1, GccEnt_unqualified);
173 Geom2dGcc_QCurve qcur2(acur2, GccEnt_unqualified);
54e37688 174 Geom2dGcc_Lin2d2TanIter lintan(qcur1, qcur2 , par1, par2, tol);
7fd59977 175 if (lintan.IsDone()) {
176 gp_Lin2d lin = lintan.ThisSolution();
177 Handle(Geom2d_Line) glin = new Geom2d_Line(lin);
178 DrawTrSurf::Set(argv[1], glin);
179 } else {
586db386 180 di << "Faulty : tangent line is not done.\n";
7fd59977 181 }
182 }
183 return 0;
184}
185
186static Standard_Integer BUC60970 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
187{
188 if(argc!=3)
189 {
586db386 190 di << "Usage : " << argv[0] << " shape result\n";
7fd59977 191 return 1;
192 }
193
194 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
195 if(aContext.IsNull()) {
196 di << "use 'vinit' command before " << argv[0] << "\n";
197 return 1;
198 }
199
200 TopoDS_Shape aResult = DBRep::Get(argv[1]);
201
202 BRepBuilderAPI_MakeWire bRepSpineWire;
203 TopExp_Explorer exp_(aResult, TopAbs_WIRE);
204
205 Standard_Integer i = 0;
206 for(;exp_.More();exp_.Next()){
207 i++;
208 bRepSpineWire.Add(TopoDS::Wire(exp_.Current()));
209 }
210
211 //printf("total no of wires are ............. %d\n", i);
212 di << "total no of wires are ............. " << i << "\n";
213
214 TopoDS_Wire spineWire = bRepSpineWire.Wire();
0577ae8c 215 aContext->Display (new AIS_Shape(spineWire), Standard_False);
7fd59977 216
217 DBRep::Set("slineW",spineWire);
218
219 TopExp_Explorer spineWireExp(spineWire, TopAbs_EDGE);
220 Standard_Real first, last;
857ffd5e 221 Handle(Geom_Curve) curl_ = BRep_Tool::Curve(TopoDS::Edge(spineWireExp.Current()), first, last);
7fd59977 222 gp_Pnt firstPnt;
223 gp_Vec tanVec;
224 curl_->D1(first, firstPnt, tanVec);
225 tanVec.Normalize();
226 gp_Dir tanDir(tanVec.X(), tanVec.Y(), tanVec.Z());
227 gp_Ax2 gpAx2(firstPnt, tanDir);
228 gp_Circ gpCirc(gpAx2, 2.5);
229 BRepBuilderAPI_MakeWire aMWire(BRepBuilderAPI_MakeEdge(new Geom_Circle(gpCirc)).Edge());
230 TopoDS_Wire topoWire(aMWire);
0577ae8c 231 aContext->Display (new AIS_Shape(topoWire), Standard_False);
7fd59977 232
233 DBRep::Set("topoW",topoWire);
234
235 BRepOffsetAPI_MakePipeShell bRepPipe(spineWire);
236 bRepPipe.Add(topoWire);
237 bRepPipe.Build();
238
0577ae8c 239 aContext->Display (new AIS_Shape(bRepPipe.Shape()), Standard_True);
7fd59977 240
241 DBRep::Set(argv[2],bRepPipe.Shape());
242
243 return 0;
244}
245
246static Standard_Integer BUC60818(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
247{
248 if(argc!=1)
249 {
250 di << "Usage : " << argv[0] << "\n";
251 return -1;
252 }
253
254 Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
255 if(myAISContext.IsNull())
256 {
257 di << "use 'vinit' command before " << argv[0] << "\n";
258 return -1;
259 }
260
261 // TRIHEDRON
262 Handle(AIS_Trihedron) aTrihedron;
263 Handle(Geom_Axis2Placement) aTrihedronAxis=new Geom_Axis2Placement(gp::XOY());
264 aTrihedron=new AIS_Trihedron(aTrihedronAxis);
0577ae8c 265 myAISContext->Display (aTrihedron, Standard_True);
7fd59977 266
404c8936 267 Standard_DISABLE_DEPRECATION_WARNINGS
7fd59977 268 myAISContext->OpenLocalContext();
404c8936 269 Standard_ENABLE_DEPRECATION_WARNINGS
7fd59977 270 myAISContext->Load(aTrihedron,0);
271
272 myAISContext->SetAutomaticHilight( Standard_False );
273
274 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
275 double Xv,Yv;
276 myV3dView->Project(0,0,0,Xv,Yv);
277
278 Standard_Integer Xp,Yp;
279 myV3dView->Convert(Xv,Yv,Xp,Yp);
280
0577ae8c 281 myAISContext->MoveTo (Xp,Yp, myV3dView, Standard_False);
282 myAISContext->MoveTo (Xp,Yp, myV3dView, Standard_True);
7fd59977 283
284 if (myAISContext->HasDetected( ))
285 di << "has detected shape : OK" << "\n";
286 else di << "has detected shape : bugged - Faulty " << "\n";
287
288 myAISContext->SetAutomaticHilight( Standard_True );
289
290 return 0;
291}
292
60bf98ae 293static Standard_Integer BUC60915_1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
7fd59977 294{
295 if (argc > 1) {
586db386 296 di<<"Function don't has parameters\n";
7fd59977 297 return 1;
298 }
299
60bf98ae 300 if(ViewerTest::GetAISContext().IsNull())
301 {
302 di << "View was not created. Use 'vinit' command before "
303 << argv[0] << "\n";
304 return 1;
305 }
306 Handle(AIS_InteractiveContext) context = ViewerTest::GetAISContext();
7fd59977 307
308 //The following dimesion code has problems regarding arrow_size. The desired effect is not produced.
309 /***************************************/
310 //First view
311 /***************************************/
312 gp_Pnt p1 = gp_Pnt(602.51,50.,0.);
313 gp_Pnt p2 = gp_Pnt(602.51,200.,0.);
314 gp_Pnt p3 = gp_Pnt(102.51,200.,0.);
315 gp_Pnt p4 = gp_Pnt(102.51,170.,0.);
316 gp_Pnt p5 = gp_Pnt(502.51,170.,0.);
317 gp_Pnt p6 = gp_Pnt(502.51,80.,0.);
318 gp_Pnt p7 = gp_Pnt(102.51,80.,0.);
319 gp_Pnt p8 = gp_Pnt(102.51,50.,0.);
320 TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(p1);
321 TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(p2);
322 TopoDS_Vertex V3 = BRepBuilderAPI_MakeVertex(p3);
323 TopoDS_Vertex V4 = BRepBuilderAPI_MakeVertex(p4);
324 TopoDS_Vertex V5 = BRepBuilderAPI_MakeVertex(p5);
325 TopoDS_Vertex V6 = BRepBuilderAPI_MakeVertex(p6);
326 TopoDS_Vertex V7 = BRepBuilderAPI_MakeVertex(p7);
327 TopoDS_Vertex V8 = BRepBuilderAPI_MakeVertex(p8);
328 gp_Pnt plnpt(0, 0, 0);
329 gp_Dir plndir(0, 0, 1);
330 Handle(Geom_Plane) pln = new Geom_Plane(plnpt,plndir);
60bf98ae 331 Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
332 anAspect->MakeArrows3d (Standard_True);
333 anAspect->ArrowAspect()->SetAngle (M_PI/180.0 * 10.0);
7fd59977 334 /***************************************/
335 //dimension "L 502.51"
336 /***************************************/
a6eb515f 337 Handle(AIS_LengthDimension) len = new AIS_LengthDimension(V2, V3, pln->Pln());
60bf98ae 338 anAspect->ArrowAspect()->SetLength (30.0);
339 len->SetDimensionAspect (anAspect);
0577ae8c 340 context->Display (len, Standard_False);
7fd59977 341 /***************************************/
342 //dimension "L 90"
343 /***************************************/
60bf98ae 344 Handle(AIS_LengthDimension) len1 = new AIS_LengthDimension(V7, V4, pln->Pln());
345 len1->SetDimensionAspect (anAspect);
346 len1->SetFlyout (30.0);
347 anAspect->ArrowAspect()->SetLength (100.0);
0577ae8c 348 context->Display (len1, Standard_False);
7fd59977 349 /***************************************/
350 //dimension "L 150"
351 /***************************************/
a6eb515f 352 Handle(AIS_LengthDimension) len2 = new AIS_LengthDimension(V1, V2, pln->Pln());
60bf98ae 353 len2->SetDimensionAspect (anAspect);
0577ae8c 354 context->Display (len2, Standard_False);
7fd59977 355 /***************************************/
356 //dimension "R 88.58"
357 /***************************************/
358 gp_Circ cir = gp_Circ(gp_Ax2(gp_Pnt(191.09, -88.58, 0), gp_Dir(0, 0, 1)), 88.58);
359 TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(cir,gp_Pnt(191.09,0,0.),gp_Pnt(191.09,-177.16,0.) );
a6eb515f 360 Handle(AIS_RadiusDimension) dim1 = new AIS_RadiusDimension(E1);
60bf98ae 361 dim1->SetDimensionAspect (anAspect);
0577ae8c 362 context->Display (dim1, Standard_False);
7fd59977 363 /***************************************/
364 //dimension "R 43.80"
365 /***************************************/
366 gp_Circ cir1 = gp_Circ(gp_Ax2(gp_Pnt(191.09, -88.58, 0), gp_Dir(0, 0, 1)), 43.80);
367 TopoDS_Edge E_cir1 = BRepBuilderAPI_MakeEdge(cir1);
a6eb515f 368 dim1 = new AIS_RadiusDimension(E_cir1);
60bf98ae 369 anAspect->ArrowAspect()->SetLength (60.0);
370 dim1->SetDimensionAspect (anAspect);
0577ae8c 371 context->Display (dim1, Standard_False);
7fd59977 372 /***************************************/
373 //dimension "R 17.86"
374 /***************************************/
375 gp_Circ cir2 = gp_Circ(gp_Ax2(gp_Pnt(566.11, -88.58, 0), gp_Dir(0, 0, -1)), 17.86);
376 TopoDS_Edge E_cir2 = BRepBuilderAPI_MakeEdge(cir2);
a6eb515f 377 dim1 = new AIS_RadiusDimension(E_cir2);
60bf98ae 378 anAspect->ArrowAspect()->SetLength (40.0);
379 dim1->SetDimensionAspect (anAspect);
0577ae8c 380 context->Display (dim1, Standard_True);
7fd59977 381
382 return 0;
383}
384
385static Standard_Integer OCC138 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
386{
387 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
388 if(aContext.IsNull()) {
389 di << "use 'vinit' command before " << argv[0] << "\n";
390 return 1;
391 }
392
393 BRepPrimAPI_MakeBox box1(gp_Pnt(0, 0, 0), gp_Pnt(100, 100, 100));
394 BRepPrimAPI_MakeBox box2(gp_Pnt(120, 120, 120), gp_Pnt(300, 300,300));
395 BRepPrimAPI_MakeBox box3(gp_Pnt(320, 320, 320), gp_Pnt(500, 500,500));
396
c3282ec1 397 Handle(AIS_InteractiveObject) ais1 = new AIS_Shape(box1.Shape());
398 Handle(AIS_InteractiveObject) ais2 = new AIS_Shape(box2.Shape());
399 Handle(AIS_InteractiveObject) ais3 = new AIS_Shape(box3.Shape());
7fd59977 400
0577ae8c 401 aContext->Display (ais1, Standard_False);
402 aContext->Display (ais2, Standard_False);
403 aContext->Display (ais3, Standard_False);
7fd59977 404
0577ae8c 405 aContext->AddOrRemoveSelected (ais1, Standard_False);
406 aContext->AddOrRemoveSelected (ais2, Standard_False);
407 aContext->AddOrRemoveSelected (ais3, Standard_False);
7fd59977 408
c3282ec1 409 di << "\n No of currents = " << aContext->NbSelected();
7fd59977 410
c3282ec1 411 aContext->InitSelected();
7fd59977 412
413 int count = 1;
c3282ec1 414 while(aContext->MoreSelected())
7fd59977 415 {
416 di << "\n count is = " << count++;
c3282ec1 417 Handle(AIS_InteractiveObject) ais = aContext->SelectedInteractive();
0577ae8c 418 aContext->AddOrRemoveSelected (ais, Standard_False);
c3282ec1 419 aContext->InitSelected();
7fd59977 420 }
421
0577ae8c 422 aContext->UpdateCurrentViewer();
423
7fd59977 424 return 0;
425}
426
7fd59977 427static int geom_get_2Dpt_from_3Dpt(const gp_Pnt& pnt3d, const gp_Pln& pln, gp_Pnt2d& pnt2d)
428{
429 int ret = 0;
857ffd5e 430 Handle(Geom_Plane) gpln = new Geom_Plane(pln);
7fd59977 431 GeomAdaptor_Surface adsur(gpln);
432 Extrema_ExtPS extps(pnt3d, adsur, 0.001, 0.001);
433 if( extps.IsDone() )
434 {
435 int index;
436 for(index=1; index<= extps.NbExt(); index++ )
437 {
438 Extrema_POnSurf pons = extps.Point(index);
439 Standard_Real U, V;
440 pons.Parameter(U, V);
441 pnt2d.SetCoord(U, V);
442 ret = 1;
443 }
444 }
445 return ret;
446}
447
448static Standard_Integer OCC353 (Draw_Interpretor& di, Standard_Integer , const char ** )
449{
450 gp_Ax2 ax21( gp_Pnt(100,0,0), gp_Dir(0,0,1) );
857ffd5e 451 Handle(Geom_Circle) h_cir1 = new Geom_Circle( ax21, 25 );
7fd59977 452
453 gp_Ax2 ax22( gp_Pnt(-100,0,0), gp_Dir(0,0,1) );
857ffd5e 454 Handle(Geom_Circle) h_cir2 = new Geom_Circle( ax22, 25 );
7fd59977 455
456 gp_Pln refpln( gp_Pnt(0,0,0), gp_Dir(0,0,1) );
857ffd5e 457 Handle(Geom2d_Curve) cir2d1 = GeomAPI::To2d(h_cir1, refpln);
458 Handle(Geom2d_Curve) cir2d2 = GeomAPI::To2d(h_cir2, refpln);
7fd59977 459
460 Geom2dAdaptor_Curve adop1(cir2d1);
461 Geom2dAdaptor_Curve adop2(cir2d2);
462
463 Geom2dGcc_QualifiedCurve qcur1(adop1, GccEnt_enclosing);
464 Geom2dGcc_QualifiedCurve qcur2(adop2, GccEnt_enclosing);
465
857ffd5e 466 Handle(Geom_CartesianPoint) h_carpt = new Geom_CartesianPoint(0,175,0);
7fd59977 467
468 gp_Pnt pt3d = h_carpt->Pnt();
469 gp_Pnt2d pt2d;
470 geom_get_2Dpt_from_3Dpt(pt3d, refpln, pt2d);
471
472 Standard_CString st;
473 st = "cir2d1";
474 DrawTrSurf::Set(st,cir2d1);
475 st = "cir2d2";
476 DrawTrSurf::Set(st,cir2d2);
477 st = "pt2d";
478 DrawTrSurf::Set(st,pt2d);
479
857ffd5e 480 Handle(Geom2d_CartesianPoint) pt = new Geom2d_CartesianPoint(pt2d);
7fd59977 481 Geom2dGcc_Circ2d3Tan sol( qcur1, qcur2, pt, 0.001, 0.0, 0.0);
482
483 int res = 0;
484 Standard_Character buf[10];
485 buf[0] = '\0';
486
487 if( sol.IsDone() ) {
488 res = sol.NbSolutions();
489 for(Standard_Integer i=1;i<=res;i++) {
490 Handle(Geom2d_Circle) aC = new Geom2d_Circle(sol.ThisSolution(i));
91322f44 491 Sprintf(buf,"Result_%d",i);
7fd59977 492 st = buf;
493 DrawTrSurf::Set(st,aC);
494 }
495 }
496 else
497 di << "\n Faulty: no solutions found ";
498 //printf("\n Faulty: no solutions found ");
499
500 //printf("\n Num of solutions are %d ", res );
501 di << "\n Num of solutions are " << res << " ";
502
503 return 0;
504}
505
506static Standard_Integer OCC280 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
507{
508 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
509 if(aContext.IsNull())
510 {
511 di << "use 'vinit' command before " << argv[0] << "\n";
512 return -1;
513 }
514 if ( argc != 3) {
586db386 515 di << "ERROR : Usage : " << argv[0] << " hlr=0/1 setsurfecedetail=0/1; set perspecrive view\n";
7fd59977 516 return 1;
517 }
518
91322f44 519 Standard_Integer HLR = Draw::Atoi(argv[1]);
7fd59977 520 if (HLR != 0) {
521 HLR = 1;
522 }
523
18d715bd 524 TCollection_AsciiString anOldName = ViewerTest::GetCurrentViewName();
7fd59977 525 Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
5e27df78 526 aViewer->SetDefaultTypeOfView (V3d_PERSPECTIVE);
18d715bd 527 Handle(Aspect_Window) asp = ViewerTest::CurrentView()->Window();
7fd59977 528 Handle(V3d_View) aNewView = aViewer->CreateView();
5e27df78 529 ViewerTest::CurrentView (aNewView);
18d715bd 530 TCollection_AsciiString aNewName=anOldName + "_new";
531 ViewerTest::InitViewName(aNewName,ViewerTest::CurrentView());
5e27df78 532 aNewView->SetWindow (asp);
7fd59977 533 if (!asp->IsMapped()) asp->Map();
18d715bd 534 aNewView->Redraw();
535 ViewerTest::RemoveView(anOldName,false);
5e27df78 536 ViewerTest::UnsetEventManager();
537 ViewerTest::SetEventManager (new ViewerTest_EventManager (aNewView, ViewerTest::GetAISContext()));
538
de75ed09 539 if (HLR == 1)
540 {
541 di << "HLR\n";
18d715bd 542 ViewerTest::CurrentView()->SetComputedMode (Standard_True);
7fd59977 543 }
544
545 return 0;
546}
547
35e08fe8 548static Standard_Integer OCC232 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
7fd59977 549{
550 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
551 if(aContext.IsNull()) {
552 di << "use 'vinit' command before " << argv[0] << "\n";
553 return 1;
554 }
555
556 BRep_Builder builder;
557 TopoDS_Compound comp;
558 TopoDS_CompSolid cs1, cs2;
559
560 builder.MakeCompound(comp);
561 builder.MakeCompSolid(cs1);
562 builder.MakeCompSolid(cs2);
563
564 TopoDS_Shape sh1 = BRepPrimAPI_MakeBox(gp_Pnt(0, 0, 0), 100, 100, 100).Shape();
565 TopoDS_Shape sh2 = BRepPrimAPI_MakeBox(gp_Pnt(100, 0, 0), 100, 100, 100).Shape();
566 TopoDS_Shape sh3 = BRepPrimAPI_MakeBox(gp_Pnt(200, 0, 0), 100, 100, 100).Shape();
567 builder.Add(cs1, sh1);
568 builder.Add(cs1, sh2);
569 builder.Add(cs1, sh3);
570
571 TopoDS_Shape sh4 = BRepPrimAPI_MakeBox(gp_Pnt(0, 500, 0), 100, 100, 100).Shape();
572 TopoDS_Shape sh5 = BRepPrimAPI_MakeBox(gp_Pnt(100, 500, 0), 100, 100, 100).Shape();
573 TopoDS_Shape sh6 = BRepPrimAPI_MakeBox(gp_Pnt(200, 500, 0), 100, 100, 100).Shape();
574
575 builder.Add(cs2, sh4);
576 builder.Add(cs2, sh5);
577 builder.Add(cs2, sh6);
578
579 builder.Add(comp, cs1);
580 builder.Add(comp, cs2);
581
857ffd5e 582 Handle(AIS_Shape) ais = new AIS_Shape(comp);
0577ae8c 583 aContext->Display (ais, Standard_False);
7fd59977 584
585 TopExp_Explorer exp(comp, TopAbs_COMPSOLID);
586 while(exp.More())
587 {
588 //printf("\n TopAbs_COMPSOLID is there \n");
589 di << "\n TopAbs_COMPSOLID is there \n";
590 exp.Next();
591 }
592
593 Handle (StdSelect_ShapeTypeFilter) filt = new StdSelect_ShapeTypeFilter(TopAbs_COMPSOLID);
594 aContext->AddFilter(filt);
404c8936 595 Standard_DISABLE_DEPRECATION_WARNINGS
0577ae8c 596 aContext->CloseAllContexts (Standard_False);
7fd59977 597 aContext->OpenLocalContext();
598 aContext->ActivateStandardMode(TopAbs_SOLID);
404c8936 599 Standard_ENABLE_DEPRECATION_WARNINGS
0577ae8c 600
601 aContext->UpdateCurrentViewer();
602
7fd59977 603 return 0;
604}
605
606static Standard_Integer OCC138LC (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
607{
608 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
609 if(aContext.IsNull()) {
610 di << "use 'vinit' command before " << argv[0] << "\n";
611 return 1;
612 }
613
614 BRepPrimAPI_MakeBox box1(gp_Pnt(0, 0, 0), gp_Pnt(100, 100, 100));
615 BRepPrimAPI_MakeBox box2(gp_Pnt(120, 120, 120), gp_Pnt(300, 300,300));
616 BRepPrimAPI_MakeBox box3(gp_Pnt(320, 320, 320), gp_Pnt(500, 500,500));
617
543a9964 618 Handle(AIS_InteractiveObject) ais1 = new AIS_Shape(box1.Shape());
619 Handle(AIS_InteractiveObject) ais2 = new AIS_Shape(box2.Shape());
620 Handle(AIS_InteractiveObject) ais3 = new AIS_Shape(box3.Shape());
7fd59977 621
0577ae8c 622 aContext->Display (ais1, Standard_False);
623 aContext->Display (ais2, Standard_False);
624 aContext->Display (ais3, Standard_False);
7fd59977 625
0577ae8c 626 aContext->AddOrRemoveSelected (ais1, Standard_False);
627 aContext->AddOrRemoveSelected (ais2, Standard_False);
628 aContext->AddOrRemoveSelected (ais3, Standard_False);
7fd59977 629
630 di << "\n No of selected = " << aContext->NbSelected();
631
632 aContext->InitSelected();
633
634 int count = 1;
635 while(aContext->MoreSelected())
636 {
637 di << "\n count is = %d" << count++;
857ffd5e 638 Handle(AIS_InteractiveObject) ais = aContext->SelectedInteractive();
0577ae8c 639 aContext->AddOrRemoveSelected (ais, Standard_False);
7fd59977 640 aContext->InitSelected();
641 }
642
0577ae8c 643 aContext->UpdateCurrentViewer();
644
7fd59977 645 return 0;
646}
647
7fd59977 648#include <BRepBndLib.hxx>
649#include <Draw.hxx>
650//=======================================================================
651//function : OCC566
652//purpose :
653//=======================================================================
654static Standard_Integer OCC566(Draw_Interpretor& di,Standard_Integer n,const char ** a)
655{
656 if (n < 2) {
586db386 657 di<<"Usage: " << a[0] << " shape [ xmin ymin zmin xmax ymax zmax]\n";
7fd59977 658 return 1;
659 }
660 TopoDS_Shape S = DBRep::Get(a[1]);
661 if (S.IsNull()) return 1;
662 Bnd_Box B;
663 BRepBndLib::AddClose(S,B);
664 Standard_Real axmin,aymin,azmin,axmax,aymax,azmax;
665 B.Get(axmin,aymin,azmin,axmax,aymax,azmax);
666 di << axmin<<" "<< aymin<<" "<< azmin<<" "<< axmax<<" "<< aymax<<" "<< azmax;
667 if (n >= 8) {
668 Draw::Set(a[2],axmin) ;
669 Draw::Set(a[3],aymin) ;
670 Draw::Set(a[4],azmin) ;
671 Draw::Set(a[5],axmax) ;
672 Draw::Set(a[6],aymax) ;
673 Draw::Set(a[7],azmax) ;
674 }
675 return 0;
676}
677
678#include <BRepFilletAPI_MakeFillet.hxx>
679//=======================================================================
680//function : OCC570
681//purpose :
682//=======================================================================
683static Standard_Integer OCC570 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
684{
685 if (argc < 2) {
586db386 686 di<<"Usage: " << argv[0] << " result\n";
7fd59977 687 return 1;
688 }
689
690 BRepPrimAPI_MakeBox mkBox(100.,100.,100.);
691 TopoDS_Shape aBox = mkBox.Shape();
692
693 TopExp_Explorer aExp;
694 aExp.Init(aBox,TopAbs_WIRE);
695 if (aExp.More())
696 {
697 TopoDS_Shape aWire = aExp.Current();
698
699 aExp.Init(aWire,TopAbs_EDGE);
700 TopoDS_Edge e1 = TopoDS::Edge(aExp.Current()); aExp.Next();
701 TopoDS_Edge e2 = TopoDS::Edge(aExp.Current()); aExp.Next();
702 TopoDS_Edge e3 = TopoDS::Edge(aExp.Current()); aExp.Next();
703 TopoDS_Edge e4 = TopoDS::Edge(aExp.Current());
704
705 try
706 {
707 OCC_CATCH_SIGNALS
708 BRepFilletAPI_MakeFillet mkFillet(aBox);
709 mkFillet.SetContinuity(GeomAbs_C1,.001);
710
711 // Setup variable fillet data
712 TColgp_Array1OfPnt2d t_pnt(1,4);
713 t_pnt.SetValue(1,gp_Pnt2d(0.0,5.0));
714 t_pnt.SetValue(2,gp_Pnt2d(0.3,15.0));
715 t_pnt.SetValue(3,gp_Pnt2d(0.7,15.0));
716 t_pnt.SetValue(4,gp_Pnt2d(1.0,5.0));
717
718 // HERE:
719 // It is impossible to build fillet if at least one edge
720 // with variable radius is added!!! If all are constant, everything is ok.
721 mkFillet.Add(t_pnt,e1);
722 mkFillet.Add(5.0,e2);
723 mkFillet.Add(t_pnt,e3);
724 mkFillet.Add(5.0,e4);
725
726 mkFillet.Build();
727 TopoDS_Shape aFinalShape = mkFillet.Shape();
728
729 DBRep::Set(argv[1],aFinalShape);
730 }
731 catch(Standard_Failure)
732 {
586db386 733 di << argv[0] << ": Exception in fillet\n";
7fd59977 734 return 2;
735 }
736 }
737
738 return 0;
739}
740
741#include <Law_Interpol.hxx>
742
743static Standard_Real t3d = 1.e-4;
744static Standard_Real t2d = 1.e-5;
745static Standard_Real ta = 1.e-2;
746static Standard_Real fl = 1.e-3;
747static Standard_Real tapp_angle = 1.e-2;
748static GeomAbs_Shape blend_cont = GeomAbs_C1;
749
7fd59977 750static BRepFilletAPI_MakeFillet* Rake = 0;
751static char name[100];
752
753static void printtolblend(Draw_Interpretor& di)
754{
755 di<<"tolerance ang : "<<ta<<"\n";
756 di<<"tolerance 3d : "<<t3d<<"\n";
757 di<<"tolerance 2d : "<<t2d<<"\n";
758 di<<"fleche : "<<fl<<"\n";
759
760 di<<"tolblend "<<ta<<" "<<t3d<<" "<<t2d<<" "<<fl<<"\n";
761}
762
763static Standard_Integer MKEVOL(Draw_Interpretor& di,
764 Standard_Integer narg,
765 const char ** a)
766{
767 if(Rake != 0) {delete Rake; Rake = 0;}
768 printtolblend(di);
769 if (narg < 3) return 1;
770 TopoDS_Shape V = DBRep::Get(a[2]);
771 Rake = new BRepFilletAPI_MakeFillet(V);
772 Rake->SetParams(ta,t3d,t2d,t3d,t2d,fl);
773 Rake->SetContinuity(blend_cont, tapp_angle);
774 if (narg == 4) {
775 ChFi3d_FilletShape FSh = ChFi3d_Rational;
776 if (!strcasecmp(a[3], "Q")) {
777 FSh = ChFi3d_QuasiAngular;
778 }
779 else if (!strcasecmp(a[3], "P")) {
780 FSh = ChFi3d_Polynomial;
781 }
782 Rake->SetFilletShape(FSh);
783 }
784 strcpy(name, a[1]);
785 return 0;
786}
787
788static Standard_Integer UPDATEVOL(Draw_Interpretor& di,
789 Standard_Integer narg,
790 const char ** a)
791{
792 if(Rake == 0){
586db386 793 di << "MakeFillet non initialise\n";
7fd59977 794 return 1 ;
795 }
796 if(narg%2 != 0 || narg < 4) return 1;
797 TColgp_Array1OfPnt2d uandr(1,(narg/2)-1);
798 Standard_Real Rad, Par;
799 TopoDS_Shape aLocalEdge(DBRep::Get(a[1],TopAbs_EDGE));
800 TopoDS_Edge E = TopoDS::Edge(aLocalEdge);
801 for (Standard_Integer ii = 1; ii <= (narg/2)-1; ii++){
91322f44 802 Par = Draw::Atof(a[2*ii]);
803 Rad = Draw::Atof(a[2*ii + 1]);
7fd59977 804 uandr.ChangeValue(ii).SetCoord(Par,Rad);
805 }
806 //HELPDESK: Add law creation
807 const Standard_Boolean aLawMode = !strcmp(a[0],"OCC570evollaw");
808 if (aLawMode)
809 {
586db386 810 di<<"INFO: Using law to define variable fillet\n";
7fd59977 811 Handle(Law_Interpol) law = new Law_Interpol;
812 law->Set(uandr);
813 Rake->Add(law,E);
814 }
815 else
816 Rake->Add(uandr,E);
817
818 return 0;
819}
820
821static Standard_Integer BUILDEVOL(Draw_Interpretor& di,
822 Standard_Integer,
823 const char **)
824{
825 if(Rake == 0){
586db386 826 di << "MakeFillet non initialise\n";
7fd59977 827 return 1 ;
828 }
829 Rake->Build();
830 if(Rake->IsDone()){
831 TopoDS_Shape result = Rake->Shape();
832 DBRep::Set(name,result);
833 if(Rake != 0) {delete Rake; Rake = 0;}
834 return 0;
835 }
836 if(Rake != 0) {delete Rake; Rake = 0;}
837 return 1;
838}
839
840#include <TColGeom_SequenceOfCurve.hxx>
841#include <Geom_TrimmedCurve.hxx>
842#include <GeomFill_NSections.hxx>
843#include <BRepBuilderAPI_MakeFace.hxx>
844//=======================================================================
845//function : OCC606
846//purpose :
847//=======================================================================
848static Standard_Integer OCC606 ( Draw_Interpretor& di, Standard_Integer n, const char ** a )
849{
850 if (n != 3 && n != 4)
851 {
586db386 852 di << "Usage : " << a[0] << " result shape [-t]\n";
7fd59977 853 return 0;
854 }
855
856 Standard_Boolean TrimMode = (n == 4);
586db386 857 if (TrimMode) di<<"INFO: Using trimmed curves...\n";
858 else di<<"INFO: Using non trimmed curves...\n";
7fd59977 859
860 TopoDS_Shape S = DBRep::Get(a[2]);
861
862 TopExp_Explorer t_exp(S,TopAbs_EDGE);
863 TColGeom_SequenceOfCurve n_curves1;
864 TColStd_SequenceOfReal np;
865 Standard_Real param = 5.0;
866
867 for (;t_exp.More();t_exp.Next())
868 {
869 Standard_Real f,l;
870 Handle(Geom_Curve) h_cur = BRep_Tool::Curve(TopoDS::Edge(t_exp.Current()),f,l);
871 if (!h_cur.IsNull())
872 {
873 if (TrimMode) h_cur = new Geom_TrimmedCurve(h_cur,f,l);
874
875 n_curves1.Append(h_cur);
876 np.Append(param);
877 param += 1.0;
878 }
879 }
880
881 if (n_curves1.Length()>1 && !np.IsEmpty())
882 {
883 try
884 {
885 OCC_CATCH_SIGNALS
886 GeomFill_NSections b_surface1(n_curves1, np);
887 b_surface1.ComputeSurface();
888 Handle(Geom_BSplineSurface) result_surf1 = b_surface1.BSplineSurface();
889 if (!result_surf1.IsNull())
890 {
1c72dff6 891 BRepBuilderAPI_MakeFace b_face1(result_surf1, Precision::Confusion());
7fd59977 892 TopoDS_Face bsp_face1 = b_face1.Face();
893 DBRep::Set(a[1],bsp_face1);
894 }
895 }
896 catch(Standard_Failure)
897 {
586db386 898 di<<"ERROR: Exception in GeomFill_NSections\n";
7fd59977 899 }
900 }
901
902
903 return 0;
904}
905
906//=======================================================================
907//function : OCC813
908//purpose :
909//=======================================================================
910static Standard_Integer OCC813 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
911{
912 if (argc < 3)
913 {
586db386 914 di << "Usage : " << argv[0] << " U V\n";
7fd59977 915 return 1;
916 }
917
918 Standard_CString str;
91322f44 919 Standard_Real U = Draw::Atof(argv[1]);
920 Standard_Real V = Draw::Atof(argv[2]);
7fd59977 921
922 //Between ellipse and point:
923
924 Handle(Geom_Ellipse) ell = new Geom_Ellipse(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
925 gp_Dir(0.173648,0.984808,0.000000),
926 gp_Dir(-0.932169,0.164367,-0.322560)), 150, 100);
927 Handle(Geom_Plane) plne = new Geom_Plane(gp_Ax3(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
928 gp_Dir(0.173648,0.984808,0.000000),
929 gp_Dir(-0.932169,0.164367,-0.322560))) );
930
931 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
932
933 gp_Pnt2d pt2d(U,V);
934 gp_Pln pln = plne->Pln();
935
936 str = "OCC813_pnt"; DrawTrSurf::Set(str,pt2d);
937
938 Handle(Geom2d_Curve) curve2d = GeomAPI::To2d(ell,pln);
939 Geom2dAdaptor_Curve acur(curve2d);
940 Geom2dGcc_QualifiedCurve qcur(acur, GccEnt_outside);
941
942 str = "OCC813_ell"; DrawTrSurf::Set(str,curve2d);
943 if(!aContext.IsNull()) {
944 Handle(AIS_Shape) aisp =
945 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(curve2d, pln)).Edge());
0577ae8c 946 aContext->Display (aisp, Standard_False);
7fd59977 947 }
948
949 //This does not give any solutions.
950 Geom2dGcc_Lin2d2Tan lintan(qcur, pt2d, 0.1);
951 di<<"OCC813 nb of solutions = "<<lintan.NbSolutions()<<"\n";
952
953 Standard_Character abuf[16];
954 Standard_CString st = abuf;
955
956 Standard_Integer i;
957 for(i=1;i<=lintan.NbSolutions();i++) {
91322f44 958 Sprintf(abuf,"lintan_%d",i);
7fd59977 959 Handle(Geom2d_Line) glin = new Geom2d_Line(lintan.ThisSolution(i));
960 DrawTrSurf::Set(st,glin);
961 if(!aContext.IsNull()) {
962 Handle(AIS_Shape) aisp =
0577ae8c 963 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(glin, pln)).Edge());
964 aContext->Display (aisp, Standard_False);
7fd59977 965 }
966 }
967
0577ae8c 968 if (!aContext.IsNull())
969 {
970 aContext->UpdateCurrentViewer();
971 }
972
7fd59977 973 return 0;
974}
975
976//=======================================================================
977//function : OCC814
978//purpose :
979//=======================================================================
980static Standard_Integer OCC814 (Draw_Interpretor& di, Standard_Integer argc,const char ** argv)
981{
982 if (argc > 1)
983 {
984 di << "Usage : " << argv[0] << "\n";
985 return 1;
986 }
987
988 Standard_CString str;
989
990 //Between Ellipse and Circle:
991
992 Handle(Geom_Circle) cir = new Geom_Circle(gp_Ax2(gp_Pnt(823.687192,502.366825,478.960440),
993 gp_Dir(0.173648,0.984808,0.000000),
994 gp_Dir(-0.932169,0.164367,-0.322560)), 50);
995 Handle(Geom_Ellipse) ell = new Geom_Ellipse(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
996 gp_Dir(0.173648,0.984808,0.000000),
997 gp_Dir(-0.932169,0.164367,-0.322560)), 150, 100);
998 Handle(Geom_Plane) plne = new Geom_Plane(gp_Ax3(gp_Ax2(gp_Pnt(1262.224429,425.040878,363.609716),
999 gp_Dir(0.173648,0.984808,0.000000),
1000 gp_Dir(-0.932169,0.164367,-0.322560))) );
1001
1002 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1003
1004 gp_Pln pln = plne->Pln();
1005 Handle(Geom2d_Curve) curve2d = GeomAPI::To2d(ell, pln);
1006 Handle(Geom2d_Curve) fromcurve2d = GeomAPI::To2d(cir, pln);
1007
1008 str = "OCC814_cir"; DrawTrSurf::Set(str,curve2d);
1009 str = "OCC814_ell"; DrawTrSurf::Set(str,fromcurve2d);
1010 if(!aContext.IsNull()) {
1011 Handle(AIS_Shape) aisp =
1012 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(curve2d, pln)).Edge());
0577ae8c 1013 aContext->Display (aisp, Standard_False);
7fd59977 1014 }
1015 if(!aContext.IsNull()) {
1016 Handle(AIS_Shape) aisp =
1017 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(fromcurve2d, pln)).Edge());
0577ae8c 1018 aContext->Display (aisp, Standard_False);
7fd59977 1019 }
1020
1021 Geom2dAdaptor_Curve acur(curve2d), afromcur(fromcurve2d);
1022
1023 Geom2dGcc_QualifiedCurve qcur(acur, GccEnt_outside) ;
1024 Geom2dGcc_QualifiedCurve qfromcur(afromcur, GccEnt_outside) ;
1025
1026 //This does not give any solutions.
1027 Geom2dGcc_Lin2d2Tan lintan(qcur, qfromcur, 0.1);
1028 di<<"OCC814 nb of solutions = "<<lintan.NbSolutions()<<"\n";
1029
1030 Standard_Character abuf[16];
1031 Standard_CString st = abuf;
1032
1033 Standard_Integer i;
1034 for(i=1;i<=lintan.NbSolutions();i++) {
91322f44 1035 Sprintf(abuf,"lintan_%d",i);
7fd59977 1036 Handle(Geom2d_Line) glin = new Geom2d_Line(lintan.ThisSolution(i));
1037 DrawTrSurf::Set(st,glin);
1038 if(!aContext.IsNull()) {
1039 Handle(AIS_Shape) aisp =
0577ae8c 1040 new AIS_Shape (BRepBuilderAPI_MakeEdge(GeomAPI::To3d(glin, pln)).Edge());
1041 aContext->Display (aisp, Standard_False);
7fd59977 1042 }
1043 }
1044
0577ae8c 1045 if (!aContext.IsNull())
1046 {
1047 aContext->UpdateCurrentViewer();
1048 }
1049
7fd59977 1050 return 0;
1051}
1052
1053#include <ShapeAnalysis_Wire.hxx>
1054#include <IntRes2d_SequenceOfIntersectionPoint.hxx>
1055#include <TColgp_SequenceOfPnt.hxx>
1056#include <ShapeFix_Wire.hxx>
1057//=======================================================================
1058//function : OCC884
1059//purpose :
1060//=======================================================================
1061static Standard_Integer OCC884 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1062{
1063 if (argc < 3 || argc > 5)
1064 {
586db386 1065 di << "Usage : " << argv[0] << " result shape [toler [maxtoler]]\n";
7fd59977 1066 return 1;
1067 }
1068
1069 TopoDS_Shape shape = DBRep::Get(argv[2]); //read the shape
1070
1071 TopExp_Explorer exp(shape, TopAbs_EDGE);
1072 if (!exp.More())
1073 {
586db386 1074 di<<"Error: no edge found\n";
7fd59977 1075 return 1;
1076 }
1077
1078 BRep_Builder builder;
1079 TopoDS_Wire wire;
1080 builder.MakeWire(wire);
1081 builder.Add(wire, TopoDS::Edge(exp.Current()));
1082
1083 // HelpDesk: Create planar face if possible
1084 TopoDS_Face face = BRepBuilderAPI_MakeFace(wire,Standard_True);
1085
1086 Handle(ShapeAnalysis_Wire) advWA = new ShapeAnalysis_Wire;
1087 advWA->Load(wire);
1088 advWA->SetFace(face);
1089 advWA->SetPrecision(0.001);
1090
1091 IntRes2d_SequenceOfIntersectionPoint points2d;
1092 TColgp_SequenceOfPnt points3d;
1093
1094 di << "Info: CheckSelfIntersectingEdge = " << (Standard_Integer) advWA->CheckSelfIntersectingEdge(1,points2d,points3d) << "\n";
1095
1096 ShapeExtend_Status status = ShapeExtend_FAIL1;
1097 if (advWA->StatusSelfIntersection(status))
1098 di << "Info: No P Curve found in the edge\n";
1099
1100 status = ShapeExtend_FAIL2;
1101 if (advWA->StatusSelfIntersection(status))
1102 di << "Info: No Vertices found in the edge\n";
1103
1104 status = ShapeExtend_DONE1;
1105 if (advWA->StatusSelfIntersection(status))
1106 di << "Info: Self-intersection found in the edge\n";
1107
1108 Standard_Integer i, num = points2d.Length();
1109 di << "Info: No. of self-intersection points : " << num << "\n";
1110
1111 char str[80];
75259fc5 1112 Standard_CString aName = str;
7fd59977 1113 for (i = 1; i <= num; ++i)
1114 {
1115 gp_Pnt pt = points3d(i);
1116 di << "Info: Intersecting pt : (" << pt.X() << ", " << pt.Y() << ", " << pt.Z() << ")\n";
91322f44 1117 Sprintf(str,"p_%d",i);
75259fc5 1118 DrawTrSurf::Set(aName,pt);
7fd59977 1119 }
1120
1121 Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire;
1122 sfw->Load(wire);
1123 sfw->SetFace(face);
1124
91322f44 1125 if (argc > 3) sfw->SetPrecision(Draw::Atof(argv[3])/*0.1*/);
1126 if (argc > 4) sfw->SetMaxTolerance(Draw::Atof(argv[4]));
7fd59977 1127 di << "Info: Precision is set to " << sfw->Precision() << "\n";
1128 di << "Info: MaxTolerance is set to " << sfw->MaxTolerance() << "\n";
1129
1130 sfw->ModifyTopologyMode() = 1;
1131 sfw->ModifyGeometryMode() = 1;
1132 sfw->FixSelfIntersectingEdgeMode() = 1;
1133 //printf("Info: FixSelfIntersection = %d\n",sfw->FixSelfIntersection());
1134 di << "Info: FixSelfIntersection = " << (Standard_Integer) sfw->FixSelfIntersection() << "\n";
1135
1136 DBRep::Set(argv[1],sfw->Wire());
1137
1138 status = ShapeExtend_OK;
1139 if (sfw->StatusSelfIntersection(status))
1140 di << "Info: ShapeExtend_OK : No intersection found\n";
1141 //printf("Info: ShapeExtend_OK : No intersection found\n");
1142
1143 status = ShapeExtend_FAIL1;
1144 if (sfw->StatusSelfIntersection(status))
1145 di << "Info: ShapeExtend_FAIL1 : analysis failed (edge has no pcurve, or no vertices etc.)\n";
1146
1147 status = ShapeExtend_FAIL2;
1148 if (sfw->StatusSelfIntersection(status))
1149 di << "Info: ShapeExtend_FAIL2 : self-intersection was found, but not fixed because of limit of increasing tolerance (MaxTolerance)\n";
1150
1151 status = ShapeExtend_FAIL3;
1152 if (sfw->StatusSelfIntersection(status))
1153 di << "Info: ShapeExtend_FAIL3 : intercestion of non adjacent edges found, but not fixed because of limit of increasing tolerance (MaxTolerance)\n";
1154
1155 status = ShapeExtend_DONE1;
1156 if (sfw->StatusSelfIntersection(status))
1157 di << "Info: ShapeExtend_DONE1 : tolerance of vertex was increased to fix self-intersection\n";
1158
1159 status = ShapeExtend_DONE2;
1160 if (sfw->StatusSelfIntersection(status))
1161 di << "Info: ShapeExtend_DONE2 : vertex was moved to fix self-intersection\n";
1162
1163 status = ShapeExtend_DONE3;
1164 if (sfw->StatusSelfIntersection(status))
1165 di << "Info: ShapeExtend_DONE3 : some edges were removed because of intersection\n";
1166
1167 status = ShapeExtend_DONE4;
1168 if (sfw->StatusSelfIntersection(status))
1169 di << "Info: ShapeExtend_DONE4 : pcurve(s) was(were) modified\n";
1170
1171 status = ShapeExtend_DONE5;
1172 if (sfw->StatusSelfIntersection(status))
1173 di << "Info: ShapeExtend_DONE5 : non adjacent intersection fixed by increasing tolerance of vertex(vertices)\n";
1174
1175 status = ShapeExtend_DONE6;
1176 if (sfw->StatusSelfIntersection(status))
1177 di << "Info: ShapeExtend_DONE6 : tolerance of edge was increased to hide intersection\n";
1178
1179 status = ShapeExtend_DONE7;
1180 if (sfw->StatusSelfIntersection(status))
1181 di << "Info: ShapeExtend_DONE7 : range of some edges was decreased to avoid intersection\n";
1182
1183 return 0;
1184}
1185
1186#include <Aspect_FillMethod.hxx>
1187//=======================================================================
1188//function : OCC1188
1189//purpose :
1190//=======================================================================
1191static Standard_Integer OCC1188 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1192{
1193 if (argc < 2 || argc > 3)
1194 {
586db386 1195 di << "Usage : " << argv[0] << " imagefile [filltype] : Load image as background\n";
7fd59977 1196 return 1;
1197 }
1198
1199 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1200 if(AISContext.IsNull())
1201 {
1202 di << "use 'vinit' command before " << argv[0] << "\n";
1203 return 1;
1204 }
1205
1206 Aspect_FillMethod aFillType = Aspect_FM_CENTERED;
1207 if (argc == 3)
1208 {
1209 const char* szType = argv[2];
1210 if (strcmp(szType, "NONE" ) == 0) aFillType = Aspect_FM_NONE;
1211 else if (strcmp(szType, "CENTERED") == 0) aFillType = Aspect_FM_CENTERED;
1212 else if (strcmp(szType, "TILED" ) == 0) aFillType = Aspect_FM_TILED;
1213 else if (strcmp(szType, "STRETCH" ) == 0) aFillType = Aspect_FM_STRETCH;
1214 else
1215 {
1216 di << "Wrong fill type : " << szType << "\n";
586db386 1217 di << "Must be one of CENTERED, TILED, STRETCH, NONE\n";
7fd59977 1218 return 1;
1219 }
1220 }
1221
1222 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
1223 V3dView->SetBackgroundImage(argv[1], aFillType, Standard_True);
1224
1225 return 0;
1226}
1227
7fd59977 1228#include <Graphic3d_MaterialAspect.hxx>
6262338c 1229#include <Prs3d_Drawer.hxx>
7fd59977 1230#include <Prs3d_ShadingAspect.hxx>
1231//=======================================================================
1232//function : OCC1174_1
1233//purpose :
1234//=======================================================================
1235static Standard_Integer OCC1174_1 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1236{
1237 if (argc != 2)
1238 {
586db386 1239 di << "Usage : " << argv[0] << " shape\n";
7fd59977 1240 return 1;
1241 }
1242
6262338c 1243 Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
1244 if(anAISContext.IsNull())
7fd59977 1245 {
1246 di << "use 'vinit' command before " << argv[0] << "\n";
1247 return 1;
1248 }
1249
6262338c 1250 TopoDS_Shape aShape = DBRep::Get(argv[1]);
1251
1252 Handle(AIS_Shape) anAisIO = new AIS_Shape(aShape);
7fd59977 1253
6262338c 1254 Quantity_Color aColF(0.0, 0.4, 0.0, Quantity_TOC_RGB);
1255 Quantity_Color aColB(0.0, 0.0, 0.6, Quantity_TOC_RGB);
7fd59977 1256
6262338c 1257 Handle(Prs3d_Drawer) aDrawer = anAisIO->Attributes();
1258 Handle(Prs3d_ShadingAspect) aShadingAspect = aDrawer->ShadingAspect();
7fd59977 1259
6262338c 1260 Graphic3d_MaterialAspect aFront = aShadingAspect->Material(Aspect_TOFM_FRONT_SIDE);
1261 aFront.SetAmbientColor(aColF);
1262 aFront.SetDiffuseColor(aColF);
1263 aFront.SetSpecularColor(aColF);
1264 aFront.SetEmissiveColor(aColF);
1265 aFront.SetTransparency(0.0);
1266 aShadingAspect->SetMaterial(aFront,Aspect_TOFM_FRONT_SIDE);
7fd59977 1267
6262338c 1268 Graphic3d_MaterialAspect aBack = aShadingAspect->Material(Aspect_TOFM_BACK_SIDE);
1269 aBack.SetAmbientColor(aColB);
1270 aBack.SetDiffuseColor(aColB);
1271 aBack.SetSpecularColor(aColB);
1272 aBack.SetEmissiveColor(aColB);
1273 aBack.SetTransparency(0.0);
1274 aShadingAspect->SetMaterial(aBack,Aspect_TOFM_BACK_SIDE);
7fd59977 1275
6262338c 1276 aDrawer->SetShadingAspect (aShadingAspect);
7fd59977 1277
0577ae8c 1278 anAISContext->Display (anAisIO, 1, 0, Standard_True);
7fd59977 1279
1280 Standard_Real r, g, b;
6262338c 1281 aShadingAspect->Color(Aspect_TOFM_FRONT_SIDE).Values(r,g,b, Quantity_TOC_RGB);
7fd59977 1282 di << "Info: color on front side (" << r << "," << g << "," << b << ")\n";
6262338c 1283 aShadingAspect->Color(Aspect_TOFM_BACK_SIDE).Values(r,g,b, Quantity_TOC_RGB);
7fd59977 1284 di << "Info: color on back side (" << r << "," << g << "," << b << ")\n";
1285
1286 return 0;
1287}
1288
1289//=======================================================================
1290//function : OCC1174_2
1291//purpose :
1292//=======================================================================
1293static Standard_Integer OCC1174_2 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1294{
1295 if (argc != 2)
1296 {
586db386 1297 di << "Usage : " << argv[0] << " shape\n";
7fd59977 1298 return 1;
1299 }
1300
1301 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1302 if(AISContext.IsNull())
1303 {
1304 di << "use 'vinit' command before " << argv[0] << "\n";
1305 return 1;
1306 }
1307
1308 TopoDS_Shape sh = DBRep::Get(argv[1]);
1309
1310 Handle(AIS_Shape) ais = new AIS_Shape(sh);
0577ae8c 1311 AISContext->Display (ais, 1, 0, Standard_False);
1312 AISContext->SetMaterial (ais, Graphic3d_NOM_SHINY_PLASTIC, Standard_False);
7fd59977 1313
1314 Quantity_Color colf(0.0, 0.4, 0.0, Quantity_TOC_RGB);
1315 Quantity_Color colb(0.0, 0.0, 0.6, Quantity_TOC_RGB);
1316 Handle(Prs3d_ShadingAspect) sa = ais->Attributes()->ShadingAspect();
1317
1318 Graphic3d_MaterialAspect front = sa->Material(Aspect_TOFM_FRONT_SIDE);
1319 front.SetAmbientColor(colf);
1320 front.SetDiffuseColor(colf);
1321 front.SetSpecularColor(colf);
1322 front.SetEmissiveColor(colf);
4e1bc39a 1323 front.SetTransparency (0.4f);
7fd59977 1324 sa->SetMaterial(front,Aspect_TOFM_FRONT_SIDE);
1325
1326 Graphic3d_MaterialAspect back = sa->Material(Aspect_TOFM_BACK_SIDE);
1327 back.SetAmbientColor(colb);
1328 back.SetDiffuseColor(colb);
1329 back.SetSpecularColor(colb);
1330 back.SetEmissiveColor(colb);
4e1bc39a 1331 back.SetTransparency (0.2f);
7fd59977 1332 sa->SetMaterial(back,Aspect_TOFM_BACK_SIDE);
1333
0577ae8c 1334 AISContext->Redisplay (ais, 1, 0);
7fd59977 1335
1336 return 0;
1337}
1338
7fd59977 1339#include <TopoDS_Solid.hxx>
1340#include <BRepFeat_MakeDPrism.hxx>
1341//=======================================================================
1342//function : OCCN1
1343//purpose : FEATURE OPERATION (BOSS and SLOT)
1344//=======================================================================
1345static Standard_Integer OCCN1 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1346{
1347 if (argc != 4)
1348 {
586db386 1349 di << "Usage : " << argv[0] << " angle fuse(1 for boss / 0 for slot) length\n";
7fd59977 1350 return 1;
1351 }
1352
1353 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1354 if(aContext.IsNull())
1355 {
1356 di << "use 'vinit' command before " << argv[0] << "\n";
1357 return 1;
1358 }
91322f44 1359 Standard_Real angle = Draw::Atof(argv[1]);
1360 Standard_Integer fuse = Draw::Atoi(argv[2]);
1361 Standard_Real length = Draw::Atof(argv[3]);
7fd59977 1362
1363 BRepBuilderAPI_MakeEdge edge1(gp_Pnt(0, 0, 0), gp_Pnt(50, 0, 0));
1364 BRepBuilderAPI_MakeEdge edge2(gp_Pnt(50, 0, 0), gp_Pnt(50, 50, 0));
1365 BRepBuilderAPI_MakeEdge edge3(gp_Pnt(50, 50, 0), gp_Pnt(0, 50, 0));
1366 BRepBuilderAPI_MakeEdge edge4(gp_Pnt(0, 50, 0), gp_Pnt(0, 0, 0));
1367 TopoDS_Edge ted1 = edge1.Edge();
1368 TopoDS_Edge ted2 = edge2.Edge();
1369 TopoDS_Edge ted3 = edge3.Edge();
1370 TopoDS_Edge ted4 = edge4.Edge();
1371
1372 BRepBuilderAPI_MakeWire wire(ted1, ted2, ted3, ted4);
1373 TopoDS_Wire twire = wire.Wire();
1374
1375 BRepBuilderAPI_MakeFace face(twire);
1376 TopoDS_Face tface = face.Face();
857ffd5e 1377 ////////Handle(AIS_Shape) face_ais = new AIS_Shape( tface );
7fd59977 1378 ////////aContext->Display(face_ais);
1379
1380 TopoDS_Solid box;
1381 BRepPrimAPI_MakeBox block(gp_Pnt(-50, -50, -150), 150, 150, 100);
1382 box = block.Solid();
1383
1384 TopoDS_Face top_face;
1385 top_face = block.TopFace();
1386
1387 BRepFeat_MakeDPrism slot(box, tface, top_face, angle, fuse,
1388 Standard_True);
1389
1390 slot.Perform(length);
1391 TopoDS_Shape S2 = slot.Shape();
1392
1393 DBRep::Set("OCCN1_tface",tface);
1394 DBRep::Set("OCCN1_slot",S2);
1395
1396 return 0;
1397}
1398
1399#include <BRepPrimAPI_MakeCylinder.hxx>
1400#include <BRepPrimAPI_MakeSphere.hxx>
1401#include <BRepAlgoAPI_Section.hxx>
7fd59977 1402//=======================================================================
1403//function : OCCN2
1404//purpose : BOOLEAN OPERATION
1405//=======================================================================
1406static Standard_Integer OCCN2 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1407{
1408 if (argc > 2) {
431d0f18 1409 di << "Usage : " << argv[0] << "\n";
7fd59977 1410 return 1;
1411 }
7fd59977 1412
1413 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1414 if(aContext.IsNull())
1415 {
1416 di << "use 'vinit' command before " << argv[0] << "\n";
1417 return 1;
1418 }
1419
1420 BRepPrimAPI_MakeCylinder cylinder(50,200);
1421 TopoDS_Shape cylinder_sh = cylinder.Shape();
1422
1423 BRepPrimAPI_MakeSphere sphere(gp_Pnt(60,0,100),50);
1424 TopoDS_Shape sphere_sh = sphere.Shape();
1425
431d0f18 1426 di << "BRepAlgoAPI_Section section(cylinder_sh, sphere_sh)\n";
1427 BRepAlgoAPI_Section section(cylinder_sh, sphere_sh);
1428 if (!section.IsDone()){
1429 di << "Error performing intersection: not done.\n";
7fd59977 1430 }
431d0f18 1431 const TopoDS_Shape& shape = section.Shape();
7fd59977 1432
1433 DBRep::Set("OCCN2_cylinder",cylinder_sh);
1434 DBRep::Set("OCCN2_sphere",sphere_sh);
1435 DBRep::Set("OCCN2_section",shape);
1436
1437 return 0;
1438}
1439
1440#include <TColgp_Array1OfPnt.hxx>
1441#include <Geom_BezierCurve.hxx>
1442
1443static Standard_Integer OCC2569 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1444{
1445 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1446 if(aContext.IsNull())
1447 {
1448 di << "use 'vinit' command before " << argv[0] << "\n";
1449 return 1;
1450 }
1451 if(argc != 3) {
586db386 1452 di << "Usage : " << argv[0] << " nbpoles result\n";
7fd59977 1453 return 1;
1454 }
1455
91322f44 1456 int poles=Draw::Atoi(argv[1]);
7fd59977 1457
1458 TColgp_Array1OfPnt arr(1, poles);
1459 for(int i=1; i<=poles; i++)
1460 arr.SetValue(i, gp_Pnt(i+10, i*2+20, i*3+45));
1461
857ffd5e 1462 Handle(Geom_BezierCurve) bez = new Geom_BezierCurve(arr);
7fd59977 1463 if(bez.IsNull()) {
1464 di << "\n The curve is not created.\n";
1465 } else {
1466 di << "\n Degree = " << bez->Degree() << "\n";
1467 }
1468 TopoDS_Edge sh = BRepBuilderAPI_MakeEdge(bez).Edge();
857ffd5e 1469 Handle(AIS_Shape) ais = new AIS_Shape(sh);
0577ae8c 1470 aContext->Display (ais, Standard_True);
7fd59977 1471 DrawTrSurf::Set(argv[2],bez);
1472 return 0;
1473}
1474
1475#include <TopTools_IndexedMapOfShape.hxx>
1476#include <TopExp.hxx>
1477
1478static Standard_Integer OCC1642 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1479{
1480 if (argc != 10) {
586db386 1481 di<<"Usage: " << argv[0] << " FinalWare FinalFace InitWare InitFace shape FixReorder FixDegenerated FixConnected FixSelfIntersection\n";
7fd59977 1482 return 1;
1483 }
1484
1485 TopoDS_Shape shape = DBRep::Get(argv[5]);
1486
1487 TopExp_Explorer exp(shape, TopAbs_WIRE);
1488 TopoDS_Shape wire = exp.Current();
1489
1490 Handle(ShapeAnalysis_Wire) advWA = new ShapeAnalysis_Wire;
1491 advWA->Load(TopoDS::Wire(wire));
1492
1493 DBRep::Set(argv[3],wire);
1494
1495 TopoDS_Face face =
1496 BRepBuilderAPI_MakeFace(TopoDS::Wire(wire),Standard_True);
1497
1498 DBRep::Set(argv[4],face);
1499
1500 advWA->SetFace(face);
5e27df78 1501 Standard_Real precision_to_ana = 0.0001;
7fd59977 1502 advWA->SetPrecision(precision_to_ana);
1503
1504 TopTools_IndexedMapOfShape M;
1505 TopExp::MapShapes(wire, TopAbs_EDGE, M);
1506
1507 int j= 1;
1508 for(j= 1; j<=M.Extent(); ++j) {
1509 Standard_Integer num=1;
1510 IntRes2d_SequenceOfIntersectionPoint points2d;
1511 TColgp_SequenceOfPnt points3d;
1512
1513 cout << "\n j =" << j << ", CheckSelfIntersectingEdge = " <<
1514 advWA->CheckSelfIntersectingEdge(j, points2d, points3d);
1515
1516
1517 ShapeExtend_Status status = ShapeExtend_FAIL1;
1518 if(advWA->StatusSelfIntersection(status))
1519
1520 status = ShapeExtend_FAIL2;
1521 if(advWA->StatusSelfIntersection(status))
1522 di << "\n No Vertices found in the edge";
1523
1524 status = ShapeExtend_DONE1;
1525 if(advWA->StatusSelfIntersection(status))
1526 di << "\n Self-intersection found in the edge";
1527
1528 num = points2d.Length();
1529 di << "\n No. of self-intersecting edges : " << num;
1530
1531 for(int i=1; i<=num; ++i) {
1532 gp_Pnt pt = points3d(i);
1533 di << "\n Intersecting pt : (" << pt.X() << ", " << pt.Y()<< ", " << pt.Z() << ")";
1534 }
1535
1536 }
1537
857ffd5e 1538 Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire;
7fd59977 1539 sfw->Load(TopoDS::Wire(wire));
1540 sfw->SetFace(face);
1541 sfw->SetPrecision(Precision::Confusion());
1542
1543 sfw->FixReorderMode() = 1;
1544 sfw->ClosedWireMode() = 1;
1545 sfw->FixDegeneratedMode() = 1;
1546 sfw->FixConnectedMode() = 1;
1547 sfw->ModifyTopologyMode() = 1;
1548 sfw->ModifyGeometryMode() = 1;
1549 sfw->FixSelfIntersectionMode() = 1;
1550 sfw->FixSelfIntersectingEdgeMode() = 1;
1551 sfw->FixIntersectingEdgesMode() = 1;
1552 sfw->FixNonAdjacentIntersectingEdgesMode() = 1;
1553 sfw->FixEdgeCurvesMode() = 1;
1554
1555 sfw->ModifyRemoveLoopMode() = 1;
1556 sfw->SetMaxTolerance(1.0);
1557
1558 di << "\n FixReorder = " << (Standard_Integer) sfw->FixReorder();
1559 di << "\n FixDegenerated = " << (Standard_Integer) sfw->FixDegenerated();
1560 di << "\n FixConnected = " << (Standard_Integer) sfw->FixConnected();
1561 di << "\n";
1562 di << "\n FixSelfIntersection = " << (Standard_Integer) sfw->FixSelfIntersection();
1563 di << "\n";
1564
1565 Draw::Set(argv[6],sfw->FixReorder()) ;
1566 Draw::Set(argv[7],sfw->FixDegenerated()) ;
1567 Draw::Set(argv[8],sfw->FixConnected()) ;
1568 Draw::Set(argv[9],sfw->FixSelfIntersection()) ;
1569
1570 ShapeExtend_Status status = ShapeExtend_OK;
1571 if(sfw->StatusSelfIntersection(status))
1572 di << "\n ShapeExtend_OK : No intersection found";
1573
1574 status = ShapeExtend_FAIL1;
1575 if(sfw->StatusSelfIntersection(status))
1576 di << "\n ShapeExtend_FAIL1 : analysis failed (edge has no pcurve,or no vertices etc.)";
1577
1578 status = ShapeExtend_FAIL2;
1579 if(sfw->StatusSelfIntersection(status))
1580 di << "\n ShapeExtend_FAIL2 : self-intersection was found, but not fixed because of limit of increasing tolerance (MaxTolerance)";
1581
1582 status = ShapeExtend_FAIL3;
1583 if(sfw->StatusSelfIntersection(status))
1584 di << "\n ShapeExtend_FAIL3 : intercestion of non adjacent edges found, but not fixed because of limit of increasing tolerance (MaxTolerance)";
1585
1586 status = ShapeExtend_DONE1;
1587 if(sfw->StatusSelfIntersection(status))
1588 di << "\n ShapeExtend_DONE1 : tolerance of vertex was increased to fix self-intersection";
1589
1590 status = ShapeExtend_DONE2;
1591 if(sfw->StatusSelfIntersection(status))
1592 di << "\n ShapeExtend_DONE2 : vertex was moved to fix self-intersection";
1593
1594 status = ShapeExtend_DONE3;
1595 if(sfw->StatusSelfIntersection(status))
1596 di << "\n ShapeExtend_DONE3 : some edges were removed because of intersection";
1597
1598 status = ShapeExtend_DONE4;
1599 if(sfw->StatusSelfIntersection(status))
1600 di << "\n ShapeExtend_DONE4 : pcurve(s) was(were) modified";
1601
1602 status = ShapeExtend_DONE5;
1603 if(sfw->StatusSelfIntersection(status))
1604 di << "\n ShapeExtend_DONE5 : non adjacent intersection fixed by increasing tolerance of vertex(vertices)";
1605
1606 status = ShapeExtend_DONE6;
1607 if(sfw->StatusSelfIntersection(status))
1608 di << "\n ShapeExtend_DONE6 : tolerance of edge was increased to hide intersection";
1609
1610 status = ShapeExtend_DONE7;
1611 if(sfw->StatusSelfIntersection(status))
1612 di << "\n ShapeExtend_DONE7 : range of some edges was decreased to avoid intersection";
1613
1614 TopoDS_Wire finalwire = sfw->Wire();
1615
1616 DBRep::Set(argv[1],finalwire);
1617
1618
1619 advWA->Load(TopoDS::Wire(finalwire));
1620
1621 TopoDS_Face fface =
1622 BRepBuilderAPI_MakeFace(TopoDS::Wire(finalwire),Standard_True);
1623
1624 DBRep::Set(argv[2],fface);
1625
1626 advWA->SetFace(fface);
1627
1628 TopTools_IndexedMapOfShape fM;
1629 TopExp::MapShapes(finalwire, TopAbs_EDGE, fM);
1630
1631 for(j= 1; j<=fM.Extent(); ++j) {
1632 Standard_Integer num=1;
1633 IntRes2d_SequenceOfIntersectionPoint points2d;
1634 TColgp_SequenceOfPnt points3d;
1635
1636 di << "\n j =" << j << ", CheckSelfIntersectingEdge = " <<
1637 (Standard_Integer) advWA->CheckSelfIntersectingEdge(j, points2d, points3d);
1638
1639
51740958 1640 status = ShapeExtend_FAIL1;
7fd59977 1641 if(advWA->StatusSelfIntersection(status))
1642
1643 status = ShapeExtend_FAIL2;
1644 if(advWA->StatusSelfIntersection(status))
1645 di << "\n No Vertices found in the edge";
1646
1647 status = ShapeExtend_DONE1;
1648 if(advWA->StatusSelfIntersection(status))
1649 di << "\n Self-intersection found in the edge";
1650
1651 num = points2d.Length();
1652 di << "\n No. of self-intersecting edges : " << num;
1653
1654 for(int i=1; i<=num; ++i) {
1655 gp_Pnt pt = points3d(i);
1656 di << "\n Intersecting pt : (" << pt.X() << ", " << pt.Y() << ", " << pt.Z() << ")";
1657 }
1658
1659 }
1660
1661 di << "\n";
1662
1663 return 0;
1664}
1665
1cd84fee 1666void QABugs::Commands_17(Draw_Interpretor& theCommands) {
1365140b 1667 const char *group = "QABugs";
7fd59977 1668
1669 theCommands.Add ("BUC60842", "BUC60842", __FILE__, BUC60842, group);
1670 theCommands.Add ("BUC60843", "BUC60843 result_shape name_of_circle name_of_curve [ par1 [ tol ] ]", __FILE__, BUC60843, group);
1671 theCommands.Add ("BUC60970", "BUC60970 shape result", __FILE__, BUC60970, group);
1672 theCommands.Add ("BUC60818", "BUC60818", __FILE__, BUC60818, group);
1673 theCommands.Add ("BUC60915", "BUC60915", __FILE__, BUC60915_1, group);
1674 theCommands.Add ("OCC138", "OCC138", __FILE__, OCC138, group);
7fd59977 1675 theCommands.Add ("OCC353","OCC353",__FILE__,OCC353,group);
1676 theCommands.Add ("OCC280","OCC280 hlr=0/1 setsurfecedetail=0/1; set perspecrive view",__FILE__,OCC280,group);
1677 theCommands.Add ("OCC232", "OCC232", __FILE__, OCC232 , group);
1678 theCommands.Add ("OCC138LC", "OCC138LC", __FILE__, OCC138LC, group);
7fd59977 1679 theCommands.Add ("OCC566", "OCC566 shape [ xmin ymin zmin xmax ymax zmax] ; print bounding box", __FILE__, OCC566, group);
1680 theCommands.Add ("OCC570", "OCC570 result", __FILE__, OCC570, group);
1681
1682 theCommands.Add("OCC570mkevol",
1683 "OCC570mkevol result object (then use updatevol) [R/Q/P]; mkevol",
1684 __FILE__, MKEVOL,group);
1685 theCommands.Add("OCC570updatevol",
1686 "OCC570updatevol edge u1 rad1 u2 rad2 ...; updatevol",
1687 __FILE__, UPDATEVOL,group);
1688 theCommands.Add("OCC570updatevollaw",
1689 "OCC570updatevollaw edge u1 rad1 u2 rad2 ...; updatevollaw",
1690 __FILE__, UPDATEVOL,group);
1691 theCommands.Add("OCC570buildevol",
1692 "OCC570buildevol; end of the evol fillet computation",
1693 __FILE__, BUILDEVOL,group);
1694
1695 theCommands.Add ("OCC606", "OCC606 result shape [-t]", __FILE__, OCC606, group);
1696
1697 theCommands.Add ("OCC813", "OCC813 U V", __FILE__, OCC813, group);
1698 theCommands.Add ("OCC814", "OCC814", __FILE__, OCC814, group);
1699 theCommands.Add ("OCC884", "OCC884 result shape [toler [maxtoler]]", __FILE__, OCC884, group);
1700 theCommands.Add ("OCC1188", "OCC1188 imagefile [filltype] : Load image as background", __FILE__, OCC1188, group);
1701
1702 theCommands.Add ("OCC1174_1", "OCC1174_1 shape", __FILE__, OCC1174_1, group);
1703 theCommands.Add ("OCC1174_2", "OCC1174_2 shape", __FILE__, OCC1174_2, group);
1704
7fd59977 1705 theCommands.Add ("OCCN1", "OCCN1 angle fuse(1 for boss / 0 for slot) length", __FILE__, OCCN1, group);
1706 theCommands.Add ("OCCN2", "OCCN2", __FILE__, OCCN2, group);
1707
1708 theCommands.Add ("OCC2569", "OCC2569 nbpoles result", __FILE__, OCC2569, group);
1709
1710 theCommands.Add ("OCC1642", "OCC1642 FinalWare FinalFace InitWare InitFace shape FixReorder FixDegenerated FixConnected FixSelfIntersection", __FILE__, OCC1642, group);
1711
7fd59977 1712 return;
1713}