b311480e |
1 | // Created on: 1991-07-25 |
2 | // Created by: Christophe MARION |
3 | // Copyright (c) 1991-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
22 | |
23 | |
24 | #include <BRepPrim_Builder.ixx> |
25 | |
26 | #include <Precision.hxx> |
27 | #include <TopoDS.hxx> |
28 | |
29 | #include <Geom_Plane.hxx> |
30 | #include <Geom_Line.hxx> |
31 | #include <Geom_Circle.hxx> |
32 | |
33 | #include <Geom2d_Line.hxx> |
34 | #include <Geom2d_Circle.hxx> |
35 | |
36 | #include <BRepTools.hxx> |
37 | |
38 | //======================================================================= |
39 | //function : BRepPrim_Builder |
40 | //purpose : constructor |
41 | //======================================================================= |
42 | |
43 | BRepPrim_Builder::BRepPrim_Builder () |
44 | { |
45 | } |
46 | |
47 | //======================================================================= |
48 | //function : BRepPrim_Builder |
49 | //purpose : constructor |
50 | //======================================================================= |
51 | |
52 | BRepPrim_Builder::BRepPrim_Builder (const BRep_Builder& B) : |
53 | myBuilder(B) |
54 | { |
55 | } |
56 | |
57 | //======================================================================= |
58 | //function : MakeShell |
59 | //purpose : Make a Shell |
60 | //======================================================================= |
61 | |
62 | void BRepPrim_Builder::MakeShell (TopoDS_Shell& S) const |
63 | { |
64 | myBuilder.MakeShell(S); |
65 | S.Closed(Standard_True); |
66 | } |
67 | |
68 | //======================================================================= |
69 | //function : MakeFace |
70 | //purpose : Make a Planar Face |
71 | //======================================================================= |
72 | |
73 | void BRepPrim_Builder::MakeFace (TopoDS_Face& F, const gp_Pln& P) const |
74 | { |
75 | myBuilder.MakeFace(F,new Geom_Plane(P),Precision::Confusion()); |
76 | } |
77 | |
78 | //======================================================================= |
79 | //function : MakeWire |
80 | //purpose : Make an empty Wire |
81 | //======================================================================= |
82 | |
83 | void BRepPrim_Builder::MakeWire (TopoDS_Wire& W) const |
84 | { |
85 | myBuilder.MakeWire(W); |
86 | } |
87 | |
88 | //======================================================================= |
89 | //function : MakeDegeneratedEdge |
90 | //purpose : |
91 | //======================================================================= |
92 | |
93 | void BRepPrim_Builder::MakeDegeneratedEdge (TopoDS_Edge& E) const |
94 | { |
95 | myBuilder.MakeEdge(E); |
96 | myBuilder.Degenerated(E,Standard_True); |
97 | } |
98 | |
99 | //======================================================================= |
100 | //function : MakeEdge |
101 | //purpose : Make a linear Edge |
102 | //======================================================================= |
103 | |
104 | void BRepPrim_Builder::MakeEdge (TopoDS_Edge& E, const gp_Lin& L) const |
105 | { |
106 | myBuilder.MakeEdge(E,new Geom_Line(L),Precision::Confusion()); |
107 | } |
108 | |
109 | //======================================================================= |
110 | //function : MakeEdge |
111 | //purpose : Make a Circular Edge |
112 | //======================================================================= |
113 | |
114 | void BRepPrim_Builder::MakeEdge (TopoDS_Edge& E, const gp_Circ& C) const |
115 | { |
116 | myBuilder.MakeEdge(E,new Geom_Circle(C),Precision::Confusion()); |
117 | } |
118 | |
119 | //======================================================================= |
120 | //function : SetPCurve |
121 | //purpose : |
122 | //======================================================================= |
123 | |
124 | void BRepPrim_Builder::SetPCurve(TopoDS_Edge& E, |
125 | const TopoDS_Face& F, |
126 | const gp_Lin2d& L) const |
127 | { |
128 | myBuilder.UpdateEdge(E,new Geom2d_Line(L),F,Precision::Confusion()); |
129 | } |
130 | |
131 | //======================================================================= |
132 | //function : SetPCurve |
133 | //purpose : |
134 | //======================================================================= |
135 | |
136 | void BRepPrim_Builder::SetPCurve(TopoDS_Edge& E, |
137 | const TopoDS_Face& F, |
138 | const gp_Lin2d& L1, |
139 | const gp_Lin2d& L2) const |
140 | { |
141 | TopoDS_Shape aLocalShape = E.Oriented(TopAbs_FORWARD); |
142 | myBuilder.UpdateEdge(TopoDS::Edge(aLocalShape), |
143 | new Geom2d_Line(L1), |
144 | new Geom2d_Line(L2), |
145 | F,Precision::Confusion()); |
146 | // myBuilder.UpdateEdge(TopoDS::Edge(E.Oriented(TopAbs_FORWARD)), |
147 | // new Geom2d_Line(L1), |
148 | // new Geom2d_Line(L2), |
149 | // F,Precision::Confusion()); |
150 | myBuilder.Continuity(E,F,F,GeomAbs_CN); |
151 | } |
152 | |
153 | //======================================================================= |
154 | //function : SetPCurve |
155 | //purpose : |
156 | //======================================================================= |
157 | |
158 | void BRepPrim_Builder::SetPCurve(TopoDS_Edge& E, |
159 | const TopoDS_Face& F, |
160 | const gp_Circ2d& C) const |
161 | { |
162 | myBuilder.UpdateEdge(E,new Geom2d_Circle(C),F,Precision::Confusion()); |
163 | } |
164 | |
165 | |
166 | //======================================================================= |
167 | //function : MakeVertex |
168 | //purpose : Make a Vertex |
169 | //======================================================================= |
170 | |
171 | void BRepPrim_Builder::MakeVertex (TopoDS_Vertex& V, const gp_Pnt& P) const |
172 | { |
173 | myBuilder.MakeVertex(V,P,Precision::Confusion()); |
174 | } |
175 | |
176 | //======================================================================= |
177 | //function : ReverseFace |
178 | //purpose : Reverse a Face |
179 | //======================================================================= |
180 | |
181 | void BRepPrim_Builder::ReverseFace (TopoDS_Face& F) const |
182 | { |
183 | F.Reverse(); |
184 | } |
185 | |
186 | //======================================================================= |
187 | //function : AddEdgeVertex |
188 | //purpose : Add a Vertex to an Edge |
189 | //======================================================================= |
190 | |
191 | void BRepPrim_Builder::AddEdgeVertex (TopoDS_Edge& E, |
192 | const TopoDS_Vertex& V, |
193 | const Standard_Real P, |
194 | const Standard_Boolean direct) const |
195 | { |
196 | TopoDS_Vertex VV = V; |
197 | if (!direct) |
198 | VV.Reverse(); |
199 | myBuilder.Add(E,VV); |
200 | myBuilder.UpdateVertex(VV,P,E,Precision::Confusion()); |
201 | } |
202 | |
203 | |
204 | //======================================================================= |
205 | //function : AddEdgeVertex |
206 | //purpose : Add a Vertex to an Edge |
207 | //======================================================================= |
208 | |
209 | void BRepPrim_Builder::AddEdgeVertex (TopoDS_Edge& E, |
210 | const TopoDS_Vertex& V, |
211 | const Standard_Real P1, |
212 | const Standard_Real P2) const |
213 | { |
214 | TopoDS_Vertex VV = V; |
215 | VV.Orientation(TopAbs_FORWARD); |
216 | myBuilder.Add(E,VV); |
217 | VV.Orientation(TopAbs_REVERSED); |
218 | myBuilder.Add(E,VV); |
219 | myBuilder.Range(E,P1,P2); |
220 | E.Closed(Standard_True); |
221 | } |
222 | |
223 | //======================================================================= |
224 | //function : SetParameters |
225 | //purpose : |
226 | //======================================================================= |
227 | |
228 | void BRepPrim_Builder::SetParameters (TopoDS_Edge& E, |
229 | const TopoDS_Vertex& , |
230 | const Standard_Real P1, |
231 | const Standard_Real P2) const |
232 | { |
233 | myBuilder.Range(E,P1,P2); |
234 | } |
235 | |
236 | //======================================================================= |
237 | //function : AddWireEdge |
238 | //purpose : Add an Edge to a Wire |
239 | //======================================================================= |
240 | |
241 | void BRepPrim_Builder::AddWireEdge (TopoDS_Wire& W, |
242 | const TopoDS_Edge& E, |
243 | const Standard_Boolean direct) const |
244 | { |
245 | TopoDS_Edge EE = E; |
246 | if (!direct) |
247 | EE.Reverse(); |
248 | myBuilder.Add(W,EE); |
249 | } |
250 | |
251 | //======================================================================= |
252 | //function : AddFaceWire |
253 | //purpose : Add a Wire to a Face |
254 | //======================================================================= |
255 | |
256 | void BRepPrim_Builder::AddFaceWire (TopoDS_Face& F, |
257 | const TopoDS_Wire& W) const |
258 | { |
259 | myBuilder.Add(F,W); |
260 | } |
261 | |
262 | //======================================================================= |
263 | //function : AddShellFace |
264 | //purpose : Add a Face to a Shell |
265 | //======================================================================= |
266 | |
267 | void BRepPrim_Builder::AddShellFace(TopoDS_Shell& S, |
268 | const TopoDS_Face& F) const |
269 | { |
270 | myBuilder.Add(S,F); |
271 | } |
272 | |
273 | //======================================================================= |
274 | //function : Complete |
275 | //purpose : |
276 | //======================================================================= |
277 | |
278 | void BRepPrim_Builder::CompleteEdge(TopoDS_Edge& E)const |
279 | { |
280 | BRepTools::Update(E); |
281 | } |
282 | |
283 | //======================================================================= |
284 | //function : Complete |
285 | //purpose : |
286 | //======================================================================= |
287 | |
288 | void BRepPrim_Builder::CompleteWire(TopoDS_Wire& W)const |
289 | { |
290 | BRepTools::Update(W); |
291 | } |
292 | |
293 | |
294 | //======================================================================= |
295 | //function : Complete |
296 | //purpose : |
297 | //======================================================================= |
298 | |
299 | void BRepPrim_Builder::CompleteFace(TopoDS_Face& F)const |
300 | { |
301 | BRepTools::Update(F); |
302 | } |
303 | |
304 | |
305 | //======================================================================= |
306 | //function : Complete |
307 | //purpose : |
308 | //======================================================================= |
309 | |
310 | void BRepPrim_Builder::CompleteShell(TopoDS_Shell& S)const |
311 | { |
312 | BRepTools::Update(S); |
313 | } |