mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +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:
@@ -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();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
Reference in New Issue
Block a user