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.
17 #include <ChFi3d_Builder.ixx>
19 #include <Standard_Failure.hxx>
20 #include <Standard_NoSuchObject.hxx>
21 #include <Standard_NotImplemented.hxx>
22 #include <Standard_ErrorHandler.hxx>
23 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
24 #include <TColStd_MapOfInteger.hxx>
25 #include <TColStd_ListIteratorOfListOfInteger.hxx>
28 #include <TopoDS_Shape.hxx>
29 #include <TopoDS_Face.hxx>
30 #include <TopoDS_Edge.hxx>
31 #include <TopoDS_Vertex.hxx>
34 #include <TopAbs_ShapeEnum.hxx>
35 #include <TopAbs_Orientation.hxx>
36 #include <BRep_Builder.hxx>
37 #include <BRep_Tool.hxx>
39 #include <TopExp_Explorer.hxx>
40 #include <TopTools_ListOfShape.hxx>
41 #include <TopTools_ListIteratorOfListOfShape.hxx>
43 #include <TopOpeBRepDS_CurveExplorer.hxx>
44 #include <TopOpeBRepDS_CurvePointInterference.hxx>
45 #include <TopOpeBRepDS_DataStructure.hxx>
46 #include <TopOpeBRepDS_BuildTool.hxx>
47 #include <TopOpeBRepDS_Curve.hxx>
48 #include <TopOpeBRepDS_PointIterator.hxx>
49 #include <TopTools_ListIteratorOfListOfShape.hxx>
51 #include <BRep_Tool.hxx>
52 #include <ChFiDS_Stripe.hxx>
53 #include <ChFiDS_ListIteratorOfListOfStripe.hxx>
54 #include <ChFiDS_SequenceOfSurfData.hxx>
55 #include <ChFiDS_HData.hxx>
59 #include <ChFi3d_Builder_0.hxx>
60 #include <TopOpeBRepDS_ListOfInterference.hxx>
61 #include <BRepLib.hxx>
62 #include <ShapeFix.hxx>
63 #include <Precision.hxx>
66 #include <TestTopOpeTools.hxx>
67 #include <TestTopOpe.hxx>
70 #include <OSD_Chronometer.hxx>
74 // variables for performances
77 OSD_Chronometer cl_total,cl_extent,cl_perfsetofsurf,cl_perffilletonvertex,
78 cl_filds,cl_reconstruction,cl_setregul,cl_perform1corner,cl_perform2corner,
79 cl_performatend,cl_perform3corner,cl_performmore3corner;
81 Standard_EXPORT Standard_Real t_total, t_extent,t_perfsetofsurf,
82 t_perffilletonvertex, t_filds,t_reconstruction,t_setregul, t_perfsetofkgen,
83 t_perfsetofkpart,t_makextremities,t_performatend,t_startsol,t_performsurf,
84 t_perform1corner,t_perform2corner,t_perform3corner,t_performmore3corner,
85 t_batten,t_inter,t_sameinter,t_same,t_plate,t_approxplate,t_t2cornerinit,
86 t_perf2cornerbyinter,t_chfikpartcompdata,t_cheminement,t_remplissage,
87 t_t3cornerinit ,t_spherique,t_torique, t_notfilling,t_filling,t_sameparam,
88 t_computedata,t_completedata,t_t2cornerDS,t_t3cornerDS;
90 extern void ChFi3d_InitChron(OSD_Chronometer& ch);
91 extern void ChFi3d_ResultChron(OSD_Chronometer & ch, Standard_Real& time);
92 extern Standard_Boolean ChFi3d_GettraceCHRON();
96 //=======================================================================
97 //function : CompleteDS
99 //=======================================================================
101 static void CompleteDS(TopOpeBRepDS_DataStructure& DStr,
102 const TopoDS_Shape& S)
104 ChFiDS_Map MapEW,MapFS;
105 MapEW.Fill(S,TopAbs_EDGE,TopAbs_WIRE);
106 MapFS.Fill(S,TopAbs_FACE,TopAbs_SHELL);
108 TopExp_Explorer ExpE;
109 for (ExpE.Init(S,TopAbs_EDGE); ExpE.More(); ExpE.Next()) {
110 const TopoDS_Edge& E = TopoDS::Edge(ExpE.Current());
111 Standard_Boolean hasgeom = DStr.HasGeometry(E);
113 const TopTools_ListOfShape& WireListAnc = MapEW(E);
114 TopTools_ListIteratorOfListOfShape itaW(WireListAnc);
115 while (itaW.More()) {
116 const TopoDS_Shape& WireAnc = itaW.Value();
117 DStr.AddShape(WireAnc);
123 TopExp_Explorer ExpF;
124 for (ExpF.Init(S,TopAbs_FACE); ExpF.More(); ExpF.Next()) {
125 const TopoDS_Face& F = TopoDS::Face(ExpF.Current());
126 Standard_Boolean hasgeom = DStr.HasGeometry(F);
128 const TopTools_ListOfShape& ShellListAnc = MapFS(F);
129 TopTools_ListIteratorOfListOfShape itaS(ShellListAnc);
130 while (itaS.More()) {
131 const TopoDS_Shape& ShellAnc = itaS.Value();
132 DStr.AddShape(ShellAnc);
138 // set the range on the DS Curves
139 for (Standard_Integer ic = 1; ic <= DStr.NbCurves(); ic++) {
140 Standard_Real parmin = RealLast(), parmax = RealFirst();
141 const TopOpeBRepDS_ListOfInterference& LI = DStr.CurveInterferences(ic);
142 for (TopOpeBRepDS_PointIterator it(LI);
145 Standard_Real par = it.Parameter();
146 parmin = Min (parmin,par); parmax = Max (parmax,par);
148 DStr.ChangeCurve(ic).SetRange(parmin,parmax);
152 void ChFi3d_Builder::Delete()
155 //=======================================================================
156 //function : ExtentAnalyse
158 //=======================================================================
160 void ChFi3d_Builder::ExtentAnalyse ()
162 Standard_Integer nbedges, nbs;
163 for (Standard_Integer iv = 1; iv <= myVDataMap.Extent(); iv++) {
164 nbs = myVDataMap(iv).Extent();
165 const TopoDS_Vertex& Vtx = myVDataMap.FindKey(iv);
166 nbedges = ChFi3d_NumberOfEdges(Vtx, myVEMap);
169 ExtentOneCorner(Vtx, myVDataMap.FindFromIndex(iv).First());
173 ExtentTwoCorner(Vtx, myVDataMap.FindFromIndex(iv));
177 ExtentThreeCorner(Vtx, myVDataMap.FindFromIndex(iv));
185 //=======================================================================
188 //=======================================================================
190 void ChFi3d_Builder::Compute()
193 #ifdef OCCT_DEBUG //perf
194 t_total=0;t_extent=0; t_perfsetofsurf=0;t_perffilletonvertex=0;
195 t_filds=0;t_reconstruction=0;t_setregul=0;
196 t_perfsetofkpart=0; t_perfsetofkgen=0;t_makextremities=0;
197 t_performsurf=0;t_startsol=0; t_perform1corner=0;t_perform2corner=0;
198 t_perform3corner=0;t_performmore3corner=0;t_inter=0;t_same=0;t_sameinter=0;
199 t_plate=0;t_approxplate=0; t_batten=0;t_remplissage=0;t_t3cornerinit=0;
200 t_spherique=0;t_torique=0;t_notfilling=0;t_filling=0;t_performatend=0;
201 t_t2cornerinit=0; t_perf2cornerbyinter=0;t_chfikpartcompdata=0;
202 t_cheminement=0; t_sameparam=0; t_computedata=0;t_completedata=0;
203 t_t2cornerDS=0;t_t3cornerDS=0;
204 ChFi3d_InitChron(cl_total);
205 ChFi3d_InitChron(cl_extent);
208 if (myListStripe.IsEmpty())
209 Standard_Failure::Raise("There are no suitable edges for chamfer or fillet");
212 myDS = new TopOpeBRepDS_HDataStructure();
213 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
214 done = Standard_True;
215 hasresult=Standard_False;
217 TestTopOpe::CurrentDS(myDS);
219 TestTopOpe::Shapes(myShape,bids);
222 // filling of myVDatatMap
223 ChFiDS_ListIteratorOfListOfStripe itel;
225 for (itel.Initialize(myListStripe);itel.More(); itel.Next()) {
226 if ((itel.Value()->Spine()->FirstStatus() <= ChFiDS_BreakPoint))
227 myVDataMap.Add(itel.Value()->Spine()->FirstVertex(),itel.Value());
228 else if (itel.Value()->Spine()->FirstStatus() == ChFiDS_FreeBoundary)
229 ExtentOneCorner(itel.Value()->Spine()->FirstVertex(),itel.Value());
230 if ((itel.Value()->Spine()->LastStatus() <= ChFiDS_BreakPoint))
231 myVDataMap.Add(itel.Value()->Spine()->LastVertex() ,itel.Value());
232 else if (itel.Value()->Spine()->LastStatus() == ChFiDS_FreeBoundary)
233 ExtentOneCorner(itel.Value()->Spine()->LastVertex(),itel.Value());
235 // preanalysis to evaluate the extensions.
239 #ifdef OCCT_DEBUG //perf
240 ChFi3d_ResultChron(cl_extent,t_extent);
241 ChFi3d_InitChron(cl_perfsetofsurf);
244 // Construction of the stripe of fillet on each stripe.
245 for (itel.Initialize(myListStripe);itel.More(); itel.Next()) {
246 itel.Value()->Spine()->SetErrorStatus(ChFiDS_Ok);
249 PerformSetOfSurf(itel.Value());
251 catch(Standard_Failure) {
252 Handle(Standard_Failure) exc = Standard_Failure::Caught();
254 cout <<"EXCEPTION Stripe compute " << exc << endl;
256 badstripes.Append(itel.Value());
257 done = Standard_True;
258 if (itel.Value()->Spine()->ErrorStatus()==ChFiDS_Ok)
259 itel.Value()->Spine()->SetErrorStatus(ChFiDS_Error);
261 if (!done) badstripes.Append(itel.Value());
262 done = Standard_True;
264 done = (badstripes.IsEmpty());
266 #ifdef OCCT_DEBUG //perf
267 ChFi3d_ResultChron(cl_perfsetofsurf,t_perfsetofsurf);
268 ChFi3d_InitChron(cl_perffilletonvertex);
271 //construct fillets on each vertex + feed the Ds
274 for (j=1;j<=myVDataMap.Extent();j++)
279 PerformFilletOnVertex(j);
281 catch(Standard_Failure)
283 Handle(Standard_Failure) exc = Standard_Failure::Caught();
285 cout <<"EXCEPTION Corner compute " << exc << endl;
287 badvertices.Append(myVDataMap.FindKey(j));
288 hasresult=Standard_False;
289 done = Standard_True;
291 if (!done) badvertices.Append(myVDataMap.FindKey(j));
292 done = Standard_True;
294 if (!hasresult) done = badvertices.IsEmpty();
298 #ifdef OCCT_DEBUG //perf
299 ChFi3d_ResultChron(cl_perffilletonvertex,t_perffilletonvertex);
300 ChFi3d_InitChron(cl_filds);
303 TColStd_MapOfInteger MapIndSo;
304 TopExp_Explorer expso(myShape,TopAbs_SOLID);
305 for(; expso.More(); expso.Next()){
306 const TopoDS_Shape& cursol = expso.Current();
307 Standard_Integer indcursol = DStr.AddShape(cursol);
308 MapIndSo.Add(indcursol);
310 TopExp_Explorer expsh(myShape,TopAbs_SHELL,TopAbs_SOLID);
311 for(; expsh.More(); expsh.Next()){
312 const TopoDS_Shape& cursh = expsh.Current();
313 Standard_Integer indcursh = DStr.AddShape(cursh);
314 MapIndSo.Add(indcursh);
318 for (itel.Initialize(myListStripe), i1=0;
321 const Handle(ChFiDS_Stripe)& st = itel.Value();
322 // 05/02/02 akm vvv : (OCC119) First we'll check ain't there
323 // intersections between fillets
324 ChFiDS_ListIteratorOfListOfStripe itel1;
326 for (itel1.Initialize(myListStripe), i2=0;
328 itel1.Next(), i2++) {
330 // Do not twice intersect the stripes
332 Handle(ChFiDS_Stripe) aCheckStripe = itel1.Value();
335 ChFi3d_StripeEdgeInter (st, aCheckStripe, DStr, tol2d);
337 catch(Standard_Failure) {
338 Handle(Standard_Failure) exc = Standard_Failure::Caught();
340 cout <<"EXCEPTION Fillets compute " << exc << endl;
342 badstripes.Append(itel.Value());
343 hasresult=Standard_False;
344 done = Standard_False;
349 Standard_Integer solidindex = st->SolidIndex();
350 ChFi3d_FilDS(solidindex,st,DStr,myRegul,tolesp,tol2d);
354 #ifdef OCCT_DEBUG //perf
355 ChFi3d_ResultChron(cl_filds,t_filds);
356 ChFi3d_InitChron(cl_reconstruction);
362 CompleteDS(DStr,myShape);
363 //Update tolerances on vertex to max adjacent edges or
364 //Update tolerances on degenerated edge to max of adjacent vertexes.
365 TopOpeBRepDS_CurveExplorer cex(DStr);
366 for(;cex.More();cex.Next()){
367 TopOpeBRepDS_Curve& c = *((TopOpeBRepDS_Curve*)(void*)&(cex.Curve()));
368 Standard_Real tolc = 0.;
369 Standard_Boolean degen = c.Curve().IsNull();
370 if(!degen) tolc = c.Tolerance();
371 Standard_Integer ic = cex.Index();
372 TopOpeBRepDS_PointIterator It(myDS->CurvePoints(ic));
373 for(;It.More();It.Next()){
374 Handle(TopOpeBRepDS_CurvePointInterference) II;
375 II = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(It.Value());
376 if (II.IsNull()) continue;
377 TopOpeBRepDS_Kind gk = II->GeometryType();
378 Standard_Integer gi = II->Geometry();
379 if(gk == TopOpeBRepDS_VERTEX){
380 const TopoDS_Vertex& v = TopoDS::Vertex(myDS->Shape(gi));
381 Standard_Real tolv = BRep_Tool::Tolerance(v);
382 if( tolv > 0.0001 ) {
384 if( tolc < tolv ) tolc = tolv + 0.00001;
386 if(degen && tolc < tolv) tolc = tolv;
387 else if(tolc>tolv) B1.UpdateVertex(v,tolc);
389 else if(gk == TopOpeBRepDS_POINT){
390 TopOpeBRepDS_Point& p = DStr.ChangePoint(gi);
391 Standard_Real tolp = p.Tolerance();
392 if(degen && tolc < tolp) tolc = tolp;
393 else if(tolc>tolp) p.Tolerance(tolc);
396 if(degen) c.Tolerance(tolc);
398 myCoup->Perform(myDS);
399 TColStd_MapIteratorOfMapOfInteger It(MapIndSo);
400 for(; It.More(); It.Next()){
401 Standard_Integer indsol = It.Key();
402 const TopoDS_Shape& curshape = DStr.Shape(indsol);
403 myCoup->MergeSolid(curshape,TopAbs_IN);
406 Standard_Integer i=1,n=DStr.NbShapes();
408 const TopoDS_Shape S = DStr.Shape(i);
409 if (S.ShapeType() != TopAbs_EDGE) continue;
410 Standard_Boolean issplitIN = myCoup->IsSplit(S,TopAbs_IN);
411 if ( !issplitIN ) continue;
412 TopTools_ListIteratorOfListOfShape it(myCoup->Splits(S,TopAbs_IN));
413 for (; it.More(); it.Next() ) {
414 const TopoDS_Edge& newE = TopoDS::Edge(it.Value());
415 Standard_Real tole = BRep_Tool::Tolerance(newE);
416 TopExp_Explorer exv(newE,TopAbs_VERTEX);
417 for (; exv.More(); exv.Next() ) {
418 const TopoDS_Vertex& v = TopoDS::Vertex(exv.Current());
419 Standard_Real tolv = BRep_Tool::Tolerance(v);
420 if (tole>tolv) B1.UpdateVertex(v,tole);
425 B1.MakeCompound(TopoDS::Compound(myShapeResult));
426 for(It.Reset(); It.More(); It.Next()){
427 Standard_Integer indsol = It.Key();
428 const TopoDS_Shape& curshape = DStr.Shape(indsol);
429 TopTools_ListIteratorOfListOfShape
430 its = myCoup->Merged(curshape,TopAbs_IN);
431 if(!its.More()) B1.Add(myShapeResult,curshape);
433 //If the old type of Shape is Shell, Shell is placed instead of Solid,
434 //However there is a problem for compound of open Shell.
436 const TopAbs_ShapeEnum letype = curshape.ShapeType();
437 if (letype == TopAbs_SHELL){
438 TopExp_Explorer expsh2(its.Value(),TopAbs_SHELL);
439 const TopoDS_Shape& cursh = expsh2.Current();
440 TopoDS_Shape tt = cursh;
441 B1.Add(myShapeResult,cursh);
445 B1.Add(myShapeResult,its.Value());
454 B1.MakeCompound(TopoDS::Compound(badShape));
455 for(It.Reset(); It.More(); It.Next()){
456 Standard_Integer indsol = It.Key();
457 const TopoDS_Shape& curshape = DStr.Shape(indsol);
458 TopTools_ListIteratorOfListOfShape
459 its = myCoup->Merged(curshape,TopAbs_IN);
460 if(!its.More()) B1.Add(badShape,curshape);
463 B1.Add(badShape,its.Value());
469 #ifdef OCCT_DEBUG //perf
470 ChFi3d_ResultChron(cl_reconstruction ,t_reconstruction);
471 ChFi3d_InitChron(cl_setregul);
474 // Regularities are coded after cutting.
478 #ifdef OCCT_DEBUG //perf
479 ChFi3d_ResultChron(cl_setregul ,t_setregul);
483 #ifdef OCCT_DEBUG //perf
484 ChFi3d_ResultChron(cl_total,t_total);
488 // display of time for perfs
491 if(ChFi3d_GettraceCHRON()){
493 cout<<"COMPUTE: temps total "<<t_total<<"s dont :"<<endl;
494 cout<<"- Init + ExtentAnalyse "<<t_extent<<"s"<<endl;
495 cout<<"- PerformSetOfSurf "<<t_perfsetofsurf<<"s"<<endl;
496 cout<<"- PerformFilletOnVertex "<<t_perffilletonvertex<<"s"<<endl;
497 cout<<"- FilDS "<<t_filds<<"s"<<endl;
498 cout<<"- Reconstruction "<<t_reconstruction<<"s"<<endl;
499 cout<<"- SetRegul "<<t_setregul<<"s"<<endl<<endl;
502 cout <<"temps PERFORMSETOFSURF "<<t_perfsetofsurf <<"s dont : "<<endl;
503 cout <<"- SetofKPart "<<t_perfsetofkpart<<"s"<<endl;
504 cout <<"- SetofKGen "<< t_perfsetofkgen <<"s"<<endl;
505 cout <<"- MakeExtremities "<<t_makextremities<<"s"<<endl<<endl;
508 cout <<"temps SETOFKGEN "<< t_perfsetofkgen<<"s dont : "<<endl;
509 cout<<"- PerformSurf "<<t_performsurf<<"s"<<endl;
510 cout<<"- starsol "<< t_startsol <<"s"<<endl<<endl;
512 cout<<"temps PERFORMSURF "<<t_performsurf<<"s dont : " << endl;
513 cout<<"- computedata "<<t_computedata<<"s"<<endl;
514 cout<<"- completedata "<<t_completedata<<"s"<<endl<<endl;
517 cout<<"temps PERFORMFILLETVERTEX "<<t_perffilletonvertex <<"s dont : " << endl;
518 cout<<"- PerformOneCorner "<<t_perform1corner<<"s"<<endl;
519 cout<<"- PerformIntersectionAtEnd "<<t_performatend<<"s"<<endl;
520 cout<<"- PerformTwoCorner "<<t_perform2corner<<"s"<<endl;
521 cout<<"- PerformThreeCorner "<<t_perform3corner<<"s"<<endl;
522 cout<<"- PerformMoreThreeCorner "<<t_performmore3corner<<"s"<<endl<<endl;
525 cout<<"temps PerformOneCorner "<<t_perform1corner<<"s dont:"<<endl;
526 cout<<"- temps condition if (same) "<<t_same << "s "<<endl;
527 cout<<"- temps condition if (inter) "<<t_inter<<"s " <<endl;
528 cout<<"- temps condition if (same inter) "<<t_sameinter<<"s " <<endl<<endl;
530 cout<<"temps PerformTwocorner "<<t_perform2corner<<"s dont:"<<endl;
531 cout<<"- temps initialisation "<< t_t2cornerinit<<"s"<<endl;
532 cout<<"- temps PerformTwoCornerbyInter "<<t_perf2cornerbyinter<<"s"<<endl;
533 cout<<"- temps ChFiKPart_ComputeData "<<t_chfikpartcompdata <<"s"<<endl;
534 cout<<"- temps cheminement "<<t_cheminement<<"s"<<endl;
535 cout<<"- temps remplissage "<<t_remplissage<<"s"<<endl;
536 cout<<"- temps mise a jour stripes "<<t_t2cornerDS<<"s"<<endl<<endl;
538 cout<<" temps PerformThreecorner "<<t_perform3corner<<"s dont:"<<endl;
539 cout<<"- temps initialisation "<< t_t3cornerinit<<"s"<<endl;
540 cout<<"- temps cas spherique "<<t_spherique<<"s"<<endl;
541 cout<<"- temps cas torique "<<t_torique<<"s"<<endl;
542 cout<<"- temps notfilling "<<t_notfilling<<"s"<<endl;
543 cout<<"- temps filling "<<t_filling<<"s"<<endl;
544 cout<<"- temps mise a jour stripes "<<t_t3cornerDS<<"s"<<endl<<endl;
546 cout<<"temps PerformMore3Corner "<<t_performmore3corner<<"s dont:"<<endl;
547 cout<<"-temps plate "<<t_plate << "s "<<endl;
548 cout<<"-temps approxplate "<<t_approxplate<<"s " <<endl;
549 cout<<"-temps batten "<< t_batten<<"s " <<endl<<endl;
551 cout <<"TEMPS DIVERS "<<endl;
552 cout<<"-temps ChFi3d_sameparameter "<<t_sameparam<<"s"<<endl<<endl;
556 // Inspect the new faces to provide sameparameter
557 // if it is necessary
560 Standard_Real SameParTol = Precision::Confusion();
561 Standard_Integer aNbSurfaces, iF;
562 TopTools_ListIteratorOfListOfShape aIt;
564 aNbSurfaces=myDS->NbSurfaces();
566 for (iF=1; iF<=aNbSurfaces; ++iF) {
567 const TopTools_ListOfShape& aLF=myCoup->NewFaces(iF);
569 for (; aIt.More(); aIt.Next()) {
570 const TopoDS_Shape& aF=aIt.Value();
571 BRepLib::SameParameter(aF, SameParTol, Standard_True);
572 ShapeFix::SameParameter(aF, Standard_False, SameParTol);
578 //=======================================================================
579 //function : PerformSingularCorner
580 //purpose : Load vertex and degenerated edges.
581 //=======================================================================
583 void ChFi3d_Builder::PerformSingularCorner
584 (const Standard_Integer Index){
585 ChFiDS_ListIteratorOfListOfStripe It;
586 Handle(ChFiDS_Stripe) stripe;
587 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
588 const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Index);
590 Handle(ChFiDS_SurfData) Fd;
591 Standard_Integer i, Icurv;
592 Standard_Integer Ivtx = 0;
593 for (It.Initialize(myVDataMap(Index)), i=0; It.More(); It.Next(),i++){
595 // SurfData concerned and its CommonPoints,
596 Standard_Integer sens = 0;
597 Standard_Integer num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens);
598 Standard_Boolean isfirst = (sens == 1);
599 Fd = stripe->SetOfSurfData()->Sequence().Value(num);
600 const ChFiDS_CommonPoint& CV1 = Fd->Vertex(isfirst,1);
601 const ChFiDS_CommonPoint& CV2 = Fd->Vertex(isfirst,2);
602 // Is it always degenerated ?
603 if ( CV1.Point().IsEqual( CV2.Point(), 0) ) {
604 // if yes the vertex is stored in the stripe
605 // and the edge at end is created
606 if (i==0) Ivtx = ChFi3d_IndexPointInDS(CV1, DStr);
607 Standard_Real tolreached;
608 Standard_Real Pardeb, Parfin;
609 gp_Pnt2d VOnS1, VOnS2;
610 Handle(Geom_Curve) C3d;
611 Handle(Geom2d_Curve) PCurv;
612 TopOpeBRepDS_Curve Crv;
614 VOnS1 = Fd->InterferenceOnS1().PCurveOnSurf()->
615 Value(Fd->InterferenceOnS1().FirstParameter());
616 VOnS2 = Fd->InterferenceOnS2().PCurveOnSurf()->
617 Value(Fd->InterferenceOnS2().FirstParameter());
620 VOnS1 = Fd->InterferenceOnS1().PCurveOnSurf()->
621 Value(Fd->InterferenceOnS1().LastParameter());
622 VOnS2 = Fd->InterferenceOnS2().PCurveOnSurf()->
623 Value(Fd->InterferenceOnS2().LastParameter());
626 ChFi3d_ComputeArete(CV1, VOnS1,
628 DStr.Surface(Fd->Surf()).Surface(),
630 Pardeb,Parfin,tolapp3d,tolapp2d,tolreached,0);
631 Crv = TopOpeBRepDS_Curve(C3d,tolreached);
632 Icurv = DStr.AddCurve(Crv);
634 stripe->SetCurve(Icurv, isfirst);
635 stripe->SetParameters(isfirst, Pardeb,Parfin);
636 stripe->ChangePCurve(isfirst) = PCurv;
637 stripe->SetIndexPoint(Ivtx, isfirst, 1);
638 stripe->SetIndexPoint(Ivtx, isfirst, 2);
643 //=======================================================================
644 //function : PerformFilletOnVertex
646 //=======================================================================
648 void ChFi3d_Builder::PerformFilletOnVertex
649 (const Standard_Integer Index){
651 ChFiDS_ListIteratorOfListOfStripe It;
652 Handle(ChFiDS_Stripe) stripe;
653 Handle(ChFiDS_Spine) sp;
654 const TopoDS_Vertex& Vtx = myVDataMap.FindKey(Index);
656 Handle(ChFiDS_SurfData) Fd;
658 Standard_Boolean nondegenere = Standard_True;
659 Standard_Boolean toujoursdegenere = Standard_True;
660 Standard_Boolean isfirst = Standard_False;
661 for (It.Initialize(myVDataMap(Index)), i=0; It.More(); It.Next(),i++){
663 sp = stripe->Spine();
664 // SurfData and its CommonPoints,
665 Standard_Integer sens = 0;
666 Standard_Integer num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens);
667 isfirst = (sens == 1);
668 Fd = stripe->SetOfSurfData()->Sequence().Value(num);
669 const ChFiDS_CommonPoint& CV1 = Fd->Vertex(isfirst,1);
670 const ChFiDS_CommonPoint& CV2 = Fd->Vertex(isfirst,2);
671 // Is it always degenerated ?
672 if ( CV1.Point().IsEqual( CV2.Point(), 0) )
673 nondegenere = Standard_False;
674 else toujoursdegenere = Standard_False;
677 // calcul du nombre de faces = nombre d'aretes
678 /* TopTools_ListIteratorOfListOfShape ItF,JtF,ItE;
679 Standard_Integer nbf = 0, jf = 0;
680 for (ItF.Initialize(myVFMap(Vtx)); ItF.More(); ItF.Next()){
682 Standard_Integer kf = 1;
683 const TopoDS_Shape& cur = ItF.Value();
684 for (JtF.Initialize(myVFMap(Vtx)); JtF.More() && (kf < jf); JtF.Next(), kf++){
685 if(cur.IsSame(JtF.Value())) break;
689 Standard_Integer nba=myVEMap(Vtx).Extent();
690 for (ItE.Initialize(myVEMap(Vtx)); ItE.More(); ItE.Next()){
691 const TopoDS_Edge& cur = TopoDS::Edge(ItE.Value());
692 if (BRep_Tool::Degenerated(cur)) nba--;
695 Standard_Integer nba = ChFi3d_NumberOfEdges(Vtx, myVEMap);
697 if (nondegenere) { // Normal processing
701 if(sp->Status(isfirst) == ChFiDS_FreeBoundary) return;
703 #ifdef OCCT_DEBUG //perf
704 ChFi3d_InitChron(cl_performatend);
706 PerformIntersectionAtEnd(Index);
708 ChFi3d_ResultChron(cl_performatend,t_performatend);
712 #ifdef OCCT_DEBUG //perf
713 ChFi3d_InitChron(cl_perform1corner);
715 if (MoreSurfdata(Index))
716 PerformMoreSurfdata(Index);
717 else PerformOneCorner(Index);
718 #ifdef OCCT_DEBUG //perf
719 ChFi3d_ResultChron(cl_perform1corner,t_perform1corner);
727 #ifdef OCCT_DEBUG //perf
728 ChFi3d_InitChron(cl_performmore3corner);
730 PerformMoreThreeCorner(Index, i);
731 #ifdef OCCT_DEBUG //perf
732 ChFi3d_ResultChron(cl_performmore3corner,t_performmore3corner);
736 #ifdef OCCT_DEBUG //perf
737 ChFi3d_InitChron(cl_perform2corner);
739 PerformTwoCorner(Index);
740 #ifdef OCCT_DEBUG //perf
741 ChFi3d_ResultChron(cl_perform2corner,t_perform2corner);
749 #ifdef OCCT_DEBUG //perf
750 ChFi3d_InitChron(cl_performmore3corner);
752 PerformMoreThreeCorner(Index, i);
753 #ifdef OCCT_DEBUG //perf
754 ChFi3d_ResultChron(cl_performmore3corner,t_performmore3corner);
758 #ifdef OCCT_DEBUG //perf
759 ChFi3d_InitChron(cl_perform3corner);
761 PerformThreeCorner(Index);
762 #ifdef OCCT_DEBUG //perf
763 ChFi3d_ResultChron(cl_perform3corner,t_perform3corner);
769 #ifdef OCCT_DEBUG //perf
770 ChFi3d_InitChron(cl_performmore3corner);
772 PerformMoreThreeCorner(Index, i);
773 #ifdef OCCT_DEBUG //perf
774 ChFi3d_ResultChron(cl_performmore3corner,t_performmore3corner);
779 else { // Single case processing
780 if (toujoursdegenere) PerformSingularCorner(Index);
781 else PerformMoreThreeCorner(Index, i);//Last chance...
786 //=======================================================================
789 //=======================================================================
791 void ChFi3d_Builder::Reset()
793 done = Standard_False;
800 ChFiDS_ListIteratorOfListOfStripe itel;
801 for (itel.Initialize(myListStripe); itel.More(); ){
802 if(!itel.Value()->Spine().IsNull()){
803 itel.Value()->Reset();
806 else myListStripe.Remove(itel);
810 //=======================================================================
811 //function : Generated
813 //=======================================================================
815 const TopTools_ListOfShape& ChFi3d_Builder::Generated(const TopoDS_Shape& EouV)
818 if(EouV.IsNull()) return myGenerated;
819 if(EouV.ShapeType() != TopAbs_EDGE &&
820 EouV.ShapeType() != TopAbs_VERTEX) return myGenerated;
821 if(myEVIMap.IsBound(EouV)) {
822 const TColStd_ListOfInteger& L = myEVIMap.Find(EouV);
823 TColStd_ListIteratorOfListOfInteger IL;
824 for(IL.Initialize(L); IL.More(); IL.Next()){
825 Standard_Integer I = IL.Value();
826 const TopTools_ListOfShape& LS = myCoup->NewFaces(I);
827 TopTools_ListIteratorOfListOfShape ILS;
828 for(ILS.Initialize(LS); ILS.More(); ILS.Next()){
829 myGenerated.Append(ILS.Value());