From 5a3993c7b06b1f7b0d79e66af3411d9982cf2b62 Mon Sep 17 00:00:00 2001 From: jfa Date: Tue, 4 Apr 2023 14:51:11 +0100 Subject: [PATCH] [bos #33687] EDF 26791 - Points cloud on face --- src/GEOMAlgo/GEOMAlgo_AlgoTools.cxx | 45 +++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/src/GEOMAlgo/GEOMAlgo_AlgoTools.cxx b/src/GEOMAlgo/GEOMAlgo_AlgoTools.cxx index 7965b41a5..baa1ce94c 100644 --- a/src/GEOMAlgo/GEOMAlgo_AlgoTools.cxx +++ b/src/GEOMAlgo/GEOMAlgo_AlgoTools.cxx @@ -1178,8 +1178,11 @@ Standard_Integer GEOMAlgo_AlgoTools::PointCloudInFace(const TopoDS_Face& theFace aBB.Add (aGlobalRes, res); + int iface = 1; aBB.MakeCompound (theCompound); - for (TopExp_Explorer aGlobalExplo(aGlobalRes, TopAbs_FACE); aGlobalExplo.More(); aGlobalExplo.Next()) + for (TopExp_Explorer aGlobalExplo (aGlobalRes, TopAbs_FACE); + aGlobalExplo.More(), iface <= theNbPnts; + aGlobalExplo.Next(), iface++) { const TopoDS_Face& aFace = TopoDS::Face (aGlobalExplo.Current()); Standard_Boolean anIsNaturalRestrictions = Standard_True; @@ -1283,9 +1286,11 @@ gp_Pnt GetMidPnt2d(const TopoDS_Face& theFace, BRepTools_WireExplorer aWexp (aWire, theFace); Standard_Integer anInd = 0; + TopTools_MapOfShape aUsedEmap; for (; aWexp.More(); aWexp.Next()) { const TopoDS_Edge& anEdge = aWexp.Current(); + if (!aUsedEmap.Add(anEdge)) continue; BRepAdaptor_Curve2d aBAcurve2d (anEdge, theFace); Standard_Real aDelta = (aBAcurve2d.LastParameter() - aBAcurve2d.FirstParameter())/aNbSamples; for (Standard_Integer ii = 0; ii < aNbSamples; ii++) @@ -1353,6 +1358,9 @@ void ModifyFacesForGlobalResult(const TopoDS_Face& theInputFace, TopoDS_Shape& theGlobalRes, TopTools_MapOfShape& theRemovedFaces) { + BRepAdaptor_Surface aBAsurf (theInputFace, Standard_False); + GeomAbs_SurfaceType aType = aBAsurf.GetType(); + BRep_Builder aBB; const Standard_Integer aNbFaces = (Standard_Integer) theFacesAndAreas.size(); @@ -1363,11 +1371,11 @@ void ModifyFacesForGlobalResult(const TopoDS_Face& theInputFace, { Standard_Integer aNbFacesDone = 0, aNbFacesInTape = 0; TopoDS_Face aStartFace; - + Standard_Integer aStartIndex = (theIsToAddFaces)? aNbFaces-1 : 0; Standard_Integer anEndIndex = (theIsToAddFaces)? 0 : aNbFaces-1; Standard_Integer aStep = (theIsToAddFaces)? -1 : 1; - + for (Standard_Integer ii = aStartIndex; ii != anEndIndex; ii += aStep) { const TopoDS_Face& aFace = TopoDS::Face (theFacesAndAreas[ii].first); @@ -1381,7 +1389,7 @@ void ModifyFacesForGlobalResult(const TopoDS_Face& theInputFace, break; theRemovedFaces.Add (aStartFace); - + TopoDS_Edge aCommonEdge; TopoDS_Face aNextFace; Standard_Real anExtremalArea = (theIsToAddFaces)? 0. : Precision::Infinite(); @@ -1456,6 +1464,19 @@ void ModifyFacesForGlobalResult(const TopoDS_Face& theInputFace, if (aFace.IsSame (aStartFace)) { anIsRound = Standard_True; + if (aType > GeomAbs_Torus) { // non-elementary surfaces + // remove last face to prevent close tape creation + // it is a workaround for Tulip bos #26791 + // as there is a problem with closed tape on some surface types + aBB.Remove (aShell, aCurrentFace); + aNbFacesInTape--; + anAreaOfTape -= theFaceAreaMap(aCurrentFace); + aBB.Add(theRes, aCurrentFace); // aaajfa ??? + theRemovedFaces.Remove(aCurrentFace); + if (theExtremalFaces.Contains(aCurrentFace)) { + aNbFacesDone--; + } + } break; } if (theRemovedFaces.Contains(aFace)) @@ -1511,7 +1532,9 @@ void ModifyFacesForGlobalResult(const TopoDS_Face& theInputFace, if (aNewNumberToSplit < aNbFacesInTape) { Standard_Integer aNumberToIncrease = aNewNumberToSplit - aNumberToSplit; - for (Standard_Integer jj = theNbExtremalFaces; jj < theNbExtremalFaces + aNumberToIncrease; jj++) + for (Standard_Integer jj = theNbExtremalFaces; + jj < theNbExtremalFaces + aNumberToIncrease && jj < aNbFaces; + jj++) theExtremalFaces.Add (theFacesAndAreas[jj].first); theNbExtremalFaces += aNumberToIncrease; aNumberToSplit = aNewNumberToSplit; @@ -1521,7 +1544,9 @@ void ModifyFacesForGlobalResult(const TopoDS_Face& theInputFace, if (anIsRound && aNumberToSplit <= 1) { Standard_Integer aNumberToIncrease = 3 - aNumberToSplit; - for (Standard_Integer jj = theNbExtremalFaces; jj < theNbExtremalFaces + aNumberToIncrease; jj++) + for (Standard_Integer jj = theNbExtremalFaces; + jj < theNbExtremalFaces + aNumberToIncrease && jj < aNbFaces; + jj++) theExtremalFaces.Add (theFacesAndAreas[jj].first); theNbExtremalFaces += aNumberToIncrease; aNumberToSplit = 3; @@ -1556,8 +1581,10 @@ void ModifyFacesForGlobalResult(const TopoDS_Face& theInputFace, aNbFacesInLocalResult = 1; if (aNumberToSplit == 0) { - theExtremalFaces.Add (theFacesAndAreas[theNbExtremalFaces].first); - theNbExtremalFaces++; + if (theNbExtremalFaces < aNbFaces) { + theExtremalFaces.Add (theFacesAndAreas[theNbExtremalFaces].first); + theNbExtremalFaces++; + } } } aBB.Add (theGlobalRes, aLocalResult); @@ -1587,7 +1614,7 @@ void ModifyFacesForGlobalResult(const TopoDS_Face& theInputFace, if (aMaxNbFaces == 1) break; - + aBB.Remove (theGlobalRes, aMaxShell); //Find iso Standard_Boolean anIsUiso = Standard_True;