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