42cf5bc1 |
1 | // Created on: 1995-06-12 |
2 | // Created by: Joelle CHAUVET |
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 _ChFi2d_Builder_HeaderFile |
18 | #define _ChFi2d_Builder_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <ChFi2d_ConstructionError.hxx> |
25 | #include <TopoDS_Face.hxx> |
26 | #include <TopTools_SequenceOfShape.hxx> |
27 | #include <TopTools_DataMapOfShapeShape.hxx> |
28 | #include <Standard_Real.hxx> |
29 | #include <Standard_Boolean.hxx> |
30 | #include <Standard_Integer.hxx> |
9fd2d2c3 |
31 | |
42cf5bc1 |
32 | class TopoDS_Edge; |
33 | class TopoDS_Vertex; |
34 | |
9fd2d2c3 |
35 | // resolve name collisions with X11 headers |
36 | #ifdef Status |
37 | #undef Status |
38 | #endif |
42cf5bc1 |
39 | |
40 | //! This class contains the algorithm used to build |
41 | //! fillet on planar wire. |
42 | class ChFi2d_Builder |
43 | { |
44 | public: |
45 | |
46 | DEFINE_STANDARD_ALLOC |
47 | |
48 | |
49 | Standard_EXPORT ChFi2d_Builder(); |
50 | |
51 | //! The face <F> can be build on a closed or an open |
52 | //! wire. |
53 | Standard_EXPORT ChFi2d_Builder(const TopoDS_Face& F); |
54 | |
55 | Standard_EXPORT void Init (const TopoDS_Face& F); |
56 | |
57 | Standard_EXPORT void Init (const TopoDS_Face& RefFace, const TopoDS_Face& ModFace); |
58 | |
59 | //! Add a fillet of radius <Radius> on the wire |
60 | //! between the two edges connected to the vertex <V>. |
61 | //! <AddFillet> returns the fillet edge. The returned |
62 | //! edge has sense only if the status <status> is |
63 | //! <IsDone> |
64 | Standard_EXPORT TopoDS_Edge AddFillet (const TopoDS_Vertex& V, const Standard_Real Radius); |
65 | |
66 | //! modify the fillet radius and return the new fillet |
67 | //! edge. this edge has sense only if the status |
68 | //! <status> is <IsDone>. |
69 | Standard_EXPORT TopoDS_Edge ModifyFillet (const TopoDS_Edge& Fillet, const Standard_Real Radius); |
70 | |
71 | //! removes the fillet <Fillet> and returns the vertex |
72 | //! connecting the two adjacent edges to this fillet. |
73 | Standard_EXPORT TopoDS_Vertex RemoveFillet (const TopoDS_Edge& Fillet); |
74 | |
75 | //! Add a chamfer on the wire between the two edges |
76 | //! connected <E1> and <E2>. <AddChamfer> returns the |
77 | //! chamfer edge. This edge has sense only if the |
78 | //! status <status> is <IsDone>. |
79 | Standard_EXPORT TopoDS_Edge AddChamfer (const TopoDS_Edge& E1, const TopoDS_Edge& E2, const Standard_Real D1, const Standard_Real D2); |
80 | |
81 | //! Add a chamfer on the wire between the two edges |
82 | //! connected to the vertex <V>. The chamfer will make |
83 | //! an angle <Ang> with the edge <E>, and one of its |
84 | //! extremities will be on <E> at distance <D>. The |
85 | //! returned edge has sense only if the status |
86 | //! <status> is <IsDone>. |
87 | //! Warning: The value of <Ang> must be expressed in Radian. |
88 | Standard_EXPORT TopoDS_Edge AddChamfer (const TopoDS_Edge& E, const TopoDS_Vertex& V, const Standard_Real D, const Standard_Real Ang); |
89 | |
90 | //! modify the chamfer <Chamfer> and returns the new |
91 | //! chamfer edge. |
92 | //! This edge as sense only if the status <status> is |
93 | //! <IsDone>. |
94 | 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); |
95 | |
96 | //! modify the chamfer <Chamfer> and returns the new |
97 | //! chamfer edge. This edge as sense only if the |
98 | //! status <status> is <IsDone>. |
99 | //! Warning: The value of <Ang> must be expressed in Radian. |
100 | Standard_EXPORT TopoDS_Edge ModifyChamfer (const TopoDS_Edge& Chamfer, const TopoDS_Edge& E, const Standard_Real D, const Standard_Real Ang); |
101 | |
102 | //! removes the chamfer <Chamfer> and returns the |
103 | //! vertex connecting the two adjacent edges to this |
104 | //! chamfer. |
105 | Standard_EXPORT TopoDS_Vertex RemoveChamfer (const TopoDS_Edge& Chamfer); |
106 | |
107 | //! returns the modified face |
108 | TopoDS_Face Result() const; |
109 | |
110 | Standard_Boolean IsModified (const TopoDS_Edge& E) const; |
111 | |
112 | //! returns the list of new edges |
113 | const TopTools_SequenceOfShape& FilletEdges() const; |
114 | |
115 | Standard_Integer NbFillet() const; |
116 | |
117 | //! returns the list of new edges |
118 | const TopTools_SequenceOfShape& ChamferEdges() const; |
119 | |
120 | Standard_Integer NbChamfer() const; |
121 | |
122 | Standard_Boolean HasDescendant (const TopoDS_Edge& E) const; |
123 | |
124 | //! returns the modified edge if <E> has descendant or |
125 | //! <E> in the other case. |
126 | const TopoDS_Edge& DescendantEdge (const TopoDS_Edge& E) const; |
127 | |
128 | //! Returns the parent edge of <E> |
129 | //! Warning: If <E>is a basis edge, the returned edge would be |
130 | //! equal to <E> |
131 | Standard_EXPORT const TopoDS_Edge& BasisEdge (const TopoDS_Edge& E) const; |
132 | |
133 | ChFi2d_ConstructionError Status() const; |
134 | |
135 | |
136 | |
137 | |
138 | protected: |
139 | |
140 | |
141 | |
142 | |
143 | |
144 | private: |
145 | |
146 | |
21c7c457 |
147 | //! Is internally used by <AddFillet>. |
42cf5bc1 |
148 | //! Warning: <TrimE1>, <TrimE2>, <Fillet> has sense only if the |
149 | //! status <status> is equal to <IsDone> |
150 | Standard_EXPORT void ComputeFillet (const TopoDS_Vertex& V, const TopoDS_Edge& E1, const TopoDS_Edge& E2, const Standard_Real Radius, TopoDS_Edge& TrimE1, TopoDS_Edge& TrimE2, TopoDS_Edge& Fillet); |
151 | |
21c7c457 |
152 | //! Is internally used by <AddChamfer>. The chamfer is |
42cf5bc1 |
153 | //! computed from a vertex, two edges and two |
154 | //! distances |
155 | //! Warning: <TrimE1>, <TrimE2> and <Chamfer> has sense only if |
156 | //! if the status <status> is equal to <IsDone> |
157 | Standard_EXPORT void ComputeChamfer (const TopoDS_Vertex& V, const TopoDS_Edge& E1, const TopoDS_Edge& E2, const Standard_Real D1, const Standard_Real D2, TopoDS_Edge& TrimE1, TopoDS_Edge& TrimE2, TopoDS_Edge& Chamfer); |
158 | |
21c7c457 |
159 | //! Is internally used by <AddChamfer>. The chamfer is |
42cf5bc1 |
160 | //! computed from an edge, a vertex, a distance |
161 | //! and an angle |
162 | //! Warning: <TrimE1>, <TrimE2>, and <Chamfer> has |
163 | //! sense only if the status <status> is equal to |
164 | //! <IsDone> |
165 | Standard_EXPORT void ComputeChamfer (const TopoDS_Vertex& V, const TopoDS_Edge& E1, const Standard_Real D, const Standard_Real Ang, const TopoDS_Edge& E2, TopoDS_Edge& TrimE1, TopoDS_Edge& TrimE2, TopoDS_Edge& Chamfer); |
166 | |
21c7c457 |
167 | //! Is internally used by <ComputeFillet>. |
42cf5bc1 |
168 | //! <NewExtr1> and <NewExtr2> will contains the new |
169 | //! extremities of <AdjEdge1> and <AdjEdge2> |
170 | //! Warning: The returned edge has sense only if the status |
171 | //! <status> is equal to <IsDone> |
172 | //! or to one of those specific cases : |
173 | //! <FirstEdgeDegenerated> |
174 | //! <LastEdgeDegenerated> |
175 | //! <BothEdgesDegenerated> |
176 | Standard_EXPORT TopoDS_Edge BuildFilletEdge (const TopoDS_Vertex& V, const TopoDS_Edge& AdjEdge1, const TopoDS_Edge& AdjEdge2, const Standard_Real Radius, TopoDS_Vertex& NewExtr1, TopoDS_Vertex& NewExtr2); |
177 | |
21c7c457 |
178 | //! Is internally used by <ComputeFillet>. |
42cf5bc1 |
179 | //! <NewExtr1> and <NewExtr2> will contains the new |
180 | //! extremities of <AdjEdge1> and <AdjEdge2> |
181 | //! Warning: The returned edge has sense only if the status |
182 | //! <status> is equal to <IsDone> |
183 | Standard_EXPORT TopoDS_Edge BuildChamferEdge (const TopoDS_Vertex& V, const TopoDS_Edge& AdjEdge1, const TopoDS_Edge& AdjEdge2, const Standard_Real D1, const Standard_Real D2, TopoDS_Vertex& NewExtr1, TopoDS_Vertex& NewExtr2); |
184 | |
21c7c457 |
185 | //! Is internally used by <ComputeFillet>. |
42cf5bc1 |
186 | //! <NewExtr1> and <NewExtr2> will contains the new |
187 | //! extremities of <AdjEdge1> and <AdjEdge2> |
188 | //! Warning: The returned edge has sense only if the status |
189 | //! <status> is equal to <IsDone> |
190 | Standard_EXPORT TopoDS_Edge BuildChamferEdge (const TopoDS_Vertex& V, const TopoDS_Edge& AdjEdge2, const Standard_Real D, const Standard_Real Ang, const TopoDS_Edge& AdjEdge1, TopoDS_Vertex& NewExtr1, TopoDS_Vertex& NewExtr2); |
191 | |
192 | //! replaces in the new face <newFace> <OldE1> and |
193 | //! <OldE2> by <E1>, <Fillet> and <E2> |
194 | //! or by <Fillet> and <E2> if <E1> is degenerated |
195 | //! or by <E1> and <Fillet> if <E2> is degenerated |
196 | //! or by <Fillet> if <E1> and <E2> are degenerated . |
197 | Standard_EXPORT void BuildNewWire (const TopoDS_Edge& OldE1, const TopoDS_Edge& OldE2, const TopoDS_Edge& E1, const TopoDS_Edge& Fillet, const TopoDS_Edge& E2); |
198 | |
199 | //! Changes <OldExtr> of <E1> by <NewExtr> |
200 | Standard_EXPORT TopoDS_Edge BuildNewEdge (const TopoDS_Edge& E1, const TopoDS_Vertex& OldExtr, const TopoDS_Vertex& NewExtr) const; |
201 | |
202 | //! Changes <OldExtr> of <E1> by <NewExtr> |
203 | //! returns E1 and IsDegenerated = Standard_True |
204 | //! if the new edge is degenerated |
205 | Standard_EXPORT TopoDS_Edge BuildNewEdge (const TopoDS_Edge& E1, const TopoDS_Vertex& OldExtr, const TopoDS_Vertex& NewExtr, Standard_Boolean& IsDegenerated) const; |
206 | |
207 | //! Writes <NewEdge> in <fillets> if <Id> is equal to |
208 | //! 1, or in <chamfers> if <Id> is Equal to 2. |
209 | //! Writes the modifications in <history> : |
210 | //! <TrimE1> is given by <E1>, <TrimE2> by <E2> |
211 | //! if <TrimE1> and <TrimE2> are not degenerated. |
212 | Standard_EXPORT void UpDateHistory (const TopoDS_Edge& E1, const TopoDS_Edge& E2, const TopoDS_Edge& TrimE1, const TopoDS_Edge& TrimE2, const TopoDS_Edge& NewEdge, const Standard_Integer Id); |
213 | |
214 | //! Writes the modifications in <history> . <TrimE1> |
215 | //! is given by <E1>, <TrimE2> by <E2>. |
216 | Standard_EXPORT void UpDateHistory (const TopoDS_Edge& E1, const TopoDS_Edge& E2, const TopoDS_Edge& TrimE1, const TopoDS_Edge& TrimE2); |
217 | |
218 | Standard_EXPORT Standard_Boolean IsAFillet (const TopoDS_Edge& E) const; |
219 | |
220 | Standard_EXPORT Standard_Boolean IsAChamfer (const TopoDS_Edge& E) const; |
221 | |
222 | |
223 | ChFi2d_ConstructionError status; |
224 | TopoDS_Face refFace; |
225 | TopoDS_Face newFace; |
226 | TopTools_SequenceOfShape fillets; |
227 | TopTools_SequenceOfShape chamfers; |
228 | TopTools_DataMapOfShapeShape history; |
229 | |
230 | |
231 | }; |
232 | |
233 | |
234 | #include <ChFi2d_Builder.lxx> |
235 | |
236 | |
237 | |
238 | |
239 | |
240 | #endif // _ChFi2d_Builder_HeaderFile |