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