MeshInspector / MeshLib

Mesh processing library
https://meshlib.io
Other
520 stars 59 forks source link

Anisotropic offsetting #2598

Open tobias-scheepers opened 6 months ago

tobias-scheepers commented 6 months ago

Hi all, I'm very curious if anyone has made any attempt to make an anisotropic offset operation using meshlib. As I see it there is a set of two operations that would be very valuable but not seen very often in practice:

I'm not sure if this is something that could be made on-top any of the current functions or would require more low level changes to be made.

Grantim commented 6 months ago

Hello!

Now I think we only have fixUndercuts function that is similar to Offsetting a shape in a single direction

Can you please show some examples of input and expected output?
tobias-scheepers commented 6 months ago

Hi @Grantim the fix undercut feature is indeed help full in a lot of cases. The offsetting in a certain direction would however allow for some more fine grained operations in some cases:

Let's say the original mesh looks like so: image

I believe we could create an offset function that if working symmetrically along the z-axis would look like so: image

Once the offset is large enough to cover the gap it would avoid the self intersections as we are used to from your other offsetting operations: image

Similarly one could make an operation to only work in a single direction: image image

And finally one could create an offset that would work in the plane (e.g. the XY plane). In this case I would expect something like so: image image

I'm not sure if this makes sense so far. I believe these operations might be a valuable operation for meshlib. But I'm not well enough informed to see how difficult it would be to implement. It seems the offsets in a single direction might be feasible with some smart segmentation and extrusion operations. I believe however it is the offsetting in plane that would be most valuable.

Grantim commented 6 months ago

Thanks for the explanation!

Unfortunately we don't have such functionality now, but I think we could implement it in future.

Grantim commented 6 months ago

Probably we will have a look at this in May

tobias-scheepers commented 6 months ago

That sounds amaing @Grantim I'll keep a close eye on this.

tobias-scheepers commented 4 months ago

Hi @Grantim any chance you have still been looking into this?

Grantim commented 4 months ago

Hi @tobias-scheepers! Unfortunately, we had no time to look at this yet, thanks taking it up, we will discuss it with the team and come back here.

DmitryLambin commented 4 months ago

Hi @tobias-scheepers.

As we discussed last time, we are ready to plan this feature's implementation as soon as you are ready to proceed with the project using MeshLib. Thanks for revisiting this topic. Don't hesitate to contact me to synchronize the schedule of this feature with your project needs.

Fedr commented 3 months ago

In the last release of MeshInspector, one can find anisotropic Offset. Here is an example: a sphere is offset along Y twice more than along X, and along Z twice more than along Y, resulting in an ellipsoid: image

tobias-scheepers commented 2 months ago

@Fedr, @Grantim that sounds great! Has it also been exposed to python yet by any chance. I'll update the little tests we were running and report back!

@DmitryLambin will let you know once we pick this back up. It's moved a little to the back-burner for us. But will will keep an eye on meshlib as I'm sure we'll be crossing paths at some time in the future.

Fedr commented 2 months ago

Thanks. At this moment the implementation is located within MeshInspector's tool only. Please give it a try. If everything is ok, we will work on moving it in MeshLib and python interface.

tobias-scheepers commented 2 months ago

@Fedr thank you for the update. Inside MeshInspector it works like a charm. If this is available in meshlib/python I'll have a look if we can use it for my usecase. I had three questions that came up while playing with the new feature:

For all, I'm not sure if there is a technical limit in the implementation that guided the current choices. Anyway, great work on this!

Fedr commented 2 months ago

Currently, the algorithm for anisotropic offsetting in MeshInspector works as follows:

  1. Perform not-uniform scaling with different factors along X, Y, Z axes, where each factor is inversely proportional to desired offset in that direction.
  2. Perform standard uniform offset.
  3. Perform not-uniform scaling with reversed factors to step 1.

Although there is no single function in MeshLib to perform all steps at once, you can write python program that reaches the same result.

Answering your questions: