Integration of OCCT 6.5.0 from SVN
[occt.git] / src / ChFi3d / ChFi3d_Builder.cxx
CommitLineData
7fd59977 1// File: ChFi3d_Builder.cxx
2// Created: Thu Nov 18 15:59:35 1993
3// Author: Isabelle GRIGNON
4// <isg@zerox>
5
6
7#include <ChFi3d_Builder.ixx>
8
9#include <Standard_Failure.hxx>
10#include <Standard_NoSuchObject.hxx>
11#include <Standard_NotImplemented.hxx>
12#include <Standard_ErrorHandler.hxx>
13#include <TColStd_MapIteratorOfMapOfInteger.hxx>
14#include <TColStd_MapOfInteger.hxx>
15#include <TColStd_ListIteratorOfListOfInteger.hxx>
16
17#include <TopoDS.hxx>
18#include <TopoDS_Shape.hxx>
19#include <TopoDS_Face.hxx>
20#include <TopoDS_Edge.hxx>
21#include <TopoDS_Vertex.hxx>
22
23#include <TopAbs.hxx>
24#include <TopAbs_ShapeEnum.hxx>
25#include <TopAbs_Orientation.hxx>
26#include <BRep_Builder.hxx>
27#include <BRep_Tool.hxx>
28#include <TopExp.hxx>
29#include <TopExp_Explorer.hxx>
30#include <TopTools_ListOfShape.hxx>
31#include <TopTools_ListIteratorOfListOfShape.hxx>
32
33#include <TopOpeBRepDS_CurveExplorer.hxx>
34#include <TopOpeBRepDS_CurvePointInterference.hxx>
35#include <TopOpeBRepDS_DataStructure.hxx>
36#include <TopOpeBRepDS_BuildTool.hxx>
37#include <TopOpeBRepDS_Curve.hxx>
38#include <TopOpeBRepDS_PointIterator.hxx>
39#include <TopTools_ListIteratorOfListOfShape.hxx>
40
41#include <BRep_Tool.hxx>
42#include <ChFiDS_Stripe.hxx>
43#include <ChFiDS_ListIteratorOfListOfStripe.hxx>
44#include <ChFiDS_SequenceOfSurfData.hxx>
45#include <ChFiDS_HData.hxx>
46
47#include <ChFi3d.hxx>
48
49#include <ChFi3d_Builder_0.hxx>
50#include <TopOpeBRepDS_ListOfInterference.hxx>
51
52
53#ifdef DRAW
54#include <TestTopOpeTools.hxx>
55#include <TestTopOpe.hxx>
56#endif
57#ifdef DEB
58#include <OSD_Chronometer.hxx>
59
60// variables pour les performances
61
62
63OSD_Chronometer cl_total,cl_extent,cl_perfsetofsurf,cl_perffilletonvertex,
64cl_filds,cl_reconstruction,cl_setregul,cl_perform1corner,cl_perform2corner,
65cl_performatend,cl_perform3corner,cl_performmore3corner;
66
67Standard_EXPORT Standard_Real t_total, t_extent,t_perfsetofsurf,
68t_perffilletonvertex, t_filds,t_reconstruction,t_setregul, t_perfsetofkgen,
69t_perfsetofkpart,t_makextremities,t_performatend,t_startsol,t_performsurf,
70t_perform1corner,t_perform2corner,t_perform3corner,t_performmore3corner,
71t_batten,t_inter,t_sameinter,t_same,t_plate,t_approxplate,t_t2cornerinit,
72t_perf2cornerbyinter,t_chfikpartcompdata,t_cheminement,t_remplissage,
73t_t3cornerinit ,t_spherique,t_torique, t_notfilling,t_filling,t_sameparam,
74t_computedata,t_completedata,t_t2cornerDS,t_t3cornerDS;
75
76//Standard_IMPORT extern void ChFi3d_InitChron(OSD_Chronometer& ch);
77Standard_IMPORT void ChFi3d_InitChron(OSD_Chronometer& ch);
78//Standard_IMPORT extern void ChFi3d_ResultChron(OSD_Chronometer & ch,
79Standard_IMPORT void ChFi3d_ResultChron(OSD_Chronometer & ch,
80 Standard_Real& time);
81extern Standard_Boolean ChFi3d_GettraceCHRON();
82#endif
83
84
85//=======================================================================
86//function : CompleteDS
87//purpose :
88//=======================================================================
89
90static void CompleteDS(TopOpeBRepDS_DataStructure& DStr,
91 const TopoDS_Shape& S)
92{
93 ChFiDS_Map MapEW,MapFS;
94 MapEW.Fill(S,TopAbs_EDGE,TopAbs_WIRE);
95 MapFS.Fill(S,TopAbs_FACE,TopAbs_SHELL);
96
97 TopExp_Explorer ExpE;
98 for (ExpE.Init(S,TopAbs_EDGE); ExpE.More(); ExpE.Next()) {
99 const TopoDS_Edge& E = TopoDS::Edge(ExpE.Current());
100 Standard_Boolean hasgeom = DStr.HasGeometry(E);
101 if (hasgeom) {
102 const TopTools_ListOfShape& WireListAnc = MapEW(E);
103 TopTools_ListIteratorOfListOfShape itaW(WireListAnc);
104 while (itaW.More()) {
105 const TopoDS_Shape& WireAnc = itaW.Value();
106 DStr.AddShape(WireAnc);
107 itaW.Next();
108 }
109 }
110 }
111
112 TopExp_Explorer ExpF;
113 for (ExpF.Init(S,TopAbs_FACE); ExpF.More(); ExpF.Next()) {
114 const TopoDS_Face& F = TopoDS::Face(ExpF.Current());
115 Standard_Boolean hasgeom = DStr.HasGeometry(F);
116 if (hasgeom) {
117 const TopTools_ListOfShape& ShellListAnc = MapFS(F);
118 TopTools_ListIteratorOfListOfShape itaS(ShellListAnc);
119 while (itaS.More()) {
120 const TopoDS_Shape& ShellAnc = itaS.Value();
121 DStr.AddShape(ShellAnc);
122 itaS.Next();
123 }
124 }
125 }
126
127 // set the range on the DS Curves
128 for (Standard_Integer ic = 1; ic <= DStr.NbCurves(); ic++) {
129 Standard_Real parmin = RealLast(), parmax = RealFirst();
130 const TopOpeBRepDS_ListOfInterference& LI = DStr.CurveInterferences(ic);
131 for (TopOpeBRepDS_PointIterator it(LI);
132 it.More();
133 it.Next() ) {
134 Standard_Real par = it.Parameter();
135 parmin = Min (parmin,par); parmax = Max (parmax,par);
136 }
137 DStr.ChangeCurve(ic).SetRange(parmin,parmax);
138 }
139}
140
141void ChFi3d_Builder::Delete()
142{}
143
144//=======================================================================
145//function : ExtentAnalyse
146//purpose :
147//=======================================================================
148
149void ChFi3d_Builder::ExtentAnalyse ()
150{
151 Standard_Integer nbedges, nbs;
152 for (Standard_Integer iv = 1; iv <= myVDataMap.Extent(); iv++) {
153 nbs = myVDataMap(iv).Extent();
154 const TopoDS_Vertex& Vtx = myVDataMap.FindKey(iv);
155 nbedges = ChFi3d_NumberOfEdges(Vtx, myVEMap);
156 switch (nbs) {
157 case 1 :
158 ExtentOneCorner(Vtx, myVDataMap.FindFromIndex(iv).First());
159 break;
160 case 2 :
161 if (nbedges <= 3)
162 ExtentTwoCorner(Vtx, myVDataMap.FindFromIndex(iv));
163 break;
164 case 3 :
165 if (nbedges <= 3)
166 ExtentThreeCorner(Vtx, myVDataMap.FindFromIndex(iv));
167 break;
168 default :
169 break;
170 }
171 }
172}
173
174//=======================================================================
175//function : Compute
176//purpose :
177//=======================================================================
178
179void ChFi3d_Builder::Compute()
180{
181
182#ifdef DEB //perf
183 t_total=0;t_extent=0; t_perfsetofsurf=0;t_perffilletonvertex=0;
184 t_filds=0;t_reconstruction=0;t_setregul=0;
185 t_perfsetofkpart=0; t_perfsetofkgen=0;t_makextremities=0;
186 t_performsurf=0;t_startsol=0; t_perform1corner=0;t_perform2corner=0;
187 t_perform3corner=0;t_performmore3corner=0;t_inter=0;t_same=0;t_sameinter=0;
188 t_plate=0;t_approxplate=0; t_batten=0;t_remplissage=0;t_t3cornerinit=0;
189 t_spherique=0;t_torique=0;t_notfilling=0;t_filling=0;t_performatend=0;
190 t_t2cornerinit=0; t_perf2cornerbyinter=0;t_chfikpartcompdata=0;
191 t_cheminement=0; t_sameparam=0; t_computedata=0;t_completedata=0;
192 t_t2cornerDS=0;t_t3cornerDS=0;
193 ChFi3d_InitChron(cl_total);
194 ChFi3d_InitChron(cl_extent);
195#endif
196
197 if (myListStripe.IsEmpty())
198 Standard_Failure::Raise("There are no suitable edges for chamfer or fillet");
199
200 Reset();
201 myDS = new TopOpeBRepDS_HDataStructure();
202 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
203 done = Standard_True;
204 hasresult=Standard_False;
205#ifdef DRAW
206 TestTopOpe::CurrentDS(myDS);
207 TopoDS_Shape bids;
208 TestTopOpe::Shapes(myShape,bids);
209#endif
210
211 // remplissage de myVDatatMap
212 ChFiDS_ListIteratorOfListOfStripe itel;
213
214 for (itel.Initialize(myListStripe);itel.More(); itel.Next()) {
215 if ((itel.Value()->Spine()->FirstStatus() <= ChFiDS_BreakPoint))
216 myVDataMap.Add(itel.Value()->Spine()->FirstVertex(),itel.Value());
217 else if (itel.Value()->Spine()->FirstStatus() == ChFiDS_FreeBoundary)
218 ExtentOneCorner(itel.Value()->Spine()->FirstVertex(),itel.Value());
219 if ((itel.Value()->Spine()->LastStatus() <= ChFiDS_BreakPoint))
220 myVDataMap.Add(itel.Value()->Spine()->LastVertex() ,itel.Value());
221 else if (itel.Value()->Spine()->LastStatus() == ChFiDS_FreeBoundary)
222 ExtentOneCorner(itel.Value()->Spine()->LastVertex(),itel.Value());
223 }
224 // preanalyse pour evaluer les prolongements.
225 ExtentAnalyse();
226
227
228#ifdef DEB //perf
229 ChFi3d_ResultChron(cl_extent,t_extent);
230 ChFi3d_InitChron(cl_perfsetofsurf);
231#endif
232
233 // Construction de la bande de conge sur chaque stripe.
234 for (itel.Initialize(myListStripe);itel.More(); itel.Next()) {
235 itel.Value()->Spine()->SetErrorStatus(ChFiDS_Ok);
236 try {
237 OCC_CATCH_SIGNALS
238 PerformSetOfSurf(itel.Value());
239 }
240 catch(Standard_Failure) {
241 Handle(Standard_Failure) exc = Standard_Failure::Caught();
242#ifdef DEB
243 cout <<"EXCEPTION Stripe compute " << exc << endl;
244#endif
245 badstripes.Append(itel.Value());
246 done = Standard_True;
247 if (itel.Value()->Spine()->ErrorStatus()==ChFiDS_Ok)
248 itel.Value()->Spine()->SetErrorStatus(ChFiDS_Error);
249 }
250 if (!done) badstripes.Append(itel.Value());
251 done = Standard_True;
252 }
253 done = (badstripes.IsEmpty());
254
255#ifdef DEB //perf
256 ChFi3d_ResultChron(cl_perfsetofsurf,t_perfsetofsurf);
257 ChFi3d_InitChron(cl_perffilletonvertex);
258#endif
259
260 //construire les conges sur chaque vertex +alimenter la Ds
261 if (done) {
262 //Standard_Integer nbresult=0;
263// for (Standard_Integer j=1;j<=myVDataMap.Extent();j++) {
264#ifndef DEB
265 static
266#endif //to avoid Linux warning:<< variable `j' might be clobbered by `longjmp' or `vfork' >>
267 Standard_Integer j;
268 for (j=1;j<=myVDataMap.Extent();j++) {
269 try {
270 OCC_CATCH_SIGNALS
271 PerformFilletOnVertex(j);
272 }
273 catch(Standard_Failure) {
274 Handle(Standard_Failure) exc = Standard_Failure::Caught();
275#ifdef DEB
276 cout <<"EXCEPTION Corner compute " << exc << endl;
277#endif
278 badvertices.Append(myVDataMap.FindKey(j));
279 hasresult=Standard_False;
280 done = Standard_True;
281 }
282 if (!done) badvertices.Append(myVDataMap.FindKey(j));
283 done = Standard_True;
284 }
285 if (!hasresult) done = badvertices.IsEmpty();
286 }
287
288
289#ifdef DEB //perf
290 ChFi3d_ResultChron(cl_perffilletonvertex,t_perffilletonvertex);
291 ChFi3d_InitChron(cl_filds);
292#endif
293
294 TColStd_MapOfInteger MapIndSo;
295 TopExp_Explorer expso(myShape,TopAbs_SOLID);
296 for(; expso.More(); expso.Next()){
297 const TopoDS_Shape& cursol = expso.Current();
298 Standard_Integer indcursol = DStr.AddShape(cursol);
299 MapIndSo.Add(indcursol);
300 }
301 TopExp_Explorer expsh(myShape,TopAbs_SHELL,TopAbs_SOLID);
302 for(; expsh.More(); expsh.Next()){
303 const TopoDS_Shape& cursh = expsh.Current();
304 Standard_Integer indcursh = DStr.AddShape(cursh);
305 MapIndSo.Add(indcursh);
306 }
307 if (done) {
308 Standard_Integer i1;
309 for (itel.Initialize(myListStripe), i1=0;
310 itel.More();
311 itel.Next(), i1++) {
312 const Handle(ChFiDS_Stripe)& st = itel.Value();
313 // 05/02/02 akm vvv : (OCC119) First we'll check ain't there
314 // intersections between fillets
315 ChFiDS_ListIteratorOfListOfStripe itel1;
316 Standard_Integer i2;
317 for (itel1.Initialize(myListStripe), i2=0;
318 itel1.More();
319 itel1.Next(), i2++) {
320 if (i2 <= i1)
321 // Do not twice intersect the stripes
322 continue;
323 Handle(ChFiDS_Stripe) aCheckStripe = itel1.Value();
324 try {
325 OCC_CATCH_SIGNALS
326 ChFi3d_StripeEdgeInter (st, aCheckStripe, DStr, tol2d);
327 }
328 catch(Standard_Failure) {
329 Handle(Standard_Failure) exc = Standard_Failure::Caught();
330#ifdef DEB
331 cout <<"EXCEPTION Fillets compute " << exc << endl;
332#endif
333 badstripes.Append(itel.Value());
334 hasresult=Standard_False;
335 done = Standard_False;
336 break;
337 }
338 }
339 // 05/02/02 akm ^^^
340 Standard_Integer solidindex = st->SolidIndex();
341 ChFi3d_FilDS(solidindex,st,DStr,myRegul,tolesp,tol2d);
342 if (!done) break;
343 }
344
345#ifdef DEB //perf
346 ChFi3d_ResultChron(cl_filds,t_filds);
347 ChFi3d_InitChron(cl_reconstruction);
348#endif
349
350
351 if (done) {
352 BRep_Builder B1;
353 CompleteDS(DStr,myShape);
354 //Update des tolerances sur vertex au max des aretes adjacentes ou
355 //Update des tolerances sur arete degeneree au max des vertex adjacents.
356 TopOpeBRepDS_CurveExplorer cex(DStr);
357 for(;cex.More();cex.Next()){
358 TopOpeBRepDS_Curve& c = *((TopOpeBRepDS_Curve*)(void*)&(cex.Curve()));
359 Standard_Real tolc = 0.;
360 Standard_Boolean degen = c.Curve().IsNull();
361 if(!degen) tolc = c.Tolerance();
362 Standard_Integer ic = cex.Index();
363 TopOpeBRepDS_PointIterator It(myDS->CurvePoints(ic));
364 for(;It.More();It.Next()){
365 Handle(TopOpeBRepDS_CurvePointInterference) II;
366 II = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(It.Value());
367 if (II.IsNull()) continue;
368 TopOpeBRepDS_Kind gk = II->GeometryType();
369 Standard_Integer gi = II->Geometry();
370 if(gk == TopOpeBRepDS_VERTEX){
371 const TopoDS_Vertex& v = TopoDS::Vertex(myDS->Shape(gi));
372 Standard_Real tolv = BRep_Tool::Tolerance(v);
373 if( tolv > 0.0001 ) {
374 tolv += 0.0003;
375 if( tolc < tolv ) tolc = tolv + 0.00001;
376 }
377 if(degen && tolc < tolv) tolc = tolv;
378 else if(tolc>tolv) B1.UpdateVertex(v,tolc);
379 }
380 else if(gk == TopOpeBRepDS_POINT){
381 TopOpeBRepDS_Point& p = DStr.ChangePoint(gi);
382 Standard_Real tolp = p.Tolerance();
383 if(degen && tolc < tolp) tolc = tolp;
384 else if(tolc>tolp) p.Tolerance(tolc);
385 }
386 }
387 if(degen) c.Tolerance(tolc);
388 }
389 myCoup->Perform(myDS);
390 TColStd_MapIteratorOfMapOfInteger It(MapIndSo);
391 for(; It.More(); It.Next()){
392 Standard_Integer indsol = It.Key();
393 const TopoDS_Shape& curshape = DStr.Shape(indsol);
394 myCoup->MergeSolid(curshape,TopAbs_IN);
395 }
396
397 Standard_Integer i=1,n=DStr.NbShapes();
398 for (;i<=n;i++) {
399 const TopoDS_Shape S = DStr.Shape(i);
400 if (S.ShapeType() != TopAbs_EDGE) continue;
401 Standard_Boolean issplitIN = myCoup->IsSplit(S,TopAbs_IN);
402 if ( !issplitIN ) continue;
403 TopTools_ListIteratorOfListOfShape it(myCoup->Splits(S,TopAbs_IN));
404 for (; it.More(); it.Next() ) {
405 const TopoDS_Edge& newE = TopoDS::Edge(it.Value());
406 Standard_Real tole = BRep_Tool::Tolerance(newE);
407 TopExp_Explorer exv(newE,TopAbs_VERTEX);
408 for (; exv.More(); exv.Next() ) {
409 const TopoDS_Vertex& v = TopoDS::Vertex(exv.Current());
410 Standard_Real tolv = BRep_Tool::Tolerance(v);
411 if (tole>tolv) B1.UpdateVertex(v,tole);
412 }
413 }
414 }
415 if (!hasresult) {
416 B1.MakeCompound(TopoDS::Compound(myShapeResult));
417 for(It.Reset(); It.More(); It.Next()){
418 Standard_Integer indsol = It.Key();
419 const TopoDS_Shape& curshape = DStr.Shape(indsol);
420 TopTools_ListIteratorOfListOfShape
421 its = myCoup->Merged(curshape,TopAbs_IN);
422 if(!its.More()) B1.Add(myShapeResult,curshape);
423 else {
424 //Si l'ancien type est du Shape est un Shell, on mettre un Shell et non un Solid, Il reste neanmoins un pbleme pour compound de Shell ouvert.
425 while (its.More()) {
426 const TopAbs_ShapeEnum letype = curshape.ShapeType();
427 if (letype == TopAbs_SHELL){
428 TopExp_Explorer expsh2(its.Value(),TopAbs_SHELL);
429 const TopoDS_Shape& cursh = expsh2.Current();
430 TopoDS_Shape tt = cursh;
431 B1.Add(myShapeResult,cursh);
432 its.Next();
433 }
434 else {
435 B1.Add(myShapeResult,its.Value());
436 its.Next();
437 }
438 }
439 }
440 }
441 }
442 else {
443 done=Standard_False;
444 B1.MakeCompound(TopoDS::Compound(badShape));
445 for(It.Reset(); It.More(); It.Next()){
446 Standard_Integer indsol = It.Key();
447 const TopoDS_Shape& curshape = DStr.Shape(indsol);
448 TopTools_ListIteratorOfListOfShape
449 its = myCoup->Merged(curshape,TopAbs_IN);
450 if(!its.More()) B1.Add(badShape,curshape);
451 else {
452 while (its.More()) {
453 B1.Add(badShape,its.Value());
454 its.Next();
455 }
456 }
457 }
458 }
459#ifdef DEB //perf
460 ChFi3d_ResultChron(cl_reconstruction ,t_reconstruction);
461 ChFi3d_InitChron(cl_setregul);
462#endif
463
464 // On code les regularites apres coup.
465 SetRegul();
466
467
468#ifdef DEB //perf
469 ChFi3d_ResultChron(cl_setregul ,t_setregul);
470#endif
471 }
472 }
473#ifdef DEB //perf
474 ChFi3d_ResultChron(cl_total,t_total);
475#endif
476
477
478 // affichage des temps pour les perfs
479
480#ifdef DEB
481 cout<<endl;
482 cout<<"COMPUTE: temps total "<<t_total<<"s dont :"<<endl;
483 cout<<"- Init + ExtentAnalyse "<<t_extent<<"s"<<endl;
484 cout<<"- PerformSetOfSurf "<<t_perfsetofsurf<<"s"<<endl;
485 cout<<"- PerformFilletOnVertex "<<t_perffilletonvertex<<"s"<<endl;
486 cout<<"- FilDS "<<t_filds<<"s"<<endl;
487 cout<<"- Reconstruction "<<t_reconstruction<<"s"<<endl;
488 cout<<"- SetRegul "<<t_setregul<<"s"<<endl<<endl;
489
490 if(ChFi3d_GettraceCHRON()){
491 cout<<endl;
492 cout <<"temps PERFORMSETOFSURF "<<t_perfsetofsurf <<"s dont : "<<endl;
493 cout <<"- SetofKPart "<<t_perfsetofkpart<<"s"<<endl;
494 cout <<"- SetofKGen "<< t_perfsetofkgen <<"s"<<endl;
495 cout <<"- MakeExtremities "<<t_makextremities<<"s"<<endl<<endl;
496
497
498 cout <<"temps SETOFKGEN "<< t_perfsetofkgen<<"s dont : "<<endl;
499 cout<<"- PerformSurf "<<t_performsurf<<"s"<<endl;
500 cout<<"- starsol "<< t_startsol <<"s"<<endl<<endl;
501
502 cout<<"temps PERFORMSURF "<<t_performsurf<<"s dont : " << endl;
503 cout<<"- computedata "<<t_computedata<<"s"<<endl;
504 cout<<"- completedata "<<t_completedata<<"s"<<endl<<endl;
505
506
507 cout<<"temps PERFORMFILLETVERTEX "<<t_perffilletonvertex <<"s dont : " << endl;
508 cout<<"- PerformOneCorner "<<t_perform1corner<<"s"<<endl;
509 cout<<"- PerformIntersectionAtEnd "<<t_performatend<<"s"<<endl;
510 cout<<"- PerformTwoCorner "<<t_perform2corner<<"s"<<endl;
511 cout<<"- PerformThreeCorner "<<t_perform3corner<<"s"<<endl;
512 cout<<"- PerformMoreThreeCorner "<<t_performmore3corner<<"s"<<endl<<endl;
513
514
515 cout<<"temps PerformOneCorner "<<t_perform1corner<<"s dont:"<<endl;
516 cout<<"- temps condition if (same) "<<t_same << "s "<<endl;
517 cout<<"- temps condition if (inter) "<<t_inter<<"s " <<endl;
518 cout<<"- temps condition if (same inter) "<<t_sameinter<<"s " <<endl<<endl;
519
520 cout<<"temps PerformTwocorner "<<t_perform2corner<<"s dont:"<<endl;
521 cout<<"- temps initialisation "<< t_t2cornerinit<<"s"<<endl;
522 cout<<"- temps PerformTwoCornerbyInter "<<t_perf2cornerbyinter<<"s"<<endl;
523 cout<<"- temps ChFiKPart_ComputeData "<<t_chfikpartcompdata <<"s"<<endl;
524 cout<<"- temps cheminement "<<t_cheminement<<"s"<<endl;
525 cout<<"- temps remplissage "<<t_remplissage<<"s"<<endl;
526 cout<<"- temps mise a jour stripes "<<t_t2cornerDS<<"s"<<endl<<endl;
527
528 cout<<" temps PerformThreecorner "<<t_perform3corner<<"s dont:"<<endl;
529 cout<<"- temps initialisation "<< t_t3cornerinit<<"s"<<endl;
530 cout<<"- temps cas spherique "<<t_spherique<<"s"<<endl;
531 cout<<"- temps cas torique "<<t_torique<<"s"<<endl;
532 cout<<"- temps notfilling "<<t_notfilling<<"s"<<endl;
533 cout<<"- temps filling "<<t_filling<<"s"<<endl;
534 cout<<"- temps mise a jour stripes "<<t_t3cornerDS<<"s"<<endl<<endl;
535
536 cout<<"temps PerformMore3Corner "<<t_performmore3corner<<"s dont:"<<endl;
537 cout<<"-temps plate "<<t_plate << "s "<<endl;
538 cout<<"-temps approxplate "<<t_approxplate<<"s " <<endl;
539 cout<<"-temps batten "<< t_batten<<"s " <<endl<<endl;
540
541 cout <<"TEMPS DIVERS "<<endl;
542 cout<<"-temps ChFi3d_sameparameter "<<t_sameparam<<"s"<<endl<<endl;
543 }
544#endif
545}
546
547//=======================================================================
548//function : PerformSingularCorner
549//purpose : Charge le vertex et les aretes degeneree.
550//=======================================================================
551
552void ChFi3d_Builder::PerformSingularCorner
553(const Standard_Integer Index){
554 ChFiDS_ListIteratorOfListOfStripe It;
555 Handle(ChFiDS_Stripe) stripe;
556 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
557 const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Index);
558
559 Handle(ChFiDS_SurfData) Fd;
560 Standard_Integer i, Icurv;
561#ifndef DEB
562 Standard_Integer Ivtx = 0;
563#else
564 Standard_Integer Ivtx;
565#endif
566 for (It.Initialize(myVDataMap(Index)), i=0; It.More(); It.Next(),i++){
567 stripe = It.Value();
568 // la SurfData en cause et ses CommonPoints,
569 Standard_Integer sens = 0;
570 Standard_Integer num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens);
571 Standard_Boolean isfirst = (sens == 1);
572 Fd = stripe->SetOfSurfData()->Sequence().Value(num);
573 const ChFiDS_CommonPoint& CV1 = Fd->Vertex(isfirst,1);
574 const ChFiDS_CommonPoint& CV2 = Fd->Vertex(isfirst,2);
575 // Est ce toujours degenere ?
576 if ( CV1.Point().IsEqual( CV2.Point(), 0) ) {
577 // si oui on stoke le vertex dans la stripe
578 // et on fabrique l'arete en bout
579 if (i==0) Ivtx = ChFi3d_IndexPointInDS(CV1, DStr);
580 Standard_Real tolreached;
581 Standard_Real Pardeb, Parfin;
582 gp_Pnt2d VOnS1, VOnS2;
583 Handle(Geom_Curve) C3d;
584 Handle(Geom2d_Curve) PCurv;
585 TopOpeBRepDS_Curve Crv;
586 if (isfirst) {
587 VOnS1 = Fd->InterferenceOnS1().PCurveOnSurf()->
588 Value(Fd->InterferenceOnS1().FirstParameter());
589 VOnS2 = Fd->InterferenceOnS2().PCurveOnSurf()->
590 Value(Fd->InterferenceOnS2().FirstParameter());
591 }
592 else {
593 VOnS1 = Fd->InterferenceOnS1().PCurveOnSurf()->
594 Value(Fd->InterferenceOnS1().LastParameter());
595 VOnS2 = Fd->InterferenceOnS2().PCurveOnSurf()->
596 Value(Fd->InterferenceOnS2().LastParameter());
597 }
598
599 ChFi3d_ComputeArete(CV1, VOnS1,
600 CV2, VOnS2,
601 DStr.Surface(Fd->Surf()).Surface(),
602 C3d, PCurv,
603 Pardeb,Parfin,tolapp3d,tolapp2d,tolreached,0);
604 Crv = TopOpeBRepDS_Curve(C3d,tolreached);
605 Icurv = DStr.AddCurve(Crv);
606
607 stripe->SetCurve(Icurv, isfirst);
608 stripe->SetParameters(isfirst, Pardeb,Parfin);
609 stripe->ChangePCurve(isfirst) = PCurv;
610 stripe->SetIndexPoint(Ivtx, isfirst, 1);
611 stripe->SetIndexPoint(Ivtx, isfirst, 2);
612 }
613 }
614}
615
616//=======================================================================
617//function : PerformFilletOnVertex
618//purpose :
619//=======================================================================
620
621void ChFi3d_Builder::PerformFilletOnVertex
622(const Standard_Integer Index){
623
624 ChFiDS_ListIteratorOfListOfStripe It;
625 Handle(ChFiDS_Stripe) stripe;
626 Handle(ChFiDS_Spine) sp;
627 const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Index);
628
629 Handle(ChFiDS_SurfData) Fd;
630 Standard_Integer i;
631 Standard_Boolean nondegenere = Standard_True;
632 Standard_Boolean toujoursdegenere = Standard_True;
633#ifndef DEB
634 Standard_Boolean isfirst = Standard_False;
635#else
636 Standard_Boolean isfirst;
637#endif
638 for (It.Initialize(myVDataMap(Index)), i=0; It.More(); It.Next(),i++){
639 stripe = It.Value();
640 sp = stripe->Spine();
641 // la SurfData en cause et ses CommonPoints,
642 Standard_Integer sens = 0;
643 Standard_Integer num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens);
644 isfirst = (sens == 1);
645 Fd = stripe->SetOfSurfData()->Sequence().Value(num);
646 const ChFiDS_CommonPoint& CV1 = Fd->Vertex(isfirst,1);
647 const ChFiDS_CommonPoint& CV2 = Fd->Vertex(isfirst,2);
648 // Est ce toujours degenere ?
649 if ( CV1.Point().IsEqual( CV2.Point(), 0) )
650 nondegenere = Standard_False;
651 else toujoursdegenere = Standard_False;
652 }
653
654 // calcul du nombre de faces = nombre d'aretes
655/* TopTools_ListIteratorOfListOfShape ItF,JtF,ItE;
656 Standard_Integer nbf = 0, jf = 0;
657 for (ItF.Initialize(myVFMap(Vtx)); ItF.More(); ItF.Next()){
658 jf++;
659 Standard_Integer kf = 1;
660 const TopoDS_Shape& cur = ItF.Value();
661 for (JtF.Initialize(myVFMap(Vtx)); JtF.More() && (kf < jf); JtF.Next(), kf++){
662 if(cur.IsSame(JtF.Value())) break;
663 }
664 if(kf == jf) nbf++;
665 }
666 Standard_Integer nba=myVEMap(Vtx).Extent();
667 for (ItE.Initialize(myVEMap(Vtx)); ItE.More(); ItE.Next()){
668 const TopoDS_Edge& cur = TopoDS::Edge(ItE.Value());
669 if (BRep_Tool::Degenerated(cur)) nba--;
670 }
671 nba=nba/2;*/
672 Standard_Integer nba = ChFi3d_NumberOfEdges(Vtx, myVEMap);
673
674 if (nondegenere) { // Traitement normal
675 switch (i) {
676 case 1 :
677 {
678 if(sp->Status(isfirst) == ChFiDS_FreeBoundary) return;
679 if(nba>3) {
680#ifdef DEB //perf
681 ChFi3d_InitChron(cl_performatend);
682#endif
683 PerformIntersectionAtEnd(Index);
684#ifdef DEB
685 ChFi3d_ResultChron(cl_performatend,t_performatend);
686#endif
687 }
688 else {
689#ifdef DEB //perf
690 ChFi3d_InitChron(cl_perform1corner);
691#endif
692 if (MoreSurfdata(Index))
693 PerformMoreSurfdata(Index);
694 else PerformOneCorner(Index);
695#ifdef DEB //perf
696 ChFi3d_ResultChron(cl_perform1corner,t_perform1corner);
697#endif
698 }
699 }
700 break;
701 case 2 :
702 {
703 if(nba>3){
704#ifdef DEB //perf
705 ChFi3d_InitChron(cl_performmore3corner);
706#endif
707 PerformMoreThreeCorner(Index, i);
708#ifdef DEB //perf
709 ChFi3d_ResultChron(cl_performmore3corner,t_performmore3corner);
710#endif
711 }
712 else {
713#ifdef DEB //perf
714 ChFi3d_InitChron(cl_perform2corner);
715#endif
716 PerformTwoCorner(Index);
717#ifdef DEB //perf
718 ChFi3d_ResultChron(cl_perform2corner,t_perform2corner);
719#endif
720 }
721 }
722 break;
723 case 3 :
724 {
725 if(nba>3){
726#ifdef DEB //perf
727 ChFi3d_InitChron(cl_performmore3corner);
728#endif
729 PerformMoreThreeCorner(Index, i);
730#ifdef DEB //perf
731 ChFi3d_ResultChron(cl_performmore3corner,t_performmore3corner);
732#endif
733 }
734 else {
735#ifdef DEB //perf
736 ChFi3d_InitChron(cl_perform3corner);
737#endif
738 PerformThreeCorner(Index);
739#ifdef DEB //perf
740 ChFi3d_ResultChron(cl_perform3corner,t_perform3corner);
741#endif
742 }
743 }
744 break;
745 default : {
746#ifdef DEB //perf
747 ChFi3d_InitChron(cl_performmore3corner);
748#endif
749 PerformMoreThreeCorner(Index, i);
750#ifdef DEB //perf
751 ChFi3d_ResultChron(cl_performmore3corner,t_performmore3corner);
752#endif
753 }
754 }
755 }
756 else { // Traitement des cas singulier
757 if (toujoursdegenere) PerformSingularCorner(Index);
758 else PerformMoreThreeCorner(Index, i);//Derniere chance...
759 }
760}
761
762
763//=======================================================================
764//function : Reset
765//purpose :
766//=======================================================================
767
768void ChFi3d_Builder::Reset()
769{
770 done = Standard_False;
771 myVDataMap.Clear();
772 myRegul.Clear();
773 myEVIMap.Clear();
774 badstripes.Clear();
775 badvertices.Clear();
776
777 ChFiDS_ListIteratorOfListOfStripe itel;
778 for (itel.Initialize(myListStripe); itel.More(); ){
779 if(!itel.Value()->Spine().IsNull()){
780 itel.Value()->Reset();
781 itel.Next();
782 }
783 else myListStripe.Remove(itel);
784 }
785}
786
787//=======================================================================
788//function : Generated
789//purpose :
790//=======================================================================
791
792const TopTools_ListOfShape& ChFi3d_Builder::Generated(const TopoDS_Shape& EouV)
793{
794 myGenerated.Clear();
795 if(EouV.IsNull()) return myGenerated;
796 if(EouV.ShapeType() != TopAbs_EDGE &&
797 EouV.ShapeType() != TopAbs_VERTEX) return myGenerated;
798 if(myEVIMap.IsBound(EouV)) {
799 const TColStd_ListOfInteger& L = myEVIMap.Find(EouV);
800 TColStd_ListIteratorOfListOfInteger IL;
801 for(IL.Initialize(L); IL.More(); IL.Next()){
802 Standard_Integer I = IL.Value();
803 const TopTools_ListOfShape& LS = myCoup->NewFaces(I);
804 TopTools_ListIteratorOfListOfShape ILS;
805 for(ILS.Initialize(LS); ILS.More(); ILS.Next()){
806 myGenerated.Append(ILS.Value());
807 }
808 }
809 }
810 return myGenerated;
811}
812
813