Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1996-02-13 |
2 | // Created by: Jacques GOUSSARD | |
3 | // Copyright (c) 1996-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 <BRepFeat_MakeRevol.ixx> | |
24 | ||
25 | #include <BRepFeat.hxx> | |
26 | #include <LocOpe.hxx> | |
27 | #include <LocOpe_Revol.hxx> | |
28 | #include <LocOpe_Builder.hxx> | |
29 | #include <LocOpe_Gluer.hxx> | |
30 | #include <LocOpe_FindEdges.hxx> | |
31 | #include <LocOpe_SequenceOfCirc.hxx> | |
32 | #include <LocOpe_BuildShape.hxx> | |
33 | #include <LocOpe_CSIntersector.hxx> | |
34 | #include <LocOpe_PntFace.hxx> | |
35 | ||
36 | #include <gp_Vec.hxx> | |
37 | #include <gp_Pnt.hxx> | |
38 | #include <gp_Ax1.hxx> | |
39 | #include <gp_Pnt2d.hxx> | |
40 | #include <TColgp_SequenceOfPnt.hxx> | |
41 | #include <Geom_Surface.hxx> | |
42 | #include <Geom_Curve.hxx> | |
43 | #include <Geom_Circle.hxx> | |
44 | #include <Geom2d_Curve.hxx> | |
45 | #include <Geom_RectangularTrimmedSurface.hxx> | |
46 | #include <Bnd_Box.hxx> | |
47 | ||
48 | #include <BRepSweep_Revol.hxx> | |
49 | #include <BRep_Builder.hxx> | |
50 | #include <BRep_Tool.hxx> | |
51 | #include <TopExp_Explorer.hxx> | |
52 | #include <TopTools_MapOfShape.hxx> | |
53 | #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx> | |
54 | #include <TopTools_ListIteratorOfListOfShape.hxx> | |
55 | #include <TopTools_MapIteratorOfMapOfShape.hxx> | |
56 | #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx> | |
57 | ||
58 | #include <BRepAlgoAPI_Cut.hxx> | |
59 | #include <BRepAlgoAPI_Fuse.hxx> | |
60 | ||
61 | #include <BRepLib_MakeFace.hxx> | |
62 | #include <BRepTools_Modifier.hxx> | |
63 | #include <BRepTools_TrsfModification.hxx> | |
64 | ||
65 | #include <Standard_ConstructionError.hxx> | |
66 | ||
67 | #include <TopoDS_Solid.hxx> | |
68 | #include <TopoDS_Compound.hxx> | |
69 | #include <TopoDS_Shell.hxx> | |
70 | ||
71 | #include <gp_Pln.hxx> | |
72 | #include <Geom_Plane.hxx> | |
73 | ||
74 | ||
75 | #include <TopExp.hxx> | |
76 | #include <Precision.hxx> | |
77 | #include <BRepBndLib.hxx> | |
78 | #include <BRepBuilderAPI.hxx> | |
79 | #include <BRepFeat.hxx> | |
80 | ||
81 | #include <ElCLib.hxx> | |
82 | ||
83 | #ifdef DEB | |
1d0a9d4d | 84 | extern Standard_Boolean BRepFeat_GettraceFEAT(); |
7fd59977 | 85 | #endif |
86 | ||
87 | static void MajMap(const TopoDS_Shape&, // base | |
88 | const LocOpe_Revol&, | |
89 | TopTools_DataMapOfShapeListOfShape&, // myMap | |
90 | TopoDS_Shape&, // myFShape | |
91 | TopoDS_Shape&); // myLShape | |
92 | ||
93 | ||
94 | static void SetGluedFaces(const TopoDS_Face& theSkface, | |
95 | const TopoDS_Shape& theSbase, | |
96 | const TopoDS_Shape& thePbase, | |
97 | const TopTools_DataMapOfShapeListOfShape& theSlmap, | |
98 | LocOpe_Revol&, | |
99 | TopTools_DataMapOfShapeShape&); | |
100 | ||
101 | ||
102 | static void VerifGluedFaces(const TopoDS_Face& theSkface, | |
103 | const TopoDS_Shape& thePbase, | |
104 | Handle(Geom_Curve)& theBCurve, | |
105 | TColGeom_SequenceOfCurve& theCurves, | |
106 | LocOpe_Revol& theRevol, | |
107 | TopTools_DataMapOfShapeShape& theMap); | |
108 | ||
109 | ||
110 | static Standard_Boolean ToFuse(const TopoDS_Face& , | |
111 | const TopoDS_Face&); | |
112 | ||
113 | ||
114 | ||
115 | ||
116 | //======================================================================= | |
117 | //function : Init | |
118 | //purpose : | |
119 | //======================================================================= | |
120 | ||
121 | void BRepFeat_MakeRevol::Init(const TopoDS_Shape& Sbase, | |
122 | const TopoDS_Shape& Pbase, | |
123 | const TopoDS_Face& Skface, | |
124 | const gp_Ax1& Axis, | |
125 | const Standard_Integer Mode, | |
126 | const Standard_Boolean Modify) | |
127 | { | |
128 | #ifdef DEB | |
129 | Standard_Boolean trc = BRepFeat_GettraceFEAT(); | |
130 | if (trc) cout << "BRepFeat_MakeRevol::Init" << endl; | |
131 | #endif | |
132 | myAxis = Axis; | |
133 | myPbase = Pbase; | |
134 | mySbase = Sbase; | |
135 | BasisShapeValid(); | |
136 | mySkface = Skface; | |
137 | SketchFaceValid(); | |
138 | myPbase = Pbase; | |
139 | mySlface.Clear(); | |
140 | if(Mode == 0) { | |
141 | myFuse = Standard_False; | |
142 | myJustFeat = Standard_False; | |
143 | } | |
144 | else if(Mode == 1) { | |
145 | myFuse = Standard_True; | |
146 | myJustFeat = Standard_False; | |
147 | } | |
148 | else if(Mode == 2) { | |
149 | myFuse = Standard_True; | |
150 | myJustFeat = Standard_True; | |
151 | } | |
152 | else { | |
153 | } | |
154 | myModify = Modify; | |
155 | myJustGluer = Standard_False; | |
156 | ||
157 | //-------------- ifv | |
158 | // mySkface.Nullify(); | |
159 | //-------------- ifv | |
160 | ||
161 | ||
162 | myShape.Nullify(); | |
163 | myMap.Clear(); | |
164 | myFShape.Nullify(); | |
165 | myLShape.Nullify(); | |
166 | TopExp_Explorer exp; | |
167 | for (exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) { | |
168 | TopTools_ListOfShape thelist; | |
169 | myMap.Bind(exp.Current(), thelist); | |
170 | myMap(exp.Current()).Append(exp.Current()); | |
171 | } | |
172 | #ifdef DEB | |
173 | if (trc) { | |
174 | if (myJustFeat) cout << " Just Feature" << endl; | |
175 | if (myFuse) cout << " Fuse" << endl; | |
176 | if (!myFuse) cout << " Cut" << endl; | |
177 | if (!myModify) cout << " Modify = 0" << endl; | |
178 | } | |
179 | #endif | |
180 | } | |
181 | ||
182 | ||
183 | //======================================================================= | |
184 | //function : Add | |
0d969553 | 185 | //purpose : add faces add edges of sliding |
7fd59977 | 186 | //======================================================================= |
187 | ||
188 | void BRepFeat_MakeRevol::Add(const TopoDS_Edge& E, | |
189 | const TopoDS_Face& F) | |
190 | { | |
191 | #ifdef DEB | |
192 | Standard_Boolean trc = BRepFeat_GettraceFEAT(); | |
193 | if (trc) cout << "BRepFeat_MakeRevol::Add(Edge,face)" << endl; | |
194 | #endif | |
195 | TopExp_Explorer exp; | |
196 | for (exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) { | |
197 | if (exp.Current().IsSame(F)) { | |
198 | break; | |
199 | } | |
200 | } | |
201 | if (!exp.More()) { | |
202 | Standard_ConstructionError::Raise(); | |
203 | } | |
204 | ||
205 | for (exp.Init(myPbase,TopAbs_EDGE);exp.More();exp.Next()) { | |
206 | if (exp.Current().IsSame(E)) { | |
207 | break; | |
208 | } | |
209 | } | |
210 | if (!exp.More()) { | |
211 | Standard_ConstructionError::Raise(); | |
212 | } | |
213 | ||
214 | if (!mySlface.IsBound(F)) { | |
215 | TopTools_ListOfShape thelist; | |
216 | mySlface.Bind(F, thelist); | |
217 | } | |
218 | TopTools_ListIteratorOfListOfShape itl(mySlface(F)); | |
219 | for (; itl.More();itl.Next()) { | |
220 | if (itl.Value().IsSame(E)) { | |
221 | break; | |
222 | } | |
223 | } | |
224 | if (!itl.More()) { | |
225 | mySlface(F).Append(E); | |
226 | } | |
227 | } | |
228 | ||
229 | ||
230 | //======================================================================= | |
231 | //function : Perform | |
232 | //purpose : | |
233 | //======================================================================= | |
234 | ||
235 | void BRepFeat_MakeRevol::Perform(const Standard_Real Angle) | |
236 | { | |
237 | #ifdef DEB | |
238 | Standard_Boolean trc = BRepFeat_GettraceFEAT(); | |
239 | if (trc) cout << "BRepFeat_MakeRevol::Perform(Angle)" << endl; | |
240 | #endif | |
241 | mySFrom.Nullify(); | |
242 | ShapeFromValid(); | |
243 | mySUntil.Nullify(); | |
244 | ShapeUntilValid(); | |
245 | myGluedF.Clear(); | |
246 | myPerfSelection = BRepFeat_NoSelection; | |
247 | PerfSelectionValid(); | |
c6541a0c | 248 | Standard_Boolean RevolComp = (2*M_PI-Abs(Angle) <= Precision::Angular()); |
7fd59977 | 249 | LocOpe_Revol theRevol; |
250 | Standard_Real angledec = 0.; | |
251 | TopExp_Explorer exp; | |
252 | if(RevolComp) { | |
253 | /* | |
254 | if (!mySkface.IsNull() || !mySlface.IsEmpty()) { | |
255 | for (exp.Init(mySbase,TopAbs_FACE); exp.More(); exp.Next()) { | |
256 | if (exp.Current().IsSame(mySkface)) { | |
c6541a0c | 257 | angledec = M_PI/5; // pourquoi pas |
7fd59977 | 258 | if (myFuse) angledec = -angledec; |
259 | break; | |
260 | } | |
261 | } | |
262 | } | |
263 | */ | |
264 | mySkface.Nullify(); | |
265 | } | |
266 | if(angledec == 0.) theRevol.Perform(myPbase, myAxis, Angle); | |
267 | else theRevol.Perform(myPbase, myAxis, Angle, angledec); | |
268 | ||
269 | TopoDS_Shape VraiRevol = theRevol.Shape(); | |
270 | ||
271 | MajMap(myPbase,theRevol,myMap,myFShape,myLShape); | |
272 | ||
273 | myGShape = VraiRevol; | |
274 | GeneratedShapeValid(); | |
275 | TopoDS_Shape Base = theRevol.FirstShape(); | |
276 | exp.Init(Base, TopAbs_FACE); | |
277 | TopoDS_Face theBase = TopoDS::Face(exp.Current()); | |
278 | exp.Next(); | |
279 | if(exp.More()) { | |
280 | NotDone(); | |
281 | myStatusError = BRepFeat_InvFirstShape; | |
282 | return; | |
283 | } | |
284 | ||
285 | TopoDS_Face FFace; | |
286 | ||
287 | Standard_Boolean found = Standard_False; | |
288 | ||
289 | if(!mySkface.IsNull() || !mySlface.IsEmpty()) { | |
290 | if(myLShape.ShapeType() == TopAbs_WIRE) { | |
291 | TopExp_Explorer ex1(VraiRevol, TopAbs_FACE); | |
292 | for(; ex1.More(); ex1.Next()) { | |
293 | TopExp_Explorer ex2(ex1.Current(), TopAbs_WIRE); | |
294 | for(; ex2.More(); ex2.Next()) { | |
295 | if(ex2.Current().IsSame(myLShape)) { | |
296 | FFace = TopoDS::Face(ex1.Current()); | |
297 | found = Standard_True; | |
298 | break; | |
299 | } | |
300 | } | |
301 | if(found) break; | |
302 | } | |
303 | } | |
304 | ||
305 | TopExp_Explorer exp(mySbase, TopAbs_FACE); | |
306 | for(; exp.More(); exp.Next()) { | |
307 | const TopoDS_Face& ff = TopoDS::Face(exp.Current()); | |
308 | if(ToFuse(ff, FFace)) { | |
309 | TopTools_DataMapOfShapeListOfShape sl; | |
310 | if(!FFace.IsSame(myPbase) && BRepFeat::IsInside(ff, FFace)) | |
311 | //SetGluedFaces(ff, mySbase, FFace, sl, theRevol, myGluedF); | |
312 | break; | |
313 | } | |
314 | } | |
315 | } | |
316 | ||
317 | //SetGluedFaces(mySkface, mySbase, theBase, mySlface, theRevol, myGluedF); | |
318 | GluedFacesValid(); | |
319 | if (!mySkface.IsNull()) { | |
320 | VerifGluedFaces(mySkface, theBase, myBCurve, myCurves, theRevol, myGluedF); | |
321 | } | |
322 | ||
323 | if(myGluedF.IsEmpty()) { | |
324 | if(myFuse == 1) { | |
325 | //modified by NIZNHY-PKV Thu Mar 21 18:15:06 2002 f | |
326 | //BRepAlgo_Fuse f(mySbase, myGShape); | |
327 | //myShape = f.Shape(); | |
328 | //UpdateDescendants(f.Builder(), myShape, Standard_False); | |
329 | BRepAlgoAPI_Fuse f(mySbase, myGShape); | |
330 | myShape = f.Shape(); | |
331 | UpdateDescendants(f, myShape, Standard_False); | |
332 | //modified by NIZNHY-PKV Thu Mar 21 18:15:11 2002 t | |
333 | Done(); | |
334 | } | |
335 | else if(myFuse == 0) { | |
336 | //modified by NIZNHY-PKV Thu Mar 21 18:15:37 2002 f | |
337 | //BRepAlgo_Cut c(mySbase, myGShape); | |
338 | //myShape = c.Shape(); | |
339 | //UpdateDescendants(c.Builder(), myShape, Standard_False); | |
340 | BRepAlgoAPI_Cut c(mySbase, myGShape); | |
341 | myShape = c.Shape(); | |
342 | UpdateDescendants(c, myShape, Standard_False); | |
343 | //modified by NIZNHY-PKV Thu Mar 21 18:15:47 2002 t | |
344 | Done(); | |
345 | } | |
346 | else { | |
347 | myShape = myGShape; | |
348 | Done(); | |
349 | } | |
350 | } | |
351 | else { | |
352 | theRevol.Curves(myCurves); | |
353 | myBCurve = theRevol.BarycCurve(); | |
354 | GlobalPerform(); | |
355 | } | |
356 | } | |
357 | ||
358 | ||
359 | //======================================================================= | |
360 | //function : Perform | |
0d969553 | 361 | //purpose : feature till shape Until |
7fd59977 | 362 | //======================================================================= |
363 | ||
364 | void BRepFeat_MakeRevol::Perform(const TopoDS_Shape& Until) | |
365 | { | |
366 | #ifdef DEB | |
367 | Standard_Boolean trc = BRepFeat_GettraceFEAT(); | |
368 | if (trc) cout << "BRepFeat_MakeRevol::Perform(Until)" << endl; | |
369 | #endif | |
370 | Standard_Real Angle = 0.; | |
371 | Standard_Boolean TourComplet = Standard_False; | |
372 | ||
373 | if (Until.IsNull()) { | |
374 | Standard_ConstructionError::Raise(); | |
375 | } | |
376 | TopExp_Explorer exp(Until, TopAbs_FACE); | |
377 | if (!exp.More()) { | |
378 | Standard_ConstructionError::Raise(); | |
379 | } | |
380 | if (!mySkface.IsNull() && Until.IsSame(mySkface)) { | |
c6541a0c | 381 | Angle = 2*M_PI; |
7fd59977 | 382 | TourComplet = Standard_True; |
383 | } | |
384 | myGluedF.Clear(); | |
385 | myPerfSelection = BRepFeat_SelectionU; | |
386 | PerfSelectionValid(); | |
387 | mySFrom.Nullify(); | |
388 | ShapeFromValid(); | |
389 | mySUntil = Until; | |
390 | Standard_Boolean Trf = TransformShapeFU(1); | |
391 | ShapeUntilValid(); | |
392 | ||
0d969553 | 393 | // Do systematically almost complete revolution |
c6541a0c | 394 | // BRepSweep_Revol theRevol(myPbase,myAxis,2.*M_PI-10.*Precision::Angular()); |
7fd59977 | 395 | LocOpe_Revol theRevol; |
396 | if(!TourComplet) { | |
c6541a0c | 397 | Angle = 2.*M_PI- 3*M_PI/180.; |
7fd59977 | 398 | #ifdef DEB |
0d969553 | 399 | if (trc) cout << " No complete Revolution" << endl; |
7fd59977 | 400 | #endif |
401 | } | |
402 | theRevol.Perform(myPbase, myAxis, Angle); | |
403 | TopoDS_Shape VraiRevol = theRevol.Shape(); | |
404 | MajMap(myPbase,theRevol,myMap,myFShape,myLShape); | |
405 | ||
406 | ||
407 | if(!Trf) { | |
408 | ||
409 | myGShape = VraiRevol; | |
410 | GeneratedShapeValid(); | |
411 | ||
412 | TopoDS_Shape Base = theRevol.FirstShape(); | |
413 | exp.Init(Base, TopAbs_FACE); | |
414 | TopoDS_Face theBase = TopoDS::Face(exp.Current()); | |
415 | exp.Next(); | |
416 | if(exp.More()) { | |
417 | NotDone(); | |
418 | myStatusError = BRepFeat_InvFirstShape; | |
419 | return; | |
420 | } | |
421 | ||
422 | //SetGluedFaces(mySkface, mySbase, theBase, mySlface, theRevol, myGluedF); | |
423 | GluedFacesValid(); | |
424 | //VerifGluedFaces(mySkface, theBase, myBCurve, myCurves, theRevol, myGluedF); | |
425 | ||
426 | theRevol.Curves(myCurves); | |
427 | myBCurve = theRevol.BarycCurve(); | |
428 | GlobalPerform(); | |
429 | } | |
430 | else { | |
431 | TColGeom_SequenceOfCurve scur; | |
432 | theRevol.Curves(myCurves); | |
433 | myBCurve = theRevol.BarycCurve(); | |
434 | scur.Clear(); | |
435 | scur.Append(myBCurve); | |
436 | LocOpe_CSIntersector ASI(mySUntil); | |
437 | ASI.Perform(scur); | |
438 | if (ASI.IsDone() && ASI.NbPoints(1) >=1) { | |
439 | TopAbs_Orientation Or = ASI.Point(1,1).Orientation(); | |
440 | TopoDS_Face FUntil = ASI.Point(1,1).Face(); | |
441 | TopoDS_Shape Comp; | |
442 | BRep_Builder B; | |
443 | B.MakeCompound(TopoDS::Compound(Comp)); | |
444 | TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, Or); | |
445 | if (!S.IsNull()) B.Add(Comp,S); | |
446 | //modified by NIZNHY-PKV Thu Mar 21 18:17:31 2002 f | |
447 | //BRepAlgo_Cut trP(VraiRevol,Comp); | |
448 | BRepAlgoAPI_Cut trP(VraiRevol,Comp); | |
449 | //modified by NIZNHY-PKV Thu Mar 21 18:17:37 2002 t | |
450 | TopoDS_Shape Cutsh = trP.Shape(); | |
451 | TopExp_Explorer ex(Cutsh, TopAbs_SOLID); | |
452 | for(; ex.More(); ex.Next()) { | |
453 | TopExp_Explorer ex1(ex.Current(), TopAbs_FACE); | |
454 | for(; ex1.More(); ex1.Next()) { | |
455 | const TopoDS_Face& fac = TopoDS::Face(ex1.Current()); | |
456 | if(fac.IsSame(myPbase)) { | |
457 | VraiRevol = ex.Current(); | |
458 | break; | |
459 | } | |
460 | } | |
461 | } | |
462 | if(myFuse == 1) { | |
463 | //modified by NIZNHY-PKV Thu Mar 21 18:17:53 2002 f | |
464 | //BRepAlgo_Fuse f(mySbase, VraiRevol); | |
465 | //myShape = f.Shape(); | |
466 | //UpdateDescendants(f.Builder(), myShape, Standard_False); | |
467 | BRepAlgoAPI_Fuse f(mySbase, VraiRevol); | |
468 | myShape = f.Shape(); | |
469 | UpdateDescendants(f, myShape, Standard_False); | |
470 | //modified by NIZNHY-PKV Thu Mar 21 18:17:57 2002 t | |
471 | Done(); | |
472 | } | |
473 | else if(myFuse == 0) { | |
474 | //modified by NIZNHY-PKV Thu Mar 21 18:18:23 2002 f | |
475 | //BRepAlgo_Cut c(mySbase, VraiRevol); | |
476 | //myShape = c.Shape(); | |
477 | //UpdateDescendants(c.Builder(), myShape, Standard_False); | |
478 | BRepAlgoAPI_Cut c(mySbase, VraiRevol); | |
479 | myShape = c.Shape(); | |
480 | UpdateDescendants(c, myShape, Standard_False); | |
481 | //modified by NIZNHY-PKV Thu Mar 21 18:18:28 2002 t | |
482 | Done(); | |
483 | } | |
484 | else { | |
485 | myShape = VraiRevol; | |
486 | Done(); | |
487 | } | |
488 | } | |
489 | } | |
0d969553 | 490 | // Loop of control of descendance |
7fd59977 | 491 | /* |
492 | TopExp_Explorer expr(mySbase, TopAbs_FACE); | |
493 | char nom1[20], nom2[20]; | |
494 | Standard_Integer ii = 0; | |
495 | for(; expr.More(); expr.Next()) { | |
496 | ii++; | |
497 | sprintf(nom1, "faceinitial_%d", ii); | |
498 | DBRep::Set(nom1, expr.Current()); | |
499 | Standard_Integer jj = 0; | |
500 | const TopTools_ListOfShape& list = Modified(expr.Current()); | |
501 | TopTools_ListIteratorOfListOfShape ite(list); | |
502 | for(; ite.More(); ite.Next()) { | |
503 | jj++; | |
504 | sprintf(nom2, "facemodifie_%d_%d", ii, jj); | |
505 | DBRep::Set(nom2, ite.Value()); | |
506 | } | |
507 | } | |
508 | ||
509 | expr.Init(myPbase, TopAbs_EDGE); | |
510 | ii=0; | |
511 | for(; expr.More(); expr.Next()) { | |
512 | ii++; | |
513 | sprintf(nom1, "edgeinitial_%d", ii); | |
514 | DBRep::Set(nom1, expr.Current()); | |
515 | Standard_Integer jj = 0; | |
516 | const TopTools_ListOfShape& list = Generated(expr.Current()); | |
517 | TopTools_ListIteratorOfListOfShape ite(list); | |
518 | for(; ite.More(); ite.Next()) { | |
519 | jj++; | |
520 | sprintf(nom2, "facegeneree_%d_%d", ii, jj); | |
521 | DBRep::Set(nom2, ite.Value()); | |
522 | } | |
523 | } | |
524 | */ | |
525 | } | |
526 | ||
527 | ||
528 | //======================================================================= | |
529 | //function : Perform | |
0d969553 | 530 | //purpose : feature limited by two shapes |
7fd59977 | 531 | //======================================================================= |
532 | ||
533 | void BRepFeat_MakeRevol::Perform(const TopoDS_Shape& From, | |
534 | const TopoDS_Shape& Until) | |
535 | { | |
536 | #ifdef DEB | |
537 | Standard_Boolean trc = BRepFeat_GettraceFEAT(); | |
538 | if (trc) cout << "BRepFeat_MakeRevol::Perform(From,Until)" << endl; | |
539 | #endif | |
540 | if (From.IsNull() || Until.IsNull()) { | |
541 | Standard_ConstructionError::Raise(); | |
542 | } | |
543 | if (!mySkface.IsNull()) { | |
544 | if (From.IsSame(mySkface)) { | |
545 | myJustGluer = Standard_True; | |
546 | Perform(Until); | |
547 | if (myJustGluer) return; | |
548 | } | |
549 | else if (Until.IsSame(mySkface)) { | |
550 | myJustGluer = Standard_True; | |
551 | myAxis.Reverse(); | |
552 | Perform(From); | |
553 | if (myJustGluer) return; | |
554 | } | |
555 | } | |
556 | ||
557 | myGluedF.Clear(); | |
558 | myPerfSelection = BRepFeat_SelectionFU; | |
559 | PerfSelectionValid(); | |
560 | ||
561 | TopExp_Explorer exp(From, TopAbs_FACE); | |
562 | if (!exp.More()) { | |
563 | Standard_ConstructionError::Raise(); | |
564 | } | |
565 | exp.Init(Until, TopAbs_FACE); | |
566 | if (!exp.More()) { | |
567 | Standard_ConstructionError::Raise(); | |
568 | } | |
569 | ||
570 | mySFrom = From; | |
571 | Standard_Boolean Trff = TransformShapeFU(0); | |
572 | ShapeFromValid(); | |
573 | mySUntil = Until; | |
574 | Standard_Boolean Trfu = TransformShapeFU(1); | |
575 | ShapeUntilValid(); | |
576 | ||
577 | if(Trfu != Trff) { | |
578 | NotDone(); | |
579 | myStatusError = BRepFeat_IncTypes; | |
580 | return; | |
581 | } | |
582 | ||
583 | LocOpe_Revol theRevol; | |
c6541a0c | 584 | theRevol.Perform(myPbase, myAxis, 2*M_PI); |
7fd59977 | 585 | TopoDS_Shape VraiRevol = theRevol.Shape(); |
586 | ||
587 | MajMap(myPbase,theRevol,myMap,myFShape,myLShape); | |
588 | ||
589 | if(!Trff) { | |
590 | myGShape = VraiRevol; | |
591 | GeneratedShapeValid(); | |
592 | ||
593 | //SetGluedFaces(TopoDS_Face(), mySbase, myPbase, mySlface, theRevol, myGluedF); | |
594 | GluedFacesValid(); | |
595 | // VerifGluedFaces(mySkface, theBase, myBCurve, myCurves, theRevol, myGluedF); | |
596 | ||
597 | theRevol.Curves(myCurves); | |
598 | myBCurve = theRevol.BarycCurve(); | |
599 | GlobalPerform(); | |
600 | } | |
601 | else { | |
602 | theRevol.Curves(myCurves); | |
603 | myBCurve = theRevol.BarycCurve(); | |
604 | TColGeom_SequenceOfCurve scur; | |
605 | scur.Clear(); | |
606 | scur.Append(myBCurve); | |
607 | LocOpe_CSIntersector ASI1(mySUntil); | |
608 | LocOpe_CSIntersector ASI2(mySFrom); | |
609 | ASI1.Perform(scur); | |
610 | ASI2.Perform(scur); | |
611 | TopAbs_Orientation OrU, OrF; | |
612 | TopoDS_Face FFrom, FUntil; | |
613 | Standard_Real PrF, PrU; | |
614 | if (ASI1.IsDone() && ASI1.NbPoints(1) >=1) { | |
615 | OrU = ASI1.Point(1,1).Orientation(); | |
616 | FUntil = ASI1.Point(1,1).Face(); | |
617 | PrU = ASI1.Point(1,1).Parameter(); | |
618 | } | |
619 | else { | |
620 | NotDone(); | |
621 | myStatusError = BRepFeat_NoIntersectU; | |
622 | return; | |
623 | } | |
624 | if (ASI2.IsDone() && ASI2.NbPoints(1) >=1) { | |
625 | Standard_Real pr1 = ASI2.Point(1,1).Parameter(); | |
c6541a0c | 626 | pr1 = ElCLib::InPeriod(pr1,PrU-2*M_PI,PrU); |
7fd59977 | 627 | Standard_Real pr2 = ASI2.Point(1,ASI2.NbPoints(1)).Parameter(); |
c6541a0c | 628 | pr2 = ElCLib::InPeriod(pr2,PrU-2*M_PI,PrU); |
7fd59977 | 629 | OrF = OrU; |
630 | FFrom = ASI2.Point(1,1).Face(); | |
631 | PrF = Max(pr1, pr2); | |
632 | } | |
633 | else { | |
634 | NotDone(); | |
635 | myStatusError = BRepFeat_NoIntersectF; | |
636 | return; | |
637 | } | |
638 | if(!(PrU > PrF)) { | |
639 | NotDone(); | |
640 | myStatusError = BRepFeat_IncParameter; | |
641 | return; | |
642 | } | |
643 | TopoDS_Shape Comp; | |
644 | BRep_Builder B; | |
645 | B.MakeCompound(TopoDS::Compound(Comp)); | |
646 | TopoDS_Solid SF = BRepFeat::Tool(mySFrom, FFrom, OrF); | |
647 | if (!SF.IsNull()) B.Add(Comp,SF); | |
648 | TopoDS_Solid SU = BRepFeat::Tool(mySUntil, FUntil, OrU); | |
649 | if (!SU.IsNull()) B.Add(Comp,SU); | |
650 | //modified by NIZNHY-PKV Thu Mar 21 18:18:54 2002 f | |
651 | //BRepAlgo_Cut trP(VraiRevol,Comp); | |
652 | BRepAlgoAPI_Cut trP(VraiRevol,Comp); | |
653 | //modified by NIZNHY-PKV Thu Mar 21 18:18:57 2002 t | |
654 | TopoDS_Shape Cutsh = trP.Shape(); | |
655 | TopExp_Explorer ex(Cutsh, TopAbs_SOLID); | |
656 | // Standard_Real PrF = BRepFeat::ParametricBarycenter(mySFrom, myBCurve); | |
657 | // Standard_Real PrU = BRepFeat::ParametricBarycenter(mySUntil, myBCurve); | |
658 | VraiRevol = ex.Current(); | |
659 | for(; ex.More(); ex.Next()) { | |
660 | Standard_Real PrCur = BRepFeat:: | |
661 | ParametricBarycenter(ex.Current(), myBCurve); | |
662 | if(PrF <= PrCur && PrU >= PrCur) { | |
663 | VraiRevol = ex.Current(); | |
664 | break; | |
665 | } | |
666 | } | |
667 | if(myFuse == 1) { | |
668 | //modified by NIZNHY-PKV Thu Mar 21 18:19:14 2002 f | |
669 | //BRepAlgo_Fuse f(mySbase, VraiRevol); | |
670 | //myShape = f.Shape(); | |
671 | //UpdateDescendants(f.Builder(), myShape, Standard_False); | |
672 | BRepAlgoAPI_Fuse f(mySbase, VraiRevol); | |
673 | myShape = f.Shape(); | |
674 | UpdateDescendants(f, myShape, Standard_False); | |
675 | //modified by NIZNHY-PKV Thu Mar 21 18:19:18 2002 t | |
676 | Done(); | |
677 | } | |
678 | else if(myFuse == 0) { | |
679 | //modified by NIZNHY-PKV Thu Mar 21 18:19:46 2002 f | |
680 | //BRepAlgo_Cut c(mySbase, VraiRevol); | |
681 | //myShape = c.Shape(); | |
682 | //UpdateDescendants(c.Builder(), myShape, Standard_False); | |
683 | BRepAlgoAPI_Cut c(mySbase, VraiRevol); | |
684 | myShape = c.Shape(); | |
685 | UpdateDescendants(c, myShape, Standard_False); | |
686 | //modified by NIZNHY-PKV Thu Mar 21 18:19:50 2002 t | |
687 | Done(); | |
688 | } | |
689 | else { | |
690 | myShape = VraiRevol; | |
691 | Done(); | |
692 | } | |
693 | } | |
694 | } | |
695 | ||
696 | ||
697 | //======================================================================= | |
698 | //function : PerformThruAll | |
0d969553 | 699 | //purpose : feature throughout the initial shape |
7fd59977 | 700 | //======================================================================= |
701 | ||
702 | void BRepFeat_MakeRevol::PerformThruAll() | |
703 | { | |
704 | #ifdef DEB | |
705 | Standard_Boolean trc = BRepFeat_GettraceFEAT(); | |
706 | if (trc) cout << "BRepFeat_MakeRevol::PerformThruAll()" << endl; | |
707 | #endif | |
c6541a0c | 708 | Perform(2.*M_PI); |
7fd59977 | 709 | } |
710 | ||
711 | //======================================================================= | |
712 | //function : PerformUntilAngle | |
0d969553 | 713 | //purpose : feature till shape Until defined with the angle |
7fd59977 | 714 | //======================================================================= |
715 | ||
716 | void BRepFeat_MakeRevol::PerformUntilAngle(const TopoDS_Shape& Until, | |
717 | const Standard_Real Angle) | |
718 | { | |
719 | #ifdef DEB | |
720 | Standard_Boolean trc = BRepFeat_GettraceFEAT(); | |
721 | if (trc) cout << "BRepFeat_MakeRevol::PerformUntilAngle(Until,Angle)" << endl; | |
722 | #endif | |
723 | if (Until.IsNull()) { | |
724 | Perform(Angle); | |
725 | } | |
726 | if(Angle == 0) { | |
727 | Perform(Until); | |
728 | } | |
729 | TopExp_Explorer exp(Until, TopAbs_FACE); | |
730 | if (!exp.More()) { | |
731 | Standard_ConstructionError::Raise(); | |
732 | } | |
733 | if (!mySkface.IsNull() && Until.IsSame(mySkface)) { | |
734 | Perform(Angle); | |
735 | return; | |
736 | } | |
737 | myGluedF.Clear(); | |
738 | myPerfSelection = BRepFeat_NoSelection; | |
739 | PerfSelectionValid(); | |
740 | mySFrom.Nullify(); | |
741 | ShapeFromValid(); | |
742 | mySUntil = Until; | |
743 | Standard_Boolean Trf = TransformShapeFU(1); | |
744 | ShapeUntilValid(); | |
745 | ||
0d969553 | 746 | // Produce systematicallt an almost complete revolution |
c6541a0c | 747 | // BRepSweep_Revol theRevol(myPbase,myAxis,2.*M_PI-10.*Precision::Angular()); |
7fd59977 | 748 | LocOpe_Revol theRevol; |
749 | theRevol.Perform(myPbase, myAxis, Angle); | |
750 | TopoDS_Shape VraiRevol = theRevol.Shape(); | |
751 | ||
752 | MajMap(myPbase,theRevol,myMap,myFShape,myLShape); | |
753 | ||
754 | if(Trf) { | |
755 | myGShape = VraiRevol; | |
756 | GeneratedShapeValid(); | |
757 | ||
758 | TopoDS_Shape Base = theRevol.FirstShape(); | |
759 | exp.Init(Base, TopAbs_FACE); | |
760 | TopoDS_Face theBase = TopoDS::Face(exp.Current()); | |
761 | exp.Next(); | |
762 | if(exp.More()) { | |
763 | NotDone(); | |
764 | myStatusError = BRepFeat_InvFirstShape; | |
765 | return; | |
766 | } | |
767 | ||
768 | //SetGluedFaces(mySkface, mySbase, theBase, mySlface, theRevol, myGluedF); | |
769 | GluedFacesValid(); | |
770 | //VerifGluedFaces(mySkface, theBase, myBCurve, myCurves, theRevol, myGluedF); | |
771 | ||
772 | ||
773 | theRevol.Curves(myCurves); | |
774 | myBCurve = theRevol.BarycCurve(); | |
775 | GlobalPerform(); | |
776 | } | |
777 | else { | |
778 | TColGeom_SequenceOfCurve scur; | |
779 | theRevol.Curves(myCurves); | |
780 | myBCurve = theRevol.BarycCurve(); | |
781 | scur.Clear(); | |
782 | scur.Append(myBCurve); | |
783 | LocOpe_CSIntersector ASI(mySUntil); | |
784 | ASI.Perform(scur); | |
785 | if (ASI.IsDone() && ASI.NbPoints(1) >=1) { | |
786 | TopAbs_Orientation Or = ASI.Point(1,1).Orientation(); | |
787 | TopoDS_Face FUntil = ASI.Point(1,1).Face(); | |
788 | TopoDS_Shape Comp; | |
789 | BRep_Builder B; | |
790 | B.MakeCompound(TopoDS::Compound(Comp)); | |
791 | TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, Or); | |
792 | if (!S.IsNull()) B.Add(Comp,S); | |
793 | //modified by NIZNHY-PKV Thu Mar 21 18:20:14 2002 f | |
794 | //BRepAlgo_Cut trP(VraiRevol,Comp); | |
795 | BRepAlgoAPI_Cut trP(VraiRevol,Comp); | |
796 | //modified by NIZNHY-PKV Thu Mar 21 18:20:19 2002 t | |
797 | TopoDS_Shape Cutsh = trP.Shape(); | |
798 | TopExp_Explorer ex(Cutsh, TopAbs_SOLID); | |
799 | for(; ex.More(); ex.Next()) { | |
800 | TopExp_Explorer ex1(ex.Current(), TopAbs_FACE); | |
801 | for(; ex1.More(); ex1.Next()) { | |
802 | const TopoDS_Face& fac = TopoDS::Face(ex1.Current()); | |
803 | if(fac.IsSame(myPbase)) { | |
804 | VraiRevol = ex.Current(); | |
805 | break; | |
806 | } | |
807 | } | |
808 | } | |
809 | if(myFuse == 1) { | |
810 | //modified by NIZNHY-PKV Thu Mar 21 18:20:36 2002 f | |
811 | //BRepAlgo_Fuse f(mySbase, VraiRevol); | |
812 | //myShape = f.Shape(); | |
813 | //UpdateDescendants(f.Builder(), myShape, Standard_False); | |
814 | BRepAlgoAPI_Fuse f(mySbase, VraiRevol); | |
815 | myShape = f.Shape(); | |
816 | UpdateDescendants(f, myShape, Standard_False); | |
817 | //modified by NIZNHY-PKV Thu Mar 21 18:20:40 2002 t | |
818 | Done(); | |
819 | } | |
820 | else if(myFuse == 0) { | |
821 | //modified by NIZNHY-PKV Thu Mar 21 18:21:07 2002 f | |
822 | //BRepAlgo_Cut c(mySbase, VraiRevol); | |
823 | //myShape = c.Shape(); | |
824 | //UpdateDescendants(c.Builder(), myShape, Standard_False); | |
825 | BRepAlgoAPI_Cut c(mySbase, VraiRevol); | |
826 | myShape = c.Shape(); | |
827 | UpdateDescendants(c, myShape, Standard_False); | |
828 | //modified by NIZNHY-PKV Thu Mar 21 18:21:26 2002 t | |
829 | Done(); | |
830 | } | |
831 | else { | |
832 | myShape = VraiRevol; | |
833 | Done(); | |
834 | } | |
835 | } | |
836 | } | |
837 | } | |
838 | //======================================================================= | |
839 | //function : Curves | |
0d969553 | 840 | //purpose : circles parallel to the generating edge of revolution |
7fd59977 | 841 | //======================================================================= |
842 | ||
843 | void BRepFeat_MakeRevol::Curves(TColGeom_SequenceOfCurve& scur) | |
844 | { | |
845 | scur = myCurves; | |
846 | } | |
847 | ||
848 | //======================================================================= | |
849 | //function : BarycCurve | |
0d969553 | 850 | //purpose : pass through the center of mass of the primitive |
7fd59977 | 851 | //======================================================================= |
852 | ||
853 | Handle(Geom_Curve) BRepFeat_MakeRevol::BarycCurve() | |
854 | { | |
855 | return myBCurve; | |
856 | } | |
857 | ||
858 | ||
859 | //======================================================================= | |
860 | //function : SetGluedFaces | |
0d969553 | 861 | //purpose : management of gluing faces |
7fd59977 | 862 | //======================================================================= |
863 | ||
864 | static void SetGluedFaces(const TopoDS_Face& theSkface, | |
865 | const TopoDS_Shape& theSbase, | |
866 | const TopoDS_Shape& thePbase, | |
867 | const TopTools_DataMapOfShapeListOfShape& theSlmap, | |
868 | LocOpe_Revol& theRevol, | |
869 | TopTools_DataMapOfShapeShape& theMap) | |
870 | { | |
871 | TopExp_Explorer exp; | |
872 | if (!theSkface.IsNull() && thePbase.ShapeType() == TopAbs_FACE) { | |
873 | for (exp.Init(theSbase,TopAbs_FACE); exp.More(); exp.Next()) { | |
874 | if (exp.Current().IsSame(theSkface)) { | |
875 | theMap.Bind(thePbase,theSkface); | |
876 | break; | |
877 | } | |
878 | } | |
879 | } | |
880 | else { | |
881 | TopExp_Explorer exp2; | |
882 | for (exp.Init(thePbase,TopAbs_FACE);exp.More();exp.Next()) { | |
883 | const TopoDS_Face& fac = TopoDS::Face(exp.Current()); | |
884 | for (exp2.Init(theSbase,TopAbs_FACE);exp2.More();exp2.Next()) { | |
885 | if (exp2.Current().IsSame(fac)) { | |
886 | theMap.Bind(fac,fac); | |
887 | break; | |
888 | } | |
889 | } | |
890 | } | |
891 | } | |
892 | ||
0d969553 | 893 | // Sliding |
7fd59977 | 894 | TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm(theSlmap); |
895 | if(!theSlmap.IsEmpty()) { | |
896 | for (; itm.More(); itm.Next()) { | |
897 | const TopoDS_Face& fac = TopoDS::Face(itm.Key()); | |
898 | const TopTools_ListOfShape& ledg = itm.Value(); | |
899 | TopTools_ListIteratorOfListOfShape it; | |
900 | for (it.Initialize(ledg); it.More(); it.Next()) { | |
901 | const TopTools_ListOfShape& gfac = theRevol.Shapes(it.Value()); | |
902 | if (gfac.Extent() != 1) { | |
903 | #ifdef DEB | |
904 | Standard_Boolean trc = BRepFeat_GettraceFEAT(); | |
905 | if (trc) cout << " BRepFeat_MakeRevol : Pb SetGluedFace" << endl; | |
906 | #endif | |
907 | } | |
908 | theMap.Bind(gfac.First(),fac); | |
909 | } | |
910 | } | |
911 | } | |
912 | } | |
913 | ||
914 | //======================================================================= | |
915 | //function : VerifGluedFaces | |
0d969553 Y |
916 | //purpose : Check intersection Tool/theSkface = thePbase |
917 | // if yes -> OK otherwise -> case without gluing | |
7fd59977 | 918 | //======================================================================= |
919 | ||
920 | static void VerifGluedFaces(const TopoDS_Face& theSkface, | |
921 | const TopoDS_Shape& thePbase, | |
922 | Handle(Geom_Curve)& theBCurve, | |
923 | TColGeom_SequenceOfCurve& theCurves, | |
924 | LocOpe_Revol& theRevol, | |
925 | TopTools_DataMapOfShapeShape& theMap) | |
926 | { | |
927 | Standard_Boolean GluedFaces = Standard_True; | |
928 | TopoDS_Shape VraiRevol = theRevol.Shape(); | |
929 | ||
930 | TColGeom_SequenceOfCurve scur; | |
931 | theRevol.Curves(theCurves); | |
932 | theBCurve = theRevol.BarycCurve(); | |
933 | scur.Clear(); | |
934 | scur.Append(theBCurve); | |
935 | LocOpe_CSIntersector ASI(theSkface); | |
936 | ASI.Perform(scur); | |
937 | if (ASI.IsDone() && ASI.NbPoints(1) >=1) { | |
938 | TopAbs_Orientation Or = ASI.Point(1,1).Orientation(); | |
939 | TopoDS_Face FSk = ASI.Point(1,1).Face(); | |
940 | TopoDS_Shape Comp; | |
941 | BRep_Builder B; | |
942 | B.MakeCompound(TopoDS::Compound(Comp)); | |
943 | TopoDS_Solid S = BRepFeat::Tool(theSkface, FSk, Or); | |
944 | if (!S.IsNull()) B.Add(Comp,S); | |
945 | //modified by NIZNHY-PKV Thu Mar 21 18:21:54 2002 f | |
946 | //BRepAlgo_Cut trP(VraiRevol,Comp); | |
947 | BRepAlgoAPI_Cut trP(VraiRevol,Comp); | |
948 | //modified by NIZNHY-PKV Thu Mar 21 18:21:58 2002 t | |
949 | TopoDS_Shape Cutsh = trP.Shape(); | |
950 | TopExp_Explorer ex(Cutsh, TopAbs_SOLID); | |
951 | for(; ex.More(); ex.Next()) { | |
952 | TopExp_Explorer ex1(ex.Current(), TopAbs_FACE); | |
953 | for(; ex1.More(); ex1.Next()) { | |
954 | const TopoDS_Face& fac1 = TopoDS::Face(ex1.Current()); | |
955 | TopExp_Explorer ex2(thePbase, TopAbs_FACE); | |
956 | for(; ex2.More(); ex2.Next()) { | |
957 | const TopoDS_Face& fac2 = TopoDS::Face(ex2.Current()); | |
958 | if(fac1.IsSame(fac2)) break; | |
959 | } | |
960 | if (ex2.More()) break; | |
961 | } | |
962 | if (ex1.More()) continue; | |
963 | GluedFaces = Standard_False; | |
964 | break; | |
965 | } | |
966 | if (!GluedFaces) { | |
967 | #ifdef DEB | |
968 | Standard_Boolean trc = BRepFeat_GettraceFEAT(); | |
0d969553 | 969 | if (trc) cout << " Intersection Revol/skface : no gluing" << endl; |
7fd59977 | 970 | #endif |
971 | theMap.Clear(); | |
972 | } | |
973 | } | |
974 | } | |
975 | ||
976 | //======================================================================= | |
977 | //function : MajMap | |
0d969553 | 978 | //purpose : management of descendants |
7fd59977 | 979 | //======================================================================= |
980 | ||
981 | static void MajMap(const TopoDS_Shape& theB, | |
982 | const LocOpe_Revol& theP, | |
983 | TopTools_DataMapOfShapeListOfShape& theMap, // myMap | |
984 | TopoDS_Shape& theFShape, // myFShape | |
985 | TopoDS_Shape& theLShape) // myLShape | |
986 | { | |
987 | TopExp_Explorer exp(theP.FirstShape(),TopAbs_WIRE); | |
988 | if (exp.More()) { | |
989 | theFShape = exp.Current(); | |
990 | TopTools_ListOfShape thelist; | |
991 | theMap.Bind(theFShape, thelist); | |
992 | for (exp.Init(theP.FirstShape(),TopAbs_FACE);exp.More();exp.Next()) { | |
993 | theMap(theFShape).Append(exp.Current()); | |
994 | } | |
995 | } | |
996 | ||
997 | exp.Init(theP.LastShape(),TopAbs_WIRE); | |
998 | if (exp.More()) { | |
999 | theLShape = exp.Current(); | |
1000 | TopTools_ListOfShape thelist1; | |
1001 | theMap.Bind(theLShape, thelist1); | |
1002 | for (exp.Init(theP.LastShape(),TopAbs_FACE);exp.More();exp.Next()) { | |
1003 | theMap(theLShape).Append(exp.Current()); | |
1004 | } | |
1005 | } | |
1006 | ||
1007 | for (exp.Init(theB,TopAbs_EDGE); exp.More(); exp.Next()) { | |
1008 | if (!theMap.IsBound(exp.Current())) { | |
1009 | TopTools_ListOfShape thelist2; | |
1010 | theMap.Bind(exp.Current(), thelist2); | |
1011 | theMap(exp.Current()) = theP.Shapes(exp.Current()); | |
1012 | } | |
1013 | } | |
1014 | } | |
1015 | ||
1016 | ||
1017 | ||
1018 | //======================================================================= | |
1019 | //function : ToFuse | |
0d969553 | 1020 | //purpose : two faces samedomaine or not |
7fd59977 | 1021 | //======================================================================= |
1022 | ||
1023 | Standard_Boolean ToFuse(const TopoDS_Face& F1, | |
1024 | const TopoDS_Face& F2) | |
1025 | { | |
1026 | if (F1.IsNull() || F2.IsNull()) { | |
1027 | return Standard_False; | |
1028 | } | |
1029 | ||
1030 | Handle(Geom_Surface) S1,S2; | |
1031 | TopLoc_Location loc1, loc2; | |
1032 | Handle(Standard_Type) typS1,typS2; | |
1033 | const Standard_Real tollin = Precision::Confusion(); | |
1034 | const Standard_Real tolang = Precision::Angular(); | |
1035 | ||
1036 | S1 = BRep_Tool::Surface(F1,loc1); | |
1037 | S2 = BRep_Tool::Surface(F2,loc2); | |
1038 | ||
1039 | typS1 = S1->DynamicType(); | |
1040 | typS2 = S2->DynamicType(); | |
1041 | ||
1042 | if (typS1 == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) { | |
1043 | S1 = (*((Handle(Geom_RectangularTrimmedSurface)*)&S1))->BasisSurface(); | |
1044 | typS1 = S1->DynamicType(); | |
1045 | } | |
1046 | ||
1047 | if (typS2 == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) { | |
1048 | S2 = (*((Handle(Geom_RectangularTrimmedSurface)*)&S2))->BasisSurface(); | |
1049 | typS2 = S2->DynamicType(); | |
1050 | } | |
1051 | ||
1052 | if (typS1 != typS2) { | |
1053 | return Standard_False; | |
1054 | } | |
1055 | ||
1056 | ||
1057 | Standard_Boolean ValRet = Standard_False; | |
1058 | if (typS1 == STANDARD_TYPE(Geom_Plane)) { | |
0d969553 | 1059 | S1 = BRep_Tool::Surface(F1); // to apply the location. |
7fd59977 | 1060 | S2 = BRep_Tool::Surface(F2); |
1061 | gp_Pln pl1( (*((Handle(Geom_Plane)*)&S1))->Pln()); | |
1062 | gp_Pln pl2( (*((Handle(Geom_Plane)*)&S2))->Pln()); | |
1063 | ||
1064 | if (pl1.Position().IsCoplanar(pl2.Position(),tollin,tolang)) { | |
1065 | ValRet = Standard_True; | |
1066 | } | |
1067 | } | |
1068 | ||
1069 | return ValRet; | |
1070 | } | |
1071 | ||
1072 | ||
1073 | ||
1074 | ||
1075 | ||
1076 | ||
1077 | ||
1078 | ||
1079 |