mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-04-24 08:12:03 +05:00
Bug 0020228: [CEA 331] the geompy.RemoveExtraEdges crash with the attached brep shape file.
This commit is contained in:
parent
cca851206f
commit
268965c6d9
@ -22,7 +22,7 @@
|
|||||||
// File: BlockFix_CheckTool.cxx
|
// File: BlockFix_CheckTool.cxx
|
||||||
// Created: 17.12.04 11:15:25
|
// Created: 17.12.04 11:15:25
|
||||||
// Author: Sergey KUUL
|
// Author: Sergey KUUL
|
||||||
//
|
|
||||||
#include <BlockFix_CheckTool.ixx>
|
#include <BlockFix_CheckTool.ixx>
|
||||||
|
|
||||||
#include <BRep_Tool.hxx>
|
#include <BRep_Tool.hxx>
|
||||||
@ -78,16 +78,23 @@ void BlockFix_CheckTool::Perform()
|
|||||||
myNbUF=0;
|
myNbUF=0;
|
||||||
myNbUE=0;
|
myNbUE=0;
|
||||||
myNbUFUE=0;
|
myNbUFUE=0;
|
||||||
TopExp_Explorer exps;
|
|
||||||
for(exps.Init(myShape, TopAbs_SOLID); exps.More(); exps.Next()) {
|
TopExp_Explorer exps (myShape, TopAbs_SOLID);
|
||||||
|
TopTools_MapOfShape mapS;
|
||||||
|
for (; exps.More(); exps.Next()) {
|
||||||
TopoDS_Solid aSolid = TopoDS::Solid(exps.Current());
|
TopoDS_Solid aSolid = TopoDS::Solid(exps.Current());
|
||||||
|
if (!mapS.Add(aSolid)) continue;
|
||||||
myNbSolids++;
|
myNbSolids++;
|
||||||
Standard_Boolean IsBlock=Standard_True;
|
Standard_Boolean IsBlock=Standard_True;
|
||||||
Standard_Boolean MayBeUF=Standard_False;
|
Standard_Boolean MayBeUF=Standard_False;
|
||||||
Standard_Boolean MayBeUE=Standard_False;
|
Standard_Boolean MayBeUE=Standard_False;
|
||||||
Standard_Integer nf=0;
|
Standard_Integer nf=0;
|
||||||
TopExp_Explorer expf;
|
TopExp_Explorer expf (aSolid, TopAbs_FACE);
|
||||||
for(expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) nf++;
|
TopTools_MapOfShape mapF;
|
||||||
|
for (; expf.More(); expf.Next()) {
|
||||||
|
if (mapF.Add(expf.Current()))
|
||||||
|
nf++;
|
||||||
|
}
|
||||||
|
|
||||||
if (nf < 6) {
|
if (nf < 6) {
|
||||||
IsBlock = Standard_False;
|
IsBlock = Standard_False;
|
||||||
@ -96,10 +103,13 @@ void BlockFix_CheckTool::Perform()
|
|||||||
IsBlock = Standard_False;
|
IsBlock = Standard_False;
|
||||||
// check faces unification
|
// check faces unification
|
||||||
TopTools_SequenceOfShape faces;
|
TopTools_SequenceOfShape faces;
|
||||||
|
mapF.Clear();
|
||||||
for (expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) {
|
for (expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) {
|
||||||
|
if (mapF.Add(expf.Current())) {
|
||||||
TopoDS_Face aFace = TopoDS::Face(expf.Current());
|
TopoDS_Face aFace = TopoDS::Face(expf.Current());
|
||||||
faces.Append(aFace);
|
faces.Append(aFace);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Standard_Boolean HasFacesForUnification = Standard_False;
|
Standard_Boolean HasFacesForUnification = Standard_False;
|
||||||
for (Standard_Integer i=1; i<faces.Length() && !HasFacesForUnification; i++) {
|
for (Standard_Integer i=1; i<faces.Length() && !HasFacesForUnification; i++) {
|
||||||
TopoDS_Face F1 = TopoDS::Face(faces.Value(i));
|
TopoDS_Face F1 = TopoDS::Face(faces.Value(i));
|
||||||
@ -131,37 +141,43 @@ void BlockFix_CheckTool::Perform()
|
|||||||
|
|
||||||
Standard_Integer nbe=0;
|
Standard_Integer nbe=0;
|
||||||
TopTools_MapOfShape DegenEdges;
|
TopTools_MapOfShape DegenEdges;
|
||||||
TopExp_Explorer expe;
|
TopExp_Explorer expe (aSolid, TopAbs_EDGE);
|
||||||
for(expe.Init(aSolid, TopAbs_EDGE); expe.More(); expe.Next()) {
|
TopTools_MapOfShape mapE;
|
||||||
|
for (; expe.More(); expe.Next()) {
|
||||||
TopoDS_Edge E = TopoDS::Edge(expe.Current());
|
TopoDS_Edge E = TopoDS::Edge(expe.Current());
|
||||||
|
if (!mapE.Add(E)) continue;
|
||||||
if (BRep_Tool::Degenerated(E)) {
|
if (BRep_Tool::Degenerated(E)) {
|
||||||
if(!DegenEdges.Contains(E)) {
|
|
||||||
DegenEdges.Add(E);
|
DegenEdges.Add(E);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
nbe++;
|
nbe++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( nbe==24 && DegenEdges.Extent()>0 ) {
|
if (nbe == 12 && DegenEdges.Extent() > 0) {
|
||||||
IsBlock = Standard_False;
|
IsBlock = Standard_False;
|
||||||
myNbDegen++;
|
myNbDegen++;
|
||||||
myPossibleBlocks.Append(aSolid);
|
myPossibleBlocks.Append(aSolid);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(nbe<24)
|
if (nbe < 12)
|
||||||
IsBlock = Standard_False;
|
IsBlock = Standard_False;
|
||||||
if(nbe>24) {
|
if (nbe > 12) {
|
||||||
IsBlock = Standard_False;
|
IsBlock = Standard_False;
|
||||||
// check edges unification
|
// check edges unification
|
||||||
// creating map of edge faces
|
// creating map of edge faces
|
||||||
TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces;
|
TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces;
|
||||||
TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces);
|
TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces);
|
||||||
|
|
||||||
|
mapF.Clear();
|
||||||
for (expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) {
|
for (expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) {
|
||||||
TopoDS_Face aFace = TopoDS::Face(expf.Current());
|
TopoDS_Face aFace = TopoDS::Face(expf.Current());
|
||||||
|
if (!mapF.Add(aFace)) continue;
|
||||||
TopTools_IndexedDataMapOfShapeListOfShape aMapFacesEdges;
|
TopTools_IndexedDataMapOfShapeListOfShape aMapFacesEdges;
|
||||||
|
|
||||||
|
TopTools_MapOfShape mapEe;
|
||||||
for (expe.Init(aFace, TopAbs_EDGE); expe.More(); expe.Next()) {
|
for (expe.Init(aFace, TopAbs_EDGE); expe.More(); expe.Next()) {
|
||||||
TopoDS_Edge edge = TopoDS::Edge(expe.Current());
|
TopoDS_Edge edge = TopoDS::Edge(expe.Current());
|
||||||
|
if (!mapEe.Add(edge)) continue;
|
||||||
if (!aMapEdgeFaces.Contains(edge)) continue;
|
if (!aMapEdgeFaces.Contains(edge)) continue;
|
||||||
const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge);
|
const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge);
|
||||||
TopTools_ListIteratorOfListOfShape anIter (aList);
|
TopTools_ListIteratorOfListOfShape anIter (aList);
|
||||||
@ -205,7 +221,6 @@ void BlockFix_CheckTool::Perform()
|
|||||||
myPossibleBlocks.Append(aSolid);
|
myPossibleBlocks.Append(aSolid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
myHasCheck = Standard_True;
|
myHasCheck = Standard_True;
|
||||||
|
@ -191,10 +191,19 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
|
|||||||
Standard_Integer NbModif = 0;
|
Standard_Integer NbModif = 0;
|
||||||
Standard_Boolean hasFailed = Standard_False;
|
Standard_Boolean hasFailed = Standard_False;
|
||||||
Standard_Real tol = Min(Max(Precision::Confusion(), myTolerance/10.), 0.1);
|
Standard_Real tol = Min(Max(Precision::Confusion(), myTolerance/10.), 0.1);
|
||||||
// processing each face
|
|
||||||
|
// count faces
|
||||||
|
int nbf = 0;
|
||||||
TopExp_Explorer exp;
|
TopExp_Explorer exp;
|
||||||
//for( exp.Init(Shape, TopAbs_FACE); exp.More(); exp.Next()) {
|
TopTools_MapOfShape mapF;
|
||||||
for (exp.Init(aSolid, TopAbs_FACE); exp.More(); exp.Next()) {
|
for (exp.Init(aSolid, TopAbs_FACE); exp.More(); exp.Next()) {
|
||||||
|
if (mapF.Add(exp.Current()))
|
||||||
|
nbf++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// processing each face
|
||||||
|
mapF.Clear();
|
||||||
|
for (exp.Init(aSolid, TopAbs_FACE); exp.More() && nbf > 6; exp.Next()) {
|
||||||
TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD));
|
TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD));
|
||||||
|
|
||||||
if (aProcessed.Contains(aFace))
|
if (aProcessed.Contains(aFace))
|
||||||
@ -372,13 +381,11 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
|
|||||||
B.Add(aW,E);
|
B.Add(aW,E);
|
||||||
B.Add(aResult,aW);
|
B.Add(aResult,aW);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// perform substitution of face
|
// perform substitution of face
|
||||||
aContext->Replace(aContext->Apply(aFace),aResult);
|
aContext->Replace(aContext->Apply(aFace),aResult);
|
||||||
|
|
||||||
|
|
||||||
ShapeFix_Face sff (aResult);
|
ShapeFix_Face sff (aResult);
|
||||||
//Intializing by tolerances
|
//Intializing by tolerances
|
||||||
sff.SetPrecision(myTolerance);
|
sff.SetPrecision(myTolerance);
|
||||||
@ -437,13 +444,11 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
|
|||||||
for(i = 2; i <= faces.Length(); i++)
|
for(i = 2; i <= faces.Length(); i++)
|
||||||
aContext->Remove(faces(i));
|
aContext->Remove(faces(i));
|
||||||
}
|
}
|
||||||
}
|
} // end processing each face
|
||||||
|
|
||||||
//TopoDS_Shape aResult = Shape;
|
//TopoDS_Shape aResult = Shape;
|
||||||
if(NbModif>0) {
|
if (NbModif > 0 && !hasFailed) {
|
||||||
TopoDS_Shape aResult = aSolid;
|
TopoDS_Shape aResult = aContext->Apply(aSolid);
|
||||||
if(!hasFailed) {
|
|
||||||
aResult = aContext->Apply(aSolid);
|
|
||||||
|
|
||||||
ShapeFix_Edge sfe;
|
ShapeFix_Edge sfe;
|
||||||
for (exp.Init(aResult,TopAbs_EDGE); exp.More(); exp.Next()) {
|
for (exp.Init(aResult,TopAbs_EDGE); exp.More(); exp.Next()) {
|
||||||
@ -455,8 +460,8 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
|
|||||||
|
|
||||||
myContext->Replace(aSolid, aResult);
|
myContext->Replace(aSolid, aResult);
|
||||||
}
|
}
|
||||||
}
|
//else
|
||||||
// else {
|
{
|
||||||
for (exp.Init(aSolid, TopAbs_FACE); exp.More(); exp.Next()) {
|
for (exp.Init(aSolid, TopAbs_FACE); exp.More(); exp.Next()) {
|
||||||
TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD));
|
TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD));
|
||||||
Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire;
|
Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire;
|
||||||
@ -472,8 +477,7 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
|
|||||||
sfw->FixShifted();
|
sfw->FixShifted();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
} // end processing each solid
|
} // end processing each solid
|
||||||
|
|
||||||
aResShape = myContext->Apply(Shape);
|
aResShape = myContext->Apply(Shape);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user