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 | |
81bba717 |
60 | // variables for performances |
7fd59977 |
61 | |
62 | |
63 | OSD_Chronometer cl_total,cl_extent,cl_perfsetofsurf,cl_perffilletonvertex, |
64 | cl_filds,cl_reconstruction,cl_setregul,cl_perform1corner,cl_perform2corner, |
65 | cl_performatend,cl_perform3corner,cl_performmore3corner; |
66 | |
67 | Standard_EXPORT Standard_Real t_total, t_extent,t_perfsetofsurf, |
68 | t_perffilletonvertex, t_filds,t_reconstruction,t_setregul, t_perfsetofkgen, |
69 | t_perfsetofkpart,t_makextremities,t_performatend,t_startsol,t_performsurf, |
70 | t_perform1corner,t_perform2corner,t_perform3corner,t_performmore3corner, |
71 | t_batten,t_inter,t_sameinter,t_same,t_plate,t_approxplate,t_t2cornerinit, |
72 | t_perf2cornerbyinter,t_chfikpartcompdata,t_cheminement,t_remplissage, |
73 | t_t3cornerinit ,t_spherique,t_torique, t_notfilling,t_filling,t_sameparam, |
74 | t_computedata,t_completedata,t_t2cornerDS,t_t3cornerDS; |
75 | |
76 | //Standard_IMPORT extern void ChFi3d_InitChron(OSD_Chronometer& ch); |
77 | Standard_IMPORT void ChFi3d_InitChron(OSD_Chronometer& ch); |
78 | //Standard_IMPORT extern void ChFi3d_ResultChron(OSD_Chronometer & ch, |
79 | Standard_IMPORT void ChFi3d_ResultChron(OSD_Chronometer & ch, |
80 | Standard_Real& time); |
81 | extern Standard_Boolean ChFi3d_GettraceCHRON(); |
82 | #endif |
83 | |
84 | |
85 | //======================================================================= |
86 | //function : CompleteDS |
87 | //purpose : |
88 | //======================================================================= |
89 | |
90 | static 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 | |
141 | void ChFi3d_Builder::Delete() |
142 | {} |
143 | |
144 | //======================================================================= |
145 | //function : ExtentAnalyse |
146 | //purpose : |
147 | //======================================================================= |
148 | |
149 | void 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 | |
179 | void 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 | |
81bba717 |
211 | // filling of myVDatatMap |
7fd59977 |
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 | } |
81bba717 |
224 | // preanalysis to evaluate the extensions. |
7fd59977 |
225 | ExtentAnalyse(); |
226 | |
227 | |
228 | #ifdef DEB //perf |
229 | ChFi3d_ResultChron(cl_extent,t_extent); |
230 | ChFi3d_InitChron(cl_perfsetofsurf); |
231 | #endif |
232 | |
81bba717 |
233 | // Construction of the stripe of fillet on each stripe. |
7fd59977 |
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 | |
81bba717 |
260 | //construct fillets on each vertex + feed the Ds |
7fd59977 |
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); |
81bba717 |
354 | //Update tolerances on vertex to max adjacent edges or |
355 | //Update tolerances on degenerated edge to max of adjacent vertexes. |
7fd59977 |
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 { |
81bba717 |
424 | //If the old type of Shape is Shell, Shell is placed instead of Solid, |
425 | //However there is a problem for compound of open Shell. |
7fd59977 |
426 | while (its.More()) { |
427 | const TopAbs_ShapeEnum letype = curshape.ShapeType(); |
428 | if (letype == TopAbs_SHELL){ |
429 | TopExp_Explorer expsh2(its.Value(),TopAbs_SHELL); |
430 | const TopoDS_Shape& cursh = expsh2.Current(); |
431 | TopoDS_Shape tt = cursh; |
432 | B1.Add(myShapeResult,cursh); |
433 | its.Next(); |
434 | } |
435 | else { |
436 | B1.Add(myShapeResult,its.Value()); |
437 | its.Next(); |
438 | } |
439 | } |
440 | } |
441 | } |
442 | } |
443 | else { |
444 | done=Standard_False; |
445 | B1.MakeCompound(TopoDS::Compound(badShape)); |
446 | for(It.Reset(); It.More(); It.Next()){ |
447 | Standard_Integer indsol = It.Key(); |
448 | const TopoDS_Shape& curshape = DStr.Shape(indsol); |
449 | TopTools_ListIteratorOfListOfShape |
450 | its = myCoup->Merged(curshape,TopAbs_IN); |
451 | if(!its.More()) B1.Add(badShape,curshape); |
452 | else { |
453 | while (its.More()) { |
454 | B1.Add(badShape,its.Value()); |
455 | its.Next(); |
456 | } |
457 | } |
458 | } |
459 | } |
460 | #ifdef DEB //perf |
461 | ChFi3d_ResultChron(cl_reconstruction ,t_reconstruction); |
462 | ChFi3d_InitChron(cl_setregul); |
463 | #endif |
464 | |
81bba717 |
465 | // Regularities are coded after cutting. |
7fd59977 |
466 | SetRegul(); |
467 | |
468 | |
469 | #ifdef DEB //perf |
470 | ChFi3d_ResultChron(cl_setregul ,t_setregul); |
471 | #endif |
472 | } |
473 | } |
474 | #ifdef DEB //perf |
475 | ChFi3d_ResultChron(cl_total,t_total); |
476 | #endif |
477 | |
478 | |
81bba717 |
479 | // display of time for perfs |
7fd59977 |
480 | |
481 | #ifdef DEB |
482 | cout<<endl; |
483 | cout<<"COMPUTE: temps total "<<t_total<<"s dont :"<<endl; |
484 | cout<<"- Init + ExtentAnalyse "<<t_extent<<"s"<<endl; |
485 | cout<<"- PerformSetOfSurf "<<t_perfsetofsurf<<"s"<<endl; |
486 | cout<<"- PerformFilletOnVertex "<<t_perffilletonvertex<<"s"<<endl; |
487 | cout<<"- FilDS "<<t_filds<<"s"<<endl; |
488 | cout<<"- Reconstruction "<<t_reconstruction<<"s"<<endl; |
489 | cout<<"- SetRegul "<<t_setregul<<"s"<<endl<<endl; |
490 | |
491 | if(ChFi3d_GettraceCHRON()){ |
492 | cout<<endl; |
493 | cout <<"temps PERFORMSETOFSURF "<<t_perfsetofsurf <<"s dont : "<<endl; |
494 | cout <<"- SetofKPart "<<t_perfsetofkpart<<"s"<<endl; |
495 | cout <<"- SetofKGen "<< t_perfsetofkgen <<"s"<<endl; |
496 | cout <<"- MakeExtremities "<<t_makextremities<<"s"<<endl<<endl; |
497 | |
498 | |
499 | cout <<"temps SETOFKGEN "<< t_perfsetofkgen<<"s dont : "<<endl; |
500 | cout<<"- PerformSurf "<<t_performsurf<<"s"<<endl; |
501 | cout<<"- starsol "<< t_startsol <<"s"<<endl<<endl; |
502 | |
503 | cout<<"temps PERFORMSURF "<<t_performsurf<<"s dont : " << endl; |
504 | cout<<"- computedata "<<t_computedata<<"s"<<endl; |
505 | cout<<"- completedata "<<t_completedata<<"s"<<endl<<endl; |
506 | |
507 | |
508 | cout<<"temps PERFORMFILLETVERTEX "<<t_perffilletonvertex <<"s dont : " << endl; |
509 | cout<<"- PerformOneCorner "<<t_perform1corner<<"s"<<endl; |
510 | cout<<"- PerformIntersectionAtEnd "<<t_performatend<<"s"<<endl; |
511 | cout<<"- PerformTwoCorner "<<t_perform2corner<<"s"<<endl; |
512 | cout<<"- PerformThreeCorner "<<t_perform3corner<<"s"<<endl; |
513 | cout<<"- PerformMoreThreeCorner "<<t_performmore3corner<<"s"<<endl<<endl; |
514 | |
515 | |
516 | cout<<"temps PerformOneCorner "<<t_perform1corner<<"s dont:"<<endl; |
517 | cout<<"- temps condition if (same) "<<t_same << "s "<<endl; |
518 | cout<<"- temps condition if (inter) "<<t_inter<<"s " <<endl; |
519 | cout<<"- temps condition if (same inter) "<<t_sameinter<<"s " <<endl<<endl; |
520 | |
521 | cout<<"temps PerformTwocorner "<<t_perform2corner<<"s dont:"<<endl; |
522 | cout<<"- temps initialisation "<< t_t2cornerinit<<"s"<<endl; |
523 | cout<<"- temps PerformTwoCornerbyInter "<<t_perf2cornerbyinter<<"s"<<endl; |
524 | cout<<"- temps ChFiKPart_ComputeData "<<t_chfikpartcompdata <<"s"<<endl; |
525 | cout<<"- temps cheminement "<<t_cheminement<<"s"<<endl; |
526 | cout<<"- temps remplissage "<<t_remplissage<<"s"<<endl; |
527 | cout<<"- temps mise a jour stripes "<<t_t2cornerDS<<"s"<<endl<<endl; |
528 | |
529 | cout<<" temps PerformThreecorner "<<t_perform3corner<<"s dont:"<<endl; |
530 | cout<<"- temps initialisation "<< t_t3cornerinit<<"s"<<endl; |
531 | cout<<"- temps cas spherique "<<t_spherique<<"s"<<endl; |
532 | cout<<"- temps cas torique "<<t_torique<<"s"<<endl; |
533 | cout<<"- temps notfilling "<<t_notfilling<<"s"<<endl; |
534 | cout<<"- temps filling "<<t_filling<<"s"<<endl; |
535 | cout<<"- temps mise a jour stripes "<<t_t3cornerDS<<"s"<<endl<<endl; |
536 | |
537 | cout<<"temps PerformMore3Corner "<<t_performmore3corner<<"s dont:"<<endl; |
538 | cout<<"-temps plate "<<t_plate << "s "<<endl; |
539 | cout<<"-temps approxplate "<<t_approxplate<<"s " <<endl; |
540 | cout<<"-temps batten "<< t_batten<<"s " <<endl<<endl; |
541 | |
542 | cout <<"TEMPS DIVERS "<<endl; |
543 | cout<<"-temps ChFi3d_sameparameter "<<t_sameparam<<"s"<<endl<<endl; |
544 | } |
545 | #endif |
546 | } |
547 | |
548 | //======================================================================= |
549 | //function : PerformSingularCorner |
81bba717 |
550 | //purpose : Load vertex and degenerated edges. |
7fd59977 |
551 | //======================================================================= |
552 | |
553 | void ChFi3d_Builder::PerformSingularCorner |
554 | (const Standard_Integer Index){ |
555 | ChFiDS_ListIteratorOfListOfStripe It; |
556 | Handle(ChFiDS_Stripe) stripe; |
557 | TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS(); |
558 | const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Index); |
559 | |
560 | Handle(ChFiDS_SurfData) Fd; |
561 | Standard_Integer i, Icurv; |
562 | #ifndef DEB |
563 | Standard_Integer Ivtx = 0; |
564 | #else |
565 | Standard_Integer Ivtx; |
566 | #endif |
567 | for (It.Initialize(myVDataMap(Index)), i=0; It.More(); It.Next(),i++){ |
568 | stripe = It.Value(); |
81bba717 |
569 | // SurfData concerned and its CommonPoints, |
7fd59977 |
570 | Standard_Integer sens = 0; |
571 | Standard_Integer num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens); |
572 | Standard_Boolean isfirst = (sens == 1); |
573 | Fd = stripe->SetOfSurfData()->Sequence().Value(num); |
574 | const ChFiDS_CommonPoint& CV1 = Fd->Vertex(isfirst,1); |
575 | const ChFiDS_CommonPoint& CV2 = Fd->Vertex(isfirst,2); |
81bba717 |
576 | // Is it always degenerated ? |
7fd59977 |
577 | if ( CV1.Point().IsEqual( CV2.Point(), 0) ) { |
81bba717 |
578 | // if yes the vertex is stored in the stripe |
579 | // and the edge at end is created |
7fd59977 |
580 | if (i==0) Ivtx = ChFi3d_IndexPointInDS(CV1, DStr); |
581 | Standard_Real tolreached; |
582 | Standard_Real Pardeb, Parfin; |
583 | gp_Pnt2d VOnS1, VOnS2; |
584 | Handle(Geom_Curve) C3d; |
585 | Handle(Geom2d_Curve) PCurv; |
586 | TopOpeBRepDS_Curve Crv; |
587 | if (isfirst) { |
588 | VOnS1 = Fd->InterferenceOnS1().PCurveOnSurf()-> |
589 | Value(Fd->InterferenceOnS1().FirstParameter()); |
590 | VOnS2 = Fd->InterferenceOnS2().PCurveOnSurf()-> |
591 | Value(Fd->InterferenceOnS2().FirstParameter()); |
592 | } |
593 | else { |
594 | VOnS1 = Fd->InterferenceOnS1().PCurveOnSurf()-> |
595 | Value(Fd->InterferenceOnS1().LastParameter()); |
596 | VOnS2 = Fd->InterferenceOnS2().PCurveOnSurf()-> |
597 | Value(Fd->InterferenceOnS2().LastParameter()); |
598 | } |
599 | |
600 | ChFi3d_ComputeArete(CV1, VOnS1, |
601 | CV2, VOnS2, |
602 | DStr.Surface(Fd->Surf()).Surface(), |
603 | C3d, PCurv, |
604 | Pardeb,Parfin,tolapp3d,tolapp2d,tolreached,0); |
605 | Crv = TopOpeBRepDS_Curve(C3d,tolreached); |
606 | Icurv = DStr.AddCurve(Crv); |
607 | |
608 | stripe->SetCurve(Icurv, isfirst); |
609 | stripe->SetParameters(isfirst, Pardeb,Parfin); |
610 | stripe->ChangePCurve(isfirst) = PCurv; |
611 | stripe->SetIndexPoint(Ivtx, isfirst, 1); |
612 | stripe->SetIndexPoint(Ivtx, isfirst, 2); |
613 | } |
614 | } |
615 | } |
616 | |
617 | //======================================================================= |
618 | //function : PerformFilletOnVertex |
619 | //purpose : |
620 | //======================================================================= |
621 | |
622 | void ChFi3d_Builder::PerformFilletOnVertex |
623 | (const Standard_Integer Index){ |
624 | |
625 | ChFiDS_ListIteratorOfListOfStripe It; |
626 | Handle(ChFiDS_Stripe) stripe; |
627 | Handle(ChFiDS_Spine) sp; |
628 | const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Index); |
629 | |
630 | Handle(ChFiDS_SurfData) Fd; |
631 | Standard_Integer i; |
632 | Standard_Boolean nondegenere = Standard_True; |
633 | Standard_Boolean toujoursdegenere = Standard_True; |
634 | #ifndef DEB |
635 | Standard_Boolean isfirst = Standard_False; |
636 | #else |
637 | Standard_Boolean isfirst; |
638 | #endif |
639 | for (It.Initialize(myVDataMap(Index)), i=0; It.More(); It.Next(),i++){ |
640 | stripe = It.Value(); |
641 | sp = stripe->Spine(); |
81bba717 |
642 | // SurfData and its CommonPoints, |
7fd59977 |
643 | Standard_Integer sens = 0; |
644 | Standard_Integer num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens); |
645 | isfirst = (sens == 1); |
646 | Fd = stripe->SetOfSurfData()->Sequence().Value(num); |
647 | const ChFiDS_CommonPoint& CV1 = Fd->Vertex(isfirst,1); |
648 | const ChFiDS_CommonPoint& CV2 = Fd->Vertex(isfirst,2); |
81bba717 |
649 | // Is it always degenerated ? |
7fd59977 |
650 | if ( CV1.Point().IsEqual( CV2.Point(), 0) ) |
651 | nondegenere = Standard_False; |
652 | else toujoursdegenere = Standard_False; |
653 | } |
654 | |
655 | // calcul du nombre de faces = nombre d'aretes |
656 | /* TopTools_ListIteratorOfListOfShape ItF,JtF,ItE; |
657 | Standard_Integer nbf = 0, jf = 0; |
658 | for (ItF.Initialize(myVFMap(Vtx)); ItF.More(); ItF.Next()){ |
659 | jf++; |
660 | Standard_Integer kf = 1; |
661 | const TopoDS_Shape& cur = ItF.Value(); |
662 | for (JtF.Initialize(myVFMap(Vtx)); JtF.More() && (kf < jf); JtF.Next(), kf++){ |
663 | if(cur.IsSame(JtF.Value())) break; |
664 | } |
665 | if(kf == jf) nbf++; |
666 | } |
667 | Standard_Integer nba=myVEMap(Vtx).Extent(); |
668 | for (ItE.Initialize(myVEMap(Vtx)); ItE.More(); ItE.Next()){ |
669 | const TopoDS_Edge& cur = TopoDS::Edge(ItE.Value()); |
670 | if (BRep_Tool::Degenerated(cur)) nba--; |
671 | } |
672 | nba=nba/2;*/ |
673 | Standard_Integer nba = ChFi3d_NumberOfEdges(Vtx, myVEMap); |
674 | |
81bba717 |
675 | if (nondegenere) { // Normal processing |
7fd59977 |
676 | switch (i) { |
677 | case 1 : |
678 | { |
679 | if(sp->Status(isfirst) == ChFiDS_FreeBoundary) return; |
680 | if(nba>3) { |
681 | #ifdef DEB //perf |
682 | ChFi3d_InitChron(cl_performatend); |
683 | #endif |
684 | PerformIntersectionAtEnd(Index); |
685 | #ifdef DEB |
686 | ChFi3d_ResultChron(cl_performatend,t_performatend); |
687 | #endif |
688 | } |
689 | else { |
690 | #ifdef DEB //perf |
691 | ChFi3d_InitChron(cl_perform1corner); |
692 | #endif |
693 | if (MoreSurfdata(Index)) |
694 | PerformMoreSurfdata(Index); |
695 | else PerformOneCorner(Index); |
696 | #ifdef DEB //perf |
697 | ChFi3d_ResultChron(cl_perform1corner,t_perform1corner); |
698 | #endif |
699 | } |
700 | } |
701 | break; |
702 | case 2 : |
703 | { |
704 | if(nba>3){ |
705 | #ifdef DEB //perf |
706 | ChFi3d_InitChron(cl_performmore3corner); |
707 | #endif |
708 | PerformMoreThreeCorner(Index, i); |
709 | #ifdef DEB //perf |
710 | ChFi3d_ResultChron(cl_performmore3corner,t_performmore3corner); |
711 | #endif |
712 | } |
713 | else { |
714 | #ifdef DEB //perf |
715 | ChFi3d_InitChron(cl_perform2corner); |
716 | #endif |
717 | PerformTwoCorner(Index); |
718 | #ifdef DEB //perf |
719 | ChFi3d_ResultChron(cl_perform2corner,t_perform2corner); |
720 | #endif |
721 | } |
722 | } |
723 | break; |
724 | case 3 : |
725 | { |
726 | if(nba>3){ |
727 | #ifdef DEB //perf |
728 | ChFi3d_InitChron(cl_performmore3corner); |
729 | #endif |
730 | PerformMoreThreeCorner(Index, i); |
731 | #ifdef DEB //perf |
732 | ChFi3d_ResultChron(cl_performmore3corner,t_performmore3corner); |
733 | #endif |
734 | } |
735 | else { |
736 | #ifdef DEB //perf |
737 | ChFi3d_InitChron(cl_perform3corner); |
738 | #endif |
739 | PerformThreeCorner(Index); |
740 | #ifdef DEB //perf |
741 | ChFi3d_ResultChron(cl_perform3corner,t_perform3corner); |
742 | #endif |
743 | } |
744 | } |
745 | break; |
746 | default : { |
747 | #ifdef DEB //perf |
748 | ChFi3d_InitChron(cl_performmore3corner); |
749 | #endif |
750 | PerformMoreThreeCorner(Index, i); |
751 | #ifdef DEB //perf |
752 | ChFi3d_ResultChron(cl_performmore3corner,t_performmore3corner); |
753 | #endif |
754 | } |
755 | } |
756 | } |
81bba717 |
757 | else { // Single case processing |
7fd59977 |
758 | if (toujoursdegenere) PerformSingularCorner(Index); |
81bba717 |
759 | else PerformMoreThreeCorner(Index, i);//Last chance... |
7fd59977 |
760 | } |
761 | } |
762 | |
763 | |
764 | //======================================================================= |
765 | //function : Reset |
766 | //purpose : |
767 | //======================================================================= |
768 | |
769 | void ChFi3d_Builder::Reset() |
770 | { |
771 | done = Standard_False; |
772 | myVDataMap.Clear(); |
773 | myRegul.Clear(); |
774 | myEVIMap.Clear(); |
775 | badstripes.Clear(); |
776 | badvertices.Clear(); |
777 | |
778 | ChFiDS_ListIteratorOfListOfStripe itel; |
779 | for (itel.Initialize(myListStripe); itel.More(); ){ |
780 | if(!itel.Value()->Spine().IsNull()){ |
781 | itel.Value()->Reset(); |
782 | itel.Next(); |
783 | } |
784 | else myListStripe.Remove(itel); |
785 | } |
786 | } |
787 | |
788 | //======================================================================= |
789 | //function : Generated |
790 | //purpose : |
791 | //======================================================================= |
792 | |
793 | const TopTools_ListOfShape& ChFi3d_Builder::Generated(const TopoDS_Shape& EouV) |
794 | { |
795 | myGenerated.Clear(); |
796 | if(EouV.IsNull()) return myGenerated; |
797 | if(EouV.ShapeType() != TopAbs_EDGE && |
798 | EouV.ShapeType() != TopAbs_VERTEX) return myGenerated; |
799 | if(myEVIMap.IsBound(EouV)) { |
800 | const TColStd_ListOfInteger& L = myEVIMap.Find(EouV); |
801 | TColStd_ListIteratorOfListOfInteger IL; |
802 | for(IL.Initialize(L); IL.More(); IL.Next()){ |
803 | Standard_Integer I = IL.Value(); |
804 | const TopTools_ListOfShape& LS = myCoup->NewFaces(I); |
805 | TopTools_ListIteratorOfListOfShape ILS; |
806 | for(ILS.Initialize(LS); ILS.More(); ILS.Next()){ |
807 | myGenerated.Append(ILS.Value()); |
808 | } |
809 | } |
810 | } |
811 | return myGenerated; |
812 | } |
813 | |
814 | |