1 // Created on: 1994-06-17
2 // Created by: Modeling
3 // Copyright (c) 1994-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 <BRepFilletAPI_MakeFillet.hxx>
19 #include <ChFiDS_ErrorStatus.hxx>
20 #include <ChFiDS_Spine.hxx>
21 #include <Geom_Surface.hxx>
22 #include <Law_Function.hxx>
23 #include <Law_Interpol.hxx>
24 #include <Law_Linear.hxx>
26 #include <Precision.hxx>
27 #include <Standard_NoSuchObject.hxx>
28 #include <StdFail_NotDone.hxx>
29 #include <TopExp_Explorer.hxx>
30 #include <TopoDS_Edge.hxx>
31 #include <TopoDS_Shape.hxx>
32 #include <TopoDS_Vertex.hxx>
33 #include <TopOpeBRepBuild_HBuilder.hxx>
34 #include <TopOpeBRepDS_HDataStructure.hxx>
35 #include <TopTools_ListIteratorOfListOfShape.hxx>
37 //=======================================================================
38 //function : BRepFilletAPI_MakeFillet
40 //=======================================================================
41 BRepFilletAPI_MakeFillet::BRepFilletAPI_MakeFillet(const TopoDS_Shape& S,
42 const ChFi3d_FilletShape FShape):
47 //=======================================================================
48 //function : SetParams
50 //=======================================================================
52 void BRepFilletAPI_MakeFillet::SetParams(const Standard_Real Tang,
53 const Standard_Real Tesp,
54 const Standard_Real T2d,
55 const Standard_Real TApp3d,
56 const Standard_Real TolApp2d,
57 const Standard_Real Fleche)
59 myBuilder.SetParams(Tang,Tesp, T2d, TApp3d, TolApp2d, Fleche);
62 //=======================================================================
63 //function : SetContinuity
65 //=======================================================================
67 void BRepFilletAPI_MakeFillet::SetContinuity(
68 const GeomAbs_Shape InternalContinuity,
69 const Standard_Real AngleTol)
71 myBuilder.SetContinuity(InternalContinuity, AngleTol );
74 //=======================================================================
77 //=======================================================================
79 void BRepFilletAPI_MakeFillet::Add(const TopoDS_Edge& E)
85 //=======================================================================
88 //=======================================================================
90 void BRepFilletAPI_MakeFillet::Add(const Standard_Real Radius,
93 //myBuilder.Add(Radius,E);
95 Standard_Integer IinC;
96 Standard_Integer IC = myBuilder.Contains(E, IinC);
98 SetRadius( Radius, IC, IinC );
103 //=======================================================================
106 //=======================================================================
108 void BRepFilletAPI_MakeFillet::Add(const Standard_Real R1,
109 const Standard_Real R2,
110 const TopoDS_Edge& E)
113 Standard_Integer IinC;
114 Standard_Integer IC = myBuilder.Contains(E, IinC);
116 SetRadius(R1,R2,IC,IinC);
120 //=======================================================================
123 //=======================================================================
125 void BRepFilletAPI_MakeFillet::Add(const Handle(Law_Function)& L,
126 const TopoDS_Edge& E)
128 //myBuilder.Add(L,E);
130 Standard_Integer IinC;
131 Standard_Integer IC = myBuilder.Contains(E, IinC);
133 SetRadius(L,IC,IinC);
137 //=======================================================================
140 //=======================================================================
142 void BRepFilletAPI_MakeFillet::Add(const TColgp_Array1OfPnt2d& UandR,
143 const TopoDS_Edge& E)
146 Standard_Integer IinC;
147 Standard_Integer IC = myBuilder.Contains(E, IinC);
149 SetRadius( UandR, IC, IinC );
153 //=======================================================================
154 //function : SetRadius
156 //=======================================================================
158 void BRepFilletAPI_MakeFillet::SetRadius(const Standard_Real Radius,
159 const Standard_Integer IC,
160 const Standard_Integer IinC)
162 gp_XY FirstUandR( 0., Radius ), LastUandR( 1., Radius );
163 myBuilder.SetRadius( FirstUandR, IC, IinC );
164 myBuilder.SetRadius( LastUandR, IC, IinC );
168 //=======================================================================
169 //function : SetRadius
171 //=======================================================================
173 void BRepFilletAPI_MakeFillet::SetRadius(const Standard_Real R1,
174 const Standard_Real R2,
175 const Standard_Integer IC,
176 const Standard_Integer IinC)
178 Standard_Real r1, r2;
180 if(Abs(R1-R2) < Precision::Confusion())
181 r1 = r2 = (R1+R2)*0.5;
187 gp_XY FirstUandR( 0., r1 ), LastUandR( 1., r2 );
188 myBuilder.SetRadius( FirstUandR, IC, IinC );
189 myBuilder.SetRadius( LastUandR, IC, IinC );
193 //=======================================================================
194 //function : SetRadius
196 //=======================================================================
198 void BRepFilletAPI_MakeFillet::SetRadius(const Handle(Law_Function)& L,
199 const Standard_Integer IC,
200 const Standard_Integer IinC)
202 myBuilder.SetRadius(L,IC,IinC);
206 //=======================================================================
207 //function : SetRadius
209 //=======================================================================
211 void BRepFilletAPI_MakeFillet::SetRadius(const TColgp_Array1OfPnt2d& UandR,
212 const Standard_Integer IC,
213 const Standard_Integer IinC)
215 if(UandR.Length() == 1)
216 SetRadius( UandR(UandR.Lower()).Y(), IC, IinC );
217 else if(UandR.Length() == 2)
218 SetRadius( UandR(UandR.Lower()).Y(), UandR(UandR.Upper()).Y(), IC, IinC );
220 Standard_Real Uf = UandR(UandR.Lower()).X();
221 Standard_Real Ul = UandR(UandR.Upper()).X();
222 for(Standard_Integer i = UandR.Lower(); i <= UandR.Upper(); i++){
223 Standard_Real Ucur = UandR(i).X();
224 Ucur = ( Ucur - Uf ) / ( Ul - Uf );
225 gp_XY newUandR( Ucur, UandR(i).Y() );
226 myBuilder.SetRadius( newUandR, IC, IinC );
232 //=======================================================================
233 //function : IsConstant
235 //=======================================================================
237 Standard_Boolean BRepFilletAPI_MakeFillet::IsConstant(const Standard_Integer IC)
239 return myBuilder.IsConstant(IC);
243 //=======================================================================
246 //=======================================================================
248 Standard_Real BRepFilletAPI_MakeFillet::Radius(const Standard_Integer IC)
250 return myBuilder.Radius(IC);
254 //=======================================================================
255 //function : ResetContour
257 //=======================================================================
259 void BRepFilletAPI_MakeFillet::ResetContour(const Standard_Integer IC)
261 myBuilder.ResetContour(IC);
265 //=======================================================================
266 //function : IsConstant
268 //=======================================================================
270 Standard_Boolean BRepFilletAPI_MakeFillet::IsConstant(const Standard_Integer IC,
271 const TopoDS_Edge& E)
273 return myBuilder.IsConstant(IC,E);
277 //=======================================================================
280 //=======================================================================
282 Standard_Real BRepFilletAPI_MakeFillet::Radius(const Standard_Integer IC,
283 const TopoDS_Edge& E)
285 return myBuilder.Radius(IC,E);
289 //=======================================================================
290 //function : SetRadius
292 //=======================================================================
294 void BRepFilletAPI_MakeFillet::SetRadius(const Standard_Real Radius,
295 const Standard_Integer IC,
296 const TopoDS_Edge& E)
298 myBuilder.SetRadius(Radius,IC,E);
302 //=======================================================================
303 //function : GetBounds
305 //=======================================================================
307 Standard_Boolean BRepFilletAPI_MakeFillet::GetBounds(const Standard_Integer IC,
308 const TopoDS_Edge& E,
312 return myBuilder.GetBounds(IC,E,F,L);
316 //=======================================================================
319 //=======================================================================
321 Handle(Law_Function) BRepFilletAPI_MakeFillet::GetLaw(const Standard_Integer IC,
322 const TopoDS_Edge& E)
324 return myBuilder.GetLaw(IC,E);
328 //=======================================================================
331 //=======================================================================
333 void BRepFilletAPI_MakeFillet::SetLaw(const Standard_Integer IC,
334 const TopoDS_Edge& E,
335 const Handle(Law_Function)& L)
337 myBuilder.SetLaw(IC,E, L);
341 //=======================================================================
342 //function : SetRadius
344 //=======================================================================
346 void BRepFilletAPI_MakeFillet::SetRadius(const Standard_Real Radius,
347 const Standard_Integer IC,
348 const TopoDS_Vertex& V)
350 myBuilder.SetRadius(Radius,IC,V);
353 //=======================================================================
354 //function : SetFilletShape
356 //=======================================================================
358 void BRepFilletAPI_MakeFillet::SetFilletShape(const ChFi3d_FilletShape FShape)
360 myBuilder.SetFilletShape(FShape);
364 //=======================================================================
365 //function : GetFilletShape
367 //=======================================================================
369 ChFi3d_FilletShape BRepFilletAPI_MakeFillet::GetFilletShape() const
371 return myBuilder.GetFilletShape();
375 //=======================================================================
376 //function : NbContours
378 //=======================================================================
380 Standard_Integer BRepFilletAPI_MakeFillet::NbContours()const
382 return myBuilder.NbElements();
386 //=======================================================================
389 //=======================================================================
391 Standard_Integer BRepFilletAPI_MakeFillet::Contour(const TopoDS_Edge& E)const
393 return myBuilder.Contains(E);
397 //=======================================================================
400 //=======================================================================
402 Standard_Integer BRepFilletAPI_MakeFillet::NbEdges(const Standard_Integer I)const
404 const Handle(ChFiDS_Spine)& Spine = myBuilder.Value(I);
405 Standard_Integer n = Spine->NbEdges();
409 //=======================================================================
412 //=======================================================================
414 const TopoDS_Edge& BRepFilletAPI_MakeFillet::Edge(const Standard_Integer I,
415 const Standard_Integer J)const
417 const Handle(ChFiDS_Spine)& Spine = myBuilder.Value(I);
418 const TopoDS_Edge& S = Spine->Edges(J);
423 //=======================================================================
426 //=======================================================================
428 void BRepFilletAPI_MakeFillet::Remove(const TopoDS_Edge& E)
434 //=======================================================================
437 //=======================================================================
439 Standard_Real BRepFilletAPI_MakeFillet::Length(const Standard_Integer IC)const
441 return myBuilder.Length(IC);
445 //=======================================================================
446 //function : FirstVertex
448 //=======================================================================
450 TopoDS_Vertex BRepFilletAPI_MakeFillet::FirstVertex(const Standard_Integer IC)const
452 return myBuilder.FirstVertex(IC);
456 //=======================================================================
457 //function : LastVertex
459 //=======================================================================
461 TopoDS_Vertex BRepFilletAPI_MakeFillet::LastVertex(const Standard_Integer IC)const
463 return myBuilder.LastVertex(IC);
467 //=======================================================================
468 //function : Abscissa
470 //=======================================================================
472 Standard_Real BRepFilletAPI_MakeFillet::Abscissa(const Standard_Integer IC,
473 const TopoDS_Vertex& V)const
475 return myBuilder.Abscissa(IC,V);
479 //=======================================================================
480 //function : RelativeAbscissa
482 //=======================================================================
484 Standard_Real BRepFilletAPI_MakeFillet::RelativeAbscissa(const Standard_Integer IC,
485 const TopoDS_Vertex& V)const
487 return myBuilder.RelativeAbscissa(IC,V);
491 //=======================================================================
492 //function : ClosedAndTangent
494 //=======================================================================
496 Standard_Boolean BRepFilletAPI_MakeFillet::ClosedAndTangent
497 (const Standard_Integer IC)const
499 return myBuilder.ClosedAndTangent(IC);
503 //=======================================================================
506 //=======================================================================
508 Standard_Boolean BRepFilletAPI_MakeFillet::Closed
509 (const Standard_Integer IC)const
511 return myBuilder.Closed(IC);
515 //=======================================================================
518 //=======================================================================
520 Handle(TopOpeBRepBuild_HBuilder) BRepFilletAPI_MakeFillet::Builder()const
522 return myBuilder.Builder();
526 //=======================================================================
529 //=======================================================================
531 void BRepFilletAPI_MakeFillet::Build()
534 if(myBuilder.IsDone()) {
536 myShape = myBuilder.Shape();
538 // creation of the Map.
540 for (ex.Init(myShape, TopAbs_FACE); ex.More(); ex.Next()) {
541 myMap.Add(ex.Current());
547 //=======================================================================
550 //=======================================================================
552 void BRepFilletAPI_MakeFillet::Reset()
559 //=======================================================================
560 //function : NbSurfaces
562 //=======================================================================
564 Standard_Integer BRepFilletAPI_MakeFillet::NbSurfaces() const
566 return (myBuilder.Builder()->DataStructure())->NbSurfaces();
569 //=======================================================================
570 //function : NewFaces
572 //=======================================================================
574 const TopTools_ListOfShape& BRepFilletAPI_MakeFillet::NewFaces
575 (const Standard_Integer I)
577 return (*(TopTools_ListOfShape*)&(myBuilder.Builder()->NewFaces(I)));
580 //=======================================================================
581 //function : Simulate
583 //=======================================================================
585 void BRepFilletAPI_MakeFillet::Simulate(const Standard_Integer IC)
587 myBuilder.Simulate(IC);
591 //=======================================================================
594 //=======================================================================
596 Standard_Integer BRepFilletAPI_MakeFillet::NbSurf(const Standard_Integer IC)const
598 return myBuilder.NbSurf(IC);
601 //=======================================================================
604 //=======================================================================
606 Handle(ChFiDS_SecHArray1) BRepFilletAPI_MakeFillet::Sect(const Standard_Integer IC,
607 const Standard_Integer IS)const
609 return myBuilder.Sect(IC, IS);
612 //=======================================================================
613 //function : Generated
615 //=======================================================================
617 const TopTools_ListOfShape& BRepFilletAPI_MakeFillet::Generated
618 (const TopoDS_Shape& EorV)
620 return myBuilder.Generated(EorV);
623 //=======================================================================
624 //function : Modified
626 //=======================================================================
628 const TopTools_ListOfShape& BRepFilletAPI_MakeFillet::Modified
629 (const TopoDS_Shape& F)
633 if (myBuilder.Builder()->IsSplit(F, TopAbs_OUT)) {
634 TopTools_ListIteratorOfListOfShape It(myBuilder.Builder()->Splits(F, TopAbs_OUT));
635 for(;It.More();It.Next()) {
636 myGenerated.Append(It.Value());
639 if (myBuilder.Builder()->IsSplit(F, TopAbs_IN)) {
640 TopTools_ListIteratorOfListOfShape It(myBuilder.Builder()->Splits(F, TopAbs_IN));
641 for(;It.More();It.Next()) {
642 myGenerated.Append(It.Value());
645 if (myBuilder.Builder()->IsSplit(F, TopAbs_ON)) {
646 TopTools_ListIteratorOfListOfShape It(myBuilder.Builder()->Splits(F, TopAbs_ON));
647 for(;It.More();It.Next()) {
648 myGenerated.Append(It.Value());
654 //=======================================================================
655 //function : IsDeleted
657 //=======================================================================
659 Standard_Boolean BRepFilletAPI_MakeFillet::IsDeleted(const TopoDS_Shape& F)
661 if (myMap.Contains(F) ||
662 myBuilder.Builder()->IsSplit (F, TopAbs_OUT) ||
663 myBuilder.Builder()->IsSplit (F, TopAbs_IN) ||
664 myBuilder.Builder()->IsSplit (F, TopAbs_ON))
665 return Standard_False;
667 return Standard_True;
670 //=======================================================================
671 //function : NbFaultyContours
673 //=======================================================================
675 Standard_Integer BRepFilletAPI_MakeFillet::NbFaultyContours() const
677 return myBuilder.NbFaultyContours();
679 //=======================================================================
680 //function : FaultyContour
682 //=======================================================================
684 Standard_Integer BRepFilletAPI_MakeFillet::FaultyContour(const Standard_Integer I) const
686 return myBuilder.FaultyContour(I);
689 //=======================================================================
690 //function : NbComputedSurfaces
692 //=======================================================================
694 Standard_Integer BRepFilletAPI_MakeFillet::NbComputedSurfaces(const Standard_Integer IC) const
696 return myBuilder.NbComputedSurfaces (IC);
699 //=======================================================================
700 //function : ComputedSurface
702 //=======================================================================
704 Handle(Geom_Surface) BRepFilletAPI_MakeFillet::ComputedSurface(const Standard_Integer IC,
705 const Standard_Integer IS) const
707 return myBuilder.ComputedSurface(IC,IS);
710 //=======================================================================
711 //function : NbFaultyVertices
713 //=======================================================================
715 Standard_Integer BRepFilletAPI_MakeFillet::NbFaultyVertices() const
717 return myBuilder.NbFaultyVertices();
720 //=======================================================================
721 //function : FaultyVertex
723 //=======================================================================
725 TopoDS_Vertex BRepFilletAPI_MakeFillet::FaultyVertex(const Standard_Integer IV) const
727 return myBuilder.FaultyVertex(IV);
730 //=======================================================================
731 //function : HasResult
733 //=======================================================================
735 Standard_Boolean BRepFilletAPI_MakeFillet::HasResult() const
737 return myBuilder.HasResult();
740 //=======================================================================
741 //function : BadShape
743 //=======================================================================
745 TopoDS_Shape BRepFilletAPI_MakeFillet::BadShape()const
747 return myBuilder.BadShape();
750 //=======================================================================
751 //function : StripeStatus
753 //=======================================================================
755 ChFiDS_ErrorStatus BRepFilletAPI_MakeFillet::StripeStatus(const Standard_Integer IC)const
757 return myBuilder.StripeStatus(IC);