-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mesh Segmentation #1627
Comments
Hello! |
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. |
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, from meshlib import mrmeshpy as mm
help(mm.surroundingContour)
help(mm.fillContourLeftByGraphCut) the idea here is to pick 2 or 3 vertices ( |
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.
The |
Hello! 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")) |
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 Best, |
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 |
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! |
There is small example here https://github.com/MeshInspector/MeshLib/blob/master/source/MRMesh/MRSurroundingContour.h also please find documentation here |
https://meshinspector.com/MeshLib/doc/group__MeshSegmentationGroup.html this link should be helpful |
Hey,
I am trying to segment a mesh using MeshLib, I am not able to find the related source library or example. Do you an example for it?
Assuming this input mesh:
Thanks!
Best,
Ahmad
The text was updated successfully, but these errors were encountered: