Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ test_config.h

# Python cache files
setup.py
Pipfile.lock
poetry.lock
*.pyc
*.pyd
dist/*
__pycache__/*
__pycache__/
*.egg-info
.ipynb_checkpoints/

# Mesh file format
*.ply
Expand Down
21 changes: 12 additions & 9 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
[submodule "src/tinymesh/ext/tinyobjloader"]
path = src/tinymesh/ext/tinyobjloader
url = https://github.com/syoyo/tinyobjloader
[submodule "src/tinymesh/ext/tinyply"]
path = src/tinymesh/ext/tinyply
url = https://github.com/ddiakopoulos/tinyply
[submodule "src/tinymesh/ext/eigen"]
path = src/tinymesh/ext/eigen
url = https://gitlab.com/libeigen/eigen.git
[submodule "src/tinymesh/ext/tinyobjloader"]
path = src/tinymesh/ext/tinyobjloader
url = https://github.com/syoyo/tinyobjloader
[submodule "src/tinymesh/ext/tinyply"]
path = src/tinymesh/ext/tinyply
url = https://github.com/ddiakopoulos/tinyply
[submodule "src/tinymesh/ext/eigen"]
path = src/tinymesh/ext/eigen
url = https://gitlab.com/libeigen/eigen.git
[submodule "src/tinymesh/ext/spectra"]
path = src/tinymesh/ext/spectra
url = https://github.com/yixuan/spectra
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
v 0.2.1
v0.2.2
---
* Change Python env manager to Pipenv.
* Add methods computing approximated Laplacian-Beltrami operators (adjacent, cotangent, Belkin+2008).
* Add IPython notebooks as Pythons examples rather than simple scripts.
* Change traversal order of elements around a vertex to counter-clockwise order.
* Add heat kernel signature [Sun et al. 2009].

v0.2.1
---
* Minor bug fix for GCC v8.

v.0.2.0
v0.2.0
---

* Add unit test for each functions (just to check run or not).
Expand Down
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
cmake_minimum_required(VERSION 3.18.0 FATAL_ERROR)
project(TinyMesh)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
Expand All @@ -21,6 +21,7 @@ if (UNIX)
set(CXX_FS_LIBRARY "stdc++fs")
endif()
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# ----------
# Common target names
Expand Down
22 changes: 22 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
numpy = "*"
open3d = "*"
matplotlib = "*"
poetry = "*"
scipy = "*"

[dev-packages]
yapf = "*"
flake8 = "*"
mypy = "*"
isort = "*"
pytest = "*"
jupyterlab = "*"

[requires]
python_version = "3.9"
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ TinyMesh
![Ubuntu CI](https://github.com/tatsy/tinymesh/workflows/Ubuntu%20CI/badge.svg)
[![License: MPL 2.0](https://img.shields.io/badge/License-MPL%202.0-brightgreen.svg)](https://opensource.org/licenses/MPL-2.0)

> TinyMesh is a light-weight mesh processing library in C/C++
> TinyMesh is a light-weight mesh processing library in C/C++.

[!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/tatsy425)


Modules
---
Expand Down
117 changes: 59 additions & 58 deletions build.py
Original file line number Diff line number Diff line change
@@ -1,58 +1,59 @@
import re
import pathlib
import platform

from pybind11.setup_helpers import Pybind11Extension
from setuptools.command.build_ext import build_ext

exclude = ['src/tinymesh/ext']
sources = pathlib.Path().glob('src/**/*.cpp')
sources = [str(path).replace('\\', '/') for path in sources]
sources = [path for path in sources if all([not re.search(e, path) for e in exclude])]

include_dirs = [
'src/tinymesh',
'src/tinymesh/ext/tinyobjloader',
'src/tinymesh/ext/tinyply/source',
'src/tinymesh/ext/eigen',
]

extra_compile_args = []
extra_link_args = []
define_macros = [('TINYMESH_PYTHON_MODULE', 1)]
if platform.system() == "Windows":
define_macros.append(('_SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING', 1))
elif platform.system() == "Darwin":
extra_compile_args.extend([
'-std=c++17',
'-mmacosx-version-min=10.15',
])
# extra_link_args.extend([
# '-lstdc++fs',
# ])
else:
extra_compile_args.extend([
'-std=c++17',
])
extra_link_args.extend([
'-lstdc++fs',
])

ext_modules = [
Pybind11Extension('tinymesh',
sources,
language='c++',
include_dirs=include_dirs,
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
define_macros=define_macros)
]


def build(setup_kwargs):
setup_kwargs.update({
'ext_modules': ext_modules,
'cmdclass': {
'build_ext': build_ext
},
})
import re
import pathlib
import platform

from pybind11.setup_helpers import Pybind11Extension
from setuptools.command.build_ext import build_ext

exclude = ['src/tinymesh/ext']
sources = pathlib.Path().glob('src/**/*.cpp')
sources = [str(path).replace('\\', '/') for path in sources]
sources = [path for path in sources if all([not re.search(e, path) for e in exclude])]

include_dirs = [
'src/tinymesh',
'src/tinymesh/ext/tinyobjloader',
'src/tinymesh/ext/tinyply/source',
'src/tinymesh/ext/eigen',
'src/tinymesh/ext/spectra/include',
]

extra_compile_args = []
extra_link_args = []
define_macros = [('TINYMESH_PYTHON_MODULE', 1)]
if platform.system() == "Windows":
define_macros.append(('_SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING', 1))
elif platform.system() == "Darwin":
extra_compile_args.extend([
'-std=c++17',
'-mmacosx-version-min=10.15',
])
# extra_link_args.extend([
# '-lstdc++fs',
# ])
else:
extra_compile_args.extend([
'-std=c++17',
])
extra_link_args.extend([
'-lstdc++fs',
])

ext_modules = [
Pybind11Extension('tinymesh',
sources,
language='c++',
include_dirs=include_dirs,
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
define_macros=define_macros)
]


def build(setup_kwargs):
setup_kwargs.update({
'ext_modules': ext_modules,
'cmdclass': {
'build_ext': build_ext
},
})
14 changes: 14 additions & 0 deletions clang-format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

EXTS=".cpp .hpp .c .h"
FILES=""
for e in $EXTS; do
NEW=`git ls-files | grep $e\$`
FILES="${FILES} ${NEW}"
done

for f in $FILES; do
echo $f
clang-format -i $f
done

Binary file modified data/models/fandisk.ply
Binary file not shown.
14 changes: 0 additions & 14 deletions environment.yaml

This file was deleted.

9 changes: 1 addition & 8 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
# ----------
# Add example directories
# ----------
add_example(NAME read_write SOURCES example_read_write.cpp)
add_example(NAME remesh SOURCES example_remesh.cpp)
add_example(NAME simplify SOURCES example_simplify.cpp)
add_example(NAME smooth SOURCES example_smooth.cpp)
add_example(NAME denoise SOURCES example_denoise.cpp)
add_subdirectory(cpp)
8 changes: 8 additions & 0 deletions examples/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# ----------
# Add example directories
# ----------
add_example(NAME read_write SOURCES example_read_write.cpp)
add_example(NAME remesh SOURCES example_remesh.cpp)
add_example(NAME simplify SOURCES example_simplify.cpp)
add_example(NAME smooth SOURCES example_smooth.cpp)
add_example(NAME denoise SOURCES example_denoise.cpp)
29 changes: 14 additions & 15 deletions examples/example_denoise.cpp → examples/cpp/example_denoise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "tinymesh/tinymesh.h"

namespace fs = std::filesystem;
namespace mesh = tinymesh;
namespace tms = tinymesh;

int main(int argc, char **argv) {
try {
Expand All @@ -29,12 +29,12 @@ int main(int argc, char **argv) {
// Save noise mesh
std::string noiseMeshFile;
{
mesh::Mesh mesh(argv[1]);
mesh::holeFill(mesh, Pi / 6.0);
tms::Mesh mesh(argv[1]);
mesh.fillHoles(Pi / 6.0);

double Lavg = 0.0;
for (int i = 0; i < (int)mesh.numEdges(); i++) {
mesh::Edge *e = mesh.edge(i);
tms::Edge *e = mesh.edge(i);
const double l = e->length();
Lavg += l;
}
Expand All @@ -52,9 +52,9 @@ int main(int argc, char **argv) {

// Denoise (Normal Gaussian filter)
{
mesh::Mesh mesh(noiseMeshFile);
mesh::holeFill(mesh, Pi / 6.0);
mesh::denoiseNormalGaussian(mesh, sigma, 10);
tms::Mesh mesh(noiseMeshFile);
mesh.fillHoles(Pi / 6.0);
tms::denoiseNormalGaussian(mesh, sigma, 10);

const std::string outfile =
(dirpath / fs::path((basename + "_denoise_Gaussian" + extension).c_str())).string();
Expand All @@ -64,9 +64,9 @@ int main(int argc, char **argv) {

// Denoise (Normal bilateral filter)
{
mesh::Mesh mesh(noiseMeshFile);
mesh::holeFill(mesh, Pi / 6.0);
mesh::denoiseNormalBilateral(mesh, sigma, 0.1, 10);
tms::Mesh mesh(noiseMeshFile);
mesh.fillHoles(Pi / 6.0);
tms::denoiseNormalBilateral(mesh, sigma, 0.1, 10);

const std::string outfile =
(dirpath / fs::path((basename + "_denoise_bilateral" + extension).c_str())).string();
Expand All @@ -76,12 +76,11 @@ int main(int argc, char **argv) {

// Denoise (L0 smoothing)
{
mesh::Mesh mesh(noiseMeshFile);
mesh::holeFill(mesh, Pi / 6.0);
mesh::denoiseL0Smooth(mesh);
tms::Mesh mesh(noiseMeshFile);
mesh.fillHoles(Pi / 6.0);
tms::denoiseL0Smooth(mesh);

const std::string outfile =
(dirpath / fs::path((basename + "_denoise_l0" + extension).c_str())).string();
const std::string outfile = (dirpath / fs::path((basename + "_denoise_l0" + extension).c_str())).string();
mesh.save(outfile);
printf("Save: %s\n", outfile.c_str());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "tinymesh/tinymesh.h"

namespace fs = std::filesystem;
namespace tms = tinymesh;

int main(int argc, char **argv) {
if (argc <= 1) {
Expand All @@ -11,7 +12,7 @@ int main(int argc, char **argv) {
}

// Load
tinymesh::Mesh mesh(argv[1]);
tms::Mesh mesh(argv[1]);

// Save
const fs::path filepath = fs::canonical(fs::path(argv[1]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "tinymesh/tinymesh.h"

namespace fs = std::filesystem;
namespace mesh = tinymesh;
namespace tms = tinymesh;

int main(int argc, char **argv) {
if (argc <= 1) {
Expand All @@ -12,12 +12,12 @@ int main(int argc, char **argv) {
}

// Load
mesh::Mesh mesh(argv[1]);
tms::Mesh mesh(argv[1]);

// Fill holes & remesh
const double keepAngle = argc > 2 ? std::atof(argv[2]) * Pi / 180.0 : 0.0;
mesh::holeFill(mesh, Pi / 6.0);
mesh::remeshTriangular(mesh, 0.8, 1.333, keepAngle);
mesh.fillHoles(Pi / 6.0);
tms::remeshTriangular(mesh, 0.8, 1.333, keepAngle);

// Save
const fs::path filepath = fs::canonical(fs::path(argv[1]));
Expand Down
Loading