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