0022922: Clean up warnings on uninitialized / unused variables
[occt.git] / src / TestTopOpe / TestTopOpe_BOOPCommands.cxx
CommitLineData
7fd59977 1// File: TestTopOpe_BOOPCommands.cxx
2// Created: Mon Oct 21 10:32:36 1996
3// Author: Jean Yves LEBEY
4// <jyl@bistrox.paris1.matra-dtv.fr>
5
6#ifdef HAVE_CONFIG_H
7# include <config.h>
8#endif
9#include <TestTopOpe.ixx>
10
11#include <TestTopOpe_BOOP.hxx>
12#include <BRep_Tool.hxx>
13#include <TopoDS.hxx>
14#include <TopExp_Explorer.hxx>
15#include <TColStd_HArray1OfBoolean.hxx>
16#include <DBRep.hxx>
17#ifdef HAVE_STRINGS_H
18# include <strings.h>
19#endif
20
21Standard_IMPORT void suppressarg(Standard_Integer& na,const char** a,const Standard_Integer d);
22#ifdef DEB
23Standard_IMPORT void TopOpeBRepTool_SettraceEND(const Standard_Boolean);
24Standard_IMPORT Standard_Boolean TopOpeBRepTool_GettraceEND();
25#endif
26
27static const char* kboo[TESTTOPOPE_NKEYS] = {"topo","secc","sece","sec","com","c12","c21","fus"};
28static TestTopOpe_BOOP LOCALBOOP(kboo, "r");
29Standard_EXPORT TestTopOpe_BOOP* PBOOP=&LOCALBOOP;
30
31void CATIND
32(TCollection_AsciiString& s,const Standard_Integer I,const TCollection_AsciiString& a,const TCollection_AsciiString& b) {s=s+a+TCollection_AsciiString(I)+b;}
33void CATSHA
34(TCollection_AsciiString& s,const TopoDS_Shape& S,const TopOpeBRepDS_DataStructure& BDS,const TCollection_AsciiString& a,const TCollection_AsciiString& b)
35{if (S.IsNull()) return;::CATIND(s,BDS.Shape(S),a,b);}
36void CATLOSHA
37(TCollection_AsciiString& s,const TopTools_ListOfShape& L,const TopOpeBRepDS_DataStructure& BDS,const TCollection_AsciiString& a,const TCollection_AsciiString& aa,const TCollection_AsciiString& bb,const TCollection_AsciiString& b)
38{
39 if (!L.Extent()) return;
40 s=s+a;for(TopTools_ListIteratorOfListOfShape i(L);i.More();i.Next())::CATSHA(s,i.Value(),BDS,aa,bb);s=s+b;
41}
42
43Standard_Integer TOPOCHKCOMMANDS(TestTopOpe_BOOP& P,Standard_Integer na,const char**a);
44Standard_Integer TOPOSETCOMMANDS(TestTopOpe_BOOP& P,Standard_Integer na,const char**a, Draw_Interpretor& di);
45Standard_Integer TOPOCOMMANDS(TestTopOpe_BOOP& PT,Standard_Integer na,const char**a, Draw_Interpretor& di);
46
47// ----------------------------------------------------------------------
48Standard_Integer TOPOC(Draw_Interpretor& interpretor,Standard_Integer na,const char** a)
49{
50 if (PBOOP == NULL) return 0;
51 Standard_Integer err=0, i;
52
53 if (!strncmp(a[0],kboo[BOOP_TOPX],4)) {
54 err = TOPOCOMMANDS((*PBOOP),na,a,interpretor);
55 return err;
56 }
57 else if (PBOOP->IsBooope(a[0])) {
58 PBOOP->Booope(a[0],(na >= 2) ? a[1] : NULL);
59 return 0;
60 }
61 else if (!strcmp(a[0],"toposet")) {
62 err = TOPOSETCOMMANDS((*PBOOP),na,a,interpretor);
63 return err;
64 }
65 else if (!strcmp(a[0],"tsp") ) {
66 TopAbs_State sta = TopAbs_UNKNOWN;
67 if (na >= 2) {
68 if (!strcmp(a[1],"IN")) sta = TopAbs_IN;
69 else if (!strcmp(a[1],"OUT")) sta = TopAbs_OUT;
70 else if (!strcmp(a[1],"ON")) sta = TopAbs_ON;
71
72 if (sta==TopAbs_IN||sta==TopAbs_OUT||sta == TopAbs_ON) {
73 if (na==2) { PBOOP->GetSplit(sta); } // tsp IN/ON/OUT
74 else if ( na > 2 ) {
75 TopAbs_ShapeEnum typ = TopAbs_SHAPE;
76 if (!strcmp(a[2],"e")) typ = TopAbs_EDGE;
77 else if (!strcmp(a[2],"f")) typ = TopAbs_FACE;
78 else if (!strcmp(a[2],"s")) typ = TopAbs_SOLID;
79 if (typ==TopAbs_EDGE||typ==TopAbs_FACE||typ==TopAbs_SOLID) {
80 if (na == 3) {
81 // tsp IN/ON/OUT e/f/s
82 PBOOP->GetSplit(typ,sta);
83 }
84 else if (na > 3) {
85 // tsp IN/ON/OUT e/f/s i1 i2 ...
86 for(i=3;i<na;i++) PBOOP->GetSplit(typ,sta,atoi(a[i]));
87 }
88 }
89 else {
90 // tsp IN/ON/OUT i1 i2 ...
91 for(i=2;i<na;i++) PBOOP->GetSplit(sta,atoi(a[i]));
92 }
93 }
94 else if ( na > 2 ) {
95 // tsp IN/ON/OUT i1 i2 ...
96 for(i=2;i<na;i++) PBOOP->GetSplit(sta,atoi(a[i]));
97 }
98 }
99 else { // tsp i1 i2 ...
100 for (i = 1; i < na; i++) {
101 if ( ISINTEGER(a[i]) ) PBOOP->GetSplit(atoi(a[i]));
102 }
103 }
104 }
105 else {
106 PBOOP->GetSplit(TopAbs_IN);
107 PBOOP->GetSplit(TopAbs_ON);
108 PBOOP->GetSplit(TopAbs_OUT);
109 } // tsp
110 } // arg0 = tsp
111
112 else if (!strcmp(a[0],"tme") ) {
113 TopAbs_State sta = TopAbs_UNKNOWN;
114 if (na >= 2) {
115 if (!strcmp(a[1],"IN")) sta = TopAbs_IN;
116 else if (!strcmp(a[1],"OUT")) sta = TopAbs_OUT;
117 else if (!strcmp(a[1],"ON")) sta = TopAbs_ON;
118
119 if (sta==TopAbs_IN||sta==TopAbs_OUT||sta == TopAbs_ON) {
120 if (na==2) { PBOOP->GetMerged(sta); } // tme IN/ON/OUT
121 else if ( na > 2 ) {
122 TopAbs_ShapeEnum typ = TopAbs_SHAPE;
123 if (!strcmp(a[2],"e")) typ = TopAbs_EDGE;
124 else if (!strcmp(a[2],"f")) typ = TopAbs_FACE;
125 else if (!strcmp(a[2],"s")) typ = TopAbs_SOLID;
126 if (typ==TopAbs_EDGE||typ==TopAbs_FACE||typ==TopAbs_SOLID) {
127 if (na == 3) {
128 // tme IN/ON/OUT e/f/s
129 PBOOP->GetMerged(typ,sta);
130 }
131 else if (na > 3) {
132 // tme IN/ON/OUT e/f/s i1 i2 ...
133 for(i=3;i<na;i++) PBOOP->GetMerged(typ,sta,atoi(a[i]));
134 }
135 }
136 else {
137 // tme IN/ON/OUT i1 i2 ...
138 for(i=2;i<na;i++) PBOOP->GetMerged(sta,atoi(a[i]));
139 }
140 }
141 else if ( na > 2 ) {
142 // tme IN/ON/OUT i1 i2 ...
143 for(i=2;i<na;i++) PBOOP->GetMerged(sta,atoi(a[i]));
144 }
145 }
146 else { // tme i1 i2 ...
147 for (i = 1; i < na; i++) {
148 if ( ISINTEGER(a[i]) ) PBOOP->GetMerged(atoi(a[i]));
149 }
150 }
151 }
152 else {
153 PBOOP->GetMerged(TopAbs_IN);
154 PBOOP->GetMerged(TopAbs_ON);
155 PBOOP->GetMerged(TopAbs_OUT);
156 } // tme
157 } // arg0 = tme
158
159 else if (!strcmp(a[0],"csecanc") ) {
160 Standard_Integer ia;
161
162 Standard_Boolean outdraw = Standard_False,outclear = Standard_False,outAB = Standard_False;
163 for (ia=1; ia<na; ia++ ) {
164 if (!strcmp(a[ia],"-d")) outdraw = Standard_True;
165 else if (!strcmp(a[ia],"-c")) outclear = Standard_True;
166 else if (!strcmp(a[ia],"-AB")) outAB = Standard_True;
167 }
168
169 Handle_TopOpeBRepBuild_HBuilder HB = PBOOP->HBuilder();
170 Handle_TopOpeBRepDS_HDataStructure HDS = HB->DataStructure();
171 const TopOpeBRepDS_DataStructure& BDS = HDS->DS();
172 const TopTools_ListOfShape& loe = HB->Section();
173
174 Standard_Boolean onedef = Standard_False;
175 Standard_Integer n = loe.Extent();
176 Handle(TColStd_HArray1OfBoolean) tabloe = new TColStd_HArray1OfBoolean(1,n,Standard_False);
177 for (ia=1; ia<na; ia++ ) {
178 if (!strcmp(a[ia],"-d")) continue;
179 if (!strcmp(a[ia],"-c")) continue;
180 if (!strcmp(a[ia],"-AB")) continue;
181 Standard_Integer ie = atoi(a[ia]);
182 if (ie>=1 && ie<=n) { onedef = Standard_True; tabloe->SetValue(ie,Standard_True); }
183 }
184 if (!onedef) tabloe->Init(Standard_True);
185
186 TopTools_ListIteratorOfListOfShape itloe(loe);
187 for (Standard_Integer ie=1;itloe.More();itloe.Next(),ie++) {
188 if (!tabloe->Value(ie)) continue;
189 const TopoDS_Shape& es = itloe.Value();
190 TopoDS_Shape F1,F2; Standard_Integer IC; TopTools_ListOfShape LF1,LF2,LE1,LE2;
191 Standard_Boolean eca = HB->EdgeCurveAncestors(es,F1,F2,IC);
192 Standard_Boolean esa = HB->EdgeSectionAncestors(es,LF1,LF2,LE1,LE2);
193 TCollection_AsciiString namie("se"); namie = namie + TCollection_AsciiString(ie);
194 DBRep::Set(namie.ToCString(),es);
195 if (eca) {
196 TCollection_AsciiString s;
6e6cd5d9 197
7fd59977 198 if (outdraw) {
199 if (outclear) s = s + "clear; ";
200 ::CATSHA(s,F1,BDS,"tsee f ","; ");
201 ::CATSHA(s,F2,BDS,"tsee f ","; ");
202 ::CATIND(s,IC,"tsee c ","; ");
203 s = s + "cdins " + namie;
204 interpretor<<s.ToCString()<<"\n";
205 if (outAB) {
206 s = " ";
207 ::CATSHA(s,F1,BDS,"mksol A f_","; ");
208 ::CATSHA(s,F2,BDS,"mksol B f_","; ");
209 s = s + "topopeload A B; ";
210 s = s + "# " + namie;
211 interpretor<<s.ToCString()<<"\n";
212 }
213 }
214 else {
215 s = s + "section edge " + TCollection_AsciiString(ie) + " ";
216 ::CATSHA(s,F1,BDS," f1 : ","");
217 ::CATSHA(s,F2,BDS," f2 : ","");
218 ::CATIND(s,IC," c : ","");
219 interpretor<<s.ToCString()<<"\n";
220 }
221 }
222
223 if (esa) {
224 TCollection_AsciiString s;
225#ifdef DEB
226 TopTools_ListIteratorOfListOfShape ils;
227#endif
228 if (outdraw) {
229 if (outclear) s = s + "clear; ";
230 ::CATLOSHA(s,LF1,BDS,"tsee f ",""," ","; ");
231 ::CATLOSHA(s,LF2,BDS,"tsee f ",""," ","; ");
232 ::CATLOSHA(s,LE1,BDS,"tsee e ",""," ","; ");
233 ::CATLOSHA(s,LE2,BDS,"tsee e ",""," ","; ");
234 s = s + "cdins " + "-p 0.5 " + namie;
235 interpretor<<s.ToCString()<<"\n";
236 if (outAB) {
237 s = " ";
238 ::CATLOSHA(s,LF1,BDS,"mksol A ","f_"," ","; ");
239 ::CATLOSHA(s,LF2,BDS,"mksol B ","f_"," ","; ");
240 s = s + "topopeload A B;";
241 s = s + " # " + namie;
242 interpretor<<s.ToCString()<<"\n";
243 }
244 }
245 else {
246 s = s + "section edge " + TCollection_AsciiString(ie) + " ";
247 ::CATLOSHA(s,LF1,BDS," f1 : ",""," ","");
248 ::CATLOSHA(s,LF2,BDS," f2 : ",""," ","");
249 ::CATLOSHA(s,LE1,BDS," e1 : ",""," ","");
250 ::CATLOSHA(s,LE2,BDS," e2 : ",""," ","");
251 interpretor<<s.ToCString()<<"\n";
252 }
253 }
254 if ( !eca && !esa ) {
255 interpretor<<"edge "<<ie<<" has no ancestors"<<"\n";
256 }
257 }
258 }
259 else if (!strcmp(a[0],"parvi") ) {
260 TopoDS_Shape S = DBRep::Get(a[1]);
261 TopExp_Explorer ee(S,TopAbs_EDGE);
262 for(Standard_Integer ie=1; ee.More(); ee.Next(),ie++) {
263 TopoDS_Edge e = TopoDS::Edge(ee.Current());
264 e.Orientation(TopAbs_FORWARD);
265 TCollection_AsciiString enam("VIe");enam=enam+TCollection_AsciiString(ie);
266 TopExp_Explorer ev(e,TopAbs_VERTEX);
267 for(Standard_Integer iv=1; ev.More(); ev.Next(),iv++) {
268 const TopoDS_Vertex v = TopoDS::Vertex(ev.Current());
269 if (v.Orientation()!=TopAbs_INTERNAL) continue;
270 TCollection_AsciiString vnam;vnam=enam+"i"+TCollection_AsciiString(iv);
271 DBRep::Set(enam.ToCString(),e);
272 DBRep::Set(vnam.ToCString(),v);
273 interpretor<<"din "<<enam.ToCString()<<" "<<vnam.ToCString();
274 interpretor<<" ;#par("<<vnam.ToCString()<<"/"<<enam.ToCString()<<") ";
275 //cout.flush();
276 interpretor<<"\n";
277 Standard_Real p = BRep_Tool::Parameter(v,e);
278 interpretor<<p<<"\n";
279 }
280 }
281 }
282 else if (!strcmp(a[0],"parvi2d") ) {
283 TopoDS_Shape S = DBRep::Get(a[1]);
284 TopExp_Explorer ef(S,TopAbs_FACE);
285 for(Standard_Integer ifa=1; ef.More(); ef.Next(),ifa++) {
286 TopoDS_Face f = TopoDS::Face(ef.Current());
287 f.Orientation(TopAbs_FORWARD);
288 TCollection_AsciiString fnam("VIf");fnam=fnam+TCollection_AsciiString(ifa);
289 DBRep::Set(fnam.ToCString(),f);
290 TopExp_Explorer ee(f,TopAbs_EDGE);
291 for(Standard_Integer ie=1; ee.More(); ee.Next(),ie++) {
292 TopoDS_Edge e = TopoDS::Edge(ee.Current());
293 e.Orientation(TopAbs_FORWARD);
294 TCollection_AsciiString enam;enam=fnam+"e"+TCollection_AsciiString(ie);
295 TopExp_Explorer ev(e,TopAbs_VERTEX);
296 for(Standard_Integer iv=1; ev.More(); ev.Next(),iv++) {
297 const TopoDS_Vertex v = TopoDS::Vertex(ev.Current());
298 if (v.Orientation()!=TopAbs_INTERNAL) continue;
299 TCollection_AsciiString vnam;vnam=enam+"vi"+TCollection_AsciiString(iv);
300 DBRep::Set(enam.ToCString(),e);
301 DBRep::Set(vnam.ToCString(),v);
302 interpretor<<"din "<<fnam.ToCString()<<" "<<enam.ToCString()<<" "<<vnam.ToCString();
303 interpretor<<" ;#par("<<vnam.ToCString()<<"/"<<enam.ToCString()<<","<<fnam.ToCString()<<") ";
304 //cout.flush();
305 interpretor<<"\n";
306 Standard_Real p=BRep_Tool::Parameter(v,e,f);
307 interpretor<<p<<"\n";
308 }
309 }
310 }
311 }
312 return 0 ;
313} // TOPO
314
315// ----------------------------------------------------------------------
316Standard_Integer BOOPCHK(Draw_Interpretor& ,Standard_Integer na,const char** a)
317{
318 if (!strcmp(a[0],"tchk")) {
319#ifdef DEB
320// Standard_IMPORT extern Standard_Integer TopOpeBRepTool_BOOOPE_CHECK_DEB;
321 Standard_IMPORT Standard_Integer TopOpeBRepTool_BOOOPE_CHECK_DEB;
322 if ( na >= 2 ) TopOpeBRepTool_BOOOPE_CHECK_DEB = (atoi(a[1])) ? 1 : 0;
323#endif
324 return 0;
325 }
326 return 0;
327}
328
329// ----------------------------------------------------
330Standard_Integer TOPOSETCOMMANDS(TestTopOpe_BOOP& PT,Standard_Integer na,const char** a, Draw_Interpretor& di)
331{
332 switch(na) {
333 case 1:
334 di<<"toposet <kind> <index> <tol>"<<"\n";
335 di<<"toposet <kind = Point> <index> <x> <y> <z>"<<"\n";
336 di<<"kind = p | c | s | v | e | f | w "<<"\n";
337 return 1;
338 case 4:
339 if(!strcasecmp(a[1],"p"))
340 PT.SetTol(TopOpeBRepDS_POINT,atoi(a[2]),atof(a[3]));
341 else if(!strcasecmp(a[1],"c"))// c ou C
342 PT.SetTol(TopOpeBRepDS_CURVE,atoi(a[2]),atof(a[3]));
343 else if(!strcasecmp(a[1],"s"))
344 PT.SetTol(TopOpeBRepDS_SURFACE,atoi(a[2]),atof(a[3]));
345 else if(!strcasecmp(a[1],"sh") ||
346 !strcasecmp(a[1],"v") ||
347 !strcasecmp(a[1],"e") ||
348 !strcasecmp(a[1],"f") ||
349 !strcasecmp(a[1],"w"))
350 PT.SetTol(atoi(a[2]),atof(a[3]));
351 break;
352 case 6:
353 if(!strcasecmp(a[1],"p"))
354 PT.SetPnt(atoi(a[2]),atof(a[3]),atof(a[4]),atof(a[5]));
355 else
356 return 1;
357 break;
358 default:
359 break;
360 } // switch na
361 return 0;
362}
363
364// -----------------------------------------------------
365void TOPOHELP(TestTopOpe_BOOP& PT, Draw_Interpretor& di)
366{
367 di<<"\n";
368 di<<"Help on topo command :"<<"\n";
369 di<<"----------------------"<<"\n";
370 for (Standard_Integer ic=0;ic<PT.Tnb();ic++) di<<PT.Tkeys(ic).ToCString()<<" : "<<PT.Thelp(ic).ToCString()<<"\n";
371 di<<"args :"<<"\n";
372 di<<"-2d -no2d : produce (or not) 2d curves in section"<<"\n";
373 di<<"-a : section curves approximated (default)"<<"\n";
374 di<<"-p : section curve discretisated"<<"\n";
375 di<<"-tx [default] | tol1 tol2 : set approximation tolerances"<<"\n";
376 di<<"-ti [shape] | tol1 tol2 : set intersection tolerances"<<"\n";
377 di<<"-c 0/[1] : clear view before displaying result"<<"\n";
378 di<<"-m [0]/1 : execute methods / explode methods"<<"\n";
379 di<<"-f [name] : retrieve shape/index <name> among input shapes (exploration index)"<<"\n";
380 di<<"-v [0]/1 : do not trace / trace methods name"<<"\n";
381 di<<"-d : dump all control variables"<<"\n";
382 di<<"-i : initialize control variables to default values"<<"\n";
383 di<<"-h : help"<<"\n";
384 di<<"----------------------"<<"\n";
385}
386
387// -------------------------------------------------------
388Standard_Integer VARSTOPOARGS(TestTopOpe_BOOP& PT,Standard_Integer& na,const char** a, Draw_Interpretor& di)
389{
390 VarsTopo& VT = PT.ChangeVarsTopo();
391
392 Standard_Boolean dump = Standard_False;
393 Standard_Boolean help = Standard_False;
394 Standard_Integer ia = 1;
395 while (ia < na) {
396 const char *thea = a[ia];
397 if (!strcmp(thea,"-f")) {
398 suppressarg(na,a,ia);
399 if (ia < na) {
400 PT.FindShape(a[ia]);
401 suppressarg(na,a,ia);
402 }
403 else {
404 PT.FindShape(0);
405 }
406 }
407 else if (!strcasecmp(thea,"-2d")) {
408 VT.SetC2D(Standard_True);
409 suppressarg(na,a,ia);
410 }
411 else if (!strcasecmp(thea,"-no2d")){
412 VT.SetC2D(Standard_False);
413 suppressarg(na,a,ia);
414 }
415 else if (!strcasecmp(thea,"-a")) {
416 VT.SetOCT(TopOpeBRepTool_APPROX);
417 suppressarg(na,a,ia);
418 }
419 else if (!strcasecmp(thea,"-p")) {
420 VT.SetOCT(TopOpeBRepTool_BSPLINE1);
421 suppressarg(na,a,ia);
422 }
423 else if (!strcmp(thea,"-tx")) {
424 suppressarg(na,a,ia);
425 if (ia + 1 < na) {
426 VT.SetTolx(atof(a[ia]),atof(a[ia + 1]));
427 suppressarg(na,a,ia);
428 suppressarg(na,a,ia);
429 }
430 else if (ia < na) {
431 if (!strcmp(a[ia],"default")) {
432 VT.SetTolxDef();
433 suppressarg(na,a,ia);
434 }
435 else {
436 VT.SetTolx(atof(a[ia]),atof(a[ia]));
437 suppressarg(na,a,ia);
438 }
439 }
440 }
441 else if (!strcmp(thea,"-ti")) {
442 suppressarg(na,a,ia);
443 if (ia + 1 < na) {
444 VT.SetToli(atof(a[ia]),atof(a[ia + 1]));
445 suppressarg(na,a,ia);
446 suppressarg(na,a,ia);
447 }
448 else if (ia < na) {
449 if (!strcmp(a[ia],"shape")) {
450 VT.SetToliDef();
451 suppressarg(na,a,ia);
452 }
453 else {
454 VT.SetToli(atof(a[ia]),atof(a[ia]));
455 suppressarg(na,a,ia);
456 }
457 }
458 }
459 else if (!strcmp(thea,"-c")) {
460 suppressarg(na,a,ia);
461 if (ia < na) {
462 VT.SetClear((Standard_Boolean)atoi(a[ia]));
463 suppressarg(na,a,ia);
464 }
465 else VT.SetClear(Standard_True);
466 }
467 else if (!strcasecmp(thea,"-d")) {
468 dump = Standard_True;
469 suppressarg(na,a,ia);
470 }
471 else if (!strcasecmp(thea,"-i")) {
472 VT.Init();
473 suppressarg(na,a,ia);
474 }
475 else if (!strcmp(thea,"-m")) {
476 suppressarg(na,a,ia);
477 if (ia < na) {
478 VT.SetMode(atoi(a[ia]));
479 suppressarg(na,a,ia);
480 }
481 else VT.SetMode(0);
482 }
483 else if (!strcmp(thea,"-v")) {
484 suppressarg(na,a,ia);
485 if (ia < na) {
486 VT.SetVerbose(atoi(a[ia]));
487 suppressarg(na,a,ia);
488 }
489 else VT.SetVerbose(0);
490 }
491 else if (!strcasecmp(thea,"-h")) {
492 help = Standard_True;
493 suppressarg(na,a,ia);
494 }
495 else {
496 ia++;
497 }
498 } // while (ia < na)
499 if (dump) VT.Dump(cout);
500 if (help) TOPOHELP(PT, di);
501 return 0;
502
503} // VARSTOPOARGS
504
505// ----------------------------------------------------
506Standard_Integer SETTOPOCOMMANDS(TestTopOpe_BOOP& PT)
507{
508 PT.Tinit();
509 PT.Tadd("-def",0 ,"[a b] : load shapes");
510 PT.Tadd("-iss",100,"[a b] : intersection");
511 PT.Tadd("-gap",110,"[a b] : gap filler");
512 PT.Tadd("-cds",115,"[a b] : complete DS");
513 PT.Tadd("-fil",120,"[a b] : filter");
514 PT.Tadd("-red",130,"[a b] : reducer");
515 PT.Tadd("-rug",140,"[a b] : remove unshared geometry");
516 PT.Tadd("-chk",150,"[a b] : check DS");
517 PT.Tadd("-bui",200,"[a b] : section building");
518 PT.Tadd("-all",290,"[a b] : all");
519 return 0;
520}
521
522// ----------------------------------------------------
523Standard_Integer SETTOPOPREP(TestTopOpe_BOOP& PT,Standard_Integer& na,const char** a)
524{
525 if (na < 2) return 0;
526 const char* thea = a[0];
527 PT.mytodoPREP = 999;
528 if (!strcasecmp(thea,"topo") && na == 3) {
529 PT.mylastPREP = -1;
530 return 0;
531 }
532 if (na == 4) {
533 PT.mylastPREP = -1;
534 }
535
536 Standard_Integer ia = 1;
537 while (ia < na) {
538 thea = a[ia];
539 Standard_Integer ik = PT.Tstep(thea);
540 if (ik != -1) {
541 PT.mytodoPREP = ik;
542 suppressarg(na,a,ia);
543 }
544 else {
545 ia++;
546 }
547 }
548 return 0;
549}
550
551// ----------------------------------------------------
552Standard_Integer TOPOCOMMANDS(TestTopOpe_BOOP& PT,Standard_Integer na,const char** a, Draw_Interpretor& di)
553{
554 Standard_Integer err = 0;
555 if (strncmp(a[0],"topo",4)) return 1;
556 if (na == 2 && !strcasecmp(a[1],"-h")) { TOPOHELP(PT, di); return 0; }
557 err = VARSTOPOARGS(PT,na,a, di); if (err) return err;
558 if (na == 1) return 0;
559 err = SETTOPOPREP(PT,na,a); if (err) return err;
560
561#ifdef DEB
562 Standard_Boolean tend = TopOpeBRepTool_GettraceEND();
563 TopOpeBRepTool_SettraceEND(PT.ChangeVarsTopo().GetVerbose());
564#endif
565
566 err = 0;
567 TopOpeBRep_DSFiller* PDSF = PT.myPDSF;
568 while (PT.mylastPREP <= PT.mytodoPREP) {
569 switch (PT.mylastPREP) {
570 case -1 : if (na >= 3) err = PT.LoadShapes(a[1],a[2]);break;
571 case 0 : err = PT.LoadnewDS(); PDSF = PT.myPDSF; break;
572 case 100 : err = PT.DSF_Insert_InsertIntersection(*PDSF); break;
573 case 110 : err = PT.DSF_Insert_Complete_GapFiller(*PDSF);break;
574 case 115 : err = PT.DSF_Insert_Complete_CompleteDS(*PDSF); break;
575 case 120 : err = PT.DSF_Insert_Complete_Filter(*PDSF); break;
576 case 130 : err = PT.DSF_Insert_Complete_Reducer(*PDSF); break;
577 case 140 : err = PT.DSF_Insert_Complete_RemoveUnsharedGeometry(*PDSF); break;
578 case 150 : err = PT.DSF_Insert_Complete_Checker(*PDSF); break;
579 case 160 : err = PT.LoadnewHB(); break;
580 case 200 : err = PT.Builder_Perform(); break;
581 case 290 : PT.mylastPREP = 1000; break;
582 default : PT.mylastPREP = 1000; break;
583 }
584 if (err) return err;
585 }
586
587#ifdef DEB
588 TopOpeBRepTool_SettraceEND(tend);
589#endif
590 return 0;
591}
592
593//=======================================================================
594//function : BOOPCommands
595//purpose :
596//=======================================================================
597void TestTopOpe::BOOPCommands(Draw_Interpretor& theCommands)
598{
599 SETTOPOCOMMANDS(*PBOOP);
600 theCommands.Add(kboo[BOOP_TOPX],"-h for help",__FILE__,TOPOC);
601 theCommands.Add(kboo[BOOP_SECC],"secc [r]",__FILE__,TOPOC);
602 theCommands.Add(kboo[BOOP_SECE],"sece [r]",__FILE__,TOPOC);
603 theCommands.Add(kboo[BOOP_SEC],"sec [r]",__FILE__,TOPOC);
604 theCommands.Add(kboo[BOOP_C12],"c12 [r]",__FILE__,TOPOC);
605 theCommands.Add(kboo[BOOP_C21],"c21 [r]",__FILE__,TOPOC);
606 theCommands.Add(kboo[BOOP_COM],"com [r]",__FILE__,TOPOC);
607 theCommands.Add(kboo[BOOP_FUS],"fus [r]",__FILE__,TOPOC);
608 theCommands.Add("toposet","",__FILE__,TOPOC);
609 theCommands.Add("tsp","tsp [state] iS1 : get split parts",__FILE__,TOPOC);
610 theCommands.Add("tme","tme [state] iS1 : get merged parts",__FILE__,TOPOC);
611 theCommands.Add("csecanc","section edge ancestors. use : puts [csecanc]",__FILE__,TOPOC);
612 theCommands.Add("parvi","parvi <shape> : get parameter of internal vertices",__FILE__,TOPOC);
613 theCommands.Add("parvi2d","parvi <shape> : get parameter of internal vertices",__FILE__,TOPOC);
614 theCommands.Add("tchk","tchk 1/0 : check SameParameter edges or not in BRepBuilderAPI",__FILE__,BOOPCHK);
615}
616
617#if 0
618 if (!strcasecmp(thea,"-def")) { PT.mytodoPREP = 0; suppressarg(na,a,ia); }
619 else if (!strcasecmp(thea,"-iss")) { PT.mytodoPREP = 100; suppressarg(na,a,ia); }
620 else if (!strcasecmp(thea,"-gap")) { PT.mytodoPREP = 110; suppressarg(na,a,ia); }
621 else if (!strcasecmp(thea,"-cds")) { PT.mytodoPREP = 115; suppressarg(na,a,ia); }
622 else if (!strcasecmp(thea,"-fil")) { PT.mytodoPREP = 120; suppressarg(na,a,ia); }
623 else if (!strcasecmp(thea,"-red")) { PT.mytodoPREP = 130; suppressarg(na,a,ia); }
624 else if (!strcasecmp(thea,"-rug")) { PT.mytodoPREP = 140; suppressarg(na,a,ia); }
625 else if (!strcasecmp(thea,"-chk")) { PT.mytodoPREP = 150; suppressarg(na,a,ia); }
626 else if (!strcasecmp(thea,"-bui")) { PT.mytodoPREP = 200; suppressarg(na,a,ia); }
627 else if (!strcasecmp(thea,"-all")) { PT.mytodoPREP = 290; suppressarg(na,a,ia); }
628#endif