Code Monkey home page Code Monkey logo

Comments (8)

Rjialceky avatar Rjialceky commented on June 7, 2024 1

Thanks! FWIW, here's a working version of my example recast per the new functions and classes. The last little hurdle was to realize that Python crashes if you attempt to iterate on meshlib.mrmeshpy.vectorEdgePath and meshlib.mrmeshpy.Contour3f objects, rather than index them based on their size.

import numpy as np
import meshlib.mrmeshpy as mm
import meshlib.mrmeshnumpy as mmnp
faces = np.ndarray(shape=(2,3), dtype=np.int32, buffer=np.array([[0,1,2],[0,2,3]], dtype=np.int32))
verts = np.ndarray(shape=(4,3), dtype=np.float32, buffer=np.array([[0.0,0.0,0.0],[1.0,0.0,0.0],[1.0,1.0,0.0],[0.0,1.0,0.0]], dtype=np.float32))
mesh = mmnp.meshFromFacesVerts(faces, verts)
mesh_vector_edge_pathing = mm.findRightBoundary(mesh.topology)
poly_rings = []
for i in range(mesh_vector_edge_pathing.size()):
    poly_ring = mm.Polyline3()
    poly_ring_first_edge = poly_ring.addFromEdgePath(mesh, mesh_vector_edge_pathing[i])
    ring_pts = poly_ring.points.vec
    poly_rings.append([(ring_pts[i].x, ring_pts[i].y, ring_pts[i].z) for i in range(ring_pts.size())])

from meshlib.

Rjialceky avatar Rjialceky commented on June 7, 2024 1

Ah, that makes sense -- thanks for investigating / much appreciated!

from meshlib.

Grantim avatar Grantim commented on June 7, 2024

Hello!
findBoundary functoin is depricated now, there is new function

---mesh_boundary_vector_edge_path = mesh.topology.findBoundary()
+++mesh_boundary_vector_edge_path = mm.findRightBoundary( mesh.topology )

You can find this command helpful (it will show all available functions and classes)

help( mm )

from meshlib.

Grantim avatar Grantim commented on June 7, 2024

Thanks for feedback, we wiil have a look into iterating over internal vector structures

from meshlib.

Grantim avatar Grantim commented on June 7, 2024

I have jsut try simple iteration:

mesh_vector_edge_pathing = mm.findRightBoundary(mesh.topology)
assert (mesh_vector_edge_pathing.size() == len(mesh_vector_edge_pathing) )
for edgePath in mesh_vector_edge_pathing:
	print(edgePath)

and it worked.

Can you please show how to reproduce crash?

from meshlib.

Rjialceky avatar Rjialceky commented on June 7, 2024

Thanks for looking into this. I tried a similar simple iteration and it worked. Retracing my prior tests, I see now that it is only if I include an import of pymeshlab would attempts at the same iteration crashes Python. Following your example, the [one] edgePath prints followed by a few second delay and a crash of Python. The version involved is PyMeshLab 2022.2.post4 based on MeshLab 2022.02d:

Python 3.9.18 | packaged by conda-forge | (main, Aug 30 2023, 03:40:31) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> import meshlib.mrmeshpy as mm
>>> import meshlib.mrmeshnumpy as mmnp
>>> import pymeshlab as ml  # including this creates Python crash problem for meshlib iteration
>>> faces = np.ndarray(shape=(2,3), dtype=np.int32, buffer=np.array([[0,1,2],[0,2,3]], dtype=np.int32))
>>> verts = np.ndarray(shape=(4,3), dtype=np.float32, buffer=np.array([[0.0,0.0,0.0],[1.0,0.0,0.0],[1.0,1.0,0.0],[0.0,1.0,0.0]], dtype=np.float32))
>>> mesh = mmnp.meshFromFacesVerts(faces, verts)
>>> mesh_vector_edge_pathing = mm.findRightBoundary(mesh.topology)
>>> for edgePath in mesh_vector_edge_pathing:
...     print(edgePath)
...
vectorEdges[1, 9, 7, 3]
<Python crash>

from meshlib.

Grantim avatar Grantim commented on June 7, 2024

Very interesting, thanks for update

from meshlib.

Grantim avatar Grantim commented on June 7, 2024

I have investigated a little bit and here is what I've found:
pymeshlab requires msvc-runtime (from pymeshlab) (14.34.31931) but we build our binaries with newer version of MSVC that is distributed with our modules
image

looks like import pymeshlab links older MSVCP140.dll that overrides some functions from our linked dll.

I've swapped import lines and it worked without crash

>>> import numpy as np
>>> import pymeshlab as ml  # including this creates Python crash problem for meshlib iteration
>>> import meshlib.mrmeshpy as mm
>>> import meshlib.mrmeshnumpy as mmnp
>>> faces = np.ndarray(shape=(2,3), dtype=np.int32, buffer=np.array([[0,1,2],[0,2,3]], dtype=np.int32))
>>> verts = np.ndarray(shape=(4,3), dtype=np.float32, buffer=np.array([[0.0,0.0,0.0],[1.0,0.0,0.0],[1.0,1.0,0.0],[0.0,1.0,0.0]], dtype=np.float32))
>>> mesh = mmnp.meshFromFacesVerts(faces, verts)
>>> mesh_vector_edge_pathing = mm.findRightBoundary(mesh.topology)
>>> for edgePath in mesh_vector_edge_pathing:
...     print(edgePath)
...
vectorEdges[1, 9, 7, 3]

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.