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