1 // Created on: 1993-11-18
2 // Created by: Isabelle GRIGNON
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
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>
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>
54 #include <Standard_Failure.hxx>
55 #include <Standard_NoSuchObject.hxx>
56 #include <Standard_NotImplemented.hxx>
57 #include <Standard_OutOfRange.hxx>
58 #include <TColStd_ListIteratorOfListOfInteger.hxx>
59 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
60 #include <TColStd_MapOfInteger.hxx>
62 #include <TopAbs_Orientation.hxx>
63 #include <TopAbs_ShapeEnum.hxx>
65 #include <TopExp_Explorer.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>
74 #include <TopOpeBRepDS_CurveExplorer.hxx>
75 #include <TopOpeBRepDS_CurvePointInterference.hxx>
76 #include <TopOpeBRepDS_DataStructure.hxx>
77 #include <TopOpeBRepDS_HDataStructure.hxx>
78 #include <TopOpeBRepDS_ListOfInterference.hxx>
79 #include <TopOpeBRepDS_PointIterator.hxx>
80 #include <TopTools_ListIteratorOfListOfShape.hxx>
81 #include <TopTools_ListOfShape.hxx>
84 #include <TestTopOpeTools.hxx>
85 #include <TestTopOpe.hxx>
88 #include <OSD_Chronometer.hxx>
92 // variables for performances
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;
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;
108 extern void ChFi3d_InitChron(OSD_Chronometer& ch);
109 extern void ChFi3d_ResultChron(OSD_Chronometer & ch, Standard_Real& time);
110 extern Standard_Boolean ChFi3d_GettraceCHRON();
114 //=======================================================================
115 //function : CompleteDS
117 //=======================================================================
119 static void CompleteDS(TopOpeBRepDS_DataStructure& DStr,
120 const TopoDS_Shape& S)
122 ChFiDS_Map MapEW,MapFS;
123 MapEW.Fill(S,TopAbs_EDGE,TopAbs_WIRE);
124 MapFS.Fill(S,TopAbs_FACE,TopAbs_SHELL);
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);
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);
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);
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);
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);
163 Standard_Real par = it.Parameter();
164 parmin = Min (parmin,par); parmax = Max (parmax,par);
166 DStr.ChangeCurve(ic).SetRange(parmin,parmax);
170 //=======================================================================
171 //function : ~ChFi3d_Builder
173 //=======================================================================
175 ChFi3d_Builder::~ChFi3d_Builder()
178 //=======================================================================
179 //function : ExtentAnalyse
181 //=======================================================================
183 void ChFi3d_Builder::ExtentAnalyse ()
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);
189 //nbedges = ChFi3d_NumberOfEdges(Vtx, myVEMap);
190 nbedges = ChFi3d_NumberOfSharpEdges(Vtx, myVEMap, myEFMap);
193 ExtentOneCorner(Vtx, myVDataMap.FindFromIndex(iv).First());
197 ExtentTwoCorner(Vtx, myVDataMap.FindFromIndex(iv));
201 ExtentThreeCorner(Vtx, myVDataMap.FindFromIndex(iv));
209 //=======================================================================
212 //=======================================================================
214 void ChFi3d_Builder::Compute()
217 #ifdef OCCT_DEBUG //perf
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);
232 if (myListStripe.IsEmpty())
233 throw Standard_Failure("There are no suitable edges for chamfer or fillet");
236 myDS = new TopOpeBRepDS_HDataStructure();
237 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
238 done = Standard_True;
239 hasresult=Standard_False;
241 TestTopOpe::CurrentDS(myDS);
243 TestTopOpe::Shapes(myShape,bids);
246 // filling of myVDatatMap
247 ChFiDS_ListIteratorOfListOfStripe itel;
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());
259 // preanalysis to evaluate the extensions.
263 #ifdef OCCT_DEBUG //perf
264 ChFi3d_ResultChron(cl_extent,t_extent);
265 ChFi3d_InitChron(cl_perfsetofsurf);
268 // Construction of the stripe of fillet on each stripe.
269 for (itel.Initialize(myListStripe);itel.More(); itel.Next()) {
270 itel.Value()->Spine()->SetErrorStatus(ChFiDS_Ok);
273 PerformSetOfSurf(itel.Value());
275 catch(Standard_Failure const& anException) {
277 cout <<"EXCEPTION Stripe compute " << anException << endl;
280 badstripes.Append(itel.Value());
281 done = Standard_True;
282 if (itel.Value()->Spine()->ErrorStatus()==ChFiDS_Ok)
283 itel.Value()->Spine()->SetErrorStatus(ChFiDS_Error);
285 if (!done) badstripes.Append(itel.Value());
286 done = Standard_True;
288 done = (badstripes.IsEmpty());
290 #ifdef OCCT_DEBUG //perf
291 ChFi3d_ResultChron(cl_perfsetofsurf,t_perfsetofsurf);
292 ChFi3d_InitChron(cl_perffilletonvertex);
295 //construct fillets on each vertex + feed the Ds
298 for (j=1;j<=myVDataMap.Extent();j++)
303 PerformFilletOnVertex(j);
305 catch(Standard_Failure const& anException) {
307 cout <<"EXCEPTION Corner compute " << anException << endl;
310 badvertices.Append(myVDataMap.FindKey(j));
311 hasresult=Standard_False;
312 done = Standard_True;
314 if (!done) badvertices.Append(myVDataMap.FindKey(j));
315 done = Standard_True;
317 if (!hasresult) done = badvertices.IsEmpty();
321 #ifdef OCCT_DEBUG //perf
322 ChFi3d_ResultChron(cl_perffilletonvertex,t_perffilletonvertex);
323 ChFi3d_InitChron(cl_filds);
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);
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);
341 for (itel.Initialize(myListStripe), i1=0;
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;
349 for (itel1.Initialize(myListStripe), i2=0;
351 itel1.Next(), i2++) {
353 // Do not twice intersect the stripes
355 Handle(ChFiDS_Stripe) aCheckStripe = itel1.Value();
358 ChFi3d_StripeEdgeInter (st, aCheckStripe, DStr, tol2d);
360 catch(Standard_Failure const& anException) {
362 cout <<"EXCEPTION Fillets compute " << anException << endl;
365 badstripes.Append(itel.Value());
366 hasresult=Standard_False;
367 done = Standard_False;
372 Standard_Integer solidindex = st->SolidIndex();
373 ChFi3d_FilDS(solidindex,st,DStr,myRegul,tolesp,tol2d);
377 #ifdef OCCT_DEBUG //perf
378 ChFi3d_ResultChron(cl_filds,t_filds);
379 ChFi3d_InitChron(cl_reconstruction);
385 CompleteDS(DStr,myShape);
386 //Update tolerances on vertex to max adjacent edges or
387 //Update tolerances on degenerated edge to max of adjacent vertexes.
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 ) {
407 if( tolc < tolv ) tolc = tolv + 0.00001;
409 if(degen && tolc < tolv) tolc = tolv;
410 else if(tolc>tolv) B1.UpdateVertex(v,tolc);
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);
419 if(degen) c.Tolerance(tolc);
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);
429 Standard_Integer i=1,n=DStr.NbShapes();
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);
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);
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.
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);
468 B1.Add(myShapeResult,its.Value());
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);
486 B1.Add(badShape,its.Value());
492 #ifdef OCCT_DEBUG //perf
493 ChFi3d_ResultChron(cl_reconstruction ,t_reconstruction);
494 ChFi3d_InitChron(cl_setregul);
497 // Regularities are coded after cutting.
501 #ifdef OCCT_DEBUG //perf
502 ChFi3d_ResultChron(cl_setregul ,t_setregul);
506 #ifdef OCCT_DEBUG //perf
507 ChFi3d_ResultChron(cl_total,t_total);
511 // display of time for perfs
514 if(ChFi3d_GettraceCHRON()){
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;
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;
531 cout <<"temps SETOFKGEN "<< t_perfsetofkgen<<"s dont : "<<endl;
532 cout<<"- PerformSurf "<<t_performsurf<<"s"<<endl;
533 cout<<"- starsol "<< t_startsol <<"s"<<endl<<endl;
535 cout<<"temps PERFORMSURF "<<t_performsurf<<"s dont : " << endl;
536 cout<<"- computedata "<<t_computedata<<"s"<<endl;
537 cout<<"- completedata "<<t_completedata<<"s"<<endl<<endl;
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;
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;
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;
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;
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;
574 cout <<"TEMPS DIVERS "<<endl;
575 cout<<"-temps ChFi3d_sameparameter "<<t_sameparam<<"s"<<endl<<endl;
579 // Inspect the new faces to provide sameparameter
580 // if it is necessary
583 Standard_Real SameParTol = Precision::Confusion();
584 Standard_Integer aNbSurfaces, iF;
585 TopTools_ListIteratorOfListOfShape aIt;
587 aNbSurfaces=myDS->NbSurfaces();
589 for (iF=1; iF<=aNbSurfaces; ++iF) {
590 const TopTools_ListOfShape& aLF=myCoup->NewFaces(iF);
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);
601 //=======================================================================
602 //function : PerformSingularCorner
603 //purpose : Load vertex and degenerated edges.
604 //=======================================================================
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);
613 Handle(ChFiDS_SurfData) Fd;
614 Standard_Integer i, Icurv;
615 Standard_Integer Ivtx = 0;
616 for (It.Initialize(myVDataMap(Index)), i=0; It.More(); It.Next(),i++){
618 // SurfData concerned and its CommonPoints,
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);
625 // Is it always degenerated ?
626 if ( CV1.Point().IsEqual( CV2.Point(), 0) ) {
627 // if yes the vertex is stored in the stripe
628 // and the edge at end is created
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;
637 VOnS1 = Fd->InterferenceOnS1().PCurveOnSurf()->
638 Value(Fd->InterferenceOnS1().FirstParameter());
639 VOnS2 = Fd->InterferenceOnS2().PCurveOnSurf()->
640 Value(Fd->InterferenceOnS2().FirstParameter());
643 VOnS1 = Fd->InterferenceOnS1().PCurveOnSurf()->
644 Value(Fd->InterferenceOnS1().LastParameter());
645 VOnS2 = Fd->InterferenceOnS2().PCurveOnSurf()->
646 Value(Fd->InterferenceOnS2().LastParameter());
649 ChFi3d_ComputeArete(CV1, VOnS1,
651 DStr.Surface(Fd->Surf()).Surface(),
653 Pardeb,Parfin,tolapp3d,tolapp2d,tolreached,0);
654 Crv = TopOpeBRepDS_Curve(C3d,tolreached);
655 Icurv = DStr.AddCurve(Crv);
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);
666 //=======================================================================
667 //function : PerformFilletOnVertex
669 //=======================================================================
671 void ChFi3d_Builder::PerformFilletOnVertex
672 (const Standard_Integer Index){
674 ChFiDS_ListIteratorOfListOfStripe It;
675 Handle(ChFiDS_Stripe) stripe;
676 Handle(ChFiDS_Spine) sp;
677 const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Index);
679 Handle(ChFiDS_SurfData) Fd;
681 Standard_Boolean nondegenere = Standard_True;
682 Standard_Boolean toujoursdegenere = Standard_True;
683 Standard_Boolean isfirst = Standard_False;
684 for (It.Initialize(myVDataMap(Index)), i=0; It.More(); It.Next(),i++){
686 sp = stripe->Spine();
687 // SurfData and its CommonPoints,
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);
694 // Is it always degenerated ?
695 if ( CV1.Point().IsEqual( CV2.Point(), 0) )
696 nondegenere = Standard_False;
697 else toujoursdegenere = Standard_False;
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()){
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;
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--;
718 Standard_Integer nba = ChFi3d_NumberOfSharpEdges(Vtx, myVEMap, myEFMap);
720 if (nondegenere) { // Normal processing
724 if(sp->Status(isfirst) == ChFiDS_FreeBoundary) return;
726 #ifdef OCCT_DEBUG //perf
727 ChFi3d_InitChron(cl_performatend);
729 PerformIntersectionAtEnd(Index);
731 ChFi3d_ResultChron(cl_performatend,t_performatend);
735 #ifdef OCCT_DEBUG //perf
736 ChFi3d_InitChron(cl_perform1corner);
738 if (MoreSurfdata(Index))
739 PerformMoreSurfdata(Index);
740 else PerformOneCorner(Index);
741 #ifdef OCCT_DEBUG //perf
742 ChFi3d_ResultChron(cl_perform1corner,t_perform1corner);
750 #ifdef OCCT_DEBUG //perf
751 ChFi3d_InitChron(cl_performmore3corner);
753 PerformMoreThreeCorner(Index, i);
754 #ifdef OCCT_DEBUG //perf
755 ChFi3d_ResultChron(cl_performmore3corner,t_performmore3corner);
759 #ifdef OCCT_DEBUG //perf
760 ChFi3d_InitChron(cl_perform2corner);
762 PerformTwoCorner(Index);
763 #ifdef OCCT_DEBUG //perf
764 ChFi3d_ResultChron(cl_perform2corner,t_perform2corner);
772 #ifdef OCCT_DEBUG //perf
773 ChFi3d_InitChron(cl_performmore3corner);
775 PerformMoreThreeCorner(Index, i);
776 #ifdef OCCT_DEBUG //perf
777 ChFi3d_ResultChron(cl_performmore3corner,t_performmore3corner);
781 #ifdef OCCT_DEBUG //perf
782 ChFi3d_InitChron(cl_perform3corner);
784 PerformThreeCorner(Index);
785 #ifdef OCCT_DEBUG //perf
786 ChFi3d_ResultChron(cl_perform3corner,t_perform3corner);
792 #ifdef OCCT_DEBUG //perf
793 ChFi3d_InitChron(cl_performmore3corner);
795 PerformMoreThreeCorner(Index, i);
796 #ifdef OCCT_DEBUG //perf
797 ChFi3d_ResultChron(cl_performmore3corner,t_performmore3corner);
802 else { // Single case processing
803 if (toujoursdegenere) PerformSingularCorner(Index);
804 else PerformMoreThreeCorner(Index, i);//Last chance...
809 //=======================================================================
812 //=======================================================================
814 void ChFi3d_Builder::Reset()
816 done = Standard_False;
823 ChFiDS_ListIteratorOfListOfStripe itel;
824 for (itel.Initialize(myListStripe); itel.More(); ){
825 if(!itel.Value()->Spine().IsNull()){
826 itel.Value()->Reset();
829 else myListStripe.Remove(itel);
833 //=======================================================================
834 //function : Generated
836 //=======================================================================
838 const TopTools_ListOfShape& ChFi3d_Builder::Generated(const TopoDS_Shape& EouV)
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());