Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1997-10-14 |
2 | // Created by: Olga KOULECHOVA | |
3 | // Copyright (c) 1997-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_MakeRevolutionForm.ixx> | |
24 | ||
25 | #include <BRepFeat.hxx> | |
26 | ||
27 | #include <LocOpe.hxx> | |
7fd59977 | 28 | #include <LocOpe_RevolutionForm.hxx> |
29 | #include <LocOpe_CSIntersector.hxx> | |
30 | #include <LocOpe_PntFace.hxx> | |
31 | #include <LocOpe_Gluer.hxx> | |
32 | #include <LocOpe_FindEdges.hxx> | |
33 | ||
34 | #include <gp_Vec.hxx> | |
35 | #include <gp_Ax1.hxx> | |
36 | #include <gp_Pln.hxx> | |
37 | #include <gp_Lin.hxx> | |
38 | #include <gp_Pnt.hxx> | |
39 | ||
40 | #include <gp_Vec2d.hxx> | |
41 | #include <gp_Pnt2d.hxx> | |
42 | ||
43 | #include <Geom_Curve.hxx> | |
44 | ||
45 | #include <Geom2d_Curve.hxx> | |
46 | #include <Geom2d_Line.hxx> | |
47 | ||
48 | #include <Geom_Line.hxx> | |
49 | #include <Geom_Circle.hxx> | |
50 | #include <Geom_Plane.hxx> | |
51 | #include <Geom_Surface.hxx> | |
52 | #include <Geom_CylindricalSurface.hxx> | |
53 | #include <Geom_ConicalSurface.hxx> | |
54 | #include <Geom_ToroidalSurface.hxx> | |
55 | #include <Geom_RectangularTrimmedSurface.hxx> | |
56 | ||
57 | #include <Geom_TrimmedCurve.hxx> | |
58 | #include <GeomProjLib.hxx> | |
59 | ||
60 | #include <Geom2dAPI_InterCurveCurve.hxx> | |
61 | #include <Geom2dAPI_ExtremaCurveCurve.hxx> | |
62 | #include <Geom2d_Curve.hxx> | |
63 | #include <Geom2d_Curve.hxx> | |
64 | ||
65 | ||
66 | #include <GeomAPI.hxx> | |
67 | #include <GeomAPI_ProjectPointOnCurve.hxx> | |
68 | ||
69 | #include <TColgp_SequenceOfPnt.hxx> | |
70 | ||
71 | #include <TColGeom_SequenceOfCurve.hxx> | |
72 | ||
73 | #include <TColStd_Array1OfReal.hxx> | |
74 | #include <IntRes2d_IntersectionPoint.hxx> | |
75 | ||
76 | #include <BRepTools_WireExplorer.hxx> | |
77 | ||
78 | #include <BRep_Tool.hxx> | |
79 | #include <BRep_Builder.hxx> | |
80 | ||
81 | #include <TopExp_Explorer.hxx> | |
82 | #include <TopExp.hxx> | |
83 | ||
84 | #include <TopTools_MapOfShape.hxx> | |
85 | #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx> | |
86 | #include <TopTools_ListOfShape.hxx> | |
87 | #include <TopTools_ListIteratorOfListOfShape.hxx> | |
88 | #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx> | |
89 | #include <TopTools_MapIteratorOfMapOfShape.hxx> | |
90 | #include <TopOpeBRepBuild_HBuilder.hxx> | |
91 | #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx> | |
92 | ||
93 | #include <TColgp_Array1OfPnt.hxx> | |
94 | ||
95 | #include <TColGeom_Array1OfCurve.hxx> | |
96 | ||
97 | #include <TopoDS.hxx> | |
98 | #include <TopoDS_Shape.hxx> | |
99 | #include <TopoDS_Face.hxx> | |
100 | ||
101 | #include <BRepLib_MakeVertex.hxx> | |
102 | #include <BRepLib_MakeEdge.hxx> | |
103 | #include <BRepLib_MakeFace.hxx> | |
104 | ||
105 | #include <BRepTools.hxx> | |
106 | ||
107 | #include <BRepPrimAPI_MakeBox.hxx> | |
108 | #include <BRepBuilderAPI_MakeFace.hxx> | |
109 | ||
110 | #include <BRepAlgo.hxx> | |
111 | ||
112 | //modified by NIZNHY-PKV Fri Mar 22 16:56:15 2002 | |
113 | //#include <BRepAlgo_Cut.hxx> | |
114 | //#include <BRepAlgo_Section.hxx> | |
115 | //#include <BRepAlgo_Common.hxx> | |
116 | #include <BRepAlgoAPI_Cut.hxx> | |
117 | #include <BRepAlgoAPI_Section.hxx> | |
118 | #include <BRepAlgoAPI_Common.hxx> | |
119 | //modified by NIZNHY-PKV Fri Mar 22 16:56:17 2002 t | |
120 | ||
121 | #include <BRepBuilderAPI_Transform.hxx> | |
122 | #include <BRepExtrema_ExtPC.hxx> | |
123 | #include <BRepExtrema_ExtCF.hxx> | |
124 | ||
125 | #include <BRepTools_Modifier.hxx> | |
126 | #include <BRepTools_TrsfModification.hxx> | |
127 | ||
128 | #include <BRepTopAdaptor_FClass2d.hxx> | |
129 | ||
130 | #include <Standard_ConstructionError.hxx> | |
131 | ||
132 | #include <Precision.hxx> | |
133 | ||
134 | ||
135 | #include <ElCLib.hxx> | |
136 | #include <ElSLib.hxx> | |
137 | #include <CSLib.hxx> | |
138 | ||
139 | #include <GeomLProp_CLProps.hxx> | |
140 | ||
141 | #ifdef DEB | |
1d0a9d4d | 142 | extern Standard_Boolean BRepFeat_GettraceFEAT(); |
143 | extern Standard_Boolean BRepFeat_GettraceFEATRIB(); | |
7fd59977 | 144 | #endif |
145 | ||
146 | static void MajMap(const TopoDS_Shape&, // base | |
147 | const LocOpe_RevolutionForm&, | |
148 | TopTools_DataMapOfShapeListOfShape&, // myMap | |
149 | TopoDS_Shape&, // myFShape | |
150 | TopoDS_Shape&); // myLShape | |
151 | ||
152 | static void SetGluedFaces(const TopTools_DataMapOfShapeListOfShape& theSlmap, | |
153 | LocOpe_RevolutionForm&, | |
154 | const TopTools_DataMapOfShapeListOfShape& SlidingMap, | |
155 | TopTools_DataMapOfShapeShape&); | |
156 | ||
157 | //======================================================================= | |
158 | //function : Init | |
159 | //purpose : | |
160 | //======================================================================= | |
161 | ||
162 | void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase, | |
163 | const TopoDS_Wire& W, | |
164 | const Handle(Geom_Plane)& Plane, | |
165 | const gp_Ax1& Axis, | |
166 | const Standard_Real H1, | |
167 | const Standard_Real H2, | |
168 | const Standard_Integer Mode, | |
169 | Standard_Boolean& Modify) | |
170 | { | |
171 | #ifdef DEB | |
172 | Standard_Boolean trc = BRepFeat_GettraceFEAT(); | |
173 | if (trc) cout << "BRepFeat_MakeRevolutionForm::Init" << endl; | |
174 | #endif | |
175 | Standard_Boolean RevolRib = Standard_True; | |
176 | Done(); | |
177 | ||
0d969553 Y |
178 | // modify = 0 if it is not required to make sliding |
179 | // = 1 if it is intended to try to make sliding | |
7fd59977 | 180 | Standard_Boolean Sliding = Modify; |
181 | ||
182 | myAxe = Axis; | |
183 | Handle(Geom_Line) Line = new Geom_Line(Axis); | |
184 | Standard_Real LineFirst, LineLast; | |
185 | ||
186 | LocOpe_CSIntersector ASI(Sbase); | |
187 | TColGeom_SequenceOfCurve scur; | |
188 | scur.Clear(); | |
189 | scur.Append(Line); | |
190 | ASI.Perform(scur); | |
191 | if(ASI.IsDone() && ASI.NbPoints(1) >= 2) { | |
192 | LineLast = ASI.Point(1, ASI.NbPoints(1)).Parameter(); | |
193 | LineFirst = ASI.Point(1, 1).Parameter(); | |
194 | } | |
195 | else { | |
196 | LineFirst = RealFirst(); | |
197 | LineLast = RealLast(); | |
198 | } | |
199 | ||
200 | Handle(Geom2d_Curve) ln2d = GeomAPI::To2d(Line, Plane->Pln()); | |
201 | ||
202 | TopExp_Explorer exx; | |
203 | Standard_Real Rad = RealLast(); | |
204 | ||
205 | exx.Init(W, TopAbs_EDGE); | |
206 | for(; exx.More(); exx.Next()) { | |
207 | const TopoDS_Edge& e = TopoDS::Edge(exx.Current()); | |
208 | Standard_Real f, l; | |
209 | Handle(Geom_Curve) c = BRep_Tool::Curve(e, f, l); | |
210 | Handle(Geom2d_Curve) c2d = GeomAPI::To2d(c, Plane->Pln()); | |
211 | Geom2dAPI_ExtremaCurveCurve extr(ln2d, c2d, LineFirst, LineLast,f,l); | |
212 | Quantity_Length L = RealLast(); | |
213 | if(extr.NbExtrema() >= 1) { | |
214 | L = extr.LowerDistance(); | |
215 | } | |
216 | gp_Pnt p1 = c->Value(f); | |
217 | gp_Pnt p2 = c->Value(l); | |
218 | GeomAPI_ProjectPointOnCurve proj1(p1, Line); | |
219 | GeomAPI_ProjectPointOnCurve proj2(p2, Line); | |
220 | if(proj1.NbPoints() < 1 || proj2.NbPoints() < 1) { | |
221 | #ifdef DEB | |
222 | if (trc) cout << " No projection points" << endl; | |
223 | #endif | |
224 | myStatusError = BRepFeat_NoProjPt; | |
225 | NotDone(); | |
226 | return; | |
227 | } | |
228 | Standard_Real par1 = proj1.Distance(1); | |
229 | Standard_Real par2 = proj2.Distance(1); | |
230 | Standard_Real Par = Min(par1, par2); | |
231 | if(Par<L) L = Par; | |
232 | if(L<Rad && L > 0.) Rad = L; | |
233 | } | |
234 | ||
235 | Standard_Real height = Min(H1, H2); | |
236 | ||
237 | if(Rad <= height) Rad = height + 0.01*height; | |
238 | ||
c6541a0c D |
239 | myAngle1 = asin(H1/Rad) + M_PI/10.; |
240 | myAngle2 = asin(H2/Rad) + M_PI/10.; | |
7fd59977 | 241 | |
c6541a0c D |
242 | if((myAngle1 - M_PI/2) > Precision::Confusion()) |
243 | myAngle1 = M_PI/2; | |
244 | if((myAngle2 - M_PI/2) > Precision::Confusion()) | |
245 | myAngle2 = M_PI/2; | |
7fd59977 | 246 | |
247 | mySkface.Nullify(); | |
248 | myPbase.Nullify(); | |
249 | ||
250 | if(Mode == 0) | |
251 | myFuse = Standard_False; | |
252 | else // if(Mode == 1) | |
253 | myFuse = Standard_True; | |
254 | #ifdef DEB | |
255 | if (trc) { | |
256 | if (myFuse) cout << " Fuse" << endl; | |
257 | if (!myFuse) cout << " Cut" << endl; | |
258 | } | |
259 | #endif | |
260 | ||
0d969553 | 261 | // ---Determination Tolerance : tolerance max on parameters |
7fd59977 | 262 | myTol = Precision::Confusion(); |
263 | ||
264 | exx.Init(W, TopAbs_VERTEX); | |
265 | for(; exx.More(); exx.Next()) { | |
266 | const Standard_Real& tol = BRep_Tool:: | |
267 | Tolerance(TopoDS::Vertex(exx.Current())); | |
268 | if(tol > myTol) myTol = tol; | |
269 | } | |
270 | ||
271 | exx.Init(Sbase, TopAbs_VERTEX); | |
272 | for(; exx.More(); exx.Next()) { | |
273 | const Standard_Real& tol = BRep_Tool:: | |
274 | Tolerance(TopoDS::Vertex(exx.Current())); | |
275 | if(tol > myTol) myTol = tol; | |
276 | } | |
277 | ||
278 | TopoDS_Shape aLocalShape = W.Oriented(TopAbs_FORWARD); | |
279 | myWire = TopoDS::Wire(aLocalShape); | |
280 | // myWire = TopoDS::Wire(W.Oriented(TopAbs_FORWARD)); | |
281 | myPln = Plane; | |
282 | myHeight1 = H1; | |
283 | myHeight2 = H2; | |
284 | ||
285 | mySbase = Sbase; | |
286 | mySlface.Clear(); | |
287 | myShape.Nullify(); | |
288 | myMap.Clear(); | |
289 | myFShape.Nullify(); | |
290 | myLShape.Nullify(); | |
291 | ||
0d969553 | 292 | // ---Calculate bounding box |
7fd59977 | 293 | BRep_Builder BB; |
294 | ||
295 | TopTools_ListOfShape theList; | |
296 | ||
297 | TopoDS_Shape U; | |
298 | U.Nullify(); | |
299 | gp_Pnt FirstCorner, LastCorner; | |
300 | Standard_Real bnd = HeightMax(mySbase, U, FirstCorner, LastCorner); | |
301 | myBnd = bnd; | |
302 | ||
303 | BRepPrimAPI_MakeBox Bndbox(FirstCorner, LastCorner); | |
304 | TopoDS_Solid BndBox = Bndbox.Solid(); | |
305 | ||
306 | ||
0d969553 | 307 | // ---Construction of the working plane face (section bounding box) |
7fd59977 | 308 | BRepLib_MakeFace PlaneF(myPln->Pln(), -6.*myBnd, |
309 | 6.*myBnd, -6.*myBnd, 6.*myBnd); | |
310 | TopoDS_Face PlaneFace = TopoDS::Face(PlaneF.Shape()); | |
311 | ||
312 | //modified by NIZNHY-PKV Fri Mar 22 16:52:26 2002 f | |
313 | //BRepAlgo_Common PlaneS(BndBox, PlaneFace); | |
314 | BRepAlgoAPI_Common PlaneS(BndBox, PlaneFace); | |
315 | //modified by NIZNHY-PKV Fri Mar 22 16:52:31 2002 t | |
316 | TopExp_Explorer EXP; | |
317 | TopoDS_Shape PlaneSect = PlaneS.Shape(); | |
318 | EXP.Init(PlaneSect, TopAbs_WIRE); | |
319 | TopoDS_Wire www = TopoDS::Wire(EXP.Current()); | |
320 | BRepLib_MakeFace Bndface(myPln->Pln(), www, Standard_True); | |
321 | TopoDS_Face BndFace = TopoDS::Face(Bndface.Shape()); | |
322 | ||
323 | ||
0d969553 | 324 | // ---Find base faces of the rib |
7fd59977 | 325 | TopoDS_Edge FirstEdge, LastEdge; |
326 | TopoDS_Face FirstFace, LastFace; | |
327 | TopoDS_Vertex FirstVertex, LastVertex; | |
328 | ||
329 | Standard_Boolean OnFirstFace = Standard_False; | |
330 | Standard_Boolean OnLastFace = Standard_False; | |
331 | Standard_Boolean PtOnFirstEdge = Standard_False; | |
332 | Standard_Boolean PtOnLastEdge = Standard_False; | |
333 | TopoDS_Edge OnFirstEdge, OnLastEdge; | |
334 | OnFirstEdge.Nullify(); | |
335 | OnLastEdge.Nullify(); | |
336 | ||
337 | Standard_Boolean Data = ExtremeFaces(RevolRib, myBnd, myPln, FirstEdge, LastEdge, | |
338 | FirstFace, LastFace, FirstVertex, | |
339 | LastVertex, OnFirstFace, OnLastFace, | |
340 | PtOnFirstEdge, PtOnLastEdge, | |
341 | OnFirstEdge, OnLastEdge); | |
342 | ||
343 | if(!Data) { | |
344 | #ifdef DEB | |
345 | if (trc) cout << " No Extreme faces" << endl; | |
346 | #endif | |
347 | myStatusError = BRepFeat_NoExtFace; | |
348 | NotDone(); | |
349 | return; | |
350 | } | |
351 | ||
352 | ||
0d969553 | 353 | // ---Proofing Point for the side of the wire to be filled - material side |
7fd59977 | 354 | gp_Pnt CheckPnt = CheckPoint(FirstEdge, bnd/10., myPln); |
355 | ||
356 | // Standard_Real f, l; | |
357 | ||
0d969553 Y |
358 | // ---Control sliding valid |
359 | // Many cases when the sliding is abandoned | |
360 | Standard_Integer Concavite = 3; // a priori the profile is not concave | |
7fd59977 | 361 | |
362 | myFirstPnt = BRep_Tool::Pnt(FirstVertex); | |
363 | myLastPnt = BRep_Tool::Pnt(LastVertex); | |
364 | ||
0d969553 | 365 | // SliList : list of faces concerned by the rib |
7fd59977 | 366 | TopTools_ListOfShape SliList; |
367 | SliList.Append(FirstFace); | |
368 | ||
0d969553 | 369 | if(Sliding) { // sliding |
7fd59977 | 370 | #ifdef DEB |
371 | if (trc) cout << " Sliding" << endl; | |
372 | #endif | |
373 | Handle(Geom_Surface) s = BRep_Tool::Surface(FirstFace); | |
374 | if (s->DynamicType() == | |
375 | STANDARD_TYPE(Geom_RectangularTrimmedSurface)) { | |
376 | s = Handle(Geom_RectangularTrimmedSurface):: | |
377 | DownCast(s)->BasisSurface(); | |
378 | } | |
379 | if(s->DynamicType() != STANDARD_TYPE(Geom_Plane) && | |
380 | s->DynamicType() != STANDARD_TYPE(Geom_CylindricalSurface) && | |
381 | s->DynamicType() != STANDARD_TYPE(Geom_ConicalSurface) && | |
382 | s->DynamicType() != STANDARD_TYPE(Geom_ToroidalSurface)) | |
383 | Sliding = Standard_False; | |
384 | } | |
385 | ||
0d969553 | 386 | if(Sliding) { // sliding |
7fd59977 | 387 | Handle(Geom_Surface) ss = BRep_Tool::Surface(LastFace); |
388 | if (ss->DynamicType() == | |
389 | STANDARD_TYPE(Geom_RectangularTrimmedSurface)) { | |
390 | ss = Handle(Geom_RectangularTrimmedSurface):: | |
391 | DownCast(ss)->BasisSurface(); | |
392 | } | |
393 | if(ss->DynamicType() != STANDARD_TYPE(Geom_Plane) && | |
394 | ss->DynamicType() != STANDARD_TYPE(Geom_CylindricalSurface) && | |
395 | ss->DynamicType() != STANDARD_TYPE(Geom_ConicalSurface) && | |
396 | ss->DynamicType() != STANDARD_TYPE(Geom_ToroidalSurface)) | |
397 | Sliding = Standard_False; | |
398 | } | |
399 | ||
0d969553 Y |
400 | // Control only start and end points no control at the middle to improve |
401 | // If make a control between Surface and segment 2 points limited | |
402 | // -> too expensive - to improve | |
7fd59977 | 403 | //gp_Pnt FirstCenter, LastCenter; |
404 | gp_Circ FirstCircle, LastCircle; | |
405 | Handle(Geom_Curve) FirstCrv, LastCrv; | |
406 | ||
0d969553 | 407 | if(Sliding) { // sliding |
7fd59977 | 408 | GeomAPI_ProjectPointOnCurve proj(myFirstPnt, Line); |
409 | if(proj.NbPoints() < 1) { | |
410 | #ifdef DEB | |
411 | if (trc) cout << " No First Point projection" << endl; | |
412 | #endif | |
413 | myStatusError = BRepFeat_NoProjPt; | |
414 | NotDone(); | |
415 | return; | |
416 | } | |
417 | Standard_Real FirstRayon = proj.Distance(1); | |
418 | gp_Pnt FirstCenter = proj.Point(1); | |
419 | ||
420 | GeomAPI_ProjectPointOnCurve proj1(myLastPnt, Line); | |
421 | if(proj.NbPoints() < 1) { | |
422 | #ifdef DEB | |
423 | if (trc) cout << " No Last Point projection" << endl; | |
424 | #endif | |
425 | myStatusError = BRepFeat_NoProjPt; | |
426 | NotDone(); | |
427 | return; | |
428 | } | |
429 | Standard_Real LastRayon = proj1.Distance(1); | |
430 | gp_Pnt LastCenter = proj1.Point(1); | |
431 | ||
432 | gp_Vec axv(myAxe.Direction()); | |
433 | gp_Ax2 ax2(FirstCenter, axv); | |
434 | gp_Ax2 ax2p(LastCenter, axv); | |
435 | gp_Circ theFC(ax2, FirstRayon); | |
436 | gp_Circ theLC(ax2p, LastRayon); | |
437 | ||
438 | gp_Pnt RFirstPnt1 = myFirstPnt.Rotated(myAxe, myAngle1); | |
439 | gp_Pnt RLastPnt1 = myLastPnt.Rotated(myAxe, myAngle1); | |
440 | gp_Pnt RFirstPnt2 = myFirstPnt.Rotated(myAxe, -myAngle2); | |
441 | gp_Pnt RLastPnt2 = myLastPnt.Rotated(myAxe, -myAngle2); | |
442 | ||
443 | BRep_Builder Bu; | |
444 | TopoDS_Vertex v1, v2, v3, v4; | |
445 | Bu.MakeVertex(v1, RFirstPnt2, Precision::Confusion()); | |
446 | Bu.MakeVertex(v2, RFirstPnt1, Precision::Confusion()); | |
447 | Bu.MakeVertex(v3, RLastPnt2, Precision::Confusion()); | |
448 | Bu.MakeVertex(v4, RLastPnt1, Precision::Confusion()); | |
449 | ||
450 | BRepLib_MakeEdge ee1(theFC, v1, v2); | |
451 | BRepLib_MakeEdge ee2(theLC, v3, v4); | |
452 | ||
453 | if(Sliding && !PtOnFirstEdge) { | |
454 | BRepExtrema_ExtCF ext1(TopoDS::Edge(ee1.Shape()), FirstFace); | |
08cd2f6b | 455 | if(ext1.NbExt() < 1 || ext1.SquareDistance(1) > Precision::SquareConfusion()) |
7fd59977 | 456 | Sliding = Standard_False; |
457 | } | |
458 | if(Sliding && !PtOnLastEdge) { | |
0d969553 | 459 | BRepExtrema_ExtCF ext2(ee2, LastFace); // ExtCF : curves and surfaces |
08cd2f6b | 460 | if(ext2.NbExt() < 1 || ext2.SquareDistance(1) > Precision::SquareConfusion()) |
7fd59977 | 461 | Sliding = Standard_False; |
462 | } | |
463 | if(Sliding && PtOnFirstEdge) { | |
464 | Standard_Real f, l; | |
465 | FirstCrv = BRep_Tool::Curve(OnFirstEdge, f, l); | |
466 | if(FirstCrv->DynamicType() != STANDARD_TYPE(Geom_Circle)) | |
467 | Sliding = Standard_False; | |
468 | else { | |
469 | Handle(Geom_Circle) C1 = Handle(Geom_Circle)::DownCast(FirstCrv); | |
470 | gp_Circ Circ = C1->Circ(); | |
471 | FirstCircle = Circ; | |
472 | gp_Ax1 circax = FirstCircle.Axis(); | |
473 | if(!circax.IsCoaxial(myAxe, Precision::Confusion(), | |
474 | Precision::Confusion())) | |
475 | Sliding = Standard_False; | |
476 | else { | |
477 | //#ifndef DEB | |
478 | if(fabs(FirstCircle.Radius()-FirstRayon) >= | |
479 | //#else | |
480 | // if(abs(FirstCircle.Radius()-FirstRayon) >= | |
481 | //#endif | |
482 | Precision::Confusion()) | |
483 | Sliding = Standard_False; | |
484 | } | |
485 | } | |
486 | } | |
487 | ||
488 | if(Sliding && PtOnLastEdge) { | |
489 | Standard_Real f, l; | |
490 | LastCrv = BRep_Tool::Curve(OnLastEdge, f, l); | |
491 | if(LastCrv->DynamicType() != STANDARD_TYPE(Geom_Circle)) | |
492 | Sliding = Standard_False; | |
493 | else { | |
494 | Handle(Geom_Circle) C1 = Handle(Geom_Circle)::DownCast(LastCrv); | |
495 | gp_Circ Circ = C1->Circ(); | |
496 | LastCircle = Circ; | |
497 | gp_Ax1 circax = LastCircle.Axis(); | |
498 | if(!circax.IsCoaxial(myAxe, Precision::Confusion(), | |
499 | Precision::Confusion())) | |
500 | Sliding = Standard_False; | |
501 | else { | |
502 | Standard_Real rad = LastCircle.Radius(); | |
503 | //#ifndef DEB | |
504 | if(fabs(rad - LastRayon) >= Precision::Confusion()) { | |
505 | //#else | |
506 | // if(abs(rad - LastRayon) >= Precision::Confusion()) { | |
507 | //#endif | |
508 | Sliding = Standard_False; | |
509 | } | |
510 | } | |
511 | } | |
512 | } | |
513 | } | |
514 | ||
515 | ||
0d969553 Y |
516 | // Construct a great profile that goes till the bounding box |
517 | // -> by tangency with first and last edge of the Wire | |
518 | // -> by normals to base faces : statistically better | |
519 | // Intersect everythin to find the final profile | |
7fd59977 | 520 | |
521 | ||
0d969553 | 522 | // ---case of sliding : construction of the face profile |
7fd59977 | 523 | if(Sliding) { |
524 | #ifdef DEB | |
525 | if (trc) cout << " still Sliding" << endl; | |
526 | #endif | |
527 | TopoDS_Face Prof; | |
528 | Standard_Boolean ProfileOK; | |
529 | ProfileOK = SlidingProfile(Prof,RevolRib,myTol,Concavite,myPln,BndFace,CheckPnt, | |
530 | FirstFace,LastFace,FirstVertex,LastVertex, | |
531 | FirstEdge,LastEdge); | |
532 | ||
533 | if (!ProfileOK) { | |
534 | #ifdef DEB | |
535 | cout << "Not computable" << endl; | |
536 | if (trc) cout << "Face profile not computable" << endl; | |
537 | #endif | |
538 | myStatusError = BRepFeat_NoFaceProf; | |
539 | NotDone(); | |
540 | return; | |
541 | } | |
542 | ||
543 | ||
0d969553 Y |
544 | // ---Propagation on faces of the initial shape |
545 | // to find the faces concerned by the rib | |
7fd59977 | 546 | Standard_Boolean falseside = Standard_True; |
547 | Sliding = Propagate(SliList, Prof, myFirstPnt, myLastPnt, falseside); | |
0d969553 | 548 | // Control if there is everything required to have the material at the proper side |
7fd59977 | 549 | if(falseside == Standard_False) { |
550 | #ifdef DEB | |
551 | cout << " Verify plane and wire orientation" << endl; | |
552 | #endif | |
553 | myStatusError = BRepFeat_FalseSide; | |
554 | NotDone(); | |
555 | return; | |
556 | } | |
557 | } | |
558 | ||
559 | ||
0d969553 | 560 | // ---Generation of the base profile of the rib |
7fd59977 | 561 | |
562 | TopoDS_Wire w; | |
563 | BB.MakeWire(w); | |
564 | TopoDS_Edge thePreviousEdge; | |
565 | TopoDS_Vertex theFV; | |
566 | thePreviousEdge.Nullify(); | |
567 | ||
0d969553 | 568 | // counter of the number of edges to fill the map |
7fd59977 | 569 | Standard_Integer counter = 1; |
570 | ||
0d969553 | 571 | // ---case of sliding |
7fd59977 | 572 | if(Sliding && !myListOfEdges.IsEmpty()) { |
573 | BRepTools_WireExplorer EX1(myWire); | |
574 | for(; EX1.More(); EX1.Next()) { | |
575 | const TopoDS_Edge& E = EX1.Current(); | |
576 | if(!myLFMap.IsBound(E)) { | |
577 | TopTools_ListOfShape theTmpList; | |
578 | myLFMap.Bind(E, theTmpList); | |
579 | } | |
580 | if(E.IsSame(FirstEdge)) { | |
581 | Standard_Real f, l; | |
582 | Handle(Geom_Curve) cc = BRep_Tool::Curve(E, f, l); | |
583 | gp_Pnt pt; | |
584 | if(!FirstEdge.IsSame(LastEdge)) { | |
585 | pt = BRep_Tool::Pnt(TopExp::LastVertex(E,Standard_True)); | |
586 | } | |
587 | else { | |
588 | pt = myLastPnt; | |
589 | Standard_Real fpar = IntPar(cc, myFirstPnt); | |
590 | Standard_Real lpar = IntPar(cc, pt); | |
591 | Handle(Geom_Curve) ccc; | |
592 | if(fpar > lpar) { | |
593 | ccc = Handle(Geom_Curve)::DownCast(cc->Reversed()); | |
594 | cc = ccc; | |
595 | } | |
596 | } | |
597 | TopoDS_Edge ee1; | |
598 | if(thePreviousEdge.IsNull()) { | |
599 | BRepLib_MakeVertex v1(myFirstPnt); | |
600 | BRepLib_MakeVertex v2(pt); | |
601 | BRepLib_MakeEdge e(cc, v1, v2); | |
602 | ee1 = TopoDS::Edge(e.Shape()); | |
603 | } | |
604 | else { | |
605 | const TopoDS_Vertex& v1 = TopExp::LastVertex(thePreviousEdge,Standard_True); | |
606 | BRepLib_MakeVertex v2(pt); | |
607 | ||
608 | BRepLib_MakeEdge e(cc, v1, v2); | |
609 | ee1 = TopoDS::Edge(e.Shape()); | |
610 | } | |
611 | TopoDS_Shape aLocalShape = ee1.Oriented(E.Orientation()); | |
612 | ee1 = TopoDS::Edge(aLocalShape); | |
613 | // ee1 = TopoDS::Edge(ee1.Oriented(E.Orientation())); | |
614 | if(counter == 1) theFV = TopExp::FirstVertex(ee1,Standard_True); | |
615 | myLFMap(E).Append(ee1); | |
616 | BB.Add(w, ee1); | |
617 | thePreviousEdge = ee1; | |
618 | counter++; | |
619 | EX1.Next(); | |
620 | break; | |
621 | } | |
622 | } | |
623 | ||
0d969553 | 624 | // Case of several edges |
7fd59977 | 625 | if(!FirstEdge.IsSame(LastEdge)) { |
626 | for(; EX1.More(); EX1.Next()) { | |
627 | const TopoDS_Edge& E = EX1.Current(); | |
628 | if(!myLFMap.IsBound(E)) { | |
629 | TopTools_ListOfShape thelist1; | |
630 | myLFMap.Bind(E, thelist1); | |
631 | } | |
632 | theList.Append(E); | |
633 | Standard_Real f, l; | |
634 | if(!E.IsSame(LastEdge)) { | |
635 | Handle(Geom_Curve) ccc = BRep_Tool::Curve(E, f, l); | |
636 | TopoDS_Vertex v1, v2; | |
637 | if(!thePreviousEdge.IsNull()) { | |
638 | v1 = TopExp::LastVertex(thePreviousEdge,Standard_True); | |
639 | v2 = TopExp::LastVertex(E,Standard_True); | |
640 | } | |
641 | else { | |
642 | // v1 = TopExp::LastVertex(E,Standard_True); | |
643 | v1 = TopExp::FirstVertex(E,Standard_True); | |
644 | v2 = TopExp::LastVertex(E,Standard_True); | |
645 | } | |
646 | BRepLib_MakeEdge E1(ccc, v1, v2); | |
647 | TopoDS_Edge E11 = TopoDS::Edge(E1.Shape()); | |
648 | TopoDS_Shape aLocalShape = E11.Oriented(E.Orientation()); | |
649 | E11 = TopoDS::Edge(aLocalShape); | |
650 | // E11 = TopoDS::Edge(E11.Oriented(E.Orientation())); | |
651 | thePreviousEdge = E11; | |
652 | myLFMap(E).Append(E11); | |
653 | BB.Add(w, E11); | |
654 | if(counter == 1) theFV = TopExp::FirstVertex(E11,Standard_True); | |
655 | counter++; | |
656 | } | |
657 | else { | |
658 | Standard_Real f, l; | |
659 | Handle(Geom_Curve) cc = BRep_Tool::Curve(E, f, l); | |
660 | gp_Pnt pf = BRep_Tool::Pnt(TopExp::FirstVertex(E,Standard_True)); | |
661 | gp_Pnt pl = myLastPnt; | |
662 | TopoDS_Edge ee; | |
663 | if(thePreviousEdge.IsNull()) { | |
664 | BRepLib_MakeEdge e(cc, pf , pl); | |
665 | ee = TopoDS::Edge(e.Shape()); | |
666 | } | |
667 | else { | |
668 | const TopoDS_Vertex& v1 = TopExp::LastVertex(thePreviousEdge,Standard_True); | |
669 | BRepLib_MakeVertex v2(pl); | |
670 | BRepLib_MakeEdge e(cc, v1, v2); | |
671 | ee = TopoDS::Edge(e.Shape()); | |
672 | } | |
673 | TopoDS_Shape aLocalShape = ee.Oriented(E.Orientation()); | |
674 | ee = TopoDS::Edge(aLocalShape); | |
675 | // ee = TopoDS::Edge(ee.Oriented(E.Orientation())); | |
676 | BB.Add(w, ee); | |
677 | myLFMap(E).Append(ee); | |
678 | if(counter == 1) theFV = TopExp::FirstVertex(ee,Standard_True); | |
679 | thePreviousEdge = ee; | |
680 | counter++; | |
681 | break; | |
682 | } | |
683 | } | |
684 | } | |
685 | ||
686 | TopTools_ListIteratorOfListOfShape it(myListOfEdges); | |
687 | Standard_Boolean FirstOK = Standard_False; | |
688 | Standard_Boolean LastOK = Standard_False; | |
689 | ||
690 | gp_Pnt theLastPnt = myLastPnt; | |
691 | Standard_Integer sens = 0; | |
692 | TopoDS_Edge theEdge, theLEdge, theFEdge; | |
693 | Standard_Integer counter1 = counter; | |
694 | TopTools_ListOfShape NewListOfEdges; | |
695 | NewListOfEdges.Clear(); | |
696 | while (!FirstOK) { | |
697 | const TopoDS_Edge& edg = TopoDS::Edge(it.Value()); | |
698 | gp_Pnt fp, lp; | |
699 | Standard_Real f, l; | |
700 | Handle(Geom_Curve) ccc = BRep_Tool::Curve(edg, f, l); | |
701 | Handle(Geom_TrimmedCurve) cc = new Geom_TrimmedCurve(ccc, f, l); | |
702 | if ( edg.Orientation() == TopAbs_REVERSED) cc->Reverse(); | |
703 | ||
704 | fp = cc->Value(cc->FirstParameter()); | |
705 | lp = cc->Value(cc->LastParameter()); | |
706 | Standard_Real dist = fp.Distance(theLastPnt); | |
707 | if(dist <= myTol) { | |
708 | sens = 1; | |
709 | LastOK = Standard_True; | |
710 | } | |
711 | else { | |
712 | dist = lp.Distance(theLastPnt); | |
713 | if(dist <= myTol) { | |
714 | sens = 2; | |
715 | LastOK = Standard_True; | |
716 | cc->Reverse(); | |
717 | } | |
718 | } | |
719 | Standard_Integer FirstFlag = 0; | |
720 | if(sens==1 && lp.Distance(myFirstPnt) <= myTol) { | |
721 | FirstOK = Standard_True; | |
722 | FirstFlag = 1; | |
723 | } | |
724 | else if(sens==2 && fp.Distance(myFirstPnt) <= myTol) { | |
725 | FirstOK = Standard_True; | |
726 | FirstFlag = 2; | |
727 | } | |
728 | ||
729 | if (LastOK) { | |
730 | TopoDS_Edge eeee; | |
731 | Standard_Real fpar = cc->FirstParameter(); | |
732 | Standard_Real lpar = cc->LastParameter(); | |
733 | if(!FirstOK) { | |
734 | if(thePreviousEdge.IsNull()) { | |
735 | BRepLib_MakeEdge e(cc, fpar, lpar); | |
736 | eeee = TopoDS::Edge(e.Shape()); | |
737 | } | |
738 | else { | |
739 | const TopoDS_Vertex& v1 = TopExp::LastVertex(thePreviousEdge,Standard_True); | |
740 | BRepLib_MakeVertex v2(cc->Value(lpar)); | |
741 | BRepLib_MakeEdge e(cc, v1, v2); | |
742 | eeee = TopoDS::Edge(e.Shape()); | |
743 | } | |
744 | } | |
745 | else { | |
746 | if(thePreviousEdge.IsNull()) { | |
747 | BRepLib_MakeVertex v1(cc->Value(fpar)); | |
748 | BRepLib_MakeEdge e(cc, v1, theFV); | |
749 | eeee = TopoDS::Edge(e.Shape()); | |
750 | } | |
751 | else { | |
752 | const TopoDS_Vertex& v1 = TopExp::LastVertex(thePreviousEdge,Standard_True); | |
753 | BRepLib_MakeEdge e(cc, v1, theFV); | |
754 | eeee = TopoDS::Edge(e.Shape()); | |
755 | } | |
756 | } | |
757 | ||
758 | thePreviousEdge = eeee; | |
759 | BB.Add(w, eeee); | |
760 | if(counter == 1) theFV = TopExp::FirstVertex(eeee,Standard_True); | |
761 | counter1++; | |
762 | NewListOfEdges.Append(edg); | |
763 | theEdge = eeee; | |
6e6cd5d9 | 764 | |
7fd59977 | 765 | if(dist <= myTol) |
766 | theFEdge = edg; | |
767 | theLastPnt = BRep_Tool::Pnt(TopExp::LastVertex(theEdge,Standard_True)); | |
768 | } | |
769 | ||
770 | if(FirstFlag == 1) { | |
771 | theLEdge = edg; | |
772 | } | |
773 | else if(FirstFlag == 2) { | |
774 | theLEdge = theEdge; | |
775 | } | |
776 | ||
777 | if(LastOK) { | |
778 | it.Initialize(myListOfEdges); | |
779 | LastOK = Standard_False; | |
780 | } | |
781 | else if(it.More()) it.Next(); | |
782 | else { | |
783 | Sliding = Standard_False; | |
784 | break; | |
785 | } | |
786 | sens = 0; | |
787 | } | |
788 | ||
789 | ||
790 | TopTools_DataMapOfShapeListOfShape SlidMap; | |
791 | SlidMap.Clear(); | |
792 | ||
793 | if(Sliding && counter1 > counter) { | |
794 | TopTools_ListIteratorOfListOfShape it; | |
795 | TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm; | |
796 | TopExp_Explorer EX2(w, TopAbs_EDGE); | |
797 | Standard_Integer ii = 0; | |
798 | for(; EX2.More(); EX2.Next()) { | |
799 | const TopoDS_Edge& E = TopoDS::Edge(EX2.Current()); | |
800 | ii++; | |
801 | if(ii >= counter && ii <= counter1) { | |
802 | it.Initialize(NewListOfEdges); | |
803 | Standard_Integer jj = 0; | |
804 | for(; it.More(); it.Next()) { | |
805 | const TopoDS_Edge& e2 = TopoDS::Edge(it.Value()); | |
806 | jj++; | |
807 | if(jj== (ii - counter +1)) { | |
808 | itm.Initialize(mySlface); | |
809 | for(; itm.More(); itm.Next()) { | |
810 | const TopoDS_Face& fac = TopoDS::Face(itm.Key()); | |
811 | const TopTools_ListOfShape& ledg = itm.Value(); | |
812 | TopTools_ListIteratorOfListOfShape itedg(ledg); | |
813 | //Standard_Integer iiii = 0; | |
814 | for(; itedg.More(); itedg.Next()) { | |
815 | const TopoDS_Edge& e1 = TopoDS::Edge(itedg.Value()); | |
816 | if(e1.IsSame(e2)){ | |
817 | if(!SlidMap.IsBound(fac)) { | |
818 | TopTools_ListOfShape thelist2; | |
819 | SlidMap.Bind(fac, thelist2); | |
820 | } | |
821 | SlidMap(fac).Append(E); | |
822 | } | |
823 | } | |
824 | } | |
825 | } | |
826 | } | |
827 | } | |
828 | } | |
829 | } | |
830 | ||
831 | mySlface.Clear(); | |
832 | mySlface = SlidMap; | |
833 | } | |
834 | ||
0d969553 Y |
835 | // ---Arguments of LocOpe_LinearForm : arguments of the prism |
836 | // sliding | |
7fd59977 | 837 | if(Sliding) { |
838 | TopoDS_Face F; | |
839 | BB.MakeFace(F, myPln, myTol); | |
840 | BB.Add(F, w); | |
841 | mySkface = F; | |
842 | myPbase = mySkface; | |
843 | mySUntil.Nullify(); | |
844 | } | |
845 | ||
846 | ||
0d969553 | 847 | // ---Case without sliding : construction of the face profile |
7fd59977 | 848 | if(!Sliding) { |
849 | #ifdef DEB | |
850 | if (trc) { | |
851 | if (Modify) cout << " Sliding failure" << endl; | |
852 | cout << " no Sliding" << endl; | |
853 | } | |
854 | #endif | |
855 | TopExp_Explorer explo1(BndFace, TopAbs_WIRE); | |
856 | TopoDS_Wire WWW = TopoDS::Wire(explo1.Current()); | |
857 | BRepTools_WireExplorer explo(WWW); | |
858 | BRep_Builder Bu; | |
859 | TopoDS_Wire Wiwiwi; | |
860 | Bu.MakeWire(Wiwiwi); | |
861 | TopoDS_Vertex NewV1, NewV2, LastV, v; | |
862 | NewV1.Nullify(); NewV2.Nullify(); LastV.Nullify(); | |
863 | ||
864 | for(; explo.More(); explo.Next()) { | |
865 | const TopoDS_Edge& e = TopoDS::Edge(explo.Current()); | |
866 | TopoDS_Vertex v1 = TopExp::FirstVertex(e,Standard_True); | |
867 | TopoDS_Vertex v2 = TopExp::LastVertex(e,Standard_True); | |
868 | ||
869 | Standard_Real f, l;//, t; | |
870 | Handle(Geom_Curve) ln = BRep_Tool::Curve(e, f, l); | |
871 | // Handle(Geom_Curve) lln = BRep_Tool::Curve(e, f, l); | |
872 | // Handle(Geom_Curve) ln; | |
873 | // if(e.Orientation() == TopAbs_REVERSED) { | |
874 | // ln = Handle(Geom_Curve)::DownCast(lln->Reversed()); | |
875 | // v = v1; v1 = v2; v2= v; | |
876 | // f = IntPar(ln, BRep_Tool::Pnt(v1)); | |
877 | // l = IntPar(ln, BRep_Tool::Pnt(v2)); | |
878 | // } | |
879 | // else ln = lln; | |
880 | ||
881 | Handle(Geom2d_Curve) l2d = GeomAPI::To2d(ln, Plane->Pln()); | |
882 | Geom2dAPI_InterCurveCurve intcc(l2d, ln2d, Precision::Confusion()); | |
883 | TopoDS_Vertex VV; VV.Nullify(); | |
884 | TopoDS_Edge ee1, ee2; | |
885 | ||
886 | if(intcc.NbPoints() > 0) { | |
887 | gp_Pnt2d P = intcc.Point(1); | |
888 | gp_Pnt point; | |
889 | myPln->D0(P.X(), P.Y(), point); | |
890 | Standard_Real par = IntPar(ln, point); | |
891 | if(f <= par && l >= par) { | |
892 | Bu.MakeVertex(VV, point, Precision::Confusion()); | |
893 | } | |
894 | } | |
895 | ||
896 | if(VV.IsNull() && NewV1.IsNull()) continue; | |
897 | ||
898 | if(!VV.IsNull() && NewV1.IsNull()) { | |
899 | NewV1 = VV; | |
900 | LastV = v2; | |
901 | BRepLib_MakeEdge ee1(NewV1, LastV); | |
902 | Bu.Add(Wiwiwi, ee1); | |
903 | continue; | |
904 | } | |
905 | ||
906 | if(VV.IsNull() && !NewV1.IsNull()) { | |
907 | BRepLib_MakeEdge ee1(LastV, v2); | |
908 | LastV = v2; | |
909 | Bu.Add(Wiwiwi, e); | |
910 | continue; | |
911 | } | |
912 | ||
913 | if(!VV.IsNull() && !NewV1.IsNull()) { | |
914 | NewV2 = VV; | |
915 | BRepLib_MakeEdge ee1(LastV, NewV2); | |
916 | LastV = NewV2; | |
917 | Bu.Add(Wiwiwi, ee1); | |
918 | BRepLib_MakeEdge ee2(LastV, NewV1); | |
919 | Bu.Add(Wiwiwi, ee2); | |
920 | break; | |
921 | } | |
922 | } | |
923 | ||
924 | BRepLib_MakeFace newbndface(myPln->Pln(), Wiwiwi, Standard_True); | |
925 | TopoDS_Face NewBndFace = TopoDS::Face(newbndface.Shape()); | |
926 | ||
927 | BRepTopAdaptor_FClass2d Cl(NewBndFace, Precision::Confusion()); | |
928 | Standard_Real paru, parv; | |
929 | ElSLib::Parameters(myPln->Pln(), CheckPnt, paru, parv); | |
930 | gp_Pnt2d checkpnt2d(paru, parv); | |
931 | if(Cl.Perform(checkpnt2d, Standard_True) == TopAbs_OUT) { | |
932 | //modified by NIZNHY-PKV Fri Mar 22 16:52:52 2002 f | |
933 | //BRepAlgo_Cut c(BndFace, NewBndFace); | |
934 | BRepAlgoAPI_Cut c(BndFace, NewBndFace); | |
935 | //modified by NIZNHY-PKV Fri Mar 22 16:52:57 2002 t | |
936 | TopExp_Explorer exp(c.Shape(), TopAbs_WIRE); | |
937 | const TopoDS_Wire& w = TopoDS::Wire(exp.Current()); | |
938 | // akm 13/02/02 : we know the plane. Why not to use it? | |
939 | // BRepLib_MakeFace ff(w); | |
940 | BRepLib_MakeFace ff(myPln->Pln(), w, Standard_True); | |
941 | NewBndFace = TopoDS::Face(ff.Shape()); | |
942 | } | |
943 | ||
944 | ||
945 | if(!BRepAlgo::IsValid(NewBndFace)) { | |
946 | #ifdef DEB | |
947 | cout << "Invalid new bounding face" << endl; | |
948 | #endif | |
949 | myStatusError = BRepFeat_InvShape; | |
950 | NotDone(); | |
951 | return; | |
952 | } | |
953 | ||
954 | BndFace = NewBndFace; | |
955 | ||
956 | ||
957 | TopoDS_Face Prof; | |
958 | Standard_Boolean ProfileOK; | |
959 | ProfileOK = NoSlidingProfile(Prof,RevolRib,myTol,Concavite,myPln, | |
960 | bnd,BndFace,CheckPnt, | |
961 | FirstFace,LastFace,FirstVertex,LastVertex, | |
962 | FirstEdge,LastEdge,OnFirstFace,OnLastFace); | |
963 | ||
964 | if (!ProfileOK) { | |
965 | #ifdef DEB | |
966 | cout << "Not computable" << endl; | |
967 | if (trc) cout << " Face profile not computable" << endl; | |
968 | #endif | |
969 | myStatusError = BRepFeat_NoFaceProf; | |
970 | NotDone(); | |
971 | return; | |
972 | } | |
973 | ||
974 | ||
0d969553 Y |
975 | // ---Propagation on the faces of the initial shape |
976 | // to find the faces concerned by the rib | |
7fd59977 | 977 | Standard_Boolean falseside = Standard_True; |
978 | Propagate(SliList, Prof, myFirstPnt, myLastPnt, falseside); | |
0d969553 | 979 | // Control if there is everything required to have the material at the proper side |
7fd59977 | 980 | if(falseside == Standard_False) { |
981 | #ifdef DEB | |
982 | cout << " Verify plane and wire orientation" << endl; | |
983 | #endif | |
984 | myStatusError = BRepFeat_FalseSide; | |
985 | NotDone(); | |
986 | return; | |
987 | } | |
988 | ||
989 | mySlface.Clear(); | |
990 | ||
991 | TopTools_ListIteratorOfListOfShape it; | |
992 | it.Initialize(SliList); | |
993 | ||
994 | TopoDS_Shape comp; | |
995 | ||
996 | BRep_Builder BB; | |
997 | BB.MakeShell(TopoDS::Shell(comp)); | |
998 | ||
999 | for(; it.More(); it.Next()) { | |
1000 | BB.Add(comp, it.Value()); | |
1001 | } | |
1002 | ||
1003 | mySUntil = comp; | |
1004 | ||
1005 | mySkface = Prof; | |
1006 | myPbase = Prof; | |
1007 | } | |
1008 | ||
1009 | mySliding = Sliding; | |
1010 | ||
1011 | TopExp_Explorer exp; | |
1012 | for ( exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) { | |
1013 | TopTools_ListOfShape thelist3; | |
1014 | myMap.Bind(exp.Current(), thelist3); | |
1015 | myMap(exp.Current()).Append(exp.Current()); | |
1016 | } | |
1017 | } | |
1018 | ||
1019 | ||
1020 | ||
1021 | //======================================================================= | |
1022 | //function : Add | |
0d969553 | 1023 | //purpose : add elements of gluing |
7fd59977 | 1024 | //======================================================================= |
1025 | ||
1026 | void BRepFeat_MakeRevolutionForm::Add(const TopoDS_Edge& E, | |
1027 | const TopoDS_Face& F) | |
1028 | { | |
1029 | #ifdef DEB | |
1030 | Standard_Boolean trc = BRepFeat_GettraceFEAT(); | |
1031 | if (trc) cout << "BRepFeat_MakeRevolutionForm::Add" << endl; | |
1032 | #endif | |
1033 | if(mySlface.IsEmpty()) { | |
1034 | TopExp_Explorer exp; | |
1035 | for (exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) { | |
1036 | if (exp.Current().IsSame(F)) { | |
1037 | break; | |
1038 | } | |
1039 | } | |
1040 | if (!exp.More()) { | |
1041 | Standard_ConstructionError::Raise(); | |
1042 | } | |
1043 | ||
1044 | if (!mySlface.IsBound(F)) { | |
1045 | TopTools_ListOfShape thelist; | |
1046 | mySlface.Bind(F, thelist); | |
1047 | } | |
1048 | TopTools_ListIteratorOfListOfShape itl(mySlface(F)); | |
1049 | for (; itl.More();itl.Next()) { | |
1050 | if (itl.Value().IsSame(E)) { | |
1051 | break; | |
1052 | } | |
1053 | } | |
1054 | if (!itl.More()) { | |
1055 | mySlface(F).Append(E); | |
1056 | } | |
1057 | } | |
1058 | } | |
1059 | ||
1060 | ||
1061 | ||
1062 | //======================================================================= | |
1063 | //function : Perform | |
1064 | //purpose : construction | |
1065 | //======================================================================= | |
1066 | ||
1067 | void BRepFeat_MakeRevolutionForm::Perform() | |
1068 | { | |
1069 | #ifdef DEB | |
1070 | Standard_Boolean trc = BRepFeat_GettraceFEAT(); | |
1071 | if (trc) cout << "BRepFeat_MakeRevolutionForm::Perform()" << endl; | |
1072 | #endif | |
1073 | if(mySbase.IsNull() || mySkface.IsNull() || myPbase.IsNull()) { | |
1074 | #ifdef DEB | |
1075 | if (trc) cout << " Fields not initialized" << endl; | |
1076 | #endif | |
1077 | myStatusError = BRepFeat_NotInitialized; | |
1078 | NotDone(); | |
1079 | return; | |
1080 | } | |
1081 | ||
1082 | gp_Pnt Pt; | |
1083 | ||
1084 | TopExp_Explorer exx(myPbase, TopAbs_VERTEX); | |
1085 | for(; exx.More(); exx.Next()) { | |
1086 | const TopoDS_Vertex& vv = TopoDS::Vertex(exx.Current()); | |
1087 | if(!vv.IsNull()) { | |
1088 | Pt = BRep_Tool::Pnt(vv); | |
1089 | break; | |
1090 | } | |
1091 | } | |
1092 | ||
1093 | if(myAngle2 != 0) { | |
1094 | gp_Trsf T; | |
1095 | T.SetRotation(myAxe, -myAngle2); | |
1096 | BRepBuilderAPI_Transform trsf(T); | |
1097 | trsf.Perform(myPbase, Standard_False); | |
1098 | TopoDS_Face Pbase = TopoDS::Face(trsf.Shape()); | |
1099 | TopTools_DataMapIteratorOfDataMapOfShapeListOfShape iter(myLFMap); | |
1100 | for(; iter.More(); iter.Next()) { | |
1101 | const TopoDS_Shape& e1 = iter.Value().First(); | |
1102 | TopExp_Explorer ex1(myPbase, TopAbs_EDGE); | |
1103 | TopExp_Explorer ex2(Pbase, TopAbs_EDGE); | |
1104 | for(; ex1.More(); ex1.Next()) { | |
1105 | if(ex1.Current().IsSame(e1)) { | |
1106 | myLFMap(iter.Key()).Clear(); | |
1107 | myLFMap(iter.Key()).Append(ex2.Current()); | |
1108 | } | |
1109 | ex2.Next(); | |
1110 | } | |
1111 | } | |
1112 | ||
1113 | TopTools_DataMapIteratorOfDataMapOfShapeListOfShape iter1(mySlface); | |
1114 | for(; iter1.More(); iter1.Next()) { | |
1115 | const TopoDS_Shape& f1 = iter1.Key(); | |
1116 | const TopoDS_Shape& e1 = iter1.Value().First(); | |
1117 | TopExp_Explorer ex1(myPbase, TopAbs_EDGE); | |
1118 | TopExp_Explorer ex2(Pbase, TopAbs_EDGE); | |
1119 | for(; ex1.More(); ex1.Next()) { | |
1120 | const TopoDS_Shape& E1 = ex1.Current(); | |
1121 | const TopoDS_Shape& E2 = ex2.Current(); | |
1122 | if(E1.IsSame(e1)) { | |
1123 | mySlface(f1).Clear(); | |
1124 | mySlface(f1).Append(E2); | |
1125 | } | |
1126 | ex2.Next(); | |
1127 | } | |
1128 | } | |
1129 | myPbase = Pbase; | |
1130 | trsf.Perform(mySkface, Standard_False); | |
0d969553 | 1131 | // flo : check if it is required to reattributr the field mySkface |
7fd59977 | 1132 | // TopoDS_Face mySkface = TopoDS::Face(trsf.Shape()); |
1133 | mySkface = TopoDS::Face(trsf.Shape()); | |
1134 | } | |
1135 | ||
1136 | LocOpe_RevolutionForm theForm; | |
1137 | theForm.Perform(myPbase, myAxe, (myAngle1+myAngle2)); | |
0d969553 | 1138 | TopoDS_Shape VraiForm = theForm.Shape(); // uncut primitive |
7fd59977 | 1139 | |
0d969553 | 1140 | // management of descendants |
7fd59977 | 1141 | MajMap(myPbase,theForm,myMap,myFShape,myLShape); |
1142 | ||
1143 | myGluedF.Clear(); | |
1144 | ||
1145 | ||
1146 | ||
1147 | gp_Pln Pln0 = myPln->Pln(); | |
1148 | BRepLib_MakeFace f(Pln0); | |
1149 | ||
1150 | ||
1151 | gp_Vec vec1 = myHeight1*Normal(f, Pt); | |
1152 | gp_Vec vec2 = -myHeight2*Normal(f, Pt); | |
1153 | ||
1154 | gp_Pln Pln1 = Pln0.Translated(vec1); | |
1155 | gp_Pln Pln2 = Pln0.Translated(vec2); | |
1156 | ||
1157 | BRepLib_MakeFace ff1(Pln1); | |
1158 | BRepLib_MakeFace ff2(Pln2); | |
1159 | TopoDS_Face f1 = TopoDS::Face(ff1.Shape()); | |
1160 | TopoDS_Face f2 = TopoDS::Face(ff2.Shape()); | |
1161 | BRepFeat::FaceUntil(mySbase, f1); | |
1162 | BRepFeat::FaceUntil(mySbase, f2); | |
1163 | ||
1164 | LocOpe_CSIntersector ASI1(f1); | |
1165 | LocOpe_CSIntersector ASI2(f2); | |
1166 | ||
1167 | Handle(Geom_Line) normale = new Geom_Line(Pt, vec1); | |
1168 | TColGeom_SequenceOfCurve scur; | |
1169 | scur.Append(normale); | |
1170 | ||
1171 | ASI1.Perform(scur); | |
1172 | ASI2.Perform(scur); | |
1173 | ||
1174 | if(!ASI1.IsDone() || !ASI2.IsDone() || | |
1175 | ASI1.NbPoints(1) != 1 || ASI2.NbPoints(1) != 1) { | |
1176 | #ifdef DEB | |
1177 | if (trc) cout << " Intersection failure" << endl; | |
1178 | #endif | |
1179 | myStatusError = BRepFeat_BadIntersect; | |
1180 | NotDone(); | |
1181 | return; | |
1182 | } | |
1183 | ||
1184 | TopAbs_Orientation Ori1 = ASI1.Point(1,1).Orientation(); | |
1185 | TopAbs_Orientation Ori2 = TopAbs::Reverse(ASI2.Point(1,1).Orientation()); | |
1186 | TopoDS_Face FF1 = ASI1.Point(1,1).Face(); | |
1187 | TopoDS_Face FF2 = ASI2.Point(1,1).Face(); | |
1188 | ||
1189 | TopoDS_Shape Comp; | |
1190 | BRep_Builder B; | |
1191 | B.MakeCompound(TopoDS::Compound(Comp)); | |
1192 | TopoDS_Solid S1 = BRepFeat::Tool(f1,FF1,Ori1); | |
1193 | TopoDS_Solid S2 = BRepFeat::Tool(f2,FF2,Ori2); | |
1194 | if (!S1.IsNull()) B.Add(Comp,S1); | |
1195 | if (!S2.IsNull()) B.Add(Comp,S2); | |
1196 | ||
1197 | //modified by NIZNHY-PKV Fri Mar 22 16:53:20 2002 f | |
1198 | //BRepAlgo_Cut trP(VraiForm,Comp); | |
1199 | BRepAlgoAPI_Cut trP(VraiForm,Comp); | |
1200 | //modified by NIZNHY-PKV Fri Mar 22 16:53:23 2002 t | |
1201 | // coupe de la nervure par deux plans parallels | |
1202 | TopTools_DataMapOfShapeListOfShape SlidingMap; | |
1203 | ||
0d969553 | 1204 | // management of descendants |
7fd59977 | 1205 | |
1206 | TopTools_DataMapIteratorOfDataMapOfShapeListOfShape it1; | |
1207 | it1.Initialize(myMap); | |
1208 | for(; it1.More(); it1.Next()) { | |
1209 | const TopoDS_Shape& orig = it1.Key(); | |
1210 | if(it1.Value().IsEmpty()) continue; | |
1211 | const TopoDS_Shape& sh = it1.Value().First(); | |
1212 | exx.Init(VraiForm, TopAbs_FACE); | |
1213 | for(; exx.More(); exx.Next()) { | |
1214 | const TopoDS_Face& fac = TopoDS::Face(exx.Current()); | |
1215 | TopExp_Explorer exx1(fac, TopAbs_WIRE); | |
1216 | const TopoDS_Wire& thew = TopoDS::Wire(exx1.Current()); | |
1217 | if(thew.IsSame(myFShape)) { | |
1218 | const TopTools_ListOfShape& desfaces = trP.Modified(f2); | |
1219 | myMap(myFShape) = desfaces; | |
1220 | continue; | |
1221 | } | |
1222 | else if(thew.IsSame(myLShape)) { | |
1223 | const TopTools_ListOfShape& desfaces = trP.Modified(f1); | |
1224 | myMap(myLShape) = desfaces; | |
1225 | continue; | |
1226 | } | |
1227 | if(fac.IsSame(sh)) { | |
1228 | if (trP.IsDeleted(fac)) { | |
1229 | } | |
1230 | else { | |
1231 | const TopTools_ListOfShape& desfaces = trP.Modified(fac); | |
1232 | if(!desfaces.IsEmpty()) { | |
1233 | myMap(orig).Clear(); | |
1234 | myMap(orig) = trP.Modified(fac); | |
1235 | } | |
1236 | } | |
1237 | } | |
1238 | } | |
1239 | } | |
1240 | ||
1241 | exx.Init(VraiForm, TopAbs_FACE); | |
1242 | for(; exx.More(); exx.Next()) { | |
1243 | const TopoDS_Face& fac = TopoDS::Face(exx.Current()); | |
1244 | TopTools_ListOfShape thelist; | |
1245 | SlidingMap.Bind(fac, thelist); | |
1246 | if (trP.IsDeleted(fac)) { | |
1247 | } | |
1248 | else { | |
1249 | const TopTools_ListOfShape& desfaces = trP.Modified(fac); | |
1250 | if(!desfaces.IsEmpty()) | |
1251 | SlidingMap(fac) = desfaces; | |
1252 | else | |
1253 | SlidingMap(fac).Append(fac); | |
1254 | } | |
1255 | } | |
1256 | ||
1257 | ||
0d969553 | 1258 | // gestion of faces of sliding |
7fd59977 | 1259 | SetGluedFaces(mySlface, theForm, SlidingMap, myGluedF); |
1260 | ||
0d969553 | 1261 | VraiForm = trP.Shape(); // primitive cut |
7fd59977 | 1262 | |
1263 | if(!myGluedF.IsEmpty()) | |
1264 | myPerfSelection = BRepFeat_NoSelection; | |
1265 | else | |
1266 | myPerfSelection = BRepFeat_SelectionSh; | |
1267 | ||
1268 | exx.Init(myPbase, TopAbs_EDGE); | |
1269 | for(; exx.More(); exx.Next()) { | |
1270 | const TopoDS_Edge& e = TopoDS::Edge(exx.Current()); | |
1271 | if(!myMap.IsBound(e)) { | |
1272 | #ifdef DEB | |
1273 | if (trc) cout << " Sliding face not in Base shape" << endl; | |
1274 | #endif | |
1275 | myStatusError = BRepFeat_IncSlidFace; | |
1276 | NotDone(); | |
1277 | return; | |
1278 | } | |
1279 | } | |
1280 | ||
1281 | myGShape = VraiForm; | |
1282 | ||
1283 | if(!myGluedF.IsEmpty() && !mySUntil.IsNull()) { | |
1284 | #ifdef DEB | |
1285 | cout << "The case is not computable" << endl; | |
1286 | if (trc) cout << " Glued faces not empty and Until shape not null" << endl; | |
1287 | #endif | |
1288 | myStatusError = BRepFeat_InvShape; | |
1289 | NotDone(); | |
1290 | return; | |
1291 | } | |
1292 | ||
0d969553 | 1293 | LFPerform(); // topological reconstruction |
7fd59977 | 1294 | } |
1295 | ||
1296 | ||
1297 | //======================================================================= | |
1298 | //function : Propagate | |
0d969553 Y |
1299 | //purpose : propagation on the faces of the inital shape, find faces |
1300 | // concerned by the rib | |
7fd59977 | 1301 | //======================================================================= |
1302 | ||
1303 | Standard_Boolean BRepFeat_MakeRevolutionForm::Propagate(TopTools_ListOfShape& SliList, | |
1304 | const TopoDS_Face& fac, | |
1305 | const gp_Pnt& Firstpnt, | |
1306 | const gp_Pnt& Lastpnt, | |
1307 | Standard_Boolean& falseside) | |
1308 | { | |
1309 | #ifdef DEB | |
1310 | Standard_Boolean trc = BRepFeat_GettraceFEATRIB(); | |
1311 | if (trc) cout << "BRepFeat_MakeRevolutionForm::Propagate" << endl; | |
1312 | #endif | |
1313 | gp_Pnt Firstpoint = Firstpnt; | |
1314 | gp_Pnt Lastpoint = Lastpnt; | |
1315 | ||
1316 | Standard_Boolean result = Standard_True; | |
1317 | TopoDS_Face CurrentFace, saveFace; | |
1318 | CurrentFace = TopoDS::Face(SliList.First()); | |
1319 | saveFace = CurrentFace; | |
1320 | // BRepBuilderAPI_MakeFace fac(myPln); | |
1321 | Standard_Boolean LastOK = Standard_False, FirstOK= Standard_False; | |
1322 | TopoDS_Vertex v1, v2, v3, v4, Vert; | |
1323 | //modified by NIZNHY-PKV Fri Mar 22 16:54:09 2002 f | |
1324 | //BRepAlgo_Section sect (fac, CurrentFace, Standard_False); | |
1325 | BRepAlgoAPI_Section sect (fac, CurrentFace, Standard_False); | |
1326 | //modified by NIZNHY-PKV Fri Mar 22 16:54:14 2002 t | |
1327 | sect.Approximation(Standard_True); | |
1328 | sect.Build(); | |
1329 | TopExp_Explorer Ex; | |
1330 | TopoDS_Edge e, e1; | |
1331 | gp_Pnt FP, LP; | |
1332 | Standard_Integer ii = 0; | |
1333 | for (Ex.Init(sect.Shape(), TopAbs_EDGE); Ex.More(); Ex.Next()) { | |
1334 | ii++; | |
1335 | if(ii==1){ | |
1336 | e = TopoDS::Edge(Ex.Current()); | |
1337 | } | |
1338 | else if (ii > 1) { | |
1339 | e1 = TopoDS::Edge(Ex.Current()); | |
1340 | break; | |
1341 | } | |
1342 | } | |
1343 | if(e.IsNull()) { | |
1344 | falseside = Standard_False; | |
1345 | return Standard_False; | |
1346 | } | |
1347 | // | |
1348 | //modified by NIZNHY-PKV Tue Apr 2 15:08:23 2002 f | |
1349 | if(!e1.IsNull()) { | |
1350 | Standard_Real aTolV1, aTolV2; | |
1351 | myListOfEdges.Clear(); | |
1352 | TopTools_ListOfShape thelist; | |
1353 | mySlface.Bind(CurrentFace, thelist); | |
1354 | mySlface(CurrentFace).Append(e1); | |
1355 | ||
1356 | myListOfEdges.Append(e1); | |
1357 | ||
1358 | v1 = TopExp::FirstVertex(e1,Standard_True); | |
1359 | v2 = TopExp::LastVertex (e1,Standard_True); | |
1360 | ||
1361 | FP = BRep_Tool::Pnt(v1); | |
1362 | LP = BRep_Tool::Pnt(v2); | |
1363 | ||
1364 | aTolV1=BRep_Tool::Tolerance(v1); | |
1365 | aTolV2=BRep_Tool::Tolerance(v2); | |
1366 | ||
1367 | if(FP.Distance(Firstpoint) <= aTolV1 || | |
1368 | FP.Distance(Lastpoint) <= aTolV1) { | |
1369 | FirstOK = Standard_True; | |
1370 | } | |
1371 | if(LP.Distance(Firstpoint)<= aTolV2 || | |
1372 | LP.Distance(Lastpoint) <= aTolV2) { | |
1373 | LastOK = Standard_True; | |
1374 | } | |
1375 | ||
1376 | if(LastOK && FirstOK) { | |
1377 | return result; | |
1378 | } | |
1379 | ||
1380 | else { | |
1381 | myListOfEdges.Clear(); | |
1382 | } | |
1383 | } | |
1384 | //modified by NIZNHY-PKV Tue Apr 2 15:08:26 2002 t | |
1385 | // | |
1386 | if(!e1.IsNull()) { | |
1387 | myListOfEdges.Clear(); | |
1388 | TopTools_ListOfShape thelist1; | |
1389 | mySlface.Bind(CurrentFace, thelist1); | |
1390 | mySlface(CurrentFace).Append(e); | |
1391 | ||
1392 | myListOfEdges.Append(e); | |
1393 | ||
1394 | // mySlface.Bind(CurrentFace,TopTools_ListOfShape()); | |
1395 | mySlface(CurrentFace).Append(e1); | |
1396 | // myListOfEdges.Append(e1); | |
1397 | ||
1398 | v1 = TopExp::FirstVertex(e,Standard_True); | |
1399 | v2 = TopExp::LastVertex(e,Standard_True); | |
1400 | v3 = TopExp::FirstVertex(e1,Standard_True); | |
1401 | v4 = TopExp::LastVertex(e1,Standard_True); | |
1402 | gp_Pnt p1, p2, p3, p4; | |
1403 | p1 = BRep_Tool::Pnt(v1); FP = p1; | |
1404 | p2 = BRep_Tool::Pnt(v2); LP = p2; | |
1405 | p3 = BRep_Tool::Pnt(v3); | |
1406 | p4 = BRep_Tool::Pnt(v4); | |
1407 | if(p1.Distance(Firstpoint) <= BRep_Tool::Tolerance(v1)) { | |
1408 | if(p3.Distance(Lastpoint) <= BRep_Tool::Tolerance(v3)) { | |
1409 | FirstOK = Standard_True; | |
1410 | Lastpoint = p4; | |
1411 | } | |
1412 | else if(p4.Distance(Lastpoint) <= BRep_Tool::Tolerance(v4)) { | |
1413 | FirstOK = Standard_True; | |
1414 | Lastpoint = p3; | |
1415 | } | |
1416 | else { | |
1417 | e1.Nullify(); | |
1418 | } | |
1419 | } | |
1420 | else if(p1.Distance(Lastpoint) <= BRep_Tool::Tolerance(v1)) { | |
1421 | if(p3.Distance(Firstpoint) <= BRep_Tool::Tolerance(v3)) { | |
1422 | FirstOK = Standard_True; | |
1423 | Firstpoint = p4; | |
1424 | } | |
1425 | else if(p4.Distance(Firstpoint) <= BRep_Tool::Tolerance(v4)) { | |
1426 | FirstOK = Standard_True; | |
1427 | Firstpoint = p3; | |
1428 | } | |
1429 | else { | |
1430 | e1.Nullify(); | |
1431 | } | |
1432 | } | |
1433 | else if(p2.Distance(Firstpoint) <= BRep_Tool::Tolerance(v2)) { | |
1434 | if(p3.Distance(Lastpoint) <= BRep_Tool::Tolerance(v3)) { | |
1435 | LastOK = Standard_True; | |
1436 | Lastpoint = p4; | |
1437 | } | |
1438 | else if(p4.Distance(Lastpoint) <= BRep_Tool::Tolerance(v4)) { | |
1439 | LastOK = Standard_True; | |
1440 | Lastpoint = p3; | |
1441 | } | |
1442 | else { | |
1443 | e1.Nullify(); | |
1444 | } | |
1445 | } | |
1446 | else if(p2.Distance(Lastpoint) <= BRep_Tool::Tolerance(v2)) { | |
1447 | if(p3.Distance(Firstpoint) <= BRep_Tool::Tolerance(v3)) { | |
1448 | LastOK = Standard_True; | |
1449 | Firstpoint = p4; | |
1450 | } | |
1451 | else if(p4.Distance(Firstpoint) <= BRep_Tool::Tolerance(v4)) { | |
1452 | LastOK = Standard_True; | |
1453 | Firstpoint = p3; | |
1454 | } | |
1455 | else { | |
1456 | e1.Nullify(); | |
1457 | } | |
1458 | } | |
1459 | else { | |
4e57c75e | 1460 | e = e1; |
7fd59977 | 1461 | e1.Nullify(); |
1462 | } | |
1463 | } | |
1464 | if(e1.IsNull()) { | |
7fd59977 | 1465 | myListOfEdges.Clear(); |
1466 | TopTools_ListOfShape thelist2; | |
1467 | mySlface.Bind(CurrentFace, thelist2); | |
1468 | mySlface(CurrentFace).Append(e); | |
1469 | ||
1470 | myListOfEdges.Append(e); | |
1471 | ||
1472 | v1 = TopExp::FirstVertex(e,Standard_True); | |
1473 | v2 = TopExp::LastVertex(e,Standard_True); | |
1474 | ||
1475 | FP = BRep_Tool::Pnt(v1); | |
1476 | LP = BRep_Tool::Pnt(v2); | |
1477 | ||
1478 | if(FP.Distance(Firstpoint) <= BRep_Tool::Tolerance(v1) | |
1479 | || FP.Distance(Lastpoint) <= BRep_Tool::Tolerance(v1)) { | |
1480 | FirstOK = Standard_True; | |
1481 | } | |
1482 | if(LP.Distance(Firstpoint) <= BRep_Tool::Tolerance(v2) | |
1483 | || LP.Distance(Lastpoint) <= BRep_Tool::Tolerance(v2)) { | |
1484 | LastOK = Standard_True; | |
1485 | } | |
1486 | ||
1487 | if(LastOK && FirstOK) { | |
1488 | return result; | |
1489 | } | |
1490 | } | |
1491 | ||
1492 | TopTools_IndexedDataMapOfShapeListOfShape mapedges; | |
1493 | TopExp::MapShapesAndAncestors(mySbase, TopAbs_EDGE, TopAbs_FACE, mapedges); | |
1494 | TopExp_Explorer ex; | |
1495 | TopoDS_Edge FirstEdge; | |
1496 | ||
1497 | TopoDS_Vertex Vprevious; Vprevious.Nullify(); | |
1498 | TopoDS_Vertex Vpreprevious; Vpreprevious.Nullify(); | |
1499 | ||
1500 | while(!FirstOK) { | |
0d969553 | 1501 | // find edge connected to v1: |
7fd59977 | 1502 | gp_Pnt pt; |
1503 | if(!v1.IsNull()) pt= BRep_Tool::Pnt(v1); | |
1504 | gp_Pnt ptprev; | |
1505 | if(!Vprevious.IsNull()) ptprev = BRep_Tool::Pnt(Vprevious); | |
1506 | gp_Pnt ptpreprev; | |
1507 | if(!Vpreprevious.IsNull()) ptpreprev = BRep_Tool::Pnt(Vpreprevious); | |
1508 | ||
1509 | if((!Vprevious.IsNull() && ptprev.Distance(pt) <= myTol) || | |
1510 | (!Vpreprevious.IsNull() && ptpreprev.Distance(pt) <= myTol)) { | |
1511 | falseside = Standard_False; | |
1512 | return Standard_False; | |
1513 | } | |
1514 | ||
1515 | for (ex.Init(CurrentFace, TopAbs_EDGE); ex.More(); ex.Next()) { | |
1516 | const TopoDS_Edge& e = TopoDS::Edge(ex.Current()); | |
1517 | ||
1518 | BRepExtrema_ExtPC projF(v1, e); | |
1519 | ||
1520 | if(projF.IsDone() && projF.NbExt() >=1) { | |
1521 | Standard_Real dist2min = RealLast(); | |
1522 | Standard_Integer index = 0; | |
1523 | for (Standard_Integer sol =1 ; sol <= projF.NbExt(); sol++) { | |
1524 | if (projF.SquareDistance(sol) <= dist2min) { | |
1525 | index = sol; | |
1526 | dist2min = projF.SquareDistance(sol); | |
1527 | } | |
1528 | } | |
1529 | if (index != 0) { | |
1530 | if (dist2min <= BRep_Tool::Tolerance(e) * BRep_Tool::Tolerance(e)) { | |
1531 | FirstEdge = e; | |
1532 | break; | |
1533 | } | |
1534 | } | |
1535 | } | |
1536 | } | |
1537 | ||
1538 | const TopTools_ListOfShape& L = mapedges.FindFromKey(FirstEdge); | |
1539 | TopTools_ListIteratorOfListOfShape It(L); | |
1540 | ||
1541 | for (; It.More(); It.Next()) { | |
1542 | const TopoDS_Face& FF = TopoDS::Face(It.Value()); | |
1543 | if (!FF.IsSame(CurrentFace)) { | |
1544 | CurrentFace = FF; | |
1545 | break; | |
1546 | } | |
1547 | } | |
1548 | ||
1549 | //modified by NIZNHY-PKV Fri Mar 22 16:54:28 2002 f | |
1550 | //BRepAlgo_Section sectf (fac, CurrentFace, Standard_False); | |
1551 | BRepAlgoAPI_Section sectf (fac, CurrentFace, Standard_False); | |
1552 | //modified by NIZNHY-PKV Fri Mar 22 16:54:33 2002 t | |
1553 | sectf.Approximation(Standard_True); | |
1554 | sectf.Build(); | |
1555 | ||
1556 | TopoDS_Edge edg1; | |
1557 | for (Ex.Init(sectf.Shape(), TopAbs_EDGE); Ex.More(); Ex.Next()) { | |
1558 | edg1 = TopoDS::Edge(Ex.Current()); | |
1559 | gp_Pnt ppp1 = BRep_Tool::Pnt(TopExp::FirstVertex(edg1,Standard_True)); | |
1560 | gp_Pnt ppp2 = BRep_Tool::Pnt(TopExp::LastVertex(edg1,Standard_True)); | |
1561 | if(ppp1.Distance(BRep_Tool::Pnt(v1)) <= BRep_Tool::Tolerance(v1) || | |
1562 | ppp2.Distance(BRep_Tool::Pnt(v1)) <= BRep_Tool::Tolerance(v1)) | |
1563 | break; | |
1564 | } | |
1565 | ||
1566 | TopTools_ListOfShape thelist3; | |
1567 | mySlface.Bind(CurrentFace, thelist3); | |
1568 | mySlface(CurrentFace).Append(edg1); | |
1569 | myListOfEdges.Append(edg1); | |
1570 | ||
1571 | if (!edg1.IsNull()) SliList.Prepend(CurrentFace); | |
1572 | else return Standard_False; | |
1573 | ||
1574 | Vert = TopExp::FirstVertex(edg1,Standard_True); | |
1575 | gp_Pnt PP = BRep_Tool::Pnt(Vert); | |
1576 | FP = BRep_Tool::Pnt(v1); | |
1577 | Standard_Real tol = BRep_Tool::Tolerance(edg1); | |
1578 | Standard_Real tol1 = BRep_Tool::Tolerance(v1); | |
1579 | if(tol1 > tol) tol = tol1; | |
1580 | Standard_Real dist = PP.Distance(FP); | |
1581 | if (dist <= tol) { | |
1582 | Vpreprevious = Vprevious; | |
1583 | Vprevious = v1; | |
1584 | v1 = TopExp::LastVertex(edg1,Standard_True); | |
1585 | } | |
1586 | else { | |
1587 | Vpreprevious = Vprevious; | |
1588 | Vprevious = v1; | |
1589 | v1 = Vert; | |
1590 | } | |
1591 | ||
1592 | FP = BRep_Tool::Pnt(v1); | |
1593 | ||
1594 | if(FP.Distance(Firstpoint) <= BRep_Tool::Tolerance(v1) | |
1595 | || FP.Distance(Lastpoint) <= BRep_Tool::Tolerance(v1)) { | |
1596 | FirstOK = Standard_True; | |
1597 | } | |
1598 | } | |
1599 | ||
1600 | CurrentFace = saveFace; | |
1601 | Vprevious.Nullify(); | |
1602 | Vpreprevious.Nullify(); | |
1603 | ||
1604 | while(!LastOK) { | |
0d969553 | 1605 | // find edge connected to v2: |
7fd59977 | 1606 | gp_Pnt pt; |
1607 | if(!v2.IsNull()) pt= BRep_Tool::Pnt(v2); | |
1608 | gp_Pnt ptprev; | |
1609 | if(!Vprevious.IsNull()) ptprev = BRep_Tool::Pnt(Vprevious); | |
1610 | gp_Pnt ptpreprev; | |
1611 | if(!Vpreprevious.IsNull()) ptpreprev = BRep_Tool::Pnt(Vpreprevious); | |
1612 | ||
1613 | if((!Vprevious.IsNull() && ptprev.Distance(pt) <= myTol) || | |
1614 | (!Vpreprevious.IsNull() && ptpreprev.Distance(pt) <= myTol)) { | |
1615 | falseside = Standard_False; | |
1616 | return Standard_False; | |
1617 | } | |
1618 | ||
1619 | for (ex.Init(CurrentFace, TopAbs_EDGE); ex.More(); ex.Next()) { | |
1620 | const TopoDS_Edge& e = TopoDS::Edge(ex.Current()); | |
1621 | BRepExtrema_ExtPC projF(v2, e); | |
1622 | ||
1623 | if(projF.IsDone() && projF.NbExt() >=1) { | |
1624 | Standard_Real dist2min = RealLast(); | |
1625 | Standard_Integer index = 0; | |
1626 | for (Standard_Integer sol =1 ; sol <= projF.NbExt(); sol++) { | |
1627 | if (projF.SquareDistance(sol) <= dist2min) { | |
1628 | index = sol; | |
1629 | dist2min = projF.SquareDistance(sol); | |
1630 | } | |
1631 | } | |
1632 | if (index != 0) { | |
1633 | if (dist2min <= BRep_Tool::Tolerance(e) * BRep_Tool::Tolerance(e)) { | |
1634 | FirstEdge = e; | |
1635 | break; | |
1636 | } | |
1637 | } | |
1638 | } | |
1639 | } | |
1640 | ||
1641 | const TopTools_ListOfShape& L = mapedges.FindFromKey(FirstEdge); | |
1642 | TopTools_ListIteratorOfListOfShape It(L); | |
1643 | ||
1644 | for (; It.More(); It.Next()) { | |
1645 | const TopoDS_Face& FF = TopoDS::Face(It.Value()); | |
1646 | if (!FF.IsSame(CurrentFace)) { | |
1647 | CurrentFace = FF; | |
1648 | break; | |
1649 | } | |
1650 | } | |
1651 | ||
1652 | ii = 0; | |
1653 | ||
1654 | //modified by NIZNHY-PKV Fri Mar 22 16:54:45 2002 f | |
1655 | //BRepAlgo_Section sectf (fac, CurrentFace, Standard_False); | |
1656 | BRepAlgoAPI_Section sectf (fac, CurrentFace, Standard_False); | |
1657 | //modified by NIZNHY-PKV Fri Mar 22 16:54:52 2002 t | |
1658 | sectf.Approximation(Standard_True); | |
1659 | sectf.Build(); | |
1660 | ||
1661 | TopoDS_Edge edg2; | |
1662 | for (Ex.Init(sectf.Shape(), TopAbs_EDGE); Ex.More(); Ex.Next()) { | |
1663 | edg2 = TopoDS::Edge(Ex.Current()); | |
1664 | gp_Pnt ppp1 = BRep_Tool::Pnt(TopExp::FirstVertex(edg2,Standard_True)); | |
1665 | gp_Pnt ppp2 = BRep_Tool::Pnt(TopExp::LastVertex(edg2,Standard_True)); | |
1666 | if(ppp1.Distance(BRep_Tool::Pnt(v2)) <= BRep_Tool::Tolerance(v2) || | |
1667 | ppp2.Distance(BRep_Tool::Pnt(v2)) <= BRep_Tool::Tolerance(v2)) | |
1668 | break; | |
1669 | } | |
1670 | TopTools_ListOfShape thelist4; | |
1671 | mySlface.Bind(CurrentFace, thelist4); | |
1672 | mySlface(CurrentFace).Append(edg2); | |
1673 | myListOfEdges.Append(edg2); | |
1674 | ||
1675 | if (!edg2.IsNull()) SliList.Append(CurrentFace); | |
1676 | else return Standard_False; | |
1677 | ||
1678 | Vert = TopExp::FirstVertex(edg2,Standard_True); | |
1679 | gp_Pnt PP = BRep_Tool::Pnt(Vert); | |
1680 | FP = BRep_Tool::Pnt(v2); | |
1681 | if (PP.Distance(FP)<= BRep_Tool::Tolerance(v2)) { | |
1682 | Vpreprevious = Vprevious; | |
1683 | Vprevious = v2; | |
1684 | v2 = TopExp::LastVertex(edg2,Standard_True); | |
1685 | } | |
1686 | else { | |
1687 | v2 = Vert; | |
1688 | } | |
1689 | FP = BRep_Tool::Pnt(v2); | |
1690 | ||
1691 | ||
1692 | if(FP.Distance(Firstpoint) <= BRep_Tool::Tolerance(v2) | |
1693 | || FP.Distance(Lastpoint) <= BRep_Tool::Tolerance(v2)) { | |
1694 | LastOK = Standard_True; | |
1695 | } | |
1696 | } | |
1697 | if(!e1.IsNull()) myListOfEdges.Append(e1); | |
1698 | return result; | |
1699 | ||
1700 | } | |
1701 | ||
1702 | ||
1703 | //======================================================================= | |
1704 | //function : MajMap | |
0d969553 | 1705 | //purpose : management of descendants |
7fd59977 | 1706 | //======================================================================= |
1707 | ||
1708 | static void MajMap(const TopoDS_Shape& theB, | |
1709 | const LocOpe_RevolutionForm& theP, | |
1710 | TopTools_DataMapOfShapeListOfShape& theMap, // myMap | |
1711 | TopoDS_Shape& theFShape, // myFShape | |
1712 | TopoDS_Shape& theLShape) // myLShape | |
1713 | { | |
1714 | TopExp_Explorer exp(theP.FirstShape(),TopAbs_WIRE); | |
1715 | if (exp.More()) { | |
1716 | theFShape = exp.Current(); | |
1717 | TopTools_ListOfShape thelist; | |
1718 | theMap.Bind(theFShape, thelist); | |
1719 | for (exp.Init(theP.FirstShape(),TopAbs_FACE);exp.More();exp.Next()) { | |
1720 | const TopoDS_Shape& sh = exp.Current(); | |
1721 | theMap(theFShape).Append(sh); | |
1722 | } | |
1723 | } | |
1724 | ||
1725 | exp.Init(theP.LastShape(),TopAbs_WIRE); | |
1726 | if (exp.More()) { | |
1727 | theLShape = exp.Current(); | |
1728 | TopTools_ListOfShape thelist1; | |
1729 | theMap.Bind(theLShape, thelist1); | |
1730 | for (exp.Init(theP.LastShape(),TopAbs_FACE);exp.More();exp.Next()) { | |
1731 | const TopoDS_Shape& sh = exp.Current(); | |
1732 | theMap(theLShape).Append(sh); | |
1733 | } | |
1734 | } | |
1735 | ||
1736 | for (exp.Init(theB,TopAbs_EDGE); exp.More(); exp.Next()) { | |
1737 | if (!theMap.IsBound(exp.Current())) { | |
7fd59977 | 1738 | TopTools_ListOfShape thelist2; |
1739 | theMap.Bind(exp.Current(), thelist2); | |
1740 | theMap(exp.Current()) = theP.Shapes(exp.Current()); | |
1741 | } | |
1742 | } | |
1743 | } | |
1744 | ||
1745 | ||
1746 | //======================================================================= | |
1747 | //function : SetGluedFaces | |
0d969553 | 1748 | //purpose : managemnet of sliding faces |
7fd59977 | 1749 | //======================================================================= |
1750 | ||
1751 | static void SetGluedFaces(const TopTools_DataMapOfShapeListOfShape& theSlmap, | |
1752 | LocOpe_RevolutionForm& thePrism, | |
1753 | const TopTools_DataMapOfShapeListOfShape& SlidingMap, | |
1754 | TopTools_DataMapOfShapeShape& theMap) | |
1755 | { | |
0d969553 | 1756 | // Slidings |
7fd59977 | 1757 | TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm(theSlmap); |
1758 | if(!theSlmap.IsEmpty()) { | |
1759 | for (; itm.More(); itm.Next()) { | |
1760 | const TopoDS_Face& fac = TopoDS::Face(itm.Key()); | |
1761 | const TopTools_ListOfShape& ledg = itm.Value(); | |
1762 | TopTools_ListIteratorOfListOfShape it; | |
1763 | for (it.Initialize(ledg); it.More(); it.Next()) { | |
1764 | const TopTools_ListOfShape& gfac = thePrism.Shapes(it.Value()); | |
1765 | if (gfac.Extent() != 1) { | |
1766 | #ifdef DEB | |
1767 | cout << "Pb SetGluedFace" << endl; | |
1768 | #endif | |
1769 | } | |
1770 | TopTools_DataMapIteratorOfDataMapOfShapeListOfShape iterm(SlidingMap); | |
1771 | for(; iterm.More(); iterm.Next()) { | |
1772 | const TopoDS_Face& ff = TopoDS::Face(iterm.Key()); | |
1773 | const TopTools_ListOfShape& lfaces = iterm.Value(); | |
1774 | if(lfaces.IsEmpty()) continue; | |
1775 | const TopoDS_Face& fff = TopoDS::Face(lfaces.First()); | |
1776 | if(gfac.First().IsSame(ff)) theMap.Bind(fff,fac); | |
1777 | } | |
1778 | } | |
1779 | } | |
1780 | } | |
1781 | } | |
1782 |