1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-03 14:10:33 +03:00

0026682: TopExp::MapShapesAndAncestors() will build map with duplicated ancestors.

The new method TopExp::MapShapesAndUniqueAncestors has been implemented, which excludes duplication of ancestors in the list items. The optional Boolean argument 'useOrientation' of this method points whether two same shapes with different orientation will be considered equal.
OCCT code has been inspected and MapShapesAndAncestors has been replaced with MapShapesAndUniqueAncestors where it is necessary.
This commit is contained in:
mpa
2017-03-03 13:57:36 +03:00
committed by mkv
parent 4d597f3e2f
commit f1191d3099
13 changed files with 93 additions and 241 deletions

View File

@@ -99,7 +99,55 @@ void TopExp::MapShapesAndAncestors
}
}
//=======================================================================
//function : MapShapesAndUniqueAncestors
//purpose :
//=======================================================================
void TopExp::MapShapesAndUniqueAncestors
(const TopoDS_Shape& S,
const TopAbs_ShapeEnum TS,
const TopAbs_ShapeEnum TA,
TopTools_IndexedDataMapOfShapeListOfShape& M,
const Standard_Boolean useOrientation)
{
TopTools_ListOfShape empty;
// visit ancestors
TopExp_Explorer exa(S,TA);
while (exa.More())
{
// visit shapes
const TopoDS_Shape& anc = exa.Current();
TopExp_Explorer exs(anc,TS);
while (exs.More())
{
Standard_Integer index = M.FindIndex(exs.Current());
if (index == 0)
index = M.Add(exs.Current(),empty);
TopTools_ListOfShape& aList = M(index);
// check if anc already exists in a list
TopTools_ListIteratorOfListOfShape it(aList);
for (; it.More(); it.Next())
if (useOrientation? anc.IsEqual(it.Value()) : anc.IsSame(it.Value()))
break;
if (!it.More())
aList.Append(anc);
exs.Next();
}
exa.Next();
}
// visit shapes not under ancestors
TopExp_Explorer ex(S,TS,TA);
while (ex.More())
{
Standard_Integer index = M.FindIndex(ex.Current());
if (index == 0)
M.Add(ex.Current(),empty);
ex.Next();
}
}
//=======================================================================
//function : FirstVertex

View File

@@ -66,6 +66,15 @@ public:
//! Warning: The map is not cleared at first.
Standard_EXPORT static void MapShapesAndAncestors (const TopoDS_Shape& S, const TopAbs_ShapeEnum TS, const TopAbs_ShapeEnum TA, TopTools_IndexedDataMapOfShapeListOfShape& M);
//! Stores in the map <M> all the subshape of <S> of
//! type <TS> for each one append to the list all
//! unique ancestors of type <TA>. For example map all
//! the edges and bind the list of faces.
//! useOrientation = True : taking account the ancestor orientation
//! Warning: The map is not cleared at first.
Standard_EXPORT static void MapShapesAndUniqueAncestors (const TopoDS_Shape& S, const TopAbs_ShapeEnum TS, const TopAbs_ShapeEnum TA, TopTools_IndexedDataMapOfShapeListOfShape& M,
const Standard_Boolean useOrientation = Standard_False);
//! Returns the Vertex of orientation FORWARD in E. If
//! there is none returns a Null Shape.
//! CumOri = True : taking account the edge orientation