Metadata-Version: 2.1
Name: normal-position-combination
Version: 0.0.2
Summary: Python Binding for Efficiently Combining Positions and Normals for Precise 3D Geometry
Author-Email: NCJ <me@ncj.wiki>
License: MIT License
        
        Copyright (c) 2024 NCJ
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX :: Linux
Classifier: Topic :: Multimedia :: Graphics :: 3D Modeling
Project-URL: Homepage, https://github.com/iamNCJ/normal-position-combination
Requires-Python: >=3.8
Requires-Dist: trimesh
Description-Content-Type: text/markdown

# normal-position-combination
Python Binding for Efficiently Combining Positions and Normals for Precise 3D Geometry

[![Build & Test](https://github.com/iamNCJ/normal-position-combination/actions/workflows/build_test.yml/badge.svg)](https://github.com/iamNCJ/normal-position-combination/actions/workflows/build_test.yml) [![Publish to Pypi](https://github.com/iamNCJ/normal-position-combination/actions/workflows/release_pypi.yml/badge.svg)](https://github.com/iamNCJ/normal-position-combination/actions/workflows/release_pypi.yml)

| Before | After | Before | After |
| --- | --- | --- | --- |
| ![Before](./imgs/panel-before.png) | ![After](./imgs/panel-after.png) | ![Before](./imgs/car-before.png) | ![After](./imgs/car-after.png) |

```text
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](https://w3.impa.br/~diego/software/NehEtAl05/)

## Install

```bash
pip install normal-position-combination
```

## Usage

First you need to have a mesh **with** (relatively) accurate vertex normals. The method will optimize the vertex positions to better fit the normals.

### Process a `trimesh.Trimesh` Object

```python
import trimesh
import normal_position_combination as npc
mesh = trimesh.load_mesh('./sample_data/panel.ply')
optimized_mesh = npc.process_trimesh(mesh)
```

### Directly Process a Mesh File

```python
import normal_position_combination as npc
npc.process_mesh_file(
    input_filename='./sample_data/panel.ply',
    output_filename='./sample_data/processed-panel.ply'
)
```

### Parameters

Please refer to the original implementation's [manual](https://w3.impa.br/~diego/software/NehEtAl05/reference.html) for the detailed explanation of the parameters.

## Build from Source

### Ubuntu / Debian

```bash
# 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 .
```

### RHEL Series

```bash
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 .
```
