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