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