3 #include "GEOMImpl_FilletDriver.hxx"
4 #include "GEOMImpl_IFillet.hxx"
5 #include "GEOMImpl_Types.hxx"
6 #include "GEOMImpl_ILocalOperations.hxx"
7 #include "GEOM_Function.hxx"
9 #include <BRepFilletAPI_MakeFillet.hxx>
10 #include <BRepCheck_Analyzer.hxx>
11 #include <BRep_Tool.hxx>
14 #include <TopoDS_Shape.hxx>
15 #include <TopoDS_Edge.hxx>
17 #include <TopExp_Explorer.hxx>
19 #include <Precision.hxx>
21 #include <StdFail_NotDone.hxx>
23 //=======================================================================
26 //=======================================================================
27 const Standard_GUID& GEOMImpl_FilletDriver::GetID()
29 static Standard_GUID aFilletDriver("FF1BBB41-5D14-4df2-980B-3A668264EA16");
34 //=======================================================================
35 //function : GEOMImpl_FilletDriver
37 //=======================================================================
38 GEOMImpl_FilletDriver::GEOMImpl_FilletDriver()
42 //=======================================================================
45 //=======================================================================
46 Standard_Integer GEOMImpl_FilletDriver::Execute(TFunction_Logbook& log) const
48 if (Label().IsNull()) return 0;
49 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
51 GEOMImpl_IFillet aCI (aFunction);
52 Standard_Integer aType = aFunction->GetType();
56 Handle(GEOM_Function) aRefShape = aCI.GetShape();
57 TopoDS_Shape aShapeBase = aRefShape->GetValue();
58 BRepFilletAPI_MakeFillet fill (aShapeBase);
60 if (aType == FILLET_SHAPE_ALL) {
61 TopExp_Explorer Exp (aShapeBase, TopAbs_EDGE);
62 for (; Exp.More(); Exp.Next()) {
63 TopoDS_Edge E = TopoDS::Edge(Exp.Current());
66 } else if (aType == FILLET_SHAPE_EDGES) {
67 int aLen = aCI.GetLength();
69 for (; ind <= aLen; ind++) {
70 TopoDS_Shape aShapeEdge;
71 if (GEOMImpl_ILocalOperations::GetSubShape
72 (aShapeBase, aCI.GetEdge(ind), aShapeEdge)) {
73 fill.Add(TopoDS::Edge(aShapeEdge));
76 } else if (aType == FILLET_SHAPE_FACES) {
77 int aLen = aCI.GetLength();
79 for (; ind <= aLen; ind++) {
80 TopoDS_Shape aShapeFace;
81 if (GEOMImpl_ILocalOperations::GetSubShape
82 (aShapeBase, aCI.GetFace(ind), aShapeFace)) {
83 TopExp_Explorer Exp (aShapeFace, TopAbs_EDGE);
84 for (; Exp.More(); Exp.Next()) {
85 fill.Add(TopoDS::Edge(Exp.Current()));
92 for (int i = 1; i <= fill.NbContours(); i++) {
93 fill.SetRadius(aCI.GetR(), i, i);
97 StdFail_NotDone::Raise("Fillet can't be computed on the given shape with the given radius");
99 aShape = fill.Shape();
101 if (aShape.IsNull()) return 0;
103 // Check shape validity
104 BRepCheck_Analyzer ana (aShape, false);
105 if (!ana.IsValid()) {
106 StdFail_NotDone::Raise("Fillet algorithm have produced an invalid shape result");
109 aFunction->SetValue(aShape);
111 log.SetTouched(Label());
117 //=======================================================================
118 //function : GEOMImpl_FilletDriver_Type_
120 //=======================================================================
121 Standard_EXPORT Handle_Standard_Type& GEOMImpl_FilletDriver_Type_()
124 static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
125 if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
126 static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
127 if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
128 static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
129 if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
132 static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
133 static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_FilletDriver",
134 sizeof(GEOMImpl_FilletDriver),
136 (Standard_Address)_Ancestors,
137 (Standard_Address)NULL);
142 //=======================================================================
143 //function : DownCast
145 //=======================================================================
146 const Handle(GEOMImpl_FilletDriver) Handle(GEOMImpl_FilletDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
148 Handle(GEOMImpl_FilletDriver) _anOtherObject;
150 if (!AnObject.IsNull()) {
151 if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_FilletDriver))) {
152 _anOtherObject = Handle(GEOMImpl_FilletDriver)((Handle(GEOMImpl_FilletDriver)&)AnObject);
156 return _anOtherObject ;