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