Bug 0020228: [CEA 331] the geompy.RemoveExtraEdges crash with the attached brep shape file.

This commit is contained in:
jfa 2009-04-10 09:14:35 +00:00
parent cca851206f
commit 268965c6d9
2 changed files with 116 additions and 97 deletions

View File

@ -22,7 +22,7 @@
// File: BlockFix_CheckTool.cxx
// Created: 17.12.04 11:15:25
// Author: Sergey KUUL
//
#include <BlockFix_CheckTool.ixx>
#include <BRep_Tool.hxx>
@ -78,16 +78,23 @@ void BlockFix_CheckTool::Perform()
myNbUF=0;
myNbUE=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());
if (!mapS.Add(aSolid)) continue;
myNbSolids++;
Standard_Boolean IsBlock=Standard_True;
Standard_Boolean MayBeUF=Standard_False;
Standard_Boolean MayBeUE=Standard_False;
Standard_Integer nf=0;
TopExp_Explorer expf;
for(expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) nf++;
TopExp_Explorer expf (aSolid, TopAbs_FACE);
TopTools_MapOfShape mapF;
for (; expf.More(); expf.Next()) {
if (mapF.Add(expf.Current()))
nf++;
}
if (nf < 6) {
IsBlock = Standard_False;
@ -96,10 +103,13 @@ void BlockFix_CheckTool::Perform()
IsBlock = Standard_False;
// check faces unification
TopTools_SequenceOfShape faces;
mapF.Clear();
for (expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) {
if (mapF.Add(expf.Current())) {
TopoDS_Face aFace = TopoDS::Face(expf.Current());
faces.Append(aFace);
}
}
Standard_Boolean HasFacesForUnification = Standard_False;
for (Standard_Integer i=1; i<faces.Length() && !HasFacesForUnification; i++) {
TopoDS_Face F1 = TopoDS::Face(faces.Value(i));
@ -131,37 +141,43 @@ void BlockFix_CheckTool::Perform()
Standard_Integer nbe=0;
TopTools_MapOfShape DegenEdges;
TopExp_Explorer expe;
for(expe.Init(aSolid, TopAbs_EDGE); expe.More(); expe.Next()) {
TopExp_Explorer expe (aSolid, TopAbs_EDGE);
TopTools_MapOfShape mapE;
for (; expe.More(); expe.Next()) {
TopoDS_Edge E = TopoDS::Edge(expe.Current());
if (!mapE.Add(E)) continue;
if (BRep_Tool::Degenerated(E)) {
if(!DegenEdges.Contains(E)) {
DegenEdges.Add(E);
}
}
else {
nbe++;
}
}
if( nbe==24 && DegenEdges.Extent()>0 ) {
if (nbe == 12 && DegenEdges.Extent() > 0) {
IsBlock = Standard_False;
myNbDegen++;
myPossibleBlocks.Append(aSolid);
continue;
}
if(nbe<24)
if (nbe < 12)
IsBlock = Standard_False;
if(nbe>24) {
if (nbe > 12) {
IsBlock = Standard_False;
// check edges unification
// creating map of edge faces
TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces;
TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces);
mapF.Clear();
for (expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) {
TopoDS_Face aFace = TopoDS::Face(expf.Current());
if (!mapF.Add(aFace)) continue;
TopTools_IndexedDataMapOfShapeListOfShape aMapFacesEdges;
TopTools_MapOfShape mapEe;
for (expe.Init(aFace, TopAbs_EDGE); expe.More(); expe.Next()) {
TopoDS_Edge edge = TopoDS::Edge(expe.Current());
if (!mapEe.Add(edge)) continue;
if (!aMapEdgeFaces.Contains(edge)) continue;
const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge);
TopTools_ListIteratorOfListOfShape anIter (aList);
@ -205,7 +221,6 @@ void BlockFix_CheckTool::Perform()
myPossibleBlocks.Append(aSolid);
}
}
}
myHasCheck = Standard_True;

View File

@ -191,10 +191,19 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
Standard_Integer NbModif = 0;
Standard_Boolean hasFailed = Standard_False;
Standard_Real tol = Min(Max(Precision::Confusion(), myTolerance/10.), 0.1);
// processing each face
// count faces
int nbf = 0;
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()) {
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));
if (aProcessed.Contains(aFace))
@ -372,13 +381,11 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
B.Add(aW,E);
B.Add(aResult,aW);
}
}
// perform substitution of face
aContext->Replace(aContext->Apply(aFace),aResult);
ShapeFix_Face sff (aResult);
//Intializing by tolerances
sff.SetPrecision(myTolerance);
@ -437,13 +444,11 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
for(i = 2; i <= faces.Length(); i++)
aContext->Remove(faces(i));
}
}
} // end processing each face
//TopoDS_Shape aResult = Shape;
if(NbModif>0) {
TopoDS_Shape aResult = aSolid;
if(!hasFailed) {
aResult = aContext->Apply(aSolid);
if (NbModif > 0 && !hasFailed) {
TopoDS_Shape aResult = aContext->Apply(aSolid);
ShapeFix_Edge sfe;
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);
}
}
// else {
//else
{
for (exp.Init(aSolid, TopAbs_FACE); exp.More(); exp.Next()) {
TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD));
Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire;
@ -472,8 +477,7 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
sfw->FixShifted();
}
}
// }
}
} // end processing each solid
aResShape = myContext->Apply(Shape);