Remove duplicate faces using ShapeFix

Hello Everyone,

I have attached a sample STEP file which after import results into a Compound having two solids. These solids share a common Face which models an interface between two dissimilar materials. Both the Solids have their own object for this shared Face. I want to repair the compound so that Solids have common Face objects in their sub shapes.

I have gone through ShapeFix package but could not find any relevant class to solve this problem. Is anyone aware of different method in Opencascade to solve this?

TIA,
Ashish

Attachments: 
Roman Lygin's picture

Hello Ashish,

Correctly speaking, this is *not* a *shared* face, in terms of topological sharing. There are two independent solids which happen to have two faces adjacent to each other. So what you really need to do is to fuse these solids (where fuse is a type of Boolean operation). Here is how you can do this in DRAW:

pload ALL
stepread boxes_sharedface.stp b *
whatis b_1 # compound
numshapes b_1 #12 faces
explode b_1
whatis b_1_1 b_1_2 # 2 solids
bop b_1_1 b_1_2
bopfuse res
whatis res # compound
explode res
whatis res_1 # solid
numshapes res_1 #10 faces

You should be able to easily reverse-engineer above into C++ API calls.
Hope this helps.
Roman

ashish.negi's picture

Hello Roman,
Thanks a lot for your reply.

Above code removes common face and results into single solid. I want to retain common face between two solids.

I use GMSH to mesh opencascade model which has two dissimilar metals joined together. I want to mesh this model and get conforming mesh at the interface (solid meshes from both the solids sharing common surface meshes at the interface). If opencascade model does not have common face then interface cuts the solid meshes.

Thanks,
Ashish

Roman Lygin's picture

Hi Ashish,
So you want to have a non-manifold shape then, right ?
To achieve this you might want to use BRepTools_ReShape and replace a face from one solid with one from another, and then update the entire compound. Choosing which face likely won't matter but you will need to take care of orientation (as it must be different for another solid). So something like:

TopoDS_Shape aShape ; //original shape
TopoDS_Face aF1 = ..., aF2 = ...; //coincident faces in solid1 and 2
Handle(BRepTools_ReShape) aReShape = ...;
aReShape->Replace (aF1, aF2.Reversed());
TopoDS_Shape aNewShape = aReShape->Apply (aShape);

Hope this helps.
Roman

m-sazonov's picture

Good, but after that the replaced face will be disconnected from other subshapes of the solid. It is needed to take care about vertices and edges too.

Roman Lygin's picture

Correct. Thanks, Mikhail.
Yes, all 4 vertices and 4 edges need to recorded in the ReShape. Then the face being replaced is to be reconstructed, and then recorded in ReShape, and then the entire shape is to be recomputed.
Anything missing ?

Roman Lygin's picture

Oops. Interim recomputation of the face is not required.

ashish.negi's picture

It worked. Thank you very much.