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 Standard_Failure::Raise("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) {
276 Handle(Standard_Failure) exc = Standard_Failure::Caught();
278 cout <<"EXCEPTION Stripe compute " << exc << 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)
307 Handle(Standard_Failure) exc = Standard_Failure::Caught();
309 cout <<"EXCEPTION Corner compute " << exc << endl;
311 badvertices.Append(myVDataMap.FindKey(j));
312 hasresult=Standard_False;
313 done = Standard_True;
315 if (!done) badvertices.Append(myVDataMap.FindKey(j));
316 done = Standard_True;
318 if (!hasresult) done = badvertices.IsEmpty();
322 #ifdef OCCT_DEBUG //perf
323 ChFi3d_ResultChron(cl_perffilletonvertex,t_perffilletonvertex);
324 ChFi3d_InitChron(cl_filds);
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);
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);
342 for (itel.Initialize(myListStripe), i1=0;
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;
350 for (itel1.Initialize(myListStripe), i2=0;
352 itel1.Next(), i2++) {
354 // Do not twice intersect the stripes
356 Handle(ChFiDS_Stripe) aCheckStripe = itel1.Value();
359 ChFi3d_StripeEdgeInter (st, aCheckStripe, DStr, tol2d);
361 catch(Standard_Failure) {
362 Handle(Standard_Failure) exc = Standard_Failure::Caught();
364 cout <<"EXCEPTION Fillets compute " << exc << endl;
366 badstripes.Append(itel.Value());
367 hasresult=Standard_False;
368 done = Standard_False;
373 Standard_Integer solidindex = st->SolidIndex();
374 ChFi3d_FilDS(solidindex,st,DStr,myRegul,tolesp,tol2d);
378 #ifdef OCCT_DEBUG //perf
379 ChFi3d_ResultChron(cl_filds,t_filds);
380 ChFi3d_InitChron(cl_reconstruction);
386 CompleteDS(DStr,myShape);
387 //Update tolerances on vertex to max adjacent edges or
388 //Update tolerances on degenerated edge to max of adjacent vertexes.
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 ) {
408 if( tolc < tolv ) tolc = tolv + 0.00001;
410 if(degen && tolc < tolv) tolc = tolv;
411 else if(tolc>tolv) B1.UpdateVertex(v,tolc);
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);
420 if(degen) c.Tolerance(tolc);
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);
430 Standard_Integer i=1,n=DStr.NbShapes();
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);
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);
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.
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);
469 B1.Add(myShapeResult,its.Value());
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);
487 B1.Add(badShape,its.Value());
493 #ifdef OCCT_DEBUG //perf
494 ChFi3d_ResultChron(cl_reconstruction ,t_reconstruction);
495 ChFi3d_InitChron(cl_setregul);
498 // Regularities are coded after cutting.
502 #ifdef OCCT_DEBUG //perf
503 ChFi3d_ResultChron(cl_setregul ,t_setregul);
507 #ifdef OCCT_DEBUG //perf
508 ChFi3d_ResultChron(cl_total,t_total);
512 // display of time for perfs
515 if(ChFi3d_GettraceCHRON()){
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;
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;
532 cout <<"temps SETOFKGEN "<< t_perfsetofkgen<<"s dont : "<<endl;
533 cout<<"- PerformSurf "<<t_performsurf<<"s"<<endl;
534 cout<<"- starsol "<< t_startsol <<"s"<<endl<<endl;
536 cout<<"temps PERFORMSURF "<<t_performsurf<<"s dont : " << endl;
537 cout<<"- computedata "<<t_computedata<<"s"<<endl;
538 cout<<"- completedata "<<t_completedata<<"s"<<endl<<endl;
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;
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;
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;
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;
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;
575 cout <<"TEMPS DIVERS "<<endl;
576 cout<<"-temps ChFi3d_sameparameter "<<t_sameparam<<"s"<<endl<<endl;
580 // Inspect the new faces to provide sameparameter
581 // if it is necessary
584 Standard_Real SameParTol = Precision::Confusion();
585 Standard_Integer aNbSurfaces, iF;
586 TopTools_ListIteratorOfListOfShape aIt;
588 aNbSurfaces=myDS->NbSurfaces();
590 for (iF=1; iF<=aNbSurfaces; ++iF) {
591 const TopTools_ListOfShape& aLF=myCoup->NewFaces(iF);
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);
602 //=======================================================================
603 //function : PerformSingularCorner
604 //purpose : Load vertex and degenerated edges.
605 //=======================================================================
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);
614 Handle(ChFiDS_SurfData) Fd;
615 Standard_Integer i, Icurv;
616 Standard_Integer Ivtx = 0;
617 for (It.Initialize(myVDataMap(Index)), i=0; It.More(); It.Next(),i++){
619 // SurfData concerned and its CommonPoints,
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);
626 // Is it always degenerated ?
627 if ( CV1.Point().IsEqual( CV2.Point(), 0) ) {
628 // if yes the vertex is stored in the stripe
629 // and the edge at end is created
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;
638 VOnS1 = Fd->InterferenceOnS1().PCurveOnSurf()->
639 Value(Fd->InterferenceOnS1().FirstParameter());
640 VOnS2 = Fd->InterferenceOnS2().PCurveOnSurf()->
641 Value(Fd->InterferenceOnS2().FirstParameter());
644 VOnS1 = Fd->InterferenceOnS1().PCurveOnSurf()->
645 Value(Fd->InterferenceOnS1().LastParameter());
646 VOnS2 = Fd->InterferenceOnS2().PCurveOnSurf()->
647 Value(Fd->InterferenceOnS2().LastParameter());
650 ChFi3d_ComputeArete(CV1, VOnS1,
652 DStr.Surface(Fd->Surf()).Surface(),
654 Pardeb,Parfin,tolapp3d,tolapp2d,tolreached,0);
655 Crv = TopOpeBRepDS_Curve(C3d,tolreached);
656 Icurv = DStr.AddCurve(Crv);
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);
667 //=======================================================================
668 //function : PerformFilletOnVertex
670 //=======================================================================
672 void ChFi3d_Builder::PerformFilletOnVertex
673 (const Standard_Integer Index){
675 ChFiDS_ListIteratorOfListOfStripe It;
676 Handle(ChFiDS_Stripe) stripe;
677 Handle(ChFiDS_Spine) sp;
678 const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Index);
680 Handle(ChFiDS_SurfData) Fd;
682 Standard_Boolean nondegenere = Standard_True;
683 Standard_Boolean toujoursdegenere = Standard_True;
684 Standard_Boolean isfirst = Standard_False;
685 for (It.Initialize(myVDataMap(Index)), i=0; It.More(); It.Next(),i++){
687 sp = stripe->Spine();
688 // SurfData and its CommonPoints,
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);
695 // Is it always degenerated ?
696 if ( CV1.Point().IsEqual( CV2.Point(), 0) )
697 nondegenere = Standard_False;
698 else toujoursdegenere = Standard_False;
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()){
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;
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--;
719 Standard_Integer nba = ChFi3d_NumberOfSharpEdges(Vtx, myVEMap, myEFMap);
721 if (nondegenere) { // Normal processing
725 if(sp->Status(isfirst) == ChFiDS_FreeBoundary) return;
727 #ifdef OCCT_DEBUG //perf
728 ChFi3d_InitChron(cl_performatend);
730 PerformIntersectionAtEnd(Index);
732 ChFi3d_ResultChron(cl_performatend,t_performatend);
736 #ifdef OCCT_DEBUG //perf
737 ChFi3d_InitChron(cl_perform1corner);
739 if (MoreSurfdata(Index))
740 PerformMoreSurfdata(Index);
741 else PerformOneCorner(Index);
742 #ifdef OCCT_DEBUG //perf
743 ChFi3d_ResultChron(cl_perform1corner,t_perform1corner);
751 #ifdef OCCT_DEBUG //perf
752 ChFi3d_InitChron(cl_performmore3corner);
754 PerformMoreThreeCorner(Index, i);
755 #ifdef OCCT_DEBUG //perf
756 ChFi3d_ResultChron(cl_performmore3corner,t_performmore3corner);
760 #ifdef OCCT_DEBUG //perf
761 ChFi3d_InitChron(cl_perform2corner);
763 PerformTwoCorner(Index);
764 #ifdef OCCT_DEBUG //perf
765 ChFi3d_ResultChron(cl_perform2corner,t_perform2corner);
773 #ifdef OCCT_DEBUG //perf
774 ChFi3d_InitChron(cl_performmore3corner);
776 PerformMoreThreeCorner(Index, i);
777 #ifdef OCCT_DEBUG //perf
778 ChFi3d_ResultChron(cl_performmore3corner,t_performmore3corner);
782 #ifdef OCCT_DEBUG //perf
783 ChFi3d_InitChron(cl_perform3corner);
785 PerformThreeCorner(Index);
786 #ifdef OCCT_DEBUG //perf
787 ChFi3d_ResultChron(cl_perform3corner,t_perform3corner);
793 #ifdef OCCT_DEBUG //perf
794 ChFi3d_InitChron(cl_performmore3corner);
796 PerformMoreThreeCorner(Index, i);
797 #ifdef OCCT_DEBUG //perf
798 ChFi3d_ResultChron(cl_performmore3corner,t_performmore3corner);
803 else { // Single case processing
804 if (toujoursdegenere) PerformSingularCorner(Index);
805 else PerformMoreThreeCorner(Index, i);//Last chance...
810 //=======================================================================
813 //=======================================================================
815 void ChFi3d_Builder::Reset()
817 done = Standard_False;
824 ChFiDS_ListIteratorOfListOfStripe itel;
825 for (itel.Initialize(myListStripe); itel.More(); ){
826 if(!itel.Value()->Spine().IsNull()){
827 itel.Value()->Reset();
830 else myListStripe.Remove(itel);
834 //=======================================================================
835 //function : Generated
837 //=======================================================================
839 const TopTools_ListOfShape& ChFi3d_Builder::Generated(const TopoDS_Shape& EouV)
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());