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++.
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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mpfp-1.0.1-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: mpfp-1.0.1-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 204.5 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a10c467eb8e60e503f910ea64589a7c7f4dc78a24f664c85af54dcf05f9ad1c7
|
|
| MD5 |
f82c77fe363ad1d31567f1498c6e2231
|
|
| BLAKE2b-256 |
f4bbf6ba87c923abd42d8672caf4b286cf0d623d57926ae558f934fa03977354
|
File details
Details for the file mpfp-1.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: mpfp-1.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 222.6 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f64cabdfda089fc0c63778395598546e85315ca84c932055e4e61f21bee1e3a6
|
|
| MD5 |
205a3694d8e62273e144a1e2d41e0c47
|
|
| BLAKE2b-256 |
a4f72394cc844ec13fe1ceb3022dfb3353aa45894d6bcab2f9b5d909d22e192a
|
File details
Details for the file mpfp-1.0.1-cp311-cp311-macosx_14_0_arm64.whl.
File metadata
- Download URL: mpfp-1.0.1-cp311-cp311-macosx_14_0_arm64.whl
- Upload date:
- Size: 182.3 kB
- Tags: CPython 3.11, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3630088641b8978111d2ab2c75efbaa690059f281104830439212a40981d9f36
|
|
| MD5 |
de44e8d2101752e70e4a9d4fce9d6693
|
|
| BLAKE2b-256 |
4dd9d65224d6387200cd690fbac28a9b15c018c7f7e5c5339b4e062dd1d8ce81
|