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