Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1996-02-13 |
2 | // Created by: Jacques GOUSSARD | |
3 | // Copyright (c) 1996-1999 Matra Datavision | |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS | |
5 | // | |
6 | // The content of this file is subject to the Open CASCADE Technology Public | |
7 | // License Version 6.5 (the "License"). You may not use the content of this file | |
8 | // except in compliance with the License. Please obtain a copy of the License | |
9 | // at http://www.opencascade.org and read it completely before using this file. | |
10 | // | |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its | |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. | |
13 | // | |
14 | // The Original Code and all software distributed under the License is | |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the | |
16 | // Initial Developer hereby disclaims all such warranties, including without | |
17 | // limitation, any warranties of merchantability, fitness for a particular | |
18 | // purpose or non-infringement. Please see the License for the specific terms | |
19 | // and conditions governing the rights and limitations under the License. | |
20 | ||
7fd59977 | 21 | |
22 | ||
23 | #include <BRepFeat_MakePrism.ixx> | |
24 | ||
25 | #include <BRepFeat.hxx> | |
26 | #include <LocOpe.hxx> | |
27 | #include <LocOpe_Prism.hxx> | |
28 | #include <LocOpe_CSIntersector.hxx> | |
29 | #include <LocOpe_PntFace.hxx> | |
30 | ||
31 | #include <gp_Vec.hxx> | |
32 | #include <gp_Pnt.hxx> | |
33 | #include <gp_Ax1.hxx> | |
34 | #include <gp_Pnt2d.hxx> | |
35 | #include <Geom_Curve.hxx> | |
36 | #include <Geom_Line.hxx> | |
37 | #include <Geom_RectangularTrimmedSurface.hxx> | |
38 | #include <Geom_Surface.hxx> | |
39 | ||
40 | #include <BRepLib_MakeFace.hxx> | |
41 | ||
42 | #include <TColgp_SequenceOfPnt.hxx> | |
43 | #include <TColGeom_SequenceOfCurve.hxx> | |
44 | #include <Bnd_Box.hxx> | |
45 | ||
46 | #include <BRep_Tool.hxx> | |
47 | ||
48 | #include <BRepTools.hxx> | |
49 | ||
50 | ||
51 | #include <TopExp_Explorer.hxx> | |
52 | #include <TopTools_MapOfShape.hxx> | |
53 | #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx> | |
54 | #include <TopTools_ListIteratorOfListOfShape.hxx> | |
55 | #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx> | |
56 | #include <TopTools_ListIteratorOfListOfShape.hxx> | |
57 | #include <TopTools_ListOfShape.hxx> | |
58 | ||
59 | #include <BRepBuilderAPI.hxx> | |
60 | #include <BRepPrimAPI_MakeBox.hxx> | |
61 | ||
62 | //modified by NIZNHY-PKV Thu Mar 21 18:14:23 2002 f | |
63 | //#include <BRepAlgo_Cut.hxx> | |
64 | //#include <BRepAlgo_Fuse.hxx> | |
65 | #include <BRepAlgoAPI_Cut.hxx> | |
66 | #include <BRepAlgoAPI_Fuse.hxx> | |
67 | //modified by NIZNHY-PKV Thu Mar 21 18:14:26 2002 t | |
68 | ||
69 | #include <Standard_ConstructionError.hxx> | |
70 | #include <TopoDS.hxx> | |
71 | ||
72 | ||
73 | #include <TopoDS_Face.hxx> | |
74 | #include <TopoDS_Solid.hxx> | |
75 | #include <TopoDS_Compound.hxx> | |
76 | ||
77 | #include <TopExp.hxx> | |
78 | #include <BRepBndLib.hxx> | |
79 | ||
80 | #include <Precision.hxx> | |
81 | #include <gp_Pln.hxx> | |
82 | #include <Geom_Plane.hxx> | |
83 | ||
84 | #ifdef DEB | |
1d0a9d4d | 85 | extern Standard_Boolean BRepFeat_GettraceFEAT(); |
7fd59977 | 86 | #endif |
87 | ||
88 | static void MajMap(const TopoDS_Shape&, // base | |
89 | const LocOpe_Prism&, | |
90 | TopTools_DataMapOfShapeListOfShape&, // myMap | |
91 | TopoDS_Shape&, // myFShape | |
92 | TopoDS_Shape&); // myLShape | |
93 | ||
94 | static Standard_Boolean ToFuse(const TopoDS_Face& , | |
95 | const TopoDS_Face&); | |
96 | ||
97 | ||
98 | static void SetGluedFaces(const TopoDS_Face& theSkface, | |
99 | const TopoDS_Shape& theSbase, | |
100 | const TopoDS_Shape& thePbase, | |
101 | const TopTools_DataMapOfShapeListOfShape& theSlmap, | |
102 | LocOpe_Prism&, | |
103 | TopTools_DataMapOfShapeShape&); | |
104 | ||
105 | #ifdef DEB | |
106 | static void VerifGluedFaces(const TopoDS_Face& theSkface, | |
107 | const TopoDS_Shape& thePbase, | |
108 | Handle(Geom_Curve)& theBCurve, | |
109 | TColGeom_SequenceOfCurve& theCurves, | |
110 | LocOpe_Prism& thePrism, | |
111 | TopTools_DataMapOfShapeShape& theMap); | |
112 | #endif | |
113 | ||
114 | static Standard_Real HeightMax(const TopoDS_Shape& theSbase, | |
115 | const TopoDS_Face& theSkface, | |
116 | const TopoDS_Shape& theSFrom, | |
117 | const TopoDS_Shape& theSUntil); | |
118 | ||
119 | static Standard_Integer SensOfPrism(const Handle(Geom_Curve) C, | |
120 | const TopoDS_Shape& Until); | |
121 | ||
122 | static Handle(Geom_Curve) TestCurve(const TopoDS_Shape&, | |
123 | const gp_Vec&); | |
124 | ||
125 | ||
126 | //======================================================================= | |
127 | //function : Init | |
128 | //purpose : | |
129 | //======================================================================= | |
130 | ||
131 | void BRepFeat_MakePrism::Init(const TopoDS_Shape& Sbase, | |
132 | const TopoDS_Shape& Pbase, | |
133 | const TopoDS_Face& Skface, | |
134 | const gp_Dir& Direc, | |
135 | const Standard_Integer Mode, | |
136 | const Standard_Boolean Modify) | |
137 | { | |
138 | #ifdef DEB | |
139 | Standard_Boolean trc = BRepFeat_GettraceFEAT(); | |
140 | if (trc) cout << "BRepFeat_MakePrism::Init" << endl; | |
141 | #endif | |
142 | mySkface = Skface; | |
143 | SketchFaceValid(); | |
144 | mySbase = Sbase; | |
145 | BasisShapeValid(); | |
146 | myPbase = Pbase; | |
147 | mySlface.Clear(); | |
148 | myDir = Direc; | |
149 | if(Mode == 0) { | |
150 | myFuse = Standard_False; | |
151 | myJustFeat = Standard_False; | |
152 | } | |
153 | else if(Mode == 1) { | |
154 | myFuse = Standard_True; | |
155 | myJustFeat = Standard_False; | |
156 | } | |
157 | else if(Mode == 2) { | |
158 | myFuse = Standard_True; | |
159 | myJustFeat = Standard_True; | |
160 | } | |
161 | else { | |
162 | } | |
163 | myModify = Modify; | |
164 | myJustGluer = Standard_False; | |
165 | ||
166 | ||
167 | //-------------- ifv | |
168 | //mySkface.Nullify(); | |
169 | //-------------- ifv | |
170 | ||
171 | ||
172 | myShape.Nullify(); | |
173 | myNewEdges.Clear(); | |
174 | myTgtEdges.Clear(); | |
175 | myMap.Clear(); | |
176 | myFShape.Nullify(); | |
177 | myLShape.Nullify(); | |
178 | TopExp_Explorer exp; | |
179 | for (exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) { | |
180 | TopTools_ListOfShape thelist; | |
181 | myMap.Bind(exp.Current(), thelist); | |
182 | myMap(exp.Current()).Append(exp.Current()); | |
183 | } | |
184 | #ifdef DEB | |
185 | if (trc) { | |
186 | if (myJustFeat) cout << " Just Feature" << endl; | |
187 | if (myFuse) cout << " Fuse" << endl; | |
188 | if (!myFuse) cout << " Cut" << endl; | |
189 | if (!myModify) cout << " Modify = 0" << endl; | |
190 | } | |
191 | #endif | |
192 | } | |
193 | ||
194 | ||
195 | //======================================================================= | |
196 | //function : Add | |
0d969553 | 197 | //purpose : add elements of sliding (edge on face) |
7fd59977 | 198 | //======================================================================= |
199 | ||
200 | void BRepFeat_MakePrism::Add(const TopoDS_Edge& E, | |
201 | const TopoDS_Face& F) | |
202 | { | |
203 | #ifdef DEB | |
204 | Standard_Boolean trc = BRepFeat_GettraceFEAT(); | |
205 | if (trc) cout << "BRepFeat_MakePrism::Add(Edge,face)" << endl; | |
206 | #endif | |
207 | TopExp_Explorer exp; | |
208 | for (exp.Init(mySbase,TopAbs_FACE);exp.More();exp.Next()) { | |
209 | if (exp.Current().IsSame(F)) { | |
210 | break; | |
211 | } | |
212 | } | |
213 | if (!exp.More()) { | |
214 | Standard_ConstructionError::Raise(); | |
215 | } | |
216 | ||
217 | for (exp.Init(myPbase,TopAbs_EDGE);exp.More();exp.Next()) { | |
218 | if (exp.Current().IsSame(E)) { | |
219 | break; | |
220 | } | |
221 | } | |
222 | if (!exp.More()) { | |
223 | Standard_ConstructionError::Raise(); | |
224 | } | |
225 | ||
226 | if (!mySlface.IsBound(F)) { | |
227 | TopTools_ListOfShape thelist1; | |
228 | mySlface.Bind(F, thelist1); | |
229 | } | |
230 | TopTools_ListIteratorOfListOfShape itl(mySlface(F)); | |
231 | for (; itl.More();itl.Next()) { | |
232 | if (itl.Value().IsSame(E)) { | |
233 | break; | |
234 | } | |
235 | } | |
236 | if (!itl.More()) { | |
237 | mySlface(F).Append(E); | |
238 | } | |
239 | } | |
240 | ||
241 | ||
242 | //======================================================================= | |
243 | //function : Perform | |
0d969553 Y |
244 | //purpose : construction of prism of length Length and |
245 | // call of reconstruction topo | |
7fd59977 | 246 | //======================================================================= |
247 | ||
248 | void BRepFeat_MakePrism::Perform(const Standard_Real Length) | |
249 | { | |
250 | #ifdef DEB | |
251 | Standard_Boolean trc = BRepFeat_GettraceFEAT(); | |
252 | if (trc) cout << "BRepFeat_MakePrism::Perform(Length)" << endl; | |
253 | #endif | |
254 | mySFrom.Nullify(); | |
255 | ShapeFromValid(); | |
256 | mySUntil.Nullify(); | |
257 | ShapeUntilValid(); | |
258 | myGluedF.Clear(); | |
259 | myPerfSelection = BRepFeat_NoSelection; | |
260 | PerfSelectionValid(); | |
261 | gp_Vec V(Length*myDir); | |
262 | ||
0d969553 | 263 | //construction of prism of height Length |
7fd59977 | 264 | |
265 | LocOpe_Prism thePrism(myPbase,V); | |
266 | TopoDS_Shape VraiPrism = thePrism.Shape(); | |
267 | ||
0d969553 | 268 | // management of descendants |
7fd59977 | 269 | MajMap(myPbase,thePrism,myMap,myFShape,myLShape); |
270 | ||
271 | ||
0d969553 | 272 | myGShape = VraiPrism; // the primitive |
7fd59977 | 273 | GeneratedShapeValid(); |
274 | ||
275 | TopoDS_Face FFace; | |
276 | ||
277 | Standard_Boolean found = Standard_False; | |
278 | ||
0d969553 Y |
279 | // try to detect the faces of gluing |
280 | // in case if the top of the prism is tangent to the initial shape | |
7fd59977 | 281 | |
282 | if(!mySkface.IsNull() || !mySlface.IsEmpty()) { | |
283 | if(myLShape.ShapeType() == TopAbs_WIRE) { | |
284 | TopExp_Explorer ex1(VraiPrism, TopAbs_FACE); | |
285 | for(; ex1.More(); ex1.Next()) { | |
286 | TopExp_Explorer ex2(ex1.Current(), TopAbs_WIRE); | |
287 | for(; ex2.More(); ex2.Next()) { | |
288 | if(ex2.Current().IsSame(myLShape)) { | |
289 | FFace = TopoDS::Face(ex1.Current()); | |
290 | found = Standard_True; | |
291 | break; | |
292 | } | |
293 | } | |
294 | if(found) break; | |
295 | } | |
296 | } | |
297 | ||
298 | TopExp_Explorer exp(mySbase, TopAbs_FACE); | |
299 | for(; exp.More(); exp.Next()) { | |
300 | const TopoDS_Face& ff = TopoDS::Face(exp.Current()); | |
301 | if(ToFuse(ff, FFace)) { | |
302 | TopTools_DataMapOfShapeListOfShape sl; | |
303 | if(!FFace.IsSame(myPbase) && BRepFeat::IsInside(ff, FFace)) | |
304 | // SetGluedFaces(ff, mySbase, FFace, sl, thePrism, myGluedF); | |
305 | break; | |
306 | } | |
307 | } | |
308 | } | |
309 | ||
0d969553 | 310 | // management of faces of gluing given by the user |
7fd59977 | 311 | |
312 | // SetGluedFaces(mySkface, mySbase, myPbase, mySlface, thePrism, myGluedF); | |
313 | GluedFacesValid(); | |
314 | // VerifGluedFaces(mySkface, myPbase, myBCurve, myCurves, thePrism, myGluedF); | |
315 | ||
0d969553 | 316 | if(!myGluedF.IsEmpty()) { // case gluing |
7fd59977 | 317 | myJustGluer = Standard_True; |
318 | thePrism.Curves(myCurves); | |
319 | myBCurve = thePrism.BarycCurve(); | |
0d969553 | 320 | GlobalPerform(); // topological reconstruction |
7fd59977 | 321 | } |
322 | ||
0d969553 | 323 | // if there is no gluing -> call of ope topo |
7fd59977 | 324 | if(!myJustGluer) { |
325 | if(myFuse == 1 && !myJustFeat) { | |
326 | //modified by NIZNHY-PKV Thu Mar 21 17:55:30 2002 f | |
327 | //BRepAlgo_Fuse f(mySbase, myGShape); | |
328 | //myShape = f.Shape(); | |
329 | //UpdateDescendants(f.Builder(), myShape, Standard_False); | |
330 | BRepAlgoAPI_Fuse f(mySbase, myGShape); | |
331 | myShape = f.Shape(); | |
332 | UpdateDescendants(f, myShape, Standard_False); | |
333 | //modified by NIZNHY-PKV Thu Mar 21 17:55:34 2002 t | |
334 | Done(); | |
335 | } | |
336 | else if(myFuse == 0) { | |
337 | //modified by NIZNHY-PKV Thu Mar 21 17:55:59 2002 f | |
338 | //BRepAlgo_Cut c(mySbase, myGShape); | |
339 | //myShape = c.Shape(); | |
340 | //UpdateDescendants(c.Builder(), myShape, Standard_False); | |
341 | BRepAlgoAPI_Cut c(mySbase, myGShape); | |
342 | myShape = c.Shape(); | |
343 | UpdateDescendants(c, myShape, Standard_False); | |
344 | //modified by NIZNHY-PKV Thu Mar 21 17:56:02 2002 t | |
345 | Done(); | |
346 | } | |
347 | else { | |
348 | myShape = myGShape; | |
349 | Done(); | |
350 | } | |
351 | } | |
352 | } | |
353 | ||
354 | ||
355 | //======================================================================= | |
356 | //function : Perform | |
0d969553 Y |
357 | //purpose : construction of prism oriented at the face Until, sufficiently |
358 | // long; call of topological reconstruction | |
7fd59977 | 359 | //======================================================================= |
360 | ||
361 | void BRepFeat_MakePrism::Perform(const TopoDS_Shape& Until) | |
362 | { | |
363 | #ifdef DEB | |
364 | Standard_Boolean trc = BRepFeat_GettraceFEAT(); | |
365 | if (trc) cout << "BRepFeat_MakePrism::Perform(Until)" << endl; | |
366 | #endif | |
367 | if (Until.IsNull()) { | |
368 | Standard_ConstructionError::Raise(); | |
369 | } | |
370 | TopExp_Explorer exp(Until, TopAbs_FACE); | |
371 | if (!exp.More()) { | |
372 | Standard_ConstructionError::Raise(); | |
373 | } | |
374 | myGluedF.Clear(); | |
375 | myPerfSelection = BRepFeat_SelectionU; | |
376 | PerfSelectionValid(); | |
377 | mySFrom.Nullify(); | |
378 | ShapeFromValid(); | |
379 | mySUntil = Until; | |
380 | Standard_Boolean Trf = TransformShapeFU(1); | |
381 | ShapeUntilValid(); | |
382 | Handle(Geom_Curve) C = TestCurve(myPbase,myDir); | |
383 | Standard_Integer sens = SensOfPrism(C, mySUntil); | |
384 | Standard_Real Height = HeightMax(mySbase, mySkface, mySFrom, mySUntil); | |
385 | gp_Vec V(2*sens*Height*myDir); | |
386 | ||
0d969553 | 387 | // construction of long prism |
7fd59977 | 388 | LocOpe_Prism thePrism(myPbase,V); |
389 | TopoDS_Shape VraiPrism = thePrism.Shape(); | |
390 | ||
0d969553 | 391 | // in case of support of face Until |
7fd59977 | 392 | if(!Trf) { |
393 | MajMap(myPbase,thePrism,myMap,myFShape,myLShape); | |
394 | myGShape = VraiPrism; | |
395 | GeneratedShapeValid(); | |
396 | ||
397 | //SetGluedFaces(mySkface, mySbase, myPbase, mySlface, thePrism, myGluedF); | |
398 | GluedFacesValid(); | |
399 | // VerifGluedFaces(mySkface, myPbase, myBCurve, myCurves, thePrism, myGluedF); | |
400 | ||
401 | thePrism.Curves(myCurves); | |
402 | myBCurve = thePrism.BarycCurve(); | |
403 | GlobalPerform(); | |
404 | } | |
0d969553 | 405 | else { // until support -> passage to topological operations |
7fd59977 | 406 | MajMap(myPbase,thePrism,myMap,myFShape,myLShape); |
407 | TColGeom_SequenceOfCurve scur; | |
408 | scur.Clear(); | |
409 | scur.Append(C); | |
410 | ||
0d969553 | 411 | // direction of the prism depending on Until |
7fd59977 | 412 | |
413 | LocOpe_CSIntersector ASI(mySUntil); | |
414 | ASI.Perform(scur); | |
415 | TopAbs_Orientation Or; | |
416 | if (ASI.IsDone() && ASI.NbPoints(1) >=1) { | |
417 | if (myFuse == 1) { | |
418 | Or = ASI.Point(1,1).Orientation(); | |
419 | } | |
420 | else { | |
421 | Or = ASI.Point(1,ASI.NbPoints(1)).Orientation(); | |
422 | } | |
423 | if(sens==-1) Or=TopAbs::Reverse(Or); | |
424 | TopoDS_Face FUntil = ASI.Point(1,1).Face(); | |
425 | TopoDS_Shape Comp; | |
426 | BRep_Builder B; | |
427 | B.MakeCompound(TopoDS::Compound(Comp)); | |
428 | TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, Or); | |
429 | if (!S.IsNull()) B.Add(Comp,S); | |
430 | //modified by NIZNHY-PKV Thu Mar 21 17:56:31 2002 f | |
431 | //BRepAlgo_Cut trP(VraiPrism,Comp); | |
432 | //UpdateDescendants(trP.Builder(),trP.Shape(), Standard_False); | |
433 | BRepAlgoAPI_Cut trP(VraiPrism,Comp); | |
434 | UpdateDescendants(trP, trP.Shape(), Standard_False); | |
435 | //modified by NIZNHY-PKV Thu Mar 21 17:56:38 2002 t | |
436 | TopExp_Explorer ex(trP.Shape(), TopAbs_SOLID); | |
437 | TopoDS_Shape Cutsh = ex.Current(); | |
438 | if(myFuse == 1 && !myJustFeat) { | |
439 | //modified by NIZNHY-PKV Thu Mar 21 17:57:49 2002 f | |
440 | //BRepAlgo_Fuse f(mySbase, Cutsh); | |
441 | //myShape = f.Shape(); | |
442 | //UpdateDescendants(f.Builder(), myShape, Standard_False); | |
443 | BRepAlgoAPI_Fuse f(mySbase, Cutsh); | |
444 | myShape = f.Shape(); | |
445 | UpdateDescendants(f, myShape, Standard_False); | |
446 | //modified by NIZNHY-PKV Thu Mar 21 17:57:53 2002 t | |
447 | Done(); | |
448 | } | |
449 | else if(myFuse == 0) { | |
450 | //modified by NIZNHY-PKV Thu Mar 21 17:59:33 2002 f | |
451 | //BRepAlgo_Cut c(mySbase, Cutsh); | |
452 | //myShape = c.Shape(); | |
453 | //UpdateDescendants(c.Builder(), myShape, Standard_False); | |
454 | BRepAlgoAPI_Cut c(mySbase, Cutsh); | |
455 | myShape = c.Shape(); | |
456 | UpdateDescendants(c, myShape, Standard_False); | |
457 | //modified by NIZNHY-PKV Thu Mar 21 17:59:43 2002 t | |
458 | Done(); | |
459 | } | |
460 | else { | |
461 | myShape = Cutsh; | |
462 | Done(); | |
463 | } | |
464 | } | |
465 | } | |
0d969553 | 466 | /* // loop of control of descendance |
7fd59977 | 467 | |
468 | TopExp_Explorer expr(mySbase, TopAbs_FACE); | |
469 | char nom1[20], nom2[20]; | |
470 | Standard_Integer ii = 0; | |
471 | for(; expr.More(); expr.Next()) { | |
472 | ii++; | |
473 | sprintf(nom1, "faceinitial_%d", ii); | |
474 | DBRep::Set(nom1, expr.Current()); | |
475 | Standard_Integer jj = 0; | |
476 | const TopTools_ListOfShape& list = Modified(expr.Current()); | |
477 | TopTools_ListIteratorOfListOfShape ite(list); | |
478 | for(; ite.More(); ite.Next()) { | |
479 | jj++; | |
480 | sprintf(nom2, "facemodifie_%d_%d", ii, jj); | |
481 | DBRep::Set(nom2, ite.Value()); | |
482 | } | |
483 | } | |
484 | ||
485 | expr.Init(myPbase, TopAbs_EDGE); | |
486 | ii=0; | |
487 | for(; expr.More(); expr.Next()) { | |
488 | ii++; | |
489 | sprintf(nom1, "edgeinitial_%d", ii); | |
490 | DBRep::Set(nom1, expr.Current()); | |
491 | Standard_Integer jj = 0; | |
492 | const TopTools_ListOfShape& list = Generated(expr.Current()); | |
493 | TopTools_ListIteratorOfListOfShape ite(list); | |
494 | for(; ite.More(); ite.Next()) { | |
495 | jj++; | |
496 | sprintf(nom2, "facegeneree_%d_%d", ii, jj); | |
497 | DBRep::Set(nom2, ite.Value()); | |
498 | } | |
499 | } | |
500 | */ | |
501 | } | |
502 | ||
503 | ||
504 | //======================================================================= | |
505 | //function : Perform | |
0d969553 Y |
506 | //purpose : construction of a sufficiently long and properly oriented prism |
507 | // call of topological reconstruction | |
7fd59977 | 508 | //======================================================================= |
509 | ||
510 | void BRepFeat_MakePrism::Perform(const TopoDS_Shape& From, | |
511 | const TopoDS_Shape& Until) | |
512 | { | |
513 | #ifdef DEB | |
514 | Standard_Boolean trc = BRepFeat_GettraceFEAT(); | |
515 | if (trc) cout << "BRepFeat_MakePrism::Perform(From,Until)" << endl; | |
516 | #endif | |
517 | if (From.IsNull() || Until.IsNull()) { | |
518 | Standard_ConstructionError::Raise(); | |
519 | } | |
520 | ||
521 | if (!mySkface.IsNull()) { | |
522 | if (From.IsSame(mySkface)) { | |
523 | myJustGluer = Standard_True; | |
524 | Perform(Until); | |
525 | if (myJustGluer) return; | |
526 | } | |
527 | else if (Until.IsSame(mySkface)) { | |
528 | myJustGluer = Standard_True; | |
529 | Perform(From); | |
530 | if (myJustGluer) return; | |
531 | } | |
532 | } | |
533 | ||
534 | myGluedF.Clear(); | |
535 | myPerfSelection = BRepFeat_SelectionFU; | |
536 | PerfSelectionValid(); | |
537 | ||
538 | TopExp_Explorer exp(From, TopAbs_FACE); | |
539 | if (!exp.More()) { | |
540 | Standard_ConstructionError::Raise(); | |
541 | } | |
542 | exp.Init(Until, TopAbs_FACE); | |
543 | if (!exp.More()) { | |
544 | Standard_ConstructionError::Raise(); | |
545 | } | |
546 | mySFrom = From; | |
547 | Standard_Boolean Trff = TransformShapeFU(0); | |
548 | ShapeFromValid(); | |
549 | mySUntil = Until; | |
550 | Standard_Boolean Trfu = TransformShapeFU(1); | |
551 | ShapeUntilValid(); | |
552 | if(Trfu != Trff) { | |
553 | NotDone(); | |
554 | myStatusError = BRepFeat_IncTypes; | |
555 | return; | |
556 | } | |
557 | ||
0d969553 | 558 | // length depending on bounding boxes |
7fd59977 | 559 | |
560 | Standard_Real Height = HeightMax(mySbase, mySkface, mySFrom, mySUntil); | |
561 | Handle(Geom_Curve) C = TestCurve(myPbase,myDir); | |
0d969553 Y |
562 | Standard_Integer sens; // direction of prism |
563 | Standard_Integer tran; // transfer of prism | |
7fd59977 | 564 | if(From.IsSame(Until)) { |
565 | sens = 1; | |
566 | tran = -1; | |
567 | } | |
568 | else { | |
569 | sens = SensOfPrism(C, mySUntil); | |
570 | tran = sens*SensOfPrism(C, mySFrom); | |
571 | } | |
572 | LocOpe_Prism thePrism; | |
573 | if(tran < 0) { | |
574 | gp_Vec Vtra(-3*Height*sens/2.*myDir); | |
575 | thePrism.Perform(myPbase,3*sens*Height*myDir,Vtra); | |
576 | } | |
577 | else { | |
578 | thePrism.Perform(myPbase,2*sens*Height*myDir); | |
579 | } | |
580 | TopoDS_Shape VraiPrism = thePrism.Shape(); | |
581 | ||
582 | if(!Trff) { | |
583 | MajMap(myPbase,thePrism,myMap,myFShape,myLShape); | |
584 | ||
585 | myGShape = VraiPrism; | |
586 | GeneratedShapeValid(); | |
587 | ||
588 | //SetGluedFaces(TopoDS_Face(), // on ne veut pas binder mySkface | |
589 | // mySbase, myPbase, mySlface, thePrism, myGluedF); | |
590 | GluedFacesValid(); | |
591 | //// VerifGluedFaces(mySkface, myPbase, myBCurve, myCurves, thePrism, myGluedF); | |
592 | ||
593 | thePrism.Curves(myCurves); | |
594 | myBCurve = thePrism.BarycCurve(); | |
595 | GlobalPerform(); | |
596 | } | |
0d969553 | 597 | else { // case until support -> topological operation |
7fd59977 | 598 | MajMap(myPbase,thePrism,myMap,myFShape,myLShape); |
599 | TColGeom_SequenceOfCurve scur; | |
600 | scur.Clear(); | |
601 | scur.Append(C); | |
602 | LocOpe_CSIntersector ASI1(mySUntil); | |
603 | LocOpe_CSIntersector ASI2(mySFrom); | |
604 | ASI1.Perform(scur); | |
605 | ASI2.Perform(scur); | |
606 | TopAbs_Orientation OrU, OrF; | |
607 | TopoDS_Face FFrom, FUntil; | |
608 | if (ASI1.IsDone() && ASI1.NbPoints(1) >=1) { | |
609 | if (myFuse == 1) { | |
610 | OrU = ASI1.Point(1,1).Orientation(); | |
611 | } | |
612 | else { | |
613 | OrU = ASI1.Point(1,ASI1.NbPoints(1)).Orientation(); | |
614 | } | |
615 | if(sens==-1) OrU = TopAbs::Reverse(OrU); | |
616 | FUntil = ASI1.Point(1,1).Face(); | |
617 | } | |
618 | else { | |
619 | NotDone(); | |
620 | myStatusError = BRepFeat_NoIntersectU; | |
621 | return; | |
622 | } | |
623 | if (ASI2.IsDone() && ASI2.NbPoints(1) >=1) { | |
624 | OrF = ASI2.Point(1,1).Orientation(); | |
625 | if(sens==1) OrF = TopAbs::Reverse(OrF); | |
626 | FFrom = ASI2.Point(1,1).Face(); | |
627 | } | |
628 | else { | |
629 | NotDone(); | |
630 | myStatusError = BRepFeat_NoIntersectF; | |
631 | return; | |
632 | } | |
633 | TopoDS_Shape Comp; | |
634 | BRep_Builder B; | |
635 | B.MakeCompound(TopoDS::Compound(Comp)); | |
636 | TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, OrU); | |
637 | if (!S.IsNull()) { | |
638 | B.Add(Comp,S); | |
639 | } | |
640 | else { | |
641 | NotDone(); | |
642 | myStatusError = BRepFeat_NullToolU; | |
643 | return; | |
644 | } | |
645 | TopoDS_Solid SS = BRepFeat::Tool(mySFrom, FFrom, OrF); | |
646 | if (!SS.IsNull()) { | |
647 | B.Add(Comp,SS); | |
648 | } | |
649 | else { | |
650 | NotDone(); | |
651 | myStatusError = BRepFeat_NullToolF; | |
652 | return; | |
653 | } | |
654 | //modified by NIZNHY-PKV Thu Mar 21 18:00:10 2002 f | |
655 | //BRepAlgo_Cut trP(VraiPrism,Comp); | |
656 | //UpdateDescendants(trP.Builder(), trP.Shape(), Standard_False); | |
657 | BRepAlgoAPI_Cut trP(VraiPrism,Comp); | |
658 | UpdateDescendants(trP, trP.Shape(), Standard_False); | |
659 | //modified by NIZNHY-PKV Thu Mar 21 18:00:16 2002 t | |
660 | if(myFuse == 1 && !myJustFeat) { | |
661 | //modified by NIZNHY-PKV Thu Mar 21 18:00:35 2002 f | |
662 | //BRepAlgo_Fuse f(mySbase, trP.Shape()); | |
663 | //myShape = f.Shape(); | |
664 | //UpdateDescendants(f.Builder(), myShape, Standard_False); | |
665 | BRepAlgoAPI_Fuse f(mySbase, trP.Shape()); | |
666 | myShape = f.Shape(); | |
667 | UpdateDescendants(f, myShape, Standard_False); | |
668 | //modified by NIZNHY-PKV Thu Mar 21 18:00:40 2002 t | |
669 | Done(); | |
670 | } | |
671 | else if(myFuse == 0) { | |
672 | //modified by NIZNHY-PKV Thu Mar 21 18:01:01 2002 f | |
673 | //BRepAlgo_Cut c(mySbase, trP.Shape()); | |
674 | //myShape = c.Shape(); | |
675 | //UpdateDescendants(c.Builder(), myShape, Standard_False); | |
676 | BRepAlgoAPI_Cut c(mySbase, trP.Shape()); | |
677 | myShape = c.Shape(); | |
678 | UpdateDescendants(c, myShape, Standard_False); | |
679 | //modified by NIZNHY-PKV Thu Mar 21 18:01:13 2002 t | |
680 | Done(); | |
681 | } | |
682 | else { | |
683 | myShape = trP.Shape(); | |
684 | Done(); | |
685 | } | |
686 | } | |
0d969553 | 687 | // control history |
7fd59977 | 688 | /* |
689 | TopExp_Explorer expr(mySbase, TopAbs_FACE); | |
690 | char nom1[20], nom2[20]; | |
691 | Standard_Integer ii = 0; | |
692 | for(; expr.More(); expr.Next()) { | |
693 | ii++; | |
694 | sprintf(nom1, "faceinitial_%d", ii); | |
695 | DBRep::Set(nom1, expr.Current()); | |
696 | Standard_Integer jj = 0; | |
697 | const TopTools_ListOfShape& list = Modified(expr.Current()); | |
698 | TopTools_ListIteratorOfListOfShape ite(list); | |
699 | for(; ite.More(); ite.Next()) { | |
700 | jj++; | |
701 | sprintf(nom2, "facemodifie_%d_%d", ii, jj); | |
702 | DBRep::Set(nom2, ite.Value()); | |
703 | } | |
704 | } | |
705 | ||
706 | expr.Init(myPbase, TopAbs_EDGE); | |
707 | ii=0; | |
708 | for(; expr.More(); expr.Next()) { | |
709 | ii++; | |
710 | sprintf(nom1, "edgeinitial_%d", ii); | |
711 | DBRep::Set(nom1, expr.Current()); | |
712 | Standard_Integer jj = 0; | |
713 | const TopTools_ListOfShape& list = Generated(expr.Current()); | |
714 | TopTools_ListIteratorOfListOfShape ite(list); | |
715 | for(; ite.More(); ite.Next()) { | |
716 | jj++; | |
717 | sprintf(nom2, "egdegeneree_%d_%d", ii, jj); | |
718 | DBRep::Set(nom2, ite.Value()); | |
719 | } | |
720 | } | |
721 | */ | |
722 | } | |
723 | ||
724 | ||
725 | ||
726 | //======================================================================= | |
727 | //function : PerformUntilEnd | |
0d969553 | 728 | //purpose : construction of a prism and reconstruction |
7fd59977 | 729 | //======================================================================= |
730 | ||
731 | void BRepFeat_MakePrism::PerformUntilEnd() | |
732 | { | |
733 | #ifdef DEB | |
734 | Standard_Boolean trc = BRepFeat_GettraceFEAT(); | |
735 | if (trc) cout << "BRepFeat_MakePrism::PerformUntilEnd()" << endl; | |
736 | #endif | |
737 | myPerfSelection = BRepFeat_SelectionSh; | |
738 | PerfSelectionValid(); | |
739 | myGluedF.Clear(); | |
740 | mySUntil.Nullify(); | |
741 | ShapeUntilValid(); | |
742 | mySFrom.Nullify(); | |
743 | ShapeFromValid(); | |
744 | Standard_Real Height = HeightMax(mySbase, mySkface, mySFrom, mySUntil); | |
745 | gp_Vec V(2*Height*myDir); | |
746 | ||
747 | LocOpe_Prism thePrism(myPbase,V); | |
748 | TopoDS_Shape VraiPrism = thePrism.Shape(); | |
749 | ||
750 | MajMap(myPbase,thePrism,myMap,myFShape,myLShape); | |
751 | ||
752 | myGShape = VraiPrism; | |
753 | GeneratedShapeValid(); | |
754 | GluedFacesValid(); | |
755 | ||
756 | if(myFuse == 0) { | |
757 | //modified by NIZNHY-PKV Thu Mar 21 18:02:46 2002 f | |
758 | //BRepAlgo_Cut c(mySbase, myGShape); | |
759 | BRepAlgoAPI_Cut c(mySbase, myGShape); | |
760 | //modified by NIZNHY-PKV Thu Mar 21 18:03:15 2002 t | |
761 | if (c.IsDone()) { | |
762 | myShape = c.Shape(); | |
763 | //modified by NIZNHY-PKV Thu Mar 21 18:03:38 2002 f | |
764 | //UpdateDescendants(c.Builder(), myShape, Standard_False); | |
765 | UpdateDescendants(c, myShape, Standard_False); | |
766 | //modified by NIZNHY-PKV Thu Mar 21 18:03:42 2002 t | |
767 | Done(); | |
768 | } | |
769 | } | |
770 | else { | |
771 | thePrism.Curves(myCurves); | |
772 | myBCurve = thePrism.BarycCurve(); | |
773 | GlobalPerform(); | |
774 | } | |
775 | } | |
776 | ||
777 | //======================================================================= | |
778 | //function : PerformFromEnd | |
779 | //purpose : | |
780 | //======================================================================= | |
781 | ||
782 | void BRepFeat_MakePrism::PerformFromEnd(const TopoDS_Shape& Until) | |
783 | { | |
784 | #ifdef DEB | |
785 | Standard_Boolean trc = BRepFeat_GettraceFEAT(); | |
786 | if (trc) cout << "BRepFeat_MakePrism::PerformFromEnd(From,Until)" << endl; | |
787 | #endif | |
788 | if (Until.IsNull()) { | |
789 | Standard_ConstructionError::Raise(); | |
790 | } | |
791 | if (!mySkface.IsNull() && Until.IsSame(mySkface)) { | |
792 | myDir.Reverse(); | |
793 | PerformUntilEnd(); | |
794 | return; | |
795 | } | |
796 | TopExp_Explorer exp; | |
797 | exp.Init(Until, TopAbs_FACE); | |
798 | if (!exp.More()) { | |
799 | Standard_ConstructionError::Raise(); | |
800 | } | |
801 | myPerfSelection = BRepFeat_SelectionShU; | |
802 | PerfSelectionValid(); | |
803 | mySFrom.Nullify(); | |
804 | ShapeFromValid(); | |
805 | mySUntil = Until; | |
806 | Standard_Boolean Trf = TransformShapeFU(1); | |
807 | ShapeUntilValid(); | |
808 | Handle(Geom_Curve) C = TestCurve(myPbase,myDir); | |
809 | Standard_Integer sens = SensOfPrism(C, mySUntil); | |
810 | Standard_Real Height = HeightMax(mySbase, mySkface, mySFrom, mySUntil); | |
811 | gp_Vec Vtra(-3*Height*sens/2.*myDir); | |
812 | gp_Vec Vect(3*sens*Height*myDir); | |
813 | LocOpe_Prism thePrism(myPbase,Vect,Vtra); | |
814 | TopoDS_Shape VraiPrism = thePrism.Shape(); | |
815 | ||
0d969553 | 816 | if(!Trf) { // case face until |
7fd59977 | 817 | MajMap(myPbase,thePrism,myMap,myFShape,myLShape); |
818 | myGShape = VraiPrism; | |
819 | GeneratedShapeValid(); | |
820 | myGluedF.Clear(); | |
821 | GluedFacesValid(); | |
822 | thePrism.Curves(myCurves); | |
823 | myBCurve = thePrism.BarycCurve(); | |
824 | GlobalPerform(); | |
825 | } | |
0d969553 | 826 | else { // case support |
7fd59977 | 827 | MajMap(myPbase,thePrism,myMap,myFShape,myLShape); |
828 | TColGeom_SequenceOfCurve scur; | |
829 | scur.Clear(); | |
830 | scur.Append(C); | |
831 | LocOpe_CSIntersector ASI1(mySUntil); | |
832 | LocOpe_CSIntersector ASI2(mySbase); | |
833 | ASI1.Perform(scur); | |
834 | ASI2.Perform(scur); | |
7fd59977 | 835 | TopAbs_Orientation OrU = TopAbs_FORWARD, OrF = TopAbs_FORWARD; |
7fd59977 | 836 | TopoDS_Face FUntil, FFrom; |
837 | if (ASI1.IsDone() && ASI1.NbPoints(1) >=1) { | |
838 | OrU = ASI1.Point(1,1).Orientation(); | |
839 | if(sens==-1) { | |
840 | OrU = TopAbs::Reverse(OrU); | |
841 | } | |
842 | FUntil = ASI1.Point(1,1).Face(); | |
843 | } | |
844 | if (ASI2.IsDone() && ASI2.NbPoints(1) >=1) { | |
845 | OrF = ASI2.Point(1,1).Orientation(); | |
846 | // if(sens==1) OrF = TopAbs::Reverse(OrF); | |
847 | FFrom = ASI2.Point(1 ,1).Face(); | |
848 | Handle(Geom_Surface) S = BRep_Tool::Surface(FFrom); | |
849 | if (S->DynamicType() == | |
850 | STANDARD_TYPE(Geom_RectangularTrimmedSurface)) { | |
851 | S = Handle(Geom_RectangularTrimmedSurface):: | |
852 | DownCast(S)->BasisSurface(); | |
853 | } | |
1c72dff6 | 854 | BRepLib_MakeFace fac(S, Precision::Confusion()); |
7fd59977 | 855 | mySFrom = fac.Face(); |
856 | Trf = TransformShapeFU(0); | |
857 | FFrom = TopoDS::Face(mySFrom); | |
858 | } | |
859 | // else { | |
860 | // NotDone(); | |
861 | // return; | |
862 | // } | |
863 | TopoDS_Shape Comp; | |
864 | BRep_Builder B; | |
865 | B.MakeCompound(TopoDS::Compound(Comp)); | |
866 | TopoDS_Solid Sol = BRepFeat::Tool(mySUntil, FUntil, OrU); | |
867 | if (!Sol.IsNull()) { | |
868 | B.Add(Comp,Sol); | |
869 | } | |
870 | else { | |
871 | NotDone(); | |
872 | myStatusError = BRepFeat_NullToolU; | |
873 | return; | |
874 | } | |
875 | ||
876 | TopoDS_Solid Sol1 = BRepFeat::Tool(mySFrom, FFrom, OrF); | |
877 | if (!Sol1.IsNull()) { | |
878 | B.Add(Comp,Sol1); | |
879 | } | |
880 | else { | |
881 | NotDone(); | |
882 | myStatusError = BRepFeat_NullToolF; | |
883 | return; | |
884 | } | |
885 | //modified by NIZNHY-PKV Thu Mar 21 18:03:57 2002 f | |
886 | //BRepAlgo_Cut trP(VraiPrism,Comp); | |
887 | //UpdateDescendants(trP.Builder(), trP.Shape(), Standard_False); | |
888 | BRepAlgoAPI_Cut trP(VraiPrism,Comp); | |
889 | UpdateDescendants(trP, trP.Shape(), Standard_False); | |
890 | //modified by NIZNHY-PKV Thu Mar 21 18:04:08 2002 t | |
891 | if(myFuse == 1 && !myJustFeat) { | |
892 | //modified by NIZNHY-PKV Thu Mar 21 18:04:33 2002 f | |
893 | //BRepAlgo_Fuse f(mySbase, trP.Shape()); | |
894 | //myShape = f.Shape(); | |
895 | //UpdateDescendants(f.Builder(), myShape, Standard_False); | |
896 | BRepAlgoAPI_Fuse f(mySbase, trP.Shape()); | |
897 | myShape = f.Shape(); | |
898 | UpdateDescendants(f, myShape, Standard_False); | |
899 | //modified by NIZNHY-PKV Thu Mar 21 18:04:41 2002 t | |
900 | Done(); | |
901 | } | |
902 | else if(myFuse == 0) { | |
903 | //modified by NIZNHY-PKV Thu Mar 21 18:04:54 2002 f | |
904 | //BRepAlgo_Cut c(mySbase, trP.Shape()); | |
905 | //myShape = c.Shape(); | |
906 | //UpdateDescendants(c.Builder(), myShape, Standard_False); | |
907 | BRepAlgoAPI_Cut c(mySbase, trP.Shape()); | |
908 | myShape = c.Shape(); | |
909 | UpdateDescendants(c, myShape, Standard_False); | |
910 | //modified by NIZNHY-PKV Thu Mar 21 18:05:00 2002 t | |
911 | Done(); | |
912 | } | |
913 | else { | |
914 | myShape = trP.Shape(); | |
915 | Done(); | |
916 | } | |
917 | } | |
918 | } | |
919 | ||
920 | ||
921 | ||
922 | //======================================================================= | |
923 | //function : PerformThruAll | |
924 | //purpose : | |
925 | //======================================================================= | |
926 | ||
927 | void BRepFeat_MakePrism::PerformThruAll() | |
928 | { | |
929 | #ifdef DEB | |
930 | Standard_Boolean trc = BRepFeat_GettraceFEAT(); | |
931 | if (trc) cout << "BRepFeat_MakePrism::PerformThruAll()" << endl; | |
932 | #endif | |
933 | mySUntil.Nullify(); | |
934 | ShapeUntilValid(); | |
935 | mySFrom.Nullify(); | |
936 | ShapeFromValid(); | |
937 | if(myFuse == 0) { | |
938 | myPerfSelection = BRepFeat_NoSelection; | |
939 | } | |
940 | else { | |
941 | myPerfSelection = BRepFeat_SelectionSh; | |
942 | } | |
943 | PerfSelectionValid(); | |
944 | myGluedF.Clear(); | |
945 | GluedFacesValid(); | |
946 | ||
947 | Standard_Real Height = HeightMax(mySbase, mySkface, mySFrom, mySUntil); | |
948 | gp_Vec V(3*Height*myDir); | |
949 | gp_Vec Vtra(-3*Height/2.*myDir); | |
950 | LocOpe_Prism thePrism(myPbase,V,Vtra); | |
951 | TopoDS_Shape VraiPrism = thePrism.Shape(); | |
952 | MajMap(myPbase,thePrism,myMap,myFShape,myLShape); | |
953 | ||
954 | myGShape = VraiPrism; | |
955 | GeneratedShapeValid(); | |
956 | ||
957 | if(myFuse == 0) { | |
958 | //modified by NIZNHY-PKV Thu Mar 21 18:05:31 2002 f | |
959 | //BRepAlgo_Cut c(mySbase, myGShape); | |
960 | BRepAlgoAPI_Cut c(mySbase, myGShape); | |
961 | //modified by NIZNHY-PKV Thu Mar 21 18:05:33 2002 t | |
962 | if (c.IsDone()) { | |
963 | myShape = c.Shape(); | |
964 | //modified by NIZNHY-PKV Thu Mar 21 18:05:46 2002 f | |
965 | //UpdateDescendants(c.Builder(), myShape, Standard_False); | |
966 | UpdateDescendants(c, myShape, Standard_False); | |
967 | //modified by NIZNHY-PKV Thu Mar 21 18:05:50 2002 t | |
968 | Done(); | |
969 | } | |
970 | } | |
971 | else { | |
972 | thePrism.Curves(myCurves); | |
973 | myBCurve = thePrism.BarycCurve(); | |
974 | GlobalPerform(); | |
975 | } | |
976 | } | |
977 | ||
978 | ||
979 | //======================================================================= | |
980 | //function : PerformUntilHauteur | |
981 | //purpose : | |
982 | //======================================================================= | |
983 | ||
984 | void BRepFeat_MakePrism::PerformUntilHeight(const TopoDS_Shape& Until, | |
985 | const Standard_Real Length) | |
986 | { | |
987 | #ifdef DEB | |
988 | Standard_Boolean trc = BRepFeat_GettraceFEAT(); | |
989 | if (trc) cout << "BRepFeat_MakePrism::PerformUntilHeight(Until,Length)" << endl; | |
990 | #endif | |
991 | if (Until.IsNull()) { | |
992 | Perform(Length); | |
993 | } | |
994 | if(Length == 0) { | |
995 | Perform(Until); | |
996 | } | |
997 | TopExp_Explorer exp(Until, TopAbs_FACE); | |
998 | if (!exp.More()) { | |
999 | Standard_ConstructionError::Raise(); | |
1000 | } | |
1001 | myGluedF.Clear(); | |
1002 | myPerfSelection = BRepFeat_NoSelection; | |
1003 | PerfSelectionValid(); | |
1004 | mySFrom.Nullify(); | |
1005 | ShapeFromValid(); | |
1006 | mySUntil = Until; | |
1007 | Standard_Boolean Trf = TransformShapeFU(1); | |
1008 | ShapeUntilValid(); | |
1009 | Handle(Geom_Curve) C = TestCurve(myPbase,myDir); | |
1010 | Standard_Integer sens = SensOfPrism(C, mySUntil); | |
1011 | gp_Vec V(sens*Length*myDir); | |
1012 | LocOpe_Prism thePrism(myPbase,V); | |
1013 | TopoDS_Shape VraiPrism = thePrism.Shape(); | |
1014 | ||
1015 | if(!Trf) { | |
1016 | MajMap(myPbase,thePrism,myMap,myFShape,myLShape); | |
1017 | ||
1018 | myGShape = VraiPrism; | |
1019 | GeneratedShapeValid(); | |
1020 | ||
1021 | //SetGluedFaces(mySkface, mySbase, myPbase, mySlface, thePrism, myGluedF); | |
1022 | GluedFacesValid(); | |
1023 | // VerifGluedFaces(mySkface, myPbase, myBCurve, myCurves, thePrism, myGluedF); | |
1024 | ||
1025 | thePrism.Curves(myCurves); | |
1026 | myBCurve = thePrism.BarycCurve(); | |
1027 | GlobalPerform(); | |
1028 | } | |
1029 | else { | |
1030 | MajMap(myPbase,thePrism,myMap,myFShape,myLShape); | |
1031 | TColGeom_SequenceOfCurve scur; | |
1032 | scur.Clear(); | |
1033 | scur.Append(C); | |
1034 | LocOpe_CSIntersector ASI(mySUntil); | |
1035 | ASI.Perform(scur); | |
1036 | TopAbs_Orientation Or; | |
1037 | if (ASI.IsDone() && ASI.NbPoints(1) >=1) { | |
1038 | if (myFuse == 1) { | |
1039 | Or = ASI.Point(1,1).Orientation(); | |
1040 | } | |
1041 | else { | |
1042 | Or = ASI.Point(1,ASI.NbPoints(1)).Orientation(); | |
1043 | } | |
1044 | if(sens==-1) Or=TopAbs::Reverse(Or); | |
1045 | TopoDS_Face FUntil = ASI.Point(1,1).Face(); | |
1046 | TopoDS_Shape Comp; | |
1047 | BRep_Builder B; | |
1048 | B.MakeCompound(TopoDS::Compound(Comp)); | |
1049 | TopoDS_Solid S = BRepFeat::Tool(mySUntil, FUntil, Or); | |
1050 | if (!S.IsNull()) B.Add(Comp,S); | |
1051 | ||
1052 | //modified by NIZNHY-PKV Thu Mar 21 18:06:09 2002 f | |
1053 | //BRepAlgo_Cut trP(VraiPrism,Comp); | |
1054 | //UpdateDescendants(trP.Builder(), trP.Shape(), Standard_False); | |
1055 | BRepAlgoAPI_Cut trP(VraiPrism,Comp); | |
1056 | UpdateDescendants(trP, trP.Shape(), Standard_False); | |
1057 | //modified by NIZNHY-PKV Thu Mar 21 18:06:15 2002 t | |
1058 | if(myFuse == 1 && !myJustFeat) { | |
1059 | //modified by NIZNHY-PKV Thu Mar 21 18:06:36 2002 f | |
1060 | //BRepAlgo_Fuse f(mySbase, trP.Shape()); | |
1061 | //myShape = f.Shape(); | |
1062 | //UpdateDescendants(f.Builder(), myShape, Standard_False); | |
1063 | BRepAlgoAPI_Fuse f(mySbase, trP.Shape()); | |
1064 | myShape = f.Shape(); | |
1065 | UpdateDescendants(f, myShape, Standard_False); | |
1066 | //modified by NIZNHY-PKV Thu Mar 21 18:06:41 2002 t | |
1067 | Done(); | |
1068 | } | |
1069 | else if(myFuse == 0) { | |
1070 | //modified by NIZNHY-PKV Thu Mar 21 18:07:06 2002 f | |
1071 | //BRepAlgo_Cut c(mySbase, trP.Shape()); | |
1072 | //myShape = c.Shape(); | |
1073 | //UpdateDescendants(c.Builder(), myShape, Standard_False); | |
1074 | BRepAlgoAPI_Cut c(mySbase, trP.Shape()); | |
1075 | myShape = c.Shape(); | |
1076 | UpdateDescendants(c, myShape, Standard_False); | |
1077 | //modified by NIZNHY-PKV Thu Mar 21 18:07:12 2002 t | |
1078 | Done(); | |
1079 | } | |
1080 | else { | |
1081 | myShape = trP.Shape(); | |
1082 | Done(); | |
1083 | } | |
1084 | } | |
1085 | } | |
1086 | } | |
1087 | ||
1088 | //======================================================================= | |
1089 | //function : Curves | |
0d969553 | 1090 | //purpose : sequence of curves parallel to the axis of prism |
7fd59977 | 1091 | //======================================================================= |
1092 | ||
1093 | void BRepFeat_MakePrism::Curves(TColGeom_SequenceOfCurve& scur) | |
1094 | { | |
1095 | scur = myCurves; | |
1096 | } | |
1097 | ||
1098 | //======================================================================= | |
1099 | //function : BarycCurve | |
0d969553 Y |
1100 | //purpose : curve parallel to the axis of the prism passing through the center |
1101 | // of masses | |
7fd59977 | 1102 | //======================================================================= |
1103 | ||
1104 | Handle(Geom_Curve) BRepFeat_MakePrism::BarycCurve() | |
1105 | { | |
1106 | return myBCurve; | |
1107 | } | |
1108 | ||
1109 | ||
1110 | //======================================================================= | |
1111 | //function : HeightMax | |
0d969553 Y |
1112 | //purpose : Calculate the height of the prism following the parameters of |
1113 | // bounding box | |
7fd59977 | 1114 | //======================================================================= |
1115 | ||
1116 | static Standard_Real HeightMax(const TopoDS_Shape& theSbase, | |
1117 | const TopoDS_Face& theSkface, | |
1118 | const TopoDS_Shape& theSFrom, | |
1119 | const TopoDS_Shape& theSUntil) | |
1120 | { | |
1121 | Bnd_Box Box; | |
1122 | BRepBndLib::Add(theSbase,Box); | |
1123 | BRepBndLib::Add(theSkface,Box); | |
1124 | if(!theSFrom.IsNull()) { | |
7fd59977 | 1125 | Standard_Boolean FacRevolInfini = Standard_False; |
7fd59977 | 1126 | TopExp_Explorer exp; |
1127 | exp.Init(theSFrom, TopAbs_EDGE); | |
1128 | for(; exp.More(); exp.Next()) { | |
1129 | TopExp_Explorer exp1; | |
1130 | exp1.Init(exp.Current(), TopAbs_VERTEX); | |
1131 | if(!exp1.More()) { | |
1132 | FacRevolInfini = Standard_True; | |
1133 | break; | |
1134 | } | |
1135 | } | |
1136 | if(!FacRevolInfini) | |
1137 | BRepBndLib::Add(theSFrom,Box); | |
1138 | } | |
1139 | if(!theSUntil.IsNull()) { | |
7fd59977 | 1140 | Standard_Boolean FacRevolInfini; |
7fd59977 | 1141 | TopExp_Explorer exp; |
1142 | exp.Init(theSUntil, TopAbs_EDGE); | |
1143 | for(; exp.More(); exp.Next()) { | |
1144 | TopExp_Explorer exp1; | |
1145 | exp1.Init(exp.Current(), TopAbs_VERTEX); | |
1146 | if(!exp1.More()) { | |
1147 | FacRevolInfini = Standard_True; | |
1148 | break; | |
1149 | } | |
1150 | } | |
1151 | if(!FacRevolInfini) | |
1152 | BRepBndLib::Add(theSUntil,Box); | |
1153 | } | |
1154 | ||
1155 | Standard_Real c[6]; | |
1156 | ||
1157 | Box.Get(c[0],c[2],c[4],c[1],c[3],c[5]); | |
1158 | Standard_Real parmin=c[0], parmax = c[0]; | |
1159 | for(Standard_Integer i = 0 ; i < 6; i++) { | |
1160 | if(c[i] > parmax) parmax = c[i]; | |
1161 | if(c[i] < parmin ) parmin = c[i]; | |
1162 | } | |
1163 | //#ifndef DEB | |
1164 | Standard_Real Height = fabs(2.*(parmax - parmin)); | |
1165 | //#else | |
1166 | // Standard_Real Height = abs(2.*(parmax - parmin)); | |
1167 | //#endif | |
1168 | return(Height); | |
1169 | } | |
1170 | ||
1171 | ||
1172 | //======================================================================= | |
1173 | //function : SensOfPrism | |
0d969553 | 1174 | //purpose : Direction of the prism depending on the shape Until |
7fd59977 | 1175 | //======================================================================= |
1176 | Standard_Integer SensOfPrism(const Handle(Geom_Curve) C, | |
1177 | const TopoDS_Shape& Until) | |
1178 | { | |
1179 | LocOpe_CSIntersector ASI1(Until); | |
1180 | TColGeom_SequenceOfCurve scur; | |
1181 | scur.Append(C); | |
1182 | ASI1.Perform(scur); | |
1183 | Standard_Integer sens = 1; | |
1184 | if(ASI1.IsDone() && ASI1.NbPoints(1) >= 1) { | |
1185 | if(ASI1.Point(1, 1).Parameter() < 0. && | |
1186 | ASI1.Point(1, ASI1.NbPoints(1)).Parameter() < 0.) { | |
1187 | sens = -1; | |
1188 | } | |
1189 | } | |
1190 | else if(BRepFeat::ParametricBarycenter(Until,C) < 0) { | |
1191 | sens = -1; | |
1192 | } | |
1193 | else {} | |
1194 | return sens; | |
1195 | } | |
1196 | ||
1197 | ||
1198 | //======================================================================= | |
1199 | //function : SetGluedFaces | |
0d969553 | 1200 | //purpose : management of gluing faces |
7fd59977 | 1201 | //======================================================================= |
1202 | ||
1203 | static void SetGluedFaces(const TopoDS_Face& theSkface, | |
1204 | const TopoDS_Shape& theSbase, | |
1205 | const TopoDS_Shape& thePbase, | |
1206 | const TopTools_DataMapOfShapeListOfShape& theSlmap, | |
1207 | LocOpe_Prism& thePrism, | |
1208 | TopTools_DataMapOfShapeShape& theMap) | |
1209 | { | |
1210 | TopExp_Explorer exp; | |
1211 | if (!theSkface.IsNull() && thePbase.ShapeType() == TopAbs_FACE) { | |
1212 | for (exp.Init(theSbase,TopAbs_FACE); exp.More(); exp.Next()) { | |
1213 | if (exp.Current().IsSame(theSkface)) { | |
1214 | theMap.Bind(thePbase,theSkface); | |
1215 | break; | |
1216 | } | |
1217 | } | |
1218 | } | |
1219 | else { | |
1220 | for (exp.Init(theSbase,TopAbs_FACE); exp.More(); exp.Next()) { | |
1221 | if (exp.Current().IsSame(theSkface)) { | |
1222 | TopExp_Explorer exp2; | |
1223 | for (exp2.Init(thePbase,TopAbs_FACE);exp2.More();exp2.Next()) { | |
1224 | theMap.Bind(exp2.Current(),theSkface); | |
1225 | } | |
1226 | break; | |
1227 | } | |
1228 | } | |
1229 | } | |
1230 | ||
0d969553 | 1231 | // Sliding |
7fd59977 | 1232 | TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm(theSlmap); |
1233 | if(!theSlmap.IsEmpty()) { | |
1234 | for (; itm.More(); itm.Next()) { | |
1235 | const TopoDS_Face& fac = TopoDS::Face(itm.Key()); | |
1236 | const TopTools_ListOfShape& ledg = itm.Value(); | |
1237 | TopTools_ListIteratorOfListOfShape it; | |
1238 | for (it.Initialize(ledg); it.More(); it.Next()) { | |
1239 | const TopTools_ListOfShape& gfac = thePrism.Shapes(it.Value()); | |
1240 | if (gfac.Extent() != 1) { | |
1241 | #ifdef DEB | |
1242 | Standard_Boolean trc = BRepFeat_GettraceFEAT(); | |
1243 | if (trc) cout << " BRepFeat_MakePrism : Pb SetGluedFace" << endl; | |
1244 | #endif | |
1245 | } | |
1246 | theMap.Bind(gfac.First(),fac); | |
1247 | } | |
1248 | } | |
1249 | } | |
1250 | } | |
1251 | ||
1252 | ||
1253 | //======================================================================= | |
1254 | //function : VerifGluedFaces | |
0d969553 Y |
1255 | //purpose : Verification intersection Tool/theSkface = thePbase |
1256 | // If yes -> OK otherwise -> case without gluing | |
7fd59977 | 1257 | //======================================================================= |
1258 | #ifdef DEB | |
1259 | static void VerifGluedFaces(const TopoDS_Face& theSkface, | |
1260 | const TopoDS_Shape& thePbase, | |
1261 | Handle(Geom_Curve)& theBCurve, | |
1262 | TColGeom_SequenceOfCurve& theCurves, | |
1263 | LocOpe_Prism& thePrism, | |
1264 | TopTools_DataMapOfShapeShape& theMap) | |
1265 | { | |
1266 | Standard_Boolean GluedFaces = Standard_True; | |
1267 | TopoDS_Shape VraiPrism = thePrism.Shape(); | |
1268 | ||
1269 | TColGeom_SequenceOfCurve scur; | |
1270 | thePrism.Curves(theCurves); | |
1271 | theBCurve = thePrism.BarycCurve(); | |
1272 | scur.Clear(); | |
1273 | scur.Append(theBCurve); | |
1274 | LocOpe_CSIntersector ASI(theSkface); | |
1275 | ASI.Perform(scur); | |
1276 | if (ASI.IsDone() && ASI.NbPoints(1) >=1) { | |
1277 | TopAbs_Orientation Or = ASI.Point(1,1).Orientation(); | |
1278 | TopoDS_Face FSk = ASI.Point(1,1).Face(); | |
1279 | TopoDS_Shape Comp; | |
1280 | BRep_Builder B; | |
1281 | B.MakeCompound(TopoDS::Compound(Comp)); | |
1282 | TopoDS_Solid S = BRepFeat::Tool(theSkface, FSk, Or); | |
1283 | if (!S.IsNull()) B.Add(Comp,S); | |
1284 | //modified by NIZNHY-PKV Thu Mar 21 18:07:35 2002 f | |
1285 | //BRepAlgo_Cut trP(VraiPrism,Comp); | |
1286 | BRepAlgoAPI_Cut trP(VraiPrism,Comp); | |
1287 | //modified by NIZNHY-PKV Thu Mar 21 18:07:39 2002 t | |
1288 | TopoDS_Shape Cutsh = trP.Shape(); | |
1289 | TopExp_Explorer ex(Cutsh, TopAbs_SOLID); | |
1290 | for(; ex.More(); ex.Next()) { | |
1291 | TopExp_Explorer ex1(ex.Current(), TopAbs_FACE); | |
1292 | for(; ex1.More(); ex1.Next()) { | |
1293 | const TopoDS_Face& fac1 = TopoDS::Face(ex1.Current()); | |
1294 | TopExp_Explorer ex2(thePbase, TopAbs_FACE); | |
1295 | for(; ex2.More(); ex2.Next()) { | |
1296 | const TopoDS_Face& fac2 = TopoDS::Face(ex2.Current()); | |
1297 | if(fac1.IsSame(fac2)) break; | |
1298 | } | |
1299 | if (ex2.More()) break; | |
1300 | } | |
1301 | if (ex1.More()) continue; | |
1302 | GluedFaces = Standard_False; | |
1303 | break; | |
1304 | } | |
1305 | if (!GluedFaces) { | |
1306 | #ifdef DEB | |
1307 | Standard_Boolean trc = BRepFeat_GettraceFEAT(); | |
0d969553 | 1308 | if (trc) cout << " Intersection Prism/skface : no gluing" << endl; |
7fd59977 | 1309 | #endif |
1310 | theMap.Clear(); | |
1311 | } | |
1312 | } | |
1313 | } | |
1314 | #endif | |
1315 | ||
1316 | //======================================================================= | |
1317 | //function : MajMap | |
0d969553 | 1318 | //purpose : management of descendants |
7fd59977 | 1319 | //======================================================================= |
1320 | ||
1321 | static void MajMap(const TopoDS_Shape& theB, | |
1322 | const LocOpe_Prism& theP, | |
1323 | TopTools_DataMapOfShapeListOfShape& theMap, // myMap | |
1324 | TopoDS_Shape& theFShape, // myFShape | |
1325 | TopoDS_Shape& theLShape) // myLShape | |
1326 | { | |
1327 | TopExp_Explorer exp(theP.FirstShape(),TopAbs_WIRE); | |
1328 | if (exp.More()) { | |
1329 | theFShape = exp.Current(); | |
1330 | TopTools_ListOfShape thelist2; | |
1331 | theMap.Bind(theFShape, thelist2); | |
1332 | for (exp.Init(theP.FirstShape(),TopAbs_FACE);exp.More();exp.Next()) { | |
1333 | theMap(theFShape).Append(exp.Current()); | |
1334 | } | |
1335 | } | |
1336 | ||
1337 | exp.Init(theP.LastShape(),TopAbs_WIRE); | |
1338 | if (exp.More()) { | |
1339 | theLShape = exp.Current(); | |
1340 | TopTools_ListOfShape thelist3; | |
1341 | theMap.Bind(theLShape, thelist3); | |
1342 | for (exp.Init(theP.LastShape(),TopAbs_FACE);exp.More();exp.Next()) { | |
1343 | theMap(theLShape).Append(exp.Current()); | |
1344 | } | |
1345 | } | |
1346 | ||
1347 | for (exp.Init(theB,TopAbs_EDGE); exp.More(); exp.Next()) { | |
1348 | if (!theMap.IsBound(exp.Current())) { | |
1349 | TopTools_ListOfShape thelist4; | |
1350 | theMap.Bind(exp.Current(), thelist4); | |
1351 | theMap(exp.Current()) = theP.Shapes(exp.Current()); | |
1352 | } | |
1353 | } | |
1354 | } | |
1355 | ||
1356 | ||
1357 | //======================================================================= | |
1358 | //function : MajMap | |
0d969553 | 1359 | //purpose : management of descendants |
7fd59977 | 1360 | //======================================================================= |
1361 | ||
1362 | static Handle(Geom_Curve) TestCurve(const TopoDS_Shape& Base, | |
1363 | const gp_Vec& V) | |
1364 | { | |
1365 | gp_Pnt bar(0., 0., 0.); | |
1366 | TColgp_SequenceOfPnt spt; | |
1367 | LocOpe::SampleEdges(Base,spt); | |
1368 | for (Standard_Integer jj=1;jj<=spt.Length(); jj++) { | |
1369 | const gp_Pnt& pvt = spt(jj); | |
1370 | bar.ChangeCoord() += pvt.XYZ(); | |
1371 | } | |
1372 | bar.ChangeCoord().Divide(spt.Length()); | |
1373 | gp_Ax1 newAx(bar,V); | |
1374 | Handle(Geom_Line) theLin = new Geom_Line(newAx); | |
1375 | return theLin; | |
1376 | } | |
1377 | ||
1378 | ||
1379 | ||
1380 | ||
1381 | //======================================================================= | |
1382 | //function : ToFuse | |
0d969553 | 1383 | //purpose : face SameDomaine or not |
7fd59977 | 1384 | //======================================================================= |
1385 | ||
1386 | Standard_Boolean ToFuse(const TopoDS_Face& F1, | |
1387 | const TopoDS_Face& F2) | |
1388 | { | |
1389 | if (F1.IsNull() || F2.IsNull()) { | |
1390 | return Standard_False; | |
1391 | } | |
1392 | ||
1393 | Handle(Geom_Surface) S1,S2; | |
1394 | TopLoc_Location loc1, loc2; | |
1395 | Handle(Standard_Type) typS1,typS2; | |
1396 | const Standard_Real tollin = Precision::Confusion(); | |
1397 | const Standard_Real tolang = Precision::Angular(); | |
1398 | ||
1399 | S1 = BRep_Tool::Surface(F1,loc1); | |
1400 | S2 = BRep_Tool::Surface(F2,loc2); | |
1401 | ||
1402 | typS1 = S1->DynamicType(); | |
1403 | typS2 = S2->DynamicType(); | |
1404 | ||
1405 | if (typS1 == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) { | |
1406 | S1 = (*((Handle(Geom_RectangularTrimmedSurface)*)&S1))->BasisSurface(); | |
1407 | typS1 = S1->DynamicType(); | |
1408 | } | |
1409 | ||
1410 | if (typS2 == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) { | |
1411 | S2 = (*((Handle(Geom_RectangularTrimmedSurface)*)&S2))->BasisSurface(); | |
1412 | typS2 = S2->DynamicType(); | |
1413 | } | |
1414 | ||
1415 | if (typS1 != typS2) { | |
1416 | return Standard_False; | |
1417 | } | |
1418 | ||
1419 | ||
1420 | Standard_Boolean ValRet = Standard_False; | |
1421 | if (typS1 == STANDARD_TYPE(Geom_Plane)) { | |
0d969553 | 1422 | S1 = BRep_Tool::Surface(F1); // to apply the location. |
7fd59977 | 1423 | S2 = BRep_Tool::Surface(F2); |
1424 | gp_Pln pl1( (*((Handle(Geom_Plane)*)&S1))->Pln()); | |
1425 | gp_Pln pl2( (*((Handle(Geom_Plane)*)&S2))->Pln()); | |
1426 | ||
1427 | if (pl1.Position().IsCoplanar(pl2.Position(),tollin,tolang)) { | |
1428 | ValRet = Standard_True; | |
1429 | } | |
1430 | } | |
1431 | ||
1432 | return ValRet; | |
1433 | } | |
1434 | ||
1435 | ||
1436 | ||
1437 | ||
1438 | ||
1439 |