Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1994-06-20 |
2 | // Created by: Modeling | |
3 | // Copyright (c) 1994-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 | ||
26 | #include <string.h> | |
27 | #include <BRepTest.hxx> | |
28 | #include <TColgp_Array1OfPnt2d.hxx> | |
29 | #include <DBRep.hxx> | |
30 | #include <Draw_Interpretor.hxx> | |
31 | #include <Draw_Appli.hxx> | |
32 | #include <BRepFilletAPI_MakeFillet.hxx> | |
33 | #include <BRepAlgo_BooleanOperation.hxx> | |
34 | #include <BRepAlgo_Fuse.hxx> | |
35 | #include <BRepAlgo_Cut.hxx> | |
36 | #include <BiTgte_Blend.hxx> | |
37 | #include <TopOpeBRepBuild_HBuilder.hxx> | |
38 | #include <TopTools_ListIteratorOfListOfShape.hxx> | |
39 | #include <TopAbs_ShapeEnum.hxx> | |
40 | #include <TopoDS_Shape.hxx> | |
41 | #include <TopoDS_Compound.hxx> | |
42 | #include <TopoDS_Edge.hxx> | |
43 | #include <TopoDS_Vertex.hxx> | |
44 | #include <TopoDS.hxx> | |
45 | #include <TopExp.hxx> | |
46 | #include <TopExp_Explorer.hxx> | |
47 | ||
48 | #include <BOPTools_DSFiller.hxx> | |
49 | #include <BRepAlgoAPI_BooleanOperation.hxx> | |
50 | #include <BRepAlgoAPI_Fuse.hxx> | |
51 | #include <BRepAlgoAPI_Cut.hxx> | |
52 | #include <BRepAlgoAPI_Section.hxx> | |
53 | ||
54 | #include <FilletSurf_Builder.hxx> | |
55 | #include <ChFi3d_FilletShape.hxx> | |
56 | #include <Geom_TrimmedCurve.hxx> | |
57 | #include <TopTools_ListOfShape.hxx> | |
58 | #include <FilletSurf_StatusType.hxx> | |
59 | #include <FilletSurf_ErrorTypeStatus.hxx> | |
60 | #include <TopAbs.hxx> | |
61 | #include <DrawTrSurf.hxx> | |
62 | ||
63 | #ifdef WNT | |
64 | //#define strcasecmp strcmp Already defined | |
65 | #endif | |
66 | #ifdef HAVE_STRINGS_H | |
67 | # include <strings.h> | |
68 | #endif | |
69 | #include <stdio.h> | |
70 | //#endif | |
71 | ||
72 | ||
73 | static Standard_Real t3d = 1.e-4; | |
74 | static Standard_Real t2d = 1.e-5; | |
75 | static Standard_Real ta = 1.e-2; | |
76 | static Standard_Real fl = 1.e-3; | |
77 | static Standard_Real tapp_angle = 1.e-2; | |
78 | static GeomAbs_Shape blend_cont = GeomAbs_C1; | |
79 | ||
80 | static BRepFilletAPI_MakeFillet* Rakk = 0; | |
81 | static BRepFilletAPI_MakeFillet* Rake = 0; | |
82 | static char name[100]; | |
83 | ||
84 | ||
85 | static Standard_Integer contblend(Draw_Interpretor& di, Standard_Integer narg, const char** a) | |
86 | { | |
87 | if(narg ==1) { | |
88 | //cout<<"tolerance angular of approximation : "<< tapp_angle <<endl; | |
89 | //cout<<"internal continuity : "; | |
90 | di<<"tolerance angular of approximation : "<< tapp_angle <<"\n"; | |
91 | di<<"internal continuity : "; | |
92 | switch (blend_cont) { | |
93 | case GeomAbs_C0: | |
94 | //cout << ""<<endl; | |
95 | di << "C0"<<"\n"; | |
96 | break; | |
97 | case GeomAbs_C1: | |
98 | //cout << "C1"<<endl; | |
99 | di << "C1"<<"\n"; | |
100 | break; | |
101 | case GeomAbs_C2: | |
102 | //cout << "C2"<<endl; | |
103 | di << "C2"<<"\n"; | |
104 | break; | |
7fd59977 | 105 | default: |
106 | break; | |
7fd59977 | 107 | } |
108 | return 0; | |
109 | } | |
110 | else { | |
111 | if (narg >3) return 1; | |
91322f44 | 112 | if (narg == 3) { tapp_angle = Abs(Draw::Atof(a[2])); } |
7fd59977 | 113 | char c=a[1][1]; |
114 | switch (c) { | |
115 | case '0': | |
116 | blend_cont = GeomAbs_C0; | |
117 | break; | |
118 | case '2': | |
119 | blend_cont = GeomAbs_C2; | |
120 | break; | |
121 | default : | |
122 | blend_cont = GeomAbs_C1; | |
123 | } | |
124 | return 0; | |
125 | } | |
126 | } | |
127 | ||
128 | static void printtolblend(Draw_Interpretor& di) | |
129 | { | |
130 | //cout<<"tolerance ang : "<<ta<<endl; | |
131 | //cout<<"tolerance 3d : "<<t3d<<endl; | |
132 | //cout<<"tolerance 2d : "<<t2d<<endl; | |
133 | //cout<<"fleche : "<<fl<<endl; | |
134 | ||
135 | //cout<<"tolblend "<<ta<<" "<<t3d<<" "<<t2d<<" "<<fl<<endl; | |
136 | ||
137 | di<<"tolerance ang : "<<ta<<"\n"; | |
138 | di<<"tolerance 3d : "<<t3d<<"\n"; | |
139 | di<<"tolerance 2d : "<<t2d<<"\n"; | |
140 | di<<"fleche : "<<fl<<"\n"; | |
141 | ||
142 | di<<"tolblend "<<ta<<" "<<t3d<<" "<<t2d<<" "<<fl<<"\n"; | |
143 | } | |
144 | ||
145 | static Standard_Integer tolblend(Draw_Interpretor& di, Standard_Integer narg, const char** a) | |
146 | { | |
147 | if(narg == 1){ | |
148 | printtolblend(di); | |
149 | return 0; | |
150 | } | |
151 | else if(narg == 5){ | |
91322f44 | 152 | ta = Draw::Atof(a[1]); |
153 | t3d = Draw::Atof(a[2]); | |
154 | t2d = Draw::Atof(a[3]); | |
155 | fl = Draw::Atof(a[4]); | |
7fd59977 | 156 | return 0; |
157 | } | |
158 | return 1; | |
159 | } | |
160 | static Standard_Integer BLEND(Draw_Interpretor& di, Standard_Integer narg, const char** a) | |
161 | { | |
162 | if(Rakk != 0) {delete Rakk; Rakk = 0;} | |
163 | printtolblend(di); | |
164 | if (narg<5) return 1; | |
165 | TopoDS_Shape V = DBRep::Get(a[2]); | |
166 | if(V.IsNull()) return 1; | |
167 | ChFi3d_FilletShape FSh = ChFi3d_Rational; | |
168 | if (narg%2 == 0) { | |
169 | if (!strcasecmp(a[narg-1], "Q")) { | |
170 | FSh = ChFi3d_QuasiAngular; | |
171 | } | |
172 | else if (!strcasecmp(a[narg-1], "P")) { | |
173 | FSh = ChFi3d_Polynomial; | |
174 | } | |
175 | } | |
176 | Rakk = new BRepFilletAPI_MakeFillet(V,FSh); | |
177 | Rakk->SetParams(ta,t3d,t2d,t3d,t2d,fl); | |
178 | Rakk->SetContinuity(blend_cont, tapp_angle); | |
179 | Standard_Real Rad; | |
180 | TopoDS_Edge E; | |
181 | Standard_Integer nbedge = 0; | |
182 | for (Standard_Integer ii = 1; ii < (narg-1)/2; ii++){ | |
91322f44 | 183 | Rad = Draw::Atof(a[2*ii + 1]); |
7fd59977 | 184 | TopoDS_Shape aLocalEdge(DBRep::Get(a[(2*ii+2)],TopAbs_EDGE)); |
185 | E = TopoDS::Edge(aLocalEdge); | |
186 | // E = TopoDS::Edge(DBRep::Get(a[(2*ii+2)],TopAbs_EDGE)); | |
187 | if(!E.IsNull()){ | |
188 | Rakk->Add(Rad,E); | |
189 | nbedge++; | |
190 | } | |
191 | } | |
192 | if(!nbedge) return 1; | |
193 | Rakk->Build(); | |
194 | if(!Rakk->IsDone()) return 1; | |
195 | TopoDS_Shape res = Rakk->Shape(); | |
196 | DBRep::Set(a[1],res); | |
197 | return 0; | |
198 | } | |
199 | ||
200 | static void PrintHist(const TopoDS_Shape& S, | |
201 | TopTools_ListIteratorOfListOfShape& It, | |
202 | Standard_Integer& nbgen) | |
203 | { | |
204 | TopoDS_Compound C; | |
205 | BRep_Builder B; | |
206 | B.MakeCompound(C); | |
207 | B.Add(C,S); | |
208 | char localname[100]; | |
209 | if(nbgen<10){ | |
91322f44 | 210 | Sprintf(localname,"generated_00%d", nbgen++); |
7fd59977 | 211 | } |
212 | else if(nbgen<100){ | |
91322f44 | 213 | Sprintf(localname,"generated_0%d", nbgen++); |
7fd59977 | 214 | } |
215 | else { | |
91322f44 | 216 | Sprintf(localname,"generated_%d", nbgen++); |
7fd59977 | 217 | } |
218 | for(; It.More(); It.Next()){ | |
219 | B.Add(C,It.Value()); | |
220 | } | |
221 | DBRep::Set(localname,C); | |
222 | } | |
223 | ||
224 | static Standard_Integer CheckHist(Draw_Interpretor& di, | |
225 | Standard_Integer , | |
226 | const char** ) | |
227 | { | |
228 | if(Rakk == 0) { | |
0d969553 Y |
229 | //cout<<"No active Builder"<<endl; |
230 | di<<"No active Builder"<<"\n"; | |
7fd59977 | 231 | return 1; |
232 | } | |
233 | if(!Rakk->IsDone()) { | |
0d969553 Y |
234 | //cout<<"Active Builder Not Done"<<endl; |
235 | di<<"Active Builder Not Done"<<"\n"; | |
7fd59977 | 236 | return 1; |
237 | } | |
238 | Standard_Integer nbc = Rakk->NbContours(); | |
239 | Standard_Integer nbgen = 0; | |
240 | TopTools_ListIteratorOfListOfShape It; | |
241 | TopoDS_Shape curshape; | |
242 | for(Standard_Integer i = 1; i <= nbc; i++){ | |
243 | curshape = Rakk->FirstVertex(i); | |
244 | It.Initialize(Rakk->Generated(curshape)); | |
245 | PrintHist(curshape,It,nbgen); | |
246 | Standard_Integer nbe = Rakk->NbEdges(i); | |
247 | for(Standard_Integer j = 1; j <= nbe; j++){ | |
248 | curshape = Rakk->Edge(i,j); | |
249 | It.Initialize(Rakk->Generated(curshape)); | |
250 | PrintHist(curshape,It,nbgen); | |
251 | } | |
252 | curshape = Rakk->LastVertex(i); | |
253 | It.Initialize(Rakk->Generated(curshape)); | |
254 | PrintHist(curshape,It,nbgen); | |
255 | } | |
256 | //cout<<"foreach g [lsort [dir gen*]] { wclick; puts [dname $g]; donl $g; }"<<endl; | |
257 | di<<"foreach g [lsort [dir gen*]] { wclick; puts [dname $g]; donl $g; }"<<"\n"; | |
258 | return 0; | |
259 | } | |
260 | ||
261 | static Standard_Integer MKEVOL(Draw_Interpretor& di, | |
262 | Standard_Integer narg, | |
263 | const char** a) | |
264 | { | |
265 | if(Rake != 0) {delete Rake; Rake = 0;} | |
266 | printtolblend(di); | |
267 | if (narg < 3) return 1; | |
268 | TopoDS_Shape V = DBRep::Get(a[2]); | |
269 | Rake = new BRepFilletAPI_MakeFillet(V); | |
270 | Rake->SetParams(ta,t3d,t2d,t3d,t2d,fl); | |
271 | Rake->SetContinuity(blend_cont, tapp_angle); | |
272 | if (narg == 4) { | |
273 | ChFi3d_FilletShape FSh = ChFi3d_Rational; | |
274 | if (!strcasecmp(a[3], "Q")) { | |
275 | FSh = ChFi3d_QuasiAngular; | |
276 | } | |
277 | else if (!strcasecmp(a[3], "P")) { | |
278 | FSh = ChFi3d_Polynomial; | |
279 | } | |
280 | Rake->SetFilletShape(FSh); | |
281 | } | |
282 | strcpy(name, a[1]); | |
283 | return 0; | |
284 | } | |
285 | ||
286 | static Standard_Integer UPDATEVOL(Draw_Interpretor& di, | |
287 | Standard_Integer narg, | |
288 | const char** a) | |
289 | { | |
290 | if(Rake == 0){ | |
0d969553 Y |
291 | //cout << "MakeFillet not initialized"<<endl; |
292 | di << "MakeFillet not initialized"<<"\n"; | |
7fd59977 | 293 | return 1 ; |
294 | } | |
295 | if(narg%2 != 0 || narg < 4) return 1; | |
296 | TColgp_Array1OfPnt2d uandr(1,(narg/2)-1); | |
297 | Standard_Real Rad, Par; | |
298 | TopoDS_Shape aLocalEdge(DBRep::Get(a[1],TopAbs_EDGE)); | |
299 | TopoDS_Edge E = TopoDS::Edge(aLocalEdge); | |
300 | // TopoDS_Edge E = TopoDS::Edge(DBRep::Get(a[1],TopAbs_EDGE)); | |
301 | for (Standard_Integer ii = 1; ii <= (narg/2)-1; ii++){ | |
91322f44 | 302 | Par = Draw::Atof(a[2*ii]); |
303 | Rad = Draw::Atof(a[2*ii + 1]); | |
7fd59977 | 304 | uandr.ChangeValue(ii).SetCoord(Par,Rad); |
305 | } | |
306 | Rake->Add(uandr,E); | |
307 | return 0; | |
308 | } | |
309 | ||
310 | static Standard_Integer BUILDEVOL(Draw_Interpretor& di, | |
311 | Standard_Integer, | |
312 | const char**) | |
313 | { | |
314 | if(Rake == 0){ | |
0d969553 Y |
315 | //cout << "MakeFillet not initialized"<<endl; |
316 | di << "MakeFillet not initialized"<<"\n"; | |
7fd59977 | 317 | return 1 ; |
318 | } | |
319 | Rake->Build(); | |
320 | if(Rake->IsDone()){ | |
321 | TopoDS_Shape result = Rake->Shape(); | |
322 | DBRep::Set(name,result); | |
323 | if(Rake != 0) {delete Rake; Rake = 0;} | |
324 | return 0; | |
325 | } | |
326 | if(Rake != 0) {delete Rake; Rake = 0;} | |
327 | return 1; | |
328 | } | |
329 | ||
330 | ||
331 | ||
332 | ||
333 | //********************************************** | |
0d969553 | 334 | // command fuse and cut with fillets * |
7fd59977 | 335 | //********************************************** |
336 | ||
337 | Standard_Integer topoblend(Draw_Interpretor& di, Standard_Integer narg, const char** a) | |
338 | { | |
339 | printtolblend(di); | |
340 | if(narg != 5) return 1; | |
341 | Standard_Boolean fuse = !strcmp(a[0],"fubl"); | |
342 | TopoDS_Shape S1 = DBRep::Get(a[2]); | |
343 | TopoDS_Shape S2 = DBRep::Get(a[3]); | |
91322f44 | 344 | Standard_Real Rad = Draw::Atof(a[4]); |
7fd59977 | 345 | BRepAlgo_BooleanOperation* BC; |
346 | if(fuse){ | |
347 | BC = new BRepAlgo_Fuse(S1,S2); | |
348 | } | |
349 | else{ | |
350 | BC = new BRepAlgo_Cut(S1,S2); | |
351 | } | |
352 | TopoDS_Shape ShapeCut = BC->Shape(); | |
353 | ||
354 | Handle(TopOpeBRepBuild_HBuilder) build = BC->Builder(); | |
355 | TopTools_ListIteratorOfListOfShape its; | |
356 | ||
357 | TopoDS_Compound result; | |
358 | BRep_Builder B; | |
359 | B.MakeCompound(result); | |
360 | ||
361 | TopExp_Explorer ex; | |
362 | for (ex.Init(ShapeCut,TopAbs_SOLID); ex.More(); ex.Next()) { | |
363 | const TopoDS_Shape& cutsol = ex.Current(); | |
364 | ||
365 | BRepFilletAPI_MakeFillet fill(cutsol); | |
366 | fill.SetParams(ta,t3d,t2d,t3d,t2d,fl); | |
367 | fill.SetContinuity(blend_cont, tapp_angle); | |
368 | its = build->Section(); | |
369 | while (its.More()) { | |
370 | TopoDS_Edge E = TopoDS::Edge(its.Value()); | |
371 | fill.Add(Rad,E); | |
372 | its.Next(); | |
373 | } | |
374 | ||
375 | fill.Build(); | |
376 | if(fill.IsDone()){ | |
377 | B.Add(result,fill.Shape()); | |
378 | } | |
379 | else { | |
380 | B.Add(result,cutsol); | |
381 | } | |
382 | } | |
383 | ||
384 | delete BC; | |
385 | DBRep::Set(a[1],result); | |
386 | return 0; | |
387 | } | |
388 | ||
389 | //********************************************** | |
390 | // bfuse or bcut and then blend the section | |
391 | //********************************************** | |
392 | ||
393 | Standard_Integer boptopoblend(Draw_Interpretor& di, Standard_Integer narg, const char** a) | |
394 | { | |
395 | printtolblend(di); | |
396 | if(narg != 5) return 1; | |
397 | ||
398 | Standard_Boolean fuse = !strcmp(a[0],"bfuseblend"); | |
399 | TopoDS_Shape S1 = DBRep::Get(a[2]); | |
400 | TopoDS_Shape S2 = DBRep::Get(a[3]); | |
401 | if (S1.IsNull() || S2.IsNull()) { | |
402 | printf(" Null shapes are not allowed \n"); | |
403 | return 1; | |
404 | } | |
91322f44 | 405 | Standard_Real Rad = Draw::Atof(a[4]); |
7fd59977 | 406 | |
407 | BOPTools_DSFiller theDSFiller; | |
408 | ||
409 | theDSFiller.SetShapes( S1, S2 ); | |
410 | if (!theDSFiller.IsDone()) { | |
411 | printf("Check types of the arguments, please\n"); | |
412 | return 1; | |
413 | } | |
414 | ||
415 | theDSFiller.Perform(); | |
416 | ||
417 | BRepAlgoAPI_BooleanOperation* pBuilder=NULL; | |
418 | ||
419 | if (fuse) | |
420 | pBuilder = new BRepAlgoAPI_Fuse( S1, S2, theDSFiller ); | |
421 | else | |
422 | pBuilder = new BRepAlgoAPI_Cut ( S1, S2, theDSFiller ); | |
423 | ||
424 | Standard_Boolean anIsDone = pBuilder->IsDone(); | |
425 | if (!anIsDone) | |
426 | { | |
427 | printf("boolean operation not done ErrorStatus()=%d\n", pBuilder->ErrorStatus()); | |
428 | return 1; | |
429 | } | |
430 | ||
431 | TopoDS_Shape ResultOfBop = pBuilder->Shape(); | |
432 | ||
433 | delete pBuilder; | |
434 | pBuilder = new BRepAlgoAPI_Section( S1, S2, theDSFiller ); | |
435 | TopoDS_Shape theSection = pBuilder->Shape(); | |
436 | ||
437 | TopoDS_Compound result; | |
438 | BRep_Builder BB; | |
439 | BB.MakeCompound(result); | |
440 | ||
441 | TopExp_Explorer Explo( ResultOfBop, TopAbs_SOLID ); | |
442 | for (; Explo.More(); Explo.Next()) | |
443 | { | |
444 | const TopoDS_Shape& aSolid = Explo.Current(); | |
445 | ||
446 | BRepFilletAPI_MakeFillet Blender(aSolid); | |
447 | Blender.SetParams(ta,t3d,t2d,t3d,t2d,fl); | |
448 | Blender.SetContinuity( blend_cont, tapp_angle ); | |
449 | ||
450 | TopExp_Explorer expsec( theSection, TopAbs_EDGE ); | |
451 | for (; expsec.More(); expsec.Next()) | |
452 | { | |
453 | TopoDS_Edge anEdge = TopoDS::Edge(expsec.Current()); | |
454 | Blender.Add( Rad, anEdge ); | |
455 | } | |
456 | ||
457 | Blender.Build(); | |
458 | if (Blender.IsDone()) | |
459 | BB.Add( result, Blender.Shape() ); | |
460 | else | |
461 | BB.Add( result, aSolid ); | |
462 | } | |
463 | ||
464 | delete pBuilder; | |
465 | DBRep::Set( a[1], result ); | |
466 | return 0; | |
467 | } | |
468 | ||
469 | ||
470 | static Standard_Integer blend1(Draw_Interpretor& di, Standard_Integer narg, const char** a) | |
471 | { | |
472 | if (narg<5) return 1; | |
473 | TopoDS_Shape V = DBRep::Get(a[2]); | |
474 | if(V.IsNull()) return 1; | |
475 | Standard_Integer nb ,i; | |
476 | Standard_Real Rad; | |
477 | Standard_Boolean simul=Standard_False; | |
478 | const char *ns0=(a[1]); | |
91322f44 | 479 | Rad = Draw::Atof(a[3]); |
7fd59977 | 480 | TopTools_ListOfShape E; |
481 | for (i=4; i <=(narg-1) ; i++){ | |
482 | TopoDS_Shape edge= DBRep::Get(a[i],TopAbs_EDGE); | |
483 | if (edge.IsNull()) return 1 ; | |
484 | if(edge.ShapeType()!=TopAbs_EDGE) return 1; | |
485 | E.Append(edge); | |
486 | } | |
487 | FilletSurf_Builder Rakk(V,E,Rad); | |
488 | if (simul) Rakk.Simulate(); | |
489 | else Rakk.Perform(); | |
490 | ||
491 | //if (Rakk.IsDone()==FilletSurf_IsNotOk) | |
492 | // { FilletSurf_ErrorTypeStatus err=Rakk.StatusError(); | |
493 | // if (err==FilletSurf_EmptyList) cout<< "StatusError=EmptyList"<<endl; | |
494 | // else if (err==FilletSurf_EdgeNotG1) cout<< "StatusError=NotG1"<<endl; | |
495 | // else if (err==FilletSurf_FacesNotG1) cout<< "StatusError=facesNotG1"<<endl; | |
496 | // else if (err==FilletSurf_EdgeNotOnShape) | |
497 | // cout<< "StatusError=edgenotonshape"<<endl; | |
498 | // else if (err==FilletSurf_NotSharpEdge ) cout<< "StatusError=notsharpedge"<<endl; | |
499 | // else if (err==FilletSurf_PbFilletCompute) cout <<"StatusError=PBFillet"<<endl; | |
500 | // } | |
501 | // else { | |
502 | // if (Rakk.IsDone()==FilletSurf_IsPartial) cout <<"resultat partiel"<<endl; | |
503 | if (Rakk.IsDone()==FilletSurf_IsNotOk) | |
504 | { FilletSurf_ErrorTypeStatus err=Rakk.StatusError(); | |
505 | if (err==FilletSurf_EmptyList) di<< "StatusError=EmptyList"<<"\n"; | |
506 | else if (err==FilletSurf_EdgeNotG1) di<< "StatusError=NotG1"<<"\n"; | |
507 | else if (err==FilletSurf_FacesNotG1) di<< "StatusError=facesNotG1"<<"\n"; | |
508 | else if (err==FilletSurf_EdgeNotOnShape) | |
509 | di<< "StatusError=edgenotonshape"<<"\n"; | |
510 | else if (err==FilletSurf_NotSharpEdge ) di<< "StatusError=notsharpedge"<<"\n"; | |
511 | else if (err==FilletSurf_PbFilletCompute) di <<"StatusError=PBFillet"<<"\n"; | |
512 | } | |
513 | else { | |
0d969553 | 514 | if (Rakk.IsDone()==FilletSurf_IsPartial) di <<"partial result"<<"\n"; |
7fd59977 | 515 | |
516 | nb=Rakk.NbSurface(); | |
517 | char localname [100]; | |
518 | char *temp; | |
519 | ||
520 | // affichage du type d'arret | |
521 | ||
522 | if (!simul) | |
523 | { | |
524 | //if (Rakk.StartSectionStatus()==FilletSurf_NoExtremityOnEdge) | |
525 | // {cout<<" type deb conges = WLBLOUT"<<endl;} | |
526 | //else if (Rakk.StartSectionStatus()==FilletSurf_OneExtremityOnEdge ) | |
527 | // { cout<<" type deb conges = WLBLSTOP"<<endl;} | |
528 | //else if (Rakk.StartSectionStatus()==FilletSurf_TwoExtremityOnEdge) | |
529 | // {cout<<" type deb conges = WLBLEND"<<endl;} | |
530 | if (Rakk.StartSectionStatus()==FilletSurf_NoExtremityOnEdge) | |
0d969553 | 531 | {di<<" type start fillets = WLBLOUT"<<"\n";} |
7fd59977 | 532 | else if (Rakk.StartSectionStatus()==FilletSurf_OneExtremityOnEdge ) |
0d969553 | 533 | { di<<" type start fillets = WLBLSTOP"<<"\n";} |
7fd59977 | 534 | else if (Rakk.StartSectionStatus()==FilletSurf_TwoExtremityOnEdge) |
0d969553 | 535 | {di<<" type start fillets = WLBLEND"<<"\n";} |
7fd59977 | 536 | |
537 | //if (Rakk.EndSectionStatus()==FilletSurf_NoExtremityOnEdge) | |
538 | // {cout<<" type fin conges = WLBLOUT"<<endl;} | |
539 | //else if (Rakk.EndSectionStatus()==FilletSurf_OneExtremityOnEdge) | |
540 | // {cout<<" type fin conges = WLBLSTOP"<<endl;} | |
541 | //else if (Rakk.EndSectionStatus()==FilletSurf_TwoExtremityOnEdge) | |
542 | // { cout<<" type fin conges = WLBLEND"<<endl;} | |
543 | if (Rakk.EndSectionStatus()==FilletSurf_NoExtremityOnEdge) | |
0d969553 | 544 | {di<<" type end fillets = WLBLOUT"<<"\n";} |
7fd59977 | 545 | else if (Rakk.EndSectionStatus()==FilletSurf_OneExtremityOnEdge) |
0d969553 | 546 | {di<<" type end fillets = WLBLSTOP"<<"\n";} |
7fd59977 | 547 | else if (Rakk.EndSectionStatus()==FilletSurf_TwoExtremityOnEdge) |
0d969553 | 548 | { di<<" type end fillets = WLBLEND"<<"\n";} |
7fd59977 | 549 | Standard_Real f,l; |
550 | f = Rakk.FirstParameter(); | |
551 | l = Rakk.LastParameter(); | |
0d969553 Y |
552 | //cout<<"parameter on edge start : "<<f<<endl; |
553 | //cout<<"parameter on edge end : "<<l<<endl; | |
554 | di<<"parametre on edge start : "<<f<<"\n"; | |
555 | di<<"parametre on edge end : "<<l<<"\n"; | |
7fd59977 | 556 | for (i=1;i<=nb;i++){ |
557 | //precision | |
558 | //cout<<"precision "<< i << "= "<<Rakk.TolApp3d(i)<<endl; | |
559 | di<<"precision "<< i << "= "<<Rakk.TolApp3d(i)<<"\n"; | |
560 | ||
0d969553 | 561 | // display resulting surfaces |
91322f44 | 562 | Sprintf(localname, "%s%d" ,ns0,i); |
7fd59977 | 563 | temp = localname; |
564 | DrawTrSurf::Set(temp,Rakk.SurfaceFillet(i)); | |
565 | di << localname<< " "; | |
566 | ||
0d969553 | 567 | // display curves 3d |
91322f44 | 568 | Sprintf(localname, "%s%d" ,"courb1",i); |
7fd59977 | 569 | temp =localname; |
570 | DrawTrSurf::Set(temp,Rakk.CurveOnFace1(i)); | |
571 | di << localname<< " "; | |
91322f44 | 572 | Sprintf(localname, "%s%d" ,"courb2",i); |
7fd59977 | 573 | temp =localname; |
574 | DrawTrSurf::Set(temp,Rakk.CurveOnFace2(i)); | |
575 | di << localname<< " "; | |
576 | ||
0d969553 | 577 | // display supports |
91322f44 | 578 | Sprintf(localname, "%s%d" ,"face1",i); |
7fd59977 | 579 | temp =localname ; |
580 | DBRep::Set(temp,Rakk.SupportFace1(i)); | |
581 | di << localname<< " "; | |
91322f44 | 582 | Sprintf(localname, "%s%d" ,"face2",i); |
7fd59977 | 583 | temp =localname; |
584 | DBRep::Set(temp,Rakk.SupportFace2(i)); | |
585 | di << localname<< " "; | |
586 | ||
0d969553 | 587 | // display Pcurves on faces |
91322f44 | 588 | Sprintf(localname, "%s%d" ,"pcurveonface1",i); |
7fd59977 | 589 | temp =localname ; |
590 | DrawTrSurf::Set(temp,Rakk.PCurveOnFace1(i)); | |
591 | di << localname<< " "; | |
91322f44 | 592 | Sprintf(localname, "%s%d" ,"pcurveonface2",i); |
7fd59977 | 593 | temp =localname; |
594 | DrawTrSurf::Set(temp,Rakk.PCurveOnFace2(i)); | |
595 | di << localname<< " "; | |
596 | ||
0d969553 | 597 | // display Pcurves on the fillet |
91322f44 | 598 | Sprintf(localname, "%s%d" ,"pcurveonconge1",i); |
7fd59977 | 599 | temp =localname; |
600 | DrawTrSurf::Set(temp,Rakk.PCurve1OnFillet(i)); | |
601 | di << localname<< " "; | |
91322f44 | 602 | Sprintf(localname, "%s%d" ,"pcurveonconge2",i); |
7fd59977 | 603 | temp =localname; |
604 | DrawTrSurf::Set(temp,Rakk.PCurve2OnFillet(i)); | |
605 | di << localname<< " "; | |
606 | ||
607 | } } | |
608 | else{ | |
609 | Standard_Integer j; | |
610 | ||
611 | for (i=1;i<=nb;i++) | |
612 | {Standard_Integer s=Rakk.NbSection(i); | |
613 | for (j=1;j<=s;j++) | |
614 | {Handle(Geom_TrimmedCurve Sec); | |
615 | Rakk.Section(i,j,Sec); | |
91322f44 | 616 | Sprintf(localname, "%s%d%d" ,"sec",i,j); |
7fd59977 | 617 | temp =localname; |
618 | DrawTrSurf::Set (temp,Sec); | |
619 | di << localname<< " ";} | |
620 | }} | |
621 | } | |
622 | return 0; | |
623 | } | |
624 | ||
625 | //======================================================================= | |
626 | //function : rollingball | |
627 | //purpose : | |
628 | //======================================================================= | |
629 | ||
630 | Standard_Integer rollingball(Draw_Interpretor& di, Standard_Integer n, const char** a) | |
631 | { | |
632 | if ( n < 2) return 1; | |
633 | ||
634 | TopoDS_Shape S = DBRep::Get(a[2]); | |
635 | if ( S.IsNull()) return 1; | |
91322f44 | 636 | Standard_Real Rad = Draw::Atof(a[3]); |
7fd59977 | 637 | |
0d969553 | 638 | Standard_Real Tol = t3d; //the same as blend ! 1.e-7; |
7fd59977 | 639 | |
640 | BiTgte_Blend Roll; | |
641 | Roll.Init(S,Rad,Tol,Standard_False); | |
642 | ||
643 | Standard_Integer Nb = 0; | |
644 | for ( Standard_Integer i = 4; i <= n-1; i++) { | |
645 | if ( !strcmp(a[i],"@")) { | |
646 | Nb++; | |
647 | continue; | |
648 | } | |
649 | ||
0d969553 | 650 | if ( Nb == 0) { // return stop faces. |
7fd59977 | 651 | TopoDS_Shape aLocalFace(DBRep::Get(a[i],TopAbs_FACE)); |
652 | TopoDS_Face F1 = TopoDS::Face(aLocalFace); | |
653 | // TopoDS_Face F1 = TopoDS::Face(DBRep::Get(a[i],TopAbs_FACE)); | |
654 | if ( F1.IsNull()) { | |
0d969553 Y |
655 | //cout << " Stop face not referenced." << endl; |
656 | di << " Stop face not referenced." << "\n"; | |
7fd59977 | 657 | return 1; |
658 | } | |
659 | Roll.SetStoppingFace(F1); | |
660 | } | |
0d969553 | 661 | else if (Nb == 1) { // return faces on which the ball rotates |
7fd59977 | 662 | TopoDS_Shape aLocalFace(DBRep::Get(a[i],TopAbs_FACE)); |
663 | TopoDS_Face F1 = TopoDS::Face(aLocalFace); | |
664 | // TopoDS_Face F1 = TopoDS::Face(DBRep::Get(a[i],TopAbs_FACE)); | |
665 | i++; | |
666 | if ( !strcmp(a[i],"@")) { | |
0d969553 Y |
667 | //cout << " Even number of ball support faces is required " << endl; |
668 | di << " Even number of ball support faces is required " << "\n"; | |
7fd59977 | 669 | return 1; |
670 | } | |
671 | aLocalFace = DBRep::Get(a[i],TopAbs_FACE); | |
672 | TopoDS_Face F2 = TopoDS::Face(aLocalFace); | |
673 | // TopoDS_Face F2 = TopoDS::Face(DBRep::Get(a[i],TopAbs_FACE)); | |
674 | if ( F1.IsNull() || F2.IsNull()) { | |
0d969553 Y |
675 | //cout << " Support face not referenced." << endl; |
676 | di << " Support face not referenced." << "\n"; | |
7fd59977 | 677 | return 1; |
678 | } | |
679 | Roll.SetFaces(F1,F2); | |
680 | } | |
0d969553 | 681 | else if (Nb == 2) { // return the edge on which the ball rotates |
7fd59977 | 682 | TopoDS_Shape aLocalShape(DBRep::Get(a[i],TopAbs_EDGE)); |
683 | TopoDS_Edge E = TopoDS::Edge(aLocalShape); | |
684 | // TopoDS_Edge E = TopoDS::Edge(DBRep::Get(a[i],TopAbs_EDGE)); | |
685 | if ( E.IsNull()) { | |
0d969553 Y |
686 | //cout << " Edge not referenced." << endl; |
687 | di << " Edge not referenced." << "\n"; | |
7fd59977 | 688 | return 1; |
689 | } | |
690 | Roll.SetEdge(E); | |
691 | } | |
692 | ||
693 | } | |
694 | Standard_Boolean BuildShape = (!strcmp(a[0],"brollingball")); | |
695 | ||
696 | Roll.Perform(BuildShape); | |
697 | ||
698 | Standard_Boolean ComputeBranches = (!strcmp(a[0],"trollingball")); | |
699 | char localname[100]; | |
700 | if (ComputeBranches) { | |
701 | Standard_Integer NbBranches = Roll.NbBranches(); | |
702 | for (Standard_Integer i = 1; i <= NbBranches; i++) { | |
703 | Standard_Integer From,To; | |
704 | Roll.IndicesOfBranche(i,From,To); | |
0d969553 | 705 | //cout << " Indexes of the " << i << "th Branch : "; |
7fd59977 | 706 | //cout << " " << From << " " << To << endl; |
0d969553 | 707 | di << " Indexes of the " << i << "th Branch : "; |
7fd59977 | 708 | di << " " << From << " " << To << "\n"; |
709 | for (Standard_Integer j = From; j <= To; j++) { | |
710 | const TopoDS_Shape& CurF = Roll.Face(j); | |
91322f44 | 711 | Sprintf(localname,"%s_%d_%d",a[1],i,j); |
7fd59977 | 712 | DBRep::Set(localname,CurF); |
713 | } | |
714 | } | |
715 | ||
716 | } | |
717 | else | |
718 | DBRep::Set(a[1],Roll.Shape()); | |
719 | ||
720 | return 0; | |
721 | } | |
722 | ||
723 | //======================================================================= | |
724 | //function : FilletCommands | |
725 | //purpose : | |
726 | //======================================================================= | |
727 | ||
728 | void BRepTest::FilletCommands(Draw_Interpretor& theCommands) | |
729 | { | |
730 | static Standard_Boolean done = Standard_False; | |
731 | if (done) return; | |
732 | done = Standard_True; | |
733 | ||
734 | DBRep::BasicCommands(theCommands); | |
735 | ||
736 | const char* g = "TOPOLOGY Fillet construction commands"; | |
737 | ||
738 | theCommands.Add("continuityblend", | |
739 | "continuityblend C0/C1/C2 [tangle]",__FILE__, | |
740 | contblend,g); | |
741 | ||
742 | theCommands.Add("tolblend", | |
743 | "tolblend [ta t3d t2d fl]",__FILE__, | |
744 | tolblend,g); | |
745 | ||
746 | theCommands.Add("blend", | |
747 | "blend result object rad1 ed1 rad2 ed2 ... [R/Q/P]",__FILE__, | |
748 | BLEND,g); | |
749 | ||
750 | theCommands.Add("checkhist", | |
751 | "checkhist",__FILE__, | |
752 | CheckHist,g); | |
753 | ||
754 | theCommands.Add("mkevol", | |
755 | "mkevol result object (then use updatevol) [R/Q/P]",__FILE__, | |
756 | MKEVOL,g); | |
757 | ||
758 | theCommands.Add("updatevol", | |
759 | "updatevol edge u1 rad1 u2 rad2 ...",__FILE__, | |
760 | UPDATEVOL,g); | |
761 | ||
762 | theCommands.Add("buildevol", | |
763 | "buildevol end of the evol fillet computation",__FILE__, | |
764 | BUILDEVOL,g); | |
765 | ||
766 | theCommands.Add("fubl", | |
767 | "fubl result shape1 shape2 radius",__FILE__, | |
768 | topoblend,g); | |
769 | ||
770 | theCommands.Add("cubl", | |
771 | "cubl result shape tool radius",__FILE__, | |
772 | topoblend,g); | |
773 | ||
774 | theCommands.Add("bfuseblend", | |
775 | "bfuseblend result shape1 shape2 radius",__FILE__, | |
776 | boptopoblend,g); | |
777 | ||
778 | theCommands.Add("bcutblend", | |
779 | "bcutblend result shape tool radius",__FILE__, | |
780 | boptopoblend,g); | |
781 | ||
782 | theCommands.Add("blend1", | |
783 | "blend1 result object rad ed1 ed2 ...",__FILE__, | |
784 | blend1,g); | |
785 | ||
786 | theCommands.Add("rollingball", | |
787 | "rollingball r S radius [stopf1 ..] @ [f1 f2 ..] @ [e1 ..]", | |
788 | __FILE__, | |
789 | rollingball); | |
790 | ||
791 | theCommands.Add("brollingball", | |
792 | "brollingball r S radius [stopf1 ..] @ [f1 f2 ..] @ [e1 ..]", | |
793 | __FILE__, | |
794 | rollingball); | |
795 | ||
796 | theCommands.Add("trollingball", | |
797 | "trollingball r S radius [stopf1 ..] @ [f1 f2 ..] @ [e1 ..]", | |
798 | __FILE__, | |
799 | rollingball); | |
800 | } |