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