Git Product home page Git Product logo

quadric-mesh-simplification's Introduction

Quadric mesh simplification

A leightweight package for simplifying a mesh containing node features. The algorithm from Surface Simplification Using Quadric Error Metrics was implemented using cython.

Installation

with pip

$ pip install quad_mesh_simplify

from source if distribution is not supported

Download this repository and build the package by running:

$ pip install -r requirements.txt
$ python setup.py build_ext --inplace
$ pip install .

Usage

This package provides one simple function to reduce a given mesh. This can be done for simple meshes or meshes with vertex features.

simplify_mesh(positions, face, num_nodes, features=None, threshold=0., max_err=np.Infinity)

positions (numpy array): array of shape [num_nodes x 3] containing the x, y, z position for each node

face (numpy array): array of shape [num_faces x 3] containing the indices for each triangular face

num_nodes (int): number of nodes that the final mesh will have threshold (number, optional): threshold of vertices distance to be a valid pair

features (numpy array): features for all nodes [num_nodes x feature_length]

threshold (double): if the distance between two vertices is below this threshold, they are considered as valid pairs that can be merged.

max_err (double): no vertices are merged that have an error higher than this number. IMPORTANT: if provided it is not guaranteed that the output will have less than num_nodes vertices.

Returns: new_positions, new_face, (new_features)

Reduce a simple mesh

    from quad_mesh_simplify import simplify_mesh

    new_positions, new_face = simplify_mesh(positions, face, <final_num_nodes>)

Reduce a mesh with vertex features

    from quad_mesh_simplify import simplify_mesh

    new_positions, new_face = simplify_mesh(positions, face, <final_num_nodes>, features=features)

Reduce a mesh with a threshold for the minimal distance

    from quad_mesh_simplify import simplify_mesh

    new_positions, new_face = simplify_mesh(positions, face, <final_num_nodes>, threshold=0.5)

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.