42cf5bc1 |
1 | // Created on: 1995-02-22 |
2 | // Created by: Jacques GOUSSARD |
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 _BRepOffsetAPI_DraftAngle_HeaderFile |
18 | #define _BRepOffsetAPI_DraftAngle_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <TopTools_ListOfShape.hxx> |
25 | #include <BRepBuilderAPI_ModifyShape.hxx> |
26 | #include <Standard_Real.hxx> |
27 | #include <Standard_Boolean.hxx> |
28 | #include <Draft_ErrorStatus.hxx> |
29 | class StdFail_NotDone; |
30 | class Standard_NullObject; |
31 | class Standard_NoSuchObject; |
32 | class Standard_ConstructionError; |
33 | class TopoDS_Shape; |
34 | class TopoDS_Face; |
35 | class gp_Dir; |
36 | class gp_Pln; |
37 | |
38 | |
39 | //! Taper-adding transformations on a shape. |
40 | //! The resulting shape is constructed by defining one face |
41 | //! to be tapered after another one, as well as the |
42 | //! geometric properties of their tapered transformation. |
43 | //! Each tapered transformation is propagated along the |
44 | //! series of faces which are tangential to one another and |
45 | //! which contains the face to be tapered. |
46 | //! This algorithm is useful in the construction of molds or |
47 | //! dies. It facilitates the removal of the article being produced. |
48 | //! A DraftAngle object provides a framework for: |
49 | //! - initializing the construction algorithm with a given shape, |
50 | //! - acquiring the data characterizing the faces to be tapered, |
51 | //! - implementing the construction algorithm, and |
52 | //! - consulting the results. |
53 | //! Warning |
54 | //! - This algorithm treats planar, cylindrical and conical faces. |
55 | //! - Do not use shapes, which with a draft angle added to |
56 | //! a face would modify the topology. This would, for |
57 | //! example, involve creation of new vertices, edges or |
58 | //! faces, or suppression of existing vertices, edges or faces. |
59 | //! - Any face, which is continuous in tangency with the |
60 | //! face to be tapered, will also be tapered. These |
61 | //! connected faces must also respect the above criteria. |
62 | class BRepOffsetAPI_DraftAngle : public BRepBuilderAPI_ModifyShape |
63 | { |
64 | public: |
65 | |
66 | DEFINE_STANDARD_ALLOC |
67 | |
68 | |
69 | //! Constructs an empty algorithm to perform |
70 | //! taper-adding transformations on faces of a shape. |
71 | //! Use the Init function to define the shape to be tapered. |
72 | Standard_EXPORT BRepOffsetAPI_DraftAngle(); |
73 | |
74 | //! Initializes an algorithm to perform taper-adding |
75 | //! transformations on faces of the shape S. |
76 | //! S will be referred to as the initial shape of the algorithm. |
77 | Standard_EXPORT BRepOffsetAPI_DraftAngle(const TopoDS_Shape& S); |
78 | |
79 | //! Cancels the results of all taper-adding transformations |
80 | //! performed by this algorithm on the initial shape. These |
81 | //! results will have been defined by successive calls to the function Add. |
82 | Standard_EXPORT void Clear(); |
83 | |
84 | //! Initializes, or reinitializes this taper-adding algorithm with the shape S. |
85 | //! S will be referred to as the initial shape of this algorithm. |
86 | Standard_EXPORT void Init (const TopoDS_Shape& S); |
87 | |
88 | //! Adds the face F, the direction |
89 | //! Direction, the angle Angle, the plane NeutralPlane, and the flag |
90 | //! Flag to the framework created at construction time, and with this |
91 | //! data, defines the taper-adding transformation. |
92 | //! F is a face, which belongs to the initial shape of this algorithm or |
93 | //! to the shape loaded by the function Init. |
94 | //! Only planar, cylindrical or conical faces can be tapered: |
95 | //! - If the face F is planar, it is tapered by inclining it |
96 | //! through the angle Angle about the line of intersection between the |
97 | //! plane NeutralPlane and F. |
98 | //! Direction indicates the side of NeutralPlane from which matter is |
99 | //! removed if Angle is positive or added if Angle is negative. |
100 | //! - If F is cylindrical or conical, it is transformed in the |
101 | //! same way on a single face, resulting in a conical face if F |
102 | //! is cylindrical, and a conical or cylindrical face if it is already conical. |
103 | //! The taper-adding transformation is propagated from the face F along |
104 | //! the series of planar, cylindrical or conical faces containing F, |
105 | //! which are tangential to one another. |
106 | //! Use the function AddDone to check if this taper-adding transformation is successful. |
107 | //! Warning |
108 | //! Nothing is done if: |
109 | //! - the face F does not belong to the initial shape of this algorithm, or |
110 | //! - the face F is not planar, cylindrical or conical. |
111 | //! Exceptions |
112 | //! - Standard_NullObject if the initial shape is not |
113 | //! defined, i.e. if this algorithm has not been initialized |
114 | //! with the non-empty constructor or the Init function. |
115 | //! - Standard_ConstructionError if the previous call to |
116 | //! Add has failed. The function AddDone ought to have |
117 | //! been used to check for this, and the function Remove |
118 | //! to cancel the results of the unsuccessful taper-adding |
119 | //! transformation and to retrieve the previous shape. |
120 | Standard_EXPORT void Add (const TopoDS_Face& F, const gp_Dir& Direction, const Standard_Real Angle, const gp_Pln& NeutralPlane, const Standard_Boolean Flag = Standard_True); |
121 | |
122 | //! Returns true if the previous taper-adding |
123 | //! transformation performed by this algorithm in the last |
124 | //! call to Add, was successful. |
125 | //! If AddDone returns false: |
126 | //! - the function ProblematicShape returns the face |
127 | //! on which the error occurred, |
128 | //! - the function Remove has to be used to cancel the |
129 | //! results of the unsuccessful taper-adding |
130 | //! transformation and to retrieve the previous shape. |
131 | //! Exceptions |
132 | //! Standard_NullObject if the initial shape has not |
133 | //! been defined, i.e. if this algorithm has not been |
134 | //! initialized with the non-empty constructor or the .Init function. |
135 | Standard_EXPORT Standard_Boolean AddDone() const; |
136 | |
137 | //! Cancels the taper-adding transformation previously |
138 | //! performed by this algorithm on the face F and the |
139 | //! series of tangential faces which contain F, and retrieves |
140 | //! the shape before the last taper-adding transformation. |
141 | //! Warning |
142 | //! You will have to use this function if the previous call to |
143 | //! Add fails. Use the function AddDone to check it. |
144 | //! Exceptions |
145 | //! - Standard_NullObject if the initial shape has not |
146 | //! been defined, i.e. if this algorithm has not been |
147 | //! initialized with the non-empty constructor or the Init function. |
148 | //! - Standard_NoSuchObject if F has not been added |
149 | //! or has already been removed. |
150 | Standard_EXPORT void Remove (const TopoDS_Face& F); |
151 | |
152 | //! Returns the shape on which an error occurred after an |
153 | //! unsuccessful call to Add or when IsDone returns false. |
154 | //! Exceptions |
155 | //! Standard_NullObject if the initial shape has not been |
156 | //! defined, i.e. if this algorithm has not been initialized with |
157 | //! the non-empty constructor or the Init function. |
158 | Standard_EXPORT const TopoDS_Shape& ProblematicShape() const; |
159 | |
160 | //! Returns an error status when an error has occured |
161 | //! (Face, Edge or Vertex recomputaion problem). |
162 | //! Otherwise returns Draft_NoError. The method may be |
163 | //! called if AddDone returns Standard_False, or when |
164 | //! IsDone returns Standard_False. |
165 | Standard_EXPORT Draft_ErrorStatus Status() const; |
166 | |
167 | //! Returns all the faces which have been added |
168 | //! together with the face <F>. |
169 | Standard_EXPORT const TopTools_ListOfShape& ConnectedFaces (const TopoDS_Face& F) const; |
170 | |
171 | //! Returns all the faces on which a modification has |
172 | //! been given. |
173 | Standard_EXPORT const TopTools_ListOfShape& ModifiedFaces() const; |
174 | |
175 | //! Builds the resulting shape (redefined from MakeShape). |
176 | Standard_EXPORT virtual void Build() Standard_OVERRIDE; |
177 | |
178 | Standard_EXPORT void CorrectWires(); |
179 | |
180 | //! Returns the list of shapes generated from the |
181 | //! shape <S>. |
182 | Standard_EXPORT virtual const TopTools_ListOfShape& Generated (const TopoDS_Shape& S) Standard_OVERRIDE; |
183 | |
184 | //! Returns the list of shapes modified from the shape |
185 | //! <S>. |
186 | Standard_EXPORT virtual const TopTools_ListOfShape& Modified (const TopoDS_Shape& S) Standard_OVERRIDE; |
187 | |
188 | |
189 | |
190 | |
191 | protected: |
192 | |
193 | |
194 | |
195 | |
196 | |
197 | private: |
198 | |
199 | |
200 | |
201 | TopTools_ListOfShape myModifiedShapes; |
202 | |
203 | |
204 | }; |
205 | |
206 | |
207 | |
208 | |
209 | |
210 | |
211 | |
212 | #endif // _BRepOffsetAPI_DraftAngle_HeaderFile |