2 #include <Standard_Stream.hxx>
4 #include <GEOMImpl_FilletDriver.hxx>
5 #include <GEOMImpl_IFillet.hxx>
6 #include <GEOMImpl_Types.hxx>
7 #include <GEOMImpl_ILocalOperations.hxx>
8 #include <GEOM_Function.hxx>
10 #include <BRepFilletAPI_MakeFillet.hxx>
11 #include <BRepCheck_Analyzer.hxx>
12 #include <BRep_Tool.hxx>
15 #include <TopoDS_Shape.hxx>
16 #include <TopoDS_Edge.hxx>
18 #include <TopExp_Explorer.hxx>
20 #include <Precision.hxx>
22 #include <StdFail_NotDone.hxx>
24 //=======================================================================
27 //=======================================================================
28 const Standard_GUID& GEOMImpl_FilletDriver::GetID()
30 static Standard_GUID aFilletDriver("FF1BBB41-5D14-4df2-980B-3A668264EA16");
35 //=======================================================================
36 //function : GEOMImpl_FilletDriver
38 //=======================================================================
39 GEOMImpl_FilletDriver::GEOMImpl_FilletDriver()
43 //=======================================================================
46 //=======================================================================
47 Standard_Integer GEOMImpl_FilletDriver::Execute(TFunction_Logbook& log) const
49 if (Label().IsNull()) return 0;
50 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
52 GEOMImpl_IFillet aCI (aFunction);
53 Standard_Integer aType = aFunction->GetType();
57 Handle(GEOM_Function) aRefShape = aCI.GetShape();
58 TopoDS_Shape aShapeBase = aRefShape->GetValue();
59 BRepFilletAPI_MakeFillet fill (aShapeBase);
61 if (aType == FILLET_SHAPE_ALL) {
62 TopExp_Explorer Exp (aShapeBase, TopAbs_EDGE);
63 for (; Exp.More(); Exp.Next()) {
64 TopoDS_Edge E = TopoDS::Edge(Exp.Current());
67 } else if (aType == FILLET_SHAPE_EDGES) {
68 int aLen = aCI.GetLength();
70 for (; ind <= aLen; ind++) {
71 TopoDS_Shape aShapeEdge;
72 if (GEOMImpl_ILocalOperations::GetSubShape
73 (aShapeBase, aCI.GetEdge(ind), aShapeEdge)) {
74 fill.Add(TopoDS::Edge(aShapeEdge));
77 } else if (aType == FILLET_SHAPE_FACES) {
78 int aLen = aCI.GetLength();
80 for (; ind <= aLen; ind++) {
81 TopoDS_Shape aShapeFace;
82 if (GEOMImpl_ILocalOperations::GetSubShape
83 (aShapeBase, aCI.GetFace(ind), aShapeFace)) {
84 TopExp_Explorer Exp (aShapeFace, TopAbs_EDGE);
85 for (; Exp.More(); Exp.Next()) {
86 fill.Add(TopoDS::Edge(Exp.Current()));
93 for (int i = 1; i <= fill.NbContours(); i++) {
94 fill.SetRadius(aCI.GetR(), i, i);
98 StdFail_NotDone::Raise("Fillet can't be computed on the given shape with the given radius");
100 aShape = fill.Shape();
102 if (aShape.IsNull()) return 0;
104 // Check shape validity
105 BRepCheck_Analyzer ana (aShape, false);
106 if (!ana.IsValid()) {
107 StdFail_NotDone::Raise("Fillet algorithm have produced an invalid shape result");
110 aFunction->SetValue(aShape);
112 log.SetTouched(Label());
118 //=======================================================================
119 //function : GEOMImpl_FilletDriver_Type_
121 //=======================================================================
122 Standard_EXPORT Handle_Standard_Type& GEOMImpl_FilletDriver_Type_()
125 static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
126 if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
127 static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
128 if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
129 static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
130 if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
133 static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
134 static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_FilletDriver",
135 sizeof(GEOMImpl_FilletDriver),
137 (Standard_Address)_Ancestors,
138 (Standard_Address)NULL);
143 //=======================================================================
144 //function : DownCast
146 //=======================================================================
147 const Handle(GEOMImpl_FilletDriver) Handle(GEOMImpl_FilletDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
149 Handle(GEOMImpl_FilletDriver) _anOtherObject;
151 if (!AnObject.IsNull()) {
152 if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_FilletDriver))) {
153 _anOtherObject = Handle(GEOMImpl_FilletDriver)((Handle(GEOMImpl_FilletDriver)&)AnObject);
157 return _anOtherObject ;