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()) |
9775fa61 |
233 | throw Standard_Failure("There are no suitable edges for chamfer or fillet"); |
7fd59977 |
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 | } |
9775fa61 |
275 | catch(Standard_Failure const& anException) { |
0797d9d3 |
276 | #ifdef OCCT_DEBUG |
9775fa61 |
277 | cout <<"EXCEPTION Stripe compute " << anException << endl; |
7fd59977 |
278 | #endif |
9775fa61 |
279 | (void)anException; |
7fd59977 |
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 | } |
9775fa61 |
305 | catch(Standard_Failure const& anException) { |
0797d9d3 |
306 | #ifdef OCCT_DEBUG |
9775fa61 |
307 | cout <<"EXCEPTION Corner compute " << anException << endl; |
7fd59977 |
308 | #endif |
9775fa61 |
309 | (void)anException; |
7a06c690 |
310 | badvertices.Append(myVDataMap.FindKey(j)); |
7fd59977 |
311 | hasresult=Standard_False; |
7a06c690 |
312 | done = Standard_True; |
7fd59977 |
313 | } |
314 | if (!done) badvertices.Append(myVDataMap.FindKey(j)); |
315 | done = Standard_True; |
316 | } |
7a06c690 |
317 | if (!hasresult) done = badvertices.IsEmpty(); |
7fd59977 |
318 | } |
319 | |
320 | |
0797d9d3 |
321 | #ifdef OCCT_DEBUG //perf |
7fd59977 |
322 | ChFi3d_ResultChron(cl_perffilletonvertex,t_perffilletonvertex); |
323 | ChFi3d_InitChron(cl_filds); |
324 | #endif |
325 | |
326 | TColStd_MapOfInteger MapIndSo; |
327 | TopExp_Explorer expso(myShape,TopAbs_SOLID); |
328 | for(; expso.More(); expso.Next()){ |
329 | const TopoDS_Shape& cursol = expso.Current(); |
330 | Standard_Integer indcursol = DStr.AddShape(cursol); |
331 | MapIndSo.Add(indcursol); |
332 | } |
333 | TopExp_Explorer expsh(myShape,TopAbs_SHELL,TopAbs_SOLID); |
334 | for(; expsh.More(); expsh.Next()){ |
335 | const TopoDS_Shape& cursh = expsh.Current(); |
336 | Standard_Integer indcursh = DStr.AddShape(cursh); |
337 | MapIndSo.Add(indcursh); |
338 | } |
339 | if (done) { |
340 | Standard_Integer i1; |
341 | for (itel.Initialize(myListStripe), i1=0; |
342 | itel.More(); |
343 | itel.Next(), i1++) { |
344 | const Handle(ChFiDS_Stripe)& st = itel.Value(); |
345 | // 05/02/02 akm vvv : (OCC119) First we'll check ain't there |
346 | // intersections between fillets |
347 | ChFiDS_ListIteratorOfListOfStripe itel1; |
348 | Standard_Integer i2; |
349 | for (itel1.Initialize(myListStripe), i2=0; |
350 | itel1.More(); |
351 | itel1.Next(), i2++) { |
352 | if (i2 <= i1) |
353 | // Do not twice intersect the stripes |
354 | continue; |
355 | Handle(ChFiDS_Stripe) aCheckStripe = itel1.Value(); |
356 | try { |
357 | OCC_CATCH_SIGNALS |
358 | ChFi3d_StripeEdgeInter (st, aCheckStripe, DStr, tol2d); |
359 | } |
9775fa61 |
360 | catch(Standard_Failure const& anException) { |
0797d9d3 |
361 | #ifdef OCCT_DEBUG |
9775fa61 |
362 | cout <<"EXCEPTION Fillets compute " << anException << endl; |
7fd59977 |
363 | #endif |
9775fa61 |
364 | (void)anException; |
7fd59977 |
365 | badstripes.Append(itel.Value()); |
366 | hasresult=Standard_False; |
367 | done = Standard_False; |
368 | break; |
369 | } |
370 | } |
371 | // 05/02/02 akm ^^^ |
372 | Standard_Integer solidindex = st->SolidIndex(); |
373 | ChFi3d_FilDS(solidindex,st,DStr,myRegul,tolesp,tol2d); |
374 | if (!done) break; |
375 | } |
376 | |
0797d9d3 |
377 | #ifdef OCCT_DEBUG //perf |
7fd59977 |
378 | ChFi3d_ResultChron(cl_filds,t_filds); |
379 | ChFi3d_InitChron(cl_reconstruction); |
380 | #endif |
381 | |
382 | |
383 | if (done) { |
384 | BRep_Builder B1; |
385 | CompleteDS(DStr,myShape); |
81bba717 |
386 | //Update tolerances on vertex to max adjacent edges or |
387 | //Update tolerances on degenerated edge to max of adjacent vertexes. |
7fd59977 |
388 | TopOpeBRepDS_CurveExplorer cex(DStr); |
389 | for(;cex.More();cex.Next()){ |
390 | TopOpeBRepDS_Curve& c = *((TopOpeBRepDS_Curve*)(void*)&(cex.Curve())); |
391 | Standard_Real tolc = 0.; |
392 | Standard_Boolean degen = c.Curve().IsNull(); |
393 | if(!degen) tolc = c.Tolerance(); |
394 | Standard_Integer ic = cex.Index(); |
395 | TopOpeBRepDS_PointIterator It(myDS->CurvePoints(ic)); |
396 | for(;It.More();It.Next()){ |
397 | Handle(TopOpeBRepDS_CurvePointInterference) II; |
398 | II = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(It.Value()); |
399 | if (II.IsNull()) continue; |
400 | TopOpeBRepDS_Kind gk = II->GeometryType(); |
401 | Standard_Integer gi = II->Geometry(); |
402 | if(gk == TopOpeBRepDS_VERTEX){ |
403 | const TopoDS_Vertex& v = TopoDS::Vertex(myDS->Shape(gi)); |
404 | Standard_Real tolv = BRep_Tool::Tolerance(v); |
405 | if( tolv > 0.0001 ) { |
406 | tolv += 0.0003; |
407 | if( tolc < tolv ) tolc = tolv + 0.00001; |
408 | } |
409 | if(degen && tolc < tolv) tolc = tolv; |
410 | else if(tolc>tolv) B1.UpdateVertex(v,tolc); |
411 | } |
412 | else if(gk == TopOpeBRepDS_POINT){ |
413 | TopOpeBRepDS_Point& p = DStr.ChangePoint(gi); |
414 | Standard_Real tolp = p.Tolerance(); |
415 | if(degen && tolc < tolp) tolc = tolp; |
416 | else if(tolc>tolp) p.Tolerance(tolc); |
417 | } |
418 | } |
419 | if(degen) c.Tolerance(tolc); |
420 | } |
421 | myCoup->Perform(myDS); |
422 | TColStd_MapIteratorOfMapOfInteger It(MapIndSo); |
423 | for(; It.More(); It.Next()){ |
424 | Standard_Integer indsol = It.Key(); |
425 | const TopoDS_Shape& curshape = DStr.Shape(indsol); |
426 | myCoup->MergeSolid(curshape,TopAbs_IN); |
427 | } |
428 | |
429 | Standard_Integer i=1,n=DStr.NbShapes(); |
430 | for (;i<=n;i++) { |
431 | const TopoDS_Shape S = DStr.Shape(i); |
432 | if (S.ShapeType() != TopAbs_EDGE) continue; |
433 | Standard_Boolean issplitIN = myCoup->IsSplit(S,TopAbs_IN); |
434 | if ( !issplitIN ) continue; |
435 | TopTools_ListIteratorOfListOfShape it(myCoup->Splits(S,TopAbs_IN)); |
436 | for (; it.More(); it.Next() ) { |
437 | const TopoDS_Edge& newE = TopoDS::Edge(it.Value()); |
438 | Standard_Real tole = BRep_Tool::Tolerance(newE); |
439 | TopExp_Explorer exv(newE,TopAbs_VERTEX); |
440 | for (; exv.More(); exv.Next() ) { |
441 | const TopoDS_Vertex& v = TopoDS::Vertex(exv.Current()); |
442 | Standard_Real tolv = BRep_Tool::Tolerance(v); |
443 | if (tole>tolv) B1.UpdateVertex(v,tole); |
444 | } |
445 | } |
446 | } |
447 | if (!hasresult) { |
448 | B1.MakeCompound(TopoDS::Compound(myShapeResult)); |
449 | for(It.Reset(); It.More(); It.Next()){ |
450 | Standard_Integer indsol = It.Key(); |
451 | const TopoDS_Shape& curshape = DStr.Shape(indsol); |
452 | TopTools_ListIteratorOfListOfShape |
453 | its = myCoup->Merged(curshape,TopAbs_IN); |
454 | if(!its.More()) B1.Add(myShapeResult,curshape); |
455 | else { |
81bba717 |
456 | //If the old type of Shape is Shell, Shell is placed instead of Solid, |
457 | //However there is a problem for compound of open Shell. |
7fd59977 |
458 | while (its.More()) { |
459 | const TopAbs_ShapeEnum letype = curshape.ShapeType(); |
460 | if (letype == TopAbs_SHELL){ |
461 | TopExp_Explorer expsh2(its.Value(),TopAbs_SHELL); |
462 | const TopoDS_Shape& cursh = expsh2.Current(); |
463 | TopoDS_Shape tt = cursh; |
464 | B1.Add(myShapeResult,cursh); |
465 | its.Next(); |
466 | } |
467 | else { |
468 | B1.Add(myShapeResult,its.Value()); |
469 | its.Next(); |
470 | } |
471 | } |
472 | } |
473 | } |
474 | } |
475 | else { |
476 | done=Standard_False; |
477 | B1.MakeCompound(TopoDS::Compound(badShape)); |
478 | for(It.Reset(); It.More(); It.Next()){ |
479 | Standard_Integer indsol = It.Key(); |
480 | const TopoDS_Shape& curshape = DStr.Shape(indsol); |
481 | TopTools_ListIteratorOfListOfShape |
482 | its = myCoup->Merged(curshape,TopAbs_IN); |
483 | if(!its.More()) B1.Add(badShape,curshape); |
484 | else { |
485 | while (its.More()) { |
486 | B1.Add(badShape,its.Value()); |
487 | its.Next(); |
488 | } |
489 | } |
490 | } |
491 | } |
0797d9d3 |
492 | #ifdef OCCT_DEBUG //perf |
7fd59977 |
493 | ChFi3d_ResultChron(cl_reconstruction ,t_reconstruction); |
494 | ChFi3d_InitChron(cl_setregul); |
495 | #endif |
496 | |
81bba717 |
497 | // Regularities are coded after cutting. |
7fd59977 |
498 | SetRegul(); |
499 | |
500 | |
0797d9d3 |
501 | #ifdef OCCT_DEBUG //perf |
7fd59977 |
502 | ChFi3d_ResultChron(cl_setregul ,t_setregul); |
503 | #endif |
504 | } |
505 | } |
0797d9d3 |
506 | #ifdef OCCT_DEBUG //perf |
7fd59977 |
507 | ChFi3d_ResultChron(cl_total,t_total); |
508 | #endif |
509 | |
510 | |
81bba717 |
511 | // display of time for perfs |
7fd59977 |
512 | |
0797d9d3 |
513 | #ifdef OCCT_DEBUG |
7fd59977 |
514 | if(ChFi3d_GettraceCHRON()){ |
63c629aa |
515 | cout<<endl; |
516 | cout<<"COMPUTE: temps total "<<t_total<<"s dont :"<<endl; |
517 | cout<<"- Init + ExtentAnalyse "<<t_extent<<"s"<<endl; |
518 | cout<<"- PerformSetOfSurf "<<t_perfsetofsurf<<"s"<<endl; |
519 | cout<<"- PerformFilletOnVertex "<<t_perffilletonvertex<<"s"<<endl; |
520 | cout<<"- FilDS "<<t_filds<<"s"<<endl; |
521 | cout<<"- Reconstruction "<<t_reconstruction<<"s"<<endl; |
522 | cout<<"- SetRegul "<<t_setregul<<"s"<<endl<<endl; |
523 | |
7fd59977 |
524 | cout<<endl; |
525 | cout <<"temps PERFORMSETOFSURF "<<t_perfsetofsurf <<"s dont : "<<endl; |
526 | cout <<"- SetofKPart "<<t_perfsetofkpart<<"s"<<endl; |
527 | cout <<"- SetofKGen "<< t_perfsetofkgen <<"s"<<endl; |
528 | cout <<"- MakeExtremities "<<t_makextremities<<"s"<<endl<<endl; |
529 | |
530 | |
531 | cout <<"temps SETOFKGEN "<< t_perfsetofkgen<<"s dont : "<<endl; |
532 | cout<<"- PerformSurf "<<t_performsurf<<"s"<<endl; |
533 | cout<<"- starsol "<< t_startsol <<"s"<<endl<<endl; |
534 | |
535 | cout<<"temps PERFORMSURF "<<t_performsurf<<"s dont : " << endl; |
536 | cout<<"- computedata "<<t_computedata<<"s"<<endl; |
537 | cout<<"- completedata "<<t_completedata<<"s"<<endl<<endl; |
538 | |
539 | |
540 | cout<<"temps PERFORMFILLETVERTEX "<<t_perffilletonvertex <<"s dont : " << endl; |
541 | cout<<"- PerformOneCorner "<<t_perform1corner<<"s"<<endl; |
542 | cout<<"- PerformIntersectionAtEnd "<<t_performatend<<"s"<<endl; |
543 | cout<<"- PerformTwoCorner "<<t_perform2corner<<"s"<<endl; |
544 | cout<<"- PerformThreeCorner "<<t_perform3corner<<"s"<<endl; |
545 | cout<<"- PerformMoreThreeCorner "<<t_performmore3corner<<"s"<<endl<<endl; |
546 | |
547 | |
548 | cout<<"temps PerformOneCorner "<<t_perform1corner<<"s dont:"<<endl; |
549 | cout<<"- temps condition if (same) "<<t_same << "s "<<endl; |
550 | cout<<"- temps condition if (inter) "<<t_inter<<"s " <<endl; |
551 | cout<<"- temps condition if (same inter) "<<t_sameinter<<"s " <<endl<<endl; |
552 | |
553 | cout<<"temps PerformTwocorner "<<t_perform2corner<<"s dont:"<<endl; |
554 | cout<<"- temps initialisation "<< t_t2cornerinit<<"s"<<endl; |
555 | cout<<"- temps PerformTwoCornerbyInter "<<t_perf2cornerbyinter<<"s"<<endl; |
556 | cout<<"- temps ChFiKPart_ComputeData "<<t_chfikpartcompdata <<"s"<<endl; |
557 | cout<<"- temps cheminement "<<t_cheminement<<"s"<<endl; |
558 | cout<<"- temps remplissage "<<t_remplissage<<"s"<<endl; |
559 | cout<<"- temps mise a jour stripes "<<t_t2cornerDS<<"s"<<endl<<endl; |
560 | |
561 | cout<<" temps PerformThreecorner "<<t_perform3corner<<"s dont:"<<endl; |
562 | cout<<"- temps initialisation "<< t_t3cornerinit<<"s"<<endl; |
563 | cout<<"- temps cas spherique "<<t_spherique<<"s"<<endl; |
564 | cout<<"- temps cas torique "<<t_torique<<"s"<<endl; |
565 | cout<<"- temps notfilling "<<t_notfilling<<"s"<<endl; |
566 | cout<<"- temps filling "<<t_filling<<"s"<<endl; |
567 | cout<<"- temps mise a jour stripes "<<t_t3cornerDS<<"s"<<endl<<endl; |
568 | |
569 | cout<<"temps PerformMore3Corner "<<t_performmore3corner<<"s dont:"<<endl; |
570 | cout<<"-temps plate "<<t_plate << "s "<<endl; |
571 | cout<<"-temps approxplate "<<t_approxplate<<"s " <<endl; |
572 | cout<<"-temps batten "<< t_batten<<"s " <<endl<<endl; |
573 | |
574 | cout <<"TEMPS DIVERS "<<endl; |
575 | cout<<"-temps ChFi3d_sameparameter "<<t_sameparam<<"s"<<endl<<endl; |
576 | } |
577 | #endif |
cfb6776e |
578 | // |
579 | // Inspect the new faces to provide sameparameter |
580 | // if it is necessary |
581 | if (IsDone()) |
582 | { |
583 | Standard_Real SameParTol = Precision::Confusion(); |
584 | Standard_Integer aNbSurfaces, iF; |
585 | TopTools_ListIteratorOfListOfShape aIt; |
586 | // |
587 | aNbSurfaces=myDS->NbSurfaces(); |
588 | |
589 | for (iF=1; iF<=aNbSurfaces; ++iF) { |
590 | const TopTools_ListOfShape& aLF=myCoup->NewFaces(iF); |
591 | aIt.Initialize(aLF); |
592 | for (; aIt.More(); aIt.Next()) { |
593 | const TopoDS_Shape& aF=aIt.Value(); |
594 | BRepLib::SameParameter(aF, SameParTol, Standard_True); |
595 | ShapeFix::SameParameter(aF, Standard_False, SameParTol); |
596 | } |
597 | } |
598 | } |
7fd59977 |
599 | } |
600 | |
601 | //======================================================================= |
602 | //function : PerformSingularCorner |
81bba717 |
603 | //purpose : Load vertex and degenerated edges. |
7fd59977 |
604 | //======================================================================= |
605 | |
606 | void ChFi3d_Builder::PerformSingularCorner |
607 | (const Standard_Integer Index){ |
608 | ChFiDS_ListIteratorOfListOfStripe It; |
609 | Handle(ChFiDS_Stripe) stripe; |
610 | TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS(); |
611 | const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Index); |
612 | |
613 | Handle(ChFiDS_SurfData) Fd; |
614 | Standard_Integer i, Icurv; |
7fd59977 |
615 | Standard_Integer Ivtx = 0; |
7fd59977 |
616 | for (It.Initialize(myVDataMap(Index)), i=0; It.More(); It.Next(),i++){ |
617 | stripe = It.Value(); |
81bba717 |
618 | // SurfData concerned and its CommonPoints, |
7fd59977 |
619 | Standard_Integer sens = 0; |
620 | Standard_Integer num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens); |
621 | Standard_Boolean isfirst = (sens == 1); |
622 | Fd = stripe->SetOfSurfData()->Sequence().Value(num); |
623 | const ChFiDS_CommonPoint& CV1 = Fd->Vertex(isfirst,1); |
624 | const ChFiDS_CommonPoint& CV2 = Fd->Vertex(isfirst,2); |
81bba717 |
625 | // Is it always degenerated ? |
7fd59977 |
626 | if ( CV1.Point().IsEqual( CV2.Point(), 0) ) { |
81bba717 |
627 | // if yes the vertex is stored in the stripe |
628 | // and the edge at end is created |
7fd59977 |
629 | if (i==0) Ivtx = ChFi3d_IndexPointInDS(CV1, DStr); |
630 | Standard_Real tolreached; |
631 | Standard_Real Pardeb, Parfin; |
632 | gp_Pnt2d VOnS1, VOnS2; |
633 | Handle(Geom_Curve) C3d; |
634 | Handle(Geom2d_Curve) PCurv; |
635 | TopOpeBRepDS_Curve Crv; |
636 | if (isfirst) { |
637 | VOnS1 = Fd->InterferenceOnS1().PCurveOnSurf()-> |
638 | Value(Fd->InterferenceOnS1().FirstParameter()); |
639 | VOnS2 = Fd->InterferenceOnS2().PCurveOnSurf()-> |
640 | Value(Fd->InterferenceOnS2().FirstParameter()); |
641 | } |
642 | else { |
643 | VOnS1 = Fd->InterferenceOnS1().PCurveOnSurf()-> |
644 | Value(Fd->InterferenceOnS1().LastParameter()); |
645 | VOnS2 = Fd->InterferenceOnS2().PCurveOnSurf()-> |
646 | Value(Fd->InterferenceOnS2().LastParameter()); |
647 | } |
648 | |
649 | ChFi3d_ComputeArete(CV1, VOnS1, |
650 | CV2, VOnS2, |
651 | DStr.Surface(Fd->Surf()).Surface(), |
652 | C3d, PCurv, |
653 | Pardeb,Parfin,tolapp3d,tolapp2d,tolreached,0); |
654 | Crv = TopOpeBRepDS_Curve(C3d,tolreached); |
655 | Icurv = DStr.AddCurve(Crv); |
656 | |
657 | stripe->SetCurve(Icurv, isfirst); |
658 | stripe->SetParameters(isfirst, Pardeb,Parfin); |
659 | stripe->ChangePCurve(isfirst) = PCurv; |
660 | stripe->SetIndexPoint(Ivtx, isfirst, 1); |
661 | stripe->SetIndexPoint(Ivtx, isfirst, 2); |
662 | } |
663 | } |
664 | } |
665 | |
666 | //======================================================================= |
667 | //function : PerformFilletOnVertex |
668 | //purpose : |
669 | //======================================================================= |
670 | |
671 | void ChFi3d_Builder::PerformFilletOnVertex |
672 | (const Standard_Integer Index){ |
673 | |
674 | ChFiDS_ListIteratorOfListOfStripe It; |
675 | Handle(ChFiDS_Stripe) stripe; |
676 | Handle(ChFiDS_Spine) sp; |
677 | const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Index); |
678 | |
679 | Handle(ChFiDS_SurfData) Fd; |
680 | Standard_Integer i; |
681 | Standard_Boolean nondegenere = Standard_True; |
682 | Standard_Boolean toujoursdegenere = Standard_True; |
7fd59977 |
683 | Standard_Boolean isfirst = Standard_False; |
7fd59977 |
684 | for (It.Initialize(myVDataMap(Index)), i=0; It.More(); It.Next(),i++){ |
685 | stripe = It.Value(); |
686 | sp = stripe->Spine(); |
81bba717 |
687 | // SurfData and its CommonPoints, |
7fd59977 |
688 | Standard_Integer sens = 0; |
689 | Standard_Integer num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens); |
690 | isfirst = (sens == 1); |
691 | Fd = stripe->SetOfSurfData()->Sequence().Value(num); |
692 | const ChFiDS_CommonPoint& CV1 = Fd->Vertex(isfirst,1); |
693 | const ChFiDS_CommonPoint& CV2 = Fd->Vertex(isfirst,2); |
81bba717 |
694 | // Is it always degenerated ? |
7fd59977 |
695 | if ( CV1.Point().IsEqual( CV2.Point(), 0) ) |
696 | nondegenere = Standard_False; |
697 | else toujoursdegenere = Standard_False; |
698 | } |
699 | |
700 | // calcul du nombre de faces = nombre d'aretes |
701 | /* TopTools_ListIteratorOfListOfShape ItF,JtF,ItE; |
702 | Standard_Integer nbf = 0, jf = 0; |
703 | for (ItF.Initialize(myVFMap(Vtx)); ItF.More(); ItF.Next()){ |
704 | jf++; |
705 | Standard_Integer kf = 1; |
706 | const TopoDS_Shape& cur = ItF.Value(); |
707 | for (JtF.Initialize(myVFMap(Vtx)); JtF.More() && (kf < jf); JtF.Next(), kf++){ |
708 | if(cur.IsSame(JtF.Value())) break; |
709 | } |
710 | if(kf == jf) nbf++; |
711 | } |
712 | Standard_Integer nba=myVEMap(Vtx).Extent(); |
713 | for (ItE.Initialize(myVEMap(Vtx)); ItE.More(); ItE.Next()){ |
714 | const TopoDS_Edge& cur = TopoDS::Edge(ItE.Value()); |
715 | if (BRep_Tool::Degenerated(cur)) nba--; |
716 | } |
717 | nba=nba/2;*/ |
7d92212e |
718 | Standard_Integer nba = ChFi3d_NumberOfSharpEdges(Vtx, myVEMap, myEFMap); |
7fd59977 |
719 | |
81bba717 |
720 | if (nondegenere) { // Normal processing |
7fd59977 |
721 | switch (i) { |
722 | case 1 : |
723 | { |
724 | if(sp->Status(isfirst) == ChFiDS_FreeBoundary) return; |
725 | if(nba>3) { |
0797d9d3 |
726 | #ifdef OCCT_DEBUG //perf |
7fd59977 |
727 | ChFi3d_InitChron(cl_performatend); |
728 | #endif |
729 | PerformIntersectionAtEnd(Index); |
0797d9d3 |
730 | #ifdef OCCT_DEBUG |
7fd59977 |
731 | ChFi3d_ResultChron(cl_performatend,t_performatend); |
732 | #endif |
733 | } |
734 | else { |
0797d9d3 |
735 | #ifdef OCCT_DEBUG //perf |
7fd59977 |
736 | ChFi3d_InitChron(cl_perform1corner); |
737 | #endif |
738 | if (MoreSurfdata(Index)) |
739 | PerformMoreSurfdata(Index); |
740 | else PerformOneCorner(Index); |
0797d9d3 |
741 | #ifdef OCCT_DEBUG //perf |
7fd59977 |
742 | ChFi3d_ResultChron(cl_perform1corner,t_perform1corner); |
743 | #endif |
744 | } |
745 | } |
746 | break; |
747 | case 2 : |
748 | { |
749 | if(nba>3){ |
0797d9d3 |
750 | #ifdef OCCT_DEBUG //perf |
7fd59977 |
751 | ChFi3d_InitChron(cl_performmore3corner); |
752 | #endif |
753 | PerformMoreThreeCorner(Index, i); |
0797d9d3 |
754 | #ifdef OCCT_DEBUG //perf |
7fd59977 |
755 | ChFi3d_ResultChron(cl_performmore3corner,t_performmore3corner); |
756 | #endif |
757 | } |
758 | else { |
0797d9d3 |
759 | #ifdef OCCT_DEBUG //perf |
7fd59977 |
760 | ChFi3d_InitChron(cl_perform2corner); |
761 | #endif |
762 | PerformTwoCorner(Index); |
0797d9d3 |
763 | #ifdef OCCT_DEBUG //perf |
7fd59977 |
764 | ChFi3d_ResultChron(cl_perform2corner,t_perform2corner); |
765 | #endif |
766 | } |
767 | } |
768 | break; |
769 | case 3 : |
770 | { |
771 | if(nba>3){ |
0797d9d3 |
772 | #ifdef OCCT_DEBUG //perf |
7fd59977 |
773 | ChFi3d_InitChron(cl_performmore3corner); |
774 | #endif |
775 | PerformMoreThreeCorner(Index, i); |
0797d9d3 |
776 | #ifdef OCCT_DEBUG //perf |
7fd59977 |
777 | ChFi3d_ResultChron(cl_performmore3corner,t_performmore3corner); |
778 | #endif |
779 | } |
780 | else { |
0797d9d3 |
781 | #ifdef OCCT_DEBUG //perf |
7fd59977 |
782 | ChFi3d_InitChron(cl_perform3corner); |
783 | #endif |
784 | PerformThreeCorner(Index); |
0797d9d3 |
785 | #ifdef OCCT_DEBUG //perf |
7fd59977 |
786 | ChFi3d_ResultChron(cl_perform3corner,t_perform3corner); |
787 | #endif |
788 | } |
789 | } |
790 | break; |
791 | default : { |
0797d9d3 |
792 | #ifdef OCCT_DEBUG //perf |
7fd59977 |
793 | ChFi3d_InitChron(cl_performmore3corner); |
794 | #endif |
795 | PerformMoreThreeCorner(Index, i); |
0797d9d3 |
796 | #ifdef OCCT_DEBUG //perf |
7fd59977 |
797 | ChFi3d_ResultChron(cl_performmore3corner,t_performmore3corner); |
798 | #endif |
799 | } |
800 | } |
801 | } |
81bba717 |
802 | else { // Single case processing |
7fd59977 |
803 | if (toujoursdegenere) PerformSingularCorner(Index); |
81bba717 |
804 | else PerformMoreThreeCorner(Index, i);//Last chance... |
7fd59977 |
805 | } |
806 | } |
807 | |
808 | |
809 | //======================================================================= |
810 | //function : Reset |
811 | //purpose : |
812 | //======================================================================= |
813 | |
814 | void ChFi3d_Builder::Reset() |
815 | { |
816 | done = Standard_False; |
817 | myVDataMap.Clear(); |
818 | myRegul.Clear(); |
819 | myEVIMap.Clear(); |
820 | badstripes.Clear(); |
821 | badvertices.Clear(); |
822 | |
823 | ChFiDS_ListIteratorOfListOfStripe itel; |
824 | for (itel.Initialize(myListStripe); itel.More(); ){ |
825 | if(!itel.Value()->Spine().IsNull()){ |
826 | itel.Value()->Reset(); |
827 | itel.Next(); |
828 | } |
829 | else myListStripe.Remove(itel); |
830 | } |
831 | } |
832 | |
833 | //======================================================================= |
834 | //function : Generated |
835 | //purpose : |
836 | //======================================================================= |
837 | |
838 | const TopTools_ListOfShape& ChFi3d_Builder::Generated(const TopoDS_Shape& EouV) |
839 | { |
840 | myGenerated.Clear(); |
841 | if(EouV.IsNull()) return myGenerated; |
842 | if(EouV.ShapeType() != TopAbs_EDGE && |
843 | EouV.ShapeType() != TopAbs_VERTEX) return myGenerated; |
844 | if(myEVIMap.IsBound(EouV)) { |
845 | const TColStd_ListOfInteger& L = myEVIMap.Find(EouV); |
846 | TColStd_ListIteratorOfListOfInteger IL; |
847 | for(IL.Initialize(L); IL.More(); IL.Next()){ |
848 | Standard_Integer I = IL.Value(); |
849 | const TopTools_ListOfShape& LS = myCoup->NewFaces(I); |
850 | TopTools_ListIteratorOfListOfShape ILS; |
851 | for(ILS.Initialize(LS); ILS.More(); ILS.Next()){ |
852 | myGenerated.Append(ILS.Value()); |
853 | } |
854 | } |
855 | } |
856 | return myGenerated; |
857 | } |
858 | |
859 | |