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