Skip to content

Commit 77479f2

Browse files
Merge branch 'main' into nb
2 parents 722d3a5 + af88b78 commit 77479f2

File tree

29 files changed

+1209
-0
lines changed

29 files changed

+1209
-0
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "ext/libigl"]
2+
path = ext/libigl
3+
url = https://github.com/libigl/libigl.git

cmake/FindLIBIGL.cmake

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# - Try to find the LIBIGL library
2+
# Once done this will define
3+
#
4+
# LIBIGL_FOUND - system has LIBIGL
5+
# LIBIGL_INCLUDE_DIR - **the** LIBIGL include directory
6+
if(LIBIGL_FOUND)
7+
return()
8+
endif()
9+
10+
find_path(LIBIGL_INCLUDE_DIR igl/readOBJ.h
11+
HINTS
12+
ENV LIBIGL
13+
ENV LIBIGLROOT
14+
ENV LIBIGL_ROOT
15+
ENV LIBIGL_DIR
16+
PATHS
17+
${CMAKE_SOURCE_DIR}/ext/libigl
18+
${CMAKE_SOURCE_DIR}/../..
19+
${CMAKE_SOURCE_DIR}/..
20+
${CMAKE_SOURCE_DIR}
21+
${CMAKE_SOURCE_DIR}/libigl
22+
${CMAKE_SOURCE_DIR}/../libigl
23+
${CMAKE_SOURCE_DIR}/../../libigl
24+
${CMAKE_SOURCE_DIR}/../ext/libigl
25+
/usr
26+
/usr/local
27+
/usr/local/igl/libigl
28+
PATH_SUFFIXES include
29+
)
30+
31+
include(FindPackageHandleStandardArgs)
32+
find_package_handle_standard_args(LIBIGL
33+
"\nlibigl not found --- You can download it using:\n\tgit clone --recursive https://github.com/libigl/libigl.git ${CMAKE_SOURCE_DIR}/../libigl"
34+
LIBIGL_INCLUDE_DIR)
35+
mark_as_advanced(LIBIGL_INCLUDE_DIR)
36+
37+
list(APPEND CMAKE_MODULE_PATH "${LIBIGL_INCLUDE_DIR}/../cmake")
38+
include(libigl)

docs/examples/curvature.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import compas
2+
import compas_libigl as igl
3+
from compas.colors import Color
4+
from compas.datastructures import Mesh
5+
from compas.geometry import Line
6+
from compas.geometry import Point
7+
from compas.geometry import Vector
8+
from compas_viewer import Viewer
9+
10+
# ==============================================================================
11+
# Input geometry
12+
# ==============================================================================
13+
14+
mesh = Mesh.from_obj(compas.get("tubemesh.obj"))
15+
16+
trimesh = mesh.copy()
17+
trimesh.quads_to_triangles()
18+
19+
# ==============================================================================
20+
# curvature
21+
# ==============================================================================
22+
23+
curvature = igl.trimesh_gaussian_curvature(trimesh.to_vertices_and_faces())
24+
25+
# ==============================================================================
26+
# Visualisation
27+
# ==============================================================================
28+
29+
viewer = Viewer(width=1600, height=900)
30+
# viewer.view.camera.position = [1, -6, 2]
31+
# viewer.view.camera.look_at([1, 1, 1])
32+
33+
viewer.scene.add(mesh, opacity=0.7, show_points=False)
34+
35+
for vertex in mesh.vertices():
36+
if mesh.is_vertex_on_boundary(vertex):
37+
continue
38+
39+
point = Point(*mesh.vertex_coordinates(vertex))
40+
normal = Vector(*mesh.vertex_normal(vertex))
41+
c = curvature[vertex]
42+
normal.scale(10 * c)
43+
44+
viewer.scene.add(
45+
Line(point, point + normal),
46+
linecolor=(Color.red() if c > 0 else Color.blue()),
47+
linewidth=2,
48+
)
49+
50+
viewer.show()

ext/PLACEHOLDER

Whitespace-only changes.

ext/libigl

Submodule libigl added at c645aac

scripts/temp/_anisotroremesh.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# https://libigl.github.io/tutorial/#anisotropic-remeshing

scripts/temp/_mixedintquadrang.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# https://libigl.github.io/tutorial/#global-seamless-integer-grid-parametrization

scripts/temp/_nrosy.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# https://libigl.github.io/tutorial/#n-rotationally-symmetric-tangent-fields

scripts/temp/_solvers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# https://libigl.github.io/tutorial/#quadratic-energy-minimization
2+
# https://libigl.github.io/tutorial/#linear-equality-constraints
3+
# https://libigl.github.io/tutorial/#quadratic-programming

setup.py

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import io
2+
from os import path
3+
import os
4+
import re
5+
import sys
6+
import platform
7+
import subprocess
8+
9+
from setuptools import setup, Extension
10+
from setuptools.command.build_ext import build_ext
11+
from distutils.version import LooseVersion
12+
13+
here = path.abspath(path.dirname(__file__))
14+
15+
16+
def read(*names, **kwargs):
17+
return io.open(
18+
path.join(here, *names), encoding=kwargs.get("encoding", "utf8")
19+
).read()
20+
21+
22+
class CMakeExtension(Extension):
23+
def __init__(self, name, sourcedir=""):
24+
Extension.__init__(self, name, sources=[])
25+
self.sourcedir = os.path.abspath(sourcedir)
26+
27+
28+
class CMakeBuild(build_ext):
29+
def run(self):
30+
try:
31+
out = subprocess.check_output(["cmake", "--version"])
32+
except OSError:
33+
raise RuntimeError(
34+
"CMake must be installed to build the following extensions: "
35+
+ ", ".join(e.name for e in self.extensions)
36+
)
37+
38+
if platform.system() == "Windows":
39+
cmake_version = LooseVersion(
40+
re.search(r"version\s*([\d.]+)", out.decode()).group(1)
41+
)
42+
if cmake_version < "3.1.0":
43+
raise RuntimeError("CMake >= 3.1.0 is required on Windows")
44+
45+
for ext in self.extensions:
46+
self.build_extension(ext)
47+
48+
def build_extension(self, ext):
49+
extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
50+
cmake_args = [
51+
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=" + extdir,
52+
"-DPYTHON_EXECUTABLE=" + sys.executable,
53+
]
54+
55+
cfg = "Debug" if self.debug else "Release"
56+
build_args = ["--config", cfg]
57+
58+
if platform.system() == "Windows":
59+
cmake_args += [
60+
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}".format(cfg.upper(), extdir)
61+
]
62+
if sys.maxsize > 2**32:
63+
cmake_args += ["-A", "x64"]
64+
# build_args += ['--', '/m']
65+
else:
66+
# # For MacOS.
67+
# # During compiling stage, the python module always links to a temporary generated library which is going to be destroyed.
68+
# # Then importing the final installed module will return a link error
69+
# # The following commands will force the module to look up the its dynmaic linked library in the same folder
70+
# cmake_args += [
71+
# '-DCMAKE_INSTALL_RPATH=@loader_path',
72+
# '-DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON',
73+
# '-DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=OFF']
74+
75+
cmake_args += ["-DCMAKE_BUILD_TYPE=" + cfg]
76+
build_args += ["--", "-j2"]
77+
78+
env = os.environ.copy()
79+
env["CXXFLAGS"] = '{} -DVERSION_INFO=\\"{}\\"'.format(
80+
env.get("CXXFLAGS", ""), self.distribution.get_version()
81+
)
82+
if not os.path.exists(self.build_temp):
83+
os.makedirs(self.build_temp)
84+
subprocess.check_call(
85+
["cmake", ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env
86+
)
87+
subprocess.check_call(
88+
["cmake", "--build", "."] + build_args, cwd=self.build_temp
89+
)
90+
91+
92+
long_description = read("README.md")
93+
requirements = read("requirements.txt").split("\n")
94+
optional_requirements = {}
95+
96+
97+
setup(
98+
name="compas_libigl",
99+
packages=["compas_libigl"],
100+
ext_modules=[CMakeExtension("compas_libigl")],
101+
cmdclass=dict(build_ext=CMakeBuild),
102+
)

0 commit comments

Comments
 (0)