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