Mon, 01/05/2026 - 10:29
Hello,my question like this:
//I have an old top level shape
TopoDS_Shape oldTopShape=.....;//top level shape
//create a face index map
TopTools_IndexedMapOfShape shapeIndexMap;
TopExp::MapShapes(oldTopShape, TopAbs_FACE, shapeIndexMap);//used the oldTopShape here
TopoDS_Face oldFace=.....;//belongs to top level shape(oldTopShape)
//by this, we can find the index of oldFace in not fixed old shape
auto indexInOldTopShape = shapeIndexMap.FindIndex(oldFace);
//then we push faces of oldTopShape into a map
TopTools_DataMapOfIntegerShape topoFacesBeforeFixIntToShape_;
for (TopExp_Explorer explorer(oldTopShape, TopAbs_FACE);explorer.More(); explorer.Next())
{
const TopoDS_Face &topoFace = TopoDS::Face(explorer.Current());
const int oneFaceID = topoFacesBeforeFixIntToShape_.Size();
topoFacesBeforeFixIntToShape_.Bind(oneFaceID, topoFace);
}
//then we fix the shape like this:
BOPAlgo_Builder builder;
for (TopTools_DataMapIteratorOfDataMapOfIntegerShape it(topoFacesBeforeFixIntToShape_);
it.More(); it.Next())
{
const TopoDS_Shape &shape = it.Value();
builder.AddArgument(shape);
}
builder.Perform();
TopoDS_Shape fusedShape = builder.Shape();
ShapeFix_Shape shapeFix;
shapeFix.Init(fusedShape);
shapeFix.Perform();
auto newTopShape = shapeFix.Shape();
//Now
the oldTopShape has been "fixed" into newTopShape
and I knew that the oldFace in the oldTopShape has index: indexInOldTopShape
The question are:
1,how to find out the fixed newFace corresponaded to the oldFace from newTopShape
I have tried:
auto newFace = shapeFix.Context().Value(oldFace);
and this seems gave right result
2,How to find the index of newFace in newTopShape?
I have tried:
shapeIndexMap.Clear();
TopExp::MapShapes(newTopShape, TopAbs_FACE, shapeIndexMap);//used the newTopShape here
auto newFace = shapeFix.Context().Value(oldFace);
auto faceIndexInNewTopShape=shapeIndexMap.FindIndex(newFace);
std::cout<<"The index of newFace in newTopShape: "<<faceIndexInNewTopShape<<std::endl;
but this always give me: 0 (means not found)
How to solve this problem?