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.
17 #include <Precision.hxx>
18 #include <BRepFilletAPI_MakeFillet.ixx>
19 #include <TopExp_Explorer.hxx>
20 #include <TopOpeBRepDS_HDataStructure.hxx>
21 #include <TopTools_ListIteratorOfListOfShape.hxx>
22 #include <ChFiDS_Spine.hxx>
23 #include <ChFiDS_ErrorStatus.hxx>
24 #include <Law_Linear.hxx>
26 #include <Law_Interpol.hxx>
28 //=======================================================================
29 //function : BRepFilletAPI_MakeFillet
31 //=======================================================================
33 BRepFilletAPI_MakeFillet::BRepFilletAPI_MakeFillet(const TopoDS_Shape& S,
34 const ChFi3d_FilletShape FShape):
39 //=======================================================================
40 //function : SetParams
42 //=======================================================================
44 void BRepFilletAPI_MakeFillet::SetParams(const Standard_Real Tang,
45 const Standard_Real Tesp,
46 const Standard_Real T2d,
47 const Standard_Real TApp3d,
48 const Standard_Real TolApp2d,
49 const Standard_Real Fleche)
51 myBuilder.SetParams(Tang,Tesp, T2d, TApp3d, TolApp2d, Fleche);
54 //=======================================================================
55 //function : SetContinuity
57 //=======================================================================
59 void BRepFilletAPI_MakeFillet::SetContinuity(
60 const GeomAbs_Shape InternalContinuity,
61 const Standard_Real AngleTol)
63 myBuilder.SetContinuity(InternalContinuity, AngleTol );
66 //=======================================================================
69 //=======================================================================
71 void BRepFilletAPI_MakeFillet::Add(const TopoDS_Edge& E)
77 //=======================================================================
80 //=======================================================================
82 void BRepFilletAPI_MakeFillet::Add(const Standard_Real Radius,
85 //myBuilder.Add(Radius,E);
87 Standard_Integer IinC;
88 Standard_Integer IC = myBuilder.Contains(E, IinC);
90 SetRadius( Radius, IC, IinC );
95 //=======================================================================
98 //=======================================================================
100 void BRepFilletAPI_MakeFillet::Add(const Standard_Real R1,
101 const Standard_Real R2,
102 const TopoDS_Edge& E)
105 Standard_Integer IinC;
106 Standard_Integer IC = myBuilder.Contains(E, IinC);
108 SetRadius(R1,R2,IC,IinC);
112 //=======================================================================
115 //=======================================================================
117 void BRepFilletAPI_MakeFillet::Add(const Handle(Law_Function)& L,
118 const TopoDS_Edge& E)
120 //myBuilder.Add(L,E);
122 Standard_Integer IinC;
123 Standard_Integer IC = myBuilder.Contains(E, IinC);
125 SetRadius(L,IC,IinC);
129 //=======================================================================
132 //=======================================================================
134 void BRepFilletAPI_MakeFillet::Add(const TColgp_Array1OfPnt2d& UandR,
135 const TopoDS_Edge& E)
138 Standard_Integer IinC;
139 Standard_Integer IC = myBuilder.Contains(E, IinC);
141 SetRadius( UandR, IC, IinC );
145 //=======================================================================
146 //function : SetRadius
148 //=======================================================================
150 void BRepFilletAPI_MakeFillet::SetRadius(const Standard_Real Radius,
151 const Standard_Integer IC,
152 const Standard_Integer IinC)
154 gp_XY FirstUandR( 0., Radius ), LastUandR( 1., Radius );
155 myBuilder.SetRadius( FirstUandR, IC, IinC );
156 myBuilder.SetRadius( LastUandR, IC, IinC );
160 //=======================================================================
161 //function : SetRadius
163 //=======================================================================
165 void BRepFilletAPI_MakeFillet::SetRadius(const Standard_Real R1,
166 const Standard_Real R2,
167 const Standard_Integer IC,
168 const Standard_Integer IinC)
170 Standard_Real r1, r2;
172 if(Abs(R1-R2) < Precision::Confusion())
173 r1 = r2 = (R1+R2)*0.5;
179 gp_XY FirstUandR( 0., r1 ), LastUandR( 1., r2 );
180 myBuilder.SetRadius( FirstUandR, IC, IinC );
181 myBuilder.SetRadius( LastUandR, IC, IinC );
185 //=======================================================================
186 //function : SetRadius
188 //=======================================================================
190 void BRepFilletAPI_MakeFillet::SetRadius(const Handle(Law_Function)& L,
191 const Standard_Integer IC,
192 const Standard_Integer IinC)
194 myBuilder.SetRadius(L,IC,IinC);
198 //=======================================================================
199 //function : SetRadius
201 //=======================================================================
203 void BRepFilletAPI_MakeFillet::SetRadius(const TColgp_Array1OfPnt2d& UandR,
204 const Standard_Integer IC,
205 const Standard_Integer IinC)
207 if(UandR.Length() == 1)
208 SetRadius( UandR(UandR.Lower()).Y(), IC, IinC );
209 else if(UandR.Length() == 2)
210 SetRadius( UandR(UandR.Lower()).Y(), UandR(UandR.Upper()).Y(), IC, IinC );
212 Standard_Real Uf = UandR(UandR.Lower()).X();
213 Standard_Real Ul = UandR(UandR.Upper()).X();
214 for(Standard_Integer i = UandR.Lower(); i <= UandR.Upper(); i++){
215 Standard_Real Ucur = UandR(i).X();
216 Ucur = ( Ucur - Uf ) / ( Ul - Uf );
217 gp_XY newUandR( Ucur, UandR(i).Y() );
218 myBuilder.SetRadius( newUandR, IC, IinC );
224 //=======================================================================
225 //function : IsConstant
227 //=======================================================================
229 Standard_Boolean BRepFilletAPI_MakeFillet::IsConstant(const Standard_Integer IC)
231 return myBuilder.IsConstant(IC);
235 //=======================================================================
238 //=======================================================================
240 Standard_Real BRepFilletAPI_MakeFillet::Radius(const Standard_Integer IC)
242 return myBuilder.Radius(IC);
246 //=======================================================================
247 //function : ResetContour
249 //=======================================================================
251 void BRepFilletAPI_MakeFillet::ResetContour(const Standard_Integer IC)
253 myBuilder.ResetContour(IC);
257 //=======================================================================
258 //function : IsConstant
260 //=======================================================================
262 Standard_Boolean BRepFilletAPI_MakeFillet::IsConstant(const Standard_Integer IC,
263 const TopoDS_Edge& E)
265 return myBuilder.IsConstant(IC,E);
269 //=======================================================================
272 //=======================================================================
274 Standard_Real BRepFilletAPI_MakeFillet::Radius(const Standard_Integer IC,
275 const TopoDS_Edge& E)
277 return myBuilder.Radius(IC,E);
281 //=======================================================================
282 //function : SetRadius
284 //=======================================================================
286 void BRepFilletAPI_MakeFillet::SetRadius(const Standard_Real Radius,
287 const Standard_Integer IC,
288 const TopoDS_Edge& E)
290 myBuilder.SetRadius(Radius,IC,E);
294 //=======================================================================
295 //function : GetBounds
297 //=======================================================================
299 Standard_Boolean BRepFilletAPI_MakeFillet::GetBounds(const Standard_Integer IC,
300 const TopoDS_Edge& E,
304 return myBuilder.GetBounds(IC,E,F,L);
308 //=======================================================================
311 //=======================================================================
313 Handle(Law_Function) BRepFilletAPI_MakeFillet::GetLaw(const Standard_Integer IC,
314 const TopoDS_Edge& E)
316 return myBuilder.GetLaw(IC,E);
320 //=======================================================================
323 //=======================================================================
325 void BRepFilletAPI_MakeFillet::SetLaw(const Standard_Integer IC,
326 const TopoDS_Edge& E,
327 const Handle(Law_Function)& L)
329 myBuilder.SetLaw(IC,E, L);
333 //=======================================================================
334 //function : SetRadius
336 //=======================================================================
338 void BRepFilletAPI_MakeFillet::SetRadius(const Standard_Real Radius,
339 const Standard_Integer IC,
340 const TopoDS_Vertex& V)
342 myBuilder.SetRadius(Radius,IC,V);
345 //=======================================================================
346 //function : SetFilletShape
348 //=======================================================================
350 void BRepFilletAPI_MakeFillet::SetFilletShape(const ChFi3d_FilletShape FShape)
352 myBuilder.SetFilletShape(FShape);
356 //=======================================================================
357 //function : GetFilletShape
359 //=======================================================================
361 ChFi3d_FilletShape BRepFilletAPI_MakeFillet::GetFilletShape() const
363 return myBuilder.GetFilletShape();
367 //=======================================================================
368 //function : NbContours
370 //=======================================================================
372 Standard_Integer BRepFilletAPI_MakeFillet::NbContours()const
374 return myBuilder.NbElements();
378 //=======================================================================
381 //=======================================================================
383 Standard_Integer BRepFilletAPI_MakeFillet::Contour(const TopoDS_Edge& E)const
385 return myBuilder.Contains(E);
389 //=======================================================================
392 //=======================================================================
394 Standard_Integer BRepFilletAPI_MakeFillet::NbEdges(const Standard_Integer I)const
396 const Handle(ChFiDS_Spine)& Spine = myBuilder.Value(I);
397 Standard_Integer n = Spine->NbEdges();
401 //=======================================================================
404 //=======================================================================
406 const TopoDS_Edge& BRepFilletAPI_MakeFillet::Edge(const Standard_Integer I,
407 const Standard_Integer J)const
409 const Handle(ChFiDS_Spine)& Spine = myBuilder.Value(I);
410 const TopoDS_Edge& S = Spine->Edges(J);
415 //=======================================================================
418 //=======================================================================
420 void BRepFilletAPI_MakeFillet::Remove(const TopoDS_Edge& E)
426 //=======================================================================
429 //=======================================================================
431 Standard_Real BRepFilletAPI_MakeFillet::Length(const Standard_Integer IC)const
433 return myBuilder.Length(IC);
437 //=======================================================================
438 //function : FirstVertex
440 //=======================================================================
442 TopoDS_Vertex BRepFilletAPI_MakeFillet::FirstVertex(const Standard_Integer IC)const
444 return myBuilder.FirstVertex(IC);
448 //=======================================================================
449 //function : LastVertex
451 //=======================================================================
453 TopoDS_Vertex BRepFilletAPI_MakeFillet::LastVertex(const Standard_Integer IC)const
455 return myBuilder.LastVertex(IC);
459 //=======================================================================
460 //function : Abscissa
462 //=======================================================================
464 Standard_Real BRepFilletAPI_MakeFillet::Abscissa(const Standard_Integer IC,
465 const TopoDS_Vertex& V)const
467 return myBuilder.Abscissa(IC,V);
471 //=======================================================================
472 //function : RelativeAbscissa
474 //=======================================================================
476 Standard_Real BRepFilletAPI_MakeFillet::RelativeAbscissa(const Standard_Integer IC,
477 const TopoDS_Vertex& V)const
479 return myBuilder.RelativeAbscissa(IC,V);
483 //=======================================================================
484 //function : ClosedAndTangent
486 //=======================================================================
488 Standard_Boolean BRepFilletAPI_MakeFillet::ClosedAndTangent
489 (const Standard_Integer IC)const
491 return myBuilder.ClosedAndTangent(IC);
495 //=======================================================================
498 //=======================================================================
500 Standard_Boolean BRepFilletAPI_MakeFillet::Closed
501 (const Standard_Integer IC)const
503 return myBuilder.Closed(IC);
507 //=======================================================================
510 //=======================================================================
512 Handle(TopOpeBRepBuild_HBuilder) BRepFilletAPI_MakeFillet::Builder()const
514 return myBuilder.Builder();
518 //=======================================================================
521 //=======================================================================
523 void BRepFilletAPI_MakeFillet::Build()
526 if(myBuilder.IsDone()) {
528 myShape = myBuilder.Shape();
530 // creation of the Map.
532 for (ex.Init(myShape, TopAbs_FACE); ex.More(); ex.Next()) {
533 myMap.Add(ex.Current());
539 //=======================================================================
542 //=======================================================================
544 void BRepFilletAPI_MakeFillet::Reset()
551 //=======================================================================
552 //function : NbSurfaces
554 //=======================================================================
556 Standard_Integer BRepFilletAPI_MakeFillet::NbSurfaces() const
558 return (myBuilder.Builder()->DataStructure())->NbSurfaces();
561 //=======================================================================
562 //function : NewFaces
564 //=======================================================================
566 const TopTools_ListOfShape& BRepFilletAPI_MakeFillet::NewFaces
567 (const Standard_Integer I)
569 return (*(TopTools_ListOfShape*)&(myBuilder.Builder()->NewFaces(I)));
572 //=======================================================================
573 //function : Simulate
575 //=======================================================================
577 void BRepFilletAPI_MakeFillet::Simulate(const Standard_Integer IC)
579 myBuilder.Simulate(IC);
583 //=======================================================================
586 //=======================================================================
588 Standard_Integer BRepFilletAPI_MakeFillet::NbSurf(const Standard_Integer IC)const
590 return myBuilder.NbSurf(IC);
593 //=======================================================================
596 //=======================================================================
598 Handle(ChFiDS_SecHArray1) BRepFilletAPI_MakeFillet::Sect(const Standard_Integer IC,
599 const Standard_Integer IS)const
601 return myBuilder.Sect(IC, IS);
604 //=======================================================================
605 //function : Generated
607 //=======================================================================
609 const TopTools_ListOfShape& BRepFilletAPI_MakeFillet::Generated
610 (const TopoDS_Shape& EorV)
612 return myBuilder.Generated(EorV);
615 //=======================================================================
616 //function : Modified
618 //=======================================================================
620 const TopTools_ListOfShape& BRepFilletAPI_MakeFillet::Modified
621 (const TopoDS_Shape& F)
625 if (myBuilder.Builder()->IsSplit(F, TopAbs_OUT)) {
626 TopTools_ListIteratorOfListOfShape It(myBuilder.Builder()->Splits(F, TopAbs_OUT));
627 for(;It.More();It.Next()) {
628 myGenerated.Append(It.Value());
631 if (myBuilder.Builder()->IsSplit(F, TopAbs_IN)) {
632 TopTools_ListIteratorOfListOfShape It(myBuilder.Builder()->Splits(F, TopAbs_IN));
633 for(;It.More();It.Next()) {
634 myGenerated.Append(It.Value());
637 if (myBuilder.Builder()->IsSplit(F, TopAbs_ON)) {
638 TopTools_ListIteratorOfListOfShape It(myBuilder.Builder()->Splits(F, TopAbs_ON));
639 for(;It.More();It.Next()) {
640 myGenerated.Append(It.Value());
646 //=======================================================================
647 //function : IsDeleted
649 //=======================================================================
651 Standard_Boolean BRepFilletAPI_MakeFillet::IsDeleted(const TopoDS_Shape& F)
653 if (myMap.Contains(F) ||
654 myBuilder.Builder()->IsSplit (F, TopAbs_OUT) ||
655 myBuilder.Builder()->IsSplit (F, TopAbs_IN) ||
656 myBuilder.Builder()->IsSplit (F, TopAbs_ON))
657 return Standard_False;
659 return Standard_True;
662 //=======================================================================
663 //function : NbFaultyContours
665 //=======================================================================
667 Standard_Integer BRepFilletAPI_MakeFillet::NbFaultyContours() const
669 return myBuilder.NbFaultyContours();
671 //=======================================================================
672 //function : FaultyContour
674 //=======================================================================
676 Standard_Integer BRepFilletAPI_MakeFillet::FaultyContour(const Standard_Integer I) const
678 return myBuilder.FaultyContour(I);
681 //=======================================================================
682 //function : NbComputedSurfaces
684 //=======================================================================
686 Standard_Integer BRepFilletAPI_MakeFillet::NbComputedSurfaces(const Standard_Integer IC) const
688 return myBuilder.NbComputedSurfaces (IC);
691 //=======================================================================
692 //function : ComputedSurface
694 //=======================================================================
696 Handle(Geom_Surface) BRepFilletAPI_MakeFillet::ComputedSurface(const Standard_Integer IC,
697 const Standard_Integer IS) const
699 return myBuilder.ComputedSurface(IC,IS);
702 //=======================================================================
703 //function : NbFaultyVertices
705 //=======================================================================
707 Standard_Integer BRepFilletAPI_MakeFillet::NbFaultyVertices() const
709 return myBuilder.NbFaultyVertices();
712 //=======================================================================
713 //function : FaultyVertex
715 //=======================================================================
717 TopoDS_Vertex BRepFilletAPI_MakeFillet::FaultyVertex(const Standard_Integer IV) const
719 return myBuilder.FaultyVertex(IV);
722 //=======================================================================
723 //function : HasResult
725 //=======================================================================
727 Standard_Boolean BRepFilletAPI_MakeFillet::HasResult() const
729 return myBuilder.HasResult();
732 //=======================================================================
733 //function : BadShape
735 //=======================================================================
737 TopoDS_Shape BRepFilletAPI_MakeFillet::BadShape()const
739 return myBuilder.BadShape();
742 //=======================================================================
743 //function : StripeStatus
745 //=======================================================================
747 ChFiDS_ErrorStatus BRepFilletAPI_MakeFillet::StripeStatus(const Standard_Integer IC)const
749 return myBuilder.StripeStatus(IC);