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