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