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,6 +2835,33 @@ 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;
Handle(Geom_Surface) S1 = BRep_Tool::Surface(theFace1);
Handle(Geom_Surface) S2 = BRep_Tool::Surface(theFace2);
//Check if there a coincidence of two surfaces at least in two points
double U11, U12, V11, V12, U21, U22, V21, V22;
BRepTools::UVBounds(theFace1, U11, U12, V11, V12);
BRepTools::UVBounds(theFace2, U21, U22, V21, V22);
double rangeU = U12-U11;
double rangeV = V12-V11;
double U = U11 + rangeU/3.0;
double V = V11 + rangeV/3.0;
gp_Pnt P1 = S1->Value(U, V);
U = U11+rangeU*2.0/3.0;
V = V11+rangeV*2.0/3.0;
gp_Pnt P2 = S1->Value(U, V);
if(!GeomLib_Tool::Parameters(S2, P1, MAX_TOLERANCE, U, V) || U < U21 || U > U22 || V < V21 || V > V22)
return false;
if(P1.Distance(S2->Value(U,V)) > MAX_TOLERANCE) return false;
if(!GeomLib_Tool::Parameters(S2, P2, MAX_TOLERANCE, U, V) || U < U21 || U > U22 || V < V21 || V > V22)
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 //Check that each edge of the Face1 has a counterpart in the Face2
TopTools_MapOfOrientedShape aMap; TopTools_MapOfOrientedShape aMap;
TopTools_ListIteratorOfListOfShape LSI1(LS1); TopTools_ListIteratorOfListOfShape LSI1(LS1);
@ -2853,36 +2881,6 @@ static bool isSameFace(const TopoDS_Face& theFace1, const TopoDS_Face& theFace2)
if(!isFound) return false; if(!isFound) return false;
} }
Handle(Geom_Surface) S1 = BRep_Tool::Surface(theFace1);
Handle(Geom_Surface) S2 = BRep_Tool::Surface(theFace2);
if(S1->DynamicType() == S2->DynamicType()) {
return true;
}
else { //Check if there a coincidence of two surfaces at least in two points
double U11, U12, V11, V12, U21, U22, V21, V22;
BRepTools::UVBounds(theFace1, U11, U12, V11, V12);
BRepTools::UVBounds(theFace2, U21, U22, V21, V22);
double rangeU = U12-U11;
double rangeV = V12-V11;
double U = U11 + rangeU/3.0;
double V = V11 + rangeV/3.0;
gp_Pnt P1 = S1->Value(U, V);
U = U11+rangeU*2.0/3.0;
V = V11+rangeV*2.0/3.0;
gp_Pnt P2 = S1->Value(U, V);
if(!GeomLib_Tool::Parameters(S2, P1, MAX_TOLERANCE, U, V) || U < U21 || U > U22 || V < V21 || V > V22)
return false;
if(P1.Distance(S2->Value(U,V)) > MAX_TOLERANCE) return false;
if(!GeomLib_Tool::Parameters(S2, P2, MAX_TOLERANCE, U, V) || U < U21 || U > U22 || V < V21 || V > V22)
return false;
if(P2.Distance(S2->Value(U, V)) > MAX_TOLERANCE) return false;
}
return true; return true;
} }