0022922: Clean up warnings on uninitialized / unused variables
[occt.git] / src / TestTopOpeDraw / TestTopOpeDraw_OtherCommands.cxx
CommitLineData
7fd59977 1// File: TestTopOpeDraw_OtherCommands.cxx
2// Created: Fri Feb 2 15:30:24 1996
3// Author: Jean Yves LEBEY
4// <jyl@meteox>
5
6#ifdef HAVE_CONFIG_H
7# include <config.h>
8#endif
9#include <TestTopOpeDraw.hxx>
10#include <TestTopOpeDraw_Displayer.hxx>
11#include <TestTopOpeDraw_TTOT.hxx>
12#include <DBRep.hxx>
13#include <BRepTools.hxx>
14#include <BRep_Tool.hxx>
15#include <Draw_Interpretor.hxx>
16#include <Draw_Appli.hxx>
17#include <TopOpeBRepTool_define.hxx>
18#include <stdio.h>
19#ifdef HAVE_STRINGS_H
20# include <strings.h>
21#endif
22
23//-----------------------------------------------------------------------
24// 0 = testtopopedraw_cdinp
25// 1,2,3,4 = display point p of coords x y z
26//-----------------------------------------------------------------------
27Standard_Integer testtopopedraw_cdinp(Draw_Interpretor&,Standard_Integer na,const char** a)
28{
29 if ( na < 5 ) return 0;
30 TestTopOpeDraw_P3DDisplayer PD(a[1],atof(a[2]),atof(a[3]),atof(a[4]));
31 return 0;
32}
33
34//-----------------------------------------------------------------------
35// DRAWsuppressarg : remove a[d], modify na--
36//-----------------------------------------------------------------------
37Standard_EXPORT void DRAWsuppressarg(Standard_Integer& na,const char** a,const Standard_Integer d)
38{
39 for(Standard_Integer i=d;i<na;i++) {
40 a[i]=a[i+1];
41 a[i+1]=NULL;
42 }
43 na--;
44}
45
46//-----------------------------------------------------------------------
47// DRAWsuppressargs : remove a[*] from <f> to <l>, modify na = na - (l - f)
48//-----------------------------------------------------------------------
49Standard_EXPORT void DRAWsuppressargs(Standard_Integer& na,const char** a,const Standard_Integer f,const Standard_Integer l)
50{
51 if(l == f)
52 DRAWsuppressarg(na,a,l);
53 if(l <= f) return;
54 for(Standard_Integer i=0;i<na-l;i++) {
55 a[i+f]=a[i+l+1];
56 a[i+l+1]=NULL;
57 }
58 na -= l-f+1;
59}
60
61//-----------------------------------------------------------------------
62Standard_EXPORT void OthersCommands_flags(Standard_Integer& na,const char** a,TestTopOpeDraw_Displayer& TD)
63//-----------------------------------------------------------------------
64{
65 Standard_Integer i,j,l,dloc = 0,iloc,decal = 0, NbArg = na;
66 Standard_Boolean dori = Standard_False; // display orientation
67 Standard_Boolean tgeo = Standard_False; // name with geometry
68 Standard_Boolean tori = Standard_False; // name with orientation
69 Standard_Real tpar = -1.0;
70 Standard_Integer inbr = 2; Standard_Boolean inbrdef = Standard_False;
71 Standard_Boolean col = Standard_False; // display specific color
72 Standard_Boolean tolflag = Standard_False;
73 Draw_Color Color;
74 for (i=1; i<NbArg; i++) {
75 iloc = i - decal;
76 if(!a[iloc]) break;
77 if (a[iloc][0] == '-') {
78 l = strlen(a[iloc]);
79 for (j=1; j<l; j++) {
80 if (a[iloc][j] == 'g') tgeo=Standard_True;
81 else if(!strcmp(a[iloc],"-tol")) tolflag = Standard_True;
82 else if(a[iloc][j] == 'o') tori=Standard_True;
83 else if(a[iloc][j] == 'O') dori=Standard_True;
84 else if(a[iloc][j] == 'i') {
85 if (j<(l-1)) {
86 char sis[40]; sis[0] = '\0';
87 Standard_Integer kk = 0, k = j+1;
88 for (; k<l; k++,kk++,sis[kk] = '\0' ) sis[kk] = a[iloc][k];
89 inbr = atoi(sis);
90 inbrdef = Standard_True;
91 }
92 }
93 else if(a[iloc][j] == 'p') {
94 if (iloc < na - 1) {
95 tpar = atof(a[iloc+1]);
96 dloc++; decal++;
97 }
98 }
99 else if(a[iloc][j] == 'c') {
100 col=Standard_True;
0d532383
S
101 if(strcmp(a[iloc+1], "blanc") == 0) Color = Draw_blanc;
102 else if (strcmp(a[iloc+1], "rouge") == 0) Color = Draw_rouge;
103 else if (strcmp(a[iloc+1], "vert") == 0) Color = Draw_vert;
104 else if (strcmp(a[iloc+1], "bleu") == 0) Color = Draw_bleu;
105 else if (strcmp(a[iloc+1], "cyan") == 0) Color = Draw_cyan;
106 else if (strcmp(a[iloc+1], "or") == 0) Color = Draw_or;
107 else if (strcmp(a[iloc+1], "magenta") == 0) Color = Draw_magenta;
108 else if (strcmp(a[iloc+1], "marron") == 0) Color = Draw_marron;
109 else if (strcmp(a[iloc+1], "orange") == 0) Color = Draw_orange;
110 else if (strcmp(a[iloc+1], "rose") == 0) Color = Draw_rose;
111 else if (strcmp(a[iloc+1], "saumon") == 0) Color = Draw_saumon;
112 else if (strcmp(a[iloc+1], "violet") == 0) Color = Draw_violet;
113 else if (strcmp(a[iloc+1], "jaune") == 0) Color = Draw_jaune;
114 else if (strcmp(a[iloc+1], "kaki") == 0) Color = Draw_kaki;
115 else if (strcmp(a[iloc+1], "corail") == 0) Color = Draw_corail;
7fd59977 116 decal++;dloc++;
117 }
118 }
119 DRAWsuppressargs(na,a,iloc,iloc+dloc);
120 decal++;
121 dloc = 0;
122 }
123 }
124 if (inbr < 0 ) inbr = 2;
125 TD.DisplayNameWithGeometry(tgeo);
126 TD.DisplayNameWithOrientation(tori);
127 TD.DisplayGeometry(dori);
128 TD.NbIsos(inbr); TD.NbIsosDef(inbrdef);
129 TD.SetPar(tpar);
130 TD.TolIs(tolflag);
131 if(col) TD.SetColor(Color);
132}
133
134//-----------------------------------------------------------------------
135// OthersCommands_help
136//-----------------------------------------------------------------------
137
138Standard_EXPORT void OthersCommands_help(const char* CommandName, const char* syntaxe = "")
139{
140 if(strlen(syntaxe))
141 cout<<CommandName<<syntaxe<<endl;
142 cout<<" -p <parameter> to display the name of an edge round a point of <parameter>"<<endl;
143 cout<<" in [0,1] on edge curve range. Default value is 0.3"<<endl;
144// cout<<" -p <par> : on edge , diplay name at t in [0..1]"<<endl;
145 cout<<" -o : display name = DBRep name + orientation"<<endl;
146 cout<<" -g : display name = DBRep name + geometry"<<endl;
147 cout<<" -O : visualize shape orientation"<<endl;
148 cout<<" -i<n> : visualize face with <n> isos"<<endl;
149 cout<<" -c <col> : display name with color col (Draw_blanc, Draw_rouge, ...)"<<endl;
150 cout<<" -tol to display vertices with a circle of radius equal to its tolerance."<<endl;
151 cout<<"example : '"<<CommandName<<" -p 0.8 e 8 9 23'"<<endl;
152 cout<<""<<endl;
153}
154//-----------------------------------------------------------------------
155// 0 = testtopopedraw_cdins
156// 1,2,3,... = display shapes and visualise their names
157//-----------------------------------------------------------------------
158
159Standard_Integer testtopopedraw_cdins(Draw_Interpretor&,Standard_Integer na,const char** a)
160{
161 if (na == 1) {
162 const char* syntaxe = " [arg] S : display shape S with its DBRep name";
163 OthersCommands_help(a[0], syntaxe);
164 return 0;
165 }
166
167 TestTopOpeDraw_Displayer TD;
168 OthersCommands_flags(na, a, TD);
169
170 Standard_Integer i ;
171 for ( i=1;i<na;i++) {
172 const TopoDS_Shape& S = DBRep::Get(a[i]);
173 if (S.IsNull()) continue;
174 const TopAbs_ShapeEnum t = S.ShapeType();
175 if (t == TopAbs_FACE) continue;
176 if (t == TopAbs_EDGE) continue;
177 if (t == TopAbs_VERTEX) continue;
178 TD.DisplayShape(a[i],S);
179 }
180
181 for (i=1;i<na;i++) {
182 const TopoDS_Shape& S = DBRep::Get(a[i]); if (S.IsNull()) continue;
183 const TopAbs_ShapeEnum t = S.ShapeType();
184 if (t == TopAbs_FACE) TD.DisplayShape(a[i],S);
185 }
186
187 for (i=1;i<na;i++) {
188 const TopoDS_Shape& S = DBRep::Get(a[i]); if (S.IsNull()) continue;
189 const TopAbs_ShapeEnum t = S.ShapeType();
190 if (t == TopAbs_EDGE) TD.DisplayShape(a[i],S);
191 }
192
193 for (i=1;i<na;i++) {
194 const TopoDS_Shape& S = DBRep::Get(a[i]); if (S.IsNull()) continue;
195 const TopAbs_ShapeEnum t = S.ShapeType();
196 if (t != TopAbs_VERTEX) continue;
197 if(TD.TolIs()) {
198 const TopoDS_Vertex& V = TopoDS::Vertex(S);
199 Standard_Real Tol = BRep_Tool::Tolerance(V);
200 TD.SetTol(Tol);
201 }
202 TD.DisplayShape(a[i],S);
203 }
204
205 return 0;
206}
207
208static void BoopReadInitFile(Draw_Interpretor& di, const char* filename)
209{
210 if (filename == NULL) return;
211 di.EvalFile(filename);
212}
213
214static Standard_Integer ttab(Draw_Interpretor& di, Standard_Integer narg, const char** a) {
215 char s[2000]; strcpy(s,"");
216 sprintf(s,"%s%s",s,"proc addt {at args} {upvar $at x;set L \"\";addl L [join $args];");
217 sprintf(s,"%s%s",s,"foreach l $L {set x([array size x]) $l}};");
218 di.Eval(s);
219 return 0;
220}
221
222Standard_IMPORT Draw_Color DrawTrSurf_CurveColor(const Draw_Color col);
223Standard_IMPORT void DBRep_WriteColorOrientation ();
224Standard_IMPORT Draw_Color DBRep_ColorOrientation (const TopAbs_Orientation Or);
225
226#include <Geom2d_TrimmedCurve.hxx>
227#include <DrawTrSurf.hxx>
228#include <TopExp.hxx>
229
230#include <TopTools_DataMapIteratorOfDataMapOfOrientedShapeInteger.hxx>
231#include <TopTools_DataMapOfOrientedShapeInteger.hxx>
232#include <TopTools_DataMapIteratorOfDataMapOfIntegerShape.hxx>
233#include <TopTools_DataMapOfIntegerShape.hxx>
234
235#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
236#include <TopExp_Explorer.hxx>
237#include <TopoDS_Face.hxx>
238#include <TopoDS_Edge.hxx>
239#include <TopoDS_Vertex.hxx>
240#include <TColStd_ListIteratorOfListOfAsciiString.hxx>
241#include <TColStd_ListOfAsciiString.hxx>
242#include <TestTopOpeDraw_ListOfPnt2d.hxx>
243
244class cvx2d {
245
246public:
247 cvx2d(Draw_Interpretor& di) {
248 clearall();
249 mypdi = &di;
250 }
251
252 const TopoDS_Face& face() const { return myface; }
253 const TCollection_AsciiString& facename() const { return myfacename; }
254
255 void erasevisible() {
256 TColStd_ListIteratorOfListOfAsciiString i(myvis);
257 Standard_Boolean ya = i.More();
258 TCollection_AsciiString str = "erase";
259 for (; i.More(); i.Next()) {
260 const TCollection_AsciiString& s = i.Value();
261 str = str + " " + s;
262 }
263 if (ya) {
264 TCollection_AsciiString str1 = "erase -mute;"; mypdi->Eval(str1.ToCString());
265 str = str + ";"; mypdi->Eval(str.ToCString());
266 }
267 clearvisible();
268 }
269
270 void addvisible(const TCollection_AsciiString& N) { myvis.Append(N); }
271 void clearvisible() { myvis.Clear(); }
272
273 const TopoDS_Edge& edge(const Standard_Integer ie) const {
274 if ( ie >= 1 && ie <= mymapis.Extent()) {
275 const TopoDS_Edge& E = TopoDS::Edge(mymapis.Find(ie));
276 return E;
277 }
278 return myemptyedge;
279 }
280
281 Standard_Integer nedge() const { return mymapis.Extent(); }
282
283 void clearall() {
284 clearvisible();
285 mymapve.Clear();
286 mymapsi.Clear(); mymapis.Clear(); mynemap = 0; myiemap = 1; myedgedisplayed = 0;
287 myface.Nullify();
288 myfacename = "";
289 }
290
291 void addedge(const TopoDS_Shape& E) {
292 mynemap++;
293 mymapsi.Bind(E,mynemap);
294 mymapis.Bind(mynemap,E);
295 }
296
297 void initface(const TopoDS_Face& F,const TCollection_AsciiString& N) {
298 clearall();
299 myface = F; myfacename = N;
300 TopExp::MapShapesAndAncestors(myface,TopAbs_VERTEX,TopAbs_EDGE,mymapve);
301 TopExp_Explorer e;
302 for (e.Init(F,TopAbs_EDGE);e.More();e.Next()) addedge(e.Current());
303// for (TopExp_Explorer e(F,TopAbs_EDGE);e.More();e.Next()) addedge(e.Current());
304 initedgeiter();
305 setedgedisplayed(0);
306 }
307
308 void displayface() const {
309 char s[1000];
310 mypdi->Eval("info proc vx2d_displayface");
311 if (mypdi->Result()) {
312 sprintf(s,"vx2d_displayface %s",myfacename.ToCString());
313 mypdi->Eval(s);
314 }
315 else cout<<"procedure vx2d_displayface non trouvee"<<endl;
316 }
317
318 Standard_Integer eindex(const TopoDS_Shape& E) const {
319 const Standard_Integer ie = mymapsi.Find(E);
320 return ie;
321 }
322
323 void ename(const TopoDS_Shape& S,TCollection_AsciiString& ste) const {
324 ste = "";
325 if (S.ShapeType() != TopAbs_EDGE) return;
326 const TopoDS_Edge& E = TopoDS::Edge(S);
327 const Standard_Integer ie = eindex(E);
328 TopAbs_Orientation oe = E.Orientation();
329 TCollection_AsciiString stoe;TestTopOpeDraw_TTOT::OrientationToString(oe,stoe);
330 stoe = stoe.SubString(1,1);stoe.LowerCase();
331 Standard_Boolean deg = BRep_Tool::Degenerated(E);
332 if (deg) ste="D";
333 ste=ste+"e"+ie+stoe;
334 }
335
336 void vname(const TopoDS_Shape& V, const TopoDS_Shape& E,TCollection_AsciiString& stv) const {
337 stv = "";
338 if (V.ShapeType() != TopAbs_VERTEX) return;
339 TopAbs_Orientation ov = V.Orientation();
340 TCollection_AsciiString sto;TestTopOpeDraw_TTOT::OrientationToString(ov,sto);
341 TCollection_AsciiString sto11 = sto.SubString(1,1); sto11.LowerCase();
342 const TopTools_ListOfShape& l = mymapve.FindFromKey(V);
343 Standard_Integer ne=l.Extent(); TCollection_AsciiString ste; ename(E,ste);
344 stv.Copy("v"); stv=stv+sto11+ste+"."+ne;
345 }
346
347 void fenames(TCollection_AsciiString& stef) const {
348 stef="";
349 Standard_Integer i=1,n=nedge();
350 for (;i<=n;i++) {
351 TCollection_AsciiString ste;ename(edge(i),ste);
352 stef=stef+ste+" ";
353 }
354 }
355
356 Draw_Color color(const TopoDS_Shape& S) const {
357 Draw_Color col = Draw_blanc;
358 TopAbs_Orientation o = S.Orientation();
359 TopAbs_ShapeEnum t = S.ShapeType();
360 if ( t == TopAbs_VERTEX ) {
361 if ( o == TopAbs_FORWARD ) col = Draw_magenta;
362 else if ( o == TopAbs_REVERSED ) col = Draw_cyan;
363 else col = DBRep_ColorOrientation(o);
364 }
365 else if ( t == TopAbs_EDGE ) {
366 if (o == TopAbs_FORWARD) col = Draw_magenta;
367 else if (o == TopAbs_REVERSED) col = Draw_cyan;
368 else col = DBRep_ColorOrientation(o);
369 }
370 return col;
371 }
372
373 const TopTools_ListOfShape& incidentedges(const TopoDS_Shape& V) const {
374 if ( ! mymapve.Contains(V) ) return myemptylos;
375 return mymapve.FindFromKey(V);
376 }
377
378 void lenames(const TopTools_ListOfShape& l,TCollection_AsciiString& stel) const {
379 stel = "";Standard_Integer j = 0;
380 for (TopTools_ListIteratorOfListOfShape it(l);it.More();it.Next(),j++) {
381 if (j) stel = stel + " ";
382 TCollection_AsciiString ste; ename(it.Value(),ste);
383 stel = stel + ste;
384 }
385 }
386
387 void subshapename(const TCollection_AsciiString& sts,const TopAbs_ShapeEnum tss,const Standard_Integer i,TCollection_AsciiString& stss) const {
388 TCollection_AsciiString s; TestTopOpeDraw_TTOT::ShapeEnumToString(tss,s);
389 stss=sts+"_"+s+i;
390 }
391
392 Handle(Geom2d_Curve) curve2d(const TopoDS_Edge& E) const {
393 Standard_Real f,l; const Handle(Geom2d_Curve) c = BRep_Tool::CurveOnSurface(E,myface,f,l);
394 if (c.IsNull()) return c;
395 Handle(Geom2d_Curve) nc = new Geom2d_TrimmedCurve(c,f,l);
396 return nc;
397 }
398
399 void printedges() const {
400 Standard_Integer n=nedge();if (!n) return;
401//JR/Hp
402 TCollection_AsciiString se=(Standard_CString ) ((n==1)?" edge :":" edges :");
403// TCollection_AsciiString se=(n==1)?" edge :":" edges :";
404 TCollection_AsciiString s;s=s+"# face "+myfacename+" : "+n+se;
405 TCollection_AsciiString sb(s.Length()-1,' ');
406 cout<<endl<<s;
407 for (Standard_Integer i=1;i<=n;i++) {
408 TCollection_AsciiString stei;ename(edge(i),stei);cout<<" "<<stei;
409 if ((i>1) && (i%4 == 0) && (i<n)) cout<<endl<<"#"<<sb;
410 }
411 cout<<endl;
412 cout.flush();
413 }
414
415 Standard_Integer displayface(const TopoDS_Shape& S, const TCollection_AsciiString& sta);
416 Standard_Integer displayedge(const TopoDS_Shape& S);
417
418 void initedgeiter() { myiemap = 1; }
419 Standard_Boolean moreedgeiter() const { return myiemap <= mynemap; }
420 void nextedgeiter(const Standard_Integer incr = +1);
421 Standard_Integer curredgeiter() const { return myiemap; }
422 void setcurredgeiter(const Standard_Integer i) { if (i>=1 &&i<=mynemap) myiemap = i; }
423 Standard_Integer edgedisplayed() const { return myedgedisplayed; }
424 void setedgedisplayed(const Standard_Integer i) { if (i>=1 &&i<=mynemap) myedgedisplayed = i; }
425
426 TopoDS_Face myface; TCollection_AsciiString myfacename;
427 TColStd_ListOfAsciiString myvis;
428 TopTools_IndexedDataMapOfShapeListOfShape mymapve;
429
430 TopTools_DataMapOfOrientedShapeInteger mymapsi;
431 TopTools_DataMapOfIntegerShape mymapis;
432 Standard_Integer mynemap;
433 Standard_Integer myiemap;
434 Standard_Integer myedgedisplayed;
435
436 Draw_Interpretor* mypdi;
437 TopoDS_Edge myemptyedge;
438 TopTools_ListOfShape myemptylos;
439}; // cvx2d
440
441void cvx2d::nextedgeiter(const Standard_Integer incr)
442{
443 if (!moreedgeiter()) return;
444 myiemap += incr;
445 if (myiemap>mynemap) myiemap = 1;
446 else if (myiemap<1) myiemap = mynemap;
447}
448
449Standard_Integer cvx2d::displayface(const TopoDS_Shape& S, const TCollection_AsciiString& sta) {
450 TopoDS_Shape aLocalShape = S.Oriented(TopAbs_FORWARD) ;
451 TopoDS_Face F = TopoDS::Face(aLocalShape);
452// TopoDS_Face F = TopoDS::Face(S.Oriented(TopAbs_FORWARD));
453 Standard_Boolean init = Standard_True;
454 if (init) initface(F,sta);
455 displayface();
456 printedges();
457 return 0;
458} // displayface
459
460Standard_Integer cvx2d::displayedge(const TopoDS_Shape& S) {
461 if (S.IsNull()) return 0;
462 const TopoDS_Edge& E = TopoDS::Edge(S);
463 const TopoDS_Face& F = face();
464 if (F.IsNull()) return 0;
465
466 Draw_Color savecol = DrawTrSurf_CurveColor(Draw_Color(Draw_rouge));
467
468 Standard_Real u,v,V,U;BRepTools::UVBounds(F,E,u,U,v,V);
469 Standard_Boolean deg = BRep_Tool::Degenerated(E);
470 gp_Pnt2d pe1(u,v);gp_Pnt2d pe2(U,V);
471 gp_Pnt2d p1,p2;BRep_Tool::UVPoints(E,F,p1,p2);
472 TopoDS_Vertex v1,v2; TopExp::Vertices(E,v1,v2);
473 gp_Pnt P1 = BRep_Tool::Pnt(v1);
474 gp_Pnt P2 = BRep_Tool::Pnt(v2);
475 Standard_Real v1v2 = P1.Distance(P2);
476 Standard_Real tole = BRep_Tool::Tolerance(E);
477 Standard_Real tol1 = BRep_Tool::Tolerance(v1);
478 Standard_Real tol2 = BRep_Tool::Tolerance(v2);
479 const TopTools_ListOfShape& l1 = incidentedges(v1);
480 const TopTools_ListOfShape& l2 = incidentedges(v2);
481 Handle(Geom2d_Curve) c2d = curve2d(E);
482
483// char sdi[1000];
484 char stol[1000];
485 TCollection_AsciiString ste,stc,sv1,sv1a,sv2,sv2a,ste1,ste2;
486
487 ename(E,ste);
488 stc = "c"; stc = stc + ste;
489 vname(v1,E,sv1); sv1a = "V"; sv1a = sv1a + sv1;
490 vname(v2,E,sv2); sv2a = "V"; sv2a = sv2a + sv2;
491 lenames(l1,ste1);
492 lenames(l2,ste2);
493
494 cout<<endl;
495 sprintf(stol,"%g",tole);
496 cout<<"# "<<ste<<" : tole "<<stol<<" : uv "<<pe1.X()<<" "<<pe1.Y()<<" UV "<<pe2.X()<<" "<<pe2.Y();
497 cout<<endl;
498 sprintf(stol,"%g",tol1);
499 cout<<"# "<<sv1<<" : tol1 "<<stol<<" : uv "<<p1.X()<<" "<<p1.Y()<<" : edges "<<ste1;
500 cout<<endl;
501 sprintf(stol,"%g",tol2);
502 cout<<"# "<<sv2<<" : tol2 "<<stol<<" : uv "<<p2.X()<<" "<<p2.Y()<<" : edges "<<ste2;
503 cout<<endl;
504 sprintf(stol,"%g",v1v2); cout<<"# v1v2 = "<<stol;
505 cout<<endl;
506 cout.flush();
507
508 erasevisible();
509 TestTopOpeDraw_C2DDisplayer TDC2D;
510 TestTopOpeDraw_P2DDisplayer TDP2D;
511 TestTopOpeDraw_Displayer TD;
512
513 TDC2D.AllColors(color(E)); TDC2D.DisplayC2D(stc,ste,c2d);
514 TDP2D.AllColors(color(v1));TDP2D.DisplayP2D(sv1,p1);
515 TDP2D.AllColors(color(v2));TDP2D.DisplayP2D(sv2,p2);
516 TD.AllColors(color(E));TD.DisplayShape(ste,ste,E);
517 if (!deg) {
518 TD.AllColors(color(v1));TD.DisplayShape(sv1a,sv1,v1);
519 TD.AllColors(color(v2));TD.DisplayShape(sv2a,sv2,v2);
520 }
521 else {
522 TD.AllColors(Draw_Color(Draw_blanc));TD.DisplayShape(sv1a,"",v1);
523 }
524 addvisible(stc);
525 addvisible(sv1);
526 addvisible(sv2);
527 addvisible(ste);
528 addvisible(sv1a);
529 addvisible(sv2a);
530 Standard_Integer ie = eindex(E);
531 setcurredgeiter(ie);
532 setedgedisplayed(ie);
533
534 DrawTrSurf_CurveColor(savecol);
535 return 0;
536} // displayedge
537
538//=======================================================================
539// vx2d
540//=======================================================================
541Standard_Integer vx2d(Draw_Interpretor& di, Standard_Integer na, const char** a)
542{
543 static cvx2d *pv2d = NULL;
544#define ISINTEGER(MMstr) ((strspn((MMstr),"0123456789") == strlen((MMstr))))
545
546 BoopReadInitFile(di,"vx2d.tcl");
547 if (na < 2) return 0;
548 if (pv2d == NULL) pv2d = (cvx2d*) new cvx2d(di);
549
550 Standard_Integer dostep = 0;Standard_Integer doiedge= 0;
551 for(Standard_Integer ia=1;ia<na;ia++) {
552 if (!strcasecmp(a[1],"-n")) { dostep=+1; DRAWsuppressarg(na,a,ia); }
553 else if(!strcasecmp(a[1],"-p")) { dostep=-1; DRAWsuppressarg(na,a,ia); }
554 else if (ISINTEGER(a[1])) { doiedge=atoi(a[1]); DRAWsuppressarg(na,a,ia); }
555 }
556
557 if (dostep) {
558 if (pv2d->edgedisplayed()) pv2d->nextedgeiter(dostep);
559 if (pv2d->moreedgeiter()) pv2d->displayedge(pv2d->edge(pv2d->curredgeiter()));
560 return 0;
561 }
562 else if (doiedge) {
563 pv2d->setcurredgeiter(doiedge);
564 if (pv2d->moreedgeiter()) pv2d->displayedge(pv2d->edge(pv2d->curredgeiter()));
565 return 0;
566 }
567
568 TopoDS_Shape S = DBRep::Get(a[1]); if (S.IsNull()) return 0;
569 TCollection_AsciiString sta1(a[1]); TopAbs_ShapeEnum t = S.ShapeType();
570 TopAbs_ShapeEnum tt = ( t == TopAbs_FACE) ? TopAbs_EDGE : TopAbs_FACE;
571
572 Standard_Integer iearg = (na >= 3) ? atoi(a[2]) : 0;
573 TCollection_AsciiString stss; Standard_Integer i = 1;
574 TopExp_Explorer ex;
575 for (ex.Init(S,tt);ex.More();ex.Next(),i++) {
576// for (TopExp_Explorer ex(S,tt);ex.More();ex.Next(),i++) {
577 Standard_Boolean cond = Standard_False;
578 cond = cond || (!iearg);
579 cond = cond || (iearg && (iearg == i));
580 if (cond) {
581 pv2d->subshapename(sta1,tt,i,stss);
582 DBRep::Set(stss.ToCString(),ex.Current());
583 di<<"vx2d "<<stss.ToCString()<<"\n";
584 //cout.flush();
585 }
586 }
587
588 Standard_Integer r = 0;
589 if (t == TopAbs_FACE) r = pv2d->displayface(S,sta1);
590 else if (t == TopAbs_EDGE) r = pv2d->displayedge(S);
591 return r;
592} // vx2d
593
594//=======================================================================
595//function : OtherCommands
596//purpose :
597//=======================================================================
598
599void TestTopOpeDraw::OtherCommands(Draw_Interpretor& theCommands)
600{
601 const char* g = "Topological Operation other commands";
602 theCommands.Add("cdinp","cdinp p x y z",__FILE__,testtopopedraw_cdinp,g);
603 theCommands.Add("cdins","cdins s1 ... ",__FILE__,testtopopedraw_cdins,g);
604 theCommands.Add("vx2d","vx2d f",__FILE__,vx2d,g);
605 BoopReadInitFile(theCommands,getenv("BOOPGLOB"));
606 theCommands.Add("ttab","",__FILE__,ttab,g);
607}