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