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