Retrieve faces from a shell...

Hello,
Here's my problem, I have a specific face from a compound, and I want to retrieve its solid/shell ancestor to keep only this one and remove all the others (for exemple replacing a parallelipipede by a unique face)
Here's what I've tried :

BRepTools_ReShape Change;

TopTools_IndexedDataMapOfShapeListOfShape myFaceShapeMap;
TopExp::MapShapesAndAncestors(myface, TopAbs_FACE, TopAbs_SHELL, myFaceShapeMap);

// Lets go
Standard_Integer nbtemp = myFaceShapeMap.Extent();

for (k=1; k

TopoDS_Face subface = TopoDS::Face(myFaceShapeMap.FindKey(k));
Change.Remove(subface);

}

Thanks in advance...

Roman Lygin's picture

Hi Yass,

Not sure I got your intent but let me try. Let's assume you have a compound aComp consisting of several solids, shells, other stuff. And you have a face myface that belongs to some solid/shell (let it be aParent) within aComp. So what you want is to remove aParent from aComp and replace it with myface.

If so, I'd write (using your naming above):

TopExp::MapShapesAndAncestors (aComp, ....); //
if (myFaceShapeMap.Contains (myface)) {
const TopoDS_Shape& aParent = myFaceShapeMap.FindFromKey (myface).First();
Change.Remove (aParent);
//you may also iterate over the whole list, not just using .First()
aComp = Change.Apply (aComp);
BRep_Builder aBuilder;
aBuilder.Add (aComp, myface);
}

HTH.
Roman

Yass's picture

Thank u Roman it works perfectly !!
Best regards,
Yass