diff --git a/src/BRepOffset/BRepOffset_Inter3d.cxx b/src/BRepOffset/BRepOffset_Inter3d.cxx index b89e1f030a..06731bf758 100644 --- a/src/BRepOffset/BRepOffset_Inter3d.cxx +++ b/src/BRepOffset/BRepOffset_Inter3d.cxx @@ -213,7 +213,7 @@ void BRepOffset_Inter3d::FaceInter(const TopoDS_Face& F1, InitF2.ShapeType() == TopAbs_FACE); TopTools_ListOfShape LE,LV; LInt1.Clear(); LInt2.Clear(); - if (BRepOffset_Tool::HasCommonShapes(F1,F2,LE,LV) || + if (BRepOffset_Tool::FindCommonShapes(F1,F2,LE,LV) || myAsDes->HasCommonDescendant(F1,F2,LE)) { //------------------------------------------------- // F1 and F2 share shapes. @@ -248,8 +248,8 @@ void BRepOffset_Inter3d::FaceInter(const TopoDS_Face& F1, // many sections. //-------------------------------------------------------- if (InterFaces) { - if (BRepOffset_Tool::HasCommonShapes(TopoDS::Face(InitF1), - TopoDS::Face(InitF2),LE,LV)) { + if (BRepOffset_Tool::FindCommonShapes(TopoDS::Face(InitF1), + TopoDS::Face(InitF2),LE,LV)) { if (!LE.IsEmpty()) { BRepOffset_Tool::Inter3D (F1,F2,LInt1,LInt2,mySide,NullEdge); } diff --git a/src/BRepOffset/BRepOffset_MakeOffset.cxx b/src/BRepOffset/BRepOffset_MakeOffset.cxx index f05b9a169b..397f8ee90e 100644 --- a/src/BRepOffset/BRepOffset_MakeOffset.cxx +++ b/src/BRepOffset/BRepOffset_MakeOffset.cxx @@ -3313,11 +3313,9 @@ void BRepOffset_MakeOffset::EncodeRegularity () else if ( Type1 == TopAbs_FACE && Type2 == TopAbs_FACE) { // if two root faces are tangent in // the initial shape, they will be tangent in the offset shape - TopTools_ListOfShape LE,LV; - BRepOffset_Tool::HasCommonShapes(TopoDS::Face(Root1), - TopoDS::Face(Root2), - LE,LV); - if ( LE.Extent() == 1) { + TopTools_ListOfShape LE; + BRepOffset_Tool::FindCommonShapes(Root1, Root2, TopAbs_EDGE, LE); + if ( LE.Extent() == 1) { const TopoDS_Edge& Ed = TopoDS::Edge(LE.First()); if ( myAnalyse.HasAncestor(Ed)) { const BRepOffset_ListOfInterval& LI = myAnalyse.Type(Ed); @@ -3330,15 +3328,7 @@ void BRepOffset_MakeOffset::EncodeRegularity () } else if ( Type1 == TopAbs_EDGE && Type2 == TopAbs_EDGE) { TopTools_ListOfShape LV; - TopExp_Explorer exp1; - for (exp1.Init(Root1,TopAbs_VERTEX); exp1.More(); exp1.Next()) { - TopExp_Explorer exp2(F2,TopAbs_EDGE); - for (exp2.Init(Root2,TopAbs_VERTEX); exp2.More(); exp2.Next()) { - if (exp1.Current().IsSame(exp2.Current())) { - LV.Append(exp1.Current()); - } - } - } + BRepOffset_Tool::FindCommonShapes(Root1, Root2, TopAbs_VERTEX, LV); if ( LV.Extent() == 1) { TopTools_ListOfShape LEdTg; myAnalyse.TangentEdges(TopoDS::Edge(Root1), diff --git a/src/BRepOffset/BRepOffset_Tool.cxx b/src/BRepOffset/BRepOffset_Tool.cxx index 4b0c432a5c..89d5676932 100644 --- a/src/BRepOffset/BRepOffset_Tool.cxx +++ b/src/BRepOffset/BRepOffset_Tool.cxx @@ -548,42 +548,54 @@ void BRepOffset_Tool::OrientSection (const TopoDS_Edge& E, } //======================================================================= -//function : HasCommonShape +//function : FindCommonShapes //purpose : //======================================================================= - -Standard_Boolean BRepOffset_Tool::HasCommonShapes (const TopoDS_Face& F1, - const TopoDS_Face& F2, - TopTools_ListOfShape& LE, - TopTools_ListOfShape& LV) +Standard_Boolean BRepOffset_Tool::FindCommonShapes(const TopoDS_Face& theF1, + const TopoDS_Face& theF2, + TopTools_ListOfShape& theLE, + TopTools_ListOfShape& theLV) { - Standard_Boolean Common = Standard_False; - LE.Clear(); LV.Clear(); + Standard_Boolean bFoundEdges = + FindCommonShapes(theF1, theF2, TopAbs_EDGE, theLE); + Standard_Boolean bFoundVerts = + FindCommonShapes(theF1, theF2, TopAbs_VERTEX, theLV); + return bFoundEdges || bFoundVerts; +} - TopExp_Explorer exp1; - exp1.Init(F1,TopAbs_EDGE); - - for (; exp1.More(); exp1.Next()) { - TopExp_Explorer exp2; - exp2.Init(F2,TopAbs_EDGE); - for (; exp2.More(); exp2.Next()) { - if (exp1.Current().IsSame(exp2.Current())) { - Common = Standard_True; - LE.Append(exp1.Current()); +//======================================================================= +//function : FindCommonShapes +//purpose : +//======================================================================= +Standard_Boolean BRepOffset_Tool::FindCommonShapes(const TopoDS_Shape& theS1, + const TopoDS_Shape& theS2, + const TopAbs_ShapeEnum theType, + TopTools_ListOfShape& theLSC) +{ + theLSC.Clear(); + // + TopTools_MapOfShape aMS; + TopExp_Explorer aExp(theS1, theType); + for (; aExp.More(); aExp.Next()) { + aMS.Add(aExp.Current()); + } + // + if (aMS.IsEmpty()) { + return Standard_False; + } + // + TopTools_MapOfShape aMFence; + aExp.Init(theS2, theType); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Shape& aS2 = aExp.Current(); + if (aMS.Contains(aS2)) { + if (aMFence.Add(aS2)) { + theLSC.Append(aS2); } } } - for (exp1.Init(F1,TopAbs_VERTEX); exp1.More(); exp1.Next()) { - TopExp_Explorer exp2; - exp2.Init(F2,TopAbs_EDGE); - for (exp2.Init(F2,TopAbs_VERTEX); exp2.More(); exp2.Next()) { - if (exp1.Current().IsSame(exp2.Current())) { - Common = Standard_True; - LV.Append(exp1.Current()); - } - } - } - return Common; + // + return !theLSC.IsEmpty(); } //======================================================================= diff --git a/src/BRepOffset/BRepOffset_Tool.hxx b/src/BRepOffset/BRepOffset_Tool.hxx index b0609d5506..c4d9e3f681 100644 --- a/src/BRepOffset/BRepOffset_Tool.hxx +++ b/src/BRepOffset/BRepOffset_Tool.hxx @@ -62,11 +62,23 @@ public: //! idem for . Standard_EXPORT static void OrientSection (const TopoDS_Edge& E, const TopoDS_Face& F1, const TopoDS_Face& F2, TopAbs_Orientation& O1, TopAbs_Orientation& O2); - //! Returns True if and has common Vertices - //! or edges , contains the common edges. the - //! common vertices. - Standard_EXPORT static Standard_Boolean HasCommonShapes (const TopoDS_Face& F1, const TopoDS_Face& F2, TopTools_ListOfShape& LE, TopTools_ListOfShape& LV); - + //! Looks for the common Vertices and Edges between faces and .
+ //! Returns TRUE if common shapes have been found.
+ //! will contain the found common edges;
+ //! will contain the found common vertices. + Standard_EXPORT static Standard_Boolean FindCommonShapes(const TopoDS_Face& theF1, + const TopoDS_Face& theF2, + TopTools_ListOfShape& theLE, + TopTools_ListOfShape& theLV); + + //! Looks for the common shapes of type between shapes and .
+ //! Returns TRUE if common shapes have been found.
+ //! will contain the found common shapes. + Standard_EXPORT static Standard_Boolean FindCommonShapes(const TopoDS_Shape& theS1, + const TopoDS_Shape& theS2, + const TopAbs_ShapeEnum theType, + TopTools_ListOfShape& theLSC); + //! Computes the Section betwwen and the //! edges solution are stored in with the //! orientation on , the sames edges are stored in