Giter VIP home page Giter VIP logo

Comments (10)

Grantim avatar Grantim commented on May 18, 2024 1

There is small example here
https://github.com/MeshInspector/MeshLib/blob/master/examples/cmake-example/main.cpp
and some usage code can be found here
https://github.com/MeshInspector/MeshLib/tree/master/source/MRCommonPlugins

https://github.com/MeshInspector/MeshLib/blob/master/source/MRMesh/MRSurroundingContour.h
https://github.com/MeshInspector/MeshLib/blob/master/source/MRMesh/MRFillContourByGraphCut.h

also please find documentation here

from meshlib.

Grantim avatar Grantim commented on May 18, 2024 1

https://meshinspector.com/MeshLib/doc/group__MeshSegmentationGroup.html this link should be helpful

from meshlib.

Grantim avatar Grantim commented on May 18, 2024

Hello!
What kind of segmentation do you need? Can you please show visual example?

from meshlib.

lutfia95 avatar lutfia95 commented on May 18, 2024

Hey,

as I saw in the readme you mentioned two segmentation methods (Semi-auto voxel segmentation, Semi-auto mesh segmentation by curvature.) I am not sure how can I apply both of them to the mesh.

I got this example from "Link" so I want something like this.

image

from meshlib.

Grantim avatar Grantim commented on May 18, 2024

Thanks for the image: you can have a look at https://github.com/MeshInspector/MeshLib/blob/master/test_python/test_segmentation.py for example of mesh segmentation, you need to specify source and sink faces for it,
also please you can try this functions:

from meshlib import mrmeshpy as mm
help(mm.surroundingContour)
help(mm.fillContourLeftByGraphCut)

the idea here is to pick 2 or 3 vertices (tincludeEdges, vertices in the origins are used) and create contour connecting them, and then separate inside and outside parts of the contour

from meshlib.

lutfia95 avatar lutfia95 commented on May 18, 2024

Hey @Grantim,

thank you very much! I was trying to test the segmentation but I think that I did something wrong or didn't understand it correctly.
I followed the same code snippets from your `test_segmentation.py'. And I used it as following:

from helper import *
import shutil

from meshlib import mrmeshpy as mrmesh

mesh = mrmesh.makeTorus()
mrmesh.saveMesh(mesh, mrmeshpy.Path("mesh_original.stl"))
metric = mrmesh.edgeLengthMetric(mesh)

source = mrmesh.FaceBitSet()
sink = mrmesh.FaceBitSet()

# For mesh segmentation, one has to specify source and sink faces for it.
source.resize(mesh.topology.getValidFaces().size(),False)
sink.resize(mesh.topology.getValidFaces().size(),False)

source.set(mrmesh.FaceId(0),True)
sink.set(mrmesh.FaceId(5),True)

res = mrmesh.segmentByGraphCut(mesh.topology,source,sink,metric)

The res object is an FaceBitSet, I am still not sure how can I save the segmented mesh.

from meshlib.

Grantim avatar Grantim commented on May 18, 2024

Hello!
You can do so

from helper import *
import shutil

from meshlib import mrmeshpy as mrmesh

mesh = mrmesh.makeTorus()
mrmesh.saveMesh(mesh, mrmeshpy.Path("mesh_original.stl"))
metric = mrmesh.edgeLengthMetric(mesh)

source = mrmesh.FaceBitSet()
sink = mrmesh.FaceBitSet()

# For mesh segmentation, one has to specify source and sink faces for it.
source.resize(mesh.topology.getValidFaces().size(),False)
sink.resize(mesh.topology.getValidFaces().size(),False)

source.set(mrmesh.FaceId(0),True)
sink.set(mrmesh.FaceId(5),True)

res = mrmesh.segmentByGraphCut(mesh.topology,source,sink,metric)

bitSetToRemove = mesh.topology.getValidFaces() - res
mesh.topology.deleteFaces( bitSetToRemove )
mesh.pack()
mrmesh.saveMesh(mesh, mrmeshpy.Path("mesh_segmented.stl"))

from meshlib.

lutfia95 avatar lutfia95 commented on May 18, 2024

The idea is we segment out the faces and then remove them from the original mesh, so that we can store the segmented part only. Is there any way to save all segmented faces in other mesh file? And do you have examples for surroundingContour and fillContourLeftByGraphCut? I didn't find any documentation regarding segmentation.

Best,

from meshlib.

Grantim avatar Grantim commented on May 18, 2024

I have edited code sample here hope it will help you. We have more options to copy segmented part in c++ code, but it is not exposed to python yet, we will add it later! About surroundingContour and fillContourLeftByGraphCut unfortunately we dont have examples.
You can find some description with help(mrmesh.surroundingContour) and help(mrmesh.fillContourLeftByGraphCut)
Basicaly:
surroundingContour finds best closed edge loop in terms of provided metric
fillContourLeftByGraphCut fills left part of the edge loop minimizing tonnels with provided metric.

from meshlib.

lutfia95 avatar lutfia95 commented on May 18, 2024

thank you very much! with C++ will work much better in my use case, as I'm trying to segment meshes completely using C++ in the first place. Is there any snippiest example for the C++ versions? basically my goal is to segment everything inside the mesh. same as here. Thank you very much for your support!

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.