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