Code Monkey home page Code Monkey logo

Comments (14)

Grantim avatar Grantim commented on June 1, 2024 1

We have related issue #1259 and function in c++, unfortunately it is not exposed to our python module yet, we will try to do it in next release

/// in case of positive offset, returns the mesh consisting of offset mesh merged with inversed original mesh (thickening mode);
/// in case of negative offset, returns the mesh consisting of inversed offset mesh merged with original mesh (hollowing mode);
/// if your input mesh is closed then please specify params.type == Offset, and you will get closed mesh on output;
/// if your input mesh is open then please specify params.type == Shell, and you will get open mesh on output
[[nodiscard]] MRMESH_API Expected<Mesh, std::string> thickenMesh( const Mesh& mesh, float offset, const OffsetParameters & params = {} );

from meshlib.

Fedr avatar Fedr commented on June 1, 2024 1

Voxel Offset is a very simple idea:

  1. First you fill voxels with (signed) distances to input mesh,
  2. Then you build some iso-surface from voxel representation into new mesh.

But there are tons of details here, e.g. how to store voxels efficiently, how to find distance signs in the presence of holes in mesh, or how to preserve sharp features in the mesh. For example, you can read https://www.graphics.rwth-aachen.de/media/papers/feature1.pdf

And as to thickening, it is our own implementation, which was not derived from any existing paper. So you can look at its code.

from meshlib.

Grantim avatar Grantim commented on June 1, 2024

Hello! Can you please show example of input and output that you want to get? I our tums offset is equidistant surface on given distance from original surface.
image

from meshlib.

emil-peters avatar emil-peters commented on June 1, 2024

Thanks for the quick response, I should've given an example:

Current Output Desired Output
image image

If not clear what I mean with the Blender example, I could make a video of what I mean

from meshlib.

emil-peters avatar emil-peters commented on June 1, 2024

Hi,

I'd like to reopen the issue, as I feel the issue it not fully solved yet 🤔

The current output of the thickenMesh does not seem correct.

Blend output

In blender the settings are:
thickness: which indicates how far the object should be extruded
Offset: the direction of the extrusion (1 -> outwards, -1 -> inwards)

Input Output Settings
image image image
image image image
image image image

Meshlib output:

What supprises me is that thickenMesh and offsetMesh produce the same output, even though I wouldn't expect that.

/ Input Output
web app image image
(Code 1) [Offset] image image
(Code 2) [thicken] image image

Code 1:

        p = createPlane(1, np.array([0, 0, 1]))
        params.voxelSize = 0.1
        params.signDetectionMode = mr.SignDetectionMode.OpenVDB # does not require closed mesh
        mr_p = mr.offsetMesh(p.toMrMesh(), 0.5, params)
        p.assignPointLabels(28)
        p.view()
        (Mesh(mr_p)+ p).view()

Code 2

        p = createPlane(1, np.array([0, 0, 1]))
        params.voxelSize = 0.1
        params.signDetectionMode = mr.SignDetectionMode.OpenVDB # does not require closed mesh
        mr_p = mr.thickenMesh(p.toMrMesh(), 0.5, params)
        p.assignPointLabels(28)
        p.view()
        (Mesh(mr_p)+ p).view()

I have also tried all the possible SignDetectionModes but that doesn't see to do much. Often breaks the algorithm.

Any ideas?

from meshlib.

Fedr avatar Fedr commented on June 1, 2024

Hi,

Signed offset always creates a closed mesh as a result, so it is not what you are looking for.

In contrast, Thickening can do the job.

If we start from not-closed plane mesh (a couple of triangles) of size 1:
image

And apply Thickening:
image

The result will consist of two parts:
image

The first part is just the original mesh with flipped normals, and the second one is the mesh moved on 0.03 as requested in the settings. Is the second one what you expect to get?

from meshlib.

emil-peters avatar emil-peters commented on June 1, 2024

Yes, but I also expect (as seen in the blender example) that the boundary edges are connected to make it into a closed mesh without all the smoothing & rounding of edges being applied.

It would be simple extrusion of the mesh according to the vertex or face normals, but with the benefit that the resulting mesh is closed and does is cleaned. aka does not contain self intersecting vertices/triangles.

I'm working with quite compelx meshes, if needed I could show an example of the desired outcome in Blender.

from meshlib.

Fedr avatar Fedr commented on June 1, 2024

After Thickening, one can get a closed mesh by using Stitch Holes tool:
image

See more in the video:
https://www.youtube.com/watch?v=XXGoLIKy4Rg

One day we will combine Thickening and Stitch Holes.

And if one just moves vertices along their normals then there is high chance of self-intersections appearance, which are hard to resolve, so we do not use that way.

Please feel free to show your meshes and desired outcome, as it helps us to design new features in MeshInspector/MeshLib.

from meshlib.

emil-peters avatar emil-peters commented on June 1, 2024

Do you have some link to the technique or paper you use for the thickening/offset algorithm?
Thanks you :D

from meshlib.

emil-peters avatar emil-peters commented on June 1, 2024

@Fedr would it be possible to expose the StitchTwoHoles to python as I don't find the function?

from meshlib.

Fedr avatar Fedr commented on June 1, 2024

Actually it is already exposed under the name buildCylinderBetweenTwoHoles:

>>> import meshlib.mrmeshpy as mr
>>> help (mr.buildCylinderBetweenTwoHoles)
Help on built-in function buildCylinderBetweenTwoHoles in module meshlib.mrmeshpy:

buildCylinderBetweenTwoHoles(...) method of builtins.PyCapsule instance
    buildCylinderBetweenTwoHoles(*args, **kwargs)
    Overloaded function.

    1. buildCylinderBetweenTwoHoles(mesh: meshlib.mrmeshpy.Mesh, a: meshlib.mrmeshpy.EdgeId, b: meshlib.mrmeshpy.EdgeId, params: meshlib.mrmeshpy.StitchHolesParams = <meshlib.mrmeshpy.StitchHolesParams object at 0x000001DD852EA7F0>) -> None
    Build cylindrical patch to fill space between two holes represented by one of their edges each,
    default metric: ComplexStitchMetric
            mesh - mesh with hole
            a - EdgeId which represents 1st hole
            b - EdgeId which represents 2nd hole
            params - parameters of holes stitching

    2. buildCylinderBetweenTwoHoles(mesh: meshlib.mrmeshpy.Mesh, params: meshlib.mrmeshpy.StitchHolesParams = <meshlib.mrmeshpy.StitchHolesParams object at 0x000001DD852EA870>) -> bool

    this version finds holes in the mesh by itself and returns false if they are not found

from meshlib.

emil-peters avatar emil-peters commented on June 1, 2024

Cool, the param meshlib.mrmeshpy.EdgeId is this a list of vertex_idx that make up the edge of the mesh?
Or how do I pass this?

from meshlib.

Fedr avatar Fedr commented on June 1, 2024

EdgeId is a unique identifier of an edge in mesh (an integer). One option to find it is by calling topology.findHoleRepresentiveEdges(), Please see our test test_stitchTwoHoles.py:

from helper import *
import pytest


def test_stitch_two_holes():
    torus = mrmesh.makeOuterHalfTorus(2, 1, 10, 10, None)
    torus2 = mrmesh.makeOuterHalfTorus(2, 1, 10, 10, None)
    torusAutostitchTwo = torus

    holes = torus.topology.findHoleRepresentiveEdges()
    assert (len(holes) == 2)

    params = mrmesh.StitchHolesParams()
    params.metric = mrmesh.getEdgeLengthStitchMetric(torus)
    mrmesh.buildCylinderBetweenTwoHoles(torus, holes[0], holes[1], params)

    holes = torus.topology.findHoleRepresentiveEdges()
    assert (len(holes) == 0)

    mrmesh.buildCylinderBetweenTwoHoles(torus2, params)
    holes = torus2.topology.findHoleRepresentiveEdges()
    assert (len(holes) == 0)

from meshlib.

emil-peters avatar emil-peters commented on June 1, 2024

Thanks

from meshlib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.