1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

0028191: Inefficient implementation of the BRepOffset_Tool::HasCommonShapes() method

The method to find common Vertices and Edges between faces
  BRepOffset_Tool::HasCommonShapes(const TopoDS_Face&,
                                   const TopoDS_Face&,
                                   TopTools_ListOfShape&,
                                   TopTools_ListOfShape&)

has been re-implemented using maps and renamed to BRepOffset_Tool::FindCommonShapes.

The new method
  BRepOffset_Tool::FindCommonShapes(const TopoDS_Shape&,
                                    const TopoDS_Shape&,
                                    const TopAbs_ShapeEnum,
                                    TopTools_ListOfShape&)

has been implemented to look for the common shapes of given type.
This commit is contained in:
emv 2016-12-06 11:12:22 +03:00 committed by apn
parent 291fced1e6
commit fe1d4d6cff
4 changed files with 65 additions and 51 deletions

View File

@ -213,7 +213,7 @@ void BRepOffset_Inter3d::FaceInter(const TopoDS_Face& F1,
InitF2.ShapeType() == TopAbs_FACE); InitF2.ShapeType() == TopAbs_FACE);
TopTools_ListOfShape LE,LV; TopTools_ListOfShape LE,LV;
LInt1.Clear(); LInt2.Clear(); 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)) { myAsDes->HasCommonDescendant(F1,F2,LE)) {
//------------------------------------------------- //-------------------------------------------------
// F1 and F2 share shapes. // F1 and F2 share shapes.
@ -248,8 +248,8 @@ void BRepOffset_Inter3d::FaceInter(const TopoDS_Face& F1,
// many sections. // many sections.
//-------------------------------------------------------- //--------------------------------------------------------
if (InterFaces) { if (InterFaces) {
if (BRepOffset_Tool::HasCommonShapes(TopoDS::Face(InitF1), if (BRepOffset_Tool::FindCommonShapes(TopoDS::Face(InitF1),
TopoDS::Face(InitF2),LE,LV)) { TopoDS::Face(InitF2),LE,LV)) {
if (!LE.IsEmpty()) { if (!LE.IsEmpty()) {
BRepOffset_Tool::Inter3D (F1,F2,LInt1,LInt2,mySide,NullEdge); BRepOffset_Tool::Inter3D (F1,F2,LInt1,LInt2,mySide,NullEdge);
} }

View File

@ -3313,11 +3313,9 @@ void BRepOffset_MakeOffset::EncodeRegularity ()
else if ( Type1 == TopAbs_FACE && Type2 == TopAbs_FACE) { else if ( Type1 == TopAbs_FACE && Type2 == TopAbs_FACE) {
// if two root faces are tangent in // if two root faces are tangent in
// the initial shape, they will be tangent in the offset shape // the initial shape, they will be tangent in the offset shape
TopTools_ListOfShape LE,LV; TopTools_ListOfShape LE;
BRepOffset_Tool::HasCommonShapes(TopoDS::Face(Root1), BRepOffset_Tool::FindCommonShapes(Root1, Root2, TopAbs_EDGE, LE);
TopoDS::Face(Root2), if ( LE.Extent() == 1) {
LE,LV);
if ( LE.Extent() == 1) {
const TopoDS_Edge& Ed = TopoDS::Edge(LE.First()); const TopoDS_Edge& Ed = TopoDS::Edge(LE.First());
if ( myAnalyse.HasAncestor(Ed)) { if ( myAnalyse.HasAncestor(Ed)) {
const BRepOffset_ListOfInterval& LI = myAnalyse.Type(Ed); const BRepOffset_ListOfInterval& LI = myAnalyse.Type(Ed);
@ -3330,15 +3328,7 @@ void BRepOffset_MakeOffset::EncodeRegularity ()
} }
else if ( Type1 == TopAbs_EDGE && Type2 == TopAbs_EDGE) { else if ( Type1 == TopAbs_EDGE && Type2 == TopAbs_EDGE) {
TopTools_ListOfShape LV; TopTools_ListOfShape LV;
TopExp_Explorer exp1; BRepOffset_Tool::FindCommonShapes(Root1, Root2, TopAbs_VERTEX, LV);
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());
}
}
}
if ( LV.Extent() == 1) { if ( LV.Extent() == 1) {
TopTools_ListOfShape LEdTg; TopTools_ListOfShape LEdTg;
myAnalyse.TangentEdges(TopoDS::Edge(Root1), myAnalyse.TangentEdges(TopoDS::Edge(Root1),

View File

@ -548,42 +548,54 @@ void BRepOffset_Tool::OrientSection (const TopoDS_Edge& E,
} }
//======================================================================= //=======================================================================
//function : HasCommonShape //function : FindCommonShapes
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean BRepOffset_Tool::FindCommonShapes(const TopoDS_Face& theF1,
Standard_Boolean BRepOffset_Tool::HasCommonShapes (const TopoDS_Face& F1, const TopoDS_Face& theF2,
const TopoDS_Face& F2, TopTools_ListOfShape& theLE,
TopTools_ListOfShape& LE, TopTools_ListOfShape& theLV)
TopTools_ListOfShape& LV)
{ {
Standard_Boolean Common = Standard_False; Standard_Boolean bFoundEdges =
LE.Clear(); LV.Clear(); 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); //function : FindCommonShapes
//purpose :
for (; exp1.More(); exp1.Next()) { //=======================================================================
TopExp_Explorer exp2; Standard_Boolean BRepOffset_Tool::FindCommonShapes(const TopoDS_Shape& theS1,
exp2.Init(F2,TopAbs_EDGE); const TopoDS_Shape& theS2,
for (; exp2.More(); exp2.Next()) { const TopAbs_ShapeEnum theType,
if (exp1.Current().IsSame(exp2.Current())) { TopTools_ListOfShape& theLSC)
Common = Standard_True; {
LE.Append(exp1.Current()); 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; return !theLSC.IsEmpty();
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;
} }
//======================================================================= //=======================================================================

View File

@ -62,11 +62,23 @@ public:
//! idem for <O2>. //! idem for <O2>.
Standard_EXPORT static void OrientSection (const TopoDS_Edge& E, const TopoDS_Face& F1, const TopoDS_Face& F2, TopAbs_Orientation& O1, TopAbs_Orientation& O2); 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 <F1> and <F2> has common Vertices //! Looks for the common Vertices and Edges between faces <theF1> and <theF2>.<br>
//! or edges , <LE> contains the common edges. <LV> the //! Returns TRUE if common shapes have been found.<br>
//! common vertices. //! <theLE> will contain the found common edges;<br>
Standard_EXPORT static Standard_Boolean HasCommonShapes (const TopoDS_Face& F1, const TopoDS_Face& F2, TopTools_ListOfShape& LE, TopTools_ListOfShape& LV); //! <theLV> 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 <theType> between shapes <theS1> and <theS2>.<br>
//! Returns TRUE if common shapes have been found.<br>
//! <theLSC> 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 <F1> and <F2> the //! Computes the Section betwwen <F1> and <F2> the
//! edges solution are stored in <LInt1> with the //! edges solution are stored in <LInt1> with the
//! orientation on <F1>, the sames edges are stored in //! orientation on <F1>, the sames edges are stored in