42cf5bc1 |
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 |
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_MakeFillet_HeaderFile |
18 | #define _BRepFilletAPI_MakeFillet_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <ChFi3d_FilBuilder.hxx> |
25 | #include <TopTools_MapOfShape.hxx> |
26 | #include <BRepFilletAPI_LocalOperation.hxx> |
27 | #include <ChFi3d_FilletShape.hxx> |
28 | #include <Standard_Real.hxx> |
29 | #include <GeomAbs_Shape.hxx> |
30 | #include <TColgp_Array1OfPnt2d.hxx> |
31 | #include <Standard_Integer.hxx> |
32 | #include <Standard_Boolean.hxx> |
33 | #include <TopTools_ListOfShape.hxx> |
34 | #include <ChFiDS_SecHArray1.hxx> |
35 | #include <ChFiDS_ErrorStatus.hxx> |
36 | class StdFail_NotDone; |
37 | class Standard_NoSuchObject; |
38 | class TopoDS_Shape; |
39 | class TopoDS_Edge; |
40 | class Law_Function; |
41 | class TopoDS_Vertex; |
42 | class TopOpeBRepBuild_HBuilder; |
43 | class Geom_Surface; |
44 | |
45 | |
46 | //! Describes functions to build fillets on the broken edges of a shell or solid. |
47 | //! A MakeFillet object provides a framework for: |
48 | //! - initializing the construction algorithm with a given shape, |
49 | //! - acquiring the data characterizing the fillets, |
50 | //! - building the fillets and constructing the resulting shape, and |
51 | //! - consulting the result. |
52 | class BRepFilletAPI_MakeFillet : public BRepFilletAPI_LocalOperation |
53 | { |
54 | public: |
55 | |
56 | DEFINE_STANDARD_ALLOC |
57 | |
58 | |
59 | //! Initializes the computation of the fillets. |
60 | //! <FShape> sets the type of fillet surface. The |
61 | //! default value is ChFi3d_Rational (classical nurbs |
62 | //! representation of circles). ChFi3d_QuasiAngular |
63 | //! corresponds to a nurbs representation of circles |
64 | //! which parameterisation matches the circle one. |
65 | //! ChFi3d_Polynomial corresponds to a polynomial |
66 | //! representation of circles. |
67 | Standard_EXPORT BRepFilletAPI_MakeFillet(const TopoDS_Shape& S, const ChFi3d_FilletShape FShape = ChFi3d_Rational); |
68 | |
69 | Standard_EXPORT void SetParams (const Standard_Real Tang, const Standard_Real Tesp, const Standard_Real T2d, const Standard_Real TApp3d, const Standard_Real TolApp2d, const Standard_Real Fleche); |
70 | |
71 | //! Changes the parameters of continiuity |
72 | //! InternalContinuity to produce fillet'surfaces with |
73 | //! an continuity Ci (i=0,1 or 2). |
74 | //! By defaultInternalContinuity = GeomAbs_C1. |
75 | //! AngularTolerance is the G1 tolerance between fillet |
76 | //! and support'faces. |
77 | Standard_EXPORT void SetContinuity (const GeomAbs_Shape InternalContinuity, const Standard_Real AngularTolerance); |
78 | |
79 | //! Adds a fillet contour in the builder (builds a |
80 | //! contour of tangent edges). |
81 | //! The Radius must be set after. |
82 | Standard_EXPORT void Add (const TopoDS_Edge& E); |
83 | |
84 | //! Adds a fillet description in the builder |
85 | //! - builds a contour of tangent edges, |
86 | //! - sets the radius. |
87 | Standard_EXPORT void Add (const Standard_Real Radius, const TopoDS_Edge& E); |
88 | |
89 | //! Adds a fillet description in the builder |
90 | //! - builds a contour of tangent edges, |
91 | //! - sets a linear radius evolution law between |
92 | //! the first and last vertex of the spine. |
93 | Standard_EXPORT void Add (const Standard_Real R1, const Standard_Real R2, const TopoDS_Edge& E); |
94 | |
95 | //! Adds a fillet description in the builder |
96 | //! - builds a contour of tangent edges, |
97 | //! - sest the radius evolution law. |
98 | Standard_EXPORT void Add (const Handle(Law_Function)& L, const TopoDS_Edge& E); |
99 | |
100 | //! Adds a fillet description in the builder |
101 | //! - builds a contour of tangent edges, |
102 | //! - sets the radius evolution law interpolating the values |
103 | //! given in the array UandR : |
104 | //! |
105 | //! p2d.X() = relative parameter on the spine [0,1] |
106 | //! p2d.Y() = value of the radius. |
107 | Standard_EXPORT void Add (const TColgp_Array1OfPnt2d& UandR, const TopoDS_Edge& E); |
108 | |
109 | //! Sets the parameters of the fillet |
110 | //! along the contour of index IC generated using the Add function |
111 | //! in the internal data structure of |
112 | //! this algorithm, where Radius is the radius of the fillet. |
113 | Standard_EXPORT void SetRadius (const Standard_Real Radius, const Standard_Integer IC, const Standard_Integer IinC); |
114 | |
115 | //! Sets the parameters of the fillet |
116 | //! along the contour of index IC generated using the Add function |
117 | //! in the internal data structure of this algorithm, where the radius of the |
118 | //! fillet evolves according to a linear evolution law defined |
119 | //! from R1 to R2, between the first and last vertices of the contour of index IC. |
120 | Standard_EXPORT void SetRadius (const Standard_Real R1, const Standard_Real R2, const Standard_Integer IC, const Standard_Integer IinC); |
121 | |
122 | //! Sets the parameters of the fillet |
123 | //! along the contour of index IC generated using the Add function |
124 | //! in the internal data structure of this algorithm, where the radius of the |
125 | //! fillet evolves according to the evolution law L, between the |
126 | //! first and last vertices of the contour of index IC. |
127 | Standard_EXPORT void SetRadius (const Handle(Law_Function)& L, const Standard_Integer IC, const Standard_Integer IinC); |
128 | |
129 | //! Sets the parameters of the fillet |
130 | //! along the contour of index IC generated using the Add function |
131 | //! in the internal data structure of this algorithm, |
132 | //! where the radius of the fillet evolves according to the evolution law |
133 | //! which interpolates the set of parameter and radius pairs given |
134 | //! in the array UandR as follows: |
135 | //! - the X coordinate of a point in UandR defines a |
136 | //! relative parameter on the contour (i.e. a parameter between 0 and 1), |
137 | //! - the Y coordinate of a point in UandR gives the |
138 | //! corresponding value of the radius, and the radius evolves |
139 | //! between the first and last vertices of the contour of index IC. |
140 | Standard_EXPORT void SetRadius (const TColgp_Array1OfPnt2d& UandR, const Standard_Integer IC, const Standard_Integer IinC); |
141 | |
142 | //! Erases the radius information on the contour of index |
143 | //! IC in the internal data structure of this algorithm. |
144 | //! Use the SetRadius function to reset this data. |
145 | //! Warning |
146 | //! Nothing is done if IC is outside the bounds of the table of contours. |
147 | Standard_EXPORT void ResetContour (const Standard_Integer IC); |
148 | |
149 | //! Returns true if the radius of the fillet along the contour of index IC |
150 | //! in the internal data structure of this algorithm is constant, |
151 | //! Warning |
152 | //! False is returned if IC is outside the bounds of the table |
153 | //! of contours or if E does not belong to the contour of index IC. |
154 | Standard_EXPORT Standard_Boolean IsConstant (const Standard_Integer IC); |
155 | |
156 | //! Returns the radius of the fillet along the contour of index IC in the |
157 | //! internal data structure of this algorithm |
158 | //! Warning |
159 | //! - Use this function only if the radius is constant. |
160 | //! - -1. is returned if IC is outside the bounds of the |
161 | //! table of contours or if E does not belong to the contour of index IC. |
162 | Standard_EXPORT Standard_Real Radius (const Standard_Integer IC); |
163 | |
164 | //! Returns true if the radius of the fillet along the edge E of the |
165 | //! contour of index IC in the internal data structure of |
166 | //! this algorithm is constant. |
167 | //! Warning |
168 | //! False is returned if IC is outside the bounds of the table |
169 | //! of contours or if E does not belong to the contour of index IC. |
170 | Standard_EXPORT Standard_Boolean IsConstant (const Standard_Integer IC, const TopoDS_Edge& E); |
171 | |
172 | //! Returns the radius of the fillet along the edge E of the contour of index |
173 | //! IC in the internal data structure of this algorithm. |
174 | //! Warning |
175 | //! - Use this function only if the radius is constant. |
176 | //! - -1 is returned if IC is outside the bounds of the |
177 | //! table of contours or if E does not belong to the contour of index IC. |
178 | Standard_EXPORT Standard_Real Radius (const Standard_Integer IC, const TopoDS_Edge& E); |
179 | |
180 | //! Assigns Radius as the radius of the fillet on the edge E |
181 | Standard_EXPORT void SetRadius (const Standard_Real Radius, const Standard_Integer IC, const TopoDS_Edge& E); |
182 | |
183 | Standard_EXPORT void SetRadius (const Standard_Real Radius, const Standard_Integer IC, const TopoDS_Vertex& V); |
184 | |
185 | Standard_EXPORT Standard_Boolean GetBounds (const Standard_Integer IC, const TopoDS_Edge& E, Standard_Real& F, Standard_Real& L); |
186 | |
187 | Standard_EXPORT Handle(Law_Function) GetLaw (const Standard_Integer IC, const TopoDS_Edge& E); |
188 | |
189 | Standard_EXPORT void SetLaw (const Standard_Integer IC, const TopoDS_Edge& E, const Handle(Law_Function)& L); |
190 | |
191 | //! Assigns FShape as the type of fillet shape built by this algorithm. |
192 | Standard_EXPORT void SetFilletShape (const ChFi3d_FilletShape FShape); |
193 | |
194 | //! Returns the type of fillet shape built by this algorithm. |
195 | Standard_EXPORT ChFi3d_FilletShape GetFilletShape() const; |
196 | |
197 | //! Returns the number of contours generated using the |
198 | //! Add function in the internal data structure of this algorithm. |
199 | Standard_EXPORT Standard_Integer NbContours() const; |
200 | |
201 | //! Returns the index of the contour in the internal data |
202 | //! structure of this algorithm which contains the edge E of the shape. |
203 | //! This function returns 0 if the edge E does not belong to any contour. |
204 | //! Warning |
205 | //! This index can change if a contour is removed from the |
206 | //! internal data structure of this algorithm using the function Remove. |
207 | Standard_EXPORT Standard_Integer Contour (const TopoDS_Edge& E) const; |
208 | |
209 | //! Returns the number of edges in the contour of index I in |
210 | //! the internal data structure of this algorithm. |
211 | //! Warning |
212 | //! Returns 0 if I is outside the bounds of the table of contours. |
213 | Standard_EXPORT Standard_Integer NbEdges (const Standard_Integer I) const; |
214 | |
215 | //! Returns the edge of index J in the contour of index I in |
216 | //! the internal data structure of this algorithm. |
217 | //! Warning |
218 | //! Returns a null shape if: |
219 | //! - I is outside the bounds of the table of contours, or |
220 | //! - J is outside the bounds of the table of edges of the index I contour. |
221 | Standard_EXPORT const TopoDS_Edge& Edge (const Standard_Integer I, const Standard_Integer J) const; |
222 | |
223 | //! Removes the contour in the internal data structure of |
224 | //! this algorithm which contains the edge E of the shape. |
225 | //! Warning |
226 | //! Nothing is done if the edge E does not belong to the |
227 | //! contour in the internal data structure of this algorithm. |
228 | Standard_EXPORT void Remove (const TopoDS_Edge& E); |
229 | |
230 | //! Returns the length of the contour of index IC in the |
231 | //! internal data structure of this algorithm. |
232 | //! Warning |
233 | //! Returns -1. if IC is outside the bounds of the table of contours. |
234 | Standard_EXPORT Standard_Real Length (const Standard_Integer IC) const; |
235 | |
236 | //! Returns the first vertex of the contour of index IC |
237 | //! in the internal data structure of this algorithm. |
238 | //! Warning |
239 | //! Returns a null shape if IC is outside the bounds of the table of contours. |
240 | Standard_EXPORT TopoDS_Vertex FirstVertex (const Standard_Integer IC) const; |
241 | |
242 | //! Returns the last vertex of the contour of index IC |
243 | //! in the internal data structure of this algorithm. |
244 | //! Warning |
245 | //! Returns a null shape if IC is outside the bounds of the table of contours. |
246 | Standard_EXPORT TopoDS_Vertex LastVertex (const Standard_Integer IC) const; |
247 | |
248 | //! Returns the curvilinear abscissa of the vertex V on the |
249 | //! contour of index IC in the internal data structure of this algorithm. |
250 | //! Warning |
251 | //! Returns -1. if: |
252 | //! - IC is outside the bounds of the table of contours, or |
253 | //! - V is not on the contour of index IC. |
254 | Standard_EXPORT Standard_Real Abscissa (const Standard_Integer IC, const TopoDS_Vertex& V) const; |
255 | |
256 | //! Returns the relative curvilinear abscissa (i.e. between 0 |
257 | //! and 1) of the vertex V on the contour of index IC in the |
258 | //! internal data structure of this algorithm. |
259 | //! Warning |
260 | //! Returns -1. if: |
261 | //! - IC is outside the bounds of the table of contours, or |
262 | //! - V is not on the contour of index IC. |
263 | Standard_EXPORT Standard_Real RelativeAbscissa (const Standard_Integer IC, const TopoDS_Vertex& V) const; |
264 | |
265 | //! Returns true if the contour of index IC in the internal |
266 | //! data structure of this algorithm is closed and tangential |
267 | //! at the point of closure. |
268 | //! Warning |
269 | //! Returns false if IC is outside the bounds of the table of contours. |
270 | Standard_EXPORT Standard_Boolean ClosedAndTangent (const Standard_Integer IC) const; |
271 | |
272 | //! Returns true if the contour of index IC in the internal |
273 | //! data structure of this algorithm is closed. |
274 | //! Warning |
275 | //! Returns false if IC is outside the bounds of the table of contours. |
276 | Standard_EXPORT Standard_Boolean Closed (const Standard_Integer IC) const; |
277 | |
278 | //! Builds the fillets on all the contours in the internal data |
279 | //! structure of this algorithm and constructs the resulting shape. |
280 | //! Use the function IsDone to verify that the filleted shape |
281 | //! is built. Use the function Shape to retrieve the filleted shape. |
282 | //! Warning |
283 | //! The construction of fillets implements highly complex |
284 | //! construction algorithms. Consequently, there may be |
285 | //! instances where the algorithm fails, for example if the |
286 | //! data defining the radius of the fillet is not compatible |
287 | //! with the geometry of the initial shape. There is no initial |
288 | //! analysis of errors and they only become evident at the |
289 | //! construction stage. |
290 | //! Additionally, in the current software release, the |
291 | //! following cases are not handled: |
292 | //! - the end point of the contour is the point of |
293 | //! intersection of 4 or more edges of the shape, or |
294 | //! - the intersection of the fillet with a face which limits |
295 | //! the contour is not fully contained in this face. |
296 | Standard_EXPORT virtual void Build() Standard_OVERRIDE; |
297 | |
298 | //! Reinitializes this algorithm, thus canceling the effects of the Build function. |
299 | //! This function allows modifications to be made to the |
300 | //! contours and fillet parameters in order to rebuild the shape. |
301 | Standard_EXPORT void Reset(); |
302 | |
303 | //! Returns the internal topology building algorithm. |
304 | Standard_EXPORT Handle(TopOpeBRepBuild_HBuilder) Builder() const; |
305 | |
306 | //! Returns the list of shapes generated from the |
307 | //! shape <EorV>. |
308 | Standard_EXPORT virtual const TopTools_ListOfShape& Generated (const TopoDS_Shape& EorV) Standard_OVERRIDE; |
309 | |
310 | //! Returns the list of shapes modified from the shape |
311 | //! <F>. |
312 | Standard_EXPORT virtual const TopTools_ListOfShape& Modified (const TopoDS_Shape& F) Standard_OVERRIDE; |
313 | |
314 | Standard_EXPORT virtual Standard_Boolean IsDeleted (const TopoDS_Shape& F) Standard_OVERRIDE; |
315 | |
316 | //! returns the number of surfaces |
317 | //! after the shape creation. |
318 | Standard_EXPORT Standard_Integer NbSurfaces() const; |
319 | |
320 | //! Return the faces created for surface <I>. |
321 | Standard_EXPORT const TopTools_ListOfShape& NewFaces (const Standard_Integer I); |
322 | |
323 | Standard_EXPORT void Simulate (const Standard_Integer IC); |
324 | |
325 | Standard_EXPORT Standard_Integer NbSurf (const Standard_Integer IC) const; |
326 | |
327 | Standard_EXPORT Handle(ChFiDS_SecHArray1) Sect (const Standard_Integer IC, const Standard_Integer IS) const; |
328 | |
329 | //! Returns the number of contours where the computation |
330 | //! of the fillet failed |
331 | Standard_EXPORT Standard_Integer NbFaultyContours() const; |
332 | |
333 | //! for each I in [1.. NbFaultyContours] returns the index IC of |
334 | //! the contour where the computation of the fillet failed. |
335 | //! the method NbEdges(IC) gives the number of edges in the contour IC |
336 | //! the method Edge(IC,ie) gives the edge number ie of the contour IC |
337 | Standard_EXPORT Standard_Integer FaultyContour (const Standard_Integer I) const; |
338 | |
339 | //! returns the number of surfaces which have been |
340 | //! computed on the contour IC |
341 | Standard_EXPORT Standard_Integer NbComputedSurfaces (const Standard_Integer IC) const; |
342 | |
343 | //! returns the surface number IS concerning the contour IC |
344 | Standard_EXPORT Handle(Geom_Surface) ComputedSurface (const Standard_Integer IC, const Standard_Integer IS) const; |
345 | |
346 | //! returns the number of vertices where the computation failed |
347 | Standard_EXPORT Standard_Integer NbFaultyVertices() const; |
348 | |
349 | //! returns the vertex where the computation failed |
350 | Standard_EXPORT TopoDS_Vertex FaultyVertex (const Standard_Integer IV) const; |
351 | |
352 | //! returns true if a part of the result has been computed |
353 | //! if the filling in a corner failed a shape with a hole is returned |
354 | Standard_EXPORT Standard_Boolean HasResult() const; |
355 | |
356 | //! if (HasResult()) returns the partial result |
357 | Standard_EXPORT TopoDS_Shape BadShape() const; |
358 | |
359 | //! returns the status concerning the contour IC in case of error |
360 | //! ChFiDS_Ok : the computation is Ok |
361 | //! ChFiDS_StartsolFailure : the computation can't start, perhaps the |
362 | //! the radius is too big |
363 | //! ChFiDS_TwistedSurface : the computation failed because of a twisted |
364 | //! surface |
365 | //! ChFiDS_WalkingFailure : there is a problem in the walking |
366 | //! ChFiDS_Error: other error different from above |
367 | Standard_EXPORT ChFiDS_ErrorStatus StripeStatus (const Standard_Integer IC) const; |
368 | |
369 | |
370 | |
371 | |
372 | protected: |
373 | |
374 | |
375 | |
376 | |
377 | |
378 | private: |
379 | |
380 | |
381 | |
382 | ChFi3d_FilBuilder myBuilder; |
383 | TopTools_MapOfShape myMap; |
384 | |
385 | |
386 | }; |
387 | |
388 | |
389 | |
390 | |
391 | |
392 | |
393 | |
394 | #endif // _BRepFilletAPI_MakeFillet_HeaderFile |