Mapping faces between source and mirrored bodies?

Mapping faces between source and mirrored bodies?

JesusFreke
Advocate Advocate
667 Views
4 Replies
Message 1 of 5

Mapping faces between source and mirrored bodies?

JesusFreke
Advocate
Advocate

 

When I mirror a body via a Mirror feature, I can't find any good way to map a face on the original body to the equivalent face on the mirrored body.

 

Things I've tried:

- putting attributes on the source faces, but the attributes are not copied over to the mirrored body

- mapping the faces by tempId, but the tempIds are not maintained in the mirrored copy

- making a copy of the object via TemporaryBRepManager.copy() and performing a mirror via TemporaryBRepManager.transform(), but the temporary copy doesn't maintain either attributes or tempIds

 

It looks like the mirror feature accepts a face as a valid entity to mirror, so maybe I could do a temporary mirror of each face on the source body, and then find the face on the mirrored body that is coincident with the mirrored face. But that sounds rather computationally intensive.

 

Is there some better way I'm missing? Other than by using occurrence.transform to do the mirror, which is apparently not intended to work 😉

 

Ideally, the mirror feature would have an option that just modified the source body, similar to how the scale feature works. Or at the very least if it maintained the tempIds, or better, the attributes in the mirrored copy.

 

 

0 Likes
Accepted solutions (1)
668 Views
4 Replies
Replies (4)
Message 2 of 5

BrianEkins
Mentor
Mentor
Accepted solution

I think there are two possible solutions.

 

The first is the easiest and I believe should be reliable but am not 100% sure. Because the body is a direct copy of the original, without any kind of modifications (besides the mirror transform), you should be able to match up faces using the index within the faces collection of each body.  For example, if the original body is body1 and the mirrored body is body2, body1.faces.item(15) should be the equivalent face of body2.faces.item(15).

 

The second way is to get a face and a point on the face using BRepFace.pointOnFace and then transform that point using the same mirror transform using for the feature.  Finally, use the transformed point as input to the Component.findBRepUsingPoint method to find the face on the other body.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 5

JesusFreke
Advocate
Advocate

Oh, nice. I'll have to experiment with the order of the faces, I didn't think of that. That might be a better way to go, if it pans out.

 

In the meantime, since I made the original post, I started implementing a solution a bit similar to your "pointOnFace" suggestion, but using the face centroid. Since a face centroid should be unique per body (right?), you can build a map of centroid->face from the original body, and then query it using the inverse-transformed centroid from the mirror body. Although you have to use float-tolerance aware key semantics, which makes it a bit more complex.

 

Thanks for the suggestions!

0 Likes
Message 4 of 5

JesusFreke
Advocate
Advocate

Actually, nevermind. The centroid won't work. For some reason I was thinking the centroid would always be on the surface, but that's obviously not true.

 

Hmm, I may be able to use the parametric center though, using the surface evaluator and getPointAtParameter, passing in the "middle" parameter, based on the extends returned by .parameterRange.

 

But, now that I think of it, even the parametric center may not be unique per body. e.g. if a body has a small spherical face nested inside a larger one, such that they are touching at a single point - which could conceivably be the parametric centroid of each face.

 

So yeah, nevermind. That's not going to work.

0 Likes
Message 5 of 5

JesusFreke
Advocate
Advocate

I haven't tested it extensively yet, but using the order of the faces seems to be doing the trick so far.

0 Likes