Commit | Line | Data |
---|---|---|

42cf5bc1 | 1 | // Created on: 1995-08-31 |

2 | // Created by: Remi LEQUETTE | |

3 | // Copyright (c) 1995-1999 Matra Datavision | |

4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS | |

5 | // | |

6 | // This file is part of Open CASCADE Technology software library. | |

7 | // | |

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. | |

13 | // | |

14 | // Alternatively, this file may be used under the terms of Open CASCADE | |

15 | // commercial license or contractual agreement. | |

16 | ||

17 | #ifndef _BRepFilletAPI_MakeFillet2d_HeaderFile | |

18 | #define _BRepFilletAPI_MakeFillet2d_HeaderFile | |

19 | ||

20 | #include <Standard.hxx> | |

21 | #include <Standard_DefineAlloc.hxx> | |

22 | #include <Standard_Handle.hxx> | |

23 | ||

24 | #include <ChFi2d_Builder.hxx> | |

25 | #include <BRepBuilderAPI_MakeShape.hxx> | |

26 | #include <Standard_Real.hxx> | |

27 | #include <Standard_Boolean.hxx> | |

28 | #include <TopTools_SequenceOfShape.hxx> | |

29 | #include <Standard_Integer.hxx> | |

30 | #include <TopTools_ListOfShape.hxx> | |

31 | #include <ChFi2d_ConstructionError.hxx> | |

32 | class TopoDS_Face; | |

33 | class TopoDS_Edge; | |

34 | class TopoDS_Vertex; | |

35 | class TopoDS_Shape; | |

36 | ||

37 | ||

38 | //! Describes functions to build fillets and chamfers on the | |

39 | //! vertices of a planar face. | |

40 | //! Fillets and Chamfers on the Vertices of a Planar Face | |

41 | //! A MakeFillet2d object provides a framework for: | |

42 | //! - initializing the construction algorithm with a given face, | |

43 | //! - acquiring the data characterizing the fillets and chamfers, | |

44 | //! - building the fillets and chamfers, and constructing the | |

45 | //! resulting shape, and | |

46 | //! - consulting the result. | |

47 | //! Warning | |

48 | //! Only segments of straight lines and arcs of circles are | |

49 | //! treated. BSplines are not processed. | |

50 | class BRepFilletAPI_MakeFillet2d : public BRepBuilderAPI_MakeShape | |

51 | { | |

52 | public: | |

53 | ||

54 | DEFINE_STANDARD_ALLOC | |

55 | ||

56 | ||

57 | //! Initializes an empty algorithm for computing fillets and | |

58 | //! chamfers. The face on which the fillets and | |

59 | //! chamfers are built is defined using the Init function. | |

60 | //! The vertices on which fillets or chamfers are built are | |

61 | //! defined using the AddFillet or AddChamfer function. | |

62 | //! Warning | |

63 | //! The status of the initialization, as given by the Status | |

64 | //! function, can be one of the following: | |

65 | //! - ChFi2d_Ready if the initialization is correct, | |

66 | //! - ChFi2d_NotPlanar if F is not planar, | |

67 | //! - ChFi2d_NoFace if F is a null face. | |

68 | Standard_EXPORT BRepFilletAPI_MakeFillet2d(); | |

69 | ||

70 | //! Initializes an algorithm for computing fillets and chamfers on the face F. | |

71 | //! The vertices on which fillets or chamfers are built are | |

72 | //! defined using the AddFillet or AddChamfer function. | |

73 | //! Warning | |

74 | //! The status of the initialization, as given by the Status | |

75 | //! function, can be one of the following: | |

76 | //! - ChFi2d_Ready if the initialization is correct, | |

77 | //! - ChFi2d_NotPlanar if F is not planar, | |

78 | //! - ChFi2d_NoFace if F is a null face. | |

79 | Standard_EXPORT BRepFilletAPI_MakeFillet2d(const TopoDS_Face& F); | |

80 | ||

81 | //! Initializes this algorithm for constructing fillets or | |

82 | //! chamfers with the face F. | |

83 | //! Warning | |

84 | //! The status of the initialization, as given by the Status | |

85 | //! function, can be one of the following: | |

86 | //! - ChFi2d_Ready if the initialization is correct, | |

87 | //! - ChFi2d_NotPlanar if F is not planar, | |

88 | //! - ChFi2d_NoFace if F is a null face. | |

89 | Standard_EXPORT void Init (const TopoDS_Face& F); | |

90 | ||

91 | //! This initialize method allow to init the builder | |

92 | //! from a face <RefFace> and another face <ModFace> | |

93 | //! which derive from <RefFace>. This is usefull to | |

94 | //! modify a fillet or a chamfer already created on | |

95 | //! <ModFace> . | |

96 | Standard_EXPORT void Init (const TopoDS_Face& RefFace, const TopoDS_Face& ModFace); | |

97 | ||

98 | //! Adds a fillet of radius Radius between the two edges | |

99 | //! adjacent to the vertex V on the face modified by this | |

100 | //! algorithm. The two edges do not need to be rectilinear. | |

101 | //! This function returns the fillet and builds the resulting face. | |

102 | //! Warning | |

103 | //! The status of the construction, as given by the Status | |

104 | //! function, can be one of the following: | |

105 | //! - ChFi2d_IsDone if the fillet is built, | |

106 | //! - ChFi2d_ConnexionError if V does not belong to the initial face, | |

107 | //! - ChFi2d_ComputationError if Radius is too large | |

108 | //! to build a fillet between the two adjacent edges, | |

109 | //! - ChFi2d_NotAuthorized | |

110 | //! - if one of the two edges connected to V is a fillet or chamfer, or | |

111 | //! - if a curve other than a straight line or an arc of a | |

112 | //! circle is used as E, E1 or E2. | |

113 | //! Do not use the returned fillet if the status of the construction is not ChFi2d_IsDone. | |

114 | //! Exceptions | |

115 | //! Standard_NegativeValue if Radius is less than or equal to zero. | |

116 | Standard_EXPORT TopoDS_Edge AddFillet (const TopoDS_Vertex& V, const Standard_Real Radius); | |

117 | ||

118 | //! Assigns the radius Radius to the fillet Fillet already | |

119 | //! built on the face modified by this algorithm. | |

120 | //! This function returns the new fillet and modifies the existing face. | |

121 | //! Warning | |

122 | //! The status of the construction, as given by the Status | |

123 | //! function, can be one of the following: | |

124 | //! - ChFi2d_IsDone if the new fillet is built, | |

125 | //! - ChFi2d_ConnexionError if Fillet does not | |

126 | //! belong to the existing face, | |

127 | //! - ChFi2d_ComputationError if Radius is too | |

128 | //! large to build a fillet between the two adjacent edges. | |

129 | //! Do not use the returned fillet if the status of the | |

130 | //! construction is not ChFi2d_IsDone. | |

131 | //! Exceptions | |

132 | //! Standard_NegativeValue if Radius is less than or equal to zero. | |

133 | Standard_EXPORT TopoDS_Edge ModifyFillet (const TopoDS_Edge& Fillet, const Standard_Real Radius); | |

134 | ||

135 | //! Removes the fillet Fillet already built on the face | |

136 | //! modified by this algorithm. | |

137 | //! This function returns the vertex connecting the two | |

138 | //! adjacent edges of Fillet and modifies the existing face. | |

139 | //! Warning | |

140 | //! - The returned vertex is only valid if the Status | |

141 | //! function returns ChFi2d_IsDone. | |

142 | //! - A null vertex is returned if the edge Fillet does not | |

143 | //! belong to the initial face. | |

144 | Standard_EXPORT TopoDS_Vertex RemoveFillet (const TopoDS_Edge& Fillet); | |

145 | ||

146 | //! Adds a chamfer on the face modified by this algorithm | |

147 | //! between the two adjacent edges E1 and E2, where | |

148 | //! the extremities of the chamfer are on E1 and E2 at | |

149 | //! distances D1 and D2 respectively | |

150 | //! In cases where the edges are not rectilinear, distances | |

151 | //! are measured using the curvilinear abscissa of the | |

152 | //! edges and the angle is measured with respect to the | |

153 | //! tangent at the corresponding point. | |

154 | //! The angle Ang is given in radians. | |

155 | //! This function returns the chamfer and builds the resulting face. | |

156 | Standard_EXPORT TopoDS_Edge AddChamfer (const TopoDS_Edge& E1, const TopoDS_Edge& E2, const Standard_Real D1, const Standard_Real D2); | |

157 | ||

158 | //! Adds a chamfer on the face modified by this algorithm | |

159 | //! between the two edges connected by the vertex V, | |

160 | //! where E is one of the two edges. The chamfer makes | |

161 | //! an angle Ang with E and one of its extremities is on | |

162 | //! E at distance D from V. | |

163 | //! In cases where the edges are not rectilinear, distances | |

164 | //! are measured using the curvilinear abscissa of the | |

165 | //! edges and the angle is measured with respect to the | |

166 | //! tangent at the corresponding point. | |

167 | //! The angle Ang is given in radians. | |

168 | //! This function returns the chamfer and builds the resulting face. | |

169 | //! Warning | |

170 | //! The status of the construction, as given by the Status function, can | |

171 | //! be one of the following: | |

172 | //! - ChFi2d_IsDone if the chamfer is built, | |

173 | //! - ChFi2d_ParametersError if D1, D2, D or Ang is less than or equal to zero, | |

174 | //! - ChFi2d_ConnexionError if: | |

175 | //! - the edge E, E1 or E2 does not belong to the initial face, or | |

176 | //! - the edges E1 and E2 are not adjacent, or | |

177 | //! - the vertex V is not one of the limit points of the edge E, | |

178 | //! - ChFi2d_ComputationError if the parameters of the chamfer | |

179 | //! are too large to build a chamfer between the two adjacent edges, | |

180 | //! - ChFi2d_NotAuthorized if: | |

181 | //! - the edge E1, E2 or one of the two edges connected to V is a fillet or chamfer, or | |

182 | //! - a curve other than a straight line or an arc of a circle is used as E, E1 or E2. | |

183 | //! Do not use the returned chamfer if | |

184 | //! the status of the construction is not ChFi2d_IsDone. | |

185 | Standard_EXPORT TopoDS_Edge AddChamfer (const TopoDS_Edge& E, const TopoDS_Vertex& V, const Standard_Real D, const Standard_Real Ang); | |

186 | ||

187 | //! Modifies the chamfer Chamfer on the face modified | |

188 | //! by this algorithm, where: | |

189 | //! E1 and E2 are the two adjacent edges on which | |

190 | //! Chamfer is already built; the extremities of the new | |

191 | //! chamfer are on E1 and E2 at distances D1 and D2 respectively. | |

192 | Standard_EXPORT TopoDS_Edge ModifyChamfer (const TopoDS_Edge& Chamfer, const TopoDS_Edge& E1, const TopoDS_Edge& E2, const Standard_Real D1, const Standard_Real D2); | |

193 | ||

194 | //! Modifies the chamfer Chamfer on the face modified | |

195 | //! by this algorithm, where: | |

196 | //! E is one of the two adjacent edges on which | |

197 | //! Chamfer is already built; the new chamfer makes | |

198 | //! an angle Ang with E and one of its extremities is | |

199 | //! on E at distance D from the vertex on which the chamfer is built. | |

200 | //! In cases where the edges are not rectilinear, the | |

201 | //! distances are measured using the curvilinear abscissa | |

202 | //! of the edges and the angle is measured with respect | |

203 | //! to the tangent at the corresponding point. | |

204 | //! The angle Ang is given in radians. | |

205 | //! This function returns the new chamfer and modifies the existing face. | |

206 | //! Warning | |

207 | //! The status of the construction, as given by the Status | |

208 | //! function, can be one of the following: | |

209 | //! - ChFi2d_IsDone if the chamfer is built, | |

210 | //! - ChFi2d_ParametersError if D1, D2, D or Ang is less than or equal to zero, | |

211 | //! - ChFi2d_ConnexionError if: | |

212 | //! - the edge E, E1, E2 or Chamfer does not belong | |

213 | //! to the existing face, or | |

214 | //! - the edges E1 and E2 are not adjacent, | |

215 | //! - ChFi2d_ComputationError if the parameters of | |

216 | //! the chamfer are too large to build a chamfer | |

217 | //! between the two adjacent edges, | |

218 | //! - ChFi2d_NotAuthorized if E1 or E2 is a fillet or chamfer. | |

219 | //! Do not use the returned chamfer if the status of the | |

220 | //! construction is not ChFi2d_IsDone. | |

221 | Standard_EXPORT TopoDS_Edge ModifyChamfer (const TopoDS_Edge& Chamfer, const TopoDS_Edge& E, const Standard_Real D, const Standard_Real Ang); | |

222 | ||

223 | //! Removes the chamfer Chamfer already built on the face | |

224 | //! modified by this algorithm. | |

225 | //! This function returns the vertex connecting the two | |

226 | //! adjacent edges of Chamfer and modifies the existing face. | |

227 | //! Warning | |

228 | //! - The returned vertex is only valid if the Status | |

229 | //! function returns ChFi2d_IsDone. | |

230 | //! - A null vertex is returned if the edge Chamfer does | |

231 | //! not belong to the initial face. | |

232 | Standard_EXPORT TopoDS_Vertex RemoveChamfer (const TopoDS_Edge& Chamfer); | |

233 | ||

234 | //! Returns true if the edge E on the face modified by this | |

235 | //! algorithm is chamfered or filleted. | |

236 | //! Warning | |

237 | //! Returns false if E does not belong to the face modified by this algorithm. | |

238 | Standard_Boolean IsModified (const TopoDS_Edge& E) const; | |

239 | ||

240 | //! Returns the table of fillets on the face modified by this algorithm. | |

241 | const TopTools_SequenceOfShape& FilletEdges() const; | |

242 | ||

243 | //! Returns the number of fillets on the face modified by this algorithm. | |

244 | Standard_Integer NbFillet() const; | |

245 | ||

246 | //! Returns the table of chamfers on the face modified by this algorithm. | |

247 | const TopTools_SequenceOfShape& ChamferEdges() const; | |

248 | ||

249 | //! Returns the number of chamfers on the face modified by this algorithm. | |

250 | Standard_Integer NbChamfer() const; | |

251 | ||

252 | //! Returns the list of shapes modified from the shape | |

253 | //! <S>. | |

254 | Standard_EXPORT virtual const TopTools_ListOfShape& Modified (const TopoDS_Shape& S) Standard_OVERRIDE; | |

255 | ||

256 | //! returns the number of new curves | |

257 | //! after the shape creation. | |

258 | Standard_EXPORT Standard_Integer NbCurves() const; | |

259 | ||

260 | //! Return the Edges created for curve I. | |

261 | Standard_EXPORT const TopTools_ListOfShape& NewEdges (const Standard_Integer I); | |

262 | ||

263 | Standard_Boolean HasDescendant (const TopoDS_Edge& E) const; | |

264 | ||

265 | //! Returns the chamfered or filleted edge built from the | |

266 | //! edge E on the face modified by this algorithm. If E has | |

267 | //! not been modified, this function returns E. | |

268 | //! Exceptions | |

269 | //! Standard_NoSuchObject if the edge E does not | |

270 | //! belong to the initial face. | |

271 | const TopoDS_Edge& DescendantEdge (const TopoDS_Edge& E) const; | |

272 | ||

273 | //! Returns the basis edge on the face modified by this | |

274 | //! algorithm from which the chamfered or filleted edge E is | |

275 | //! built. If E has not been modified, this function returns E. | |

276 | //! Warning | |

277 | //! E is returned if it does not belong to the initial face. | |

278 | Standard_EXPORT const TopoDS_Edge& BasisEdge (const TopoDS_Edge& E) const; | |

279 | ||

280 | ChFi2d_ConstructionError Status() const; | |

281 | ||

282 | //! Update the result and set the Done flag | |

283 | Standard_EXPORT virtual void Build() Standard_OVERRIDE; | |

284 | ||

285 | ||

286 | ||

287 | ||

288 | protected: | |

289 | ||

290 | ||

291 | ||

292 | ||

293 | ||

294 | private: | |

295 | ||

296 | ||

297 | ||

298 | ChFi2d_Builder myMakeChFi2d; | |

299 | ||

300 | ||

301 | }; | |

302 | ||

303 | ||

304 | #include <BRepFilletAPI_MakeFillet2d.lxx> | |

305 | ||

306 | ||

307 | ||

308 | ||

309 | ||

310 | #endif // _BRepFilletAPI_MakeFillet2d_HeaderFile |