From 73a01143914fb0dad78b3cbc3c468da3c9410267 Mon Sep 17 00:00:00 2001 From: skv Date: Thu, 16 Jul 2015 10:51:04 +0300 Subject: [PATCH] 0023122: EDF 11178 GEOM: Fuse between a cylinder and a part with a hole fails --- src/BlockFix/BlockFix_UnionEdges.cxx | 35 ++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/BlockFix/BlockFix_UnionEdges.cxx b/src/BlockFix/BlockFix_UnionEdges.cxx index 4647d9e55..62a0307c5 100644 --- a/src/BlockFix/BlockFix_UnionEdges.cxx +++ b/src/BlockFix/BlockFix_UnionEdges.cxx @@ -88,6 +88,37 @@ #include "utilities.h" +//======================================================================= +//function : IsToMerge +//purpose : This method return Standard_True if two edges have common +// vertex. This vertex is returned by output parameter. The +// difference with the method TopExp::CommonVertex is only in +// the case if there are two common vertices. In this case +// this method returns the last vertex of theEdge1, not the first +// one that TopExp::CommonVertex does. +//======================================================================= +static Standard_Boolean GetCommonVertex(const TopoDS_Edge &theEdge1, + const TopoDS_Edge &theEdge2, + TopoDS_Vertex &theCommon) +{ + Standard_Boolean isFound = Standard_True; + ShapeAnalysis_Edge aSae; + TopoDS_Vertex aVF1 = aSae.FirstVertex(theEdge1); + TopoDS_Vertex aVL1 = aSae.LastVertex(theEdge1); + TopoDS_Vertex aVF2 = aSae.FirstVertex(theEdge2); + TopoDS_Vertex aVL2 = aSae.LastVertex(theEdge2); + + if (aVL1.IsSame(aVF2) || aVL1.IsSame(aVL2)) { + theCommon = aVL1; + } else if (aVF1.IsSame(aVL2) || aVF1.IsSame(aVF2)) { + theCommon = aVF1; + } else { + theCommon.Nullify(); + isFound = Standard_False; + } + + return isFound; +} //======================================================================= //function : IsToMerge @@ -148,7 +179,7 @@ static Standard_Boolean IsToMerge // that are connected to the common vertex. TopoDS_Vertex aVCommon; - if (TopExp::CommonVertex(theEdge1, theEdge2, aVCommon)) { + if (GetCommonVertex(theEdge1, theEdge2, aVCommon)) { TopTools_IndexedDataMapOfShapeListOfShape aMapVE; TopExp::MapShapesAndAncestors @@ -328,7 +359,7 @@ static TopoDS_Edge GlueEdgesWithPCurves(const TopTools_SequenceOfShape& aChain, if (i > 1) { - TopExp::CommonVertex(PrevEdge, anEdge, CV); + GetCommonVertex(PrevEdge, anEdge, CV); Standard_Real Tol = BRep_Tool::Tolerance(CV); tabtolvertex(i-2) = Tol; }