trimesh | Python library for loading and using triangular meshes | Service Mesh library

 by   mikedh Python Version: 4.2.2 License: MIT

kandi X-RAY | trimesh Summary

kandi X-RAY | trimesh Summary

trimesh is a Python library typically used in Institutions, Learning, Education, Architecture, Service Mesh applications. trimesh has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has high support. You can install using 'pip install trimesh' or download it from GitHub, PyPI.

Trimesh is a pure Python (2.7-3.4+) library for loading and using triangular meshes with an emphasis on watertight surfaces. The goal of the library is to provide a full featured and well tested Trimesh object which allows for easy manipulation and analysis, in the style of the Polygon object in the Shapely library. The API is mostly stable, but this should not be relied on and is not guaranteed: install a specific version if you plan on deploying something using trimesh. Pull requests are appreciated and responded to promptly! If you'd like to contribute, here is an up to date list of potential enhancements although things not on that list are also welcome. Here are some tips for writing mesh code in Python.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              trimesh has a highly active ecosystem.
              It has 2365 star(s) with 511 fork(s). There are 42 watchers for this library.
              There were 10 major release(s) in the last 6 months.
              There are 344 open issues and 1008 have been closed. On average issues are closed in 16 days. There are 3 open pull requests and 0 closed requests.
              It has a positive sentiment in the developer community.
              The latest version of trimesh is 4.2.2

            kandi-Quality Quality

              trimesh has 0 bugs and 0 code smells.

            kandi-Security Security

              trimesh has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              trimesh code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              trimesh is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              trimesh releases are available to install and integrate.
              Deployable package is available in PyPI.
              Build file is available. You can build the component from source.
              Installation instructions, examples and code snippets are available.
              It has 30348 lines of code, 2189 functions and 239 files.
              It has high code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed trimesh and discovered the below as its top functions. This is intended to give you an instant insight into trimesh implemented functionality, and help decide if they suit your requirements.
            • Read mesh data into numpy arrays .
            • Convert DXF file to trimesh entities .
            • Load a 3D scene from a 3D file .
            • Export a DXF file .
            • Loads Materials Materials from a file - like object .
            • Export a 3D mesh .
            • Slice a list of faces .
            • Load a 3D mesh .
            • Make a mesh on a plane .
            • Convert a PLY element into a dictionary .
            Get all kandi verified functions for this library.

            trimesh Key Features

            No Key Features are available at this moment for trimesh.

            trimesh Examples and Code Snippets

            4. Graphics
            C++dot img1Lines of Code : 78dot img1License : Permissive (BSD-3-Clause)
            copy iconCopy
            auto vertBatch = gl::VertBatch::create();
            vertBatch->begin( GL_POINTS );
            for( auto p : mPoints ) {
            	vertBatch->vertex( p );
            }
            vertBatch->draw();  
            
            auto trimesh = TriMesh();
            // we first add 3 positions to the TriMesh
            trimesh.appendPosition(   
            Alpha Shape Toolbox,Using a varying Alpha Parameter,3 Dimensional Example
            Pythondot img2Lines of Code : 30dot img2License : Permissive (MIT)
            copy iconCopy
            points_3d = [
                (0., 0., 0.), (0., 0., 1.), (0., 1., 0.),
                (1., 0., 0.), (1., 1., 0.), (1., 0., 1.),
                (0., 1., 1.), (1., 1., 1.), (.25, .5, .5),
                (.5, .25, .5), (.5, .5, .25), (.75, .5, .5),
                (.5, .75, .5), (.5, .5, .75)
            ]
            
            fig = plt.fi  
            Skeletor,Quickstart
            Pythondot img3Lines of Code : 28dot img3License : Strong Copyleft (GPL-3.0)
            copy iconCopy
            >>> import skeletor as sk
            >>> mesh = sk.example_mesh()
            >>> fixed = sk.pre.fix_mesh(mesh, remove_disconnected=5, inplace=False)
            >>> skel = sk.skeletonize.by_wavefront(fixed, waves=1, step_size=1)
            >>> skel
            
              
            How do you extract faces from a numpy-stl mesh?
            Pythondot img4Lines of Code : 7dot img4License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            # Package
            import trimesh
            
            myobj = trimesh.load_mesh("tank.stl", enable_post_processing=True, solid=True) # Import Objects
            myobj.show()
            print(myobj.faces)
            
            error using trimesh library on python - " no graph engine available "
            Pythondot img5Lines of Code : 4dot img5License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            pip install trimesh[easy]
            
            pip install trimesh[all]
            
            pip install -r requirements.txt throws an error when using venv instead of anaconda python
            Pythondot img6Lines of Code : 5dot img6License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            $ pip install pip --upgrade
            
            
            $ pip install setuptools --upgrade 
            
            how to make an open stl file watertight
            Pythondot img7Lines of Code : 28dot img7License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            input1 = vtk.vtkPolyData()
            input2 = vtk.vtkPolyData()
            
            
            input1.DeepCopy(Data1.GetOutput())
            input2.DeepCopy(Data2.GetOutput())
            
            # Append the two meshes 
            appendFilter = vtk.vtkAppendPolyData()
            
            appendFilter.AddInputData(input1)
            appendFilter.
            rotate a mesh in python to be parallel to a vector
            Pythondot img8Lines of Code : 15dot img8License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            #this function to create a rotation matrix was taken from https://stackoverflow.com/q/63525482/6010071
            def rotation_matrix_from_vectors(vec1, vec2):
            
                a, b = (vec1 / np.linalg.norm(vec1)).reshape(3), (vec2 / np.linalg.norm(vec2)).reshap
            trimesh.section face_index doesn't map to the returned Path3D?
            Pythondot img9Lines of Code : 15dot img9License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            paths = inner.section(plane_origin=origin, plane_normal=norm)
            # find the closed path entity with a centroid nearest to the plane origin
            nearest, idx = _find_nearest_closed_path(origin, paths)
            face_adjacency = trimesh.graph.face_adjacency(i
            Unable to convert 3d ply file image to 2d image
            Pythondot img10Lines of Code : 38dot img10License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import numpy as np
            import trimesh
            import pyrender
            import matplotlib.pyplot as plt
            fuze_trimesh = trimesh.load('examples/models/fuze.obj')
            mesh = pyrender.Mesh.from_trimesh(fuze_trimesh)
            scene = pyrender.Scene()
            scene.add(mesh)
            camera = pyr

            Community Discussions

            QUESTION

            Why all objects are sliding? Concave polygon collision shape in godot 3
            Asked 2021-Dec-15 at 15:15

            I have a plane mesh. I just click on mesh -> create trimesh collision sibling
            Then, I have a collision shape (concave polygon) and if i adding kinematicBody3d, or StaticBody3d, or RigidBody3d, etc. These objects are sliding (moving) on a surface (or not)

            added object:

            after a few seconds

            but if I change collision shape mode, it will work correctly

            ...

            ANSWER

            Answered 2021-Dec-15 at 09:22

            Rigid bodies are effected by physics. To control this, there are several paramters. What I think you might be looking for is the linear damp property

            https://docs.godotengine.org/en/stable/classes/class_projectsettings.html#class-projectsettings-property-physics-3d-default-linear-damp

            If you set it to 60, you should stop the object in one frame

            Source https://stackoverflow.com/questions/70358780

            QUESTION

            Pip lists package as outdated but updating results in Requirement already satisfied
            Asked 2021-Oct-17 at 21:02

            Solved using sudo pip install -U

            So when I do pip list --outdated I get:

            ...

            ANSWER

            Answered 2021-Oct-17 at 20:08

            See this, and as you can guess the problem here is Defaulting to user installation because normal site-packages is not writeable which relates to some permission related issues which I am not sure of.

            You can use here python3 -m pip install -U .

            A stable solution could be to reinstall python from scratch in your system.

            Source https://stackoverflow.com/questions/69608072

            QUESTION

            PyVista `add_volume`: Garbled Output & Slower than ParaView
            Asked 2021-Sep-16 at 17:40
            Questions:

            Update 14-SEP-2021: Simplified problem even further to a smaller MRE. After some analysis, it doesn't seem Qt threading is the culprit, so corresponding Qt code was removed.

            1. pyvista does not plot my volume along the correct axis and the output is garbled. ParaView on the other hand plots things properly. How can I fix this?

              (NOTE: I cannot share the actual data because it is confidential. However, below you can see pyvista orients my data along the z-axis, when in fact it should be along the x-axis, and that it is garbled. I show the bounding box in ParaView.

              The results are the same regardless if I use the fixed_point vs. smart volume mappers. I use fixed_point since I am on Windows.)

            pyvista:

            ParaView:

            1. Plotting volumes in pyvista is much slower than in ParaView. Is there some way I can make this faster?

              The time for my code with pyvista vs. ParaView is

              ...

            ANSWER

            Answered 2021-Sep-16 at 17:40

            In pyvista version 0.32.1, the lines of code in pyvista/plotting/plotting.py function add_volume here are problematic:

            Source https://stackoverflow.com/questions/69080189

            QUESTION

            How to make a custom collider that will deform with a skeleton in Godot
            Asked 2021-Aug-27 at 22:13

            I would like to make a collision detector for a mesh I have imported from blender. The mesh is parented to a skeleton, which I use to deform the mesh. I would like to attach a collider to it in order to implement physics. Instead of attaching a general shape collider like a cube or sphere to the mesh, I want it to be an accurate copy of the mesh itself. I've tried adding a Trimesh Static Body, which does make a collider the same shape as the mesh, however since it's static, it won't deform with a skeleton. Is there a way to generate a collider the same shape as a mesh that would deform with a skeleton and also stay with the mesh as it moves around?

            ...

            ANSWER

            Answered 2021-Aug-27 at 22:13

            You can make a collider the same shape as a skeleton / mesh that is deformed by a skeleton by using the BoneAttachement node, which is a subcategory of the Spatial class. By using this node, you can attach a primitive shape collider to each bone in your skeleton. This will result in a mostly accurate collider shape made up of many smaller colliders that will deform and stay with the skeleton.

            Step 1:

            Add a BoneAttachment node as a child of the Skeleton node in your model. Set the bone name property to whatever bone you would like the collision shape to follow. After this is done, any nodes parented to this BoneAttachment node will copy the transform of the bone which it is set to.

            Step 2:

            Add either a KinematicBody or an Area node as a child of the BoneAttachment node. Don't add a RigidBody, because they're meant to be controlled by physics only, so this won't work if you add it.

            • If you add a KinematicBody node, your collider won't be affected by physics, but other objects like a RigidBody will still collide and bounce off of it.

            • If you add an Area node, your collider won't directly affect any physics objects that come into contact with it (objects will pass right through it), but you can write a script that will cause some effect to happen when objects contact it. For example, you could make it so that when an object enters the area, a force is applied to it and it gets pushed away.

            Step 3:

            Add a CollisionShape node as a child of whatever PhysicsBody you chose in the last step. Choose the shape and configure its transform so it copies the shape of the part of the mesh you are working on. Then, repeat these steps for each bone of the skeleton until you have an accurately shaped collider.

            Source https://stackoverflow.com/questions/68868990

            QUESTION

            CMake Build Help for `pyembree`
            Asked 2021-Aug-01 at 17:24

            I am looking for help building pyembree from source with CMake for Windows. Further details for the history of this question are listed here on GitHub. Windows support for pyembree on conda-forge was just removed, so any help that can be provided would be much appreciated!

            Installation Instructions System

            Tested on:

            OS: Windows 10 x64 Professional, Build 1909 Python: 3.8.10

            Steps
            1. Install Microsoft Visual C++ 14.X and Windows 10 SDK. These are required for building cython code.

            (NOTE: The version of Microsoft Visual Studio is not the same as the version of Microsoft Visual C++. Visual Studio 2015, 2017, and 2019 all have MSVCv14X build tools. At the time of this writing, installing the Visual Studio 2019 Build Tools with

            MSVCv142 - VS 2019 C++ x64/x86 build tools and Windows 10 SDK (10.0.18362.0)

            components will suffice (select the Desktop development with C++ Workload if installing Visual Studio 2019).

            1. Install vcpkg in C:\\vcpkg and add the path to your System Environment Variables:
            ...

            ANSWER

            Answered 2021-Aug-01 at 17:24

            CMake is actually not required. For complete instructions, please see my solution on Install pyembree on Windows without Conda #468.

            Source https://stackoverflow.com/questions/68578252

            QUESTION

            error using trimesh library on python - " no graph engine available "
            Asked 2021-May-08 at 03:03

            I was wondering if you have used the library "trimesh" in python. It looks quite useful, but right now im having some trouble with the method "Trimesh.spli()" on the last line of the code attached. the code was working fine up to that line, which is suppose to return a list of trimesh objects.

            However, when I try to run this code, I get the error ImportError: no graph engines available! Do you know how can I set up a graph engine? or if there is any turnaround this issue? Thanks for your support, Regards

            ...

            ANSWER

            Answered 2021-May-08 at 03:03

            I found the issue. The library does not install all dependancies unless you ask for it. Usually, it only requires numpy.

            One option to install most of the dependancies is:

            Source https://stackoverflow.com/questions/67443127

            QUESTION

            How do I apply a material to a .glb/.gltf mesh?
            Asked 2021-Feb-11 at 09:12

            I have a model in .glb format with nothing edit(but a mesh) in the scene. How do I apply a material of a glb/gltf mesh using Python? I am using Pygltflib and Trimesh although I can use other libraries.

            ...

            ANSWER

            Answered 2021-Feb-11 at 09:12

            I can only give a genereal answer, because you did not provide any code, but you would do it like this in principal:

            Source https://stackoverflow.com/questions/66127030

            QUESTION

            pip install -r requirements.txt throws an error when using venv instead of anaconda python
            Asked 2021-Jan-07 at 00:02

            when I use anaconda python I can install this requirements.txt with no problem using pip install -r requirements.txt however, when I use venv, I get this error. Do you know how I can fix it? https://pastebin.com/raw/9eUc7H9x

            ...

            ANSWER

            Answered 2021-Jan-07 at 00:02
            $ pip install pip --upgrade
            
            
            $ pip install setuptools --upgrade 
            

            Source https://stackoverflow.com/questions/65604750

            QUESTION

            Python Implementation for creating a triangular mesh from an array of closed loop planar contours
            Asked 2020-Dec-13 at 11:52

            I'm a wee bit stuck.

            I have a 3D point cloud (an array of (n,3) vertices), in which I am trying to generate a 3D triangular mesh from. So far I have had no luck.

            The format my data comes in:

            • (x,y) values in regularly spaced (z) intervals. Think of the data as closed loop planar contours stored slice by slice in the z direction.
            • The vertices in my data must be absolute positions for the mesh triangles (i.e. I don't want them to be smoothed out such that the volume begins to change shape, but linear interpolation between the layers is fine).

            Illustration:

            ...

            ANSWER

            Answered 2020-Sep-04 at 06:49

            Actually there are two ways of having meshlab functionality in python:

            1. The first is MeshLabXML (https://github.com/3DLIRIOUS/MeshLabXML ) a third party, is a Python scripting interface to meshlab scripting interface
            2. the second is PyMeshLab (https://github.com/cnr-isti-vclab/PyMeshLab ) an ongoing effort done by the MeshLab authors, (currently in alpha stage) to have a direct Python bindings to all the meshlab filters

            Source https://stackoverflow.com/questions/63734323

            QUESTION

            Is it possible to create a thick Mesh?
            Asked 2020-Dec-12 at 14:31

            I'm totally new to this field, I'm using python and Trimesh to create a 3D model of a bone and I need to figure out how can I create or represent the thickness of the bone I only have surface of the bone which is ok, but I need also to represent how the bone looks inside this surface, Anyone has a clue on how to approach this problem?

            Ask me if you need more information, I'm not sure what you need to know to understand the problem.

            Thanks in advance.

            ...

            ANSWER

            Answered 2020-Jul-02 at 14:15

            You can use gmsh along with mmg to mesh in volume your surface.

            Source https://stackoverflow.com/questions/62679345

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install trimesh

            Keeping trimesh easy to install is a core goal, thus the only hard dependency is numpy. Installing other packages adds functionality but is not required. For the easiest install with just numpy, pip can generally install trimesh cleanly on Windows, Linux, and OSX:.
            Here is an example of loading a mesh from file and colorizing its faces. Here is a nicely formatted ipython notebook version of this example. Also check out the cross section example or possibly the integration of a function over a mesh example.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
          • PyPI

            pip install trimesh

          • CLONE
          • HTTPS

            https://github.com/mikedh/trimesh.git

          • CLI

            gh repo clone mikedh/trimesh

          • sshUrl

            git@github.com:mikedh/trimesh.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link