Skip to main content

A small geometry processing package for mesh planarization

Project description

Make Planar Faces Plus

A small geometry processing package for mesh planarization written in C++.

Badge referencing TinyAD.

Here is an example to get you started

# necessary imports 
from mpfp import make_planar_faces, MakePlanarSettings
# prepare mesh data (in praxis you would create this data from your mesh)
vertices = [[0,0,0], [1,0,0], [1,1,0], [0,1,1]]
faces = [[0,1,2,3]]
fixed_vertices = [0,1,2]
# here is a list of all available settings (with default values):
opt_settings = MakePlanarSettings()
opt_settings.optimization_rounds = 100
opt_settings.max_iterations = 100
opt_settings.closeness_weight = 10
opt_settings.min_closeness_weight = 0.0
opt_settings.verbose = True
opt_settings.projection_eps = 1e-16
opt_settings.w_identity = 1e-16
opt_settings.convergence_eps = 1e-16
# optimize
optimized_vertices = make_planar_faces(vertices, faces, fixed_vertices, opt_settings)
# print the result
print(optimized_vertices)

How to encode your Mesh

You provide your mesh to the make_planar_faces function via the two parameters:

  • vertices: A list of 3D vertex coordinates. You can provide them as a 2d list or a numpy array with shape (n, 3).
  • faces: A list of all mesh faces. Each face has to be provided as a list of vertex indices in ccw or cw order.

Details

The function provided by this module aims to make each face of a mesh planar. It solves a global optimization problem in order to make faces planar while preserving the objects shape as much as possible.

You can control the strength of this shape preservation objective via the closeness_weight and min_closeness_weight parameter. The algorithm will interpolate between the two while optimizing. If you struggle to get decent results, try increasing the closeness_weight and the number of optimization rounds.

The algorithm will always try to optimize the entire mesh. By providing the index list fixed_vertices, all selected vertices will not be ignored by the optimizer. This may be useful when you want to preserve certain features.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mpfp-1.0.0-cp311-cp311-win_amd64.whl (208.9 kB view details)

Uploaded CPython 3.11Windows x86-64

File details

Details for the file mpfp-1.0.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: mpfp-1.0.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 208.9 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for mpfp-1.0.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c8c0152d5878958790856725549fb8cd6b00a6e08248bf87e6f78342f1448584
MD5 677ca5dcbad013505575d66c74861ba3
BLAKE2b-256 46462f71e97c7b20ed93a1ad7f01b882159740f879e138218249e754f4d4839f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page