Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1997-04-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_MakeLinearForm.ixx> | |
24 | ||
25 | #include <BRepFeat.hxx> | |
26 | ||
27 | #include <LocOpe.hxx> | |
28 | #include <LocOpe_Builder.hxx> | |
29 | #include <LocOpe_LinearForm.hxx> | |
30 | #include <LocOpe_Gluer.hxx> | |
31 | #include <LocOpe_FindEdges.hxx> | |
32 | ||
33 | #include <gp_Vec.hxx> | |
34 | #include <gp_Pln.hxx> | |
35 | #include <gp_Lin.hxx> | |
36 | #include <gp_Dir.hxx> | |
37 | #include <gp_Pnt.hxx> | |
38 | ||
39 | #include <gp_Vec2d.hxx> | |
40 | #include <gp_Pnt2d.hxx> | |
41 | ||
42 | #include <Geom_Curve.hxx> | |
43 | ||
44 | #include <Geom2d_Curve.hxx> | |
45 | #include <Geom2d_Line.hxx> | |
46 | ||
47 | #include <Geom_Plane.hxx> | |
48 | #include <Geom_Surface.hxx> | |
49 | #include <Geom_CylindricalSurface.hxx> | |
50 | #include <Geom_RectangularTrimmedSurface.hxx> | |
51 | ||
52 | #include <Geom_TrimmedCurve.hxx> | |
53 | #include <GeomProjLib.hxx> | |
54 | ||
55 | #include <Geom2d_Curve.hxx> | |
56 | #include <Geom2d_Curve.hxx> | |
57 | ||
58 | #include <TColgp_SequenceOfPnt.hxx> | |
59 | ||
60 | #include <TColStd_Array1OfReal.hxx> | |
61 | #include <IntRes2d_IntersectionPoint.hxx> | |
62 | ||
63 | #include <BRepTools_WireExplorer.hxx> | |
64 | ||
65 | #include <BRep_Tool.hxx> | |
66 | #include <BRep_Builder.hxx> | |
67 | ||
68 | #include <TopExp_Explorer.hxx> | |
69 | #include <TopExp.hxx> | |
70 | ||
71 | #include <TopTools_MapOfShape.hxx> | |
72 | #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx> | |
73 | #include <TopTools_ListOfShape.hxx> | |
74 | #include <TopTools_ListIteratorOfListOfShape.hxx> | |
75 | #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx> | |
76 | #include <TopTools_MapIteratorOfMapOfShape.hxx> | |
77 | #include <TopOpeBRepBuild_HBuilder.hxx> | |
78 | #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx> | |
79 | ||
80 | #include <TColgp_Array1OfPnt.hxx> | |
81 | ||
82 | #include <TColGeom_Array1OfCurve.hxx> | |
83 | ||
84 | #include <TopoDS.hxx> | |
85 | #include <TopoDS_Shape.hxx> | |
86 | #include <TopoDS_Face.hxx> | |
87 | ||
88 | #include <BRepLib_MakeVertex.hxx> | |
89 | #include <BRepLib_MakeEdge.hxx> | |
90 | #include <BRepLib_MakeFace.hxx> | |
91 | ||
92 | #include <BRepTools.hxx> | |
93 | ||
94 | #include <BRepBuilderAPI.hxx> | |
95 | #include <BRepPrimAPI_MakeBox.hxx> | |
96 | #include <BRepBuilderAPI_MakeFace.hxx> | |
97 | ||
98 | //modified by NIZNHY-PKV Fri Mar 22 16:51:33 2002 f | |
99 | //#include <BRepAlgo_Section.hxx> | |
100 | //#include <BRepAlgo_Common.hxx> | |
101 | #include <BRepAlgoAPI_Section.hxx> | |
102 | #include <BRepAlgoAPI_Common.hxx> | |
103 | //modified by NIZNHY-PKV Fri Mar 22 16:51:35 2002 t | |
104 | ||
105 | #include <BRepExtrema_ExtPC.hxx> | |
106 | #include <BRepExtrema_ExtPF.hxx> | |
107 | #include <BRepExtrema_ExtCF.hxx> | |
108 | ||
109 | #include <BRepTools_Modifier.hxx> | |
110 | #include <BRepTools_TrsfModification.hxx> | |
111 | ||
112 | #include <Standard_ConstructionError.hxx> | |
113 | ||
114 | #include <Precision.hxx> | |
115 | ||
116 | #include <GeomLProp_CLProps.hxx> | |
117 | ||
118 | #include <BRepBuilderAPI_Transform.hxx> | |
119 | #include <BRepLib_MakeWire.hxx> | |
120 | //#include <DbgTools.hxx> | |
121 | ||
122 | #ifdef DEB | |
123 | Standard_IMPORT Standard_Boolean BRepFeat_GettraceFEAT(); | |
124 | Standard_IMPORT Standard_Boolean BRepFeat_GettraceFEATRIB(); | |
125 | #endif | |
126 | ||
127 | static void MajMap(const TopoDS_Shape&, // base | |
128 | const LocOpe_LinearForm&, | |
129 | TopTools_DataMapOfShapeListOfShape&, // myMap | |
130 | TopoDS_Shape&, // myFShape | |
131 | TopoDS_Shape&); // myLShape | |
132 | ||
133 | static void SetGluedFaces(const TopTools_DataMapOfShapeListOfShape& theSlmap, | |
134 | LocOpe_LinearForm&, | |
135 | TopTools_DataMapOfShapeShape&); | |
136 | ||
137 | //======================================================================= | |
138 | //function : Init | |
139 | //purpose : | |
140 | //======================================================================= | |
141 | ||
142 | void BRepFeat_MakeLinearForm::Init(const TopoDS_Shape& Sbase, | |
143 | const TopoDS_Wire& W, | |
144 | const Handle(Geom_Plane)& Plane, | |
145 | const gp_Vec& Direc, | |
146 | const gp_Vec& Direc1, | |
147 | const Standard_Integer Mode, | |
148 | const Standard_Boolean Modify) | |
149 | { | |
150 | #ifdef DEB | |
151 | Standard_Boolean trc = BRepFeat_GettraceFEAT(); | |
152 | if (trc) cout << "BRepFeat_MakeLinearForm::Init" << endl; | |
153 | #endif | |
154 | Standard_Boolean RevolRib = Standard_False; | |
155 | Done(); | |
156 | myGenerated.Clear(); | |
157 | ||
0d969553 Y |
158 | // modify = 0 if there is no intention to make sliding |
159 | // = 1 if one tries to make sliding | |
7fd59977 | 160 | Standard_Boolean Sliding = Modify; |
161 | myLFMap.Clear(); | |
162 | ||
163 | myShape.Nullify(); | |
164 | myMap.Clear(); | |
165 | myFShape.Nullify(); | |
166 | myLShape.Nullify(); | |
167 | mySbase = Sbase; | |
168 | mySkface.Nullify(); | |
169 | myPbase.Nullify(); | |
170 | ||
171 | myGShape.Nullify(); | |
172 | mySUntil.Nullify(); | |
173 | myListOfEdges.Clear(); | |
174 | mySlface.Clear(); | |
175 | ||
176 | TopoDS_Shape aLocalShape = W.Oriented(TopAbs_FORWARD); | |
177 | myWire = TopoDS::Wire(aLocalShape); | |
178 | // myWire = TopoDS::Wire(W.Oriented(TopAbs_FORWARD)); | |
179 | myDir = Direc; | |
180 | myDir1 = Direc1; | |
181 | myPln = Plane; | |
182 | ||
183 | if(Mode == 0) | |
184 | myFuse = Standard_False; | |
185 | else // if(Mode == 1) | |
186 | myFuse = Standard_True; | |
187 | #ifdef DEB | |
188 | if (trc) { | |
189 | if (myFuse) cout << " Fuse" << endl; | |
190 | if (!myFuse) cout << " Cut" << endl; | |
191 | } | |
192 | #endif | |
193 | ||
194 | ||
0d969553 | 195 | // ---Determine Tolerance : max tolerance on parameters |
7fd59977 | 196 | myTol = Precision::Confusion(); |
197 | ||
198 | TopExp_Explorer exx; | |
199 | exx.Init(myWire, TopAbs_VERTEX); | |
200 | for(; exx.More(); exx.Next()) { | |
201 | const Standard_Real& tol = BRep_Tool:: | |
202 | Tolerance(TopoDS::Vertex(exx.Current())); | |
203 | if(tol > myTol) myTol = tol; | |
204 | } | |
205 | ||
206 | exx.Init(Sbase, TopAbs_VERTEX); | |
207 | for(; exx.More(); exx.Next()) { | |
208 | const Standard_Real& tol = BRep_Tool:: | |
209 | Tolerance(TopoDS::Vertex(exx.Current())); | |
210 | if(tol > myTol) myTol = tol; | |
211 | } | |
212 | ||
0d969553 Y |
213 | // ---Control of directions |
214 | // the wire should be in the rib | |
7fd59977 | 215 | gp_Vec nulldir(0, 0, 0); |
216 | if(!myDir1.IsEqual(nulldir, myTol, myTol)) { | |
217 | Standard_Real ang = myDir1.Angle(myDir); | |
c6541a0c | 218 | if(ang != M_PI) { |
7fd59977 | 219 | #ifdef DEB |
220 | if (trc) cout << " Directions must be opposite" << endl; | |
221 | #endif | |
222 | myStatusError = BRepFeat_BadDirect; | |
223 | NotDone(); | |
224 | return; | |
225 | } | |
226 | } | |
227 | else { | |
228 | ||
229 | // Rib is centre in the middle of translation | |
230 | #ifdef DEB | |
231 | if (trc) cout << " Rib is centre" << endl; | |
232 | #endif | |
233 | const gp_Vec& DirTranslation = (Direc + Direc1) * 0.5; | |
234 | gp_Trsf T; | |
235 | T.SetTranslation(DirTranslation); | |
236 | BRepBuilderAPI_Transform trf(T); | |
237 | trf.Perform(myWire); | |
238 | myWire = TopoDS::Wire(trf.Shape()); | |
239 | myDir = Direc - DirTranslation; | |
240 | myDir1 = Direc1 - DirTranslation; | |
241 | myPln->Transform(T); | |
242 | } | |
243 | ||
0d969553 | 244 | // ---Calculate bounding box |
7fd59977 | 245 | BRep_Builder BB; |
246 | ||
247 | TopTools_ListOfShape theList; | |
248 | ||
249 | TopoDS_Shape U; | |
250 | U.Nullify(); | |
251 | gp_Pnt FirstCorner, LastCorner; | |
252 | Standard_Real bnd = HeightMax(mySbase, U, FirstCorner, LastCorner); | |
253 | myBnd = bnd; | |
254 | ||
255 | BRepPrimAPI_MakeBox Bndbox(FirstCorner, LastCorner); | |
256 | TopoDS_Solid BndBox = Bndbox.Solid(); | |
257 | ||
258 | ||
0d969553 | 259 | // ---Construction of the face workplane (section bounding box) |
7fd59977 | 260 | BRepLib_MakeFace PlaneF(myPln->Pln(), -6.*myBnd, |
261 | 6.*myBnd, -6.*myBnd, 6.*myBnd); | |
262 | TopoDS_Face PlaneFace = TopoDS::Face(PlaneF.Shape()); | |
263 | ||
264 | //modified by NIZNHY-PKV Fri Mar 22 16:49:28 2002 f | |
265 | //BRepAlgo_Common PlaneS(BndBox, PlaneFace); | |
266 | BRepAlgoAPI_Common PlaneS(BndBox, PlaneFace); | |
267 | //modified by NIZNHY-PKV Fri Mar 22 16:49:39 2002 t | |
268 | TopExp_Explorer EXP; | |
269 | TopoDS_Shape PlaneSect = PlaneS.Shape(); | |
270 | EXP.Init(PlaneSect, TopAbs_WIRE); | |
271 | TopoDS_Wire www = TopoDS::Wire(EXP.Current()); | |
272 | BRepLib_MakeFace Bndface(myPln->Pln(), www, Standard_True); | |
273 | TopoDS_Face BndFace = TopoDS::Face(Bndface.Shape()); | |
274 | ||
275 | ||
0d969553 | 276 | // ---Find support faces of the rib |
7fd59977 | 277 | TopoDS_Edge FirstEdge, LastEdge; |
278 | TopoDS_Face FirstFace, LastFace; | |
279 | TopoDS_Vertex FirstVertex, LastVertex; | |
280 | ||
281 | Standard_Boolean OnFirstFace = Standard_False; | |
282 | Standard_Boolean OnLastFace = Standard_False; | |
283 | Standard_Boolean PtOnFirstEdge = Standard_False; | |
284 | Standard_Boolean PtOnLastEdge = Standard_False; | |
285 | TopoDS_Edge OnFirstEdge, OnLastEdge; | |
286 | OnFirstEdge.Nullify(); | |
287 | OnLastEdge.Nullify(); | |
288 | ||
289 | Standard_Boolean Data = ExtremeFaces(RevolRib, myBnd, myPln, FirstEdge, LastEdge, | |
290 | FirstFace, LastFace, FirstVertex, | |
291 | LastVertex, OnFirstFace, OnLastFace, | |
292 | PtOnFirstEdge, PtOnLastEdge, | |
293 | OnFirstEdge, OnLastEdge); | |
294 | ||
295 | if(!Data) { | |
296 | #ifdef DEB | |
297 | if (trc) cout << " No Extreme faces" << endl; | |
298 | #endif | |
299 | myStatusError = BRepFeat_NoExtFace; | |
300 | NotDone(); | |
301 | return; | |
302 | } | |
303 | ||
304 | ||
0d969553 | 305 | // ---Proofing Point for the side of the wire to be filled - side material |
7fd59977 | 306 | gp_Pnt CheckPnt = CheckPoint(FirstEdge, bnd/10., myPln); |
307 | ||
308 | // Standard_Real f, l; | |
309 | ||
0d969553 Y |
310 | // ---Control sliding valuable |
311 | // Many cases when the sliding is abandoned | |
312 | Standard_Integer Concavite = 3; // a priori the profile is not concave | |
7fd59977 | 313 | |
314 | myFirstPnt = BRep_Tool::Pnt(FirstVertex); | |
315 | myLastPnt = BRep_Tool::Pnt(LastVertex); | |
316 | ||
0d969553 | 317 | // SliList : list of faces concerned by the rib |
7fd59977 | 318 | TopTools_ListOfShape SliList; |
319 | SliList.Append(FirstFace); | |
320 | ||
0d969553 | 321 | if(Sliding) { // sliding |
7fd59977 | 322 | #ifdef DEB |
323 | if (trc) cout << " Sliding" << endl; | |
324 | #endif | |
325 | Standard_Boolean Sliding = Standard_False; | |
326 | Handle(Geom_Surface) s = BRep_Tool::Surface(FirstFace); | |
327 | if (s->DynamicType() == | |
328 | STANDARD_TYPE(Geom_RectangularTrimmedSurface)) { | |
329 | s = Handle(Geom_RectangularTrimmedSurface):: | |
330 | DownCast(s)->BasisSurface(); | |
331 | } | |
332 | if(s->DynamicType() == STANDARD_TYPE(Geom_Plane) || | |
333 | s->DynamicType() == STANDARD_TYPE(Geom_CylindricalSurface)) { | |
0d969553 | 334 | // if plane or cylinder : sliding is possible |
7fd59977 | 335 | Sliding = Standard_True; |
336 | } | |
337 | } | |
338 | ||
0d969553 Y |
339 | // Control only start and end points |
340 | // -> no control at the middle - improve | |
341 | // Controle between Surface and segment between 2 limit points | |
342 | // is too expensive - improve | |
7fd59977 | 343 | if(Sliding) { |
344 | gp_Pnt p1(myFirstPnt.X()+myDir.X(),myFirstPnt.Y()+myDir.Y(), | |
345 | myFirstPnt.Z()+myDir.Z()); | |
346 | BRepLib_MakeEdge ee1(myFirstPnt, p1); | |
347 | BRepExtrema_ExtCF ext1(ee1, FirstFace); | |
348 | if(ext1.NbExt() == 1 && ext1.SquareDistance(1)<=BRep_Tool::Tolerance(FirstFace) * BRep_Tool::Tolerance(FirstFace)) { | |
349 | gp_Pnt p2(myLastPnt.X()+myDir.X(),myLastPnt.Y()+myDir.Y(), | |
350 | myLastPnt.Z()+myDir.Z()); | |
351 | BRepLib_MakeEdge ee2(myLastPnt, p2); | |
0d969553 | 352 | BRepExtrema_ExtCF ext2(ee2, LastFace); // ExtCF : curves and surfaces |
7fd59977 | 353 | if(ext2.NbExt() == 1 && ext2.SquareDistance(1)<=BRep_Tool::Tolerance(LastFace) * BRep_Tool::Tolerance(LastFace)) { |
354 | Sliding = Standard_True; | |
355 | } | |
356 | else { | |
357 | Sliding = Standard_False; | |
358 | } | |
359 | } | |
360 | else { | |
361 | Sliding = Standard_False; | |
362 | } | |
363 | } | |
364 | ||
365 | if(!myDir1.IsEqual(nulldir, Precision::Confusion(), Precision::Confusion())) { | |
366 | if(Sliding) { | |
367 | gp_Pnt p1(myFirstPnt.X()+myDir1.X(),myFirstPnt.Y()+myDir1.Y(), | |
368 | myFirstPnt.Z()+myDir1.Z()); | |
369 | BRepLib_MakeEdge ee1(myFirstPnt, p1); | |
370 | BRepExtrema_ExtCF ext1(ee1, FirstFace); | |
371 | if(ext1.NbExt() == 1 && ext1.SquareDistance(1)<=BRep_Tool::Tolerance(FirstFace) * BRep_Tool::Tolerance(FirstFace)) { | |
372 | gp_Pnt p2(myLastPnt.X()+myDir1.X(),myLastPnt.Y()+myDir1.Y(), | |
373 | myLastPnt.Z()+myDir1.Z()); | |
374 | BRepLib_MakeEdge ee2(myLastPnt, p2); | |
375 | BRepExtrema_ExtCF ext2(ee2, LastFace); | |
376 | if(ext2.NbExt() == 1 && ext2.SquareDistance(1)<=BRep_Tool::Tolerance(LastFace) * BRep_Tool::Tolerance(LastFace)) { | |
377 | Sliding = Standard_True; | |
378 | } | |
379 | else { | |
380 | Sliding = Standard_False; | |
381 | } | |
382 | } | |
383 | else { | |
384 | Sliding = Standard_False; | |
385 | } | |
386 | } | |
387 | } | |
388 | ||
389 | ||
0d969553 Y |
390 | // Construct a great profile that goes till the bounding box |
391 | // -> by tangency with the first and the last edge of the Wire | |
392 | // -> by normals to the support faces : statistically better | |
393 | // Intersect everything to find the final profile | |
7fd59977 | 394 | |
395 | ||
0d969553 | 396 | // ---case of sliding : construction of the profile face |
7fd59977 | 397 | if(Sliding) { |
398 | #ifdef DEB | |
399 | if (trc) cout << " still Sliding" << endl; | |
400 | #endif | |
401 | TopoDS_Face Prof; | |
402 | Standard_Boolean ProfileOK; | |
403 | ProfileOK = SlidingProfile(Prof,RevolRib,myTol,Concavite,myPln,BndFace,CheckPnt, | |
404 | FirstFace,LastFace,FirstVertex,LastVertex, | |
405 | FirstEdge,LastEdge); | |
406 | ||
407 | if (!ProfileOK) { | |
408 | #ifdef DEB | |
409 | cout << "Not computable" << endl; | |
410 | if (trc) cout << "Face profile not computable" << endl; | |
411 | #endif | |
412 | myStatusError = BRepFeat_NoFaceProf; | |
413 | NotDone(); | |
414 | return; | |
415 | } | |
416 | ||
417 | ||
0d969553 Y |
418 | // ---Propagation on faces of the initial shape |
419 | // to find the faces concerned by the rib | |
7fd59977 | 420 | Standard_Boolean falseside = Standard_True; |
421 | Sliding = Propagate(SliList, Prof, myFirstPnt, myLastPnt, falseside); | |
0d969553 | 422 | // Control if there is everything required to have the material at the proper side |
7fd59977 | 423 | if(falseside == Standard_False) { |
424 | #ifdef DEB | |
425 | cout << "Verify plane and wire orientation" << endl; | |
426 | #endif | |
427 | myStatusError = BRepFeat_FalseSide; | |
428 | NotDone(); | |
429 | return; | |
430 | } | |
431 | } | |
432 | ||
433 | ||
0d969553 | 434 | // ---Generation of the base of the rib profile |
7fd59977 | 435 | |
436 | TopoDS_Wire w; | |
437 | BB.MakeWire(w); | |
438 | TopoDS_Edge thePreviousEdge; | |
439 | TopoDS_Vertex theFV; | |
440 | thePreviousEdge.Nullify(); | |
441 | ||
0d969553 | 442 | // calculate the number of edges to fill the map |
7fd59977 | 443 | Standard_Integer counter = 1; |
444 | ||
0d969553 | 445 | // ---case of sliding |
7fd59977 | 446 | if(Sliding && !myListOfEdges.IsEmpty()) { |
447 | BRepTools_WireExplorer EX1(myWire); | |
448 | for(; EX1.More(); EX1.Next()) { | |
449 | const TopoDS_Edge& E = EX1.Current(); | |
450 | if(!myLFMap.IsBound(E)) { | |
451 | TopTools_ListOfShape theTmpList; | |
452 | myLFMap.Bind(E, theTmpList ); | |
453 | } | |
454 | if(E.IsSame(FirstEdge)) { | |
455 | Standard_Real f, l; | |
456 | Handle(Geom_Curve) cc = BRep_Tool::Curve(E, f, l); | |
457 | cc = new Geom_TrimmedCurve(cc, f, l); | |
458 | gp_Pnt pt; | |
459 | if(!FirstEdge.IsSame(LastEdge)) { | |
460 | pt = BRep_Tool::Pnt(TopExp::LastVertex(E,Standard_True)); | |
461 | } | |
462 | else { | |
463 | pt = myLastPnt; | |
464 | Standard_Real fpar = IntPar(cc, myFirstPnt); | |
465 | Standard_Real lpar = IntPar(cc, pt); | |
466 | Handle(Geom_Curve) ccc; | |
467 | if(fpar > lpar) { | |
468 | ccc = Handle(Geom_Curve)::DownCast(cc->Reversed()); | |
469 | cc = ccc; | |
470 | } | |
471 | } | |
472 | TopoDS_Edge ee1; | |
473 | if(thePreviousEdge.IsNull()) { | |
474 | BRepLib_MakeVertex v1(myFirstPnt); | |
475 | BRepLib_MakeVertex v2(pt); | |
476 | BRepLib_MakeEdge e(cc, v1, v2); | |
477 | ee1 = TopoDS::Edge(e.Shape()); | |
478 | } | |
479 | else { | |
480 | const TopoDS_Vertex& v1 = TopExp::LastVertex(thePreviousEdge,Standard_True); | |
481 | BRepLib_MakeVertex v2(pt); | |
482 | ||
483 | BRepLib_MakeEdge e(cc, v1, v2); | |
484 | ee1 = TopoDS::Edge(e.Shape()); | |
485 | } | |
486 | TopoDS_Shape aLocalShape = ee1.Oriented(E.Orientation()); | |
487 | ee1 = TopoDS::Edge(aLocalShape); | |
488 | // ee1 = TopoDS::Edge(ee1.Oriented(E.Orientation())); | |
489 | if(counter == 1) theFV = TopExp::FirstVertex(ee1,Standard_True); | |
490 | myLFMap(E).Append(ee1); | |
491 | BB.Add(w, ee1); | |
492 | thePreviousEdge = ee1; | |
493 | counter++; | |
494 | EX1.Next(); | |
495 | break; | |
496 | } | |
497 | } | |
498 | ||
0d969553 | 499 | // Case of several edges |
7fd59977 | 500 | if(!FirstEdge.IsSame(LastEdge)) { |
501 | for(; EX1.More(); EX1.Next()) { | |
502 | const TopoDS_Edge& E = EX1.Current(); | |
503 | if(!myLFMap.IsBound(E)) { | |
504 | TopTools_ListOfShape thelist1; | |
505 | myLFMap.Bind(E, thelist1); | |
506 | } | |
507 | theList.Append(E); | |
508 | Standard_Real f, l; | |
509 | if(!E.IsSame(LastEdge)) { | |
510 | Handle(Geom_Curve) ccc = BRep_Tool::Curve(E, f, l); | |
511 | TopoDS_Vertex v1, v2; | |
512 | if(!thePreviousEdge.IsNull()) { | |
513 | v1 = TopExp::LastVertex(thePreviousEdge,Standard_True); | |
514 | v2 = TopExp::LastVertex(E,Standard_True); | |
515 | } | |
516 | else { | |
517 | // v1 = TopExp::LastVertex(E,Standard_True); | |
518 | v1 = TopExp::FirstVertex(E,Standard_True); | |
519 | v2 = TopExp::LastVertex(E,Standard_True); | |
520 | } | |
521 | BRepLib_MakeEdge E1(ccc, v1, v2); | |
522 | TopoDS_Edge E11 = TopoDS::Edge(E1.Shape()); | |
523 | TopoDS_Shape aLocalShape = E11.Oriented(E.Orientation()); | |
524 | E11 = TopoDS::Edge(aLocalShape); | |
525 | // E11 = TopoDS::Edge(E11.Oriented(E.Orientation())); | |
526 | thePreviousEdge = E11; | |
527 | myLFMap(E).Append(E11); | |
528 | BB.Add(w, E11); | |
529 | if(counter == 1) theFV = TopExp::FirstVertex(E11,Standard_True); | |
530 | counter++; | |
531 | } | |
532 | else { | |
533 | Standard_Real f, l; | |
534 | Handle(Geom_Curve) cc = BRep_Tool::Curve(E, f, l); | |
535 | gp_Pnt pf = BRep_Tool::Pnt(TopExp::FirstVertex(E,Standard_True)); | |
536 | gp_Pnt pl = myLastPnt; | |
537 | TopoDS_Edge ee; | |
538 | if(thePreviousEdge.IsNull()) { | |
539 | BRepLib_MakeEdge e(cc, pf , pl); | |
540 | ee = TopoDS::Edge(e.Shape()); | |
541 | } | |
542 | else { | |
543 | const TopoDS_Vertex& v1 = TopExp::LastVertex(thePreviousEdge,Standard_True); | |
544 | BRepLib_MakeVertex v2(pl); | |
545 | BRepLib_MakeEdge e(cc, v1, v2); | |
546 | ee = TopoDS::Edge(e.Shape()); | |
547 | } | |
548 | TopoDS_Shape aLocalShape = ee.Oriented(E.Orientation()); | |
549 | ee = TopoDS::Edge(aLocalShape); | |
550 | // ee = TopoDS::Edge(ee.Oriented(E.Orientation())); | |
551 | BB.Add(w, ee); | |
552 | myLFMap(E).Append(ee); | |
553 | if(counter == 1) theFV = TopExp::FirstVertex(ee,Standard_True); | |
554 | thePreviousEdge = ee; | |
555 | counter++; | |
556 | break; | |
557 | } | |
558 | } | |
559 | } | |
560 | ||
561 | TopTools_ListIteratorOfListOfShape it(myListOfEdges); | |
562 | Standard_Boolean FirstOK = Standard_False; | |
563 | Standard_Boolean LastOK = Standard_False; | |
564 | ||
565 | gp_Pnt theLastPnt = myLastPnt; | |
566 | Standard_Integer sens = 0; | |
567 | TopoDS_Edge theEdge, theLEdge, theFEdge; | |
568 | Standard_Integer counter1 = counter; | |
569 | TopTools_ListOfShape NewListOfEdges; | |
570 | NewListOfEdges.Clear(); | |
571 | while (!FirstOK) { | |
572 | const TopoDS_Edge& edg = TopoDS::Edge(it.Value()); | |
573 | gp_Pnt fp, lp; | |
574 | Standard_Real f, l; | |
575 | Handle(Geom_Curve) ccc = BRep_Tool::Curve(edg, f, l); | |
576 | Handle(Geom_TrimmedCurve) cc = new Geom_TrimmedCurve(ccc, f, l); | |
577 | if ( edg.Orientation() == TopAbs_REVERSED) cc->Reverse(); | |
578 | ||
579 | fp = cc->Value(cc->FirstParameter()); | |
580 | lp = cc->Value(cc->LastParameter()); | |
581 | Standard_Real dist = fp.Distance(theLastPnt); | |
582 | if(dist <= myTol) { | |
583 | sens = 1; | |
584 | LastOK = Standard_True; | |
585 | } | |
586 | else { | |
587 | dist = lp.Distance(theLastPnt); | |
588 | if(dist <= myTol) { | |
589 | sens = 2; | |
590 | LastOK = Standard_True; | |
591 | cc->Reverse(); | |
592 | } | |
593 | } | |
594 | Standard_Integer FirstFlag = 0; | |
595 | if(sens==1 && lp.Distance(myFirstPnt) <= myTol) { | |
596 | FirstOK = Standard_True; | |
597 | FirstFlag = 1; | |
598 | } | |
599 | else if(sens==2 && fp.Distance(myFirstPnt) <= myTol) { | |
600 | FirstOK = Standard_True; | |
601 | FirstFlag = 2; | |
602 | } | |
603 | ||
604 | if (LastOK) { | |
605 | TopoDS_Edge eeee; | |
606 | Standard_Real fpar = cc->FirstParameter(); | |
607 | Standard_Real lpar = cc->LastParameter(); | |
608 | if(!FirstOK) { | |
609 | if(thePreviousEdge.IsNull()) { | |
610 | BRepLib_MakeEdge e(cc, fpar, lpar); | |
611 | eeee = TopoDS::Edge(e.Shape()); | |
612 | } | |
613 | else { | |
614 | const TopoDS_Vertex& v1 = TopExp::LastVertex(thePreviousEdge,Standard_True); | |
615 | BB.UpdateVertex(v1, dist); | |
616 | BRepLib_MakeVertex v2(cc->Value(lpar)); | |
617 | TopoDS_Vertex nv=v2.Vertex(); | |
618 | BRepLib_MakeEdge e(cc, v1, nv); | |
619 | eeee = TopoDS::Edge(e.Shape()); | |
620 | } | |
621 | } | |
622 | else { | |
623 | if(thePreviousEdge.IsNull()) { | |
624 | BRepLib_MakeVertex v1(cc->Value(fpar)); | |
625 | BRepLib_MakeEdge e(cc, v1, theFV); | |
626 | eeee = TopoDS::Edge(e.Shape()); | |
627 | } | |
628 | else { | |
629 | const TopoDS_Vertex& v1 = TopExp::LastVertex(thePreviousEdge,Standard_True); | |
630 | BRepLib_MakeEdge e(cc, v1, theFV); | |
631 | eeee = TopoDS::Edge(e.Shape()); | |
632 | } | |
633 | } | |
634 | ||
635 | thePreviousEdge = eeee; | |
636 | BB.Add(w, eeee); | |
637 | if(counter == 1) theFV = TopExp::FirstVertex(eeee,Standard_True); | |
638 | counter1++; | |
639 | NewListOfEdges.Append(edg); | |
640 | theEdge = eeee; | |
7fd59977 | 641 | |
642 | if(dist <= myTol) | |
643 | theFEdge = edg; | |
644 | theLastPnt = BRep_Tool::Pnt(TopExp::LastVertex(theEdge,Standard_True)); | |
645 | } | |
646 | ||
647 | if(FirstFlag == 1) { | |
648 | theLEdge = edg; | |
649 | } | |
650 | else if(FirstFlag == 2) { | |
651 | theLEdge = theEdge; | |
652 | } | |
653 | ||
654 | if(LastOK) { | |
655 | myListOfEdges.Remove(it); | |
656 | it.Initialize(myListOfEdges); | |
657 | LastOK = Standard_False; | |
658 | } | |
659 | else if(it.More()) it.Next(); | |
660 | else { | |
661 | Sliding = Standard_False; | |
662 | break; | |
663 | } | |
664 | sens = 0; | |
665 | } | |
666 | ||
667 | ||
668 | TopTools_DataMapOfShapeListOfShape SlidMap; | |
669 | SlidMap.Clear(); | |
670 | ||
671 | if(Sliding && counter1 > counter) { | |
672 | TopTools_ListIteratorOfListOfShape it; | |
673 | TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm; | |
674 | TopExp_Explorer EX2(w, TopAbs_EDGE); | |
675 | Standard_Integer ii = 0; | |
676 | for(; EX2.More(); EX2.Next()) { | |
677 | const TopoDS_Edge& E = TopoDS::Edge(EX2.Current()); | |
678 | ii++; | |
679 | if(ii >= counter && ii <= counter1) { | |
680 | it.Initialize(NewListOfEdges); | |
681 | Standard_Integer jj = 0; | |
682 | for(; it.More(); it.Next()) { | |
683 | const TopoDS_Edge& e2 = TopoDS::Edge(it.Value()); | |
684 | jj++; | |
685 | if(jj== (ii - counter +1)) { | |
686 | itm.Initialize(mySlface); | |
687 | for(; itm.More(); itm.Next()) { | |
688 | const TopoDS_Face& fac = TopoDS::Face(itm.Key()); | |
689 | const TopTools_ListOfShape& ledg = itm.Value(); | |
690 | TopTools_ListIteratorOfListOfShape itedg(ledg); | |
691 | //Standard_Integer iiii = 0; | |
692 | for(; itedg.More(); itedg.Next()) { | |
693 | const TopoDS_Edge& e1 = TopoDS::Edge(itedg.Value()); | |
694 | if(e1.IsSame(e2)){ | |
695 | if(!SlidMap.IsBound(fac)) { | |
696 | TopTools_ListOfShape thelist2; | |
697 | SlidMap.Bind(fac, thelist2); | |
698 | } | |
699 | SlidMap(fac).Append(E); | |
700 | } | |
701 | } | |
702 | } | |
703 | } | |
704 | } | |
705 | } | |
706 | } | |
707 | } | |
708 | ||
709 | mySlface.Clear(); | |
710 | mySlface = SlidMap; | |
711 | } | |
712 | ||
0d969553 | 713 | // ---Arguments of LocOpe_LinearForm : arguments of the prism sliding |
7fd59977 | 714 | if(Sliding) { |
715 | TopoDS_Face F; | |
716 | BB.MakeFace(F, myPln, myTol); | |
717 | BB.Add(F, w); | |
718 | // BRepLib_MakeFace F(myPln->Pln(),w, Standard_True); | |
719 | mySkface = F; | |
720 | myPbase = mySkface; | |
721 | mySUntil.Nullify(); | |
722 | } | |
723 | ||
724 | ||
0d969553 | 725 | // ---Case without sliding : construction of the profile face |
7fd59977 | 726 | if(!Sliding) { |
727 | #ifdef DEB | |
728 | if (trc) { | |
729 | if (Modify) cout << " Sliding failure" << endl; | |
730 | cout << " no Sliding" << endl; | |
731 | } | |
732 | #endif | |
733 | TopoDS_Face Prof; | |
734 | Standard_Boolean ProfileOK; | |
735 | ProfileOK = NoSlidingProfile(Prof,RevolRib,myTol,Concavite,myPln, | |
736 | bnd,BndFace,CheckPnt, | |
737 | FirstFace,LastFace,FirstVertex,LastVertex, | |
738 | FirstEdge,LastEdge,OnFirstFace,OnLastFace); | |
739 | ||
740 | if (!ProfileOK) { | |
741 | #ifdef DEB | |
742 | cout << "Not computable" << endl; | |
743 | if (trc) cout << " Face profile not computable" << endl; | |
744 | #endif | |
745 | myStatusError = BRepFeat_NoFaceProf; | |
746 | NotDone(); | |
747 | return; | |
748 | } | |
749 | ||
750 | ||
0d969553 Y |
751 | // ---Propagation on faces of the initial shape |
752 | // to find the faces concerned by the rib | |
7fd59977 | 753 | Standard_Boolean falseside = Standard_True; |
754 | Propagate(SliList, Prof, myFirstPnt, myLastPnt, falseside); | |
0d969553 | 755 | // Control if there is everything required to have the material at the proper side |
7fd59977 | 756 | if(falseside == Standard_False) { |
757 | #ifdef DEB | |
758 | cout << "Verify plane and wire orientation" << endl; | |
759 | #endif | |
760 | myStatusError = BRepFeat_FalseSide; | |
761 | NotDone(); | |
762 | return; | |
763 | } | |
764 | ||
765 | mySlface.Clear(); | |
766 | ||
767 | TopTools_ListIteratorOfListOfShape it; | |
768 | it.Initialize(SliList); | |
769 | ||
770 | TopoDS_Shape comp; | |
771 | ||
772 | BRep_Builder BB; | |
773 | BB.MakeShell(TopoDS::Shell(comp)); | |
774 | ||
775 | for(; it.More(); it.Next()) { | |
776 | BB.Add(comp, it.Value()); | |
777 | } | |
778 | ||
779 | mySUntil = comp; | |
780 | ||
781 | mySkface = Prof; | |
782 | myPbase = Prof; | |
783 | } | |
784 | ||
785 | mySliding = Sliding; | |
786 | ||
787 | TopExp_Explorer exp; | |
788 | for (exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) { | |
789 | TopTools_ListOfShape thelist3; | |
790 | myMap.Bind(exp.Current(), thelist3); | |
791 | myMap(exp.Current()).Append(exp.Current()); | |
792 | } | |
793 | } | |
794 | ||
795 | ||
796 | //======================================================================= | |
797 | //function : Add | |
798 | //purpose : add des element de collage | |
799 | //======================================================================= | |
800 | ||
801 | void BRepFeat_MakeLinearForm::Add(const TopoDS_Edge& E, | |
802 | const TopoDS_Face& F) | |
803 | { | |
804 | #ifdef DEB | |
805 | Standard_Boolean trc = BRepFeat_GettraceFEAT(); | |
806 | if (trc) cout << "BRepFeat_MakeLinearForm::Add" << endl; | |
807 | #endif | |
808 | if(mySlface.IsEmpty()) { | |
809 | TopExp_Explorer exp; | |
810 | for (exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) { | |
811 | if (exp.Current().IsSame(F)) { | |
812 | break; | |
813 | } | |
814 | } | |
815 | if (!exp.More()) { | |
816 | Standard_ConstructionError::Raise(); | |
817 | } | |
818 | ||
819 | if (!mySlface.IsBound(F)) { | |
820 | TopTools_ListOfShape thelist; | |
821 | mySlface.Bind(F, thelist); | |
822 | } | |
823 | TopTools_ListIteratorOfListOfShape itl(mySlface(F)); | |
824 | for (; itl.More();itl.Next()) { | |
825 | if (itl.Value().IsSame(E)) { | |
826 | break; | |
827 | } | |
828 | } | |
829 | if (!itl.More()) { | |
830 | mySlface(F).Append(E); | |
831 | } | |
832 | } | |
833 | } | |
834 | ||
835 | ||
836 | ||
837 | //======================================================================= | |
838 | //function : Perform | |
0d969553 | 839 | //purpose : construction of rib from a profile and the initial shape |
7fd59977 | 840 | //======================================================================= |
841 | ||
842 | void BRepFeat_MakeLinearForm::Perform() | |
843 | { | |
844 | #ifdef DEB | |
845 | Standard_Boolean trc = BRepFeat_GettraceFEAT(); | |
846 | if (trc) cout << "BRepFeat_MakeLinearForm::Perform()" << endl; | |
847 | #endif | |
848 | if(mySbase.IsNull() || mySkface.IsNull() || myPbase.IsNull()) { | |
849 | #ifdef DEB | |
850 | if (trc) cout << " Fields not initialized" << endl; | |
851 | #endif | |
852 | myStatusError = BRepFeat_NotInitialized; | |
853 | NotDone(); | |
854 | return; | |
855 | } | |
856 | ||
857 | gp_Vec nulldir(0, 0, 0); | |
858 | ||
859 | Standard_Real Length = myDir.Magnitude() + myDir1.Magnitude(); | |
860 | ||
861 | myGluedF.Clear(); | |
862 | ||
863 | if(!mySUntil.IsNull()) | |
864 | myPerfSelection = BRepFeat_SelectionU; | |
865 | else | |
866 | myPerfSelection = BRepFeat_NoSelection; | |
867 | ||
868 | gp_Dir dir(myDir); | |
869 | gp_Vec V = Length*dir; | |
870 | ||
871 | LocOpe_LinearForm theForm; | |
872 | ||
873 | if(myDir1.IsEqual(nulldir, Precision::Confusion(), Precision::Confusion())) | |
874 | theForm.Perform(myPbase, V, myFirstPnt, myLastPnt); | |
875 | else | |
876 | theForm.Perform(myPbase, V, myDir1, myFirstPnt, myLastPnt); | |
877 | ||
0d969553 | 878 | TopoDS_Shape VraiForm = theForm.Shape(); // primitive of the rib |
7fd59977 | 879 | |
880 | myFacesForDraft.Append(theForm.FirstShape()); | |
881 | myFacesForDraft.Append(theForm.LastShape()); | |
0d969553 | 882 | MajMap(myPbase,theForm,myMap,myFShape,myLShape); // management of descendants |
7fd59977 | 883 | |
884 | TopExp_Explorer exx(myPbase, TopAbs_EDGE); | |
885 | for(; exx.More(); exx.Next()) { | |
886 | const TopoDS_Edge& e = TopoDS::Edge(exx.Current()); | |
887 | if(!myMap.IsBound(e)) { | |
888 | #ifdef DEB | |
889 | if (trc) cout << " Sliding face not in Base shape" << endl; | |
890 | #endif | |
891 | myStatusError = BRepFeat_IncSlidFace; | |
892 | NotDone(); | |
893 | return; | |
894 | } | |
895 | } | |
896 | ||
897 | myGShape = VraiForm; | |
0d969553 | 898 | SetGluedFaces(mySlface, theForm, myGluedF); // management of sliding faces |
7fd59977 | 899 | |
900 | if(!myGluedF.IsEmpty() && !mySUntil.IsNull()) { | |
901 | #ifdef DEB | |
902 | cout << "The case is not computable" << endl; | |
903 | if (trc) cout << " Glued faces not empty and Until shape not null" << endl; | |
904 | #endif | |
905 | myStatusError = BRepFeat_InvShape; | |
906 | NotDone(); | |
907 | return; | |
908 | } | |
909 | ||
910 | LFPerform(); | |
911 | ||
912 | /* | |
913 | ||
914 | TopExp_Explorer expr(mySbase, TopAbs_FACE); | |
915 | char nom1[20], nom2[20]; | |
916 | Standard_Integer ii = 0; | |
917 | for(; expr.More(); expr.Next()) { | |
918 | ii++; | |
919 | sprintf(nom1, "faceinitial_%d", ii); | |
920 | DBRep::Set(nom1, expr.Current()); | |
921 | Standard_Integer jj = 0; | |
922 | const TopTools_ListOfShape& list = Modified(expr.Current()); | |
923 | TopTools_ListIteratorOfListOfShape ite(list); | |
924 | for(; ite.More(); ite.Next()) { | |
925 | jj++; | |
926 | sprintf(nom2, "facemodifie_%d_%d", ii, jj); | |
927 | DBRep::Set(nom2, ite.Value()); | |
928 | } | |
929 | } | |
930 | ||
931 | expr.Init(myWire, TopAbs_EDGE); | |
932 | ii=0; | |
933 | for(; expr.More(); expr.Next()) { | |
934 | ii++; | |
935 | sprintf(nom1, "edgeinitial_%d", ii); | |
936 | DBRep::Set(nom1, expr.Current()); | |
937 | Standard_Integer jj = 0; | |
938 | const TopTools_ListOfShape& genf = Generated(expr.Current()); | |
939 | TopTools_ListIteratorOfListOfShape ite(genf); | |
940 | for(; ite.More(); ite.Next()) { | |
941 | jj++; | |
942 | sprintf(nom2, "egdegeneree_%d_%d", ii, jj); | |
943 | DBRep::Set(nom2, ite.Value()); | |
944 | } | |
945 | } | |
946 | */ | |
947 | } | |
948 | ||
949 | //======================================================================= | |
950 | //function : Propagate | |
0d969553 Y |
951 | //purpose : propagation on faces of the initial shape, find |
952 | // faces concerned by the rib | |
7fd59977 | 953 | //======================================================================= |
954 | Standard_Boolean BRepFeat_MakeLinearForm::Propagate(TopTools_ListOfShape& SliList, | |
955 | const TopoDS_Face& fac, | |
956 | const gp_Pnt& Firstpnt, | |
957 | const gp_Pnt& Lastpnt, | |
958 | Standard_Boolean& falseside) | |
959 | { | |
960 | #ifdef DEB | |
961 | Standard_Boolean trc = BRepFeat_GettraceFEATRIB(); | |
962 | if (trc) cout << "BRepFeat_MakeLinearForm::Propagate" << endl; | |
963 | #endif | |
964 | gp_Pnt Firstpoint = Firstpnt; | |
965 | gp_Pnt Lastpoint = Lastpnt; | |
966 | ||
967 | Standard_Boolean result = Standard_True; | |
968 | TopoDS_Face CurrentFace, saveFace; | |
969 | CurrentFace = TopoDS::Face(SliList.First()); | |
970 | saveFace = CurrentFace; | |
971 | ||
972 | Standard_Boolean LastOK = Standard_False, FirstOK= Standard_False; | |
973 | Standard_Boolean v1OK = Standard_False, v2OK= Standard_False; | |
974 | TopoDS_Vertex v1, v2, v3, v4, ve1, ve2; | |
975 | ||
976 | //modified by NIZNHY-PKV Fri Mar 22 16:50:24 2002 f | |
977 | //BRepAlgo_Section sect (fac, CurrentFace, Standard_False); | |
978 | BRepAlgoAPI_Section sect (fac, CurrentFace, Standard_False); | |
979 | //modified by NIZNHY-PKV Fri Mar 22 16:50:32 2002 t | |
980 | ||
981 | sect.Approximation(Standard_True); | |
982 | sect.Build(); | |
983 | ||
984 | TopExp_Explorer Ex; | |
985 | TopoDS_Edge eb, ec; | |
986 | gp_Pnt p1, p2; | |
987 | #ifndef DEB | |
988 | Standard_Real t1 = 0., t2 = 0.; | |
989 | #else | |
990 | Standard_Real t1, t2; | |
991 | #endif | |
992 | Standard_Boolean c1f, c2f, c1l, c2l; | |
993 | ||
994 | for (Ex.Init(sect.Shape(), TopAbs_EDGE); Ex.More(); Ex.Next()) { | |
995 | ec = TopoDS::Edge(Ex.Current()); | |
996 | v1 = TopExp::FirstVertex(ec,Standard_True); | |
997 | v2 = TopExp::LastVertex(ec,Standard_True); | |
998 | p1 = BRep_Tool::Pnt(v1); | |
999 | p2 = BRep_Tool::Pnt(v2); | |
1000 | t1 = BRep_Tool::Tolerance(v1); | |
1001 | t2 = BRep_Tool::Tolerance(v2); | |
1002 | c1f = p1.Distance(Firstpoint)<=t1; | |
1003 | c2f = p2.Distance(Firstpoint)<=t2; | |
1004 | c1l = p1.Distance(Lastpoint)<=t1; | |
1005 | c2l = p2.Distance(Lastpoint)<=t2; | |
1006 | if (c1f || c2f || c1l|| c2l) { | |
1007 | eb = ec; | |
1008 | if (c1f || c1l) v1OK=Standard_True; | |
1009 | if (c2f || c2l) v2OK=Standard_True; | |
1010 | if (c1f || c2f) FirstOK=Standard_True; | |
1011 | if (c1l || c2l) LastOK=Standard_True; | |
1012 | break; | |
1013 | } | |
1014 | } | |
1015 | ||
1016 | if(eb.IsNull()) { | |
1017 | falseside = Standard_False; | |
1018 | return Standard_False; | |
1019 | } | |
1020 | TopTools_ListOfShape thelist; | |
1021 | mySlface.Bind(CurrentFace, thelist); | |
1022 | mySlface(CurrentFace).Append(eb); | |
1023 | ||
1024 | myListOfEdges.Clear(); | |
1025 | myListOfEdges.Append(eb); | |
1026 | ||
0d969553 | 1027 | // two points are on the same face. |
7fd59977 | 1028 | if(LastOK && FirstOK) { |
1029 | return result; | |
1030 | } | |
1031 | ||
1032 | TopTools_IndexedDataMapOfShapeListOfShape mapedges; | |
1033 | TopExp::MapShapesAndAncestors(mySbase, TopAbs_EDGE, TopAbs_FACE, mapedges); | |
1034 | TopExp_Explorer ex; | |
1035 | TopoDS_Edge FirstEdge; | |
1036 | BRep_Builder BB; | |
1037 | ||
1038 | TopoDS_Vertex Vprevious; | |
1039 | gp_Pnt ptprev; | |
1040 | Standard_Real tvp, dp; | |
1041 | ||
1042 | while (!(LastOK && FirstOK)) { | |
1043 | if (v1OK) { | |
1044 | Vprevious=v2; | |
1045 | ptprev=p2; | |
1046 | tvp=t2; | |
1047 | } | |
1048 | else { | |
1049 | Vprevious=v1; | |
1050 | ptprev=p1; | |
1051 | tvp=t1; | |
1052 | } | |
1053 | ||
0d969553 | 1054 | // find edge connected to v1 or v2: |
7fd59977 | 1055 | for (ex.Init(CurrentFace, TopAbs_EDGE); ex.More(); ex.Next()) { |
1056 | const TopoDS_Edge& rfe = TopoDS::Edge(ex.Current()); | |
1057 | ||
1058 | BRepExtrema_ExtPC projF(Vprevious, rfe); | |
1059 | ||
1060 | if(projF.IsDone() && projF.NbExt() >=1) { | |
1061 | Standard_Real dist2min = RealLast(); | |
1062 | Standard_Integer index = 0; | |
1063 | for (Standard_Integer sol =1 ; sol <= projF.NbExt(); sol++) { | |
1064 | if (projF.SquareDistance(sol) <= dist2min) { | |
1065 | index = sol; | |
1066 | dist2min = projF.SquareDistance(sol); | |
1067 | } | |
1068 | } | |
1069 | if (index != 0) { | |
1070 | if (dist2min <= BRep_Tool::Tolerance(rfe) * BRep_Tool::Tolerance(rfe)) { | |
1071 | FirstEdge = rfe; | |
0d969553 Y |
1072 | // If the edge is not perpendicular to the plane of the rib |
1073 | // it is required to set Sliding(result) to false. | |
7fd59977 | 1074 | if (result) { |
1075 | result=Standard_False; | |
1076 | ve1 = TopExp::FirstVertex(rfe,Standard_True); | |
1077 | ve2 = TopExp::LastVertex(rfe,Standard_True); | |
1078 | BRepExtrema_ExtPF perp(ve1, fac); | |
1079 | if (perp.IsDone()) { | |
1080 | gp_Pnt pe1=perp.Point(1); | |
1081 | perp.Perform(ve2, fac); | |
1082 | if (perp.IsDone()) { | |
1083 | gp_Pnt pe2=perp.Point(1); | |
1084 | if (pe1.Distance(pe2)<=BRep_Tool::Tolerance(rfe)) | |
1085 | result=Standard_True; | |
1086 | } | |
1087 | } | |
1088 | } | |
1089 | break; | |
1090 | } | |
1091 | } | |
1092 | } | |
1093 | } | |
1094 | ||
1095 | const TopTools_ListOfShape& L = mapedges.FindFromKey(FirstEdge); | |
1096 | TopTools_ListIteratorOfListOfShape It(L); | |
1097 | ||
1098 | for (; It.More(); It.Next()) { | |
1099 | const TopoDS_Face& FF = TopoDS::Face(It.Value()); | |
1100 | if (!FF.IsSame(CurrentFace)) { | |
1101 | CurrentFace = FF; | |
1102 | break; | |
1103 | } | |
1104 | } | |
1105 | ||
1106 | //modified by NIZNHY-PKV Fri Mar 22 16:50:53 2002 f | |
1107 | //BRepAlgo_Section sectf (fac, CurrentFace, Standard_False); | |
1108 | BRepAlgoAPI_Section sectf (fac, CurrentFace, Standard_False); | |
1109 | //modified by NIZNHY-PKV Fri Mar 22 16:51:03 2002 t | |
1110 | sectf.Approximation(Standard_True); | |
1111 | sectf.Build(); | |
1112 | ||
1113 | TopoDS_Edge edg1; | |
1114 | for (Ex.Init(sectf.Shape(), TopAbs_EDGE); Ex.More(); Ex.Next()) { | |
1115 | edg1 = TopoDS::Edge(Ex.Current()); | |
1116 | v1=TopExp::FirstVertex(edg1,Standard_True); | |
1117 | v2=TopExp::LastVertex(edg1,Standard_True); | |
1118 | t1 = BRep_Tool::Tolerance(v1); | |
1119 | t2 = BRep_Tool::Tolerance(v2); | |
1120 | p1 = BRep_Tool::Pnt(v1); | |
1121 | p2 = BRep_Tool::Pnt(v2); | |
1122 | v1OK = p1.Distance(ptprev)<=t1; | |
1123 | v2OK = p2.Distance(ptprev)<=t2; | |
1124 | if (v1OK || v2OK) break; | |
1125 | } | |
1126 | ||
1127 | if (v1OK) { | |
1128 | if (!FirstOK) { | |
1129 | dp = p2.Distance(Firstpoint); | |
1130 | if(dp <= 2*t2) { | |
1131 | FirstOK = Standard_True; | |
1132 | BB.UpdateVertex(v2, dp); | |
1133 | } | |
1134 | } | |
1135 | if (!LastOK) { | |
1136 | dp = p2.Distance(Lastpoint); | |
1137 | if(dp <= 2*t2) { | |
1138 | LastOK = Standard_True; | |
1139 | BB.UpdateVertex(v2, dp); | |
1140 | } | |
1141 | } | |
1142 | } | |
1143 | else if (v2OK) { | |
1144 | if (!FirstOK) { | |
1145 | dp = p1.Distance(Firstpoint); | |
1146 | if(dp <= 2*t1) { | |
1147 | FirstOK = Standard_True; | |
1148 | BB.UpdateVertex(v1, dp); | |
1149 | } | |
1150 | } | |
1151 | if (!LastOK) { | |
1152 | dp = p1.Distance(Lastpoint); | |
1153 | if(dp <= 2*t1) { | |
1154 | LastOK = Standard_True; | |
1155 | BB.UpdateVertex(v1, dp); | |
1156 | } | |
1157 | } | |
1158 | } | |
1159 | else { | |
0d969553 | 1160 | // end by chaining the section |
7fd59977 | 1161 | return Standard_False; |
1162 | } | |
7fd59977 | 1163 | TopTools_ListOfShape thelist1; |
7fd59977 | 1164 | mySlface.Bind(CurrentFace, thelist1); |
1165 | mySlface(CurrentFace).Append(edg1); | |
1166 | myListOfEdges.Append(edg1); | |
1167 | } | |
1168 | ||
1169 | return result; | |
1170 | ||
1171 | } | |
1172 | ||
1173 | //======================================================================= | |
1174 | //function : MajMap | |
0d969553 | 1175 | //purpose : management of descendants |
7fd59977 | 1176 | //======================================================================= |
1177 | ||
1178 | static void MajMap(const TopoDS_Shape& theB, | |
1179 | const LocOpe_LinearForm& theP, | |
1180 | TopTools_DataMapOfShapeListOfShape& theMap, // myMap | |
1181 | TopoDS_Shape& theFShape, // myFShape | |
1182 | TopoDS_Shape& theLShape) // myLShape | |
1183 | { | |
1184 | TopExp_Explorer exp(theP.FirstShape(),TopAbs_WIRE); | |
1185 | if (exp.More()) { | |
1186 | theFShape = exp.Current(); | |
1187 | TopTools_ListOfShape thelist; | |
1188 | theMap.Bind(theFShape, thelist); | |
1189 | for (exp.Init(theP.FirstShape(),TopAbs_FACE);exp.More();exp.Next()) { | |
1190 | theMap(theFShape).Append(exp.Current()); | |
1191 | } | |
1192 | } | |
1193 | ||
1194 | exp.Init(theP.LastShape(),TopAbs_WIRE); | |
1195 | if (exp.More()) { | |
1196 | theLShape = exp.Current(); | |
1197 | TopTools_ListOfShape thelist1; | |
1198 | theMap.Bind(theLShape, thelist1); | |
1199 | for (exp.Init(theP.LastShape(),TopAbs_FACE);exp.More();exp.Next()) { | |
1200 | theMap(theLShape).Append(exp.Current()); | |
1201 | } | |
1202 | } | |
1203 | ||
1204 | for (exp.Init(theB,TopAbs_EDGE); exp.More(); exp.Next()) { | |
1205 | if (!theMap.IsBound(exp.Current())) { | |
1206 | #ifdef DEB | |
1207 | const TopoDS_Edge& e = | |
1208 | #endif | |
1209 | TopoDS::Edge(exp.Current()); | |
1210 | TopTools_ListOfShape thelist2; | |
1211 | theMap.Bind(exp.Current(), thelist2); | |
1212 | theMap(exp.Current()) = theP.Shapes(exp.Current()); | |
1213 | } | |
1214 | } | |
1215 | } | |
1216 | ||
1217 | //======================================================================= | |
1218 | //function : SetGluedFaces | |
0d969553 | 1219 | //purpose : management of faces of gluing |
7fd59977 | 1220 | //======================================================================= |
1221 | ||
1222 | static void SetGluedFaces(const TopTools_DataMapOfShapeListOfShape& theSlmap, | |
1223 | LocOpe_LinearForm& thePrism, | |
1224 | TopTools_DataMapOfShapeShape& theMap) | |
1225 | { | |
0d969553 | 1226 | // Slidings |
7fd59977 | 1227 | TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm(theSlmap); |
1228 | if(!theSlmap.IsEmpty()) { | |
1229 | for (; itm.More(); itm.Next()) { | |
1230 | const TopoDS_Face& fac = TopoDS::Face(itm.Key()); | |
1231 | const TopTools_ListOfShape& ledg = itm.Value(); | |
1232 | TopTools_ListIteratorOfListOfShape it; | |
1233 | for (it.Initialize(ledg); it.More(); it.Next()) { | |
1234 | const TopTools_ListOfShape& gfac = thePrism.Shapes(it.Value()); | |
1235 | if (gfac.Extent() != 1) { | |
1236 | #ifdef DEB | |
1237 | cout << "Pb SetGluedFace" << endl; | |
1238 | #endif | |
1239 | } | |
1240 | theMap.Bind(gfac.First(),fac); | |
1241 | } | |
1242 | } | |
1243 | } | |
1244 | } | |
1245 |