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