mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0027199: Unifysamedomain regression issue in OCCT 7
Allow to process the compounds in UnifySameDomain algorithm. Earlier only faces from shells were allowed to be unified. Test case for issue #27199
This commit is contained in:
parent
758bacbb66
commit
56091b56ac
@ -134,6 +134,41 @@ static Standard_Boolean IsLikeSeam(const TopoDS_Edge& anEdge,
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
static Standard_Boolean CheckSharedEdgeOri(const TopoDS_Face& theF1,
|
||||
const TopoDS_Face& theF2,
|
||||
const TopoDS_Edge& theE)
|
||||
{
|
||||
TopAbs_Orientation anEOri = theE.Orientation();
|
||||
if (anEOri == TopAbs_EXTERNAL || anEOri == TopAbs_INTERNAL)
|
||||
return Standard_False;
|
||||
|
||||
TopExp_Explorer Exp(theF1, TopAbs_EDGE);
|
||||
for (;Exp.More();Exp.Next())
|
||||
{
|
||||
const TopoDS_Shape& aCE = Exp.Current();
|
||||
if (aCE.IsSame(theE))
|
||||
{
|
||||
anEOri = aCE.Orientation();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (Exp.Init(theF2, TopAbs_EDGE);Exp.More();Exp.Next())
|
||||
{
|
||||
const TopoDS_Shape& aCE = Exp.Current();
|
||||
if (aCE.IsSame(theE))
|
||||
{
|
||||
if (aCE.Orientation() == TopAbs::Reverse(anEOri))
|
||||
return Standard_True;
|
||||
else
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
|
||||
return Standard_False;
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AddOrdinaryEdges
|
||||
//purpose : auxilary
|
||||
@ -1171,14 +1206,33 @@ void ShapeUpgrade_UnifySameDomain::UnifyFaces()
|
||||
TopTools_IndexedDataMapOfShapeListOfShape aGMapEdgeFaces;
|
||||
TopExp::MapShapesAndAncestors(myShape, TopAbs_EDGE, TopAbs_FACE, aGMapEdgeFaces);
|
||||
|
||||
// processing each shell
|
||||
// unify faces in each shell separately
|
||||
TopExp_Explorer exps;
|
||||
for (exps.Init(myShape, TopAbs_SHELL); exps.More(); exps.Next()) {
|
||||
TopoDS_Shell aShell = TopoDS::Shell(exps.Current());
|
||||
for (exps.Init(myShape, TopAbs_SHELL); exps.More(); exps.Next())
|
||||
IntUnifyFaces(exps.Current(), aGMapEdgeFaces, Standard_False);
|
||||
|
||||
// creating map of edge faces for the shell
|
||||
// gather all faces out of shells in one compound and unify them at once
|
||||
BRep_Builder aBB;
|
||||
TopoDS_Compound aCmp;
|
||||
aBB.MakeCompound(aCmp);
|
||||
Standard_Integer nbf = 0;
|
||||
for (exps.Init(myShape, TopAbs_FACE, TopAbs_SHELL); exps.More(); exps.Next(), nbf++)
|
||||
aBB.Add(aCmp, exps.Current());
|
||||
|
||||
if (nbf > 0)
|
||||
IntUnifyFaces(aCmp, aGMapEdgeFaces, Standard_True);
|
||||
|
||||
myShape = myContext->Apply(myShape);
|
||||
}
|
||||
|
||||
|
||||
void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape,
|
||||
const TopTools_IndexedDataMapOfShapeListOfShape& theGMapEdgeFaces,
|
||||
Standard_Boolean IsCheckSharedEdgeOri)
|
||||
{
|
||||
// creating map of edge faces for the shape
|
||||
TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces;
|
||||
TopExp::MapShapesAndAncestors(aShell, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces);
|
||||
TopExp::MapShapesAndAncestors(theInpShape, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces);
|
||||
|
||||
// map of processed shapes
|
||||
TopTools_MapOfShape aProcessed;
|
||||
@ -1191,14 +1245,14 @@ void ShapeUpgrade_UnifySameDomain::UnifyFaces()
|
||||
Standard_Integer nbf = 0;
|
||||
TopExp_Explorer exp;
|
||||
TopTools_MapOfShape mapF;
|
||||
for (exp.Init(aShell, TopAbs_FACE); exp.More(); exp.Next()) {
|
||||
for (exp.Init(theInpShape, TopAbs_FACE); exp.More(); exp.Next()) {
|
||||
if (mapF.Add(exp.Current()))
|
||||
nbf++;
|
||||
}
|
||||
|
||||
// processing each face
|
||||
mapF.Clear();
|
||||
for (exp.Init(aShell, TopAbs_FACE); exp.More(); exp.Next()) {
|
||||
for (exp.Init(theInpShape, TopAbs_FACE); exp.More(); exp.Next()) {
|
||||
TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD));
|
||||
|
||||
if (aProcessed.Contains(aFace))
|
||||
@ -1224,12 +1278,12 @@ void ShapeUpgrade_UnifySameDomain::UnifyFaces()
|
||||
continue;
|
||||
|
||||
// get connectivity of the edge in the global shape
|
||||
const TopTools_ListOfShape& aGList = aGMapEdgeFaces.FindFromKey(edge);
|
||||
const TopTools_ListOfShape& aGList = theGMapEdgeFaces.FindFromKey(edge);
|
||||
if (!myAllowInternal && aGList.Extent() != 2) {
|
||||
// non mainfold case is not processed unless myAllowInternal
|
||||
continue;
|
||||
}
|
||||
// process faces connected through the edge in the current shell
|
||||
// process faces connected through the edge in the current shape
|
||||
const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge);
|
||||
TopTools_ListIteratorOfListOfShape anIter(aList);
|
||||
for (; anIter.More(); anIter.Next()) {
|
||||
@ -1240,6 +1294,9 @@ void ShapeUpgrade_UnifySameDomain::UnifyFaces()
|
||||
if (aProcessed.Contains(anCheckedFace))
|
||||
continue;
|
||||
|
||||
if (IsCheckSharedEdgeOri && !CheckSharedEdgeOri(aFace, anCheckedFace, edge) )
|
||||
continue;
|
||||
|
||||
if (IsSameDomain(aFace,anCheckedFace)) {
|
||||
|
||||
// hotfix for 27271: prevent merging along periodic direction.
|
||||
@ -1278,7 +1335,7 @@ void ShapeUpgrade_UnifySameDomain::UnifyFaces()
|
||||
const TopTools_ListOfShape& aLF = aMapEF(i);
|
||||
if (aLF.Extent() == 2) {
|
||||
const TopoDS_Shape& aE = aMapEF.FindKey(i);
|
||||
const TopTools_ListOfShape& aGLF = aGMapEdgeFaces.FindFromKey(aE);
|
||||
const TopTools_ListOfShape& aGLF = theGMapEdgeFaces.FindFromKey(aE);
|
||||
if (aGLF.Extent() > 2) {
|
||||
aMultEdges.Append(aE);
|
||||
}
|
||||
@ -1584,7 +1641,7 @@ void ShapeUpgrade_UnifySameDomain::UnifyFaces()
|
||||
//TopoDS_Shape aResult = Shape;
|
||||
if (NbModif > 0 && !hasFailed) {
|
||||
//TopoDS_Shape aResult = aContext->Apply(aShell);
|
||||
TopoDS_Shape aResult = myContext->Apply(aShell);
|
||||
TopoDS_Shape aResult = myContext->Apply(theInpShape);
|
||||
|
||||
ShapeFix_Edge sfe;
|
||||
if (!myContext.IsNull()) sfe.SetContext(myContext);
|
||||
@ -1595,7 +1652,7 @@ void ShapeUpgrade_UnifySameDomain::UnifyFaces()
|
||||
sfe.FixSameParameter(E, Precision::Confusion());
|
||||
}
|
||||
|
||||
myContext->Replace(aShell, aResult);
|
||||
myContext->Replace(theInpShape, aResult);
|
||||
//for history
|
||||
/*
|
||||
if (!myOldNewMap.IsBound(aShell))
|
||||
@ -1610,7 +1667,7 @@ void ShapeUpgrade_UnifySameDomain::UnifyFaces()
|
||||
}
|
||||
//else
|
||||
{
|
||||
for (exp.Init(aShell, TopAbs_FACE); exp.More(); exp.Next()) {
|
||||
for (exp.Init(theInpShape, TopAbs_FACE); exp.More(); exp.Next()) {
|
||||
TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD));
|
||||
Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire;
|
||||
sfw->SetContext(myContext);
|
||||
@ -1626,9 +1683,7 @@ void ShapeUpgrade_UnifySameDomain::UnifyFaces()
|
||||
}
|
||||
}
|
||||
}
|
||||
} // end processing each shell
|
||||
|
||||
myShape = myContext->Apply(myShape);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <MMgt_TShared.hxx>
|
||||
#include <TopTools_DataMapOfShapeShape.hxx>
|
||||
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||
class ShapeBuild_ReShape;
|
||||
class TopoDS_Shape;
|
||||
|
||||
@ -94,6 +95,9 @@ protected:
|
||||
|
||||
private:
|
||||
|
||||
void IntUnifyFaces(const TopoDS_Shape& theInpShape,
|
||||
const TopTools_IndexedDataMapOfShapeListOfShape& theGMapEdgeFaces,
|
||||
Standard_Boolean IsCheckSharedEdgeOri);
|
||||
|
||||
TopoDS_Shape myInitShape;
|
||||
Standard_Boolean myUnifyFaces;
|
||||
|
19
tests/bugs/modalg_6/bug27199
Normal file
19
tests/bugs/modalg_6/bug27199
Normal file
@ -0,0 +1,19 @@
|
||||
puts "========"
|
||||
puts "OCC27199"
|
||||
puts "========"
|
||||
puts ""
|
||||
##############################################
|
||||
# Unifysamedomain regression issue in OCCT 7
|
||||
##############################################
|
||||
|
||||
restore [locate_data_file bug27199_i1_i2.brep] sh
|
||||
|
||||
explode sh
|
||||
bop sh_1 sh_2
|
||||
bopfuse r
|
||||
unifysamedom result r
|
||||
checkshape result
|
||||
|
||||
checknbshapes result -face 1
|
||||
|
||||
checkview -display result -2d -path ${imagedir}/${test_image}.png
|
Loading…
x
Reference in New Issue
Block a user