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