0020716: Eliminate usage of "config.h" header file
[occt.git] / src / TestTopOpe / TestTopOpe_BOOPCommands.cxx
CommitLineData
b311480e 1// Created on: 1996-10-21
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//
d5f74e42 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
973c2be1 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
7fd59977 17#include <TestTopOpe.ixx>
18
19#include <TestTopOpe_BOOP.hxx>
20#include <BRep_Tool.hxx>
21#include <TopoDS.hxx>
22#include <TopExp_Explorer.hxx>
23#include <TColStd_HArray1OfBoolean.hxx>
91322f44 24#include <Draw.hxx>
7fd59977 25#include <DBRep.hxx>
7fd59977 26
1d0a9d4d 27extern void suppressarg(Standard_Integer& na,const char** a,const Standard_Integer d);
7fd59977 28#ifdef DEB
1d0a9d4d 29extern void TopOpeBRepTool_SettraceEND(const Standard_Boolean);
30extern Standard_Boolean TopOpeBRepTool_GettraceEND();
7fd59977 31#endif
32
33static const char* kboo[TESTTOPOPE_NKEYS] = {"topo","secc","sece","sec","com","c12","c21","fus"};
34static TestTopOpe_BOOP LOCALBOOP(kboo, "r");
1d0a9d4d 35TestTopOpe_BOOP* PBOOP=&LOCALBOOP;
7fd59977 36
37void CATIND
38(TCollection_AsciiString& s,const Standard_Integer I,const TCollection_AsciiString& a,const TCollection_AsciiString& b) {s=s+a+TCollection_AsciiString(I)+b;}
39void CATSHA
40(TCollection_AsciiString& s,const TopoDS_Shape& S,const TopOpeBRepDS_DataStructure& BDS,const TCollection_AsciiString& a,const TCollection_AsciiString& b)
41{if (S.IsNull()) return;::CATIND(s,BDS.Shape(S),a,b);}
42void CATLOSHA
43(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)
44{
45 if (!L.Extent()) return;
46 s=s+a;for(TopTools_ListIteratorOfListOfShape i(L);i.More();i.Next())::CATSHA(s,i.Value(),BDS,aa,bb);s=s+b;
47}
48
49Standard_Integer TOPOCHKCOMMANDS(TestTopOpe_BOOP& P,Standard_Integer na,const char**a);
50Standard_Integer TOPOSETCOMMANDS(TestTopOpe_BOOP& P,Standard_Integer na,const char**a, Draw_Interpretor& di);
51Standard_Integer TOPOCOMMANDS(TestTopOpe_BOOP& PT,Standard_Integer na,const char**a, Draw_Interpretor& di);
52
53// ----------------------------------------------------------------------
54Standard_Integer TOPOC(Draw_Interpretor& interpretor,Standard_Integer na,const char** a)
55{
56 if (PBOOP == NULL) return 0;
57 Standard_Integer err=0, i;
58
59 if (!strncmp(a[0],kboo[BOOP_TOPX],4)) {
60 err = TOPOCOMMANDS((*PBOOP),na,a,interpretor);
61 return err;
62 }
63 else if (PBOOP->IsBooope(a[0])) {
64 PBOOP->Booope(a[0],(na >= 2) ? a[1] : NULL);
65 return 0;
66 }
67 else if (!strcmp(a[0],"toposet")) {
68 err = TOPOSETCOMMANDS((*PBOOP),na,a,interpretor);
69 return err;
70 }
71 else if (!strcmp(a[0],"tsp") ) {
72 TopAbs_State sta = TopAbs_UNKNOWN;
73 if (na >= 2) {
74 if (!strcmp(a[1],"IN")) sta = TopAbs_IN;
75 else if (!strcmp(a[1],"OUT")) sta = TopAbs_OUT;
76 else if (!strcmp(a[1],"ON")) sta = TopAbs_ON;
77
7da2a6ab 78 if (sta != TopAbs_UNKNOWN) {
7fd59977 79 if (na==2) { PBOOP->GetSplit(sta); } // tsp IN/ON/OUT
80 else if ( na > 2 ) {
81 TopAbs_ShapeEnum typ = TopAbs_SHAPE;
82 if (!strcmp(a[2],"e")) typ = TopAbs_EDGE;
83 else if (!strcmp(a[2],"f")) typ = TopAbs_FACE;
84 else if (!strcmp(a[2],"s")) typ = TopAbs_SOLID;
7da2a6ab 85 if (typ != TopAbs_SHAPE) {
7fd59977 86 if (na == 3) {
87 // tsp IN/ON/OUT e/f/s
88 PBOOP->GetSplit(typ,sta);
89 }
90 else if (na > 3) {
91 // tsp IN/ON/OUT e/f/s i1 i2 ...
91322f44 92 for(i=3;i<na;i++) PBOOP->GetSplit(typ,sta,Draw::Atoi(a[i]));
7fd59977 93 }
94 }
95 else {
96 // tsp IN/ON/OUT i1 i2 ...
91322f44 97 for(i=2;i<na;i++) PBOOP->GetSplit(sta,Draw::Atoi(a[i]));
7fd59977 98 }
99 }
7fd59977 100 }
101 else { // tsp i1 i2 ...
102 for (i = 1; i < na; i++) {
91322f44 103 if ( ISINTEGER(a[i]) ) PBOOP->GetSplit(Draw::Atoi(a[i]));
7fd59977 104 }
105 }
106 }
107 else {
108 PBOOP->GetSplit(TopAbs_IN);
109 PBOOP->GetSplit(TopAbs_ON);
110 PBOOP->GetSplit(TopAbs_OUT);
111 } // tsp
112 } // arg0 = tsp
113
114 else if (!strcmp(a[0],"tme") ) {
115 TopAbs_State sta = TopAbs_UNKNOWN;
116 if (na >= 2) {
117 if (!strcmp(a[1],"IN")) sta = TopAbs_IN;
118 else if (!strcmp(a[1],"OUT")) sta = TopAbs_OUT;
119 else if (!strcmp(a[1],"ON")) sta = TopAbs_ON;
120
7da2a6ab 121 if (sta != TopAbs_UNKNOWN) {
7fd59977 122 if (na==2) { PBOOP->GetMerged(sta); } // tme IN/ON/OUT
123 else if ( na > 2 ) {
124 TopAbs_ShapeEnum typ = TopAbs_SHAPE;
125 if (!strcmp(a[2],"e")) typ = TopAbs_EDGE;
126 else if (!strcmp(a[2],"f")) typ = TopAbs_FACE;
127 else if (!strcmp(a[2],"s")) typ = TopAbs_SOLID;
7da2a6ab 128 if (typ != TopAbs_SHAPE) {
7fd59977 129 if (na == 3) {
130 // tme IN/ON/OUT e/f/s
131 PBOOP->GetMerged(typ,sta);
132 }
133 else if (na > 3) {
134 // tme IN/ON/OUT e/f/s i1 i2 ...
91322f44 135 for(i=3;i<na;i++) PBOOP->GetMerged(typ,sta,Draw::Atoi(a[i]));
7fd59977 136 }
137 }
138 else {
139 // tme IN/ON/OUT i1 i2 ...
91322f44 140 for(i=2;i<na;i++) PBOOP->GetMerged(sta,Draw::Atoi(a[i]));
7fd59977 141 }
142 }
7fd59977 143 }
144 else { // tme i1 i2 ...
145 for (i = 1; i < na; i++) {
91322f44 146 if ( ISINTEGER(a[i]) ) PBOOP->GetMerged(Draw::Atoi(a[i]));
7fd59977 147 }
148 }
149 }
150 else {
151 PBOOP->GetMerged(TopAbs_IN);
152 PBOOP->GetMerged(TopAbs_ON);
153 PBOOP->GetMerged(TopAbs_OUT);
154 } // tme
155 } // arg0 = tme
156
157 else if (!strcmp(a[0],"csecanc") ) {
158 Standard_Integer ia;
159
160 Standard_Boolean outdraw = Standard_False,outclear = Standard_False,outAB = Standard_False;
161 for (ia=1; ia<na; ia++ ) {
162 if (!strcmp(a[ia],"-d")) outdraw = Standard_True;
163 else if (!strcmp(a[ia],"-c")) outclear = Standard_True;
164 else if (!strcmp(a[ia],"-AB")) outAB = Standard_True;
165 }
166
857ffd5e 167 Handle(TopOpeBRepBuild_HBuilder) HB = PBOOP->HBuilder();
168 Handle(TopOpeBRepDS_HDataStructure) HDS = HB->DataStructure();
7fd59977 169 const TopOpeBRepDS_DataStructure& BDS = HDS->DS();
170 const TopTools_ListOfShape& loe = HB->Section();
171
172 Standard_Boolean onedef = Standard_False;
173 Standard_Integer n = loe.Extent();
174 Handle(TColStd_HArray1OfBoolean) tabloe = new TColStd_HArray1OfBoolean(1,n,Standard_False);
175 for (ia=1; ia<na; ia++ ) {
176 if (!strcmp(a[ia],"-d")) continue;
177 if (!strcmp(a[ia],"-c")) continue;
178 if (!strcmp(a[ia],"-AB")) continue;
91322f44 179 Standard_Integer ie = Draw::Atoi(a[ia]);
7fd59977 180 if (ie>=1 && ie<=n) { onedef = Standard_True; tabloe->SetValue(ie,Standard_True); }
181 }
182 if (!onedef) tabloe->Init(Standard_True);
183
184 TopTools_ListIteratorOfListOfShape itloe(loe);
185 for (Standard_Integer ie=1;itloe.More();itloe.Next(),ie++) {
186 if (!tabloe->Value(ie)) continue;
187 const TopoDS_Shape& es = itloe.Value();
188 TopoDS_Shape F1,F2; Standard_Integer IC; TopTools_ListOfShape LF1,LF2,LE1,LE2;
189 Standard_Boolean eca = HB->EdgeCurveAncestors(es,F1,F2,IC);
190 Standard_Boolean esa = HB->EdgeSectionAncestors(es,LF1,LF2,LE1,LE2);
191 TCollection_AsciiString namie("se"); namie = namie + TCollection_AsciiString(ie);
192 DBRep::Set(namie.ToCString(),es);
193 if (eca) {
194 TCollection_AsciiString s;
6e6cd5d9 195
7fd59977 196 if (outdraw) {
197 if (outclear) s = s + "clear; ";
198 ::CATSHA(s,F1,BDS,"tsee f ","; ");
199 ::CATSHA(s,F2,BDS,"tsee f ","; ");
200 ::CATIND(s,IC,"tsee c ","; ");
201 s = s + "cdins " + namie;
202 interpretor<<s.ToCString()<<"\n";
203 if (outAB) {
204 s = " ";
205 ::CATSHA(s,F1,BDS,"mksol A f_","; ");
206 ::CATSHA(s,F2,BDS,"mksol B f_","; ");
207 s = s + "topopeload A B; ";
208 s = s + "# " + namie;
209 interpretor<<s.ToCString()<<"\n";
210 }
211 }
212 else {
213 s = s + "section edge " + TCollection_AsciiString(ie) + " ";
214 ::CATSHA(s,F1,BDS," f1 : ","");
215 ::CATSHA(s,F2,BDS," f2 : ","");
216 ::CATIND(s,IC," c : ","");
217 interpretor<<s.ToCString()<<"\n";
218 }
219 }
220
221 if (esa) {
222 TCollection_AsciiString s;
223#ifdef DEB
224 TopTools_ListIteratorOfListOfShape ils;
225#endif
226 if (outdraw) {
227 if (outclear) s = s + "clear; ";
228 ::CATLOSHA(s,LF1,BDS,"tsee f ",""," ","; ");
229 ::CATLOSHA(s,LF2,BDS,"tsee f ",""," ","; ");
230 ::CATLOSHA(s,LE1,BDS,"tsee e ",""," ","; ");
231 ::CATLOSHA(s,LE2,BDS,"tsee e ",""," ","; ");
232 s = s + "cdins " + "-p 0.5 " + namie;
233 interpretor<<s.ToCString()<<"\n";
234 if (outAB) {
235 s = " ";
236 ::CATLOSHA(s,LF1,BDS,"mksol A ","f_"," ","; ");
237 ::CATLOSHA(s,LF2,BDS,"mksol B ","f_"," ","; ");
238 s = s + "topopeload A B;";
239 s = s + " # " + namie;
240 interpretor<<s.ToCString()<<"\n";
241 }
242 }
243 else {
244 s = s + "section edge " + TCollection_AsciiString(ie) + " ";
245 ::CATLOSHA(s,LF1,BDS," f1 : ",""," ","");
246 ::CATLOSHA(s,LF2,BDS," f2 : ",""," ","");
247 ::CATLOSHA(s,LE1,BDS," e1 : ",""," ","");
248 ::CATLOSHA(s,LE2,BDS," e2 : ",""," ","");
249 interpretor<<s.ToCString()<<"\n";
250 }
251 }
252 if ( !eca && !esa ) {
253 interpretor<<"edge "<<ie<<" has no ancestors"<<"\n";
254 }
255 }
256 }
257 else if (!strcmp(a[0],"parvi") ) {
258 TopoDS_Shape S = DBRep::Get(a[1]);
259 TopExp_Explorer ee(S,TopAbs_EDGE);
260 for(Standard_Integer ie=1; ee.More(); ee.Next(),ie++) {
261 TopoDS_Edge e = TopoDS::Edge(ee.Current());
262 e.Orientation(TopAbs_FORWARD);
263 TCollection_AsciiString enam("VIe");enam=enam+TCollection_AsciiString(ie);
264 TopExp_Explorer ev(e,TopAbs_VERTEX);
265 for(Standard_Integer iv=1; ev.More(); ev.Next(),iv++) {
266 const TopoDS_Vertex v = TopoDS::Vertex(ev.Current());
267 if (v.Orientation()!=TopAbs_INTERNAL) continue;
268 TCollection_AsciiString vnam;vnam=enam+"i"+TCollection_AsciiString(iv);
269 DBRep::Set(enam.ToCString(),e);
270 DBRep::Set(vnam.ToCString(),v);
271 interpretor<<"din "<<enam.ToCString()<<" "<<vnam.ToCString();
272 interpretor<<" ;#par("<<vnam.ToCString()<<"/"<<enam.ToCString()<<") ";
273 //cout.flush();
274 interpretor<<"\n";
275 Standard_Real p = BRep_Tool::Parameter(v,e);
276 interpretor<<p<<"\n";
277 }
278 }
279 }
280 else if (!strcmp(a[0],"parvi2d") ) {
281 TopoDS_Shape S = DBRep::Get(a[1]);
282 TopExp_Explorer ef(S,TopAbs_FACE);
283 for(Standard_Integer ifa=1; ef.More(); ef.Next(),ifa++) {
284 TopoDS_Face f = TopoDS::Face(ef.Current());
285 f.Orientation(TopAbs_FORWARD);
286 TCollection_AsciiString fnam("VIf");fnam=fnam+TCollection_AsciiString(ifa);
287 DBRep::Set(fnam.ToCString(),f);
288 TopExp_Explorer ee(f,TopAbs_EDGE);
289 for(Standard_Integer ie=1; ee.More(); ee.Next(),ie++) {
290 TopoDS_Edge e = TopoDS::Edge(ee.Current());
291 e.Orientation(TopAbs_FORWARD);
292 TCollection_AsciiString enam;enam=fnam+"e"+TCollection_AsciiString(ie);
293 TopExp_Explorer ev(e,TopAbs_VERTEX);
294 for(Standard_Integer iv=1; ev.More(); ev.Next(),iv++) {
295 const TopoDS_Vertex v = TopoDS::Vertex(ev.Current());
296 if (v.Orientation()!=TopAbs_INTERNAL) continue;
297 TCollection_AsciiString vnam;vnam=enam+"vi"+TCollection_AsciiString(iv);
298 DBRep::Set(enam.ToCString(),e);
299 DBRep::Set(vnam.ToCString(),v);
300 interpretor<<"din "<<fnam.ToCString()<<" "<<enam.ToCString()<<" "<<vnam.ToCString();
301 interpretor<<" ;#par("<<vnam.ToCString()<<"/"<<enam.ToCString()<<","<<fnam.ToCString()<<") ";
302 //cout.flush();
303 interpretor<<"\n";
304 Standard_Real p=BRep_Tool::Parameter(v,e,f);
305 interpretor<<p<<"\n";
306 }
307 }
308 }
309 }
310 return 0 ;
311} // TOPO
312
313// ----------------------------------------------------------------------
498ce76b 314#ifdef DEB
7fd59977 315Standard_Integer BOOPCHK(Draw_Interpretor& ,Standard_Integer na,const char** a)
316{
317 if (!strcmp(a[0],"tchk")) {
7fd59977 318// Standard_IMPORT extern Standard_Integer TopOpeBRepTool_BOOOPE_CHECK_DEB;
319 Standard_IMPORT Standard_Integer TopOpeBRepTool_BOOOPE_CHECK_DEB;
91322f44 320 if ( na >= 2 ) TopOpeBRepTool_BOOOPE_CHECK_DEB = (Draw::Atoi(a[1])) ? 1 : 0;
7fd59977 321 return 0;
322 }
323 return 0;
324}
498ce76b 325#else
326Standard_Integer BOOPCHK(Draw_Interpretor& ,Standard_Integer,const char**) {return 0;}
327#endif
7fd59977 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"))
91322f44 340 PT.SetTol(TopOpeBRepDS_POINT,Draw::Atoi(a[2]),Draw::Atof(a[3]));
7fd59977 341 else if(!strcasecmp(a[1],"c"))// c ou C
91322f44 342 PT.SetTol(TopOpeBRepDS_CURVE,Draw::Atoi(a[2]),Draw::Atof(a[3]));
7fd59977 343 else if(!strcasecmp(a[1],"s"))
91322f44 344 PT.SetTol(TopOpeBRepDS_SURFACE,Draw::Atoi(a[2]),Draw::Atof(a[3]));
7fd59977 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"))
91322f44 350 PT.SetTol(Draw::Atoi(a[2]),Draw::Atof(a[3]));
7fd59977 351 break;
352 case 6:
353 if(!strcasecmp(a[1],"p"))
91322f44 354 PT.SetPnt(Draw::Atoi(a[2]),Draw::Atof(a[3]),Draw::Atof(a[4]),Draw::Atof(a[5]));
7fd59977 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) {
91322f44 426 VT.SetTolx(Draw::Atof(a[ia]),Draw::Atof(a[ia + 1]));
7fd59977 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 {
91322f44 436 VT.SetTolx(Draw::Atof(a[ia]),Draw::Atof(a[ia]));
7fd59977 437 suppressarg(na,a,ia);
438 }
439 }
440 }
441 else if (!strcmp(thea,"-ti")) {
442 suppressarg(na,a,ia);
443 if (ia + 1 < na) {
91322f44 444 VT.SetToli(Draw::Atof(a[ia]),Draw::Atof(a[ia + 1]));
7fd59977 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 {
91322f44 454 VT.SetToli(Draw::Atof(a[ia]),Draw::Atof(a[ia]));
7fd59977 455 suppressarg(na,a,ia);
456 }
457 }
458 }
459 else if (!strcmp(thea,"-c")) {
460 suppressarg(na,a,ia);
461 if (ia < na) {
91322f44 462 VT.SetClear((Standard_Boolean)Draw::Atoi(a[ia]));
7fd59977 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) {
91322f44 478 VT.SetMode(Draw::Atoi(a[ia]));
7fd59977 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) {
91322f44 486 VT.SetVerbose(Draw::Atoi(a[ia]));
7fd59977 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