Fixed method GetSame for the case of two cylindrical surfaces that are part of the same cylinder. BugID 16374

This commit is contained in:
srn 2007-06-25 07:47:47 +00:00
parent b319304bd7
commit 2c83fef4e1

View File

@ -2827,6 +2827,7 @@ static bool isSameFace(const TopoDS_Face& theFace1, const TopoDS_Face& theFace2)
if(P.Z() > zmaxB2) zmaxB2 = P.Z(); if(P.Z() > zmaxB2) zmaxB2 = P.Z();
} }
//Compare the bounding boxes of both faces //Compare the bounding boxes of both faces
if(gp_Pnt(xminB1, yminB1, zminB1).Distance(gp_Pnt(xminB2, yminB2, zminB2)) > MAX_TOLERANCE) if(gp_Pnt(xminB1, yminB1, zminB1).Distance(gp_Pnt(xminB2, yminB2, zminB2)) > MAX_TOLERANCE)
return false; return false;
@ -2834,31 +2835,10 @@ static bool isSameFace(const TopoDS_Face& theFace1, const TopoDS_Face& theFace2)
if(gp_Pnt(xmaxB1, ymaxB1, zmaxB1).Distance(gp_Pnt(xmaxB2, ymaxB2, zmaxB2)) > MAX_TOLERANCE) if(gp_Pnt(xmaxB1, ymaxB1, zmaxB1).Distance(gp_Pnt(xmaxB2, ymaxB2, zmaxB2)) > MAX_TOLERANCE)
return false; return false;
//Check that each edge of the Face1 has a counterpart in the Face2
TopTools_MapOfOrientedShape aMap;
TopTools_ListIteratorOfListOfShape LSI1(LS1);
for(; LSI1.More(); LSI1.Next()) {
TopoDS_Edge E = TopoDS::Edge(LSI1.Value());
bool isFound = false;
TopTools_ListIteratorOfListOfShape LSI2(LS2);
for(; LSI2.More(); LSI2.Next()) {
TopoDS_Shape aValue = LSI2.Value();
if(aMap.Contains(aValue)) continue; //To avoid checking already found edge several times
if(isSameEdge(E, TopoDS::Edge(aValue))) {
aMap.Add(aValue);
isFound = true;
break;
}
}
if(!isFound) return false;
}
Handle(Geom_Surface) S1 = BRep_Tool::Surface(theFace1); Handle(Geom_Surface) S1 = BRep_Tool::Surface(theFace1);
Handle(Geom_Surface) S2 = BRep_Tool::Surface(theFace2); Handle(Geom_Surface) S2 = BRep_Tool::Surface(theFace2);
if(S1->DynamicType() == S2->DynamicType()) {
return true; //Check if there a coincidence of two surfaces at least in two points
}
else { //Check if there a coincidence of two surfaces at least in two points
double U11, U12, V11, V12, U21, U22, V21, V22; double U11, U12, V11, V12, U21, U22, V21, V22;
BRepTools::UVBounds(theFace1, U11, U12, V11, V12); BRepTools::UVBounds(theFace1, U11, U12, V11, V12);
BRepTools::UVBounds(theFace2, U21, U22, V21, V22); BRepTools::UVBounds(theFace2, U21, U22, V21, V22);
@ -2881,6 +2861,24 @@ static bool isSameFace(const TopoDS_Face& theFace1, const TopoDS_Face& theFace2)
return false; return false;
if(P2.Distance(S2->Value(U, V)) > MAX_TOLERANCE) return false; if(P2.Distance(S2->Value(U, V)) > MAX_TOLERANCE) return false;
//Check that each edge of the Face1 has a counterpart in the Face2
TopTools_MapOfOrientedShape aMap;
TopTools_ListIteratorOfListOfShape LSI1(LS1);
for(; LSI1.More(); LSI1.Next()) {
TopoDS_Edge E = TopoDS::Edge(LSI1.Value());
bool isFound = false;
TopTools_ListIteratorOfListOfShape LSI2(LS2);
for(; LSI2.More(); LSI2.Next()) {
TopoDS_Shape aValue = LSI2.Value();
if(aMap.Contains(aValue)) continue; //To avoid checking already found edge several times
if(isSameEdge(E, TopoDS::Edge(aValue))) {
aMap.Add(aValue);
isFound = true;
break;
}
}
if(!isFound) return false;
} }
return true; return true;