Python Binding for Efficiently Combining Positions and Normals for Precise 3D Geometry
Before | After | Before | After |
---|---|---|---|
Efficiently Combining Positions and Normals for Precise 3D Geometry
Nehab, D.; Rusinkiewicz, S.; Davis, J.; Ramamoorthi, R.
ACM Transactions on Graphics - SIGGRAPH 2005
Los Angeles, California, July 2005, Volume 24, Issue 3, pp. 536-543
Original C++ implementation: normal-position-combination
pip install normal-position-combination
First you need to have a mesh with (relatively) accurate vertex normals. The method will optimize the vertex positions to better fit the normals.
import trimesh
import normal_position_combination as npc
mesh = trimesh.load_mesh('./sample_data/panel.ply')
optimized_mesh = npc.process_trimesh(mesh)
Input mesh vertices, faces, and normals as numpy
arrays, and get the optimized vertices.
import numpy as np
import normal_position_combination as npc
mesh = trimesh.load_mesh('./sample_data/panel.ply')
optimized_vertices = npc.process_ndarray(
np.array(mesh.vertices, dtype=np.float32),
np.array(mesh.faces, dtype=np.int64),
np.array(mesh.vertex_normals, dtype=np.float32),
)
import normal_position_combination as npc
npc.process_mesh_file(
input_filename='./sample_data/panel.ply',
output_filename='./sample_data/processed-panel.ply'
)
Please refer to the original implementation's manual for the detailed explanation of the parameters.
# build trimesh2
sudo apt install libglu1-mesa libglu1-mesa-dev libxi-dev
cd submodules/trimesh2
make -j
# build normal-position-combination
cd ../..
sudo apt install libsuitesparse-dev
pip install .
sudo yum install mesa-libGLU mesa-libGLU-devel libXi-devel suitesparse-devel openblas-devel libomp-devel
cd submodules/trimesh2
make -j
cd ../..
sudo yum install suitesparse-devel
pip install .