Integration of OCCT 6.5.0 from SVN
[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;
197#ifdef DEB
198 Standard_Integer i1 =
199#endif
200 BDS.Shape(F1);
201#ifdef DEB
202 Standard_Integer i2 =
203#endif
204 BDS.Shape(F2);
205 if (outdraw) {
206 if (outclear) s = s + "clear; ";
207 ::CATSHA(s,F1,BDS,"tsee f ","; ");
208 ::CATSHA(s,F2,BDS,"tsee f ","; ");
209 ::CATIND(s,IC,"tsee c ","; ");
210 s = s + "cdins " + namie;
211 interpretor<<s.ToCString()<<"\n";
212 if (outAB) {
213 s = " ";
214 ::CATSHA(s,F1,BDS,"mksol A f_","; ");
215 ::CATSHA(s,F2,BDS,"mksol B f_","; ");
216 s = s + "topopeload A B; ";
217 s = s + "# " + namie;
218 interpretor<<s.ToCString()<<"\n";
219 }
220 }
221 else {
222 s = s + "section edge " + TCollection_AsciiString(ie) + " ";
223 ::CATSHA(s,F1,BDS," f1 : ","");
224 ::CATSHA(s,F2,BDS," f2 : ","");
225 ::CATIND(s,IC," c : ","");
226 interpretor<<s.ToCString()<<"\n";
227 }
228 }
229
230 if (esa) {
231 TCollection_AsciiString s;
232#ifdef DEB
233 TopTools_ListIteratorOfListOfShape ils;
234#endif
235 if (outdraw) {
236 if (outclear) s = s + "clear; ";
237 ::CATLOSHA(s,LF1,BDS,"tsee f ",""," ","; ");
238 ::CATLOSHA(s,LF2,BDS,"tsee f ",""," ","; ");
239 ::CATLOSHA(s,LE1,BDS,"tsee e ",""," ","; ");
240 ::CATLOSHA(s,LE2,BDS,"tsee e ",""," ","; ");
241 s = s + "cdins " + "-p 0.5 " + namie;
242 interpretor<<s.ToCString()<<"\n";
243 if (outAB) {
244 s = " ";
245 ::CATLOSHA(s,LF1,BDS,"mksol A ","f_"," ","; ");
246 ::CATLOSHA(s,LF2,BDS,"mksol B ","f_"," ","; ");
247 s = s + "topopeload A B;";
248 s = s + " # " + namie;
249 interpretor<<s.ToCString()<<"\n";
250 }
251 }
252 else {
253 s = s + "section edge " + TCollection_AsciiString(ie) + " ";
254 ::CATLOSHA(s,LF1,BDS," f1 : ",""," ","");
255 ::CATLOSHA(s,LF2,BDS," f2 : ",""," ","");
256 ::CATLOSHA(s,LE1,BDS," e1 : ",""," ","");
257 ::CATLOSHA(s,LE2,BDS," e2 : ",""," ","");
258 interpretor<<s.ToCString()<<"\n";
259 }
260 }
261 if ( !eca && !esa ) {
262 interpretor<<"edge "<<ie<<" has no ancestors"<<"\n";
263 }
264 }
265 }
266 else if (!strcmp(a[0],"parvi") ) {
267 TopoDS_Shape S = DBRep::Get(a[1]);
268 TopExp_Explorer ee(S,TopAbs_EDGE);
269 for(Standard_Integer ie=1; ee.More(); ee.Next(),ie++) {
270 TopoDS_Edge e = TopoDS::Edge(ee.Current());
271 e.Orientation(TopAbs_FORWARD);
272 TCollection_AsciiString enam("VIe");enam=enam+TCollection_AsciiString(ie);
273 TopExp_Explorer ev(e,TopAbs_VERTEX);
274 for(Standard_Integer iv=1; ev.More(); ev.Next(),iv++) {
275 const TopoDS_Vertex v = TopoDS::Vertex(ev.Current());
276 if (v.Orientation()!=TopAbs_INTERNAL) continue;
277 TCollection_AsciiString vnam;vnam=enam+"i"+TCollection_AsciiString(iv);
278 DBRep::Set(enam.ToCString(),e);
279 DBRep::Set(vnam.ToCString(),v);
280 interpretor<<"din "<<enam.ToCString()<<" "<<vnam.ToCString();
281 interpretor<<" ;#par("<<vnam.ToCString()<<"/"<<enam.ToCString()<<") ";
282 //cout.flush();
283 interpretor<<"\n";
284 Standard_Real p = BRep_Tool::Parameter(v,e);
285 interpretor<<p<<"\n";
286 }
287 }
288 }
289 else if (!strcmp(a[0],"parvi2d") ) {
290 TopoDS_Shape S = DBRep::Get(a[1]);
291 TopExp_Explorer ef(S,TopAbs_FACE);
292 for(Standard_Integer ifa=1; ef.More(); ef.Next(),ifa++) {
293 TopoDS_Face f = TopoDS::Face(ef.Current());
294 f.Orientation(TopAbs_FORWARD);
295 TCollection_AsciiString fnam("VIf");fnam=fnam+TCollection_AsciiString(ifa);
296 DBRep::Set(fnam.ToCString(),f);
297 TopExp_Explorer ee(f,TopAbs_EDGE);
298 for(Standard_Integer ie=1; ee.More(); ee.Next(),ie++) {
299 TopoDS_Edge e = TopoDS::Edge(ee.Current());
300 e.Orientation(TopAbs_FORWARD);
301 TCollection_AsciiString enam;enam=fnam+"e"+TCollection_AsciiString(ie);
302 TopExp_Explorer ev(e,TopAbs_VERTEX);
303 for(Standard_Integer iv=1; ev.More(); ev.Next(),iv++) {
304 const TopoDS_Vertex v = TopoDS::Vertex(ev.Current());
305 if (v.Orientation()!=TopAbs_INTERNAL) continue;
306 TCollection_AsciiString vnam;vnam=enam+"vi"+TCollection_AsciiString(iv);
307 DBRep::Set(enam.ToCString(),e);
308 DBRep::Set(vnam.ToCString(),v);
309 interpretor<<"din "<<fnam.ToCString()<<" "<<enam.ToCString()<<" "<<vnam.ToCString();
310 interpretor<<" ;#par("<<vnam.ToCString()<<"/"<<enam.ToCString()<<","<<fnam.ToCString()<<") ";
311 //cout.flush();
312 interpretor<<"\n";
313 Standard_Real p=BRep_Tool::Parameter(v,e,f);
314 interpretor<<p<<"\n";
315 }
316 }
317 }
318 }
319 return 0 ;
320} // TOPO
321
322// ----------------------------------------------------------------------
323Standard_Integer BOOPCHK(Draw_Interpretor& ,Standard_Integer na,const char** a)
324{
325 if (!strcmp(a[0],"tchk")) {
326#ifdef DEB
327// Standard_IMPORT extern Standard_Integer TopOpeBRepTool_BOOOPE_CHECK_DEB;
328 Standard_IMPORT Standard_Integer TopOpeBRepTool_BOOOPE_CHECK_DEB;
329 if ( na >= 2 ) TopOpeBRepTool_BOOOPE_CHECK_DEB = (atoi(a[1])) ? 1 : 0;
330#endif
331 return 0;
332 }
333 return 0;
334}
335
336// ----------------------------------------------------
337Standard_Integer TOPOSETCOMMANDS(TestTopOpe_BOOP& PT,Standard_Integer na,const char** a, Draw_Interpretor& di)
338{
339 switch(na) {
340 case 1:
341 di<<"toposet <kind> <index> <tol>"<<"\n";
342 di<<"toposet <kind = Point> <index> <x> <y> <z>"<<"\n";
343 di<<"kind = p | c | s | v | e | f | w "<<"\n";
344 return 1;
345 case 4:
346 if(!strcasecmp(a[1],"p"))
347 PT.SetTol(TopOpeBRepDS_POINT,atoi(a[2]),atof(a[3]));
348 else if(!strcasecmp(a[1],"c"))// c ou C
349 PT.SetTol(TopOpeBRepDS_CURVE,atoi(a[2]),atof(a[3]));
350 else if(!strcasecmp(a[1],"s"))
351 PT.SetTol(TopOpeBRepDS_SURFACE,atoi(a[2]),atof(a[3]));
352 else if(!strcasecmp(a[1],"sh") ||
353 !strcasecmp(a[1],"v") ||
354 !strcasecmp(a[1],"e") ||
355 !strcasecmp(a[1],"f") ||
356 !strcasecmp(a[1],"w"))
357 PT.SetTol(atoi(a[2]),atof(a[3]));
358 break;
359 case 6:
360 if(!strcasecmp(a[1],"p"))
361 PT.SetPnt(atoi(a[2]),atof(a[3]),atof(a[4]),atof(a[5]));
362 else
363 return 1;
364 break;
365 default:
366 break;
367 } // switch na
368 return 0;
369}
370
371// -----------------------------------------------------
372void TOPOHELP(TestTopOpe_BOOP& PT, Draw_Interpretor& di)
373{
374 di<<"\n";
375 di<<"Help on topo command :"<<"\n";
376 di<<"----------------------"<<"\n";
377 for (Standard_Integer ic=0;ic<PT.Tnb();ic++) di<<PT.Tkeys(ic).ToCString()<<" : "<<PT.Thelp(ic).ToCString()<<"\n";
378 di<<"args :"<<"\n";
379 di<<"-2d -no2d : produce (or not) 2d curves in section"<<"\n";
380 di<<"-a : section curves approximated (default)"<<"\n";
381 di<<"-p : section curve discretisated"<<"\n";
382 di<<"-tx [default] | tol1 tol2 : set approximation tolerances"<<"\n";
383 di<<"-ti [shape] | tol1 tol2 : set intersection tolerances"<<"\n";
384 di<<"-c 0/[1] : clear view before displaying result"<<"\n";
385 di<<"-m [0]/1 : execute methods / explode methods"<<"\n";
386 di<<"-f [name] : retrieve shape/index <name> among input shapes (exploration index)"<<"\n";
387 di<<"-v [0]/1 : do not trace / trace methods name"<<"\n";
388 di<<"-d : dump all control variables"<<"\n";
389 di<<"-i : initialize control variables to default values"<<"\n";
390 di<<"-h : help"<<"\n";
391 di<<"----------------------"<<"\n";
392}
393
394// -------------------------------------------------------
395Standard_Integer VARSTOPOARGS(TestTopOpe_BOOP& PT,Standard_Integer& na,const char** a, Draw_Interpretor& di)
396{
397 VarsTopo& VT = PT.ChangeVarsTopo();
398
399 Standard_Boolean dump = Standard_False;
400 Standard_Boolean help = Standard_False;
401 Standard_Integer ia = 1;
402 while (ia < na) {
403 const char *thea = a[ia];
404 if (!strcmp(thea,"-f")) {
405 suppressarg(na,a,ia);
406 if (ia < na) {
407 PT.FindShape(a[ia]);
408 suppressarg(na,a,ia);
409 }
410 else {
411 PT.FindShape(0);
412 }
413 }
414 else if (!strcasecmp(thea,"-2d")) {
415 VT.SetC2D(Standard_True);
416 suppressarg(na,a,ia);
417 }
418 else if (!strcasecmp(thea,"-no2d")){
419 VT.SetC2D(Standard_False);
420 suppressarg(na,a,ia);
421 }
422 else if (!strcasecmp(thea,"-a")) {
423 VT.SetOCT(TopOpeBRepTool_APPROX);
424 suppressarg(na,a,ia);
425 }
426 else if (!strcasecmp(thea,"-p")) {
427 VT.SetOCT(TopOpeBRepTool_BSPLINE1);
428 suppressarg(na,a,ia);
429 }
430 else if (!strcmp(thea,"-tx")) {
431 suppressarg(na,a,ia);
432 if (ia + 1 < na) {
433 VT.SetTolx(atof(a[ia]),atof(a[ia + 1]));
434 suppressarg(na,a,ia);
435 suppressarg(na,a,ia);
436 }
437 else if (ia < na) {
438 if (!strcmp(a[ia],"default")) {
439 VT.SetTolxDef();
440 suppressarg(na,a,ia);
441 }
442 else {
443 VT.SetTolx(atof(a[ia]),atof(a[ia]));
444 suppressarg(na,a,ia);
445 }
446 }
447 }
448 else if (!strcmp(thea,"-ti")) {
449 suppressarg(na,a,ia);
450 if (ia + 1 < na) {
451 VT.SetToli(atof(a[ia]),atof(a[ia + 1]));
452 suppressarg(na,a,ia);
453 suppressarg(na,a,ia);
454 }
455 else if (ia < na) {
456 if (!strcmp(a[ia],"shape")) {
457 VT.SetToliDef();
458 suppressarg(na,a,ia);
459 }
460 else {
461 VT.SetToli(atof(a[ia]),atof(a[ia]));
462 suppressarg(na,a,ia);
463 }
464 }
465 }
466 else if (!strcmp(thea,"-c")) {
467 suppressarg(na,a,ia);
468 if (ia < na) {
469 VT.SetClear((Standard_Boolean)atoi(a[ia]));
470 suppressarg(na,a,ia);
471 }
472 else VT.SetClear(Standard_True);
473 }
474 else if (!strcasecmp(thea,"-d")) {
475 dump = Standard_True;
476 suppressarg(na,a,ia);
477 }
478 else if (!strcasecmp(thea,"-i")) {
479 VT.Init();
480 suppressarg(na,a,ia);
481 }
482 else if (!strcmp(thea,"-m")) {
483 suppressarg(na,a,ia);
484 if (ia < na) {
485 VT.SetMode(atoi(a[ia]));
486 suppressarg(na,a,ia);
487 }
488 else VT.SetMode(0);
489 }
490 else if (!strcmp(thea,"-v")) {
491 suppressarg(na,a,ia);
492 if (ia < na) {
493 VT.SetVerbose(atoi(a[ia]));
494 suppressarg(na,a,ia);
495 }
496 else VT.SetVerbose(0);
497 }
498 else if (!strcasecmp(thea,"-h")) {
499 help = Standard_True;
500 suppressarg(na,a,ia);
501 }
502 else {
503 ia++;
504 }
505 } // while (ia < na)
506 if (dump) VT.Dump(cout);
507 if (help) TOPOHELP(PT, di);
508 return 0;
509
510} // VARSTOPOARGS
511
512// ----------------------------------------------------
513Standard_Integer SETTOPOCOMMANDS(TestTopOpe_BOOP& PT)
514{
515 PT.Tinit();
516 PT.Tadd("-def",0 ,"[a b] : load shapes");
517 PT.Tadd("-iss",100,"[a b] : intersection");
518 PT.Tadd("-gap",110,"[a b] : gap filler");
519 PT.Tadd("-cds",115,"[a b] : complete DS");
520 PT.Tadd("-fil",120,"[a b] : filter");
521 PT.Tadd("-red",130,"[a b] : reducer");
522 PT.Tadd("-rug",140,"[a b] : remove unshared geometry");
523 PT.Tadd("-chk",150,"[a b] : check DS");
524 PT.Tadd("-bui",200,"[a b] : section building");
525 PT.Tadd("-all",290,"[a b] : all");
526 return 0;
527}
528
529// ----------------------------------------------------
530Standard_Integer SETTOPOPREP(TestTopOpe_BOOP& PT,Standard_Integer& na,const char** a)
531{
532 if (na < 2) return 0;
533 const char* thea = a[0];
534 PT.mytodoPREP = 999;
535 if (!strcasecmp(thea,"topo") && na == 3) {
536 PT.mylastPREP = -1;
537 return 0;
538 }
539 if (na == 4) {
540 PT.mylastPREP = -1;
541 }
542
543 Standard_Integer ia = 1;
544 while (ia < na) {
545 thea = a[ia];
546 Standard_Integer ik = PT.Tstep(thea);
547 if (ik != -1) {
548 PT.mytodoPREP = ik;
549 suppressarg(na,a,ia);
550 }
551 else {
552 ia++;
553 }
554 }
555 return 0;
556}
557
558// ----------------------------------------------------
559Standard_Integer TOPOCOMMANDS(TestTopOpe_BOOP& PT,Standard_Integer na,const char** a, Draw_Interpretor& di)
560{
561 Standard_Integer err = 0;
562 if (strncmp(a[0],"topo",4)) return 1;
563 if (na == 2 && !strcasecmp(a[1],"-h")) { TOPOHELP(PT, di); return 0; }
564 err = VARSTOPOARGS(PT,na,a, di); if (err) return err;
565 if (na == 1) return 0;
566 err = SETTOPOPREP(PT,na,a); if (err) return err;
567
568#ifdef DEB
569 Standard_Boolean tend = TopOpeBRepTool_GettraceEND();
570 TopOpeBRepTool_SettraceEND(PT.ChangeVarsTopo().GetVerbose());
571#endif
572
573 err = 0;
574 TopOpeBRep_DSFiller* PDSF = PT.myPDSF;
575 while (PT.mylastPREP <= PT.mytodoPREP) {
576 switch (PT.mylastPREP) {
577 case -1 : if (na >= 3) err = PT.LoadShapes(a[1],a[2]);break;
578 case 0 : err = PT.LoadnewDS(); PDSF = PT.myPDSF; break;
579 case 100 : err = PT.DSF_Insert_InsertIntersection(*PDSF); break;
580 case 110 : err = PT.DSF_Insert_Complete_GapFiller(*PDSF);break;
581 case 115 : err = PT.DSF_Insert_Complete_CompleteDS(*PDSF); break;
582 case 120 : err = PT.DSF_Insert_Complete_Filter(*PDSF); break;
583 case 130 : err = PT.DSF_Insert_Complete_Reducer(*PDSF); break;
584 case 140 : err = PT.DSF_Insert_Complete_RemoveUnsharedGeometry(*PDSF); break;
585 case 150 : err = PT.DSF_Insert_Complete_Checker(*PDSF); break;
586 case 160 : err = PT.LoadnewHB(); break;
587 case 200 : err = PT.Builder_Perform(); break;
588 case 290 : PT.mylastPREP = 1000; break;
589 default : PT.mylastPREP = 1000; break;
590 }
591 if (err) return err;
592 }
593
594#ifdef DEB
595 TopOpeBRepTool_SettraceEND(tend);
596#endif
597 return 0;
598}
599
600//=======================================================================
601//function : BOOPCommands
602//purpose :
603//=======================================================================
604void TestTopOpe::BOOPCommands(Draw_Interpretor& theCommands)
605{
606 SETTOPOCOMMANDS(*PBOOP);
607 theCommands.Add(kboo[BOOP_TOPX],"-h for help",__FILE__,TOPOC);
608 theCommands.Add(kboo[BOOP_SECC],"secc [r]",__FILE__,TOPOC);
609 theCommands.Add(kboo[BOOP_SECE],"sece [r]",__FILE__,TOPOC);
610 theCommands.Add(kboo[BOOP_SEC],"sec [r]",__FILE__,TOPOC);
611 theCommands.Add(kboo[BOOP_C12],"c12 [r]",__FILE__,TOPOC);
612 theCommands.Add(kboo[BOOP_C21],"c21 [r]",__FILE__,TOPOC);
613 theCommands.Add(kboo[BOOP_COM],"com [r]",__FILE__,TOPOC);
614 theCommands.Add(kboo[BOOP_FUS],"fus [r]",__FILE__,TOPOC);
615 theCommands.Add("toposet","",__FILE__,TOPOC);
616 theCommands.Add("tsp","tsp [state] iS1 : get split parts",__FILE__,TOPOC);
617 theCommands.Add("tme","tme [state] iS1 : get merged parts",__FILE__,TOPOC);
618 theCommands.Add("csecanc","section edge ancestors. use : puts [csecanc]",__FILE__,TOPOC);
619 theCommands.Add("parvi","parvi <shape> : get parameter of internal vertices",__FILE__,TOPOC);
620 theCommands.Add("parvi2d","parvi <shape> : get parameter of internal vertices",__FILE__,TOPOC);
621 theCommands.Add("tchk","tchk 1/0 : check SameParameter edges or not in BRepBuilderAPI",__FILE__,BOOPCHK);
622}
623
624#if 0
625 if (!strcasecmp(thea,"-def")) { PT.mytodoPREP = 0; suppressarg(na,a,ia); }
626 else if (!strcasecmp(thea,"-iss")) { PT.mytodoPREP = 100; suppressarg(na,a,ia); }
627 else if (!strcasecmp(thea,"-gap")) { PT.mytodoPREP = 110; suppressarg(na,a,ia); }
628 else if (!strcasecmp(thea,"-cds")) { PT.mytodoPREP = 115; suppressarg(na,a,ia); }
629 else if (!strcasecmp(thea,"-fil")) { PT.mytodoPREP = 120; suppressarg(na,a,ia); }
630 else if (!strcasecmp(thea,"-red")) { PT.mytodoPREP = 130; suppressarg(na,a,ia); }
631 else if (!strcasecmp(thea,"-rug")) { PT.mytodoPREP = 140; suppressarg(na,a,ia); }
632 else if (!strcasecmp(thea,"-chk")) { PT.mytodoPREP = 150; suppressarg(na,a,ia); }
633 else if (!strcasecmp(thea,"-bui")) { PT.mytodoPREP = 200; suppressarg(na,a,ia); }
634 else if (!strcasecmp(thea,"-all")) { PT.mytodoPREP = 290; suppressarg(na,a,ia); }
635#endif