b311480e |
1 | // Created on: 1995-06-22 |
2 | // Created by: Flore Lantheaume |
3 | // Copyright (c) 1995-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 | #include <BRepFilletAPI_MakeChamfer.ixx> |
24 | #include <TopOpeBRepDS_HDataStructure.hxx> |
25 | #include <TopTools_ListIteratorOfListOfShape.hxx> |
26 | #include <ChFiDS_Spine.hxx> |
27 | #include <TopExp_Explorer.hxx> |
28 | |
29 | |
30 | |
31 | //======================================================================= |
32 | //function : BRepFilletAPI_MakeChamfer |
33 | //purpose : |
34 | //======================================================================= |
35 | BRepFilletAPI_MakeChamfer::BRepFilletAPI_MakeChamfer(const TopoDS_Shape &S):myBuilder(S) |
36 | { |
37 | } |
38 | |
39 | |
40 | |
41 | //======================================================================= |
42 | //function : Add |
43 | //purpose : |
44 | //======================================================================= |
45 | |
46 | void BRepFilletAPI_MakeChamfer::Add(const TopoDS_Edge &E ) |
47 | { |
48 | myBuilder.Add(E); |
49 | } |
50 | |
51 | |
52 | |
53 | //======================================================================= |
54 | //function : Add |
55 | //purpose : |
56 | //======================================================================= |
57 | |
58 | void BRepFilletAPI_MakeChamfer::Add(const Standard_Real Dis, |
59 | const TopoDS_Edge &E, |
60 | const TopoDS_Face &F) |
61 | { |
62 | myBuilder.Add(Dis, E, F); |
63 | } |
64 | |
65 | |
66 | //======================================================================= |
67 | //function : SetDist |
68 | //purpose : |
69 | //======================================================================= |
70 | |
71 | void BRepFilletAPI_MakeChamfer::SetDist(const Standard_Real Dis, |
72 | const Standard_Integer IC, |
73 | const TopoDS_Face &F) |
74 | { |
75 | myBuilder.SetDist(Dis, IC, F); |
76 | } |
77 | |
78 | //======================================================================= |
79 | //function : GetDist |
80 | //purpose : |
81 | //================================================================ |
82 | |
83 | void BRepFilletAPI_MakeChamfer::GetDist(const Standard_Integer IC, |
84 | Standard_Real& Dis) const |
85 | { |
86 | myBuilder.GetDist(IC, Dis); |
87 | |
88 | } |
89 | |
90 | //======================================================================= |
91 | //function : Add |
92 | //purpose : |
93 | //======================================================================= |
94 | |
95 | void BRepFilletAPI_MakeChamfer::Add(const Standard_Real Dis1, |
96 | const Standard_Real Dis2, |
97 | const TopoDS_Edge &E, |
98 | const TopoDS_Face &F) |
99 | { |
100 | myBuilder.Add(Dis1,Dis2,E,F); |
101 | } |
102 | |
103 | |
104 | //======================================================================= |
105 | //function : SetDists |
106 | //purpose : |
107 | //======================================================================= |
108 | |
109 | void BRepFilletAPI_MakeChamfer::SetDists(const Standard_Real Dis1, |
110 | const Standard_Real Dis2, |
111 | const Standard_Integer IC, |
112 | const TopoDS_Face &F) |
113 | { |
114 | myBuilder.SetDists(Dis1,Dis2,IC,F); |
115 | } |
116 | |
117 | //======================================================================= |
118 | //function : Dists |
119 | //purpose : |
120 | //================================================================ |
121 | |
122 | void BRepFilletAPI_MakeChamfer::Dists(const Standard_Integer IC, |
123 | Standard_Real& Dis1, |
124 | Standard_Real& Dis2) const |
125 | { |
126 | Standard_Real temp1, temp2; |
127 | myBuilder.Dists(IC,temp1,temp2); |
128 | Dis1 = temp1; |
129 | Dis2 = temp2; |
130 | |
131 | } |
132 | |
133 | |
134 | //======================================================================= |
135 | //function : Add |
136 | //purpose : |
137 | //======================================================================= |
138 | |
139 | void BRepFilletAPI_MakeChamfer::AddDA(const Standard_Real Dis, |
140 | const Standard_Real Angle, |
141 | const TopoDS_Edge &E, |
142 | const TopoDS_Face &F) |
143 | { |
144 | myBuilder.AddDA(Dis, Angle, E, F); |
145 | } |
146 | |
147 | //======================================================================= |
148 | //function : SetDist |
149 | //purpose : |
150 | //======================================================================= |
151 | |
152 | void BRepFilletAPI_MakeChamfer::SetDistAngle(const Standard_Real Dis, |
153 | const Standard_Real Angle, |
154 | const Standard_Integer IC, |
155 | const TopoDS_Face &F) |
156 | { |
157 | myBuilder.SetDistAngle(Dis, Angle, IC, F); |
158 | } |
159 | |
160 | //======================================================================= |
161 | //function : GetDistAngle |
162 | //purpose : |
163 | //================================================================ |
164 | |
165 | void BRepFilletAPI_MakeChamfer::GetDistAngle(const Standard_Integer IC, |
166 | Standard_Real& Dis, |
167 | Standard_Real& Angle, |
168 | Standard_Boolean& DisOnFace1) const |
169 | { |
170 | myBuilder.GetDistAngle(IC, Dis, Angle, DisOnFace1); |
171 | |
172 | } |
173 | |
174 | //======================================================================= |
175 | //function : IsSymetric |
176 | //purpose : |
177 | //=============================================================== |
178 | |
179 | Standard_Boolean BRepFilletAPI_MakeChamfer::IsSymetric(const Standard_Integer IC) const |
180 | { |
181 | ChFiDS_ChamfMethod ChamfMeth = myBuilder.IsChamfer(IC); |
182 | Standard_Boolean ret = Standard_False; |
183 | |
184 | if (ChamfMeth == ChFiDS_Sym) ret = Standard_True; |
185 | |
186 | return ret; |
187 | } |
188 | |
189 | |
190 | //======================================================================= |
191 | //function : IsTwoDistances |
192 | //purpose : |
193 | //=============================================================== |
194 | |
195 | Standard_Boolean BRepFilletAPI_MakeChamfer::IsTwoDistances(const Standard_Integer IC) const |
196 | { |
197 | ChFiDS_ChamfMethod ChamfMeth = myBuilder.IsChamfer(IC); |
198 | Standard_Boolean ret = Standard_False; |
199 | |
200 | if (ChamfMeth == ChFiDS_TwoDist) ret = Standard_True; |
201 | |
202 | return ret; |
203 | } |
204 | |
205 | |
206 | |
207 | //======================================================================= |
208 | //function : IsDistanceAngle |
209 | //purpose : |
210 | //=============================================================== |
211 | |
212 | Standard_Boolean BRepFilletAPI_MakeChamfer::IsDistanceAngle(const Standard_Integer IC) const |
213 | { |
214 | ChFiDS_ChamfMethod ChamfMeth = myBuilder.IsChamfer(IC); |
215 | Standard_Boolean ret = Standard_False; |
216 | |
217 | if (ChamfMeth == ChFiDS_DistAngle) ret = Standard_True; |
218 | |
219 | return ret; |
220 | } |
221 | |
222 | |
223 | |
224 | //======================================================================= |
225 | //function : ResetContour |
226 | //purpose : |
227 | //=============================================================== |
228 | |
229 | void BRepFilletAPI_MakeChamfer::ResetContour(const Standard_Integer IC) |
230 | { |
231 | myBuilder.ResetContour(IC); |
232 | } |
233 | |
234 | |
235 | //======================================================================= |
236 | //function : NbContours |
237 | //purpose : |
238 | //======================================================================= |
239 | |
240 | Standard_Integer BRepFilletAPI_MakeChamfer::NbContours()const |
241 | { |
242 | return myBuilder.NbElements(); |
243 | } |
244 | |
245 | |
246 | |
247 | //======================================================================= |
248 | //function : Contour |
249 | //purpose : |
250 | //======================================================================= |
251 | |
252 | Standard_Integer BRepFilletAPI_MakeChamfer::Contour(const TopoDS_Edge &E)const |
253 | { |
254 | return myBuilder.Contains(E); |
255 | } |
256 | |
257 | |
258 | |
259 | //======================================================================= |
260 | //function : NbEdges |
261 | //purpose : |
262 | //======================================================================= |
263 | |
264 | Standard_Integer BRepFilletAPI_MakeChamfer::NbEdges(const Standard_Integer I)const |
265 | |
266 | { |
267 | const Handle(ChFiDS_Spine)& Spine = myBuilder.Value(I); |
268 | return (Spine->NbEdges()); |
269 | } |
270 | |
271 | |
272 | //======================================================================= |
273 | //function : Edge |
274 | //purpose : |
275 | //======================================================================= |
276 | |
277 | const TopoDS_Edge& BRepFilletAPI_MakeChamfer::Edge(const Standard_Integer I, |
278 | const Standard_Integer J)const |
279 | { |
280 | const Handle(ChFiDS_Spine)& Spine = myBuilder.Value(I); |
281 | const TopoDS_Edge& E = Spine->Edges(J); |
282 | return E; |
283 | } |
284 | |
285 | //======================================================================= |
286 | //function : Remove |
287 | //purpose : |
288 | //======================================================================= |
289 | |
290 | void BRepFilletAPI_MakeChamfer::Remove(const TopoDS_Edge& E) |
291 | { |
292 | myBuilder.Remove(E); |
293 | } |
294 | |
295 | //======================================================================= |
296 | //function : Length |
297 | //purpose : |
298 | //======================================================================= |
299 | |
300 | Standard_Real BRepFilletAPI_MakeChamfer::Length(const Standard_Integer IC)const |
301 | { |
302 | return myBuilder.Length(IC); |
303 | } |
304 | |
305 | //======================================================================= |
306 | //function : FirstVertex |
307 | //purpose : |
308 | //======================================================================= |
309 | |
310 | TopoDS_Vertex BRepFilletAPI_MakeChamfer::FirstVertex(const Standard_Integer IC)const |
311 | { |
312 | return myBuilder.FirstVertex(IC); |
313 | } |
314 | |
315 | |
316 | //======================================================================= |
317 | //function : LastVertex |
318 | //purpose : |
319 | //======================================================================= |
320 | |
321 | TopoDS_Vertex BRepFilletAPI_MakeChamfer::LastVertex(const Standard_Integer IC)const |
322 | { |
323 | return myBuilder.LastVertex(IC); |
324 | } |
325 | |
326 | |
327 | //======================================================================= |
328 | //function : Abscissa |
329 | //purpose : |
330 | //======================================================================= |
331 | |
332 | Standard_Real BRepFilletAPI_MakeChamfer::Abscissa(const Standard_Integer IC, |
333 | const TopoDS_Vertex& V)const |
334 | { |
335 | return myBuilder.Abscissa(IC,V); |
336 | } |
337 | |
338 | |
339 | //======================================================================= |
340 | //function : RelativeAbscissa |
341 | //purpose : |
342 | //======================================================================= |
343 | |
344 | Standard_Real BRepFilletAPI_MakeChamfer::RelativeAbscissa(const Standard_Integer IC, |
345 | const TopoDS_Vertex& V)const |
346 | { |
347 | return myBuilder.RelativeAbscissa(IC,V); |
348 | } |
349 | |
350 | //======================================================================= |
351 | //function : ClosedAndTangent |
352 | //purpose : |
353 | //======================================================================= |
354 | |
355 | Standard_Boolean BRepFilletAPI_MakeChamfer::ClosedAndTangent |
356 | (const Standard_Integer IC)const |
357 | { |
358 | return myBuilder.ClosedAndTangent(IC); |
359 | } |
360 | |
361 | |
362 | //======================================================================= |
363 | //function : Closed |
364 | //purpose : |
365 | //======================================================================= |
366 | |
367 | Standard_Boolean BRepFilletAPI_MakeChamfer::Closed |
368 | (const Standard_Integer IC)const |
369 | { |
370 | return myBuilder.Closed(IC); |
371 | } |
372 | |
373 | //======================================================================= |
374 | //function : Builder |
375 | //purpose : |
376 | //======================================================================= |
377 | |
378 | Handle(TopOpeBRepBuild_HBuilder) BRepFilletAPI_MakeChamfer::Builder()const |
379 | { |
380 | return myBuilder.Builder(); |
381 | } |
382 | |
383 | //======================================================================= |
384 | //function : Build |
385 | //purpose : |
386 | //======================================================================= |
387 | |
388 | void BRepFilletAPI_MakeChamfer::Build() |
389 | { |
390 | myBuilder.Compute(); |
391 | if (myBuilder.IsDone()){ |
392 | Done(); |
393 | myShape = myBuilder.Shape(); |
394 | |
395 | //creation of the Map. |
396 | TopExp_Explorer ex; |
397 | for (ex.Init(myShape, TopAbs_FACE); ex.More(); ex.Next()) { |
398 | myMap.Add(ex.Current()); |
399 | } |
400 | } |
401 | } |
402 | |
403 | //======================================================================= |
404 | //function : Reset |
405 | //purpose : |
406 | //======================================================================= |
407 | |
408 | void BRepFilletAPI_MakeChamfer::Reset() |
409 | { |
410 | NotDone(); |
411 | myBuilder.Reset(); |
412 | myMap.Clear(); |
413 | } |
414 | |
415 | //======================================================================= |
416 | //function : Generated |
417 | //purpose : |
418 | //======================================================================= |
419 | |
420 | const TopTools_ListOfShape& BRepFilletAPI_MakeChamfer::Generated |
421 | (const TopoDS_Shape& EorV) |
422 | { |
423 | return myBuilder.Generated(EorV); |
424 | } |
425 | |
426 | //======================================================================= |
427 | //function : Modified |
428 | //purpose : |
429 | //======================================================================= |
430 | |
431 | const TopTools_ListOfShape& BRepFilletAPI_MakeChamfer::Modified |
432 | (const TopoDS_Shape& F) |
433 | { |
434 | myGenerated.Clear(); |
435 | |
436 | if (myBuilder.Builder()->IsSplit(F, TopAbs_OUT)) { |
437 | TopTools_ListIteratorOfListOfShape It(myBuilder.Builder()->Splits(F, TopAbs_OUT)); |
438 | for(;It.More();It.Next()) { |
439 | myGenerated.Append(It.Value()); |
440 | } |
441 | } |
442 | if (myBuilder.Builder()->IsSplit(F, TopAbs_IN)) { |
443 | TopTools_ListIteratorOfListOfShape It(myBuilder.Builder()->Splits(F, TopAbs_IN)); |
444 | for(;It.More();It.Next()) { |
445 | myGenerated.Append(It.Value()); |
446 | } |
447 | } |
448 | if (myBuilder.Builder()->IsSplit(F, TopAbs_ON)) { |
449 | TopTools_ListIteratorOfListOfShape It(myBuilder.Builder()->Splits(F, TopAbs_ON)); |
450 | for(;It.More();It.Next()) { |
451 | myGenerated.Append(It.Value()); |
452 | } |
453 | } |
454 | return myGenerated; |
455 | } |
456 | |
457 | //======================================================================= |
458 | //function : IsDeleted |
459 | //purpose : |
460 | //======================================================================= |
461 | |
462 | Standard_Boolean BRepFilletAPI_MakeChamfer::IsDeleted(const TopoDS_Shape& F) |
463 | { |
464 | if (myMap.Contains(F) || |
465 | myBuilder.Builder()->IsSplit (F, TopAbs_OUT) || |
466 | myBuilder.Builder()->IsSplit (F, TopAbs_IN) || |
467 | myBuilder.Builder()->IsSplit (F, TopAbs_ON)) |
468 | return Standard_False; |
469 | |
470 | return Standard_True; |
471 | } |
472 | |
473 | //======================================================================= |
474 | //function : Simulate |
475 | //purpose : |
476 | //======================================================================= |
477 | |
478 | void BRepFilletAPI_MakeChamfer::Simulate(const Standard_Integer IC) |
479 | { |
480 | myBuilder.Simulate(IC); |
481 | } |
482 | |
483 | |
484 | //======================================================================= |
485 | //function : NbSurf |
486 | //purpose : |
487 | //======================================================================= |
488 | |
489 | Standard_Integer BRepFilletAPI_MakeChamfer::NbSurf(const Standard_Integer IC)const |
490 | { |
491 | return myBuilder.NbSurf(IC); |
492 | } |
493 | |
494 | |
495 | //======================================================================= |
496 | //function : Sect |
497 | //purpose : |
498 | //======================================================================= |
499 | |
500 | Handle(ChFiDS_SecHArray1) BRepFilletAPI_MakeChamfer::Sect(const Standard_Integer IC, |
501 | const Standard_Integer IS)const |
502 | { |
503 | return myBuilder.Sect(IC, IS); |
504 | } |