Adding UnitsAPI in resources for FoundationClasses.tcl of OS package.
[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// ----------------------------------------------------------------------
325Standard_Integer BOOPCHK(Draw_Interpretor& ,Standard_Integer na,const char** a)
326{
327 if (!strcmp(a[0],"tchk")) {
328#ifdef DEB
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#endif
333 return 0;
334 }
335 return 0;
336}
337
338// ----------------------------------------------------
339Standard_Integer TOPOSETCOMMANDS(TestTopOpe_BOOP& PT,Standard_Integer na,const char** a, Draw_Interpretor& di)
340{
341 switch(na) {
342 case 1:
343 di<<"toposet <kind> <index> <tol>"<<"\n";
344 di<<"toposet <kind = Point> <index> <x> <y> <z>"<<"\n";
345 di<<"kind = p | c | s | v | e | f | w "<<"\n";
346 return 1;
347 case 4:
348 if(!strcasecmp(a[1],"p"))
91322f44 349 PT.SetTol(TopOpeBRepDS_POINT,Draw::Atoi(a[2]),Draw::Atof(a[3]));
7fd59977 350 else if(!strcasecmp(a[1],"c"))// c ou C
91322f44 351 PT.SetTol(TopOpeBRepDS_CURVE,Draw::Atoi(a[2]),Draw::Atof(a[3]));
7fd59977 352 else if(!strcasecmp(a[1],"s"))
91322f44 353 PT.SetTol(TopOpeBRepDS_SURFACE,Draw::Atoi(a[2]),Draw::Atof(a[3]));
7fd59977 354 else if(!strcasecmp(a[1],"sh") ||
355 !strcasecmp(a[1],"v") ||
356 !strcasecmp(a[1],"e") ||
357 !strcasecmp(a[1],"f") ||
358 !strcasecmp(a[1],"w"))
91322f44 359 PT.SetTol(Draw::Atoi(a[2]),Draw::Atof(a[3]));
7fd59977 360 break;
361 case 6:
362 if(!strcasecmp(a[1],"p"))
91322f44 363 PT.SetPnt(Draw::Atoi(a[2]),Draw::Atof(a[3]),Draw::Atof(a[4]),Draw::Atof(a[5]));
7fd59977 364 else
365 return 1;
366 break;
367 default:
368 break;
369 } // switch na
370 return 0;
371}
372
373// -----------------------------------------------------
374void TOPOHELP(TestTopOpe_BOOP& PT, Draw_Interpretor& di)
375{
376 di<<"\n";
377 di<<"Help on topo command :"<<"\n";
378 di<<"----------------------"<<"\n";
379 for (Standard_Integer ic=0;ic<PT.Tnb();ic++) di<<PT.Tkeys(ic).ToCString()<<" : "<<PT.Thelp(ic).ToCString()<<"\n";
380 di<<"args :"<<"\n";
381 di<<"-2d -no2d : produce (or not) 2d curves in section"<<"\n";
382 di<<"-a : section curves approximated (default)"<<"\n";
383 di<<"-p : section curve discretisated"<<"\n";
384 di<<"-tx [default] | tol1 tol2 : set approximation tolerances"<<"\n";
385 di<<"-ti [shape] | tol1 tol2 : set intersection tolerances"<<"\n";
386 di<<"-c 0/[1] : clear view before displaying result"<<"\n";
387 di<<"-m [0]/1 : execute methods / explode methods"<<"\n";
388 di<<"-f [name] : retrieve shape/index <name> among input shapes (exploration index)"<<"\n";
389 di<<"-v [0]/1 : do not trace / trace methods name"<<"\n";
390 di<<"-d : dump all control variables"<<"\n";
391 di<<"-i : initialize control variables to default values"<<"\n";
392 di<<"-h : help"<<"\n";
393 di<<"----------------------"<<"\n";
394}
395
396// -------------------------------------------------------
397Standard_Integer VARSTOPOARGS(TestTopOpe_BOOP& PT,Standard_Integer& na,const char** a, Draw_Interpretor& di)
398{
399 VarsTopo& VT = PT.ChangeVarsTopo();
400
401 Standard_Boolean dump = Standard_False;
402 Standard_Boolean help = Standard_False;
403 Standard_Integer ia = 1;
404 while (ia < na) {
405 const char *thea = a[ia];
406 if (!strcmp(thea,"-f")) {
407 suppressarg(na,a,ia);
408 if (ia < na) {
409 PT.FindShape(a[ia]);
410 suppressarg(na,a,ia);
411 }
412 else {
413 PT.FindShape(0);
414 }
415 }
416 else if (!strcasecmp(thea,"-2d")) {
417 VT.SetC2D(Standard_True);
418 suppressarg(na,a,ia);
419 }
420 else if (!strcasecmp(thea,"-no2d")){
421 VT.SetC2D(Standard_False);
422 suppressarg(na,a,ia);
423 }
424 else if (!strcasecmp(thea,"-a")) {
425 VT.SetOCT(TopOpeBRepTool_APPROX);
426 suppressarg(na,a,ia);
427 }
428 else if (!strcasecmp(thea,"-p")) {
429 VT.SetOCT(TopOpeBRepTool_BSPLINE1);
430 suppressarg(na,a,ia);
431 }
432 else if (!strcmp(thea,"-tx")) {
433 suppressarg(na,a,ia);
434 if (ia + 1 < na) {
91322f44 435 VT.SetTolx(Draw::Atof(a[ia]),Draw::Atof(a[ia + 1]));
7fd59977 436 suppressarg(na,a,ia);
437 suppressarg(na,a,ia);
438 }
439 else if (ia < na) {
440 if (!strcmp(a[ia],"default")) {
441 VT.SetTolxDef();
442 suppressarg(na,a,ia);
443 }
444 else {
91322f44 445 VT.SetTolx(Draw::Atof(a[ia]),Draw::Atof(a[ia]));
7fd59977 446 suppressarg(na,a,ia);
447 }
448 }
449 }
450 else if (!strcmp(thea,"-ti")) {
451 suppressarg(na,a,ia);
452 if (ia + 1 < na) {
91322f44 453 VT.SetToli(Draw::Atof(a[ia]),Draw::Atof(a[ia + 1]));
7fd59977 454 suppressarg(na,a,ia);
455 suppressarg(na,a,ia);
456 }
457 else if (ia < na) {
458 if (!strcmp(a[ia],"shape")) {
459 VT.SetToliDef();
460 suppressarg(na,a,ia);
461 }
462 else {
91322f44 463 VT.SetToli(Draw::Atof(a[ia]),Draw::Atof(a[ia]));
7fd59977 464 suppressarg(na,a,ia);
465 }
466 }
467 }
468 else if (!strcmp(thea,"-c")) {
469 suppressarg(na,a,ia);
470 if (ia < na) {
91322f44 471 VT.SetClear((Standard_Boolean)Draw::Atoi(a[ia]));
7fd59977 472 suppressarg(na,a,ia);
473 }
474 else VT.SetClear(Standard_True);
475 }
476 else if (!strcasecmp(thea,"-d")) {
477 dump = Standard_True;
478 suppressarg(na,a,ia);
479 }
480 else if (!strcasecmp(thea,"-i")) {
481 VT.Init();
482 suppressarg(na,a,ia);
483 }
484 else if (!strcmp(thea,"-m")) {
485 suppressarg(na,a,ia);
486 if (ia < na) {
91322f44 487 VT.SetMode(Draw::Atoi(a[ia]));
7fd59977 488 suppressarg(na,a,ia);
489 }
490 else VT.SetMode(0);
491 }
492 else if (!strcmp(thea,"-v")) {
493 suppressarg(na,a,ia);
494 if (ia < na) {
91322f44 495 VT.SetVerbose(Draw::Atoi(a[ia]));
7fd59977 496 suppressarg(na,a,ia);
497 }
498 else VT.SetVerbose(0);
499 }
500 else if (!strcasecmp(thea,"-h")) {
501 help = Standard_True;
502 suppressarg(na,a,ia);
503 }
504 else {
505 ia++;
506 }
507 } // while (ia < na)
508 if (dump) VT.Dump(cout);
509 if (help) TOPOHELP(PT, di);
510 return 0;
511
512} // VARSTOPOARGS
513
514// ----------------------------------------------------
515Standard_Integer SETTOPOCOMMANDS(TestTopOpe_BOOP& PT)
516{
517 PT.Tinit();
518 PT.Tadd("-def",0 ,"[a b] : load shapes");
519 PT.Tadd("-iss",100,"[a b] : intersection");
520 PT.Tadd("-gap",110,"[a b] : gap filler");
521 PT.Tadd("-cds",115,"[a b] : complete DS");
522 PT.Tadd("-fil",120,"[a b] : filter");
523 PT.Tadd("-red",130,"[a b] : reducer");
524 PT.Tadd("-rug",140,"[a b] : remove unshared geometry");
525 PT.Tadd("-chk",150,"[a b] : check DS");
526 PT.Tadd("-bui",200,"[a b] : section building");
527 PT.Tadd("-all",290,"[a b] : all");
528 return 0;
529}
530
531// ----------------------------------------------------
532Standard_Integer SETTOPOPREP(TestTopOpe_BOOP& PT,Standard_Integer& na,const char** a)
533{
534 if (na < 2) return 0;
535 const char* thea = a[0];
536 PT.mytodoPREP = 999;
537 if (!strcasecmp(thea,"topo") && na == 3) {
538 PT.mylastPREP = -1;
539 return 0;
540 }
541 if (na == 4) {
542 PT.mylastPREP = -1;
543 }
544
545 Standard_Integer ia = 1;
546 while (ia < na) {
547 thea = a[ia];
548 Standard_Integer ik = PT.Tstep(thea);
549 if (ik != -1) {
550 PT.mytodoPREP = ik;
551 suppressarg(na,a,ia);
552 }
553 else {
554 ia++;
555 }
556 }
557 return 0;
558}
559
560// ----------------------------------------------------
561Standard_Integer TOPOCOMMANDS(TestTopOpe_BOOP& PT,Standard_Integer na,const char** a, Draw_Interpretor& di)
562{
563 Standard_Integer err = 0;
564 if (strncmp(a[0],"topo",4)) return 1;
565 if (na == 2 && !strcasecmp(a[1],"-h")) { TOPOHELP(PT, di); return 0; }
566 err = VARSTOPOARGS(PT,na,a, di); if (err) return err;
567 if (na == 1) return 0;
568 err = SETTOPOPREP(PT,na,a); if (err) return err;
569
570#ifdef DEB
571 Standard_Boolean tend = TopOpeBRepTool_GettraceEND();
572 TopOpeBRepTool_SettraceEND(PT.ChangeVarsTopo().GetVerbose());
573#endif
574
575 err = 0;
576 TopOpeBRep_DSFiller* PDSF = PT.myPDSF;
577 while (PT.mylastPREP <= PT.mytodoPREP) {
578 switch (PT.mylastPREP) {
579 case -1 : if (na >= 3) err = PT.LoadShapes(a[1],a[2]);break;
580 case 0 : err = PT.LoadnewDS(); PDSF = PT.myPDSF; break;
581 case 100 : err = PT.DSF_Insert_InsertIntersection(*PDSF); break;
582 case 110 : err = PT.DSF_Insert_Complete_GapFiller(*PDSF);break;
583 case 115 : err = PT.DSF_Insert_Complete_CompleteDS(*PDSF); break;
584 case 120 : err = PT.DSF_Insert_Complete_Filter(*PDSF); break;
585 case 130 : err = PT.DSF_Insert_Complete_Reducer(*PDSF); break;
586 case 140 : err = PT.DSF_Insert_Complete_RemoveUnsharedGeometry(*PDSF); break;
587 case 150 : err = PT.DSF_Insert_Complete_Checker(*PDSF); break;
588 case 160 : err = PT.LoadnewHB(); break;
589 case 200 : err = PT.Builder_Perform(); break;
590 case 290 : PT.mylastPREP = 1000; break;
591 default : PT.mylastPREP = 1000; break;
592 }
593 if (err) return err;
594 }
595
596#ifdef DEB
597 TopOpeBRepTool_SettraceEND(tend);
598#endif
599 return 0;
600}
601
602//=======================================================================
603//function : BOOPCommands
604//purpose :
605//=======================================================================
606void TestTopOpe::BOOPCommands(Draw_Interpretor& theCommands)
607{
608 SETTOPOCOMMANDS(*PBOOP);
609 theCommands.Add(kboo[BOOP_TOPX],"-h for help",__FILE__,TOPOC);
610 theCommands.Add(kboo[BOOP_SECC],"secc [r]",__FILE__,TOPOC);
611 theCommands.Add(kboo[BOOP_SECE],"sece [r]",__FILE__,TOPOC);
612 theCommands.Add(kboo[BOOP_SEC],"sec [r]",__FILE__,TOPOC);
613 theCommands.Add(kboo[BOOP_C12],"c12 [r]",__FILE__,TOPOC);
614 theCommands.Add(kboo[BOOP_C21],"c21 [r]",__FILE__,TOPOC);
615 theCommands.Add(kboo[BOOP_COM],"com [r]",__FILE__,TOPOC);
616 theCommands.Add(kboo[BOOP_FUS],"fus [r]",__FILE__,TOPOC);
617 theCommands.Add("toposet","",__FILE__,TOPOC);
618 theCommands.Add("tsp","tsp [state] iS1 : get split parts",__FILE__,TOPOC);
619 theCommands.Add("tme","tme [state] iS1 : get merged parts",__FILE__,TOPOC);
620 theCommands.Add("csecanc","section edge ancestors. use : puts [csecanc]",__FILE__,TOPOC);
621 theCommands.Add("parvi","parvi <shape> : get parameter of internal vertices",__FILE__,TOPOC);
622 theCommands.Add("parvi2d","parvi <shape> : get parameter of internal vertices",__FILE__,TOPOC);
623 theCommands.Add("tchk","tchk 1/0 : check SameParameter edges or not in BRepBuilderAPI",__FILE__,BOOPCHK);
624}
625
626#if 0
627 if (!strcasecmp(thea,"-def")) { PT.mytodoPREP = 0; suppressarg(na,a,ia); }
628 else if (!strcasecmp(thea,"-iss")) { PT.mytodoPREP = 100; suppressarg(na,a,ia); }
629 else if (!strcasecmp(thea,"-gap")) { PT.mytodoPREP = 110; suppressarg(na,a,ia); }
630 else if (!strcasecmp(thea,"-cds")) { PT.mytodoPREP = 115; suppressarg(na,a,ia); }
631 else if (!strcasecmp(thea,"-fil")) { PT.mytodoPREP = 120; suppressarg(na,a,ia); }
632 else if (!strcasecmp(thea,"-red")) { PT.mytodoPREP = 130; suppressarg(na,a,ia); }
633 else if (!strcasecmp(thea,"-rug")) { PT.mytodoPREP = 140; suppressarg(na,a,ia); }
634 else if (!strcasecmp(thea,"-chk")) { PT.mytodoPREP = 150; suppressarg(na,a,ia); }
635 else if (!strcasecmp(thea,"-bui")) { PT.mytodoPREP = 200; suppressarg(na,a,ia); }
636 else if (!strcasecmp(thea,"-all")) { PT.mytodoPREP = 290; suppressarg(na,a,ia); }
637#endif