1 // Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : GEOMAlgo_AlgoTools.cxx
24 // Author : Peter KURNEV
26 #include <GEOMAlgo_AlgoTools.hxx>
28 #include <Basics_OCCTVersion.hxx>
31 #include <gp_Pnt2d.hxx>
32 #include <gp_Dir2d.hxx>
34 #include <Bnd_Box.hxx>
36 #include <BRepAdaptor_Curve2d.hxx>
37 #include <BRepTopAdaptor_FClass2d.hxx>
39 #include <Geom2d_Curve.hxx>
40 #include <Geom2d_TrimmedCurve.hxx>
41 #include <Geom2d_Line.hxx>
42 #include <Geom2d_TrimmedCurve.hxx>
44 #include <Geom2dHatch_Intersector.hxx>
45 #include <Geom2dHatch_Hatcher.hxx>
47 #include <Geom2dAdaptor_Curve.hxx>
48 #include <HatchGen_Domain.hxx>
50 #include <GeomLib.hxx>
51 #include <Geom_Curve.hxx>
52 #include <Geom_Surface.hxx>
54 #include <GeomAdaptor_Surface.hxx>
56 #include <GeomAPI_ProjectPointOnSurf.hxx>
57 #include <GeomAPI_ProjectPointOnCurve.hxx>
59 #include <GProp_GProps.hxx>
61 #include <Poly_Triangulation.hxx>
63 #include <TopAbs_Orientation.hxx>
65 #include <TopLoc_Location.hxx>
68 #include <TopoDS_Iterator.hxx>
69 #include <TopoDS_Face.hxx>
70 #include <TopoDS_Edge.hxx>
71 #include <TopoDS_Compound.hxx>
74 #include <TopExp_Explorer.hxx>
76 #include <BRep_Tool.hxx>
77 #include <BRep_Builder.hxx>
78 #include <BRepLib_MakeVertex.hxx>
80 #include <BRepTools.hxx>
81 #include <BRepTools_WireExplorer.hxx>
82 #include <BRepBndLib.hxx>
83 #include <BRepMesh_IncrementalMesh.hxx>
84 #include <BRepGProp.hxx>
86 #include <IntTools_Tools.hxx>
88 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
89 #include <TopTools_ListOfShape.hxx>
90 #include <TopTools_MapOfShape.hxx>
91 #include <TopTools_DataMapOfShapeReal.hxx>
92 #include <TColgp_SequenceOfPnt2d.hxx>
94 #include <TopTools_ListIteratorOfListOfShape.hxx>
95 #include <TopTools_IndexedMapOfShape.hxx>
96 #include <TopAbs_ShapeEnum.hxx>
98 #include <IntTools_Tools.hxx>
100 #include <BOPTools_AlgoTools3D.hxx>
101 #include <BOPTools_AlgoTools2D.hxx>
103 #include <ShapeUpgrade_ShapeDivideArea.hxx>
104 #include <ShapeUpgrade_UnifySameDomain.hxx>
106 #include <GEOMAlgo_PassKeyShape.hxx>
111 void GetCount(const TopoDS_Shape& aS,
112 Standard_Integer& iCnt);
114 void CopySource(const TopoDS_Shape& aS,
115 TopTools_IndexedDataMapOfShapeShape& aMapSS,
118 static Standard_Boolean comp(const std::pair<TopoDS_Shape, Standard_Real>& theA,
119 const std::pair<TopoDS_Shape, Standard_Real>& theB);
121 static Standard_Boolean IsUiso (const TopoDS_Edge& theEdge,
122 const TopoDS_Face& theFace);
124 static void CorrectShell (const TopoDS_Shape& theShell,
125 const TopoDS_Face& theFace);
127 static gp_Pnt GetMidPnt2d(const TopoDS_Face& theFace,
128 const Standard_Boolean theIsNaturalRestrictions);
130 static void ModifyFacesForGlobalResult(const TopoDS_Face& theInputFace,
131 const Standard_Real theAverageArea,
132 const Standard_Boolean theIsToAddFaces,
133 Standard_Integer& theNbExtremalFaces,
134 TopTools_MapOfShape& theExtremalFaces,
135 const std::vector<std::pair<TopoDS_Shape, Standard_Real>> theFacesAndAreas,
136 const TopTools_DataMapOfShapeReal& theFaceAreaMap,
137 const TopTools_IndexedDataMapOfShapeListOfShape& theEFmap,
138 TopoDS_Shape& theRes,
139 TopoDS_Shape& theGlobalRes,
140 TopTools_MapOfShape& theRemovedFaces);
142 //=======================================================================
143 //function : CopyShape
145 //=======================================================================
146 void GEOMAlgo_AlgoTools::CopyShape(const TopoDS_Shape& aS,
149 TopTools_IndexedDataMapOfShapeShape aMapSS;
151 CopySource(aS, aMapSS, aSC);
153 //=======================================================================
154 //function : CopyShape
156 //=======================================================================
157 void GEOMAlgo_AlgoTools::CopyShape(const TopoDS_Shape& aS,
159 TopTools_IndexedDataMapOfShapeShape& aMapSS)
161 CopySource(aS, aMapSS, aSC);
163 //=======================================================================
164 //function : CopySource
166 //=======================================================================
167 void CopySource(const TopoDS_Shape& aS,
168 TopTools_IndexedDataMapOfShapeShape& aMapSS,
171 Standard_Boolean bFree;
179 if (aMapSS.Contains(aS)) {
180 aSC=aMapSS.ChangeFromKey(aS);
181 aSC.Orientation(aS.Orientation());
185 aSC=aS.EmptyCopied();
190 aSC.Free(Standard_True);
192 if (aT==TopAbs_EDGE){
193 TopAbs_Orientation aOr;
195 aOr=aS.Orientation();
196 if(aOr==TopAbs_INTERNAL) {
197 aSF.Orientation(TopAbs_FORWARD);
201 for (; aIt.More(); aIt.Next()) {
204 const TopoDS_Shape& aSx=aIt.Value();
206 CopySource (aSx, aMapSS, aSCx);
208 aSCx.Orientation(aSx.Orientation());
213 //=======================================================================
214 //function : FaceNormal
216 //=======================================================================
217 void GEOMAlgo_AlgoTools::FaceNormal (const TopoDS_Face& aF,
218 const Standard_Real U,
219 const Standard_Real V,
224 Handle(Geom_Surface) aSurface;
226 aSurface=BRep_Tool::Surface(aF);
227 aSurface->D1 (U, V, aPnt, aD1U, aD1V);
228 aN=aD1U.Crossed(aD1V);
230 if (aF.Orientation() == TopAbs_REVERSED){
235 //=======================================================================
236 //function : BuildPCurveForEdgeOnFace
238 //=======================================================================
239 Standard_Integer GEOMAlgo_AlgoTools::BuildPCurveForEdgeOnFace
240 (const TopoDS_Edge& aEold,
241 const TopoDS_Edge& aEnew,
242 const TopoDS_Face& aF,
243 const Handle(IntTools_Context)& aCtx)
245 Standard_Boolean bIsClosed, bUClosed, bHasOld;
246 Standard_Integer iRet, aNbPoints;
247 Standard_Real aTS, aTS1, aTS2, aT, aT1, aT2, aScPr, aTol;
248 Standard_Real aU, aV, aUS1, aVS1, aUS2, aVS2;
250 gp_Pnt2d aP2DS1, aP2DS2, aP2D;
251 gp_Vec2d aV2DS1, aV2DS2;
252 Handle(Geom2d_Curve) aC2D, aC2DS1, aC2DS2;
253 Handle(Geom_Surface) aS;
258 bHasOld=BOPTools_AlgoTools2D::HasCurveOnSurface(aEnew, aF, aC2D, aT1, aT2, aTol);
263 // Try to copy PCurve from old edge to the new one.
264 iRet = BOPTools_AlgoTools2D::AttachExistingPCurve(aEold, aEnew, aF, aCtx);
267 // Do PCurve using projection algorithm.
270 // The PCurve is attached successfully.
274 BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(aEnew, aF);
275 aC2D=BRep_Tool::CurveOnSurface(aEnew, aF, aT1, aT2);
281 bIsClosed=BRep_Tool::IsClosed(aEold, aF);
288 // 1. bUClosed - direction of closeness
291 aES.Orientation(TopAbs_FORWARD);
292 aC2DS1=BRep_Tool::CurveOnSurface(aES, aF, aTS1, aTS2);
294 aES.Orientation(TopAbs_REVERSED);
295 aC2DS2=BRep_Tool::CurveOnSurface(aES, aF, aTS1, aTS2);
297 aTS=IntTools_Tools::IntermediatePoint(aTS1, aTS2);
299 aC2DS1->D1(aTS, aP2DS1, aV2DS1);
300 aC2DS2->D1(aTS, aP2DS2, aV2DS2);
302 gp_Vec2d aV2DS12(aP2DS1, aP2DS2);
303 gp_Dir2d aD2DS12(aV2DS12);
304 const gp_Dir2d& aD2DX=gp::DX2d();
307 bUClosed=Standard_True;
308 if (fabs(aScPr) < aTol) {
312 // 2. aP2D - point on curve aC2D, that corresponds to aP2DS1
313 aP2DS1.Coord(aUS1, aVS1);
314 aP2DS2.Coord(aUS2, aVS2);
316 aS=BRep_Tool::Surface(aF);
317 aS->D0(aUS1, aVS1, aP);
319 GeomAPI_ProjectPointOnCurve& aProjPC=aCtx->ProjPC(aEnew);
322 aNbPoints=aProjPC.NbPoints();
328 aT=aProjPC.LowerDistanceParameter();
331 // 3. Build the second 2D curve
332 Standard_Boolean bRevOrder;
333 gp_Vec2d aV2DT, aV2D;
334 Handle(Geom2d_Curve) aC2Dnew;
335 Handle(Geom2d_TrimmedCurve) aC2DTnew;
338 aC2D->D1(aT, aP2D, aV2D);
341 aC2Dnew=Handle(Geom2d_Curve)::DownCast(aC2D->Copy());
342 aC2DTnew = new Geom2d_TrimmedCurve(aC2Dnew, aT1, aT2);
345 if (!bUClosed) { // V Closed
346 if (fabs(aV-aVS2)<aTol) {
351 if (fabs(aU-aUS2)<aTol) {
356 aC2DTnew->Translate(aV2DT);
358 // 4 Order the 2D curves
359 bRevOrder=Standard_False;
362 bRevOrder=!bRevOrder;
365 // 5. Update the edge
366 aTol=BRep_Tool::Tolerance(aEnew);
368 aBB.UpdateEdge(aEnew, aC2D, aC2DTnew, aF, aTol);
371 aBB.UpdateEdge(aEnew, aC2DTnew, aC2D , aF, aTol);
376 //////////////////////////////////////////////////////////////////////////
377 //=======================================================================
378 // function: MakeContainer
380 //=======================================================================
381 void GEOMAlgo_AlgoTools::MakeContainer(const TopAbs_ShapeEnum theType,
387 case TopAbs_COMPOUND:{
389 aBB.MakeCompound(aC);
394 case TopAbs_COMPSOLID:{
395 TopoDS_CompSolid aCS;
396 aBB.MakeCompSolid(aCS);
403 aBB.MakeSolid(aSolid);
411 aBB.MakeShell(aShell);
427 //=======================================================================
428 //function : IsUPeriodic
430 //=======================================================================
431 Standard_Boolean GEOMAlgo_AlgoTools::IsUPeriodic(const Handle(Geom_Surface) &aS)
433 Standard_Boolean bRet;
434 GeomAbs_SurfaceType aType;
435 GeomAdaptor_Surface aGAS;
438 aType=aGAS.GetType();
439 bRet=(aType==GeomAbs_Cylinder||
440 aType==GeomAbs_Cone ||
441 aType==GeomAbs_Sphere);
446 //=======================================================================
447 //function : RefinePCurveForEdgeOnFace
449 //=======================================================================
450 void GEOMAlgo_AlgoTools::RefinePCurveForEdgeOnFace(const TopoDS_Edge& aE,
451 const TopoDS_Face& aF,
452 const Standard_Real aUMin,
453 const Standard_Real aUMax)
455 Standard_Real aT1, aT2, aTx, aUx, aTol;
457 Handle(Geom_Surface) aS;
458 Handle(Geom2d_Curve) aC2D;
461 aC2D=BRep_Tool::CurveOnSurface(aE, aF, aT1, aT2);
462 if (!aC2D.IsNull()) {
463 if (BRep_Tool::IsClosed(aE, aF)) {
466 aTx=IntTools_Tools::IntermediatePoint(aT1, aT2);
469 if (aUx < aUMin || aUx > aUMax) {
471 Handle(Geom2d_Curve) aC2Dx;
473 aTol=BRep_Tool::Tolerance(aE);
474 aBB.UpdateEdge(aE, aC2Dx, aF, aTol);
478 //=======================================================================
479 //function :IsSplitToReverse
481 //=======================================================================
482 Standard_Boolean GEOMAlgo_AlgoTools::IsSplitToReverse
483 (const TopoDS_Edge& aEF1,
484 const TopoDS_Edge& aEF2,
485 const Handle(IntTools_Context)& aContext)
487 Standard_Boolean aFlag;
488 Standard_Real aT1, aT2, aScPr, a, b;
493 Handle(Geom_Curve)aC1=BRep_Tool::Curve(aEF1, a, b);
494 aT1=IntTools_Tools::IntermediatePoint(a, b);
496 aFlag=BOPTools_AlgoTools2D::EdgeTangent(aEF1, aT1, aV1);
499 return Standard_False;
504 aFlag=aContext->ProjectPointOnEdge(aP, aEF2, aT2);
506 return Standard_False;
509 aFlag=BOPTools_AlgoTools2D::EdgeTangent(aEF2, aT2, aV2);
511 return Standard_False;
522 //=======================================================================
523 //function : ProjectPointOnShape
525 //=======================================================================
526 Standard_Boolean GEOMAlgo_AlgoTools::ProjectPointOnShape
528 const TopoDS_Shape& aS,
530 const Handle(IntTools_Context)& aCtx)
532 Standard_Boolean bIsDone = Standard_False;
534 TopAbs_ShapeEnum aType;
536 aType = aS.ShapeType();
541 const TopoDS_Edge& aE2 = TopoDS::Edge(aS);
543 if (BRep_Tool::Degenerated(aE2)) { // jfa
544 return Standard_True;
548 Handle(Geom_Curve) aC3D = BRep_Tool::Curve (aE2, f, l);
550 return Standard_True;
552 bIsDone = aCtx->ProjectPointOnEdge(aP1, aE2, aT2);
558 GEOMAlgo_AlgoTools::PointOnEdge(aE2, aT2, aP2);
564 const TopoDS_Face& aF2 = TopoDS::Face(aS);
565 GeomAPI_ProjectPointOnSurf& aProj = aCtx->ProjPS(aF2);
568 bIsDone = aProj.IsDone();
573 aP2 = aProj.NearestPoint();
583 //=======================================================================
584 //function : PointOnEdge
586 //=======================================================================
587 void GEOMAlgo_AlgoTools::PointOnEdge(const TopoDS_Edge& aE,
590 Standard_Real aTx, aT1, aT2;
592 BRep_Tool::Curve(aE, aT1, aT2);
593 aTx=IntTools_Tools::IntermediatePoint(aT1, aT2);
594 GEOMAlgo_AlgoTools::PointOnEdge(aE, aTx, aP3D);
596 //=======================================================================
597 //function : PointOnEdge
599 //=======================================================================
600 void GEOMAlgo_AlgoTools::PointOnEdge(const TopoDS_Edge& aE,
601 const Standard_Real aT,
604 Standard_Real aT1, aT2;
605 Handle(Geom_Curve) aC3D;
607 aC3D=BRep_Tool::Curve(aE, aT1, aT2);
610 //=======================================================================
611 //function : PointOnFace
613 //=======================================================================
614 void GEOMAlgo_AlgoTools::PointOnFace(const TopoDS_Face& aF,
615 const Standard_Real aU,
616 const Standard_Real aV,
619 Handle(Geom_Surface) aS;
621 aS=BRep_Tool::Surface(aF);
622 aS->D0(aU, aV, aP3D);
624 //=======================================================================
625 //function : PointOnFace
627 //=======================================================================
628 void GEOMAlgo_AlgoTools::PointOnFace(const TopoDS_Face& aF,
631 Standard_Real aU, aV, aUMin, aUMax, aVMin, aVMax;
633 BRepTools::UVBounds(aF, aUMin, aUMax, aVMin, aVMax);
635 aU=IntTools_Tools::IntermediatePoint(aUMin, aUMax);
636 aV=IntTools_Tools::IntermediatePoint(aVMin, aVMax);
638 GEOMAlgo_AlgoTools::PointOnFace(aF, aU, aV, aP3D);
640 //=======================================================================
641 //function : PointOnShape
643 //=======================================================================
644 void GEOMAlgo_AlgoTools::PointOnShape(const TopoDS_Shape& aS,
647 TopAbs_ShapeEnum aType;
649 aP3D.SetCoord(99.,99.,99.);
650 aType=aS.ShapeType();
653 const TopoDS_Edge& aE=TopoDS::Edge(aS);
654 GEOMAlgo_AlgoTools::PointOnEdge(aE, aP3D);
659 const TopoDS_Face& aF=TopoDS::Face(aS);
660 GEOMAlgo_AlgoTools::PointOnFace(aF, aP3D);
668 //=======================================================================
669 //function : FindSDShapes
671 //=======================================================================
672 Standard_Integer GEOMAlgo_AlgoTools::FindSDShapes
673 (const TopoDS_Shape& aE1,
674 const TopTools_ListOfShape& aLE,
675 const Standard_Real aTol,
676 TopTools_ListOfShape& aLESD,
677 const Handle(IntTools_Context)& aCtx)
679 Standard_Boolean bIsDone;
680 Standard_Real aTol2, aD2;
682 TopTools_ListIteratorOfListOfShape aIt;
685 GEOMAlgo_AlgoTools::PointOnShape(aE1, aP1);
688 for (; aIt.More(); aIt.Next()) {
689 const TopoDS_Shape& aE2=aIt.Value();
690 if (aE2.IsSame(aE1)) {
694 bIsDone=GEOMAlgo_AlgoTools::ProjectPointOnShape(aP1, aE2, aP2, aCtx);
697 continue; // jfa BUG 20361
699 aD2=aP1.SquareDistance(aP2);
708 //=======================================================================
709 //function : FindSDShapes
711 //=======================================================================
712 Standard_Integer GEOMAlgo_AlgoTools::FindSDShapes
713 (const TopTools_ListOfShape& aLE,
714 const Standard_Real aTol,
715 TopTools_IndexedDataMapOfShapeListOfShape& aMEE,
716 const Handle(IntTools_Context)& aCtx)
718 Standard_Integer aNbE, aNbEProcessed, aNbESD, iErr;
719 TopTools_ListOfShape aLESD;
720 TopTools_ListIteratorOfListOfShape aIt, aIt1;
721 TopTools_IndexedMapOfShape aMProcessed;
722 TopAbs_ShapeEnum aType;
729 return 0; // Nothing to do
733 aNbEProcessed=aMProcessed.Extent();
734 if (aNbEProcessed==aNbE) {
739 for (; aIt.More(); aIt.Next()) {
740 const TopoDS_Shape& aS=aIt.Value();
742 if (aMProcessed.Contains(aS)) {
746 aType=aS.ShapeType();
747 if (aType==TopAbs_EDGE) {
748 const TopoDS_Edge& aE=TopoDS::Edge(aS);
749 if (BRep_Tool::Degenerated(aE)) {
756 iErr=GEOMAlgo_AlgoTools::FindSDShapes(aS, aLE, aTol, aLESD, aCtx);
761 aNbESD=aLESD.Extent();
768 aIt1.Initialize(aLESD);
769 for (; aIt1.More(); aIt1.Next()) {
770 const TopoDS_Shape& aE1=aIt1.Value();
771 aMProcessed.Add(aE1);
777 //=======================================================================
778 //function : RefineSDShapes
780 //=======================================================================
781 Standard_Integer GEOMAlgo_AlgoTools::RefineSDShapes
782 (GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape& aMPKLE,
783 const Standard_Real aTol,
784 const Handle(IntTools_Context)& aCtx)
786 Standard_Integer i, aNbE, iErr, j, aNbEE, aNbToAdd;
787 TopTools_IndexedDataMapOfShapeListOfShape aMEE, aMSDE, aMEToAdd;
791 aNbE=aMPKLE.Extent();
792 for (i=1; i<=aNbE; ++i) {
793 TopTools_ListOfShape& aLSDE=aMPKLE.ChangeFromIndex(i);
796 iErr=GEOMAlgo_AlgoTools::FindSDShapes(aLSDE, aTol, aMEE, aCtx);
803 continue; // nothing to do
806 for (j=1; j<=aNbEE; ++j) {
807 TopTools_ListOfShape& aLEE=aMEE.ChangeFromIndex(j);
814 const TopoDS_Shape& aE1=aLEE.First();
815 aMEToAdd.Add(aE1, aLEE);
820 aNbToAdd=aMEToAdd.Extent();
825 for (i=1; i<=aNbToAdd; ++i) {
826 GEOMAlgo_PassKeyShape aPKE1;
828 const TopoDS_Shape& aE1=aMEToAdd.FindKey(i);
829 const TopTools_ListOfShape& aLE=aMEToAdd(i);
831 aPKE1.SetShapes(aE1);
832 aMPKLE.Add(aPKE1, aLE);
838 //=======================================================================
839 //function : IsCompositeShape
841 //=======================================================================
842 Standard_Boolean GEOMAlgo_AlgoTools::IsCompositeShape(const TopoDS_Shape& aS)
844 Standard_Boolean bRet;
845 Standard_Integer iCnt;
854 //=======================================================================
855 //function : GetCount
857 //=======================================================================
858 void GetCount(const TopoDS_Shape& aS,
859 Standard_Integer& iCnt)
862 TopAbs_ShapeEnum aTS;
866 if (aTS==TopAbs_SHAPE) {
869 if (aTS!=TopAbs_COMPOUND) {
875 for (; aIt.More(); aIt.Next()) {
876 const TopoDS_Shape& aSx=aIt.Value();
881 //=======================================================================
882 //function : PntInFace
884 //=======================================================================
885 Standard_Integer GEOMAlgo_AlgoTools::PntInFace(const TopoDS_Face& aF,
889 Standard_Boolean bIsDone, bHasFirstPoint, bHasSecondPoint;
890 Standard_Integer iErr, aIx, aNbDomains, i;
891 Standard_Real aUMin, aUMax, aVMin, aVMax;
892 Standard_Real aVx, aUx, aV1, aV2, aU1, aU2, aEpsT;
893 Standard_Real aTotArcIntr, aTolTangfIntr, aTolHatch2D, aTolHatch3D;
894 gp_Dir2d aD2D (0., 1.);
897 Handle(Geom2d_Curve) aC2D;
898 Handle(Geom2d_TrimmedCurve) aCT2D;
899 Handle(Geom2d_Line) aL2D;
900 Handle(Geom_Surface) aS;
901 TopAbs_Orientation aOrE;
903 TopExp_Explorer aExp;
908 aTolTangfIntr=1.e-10;
910 Geom2dHatch_Intersector aIntr(aTotArcIntr, aTolTangfIntr);
911 Geom2dHatch_Hatcher aHatcher(aIntr,
912 aTolHatch2D, aTolHatch3D,
913 Standard_True, Standard_False);
919 aFF.Orientation (TopAbs_FORWARD);
921 aS=BRep_Tool::Surface(aFF);
922 BRepTools::UVBounds(aFF, aUMin, aUMax, aVMin, aVMax);
925 aExp.Init (aFF, TopAbs_EDGE);
926 for (; aExp.More() ; aExp.Next()) {
927 const TopoDS_Edge& aE=*((TopoDS_Edge*)&aExp.Current());
928 aOrE=aE.Orientation();
930 aC2D=BRep_Tool::CurveOnSurface (aE, aFF, aU1, aU2);
931 if (aC2D.IsNull() ) {
935 if (fabs(aU1-aU2) < aEpsT) {
940 aCT2D=new Geom2d_TrimmedCurve(aC2D, aU1, aU2);
941 aHatcher.AddElement(aCT2D, aOrE);
942 }// for (; aExp.More() ; aExp.Next()) {
945 aUx=IntTools_Tools::IntermediatePoint(aUMin, aUMax);
946 aP2D.SetCoord(aUx, 0.);
947 aL2D=new Geom2d_Line (aP2D, aD2D);
948 Geom2dAdaptor_Curve aHCur(aL2D);
950 aIx=aHatcher.AddHatching(aHCur) ;
954 bIsDone=aHatcher.TrimDone(aIx);
960 aHatcher.ComputeDomains(aIx);
961 bIsDone=aHatcher.IsDone(aIx);
969 aNbDomains=aHatcher.NbDomains(aIx);
976 const HatchGen_Domain& aDomain=aHatcher.Domain (aIx, i) ;
977 bHasFirstPoint=aDomain.HasFirstPoint();
978 if (!bHasFirstPoint) {
983 aV1=aDomain.FirstPoint().Parameter();
985 bHasSecondPoint=aDomain.HasSecondPoint();
986 if (!bHasSecondPoint) {
991 aV2=aDomain.SecondPoint().Parameter();
993 aVx=IntTools_Tools::IntermediatePoint(aV1, aV2);
995 aS->D0(aUx, aVx, aPx);
997 theP2D.SetCoord(aUx, aVx);
1003 //=======================================================================
1004 //function : PointCloudInFace
1006 //=======================================================================
1007 Standard_Integer GEOMAlgo_AlgoTools::PointCloudInFace(const TopoDS_Face& theFace,
1008 const int theNbPnts,
1009 TopoDS_Compound& theCompound)
1011 #if OCC_VERSION_LARGE < 0x07050304
1014 ShapeUpgrade_ShapeDivideArea tool (theFace);
1015 tool.SetSplittingByNumber (Standard_True);
1016 tool.NbParts() = theNbPnts;
1018 TopoDS_Shape res = tool.Result();
1021 TopoDS_Compound aGlobalRes;
1022 aBB.MakeCompound (aGlobalRes);
1024 TopTools_IndexedMapOfShape aFaceMap;
1025 TopExp::MapShapes (res, TopAbs_FACE, aFaceMap);
1026 Standard_Integer aNbFaces = aFaceMap.Extent();
1028 TopTools_IndexedDataMapOfShapeListOfShape aEFmap;
1029 TopExp::MapShapesAndAncestors (res, TopAbs_EDGE, TopAbs_FACE, aEFmap);
1031 TopTools_MapOfShape aBiggestFaces, aSmallestFaces;
1032 Standard_Boolean aUseTriangulation = Standard_True;
1033 Standard_Boolean aSkipShared = Standard_False;
1034 if (aNbFaces != theNbPnts)
1036 Standard_Real aTotalArea = 0.;
1037 std::vector<std::pair<TopoDS_Shape, Standard_Real> > aFacesAndAreas (aNbFaces);
1038 for (Standard_Integer ii = 1; ii <= aNbFaces; ii++)
1040 GProp_GProps aProps;
1041 BRepGProp::SurfaceProperties (aFaceMap(ii), aProps, aSkipShared, aUseTriangulation);
1042 Standard_Real anArea = aProps.Mass();
1043 aTotalArea += anArea;
1044 std::pair<TopoDS_Shape, Standard_Real> aFaceWithArea (aFaceMap(ii), anArea);
1045 aFacesAndAreas[ii-1] = aFaceWithArea;
1047 std::sort (aFacesAndAreas.begin(), aFacesAndAreas.end(), comp);
1049 Standard_Real anAverageArea = aTotalArea / theNbPnts;
1051 TopTools_DataMapOfShapeReal aFaceAreaMap;
1052 for (Standard_Integer ii = 0; ii < aNbFaces; ii++)
1053 aFaceAreaMap.Bind (aFacesAndAreas[ii].first, aFacesAndAreas[ii].second);
1055 TopTools_MapOfShape aRemovedFaces;
1057 if (aNbFaces < theNbPnts)
1059 Standard_Integer aNbMissingFaces = theNbPnts - aNbFaces;
1060 for (Standard_Integer ii = aNbFaces-1; ii > aNbFaces - aNbMissingFaces - 1; ii--)
1061 aBiggestFaces.Add (aFacesAndAreas[ii].first);
1063 ModifyFacesForGlobalResult (theFace, anAverageArea,
1064 Standard_True, //to add faces
1065 aNbMissingFaces, aBiggestFaces,
1066 aFacesAndAreas, aFaceAreaMap, aEFmap,
1070 else //aNbFaces > theNbPnts
1072 Standard_Integer aNbExcessFaces = aNbFaces - theNbPnts;
1073 for (Standard_Integer ii = 0; ii < aNbExcessFaces; ii++)
1074 aSmallestFaces.Add (aFacesAndAreas[ii].first);
1076 TopTools_IndexedDataMapOfShapeListOfShape aVFmap;
1077 TopExp::MapShapesAndAncestors (res, TopAbs_VERTEX, TopAbs_FACE, aVFmap);
1079 //Remove smallest faces with free boundaries
1080 for (Standard_Integer ii = 0; ii < aNbExcessFaces; ii++)
1082 const TopoDS_Face& aFace = TopoDS::Face (aFacesAndAreas[ii].first);
1083 Standard_Boolean anIsFreeBoundFound = Standard_False;
1084 TopExp_Explorer anExplo (aFace, TopAbs_EDGE);
1085 for (; anExplo.More(); anExplo.Next())
1087 const TopoDS_Edge& anEdge = TopoDS::Edge (anExplo.Current());
1088 if (!BRep_Tool::Degenerated (anEdge) &&
1089 aEFmap.FindFromKey(anEdge).Extent() < 2)
1091 anIsFreeBoundFound = Standard_True;
1095 if (anIsFreeBoundFound)
1097 Standard_Real aMaxArea = 0.;
1098 for (anExplo.Init(aFace, TopAbs_VERTEX); anExplo.More(); anExplo.Next())
1100 const TopoDS_Shape& aVertex = anExplo.Current();
1101 const TopTools_ListOfShape& aFaceList = aVFmap.FindFromKey (aVertex);
1102 TopTools_ListIteratorOfListOfShape anItl (aFaceList);
1103 for (; anItl.More(); anItl.Next())
1105 Standard_Real anArea = aFaceAreaMap (anItl.Value());
1106 if (anArea > aMaxArea)
1110 Standard_Real anArreaOfSmallestFace = aFaceAreaMap (aFace);
1111 if (anArreaOfSmallestFace < aMaxArea / 16)
1113 aBB.Remove (res, aFace);
1114 aRemovedFaces.Add (aFace);
1119 ModifyFacesForGlobalResult (theFace, anAverageArea,
1120 Standard_False, //to decrease number of faces
1121 aNbExcessFaces, aSmallestFaces,
1122 aFacesAndAreas, aFaceAreaMap, aEFmap,
1128 aBB.Add (aGlobalRes, res);
1130 aBB.MakeCompound (theCompound);
1131 for (TopExp_Explorer aGlobalExplo(aGlobalRes, TopAbs_FACE); aGlobalExplo.More(); aGlobalExplo.Next())
1133 const TopoDS_Face& aFace = TopoDS::Face (aGlobalExplo.Current());
1134 Standard_Boolean anIsNaturalRestrictions = Standard_True;
1135 TopExp_Explorer anExplo (aFace, TopAbs_EDGE);
1136 for (; anExplo.More(); anExplo.Next())
1138 const TopoDS_Edge& anEdge = TopoDS::Edge (anExplo.Current());
1139 if (BRep_Tool::Degenerated (anEdge))
1141 if (!aEFmap.Contains(anEdge) ||
1142 aEFmap.FindFromKey(anEdge).Extent() < 2)
1144 anIsNaturalRestrictions = Standard_False;
1149 gp_Pnt aPnt = GetMidPnt2d (aFace, anIsNaturalRestrictions);
1150 TopoDS_Vertex aVertex = BRepLib_MakeVertex (aPnt);
1151 aBB.Add (theCompound, aVertex);
1158 Standard_Boolean comp(const std::pair<TopoDS_Shape, Standard_Real>& theA,
1159 const std::pair<TopoDS_Shape, Standard_Real>& theB)
1161 return (theA.second < theB.second);
1164 Standard_Boolean IsUiso (const TopoDS_Edge& theEdge,
1165 const TopoDS_Face& theFace)
1167 BRepAdaptor_Curve2d aBAcurve2d (theEdge, theFace);
1170 aBAcurve2d.D1 (aBAcurve2d.FirstParameter(), aP2d, aVec);
1171 return (Abs(aVec.Y()) > Abs(aVec.X()));
1174 void CorrectShell (const TopoDS_Shape& theShell,
1175 const TopoDS_Face& theFace)
1177 BRepAdaptor_Surface aBAsurf (theFace, Standard_False);
1178 GeomAbs_SurfaceType aType = aBAsurf.GetType();
1179 if (aType <= GeomAbs_Torus) //elementary surfaces
1182 TopLoc_Location anInputLoc;
1183 const Handle(Geom_Surface)& anInputSurf = BRep_Tool::Surface (theFace, anInputLoc);
1187 TopoDS_Iterator anIter (theShell);
1188 for (; anIter.More(); anIter.Next())
1190 const TopoDS_Face& aFace = TopoDS::Face (anIter.Value());
1191 TopLoc_Location aLoc;
1192 const Handle(Geom_Surface)& aSurf = BRep_Tool::Surface (aFace, aLoc);
1193 if (aSurf == anInputSurf)
1196 TopExp_Explorer anExplo (aFace, TopAbs_EDGE);
1197 for (; anExplo.More(); anExplo.Next())
1199 const TopoDS_Edge& anEdge = TopoDS::Edge (anExplo.Current());
1200 Standard_Real aFirst, aLast;
1201 Handle(Geom2d_Curve) aPCurve = BRep_Tool::CurveOnSurface (anEdge, aFace, aFirst, aLast);
1202 aBB.UpdateEdge (anEdge, aPCurve, anInputSurf, anInputLoc, 0.);
1204 Standard_Real aTol = BRep_Tool::Tolerance (aFace);
1205 aBB.UpdateFace (aFace, anInputSurf, anInputLoc, aTol);
1209 gp_Pnt GetMidPnt2d(const TopoDS_Face& theFace,
1210 const Standard_Boolean theIsNaturalRestrictions)
1214 if (theIsNaturalRestrictions)
1216 BRepAdaptor_Surface aBAsurf (theFace);
1217 Standard_Real aUmin, aUmax, aVmin, aVmax;
1218 aUmin = aBAsurf.FirstUParameter();
1219 aUmax = aBAsurf.LastUParameter();
1220 aVmin = aBAsurf.FirstVParameter();
1221 aVmax = aBAsurf.LastVParameter();
1222 aResPnt = aBAsurf.Value ((aUmin + aUmax)/2, (aVmin + aVmax)/2);
1226 const Standard_Integer aNbSamples = 4;
1227 TopoDS_Wire aWire = BRepTools::OuterWire (theFace);
1228 TopTools_IndexedMapOfShape aEmap;
1229 TopExp::MapShapes (aWire, TopAbs_EDGE, aEmap);
1230 Standard_Integer aNbPointsOnContour = aNbSamples * aEmap.Extent();
1231 TColgp_Array1OfPnt anArray (1, aNbPointsOnContour);
1233 BRepTools_WireExplorer aWexp (aWire, theFace);
1234 Standard_Integer anInd = 0;
1235 for (; aWexp.More(); aWexp.Next())
1237 const TopoDS_Edge& anEdge = aWexp.Current();
1238 BRepAdaptor_Curve2d aBAcurve2d (anEdge, theFace);
1239 Standard_Real aDelta = (aBAcurve2d.LastParameter() - aBAcurve2d.FirstParameter())/aNbSamples;
1240 for (Standard_Integer ii = 0; ii < aNbSamples; ii++)
1242 Standard_Real aParam = aBAcurve2d.FirstParameter() + ii * aDelta;
1243 gp_Pnt2d aP2d = aBAcurve2d.Value (aParam);
1244 gp_Pnt aPnt (aP2d.X(), aP2d.Y(), 0.);
1245 anArray (++anInd) = aPnt;
1250 Standard_Boolean anIsSingular;
1251 GeomLib::AxeOfInertia (anArray, anAxis, anIsSingular);
1252 gp_Pnt aBaryCentre = anAxis.Location();
1253 gp_Pnt2d aCentre2d (aBaryCentre.X(), aBaryCentre.Y());
1254 BRepTopAdaptor_FClass2d aClassifier (theFace, Precision::Confusion());
1255 BRepAdaptor_Surface aBAsurf (theFace, Standard_False);
1257 TopAbs_State aStatus = aClassifier.Perform (aCentre2d);
1258 gp_Pnt2d aP2d = aCentre2d;
1259 Standard_Integer anIndVertex = 0;
1260 const Standard_Integer aNbIter = 10;
1261 while (aStatus != TopAbs_IN && anIndVertex < aNbPointsOnContour)
1263 gp_Pnt aVertexPnt = anArray (anIndVertex+1);
1264 gp_Pnt2d aVertexP2d (aVertexPnt.X(), aVertexPnt.Y());
1265 TColgp_SequenceOfPnt2d aPseq;
1266 aPseq.Append (aCentre2d);
1267 aPseq.Append (aVertexP2d);
1268 for (Standard_Integer ii = 1; ii <= aNbIter; ii++)
1270 for (Standard_Integer jj = 1; jj < aPseq.Length(); jj++)
1272 aP2d.SetXY ((aPseq(jj).XY() + aPseq(jj+1).XY())/2);
1273 aStatus = aClassifier.Perform (aP2d);
1274 if (aStatus == TopAbs_IN)
1278 aPseq.InsertAfter (jj, aP2d);
1282 if (aStatus == TopAbs_IN)
1285 anIndVertex += aNbSamples;
1287 aResPnt = aBAsurf.Value (aP2d.X(), aP2d.Y());
1288 } //case of complex boundaries
1293 void ModifyFacesForGlobalResult(const TopoDS_Face& theInputFace,
1294 const Standard_Real theAverageArea,
1295 const Standard_Boolean theIsToAddFaces,
1296 Standard_Integer& theNbExtremalFaces,
1297 TopTools_MapOfShape& theExtremalFaces,
1298 const std::vector<std::pair<TopoDS_Shape, Standard_Real>> theFacesAndAreas,
1299 const TopTools_DataMapOfShapeReal& theFaceAreaMap,
1300 const TopTools_IndexedDataMapOfShapeListOfShape& theEFmap,
1301 TopoDS_Shape& theRes,
1302 TopoDS_Shape& theGlobalRes,
1303 TopTools_MapOfShape& theRemovedFaces)
1306 const Standard_Integer aNbFaces = (Standard_Integer) theFacesAndAreas.size();
1308 const Standard_Integer aDiff = theNbExtremalFaces - theRemovedFaces.Extent();
1310 Standard_Integer aSum = 0;
1311 while (aSum < aDiff) //global loop
1313 Standard_Integer aNbFacesDone = 0, aNbFacesInTape = 0;
1314 TopoDS_Face aStartFace;
1316 Standard_Integer aStartIndex = (theIsToAddFaces)? aNbFaces-1 : 0;
1317 Standard_Integer anEndIndex = (theIsToAddFaces)? 0 : aNbFaces-1;
1318 Standard_Integer aStep = (theIsToAddFaces)? -1 : 1;
1320 for (Standard_Integer ii = aStartIndex; ii != anEndIndex; ii += aStep)
1322 const TopoDS_Face& aFace = TopoDS::Face (theFacesAndAreas[ii].first);
1323 if (!theRemovedFaces.Contains(aFace))
1329 if (aStartFace.IsNull())
1332 theRemovedFaces.Add (aStartFace);
1334 TopoDS_Edge aCommonEdge;
1335 TopoDS_Face aNextFace;
1336 Standard_Real anExtremalArea = (theIsToAddFaces)? 0. : Precision::Infinite();
1337 for (TopExp_Explorer anExplo(aStartFace, TopAbs_EDGE); anExplo.More(); anExplo.Next())
1339 const TopoDS_Edge& anEdge = TopoDS::Edge (anExplo.Current());
1340 const TopTools_ListOfShape& aFaceList = theEFmap.FindFromKey (anEdge);
1341 TopTools_ListIteratorOfListOfShape anItl (aFaceList);
1342 for (; anItl.More(); anItl.Next())
1344 const TopoDS_Face& aFace = TopoDS::Face (anItl.Value());
1345 if (aFace.IsSame (aStartFace) ||
1346 theRemovedFaces.Contains(aFace))
1348 Standard_Real anArea = theFaceAreaMap(aFace);
1349 Standard_Boolean anIsToExchange = (theIsToAddFaces)? (anArea > anExtremalArea) : (anArea < anExtremalArea);
1352 anExtremalArea = anArea;
1353 aCommonEdge = anEdge;
1358 if (aCommonEdge.IsNull()) //all adjacent faces are already removed
1360 theExtremalFaces.Add (theFacesAndAreas[theNbExtremalFaces].first);
1361 theNbExtremalFaces++;
1365 //Start filling the shell
1366 aBB.Remove (theRes, aStartFace);
1368 TopoDS_Shell aShell;
1369 aBB.MakeShell (aShell);
1370 Standard_Real anAreaOfTape = 0.;
1371 aBB.Add (aShell, aStartFace);
1373 anAreaOfTape += theFaceAreaMap (aStartFace);
1375 Standard_Boolean anIsUiso = IsUiso (aCommonEdge, aStartFace);
1376 //Find another faces on this level
1377 TopoDS_Face aCurrentFace = aNextFace;
1378 TopoDS_Edge aCurrentEdge = aCommonEdge;
1379 Standard_Boolean anIsFirstDirection = Standard_True;
1380 aBB.Remove (theRes, aCurrentFace);
1381 theRemovedFaces.Add (aCurrentFace);
1382 if (theExtremalFaces.Contains (aCurrentFace))
1386 aBB.Add (aShell, aCurrentFace);
1388 anAreaOfTape += theFaceAreaMap (aCurrentFace);
1389 Standard_Boolean anIsRound = Standard_False;
1390 for (;;) //local loop
1392 TopoDS_Edge aNextEdge;
1393 for (TopExp_Explorer anExplo(aCurrentFace, TopAbs_EDGE); anExplo.More(); anExplo.Next())
1395 const TopoDS_Edge& anEdge = TopoDS::Edge (anExplo.Current());
1396 if (anEdge.IsSame (aCurrentEdge))
1398 const TopTools_ListOfShape& aFaceList = theEFmap.FindFromKey (anEdge);
1399 TopTools_ListIteratorOfListOfShape anItl (aFaceList);
1400 for (; anItl.More(); anItl.Next())
1402 const TopoDS_Face& aFace = TopoDS::Face (anItl.Value());
1403 if (aFace.IsSame (aCurrentFace))
1405 if (aFace.IsSame (aStartFace))
1407 anIsRound = Standard_True;
1410 if (theRemovedFaces.Contains(aFace))
1412 if (anIsUiso == IsUiso (anEdge, aFace))
1419 if (anIsRound || !aNextEdge.IsNull())
1422 if (anIsRound) //round tape: returned to start face
1424 if (aNextEdge.IsNull())
1426 if (anIsFirstDirection)
1428 aCurrentFace = aStartFace;
1429 aCurrentEdge = aCommonEdge;
1430 anIsFirstDirection = Standard_False;
1437 aBB.Add (aShell, aNextFace);
1439 anAreaOfTape += theFaceAreaMap (aNextFace);
1440 aBB.Remove (theRes, aNextFace);
1441 theRemovedFaces.Add (aNextFace);
1442 if (theExtremalFaces.Contains (aNextFace))
1446 aCurrentEdge = aNextEdge;
1447 aNextEdge.Nullify();
1448 aCurrentFace = aNextFace;
1449 } //end of local loop
1452 Standard_Integer aNumberToSplit = (theIsToAddFaces)? aNbFacesInTape + aNbFacesDone : aNbFacesInTape - aNbFacesDone;
1453 if (!theIsToAddFaces && aNbFacesDone > 1)
1455 Standard_Integer aRealNumberToSplit = (aNumberToSplit > 0)? aNumberToSplit : 1;
1456 Standard_Real anAverageAreaInTape = anAreaOfTape / aRealNumberToSplit;
1457 if (anAverageAreaInTape > theAverageArea)
1459 Standard_Integer aNewNumberToSplit = RealToInt(round(anAreaOfTape / theAverageArea));
1460 if (aNewNumberToSplit < aNbFacesInTape)
1462 Standard_Integer aNumberToIncrease = aNewNumberToSplit - aNumberToSplit;
1463 for (Standard_Integer jj = theNbExtremalFaces; jj < theNbExtremalFaces + aNumberToIncrease; jj++)
1464 theExtremalFaces.Add (theFacesAndAreas[jj].first);
1465 theNbExtremalFaces += aNumberToIncrease;
1466 aNumberToSplit = aNewNumberToSplit;
1470 if (anIsRound && aNumberToSplit <= 1)
1472 Standard_Integer aNumberToIncrease = 3 - aNumberToSplit;
1473 for (Standard_Integer jj = theNbExtremalFaces; jj < theNbExtremalFaces + aNumberToIncrease; jj++)
1474 theExtremalFaces.Add (theFacesAndAreas[jj].first);
1475 theNbExtremalFaces += aNumberToIncrease;
1478 CorrectShell (aShell, theInputFace);
1479 ShapeUpgrade_UnifySameDomain aUnifier;
1480 aUnifier.Initialize (aShell, Standard_True, Standard_True);
1482 TopoDS_Shape aUnifiedShape = aUnifier.Shape();
1484 TopoDS_Shape aLocalResult = aUnifiedShape;
1485 Standard_Integer aNbFacesInLocalResult;
1486 if (aNumberToSplit > 1)
1488 #if OCC_VERSION_LARGE < 0x07050304
1489 aNbFacesInLocalResult = 0;
1491 ShapeUpgrade_ShapeDivideArea aLocalTool (aUnifiedShape);
1492 aLocalTool.SetSplittingByNumber (Standard_True);
1493 aLocalTool.MaxArea() = -1;
1495 aLocalTool.SetNumbersUVSplits (aNumberToSplit, 1);
1497 aLocalTool.SetNumbersUVSplits (1, aNumberToSplit);
1498 aLocalTool.Perform();
1499 aLocalResult = aLocalTool.Result();
1500 aNbFacesInLocalResult = aNumberToSplit;
1505 aNbFacesInLocalResult = 1;
1506 if (aNumberToSplit == 0)
1508 theExtremalFaces.Add (theFacesAndAreas[theNbExtremalFaces].first);
1509 theNbExtremalFaces++;
1512 aBB.Add (theGlobalRes, aLocalResult);
1514 aSum += Abs(aNbFacesInTape - aNbFacesInLocalResult);
1515 } //end of global loop
1517 //Second global loop
1518 TopoDS_Compound aSecondComp;
1519 aBB.MakeCompound (aSecondComp);
1520 while (aSum < aDiff)
1522 TopoDS_Shape aMaxShell;
1523 Standard_Integer aMaxNbFaces = 0;
1524 TopoDS_Iterator anIter (theGlobalRes);
1525 for (; anIter.More(); anIter.Next())
1527 const TopoDS_Shape& aShell = anIter.Value();
1528 TopTools_IndexedMapOfShape aFaceMap;
1529 TopExp::MapShapes (aShell, TopAbs_FACE, aFaceMap);
1530 if (aFaceMap.Extent() > aMaxNbFaces)
1532 aMaxNbFaces = aFaceMap.Extent();
1537 if (aMaxNbFaces == 1)
1540 aBB.Remove (theGlobalRes, aMaxShell);
1542 Standard_Boolean anIsUiso = Standard_True;
1543 TopTools_IndexedDataMapOfShapeListOfShape aLocalEFmap;
1544 TopExp::MapShapesAndAncestors (aMaxShell, TopAbs_EDGE, TopAbs_FACE, aLocalEFmap);
1545 for (Standard_Integer jj = 1; jj <= aLocalEFmap.Extent(); jj++)
1547 const TopoDS_Edge& anEdge = TopoDS::Edge (aLocalEFmap.FindKey(jj));
1548 const TopTools_ListOfShape& aFaceList = aLocalEFmap(jj);
1549 if (aFaceList.Extent() == 2)
1551 const TopoDS_Face& aFace = TopoDS::Face (aFaceList.First());
1552 anIsUiso = IsUiso (anEdge, aFace);
1556 CorrectShell (aMaxShell, theInputFace);
1557 ShapeUpgrade_UnifySameDomain aUnifier;
1558 aUnifier.Initialize (aMaxShell, Standard_True, Standard_True);
1560 TopoDS_Shape aUnifiedShape = aUnifier.Shape();
1561 TopoDS_Shape aLocalResult = aUnifiedShape;
1563 Standard_Integer aNumberToSplit = (theIsToAddFaces)? aMaxNbFaces + (aDiff-aSum) : aMaxNbFaces - (aDiff-aSum);
1564 if (aNumberToSplit > 1)
1566 #if OCC_VERSION_LARGE < 0x07050304
1569 ShapeUpgrade_ShapeDivideArea aLocalTool (aUnifiedShape);
1570 aLocalTool.SetSplittingByNumber (Standard_True);
1571 aLocalTool.MaxArea() = -1;
1573 aLocalTool.SetNumbersUVSplits (aNumberToSplit, 1);
1575 aLocalTool.SetNumbersUVSplits (1, aNumberToSplit);
1576 aLocalTool.Perform();
1577 aLocalResult = aLocalTool.Result();
1583 aBB.Add (aSecondComp, aLocalResult);
1585 if (theIsToAddFaces)
1587 aSum += aMaxNbFaces - aNumberToSplit;
1589 aBB.Add (theGlobalRes, aSecondComp);