-
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
python filling hole(and stitching two holes) with same result as MeshInspector #1402
Comments
I have adjusted some subdivision configurations to avoid narrow triangles successfully. But there is still exploded result on some cases. I found it occurs after function buildCylinderBetweenTwoHoles. I tried the available metrics(the default one and the getEdgeLengthStitchMetric), both failed. Besides, the MeshInspector can stitching two holes(triangulate only) with different metrics. Here is my test data. |
hello, the core code is like this,
Yes, the result looks very strange. Let me try debugging again, I have just discovered some new details. |
I have checked from meshlib import mrmeshpy as mm
mesh = mm.loadMesh("test_input.ply")
holes = mesh.topology.findHoleRepresentiveEdges()
newFacesBitSet= mm.FaceBitSet()
params = mm.StitchHolesParams()
params.outNewFaces = newFacesBitSet
params.metric = mm.getEdgeLengthStitchMetric(mesh)
mm.buildCylinderBetweenTwoHoles(mesh,holes[0],holes[1], params)
# subdivide new faces only
settings = mm.SubdivideSettings()
settings.maxEdgeLen = 0.2
settings.maxEdgeSplits = 100000
settings.maxDeviationAfterFlip = 0.2
settings.region = newFacesBitSet
# accum new verts after subdivide for optional curvature positioning
newVertsBitSet = mm.VertBitSet()
settings.newVerts = newVertsBitSet
mm.subdivideMesh(mesh, settings)
# optional positioning
mm.positionVertsSmoothly(mesh, newVertsBitSet)
mm.saveMesh(mesh, mm.Path("res.ply")) and got such result |
from meshlib import mrmeshpy as mm
def stitch(mesh, he1, he2):
# Create parameters for filling hole
params = mm.StitchHolesParams()
newFacesBitSet = mm.FaceBitSet()
params.outNewFaces = newFacesBitSet
params.metric = mm.getEdgeLengthStitchMetric(mesh)
mm.buildCylinderBetweenTwoHoles(mesh, he1, he2, params)
return mesh, newFacesBitSet
mesh1 = mm.loadMesh("test_input.ply")
holes = mesh1.topology.findHoleRepresentiveEdges()
mesh, newFacesBitSet = stitch(mesh1,holes[0],holes[1])
# subdivide new faces only
settings = mm.SubdivideSettings()
settings.maxEdgeLen = 0.2
settings.maxEdgeSplits = 100000
settings.maxDeviationAfterFlip = 0.2
settings.region = newFacesBitSet
# accum new verts after subdivide for optional curvature positioning
newVertsBitSet = mm.VertBitSet()
settings.newVerts = newVertsBitSet
mm.subdivideMesh(mesh, settings)
# optional positioning
mm.positionVertsSmoothly(mesh, newVertsBitSet)
mm.saveMesh(mesh, mm.Path("res2.ply")) gave the same result as #1402 (comment) |
Hello, I found that the problem may be from the numpy_mrmesh_conversion code(in my test code below). The conversion is good for most of meshes I tested, but failed with the one here. I saved the testing mesh to npy format to show the problem, because the conversion will be correct after writing and reading back with ply format. The test mesh data(npy format), Below is my test code. It reads the npy mesh, and prints some mesh information to compare. The problem is, if directly converting the npy mesh using numpy_mrmesh_conversion code(mrmesh_from_numpy, mrmesh_to_numpy), the mesh will change a lot and look strange.
And below is the console output,
And below is the output files, |
We are now relay on elements order in memory when reading numpy arrays, thats why it loads incorrectly import numpy as np
from meshlib import mrmeshpy as mm
from meshlib import mrmeshnumpy as mn
verts = np.load("verts.npy")
#make 'C' order for this array
vShape = verts.shape
verts = verts.flatten().reshape(vShape)
#change dtype to int32 and make 'C' order
faces = np.load("faces.npy").astype(np.int32,order='C');
mesh = mn.meshFromFacesVerts(faces, verts)
mm.saveMesh(mesh, "mesh.ply") Looks like this should work, anyway we will try to improve this in future. |
Hello,
I'm testing stitching_two_holes function using python code which is similar to here, but got bad result in some cases. For example, (1) very narrow triangle directly linking the two hole border even after subdivision. (2) or the result mesh is exploded. I modified some filing hole configurations but cannot solve those problems. Besides, because we cannot modify the mesh's existing region when filing holes, I need to set SubdivideSettings.subdivideBorder=False(but this cannot avoid problems).
I tested the meshInspector's stitching_two_holes function, and it works correctly on my test meshes. I wonder if you can provide some sample code which can get same result as MeshInspector. With that, we can compare hole filling result with meshinspector directly when we encountered bad result. And it will be much convenient to report problems to you.
Thanks.
The text was updated successfully, but these errors were encountered: