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