GithubHelp home page GithubHelp logo

sgsellan / gpytoolbox Goto Github PK

View Code? Open in Web Editor NEW
159.0 159.0 11.0 52.8 MB

A collection of utility functions to prototype geometry processing research in python

Home Page: https://gpytoolbox.org

License: GNU General Public License v3.0

Python 97.44% CMake 0.05% C++ 2.47% C 0.04%
geometry geometry-processing python

gpytoolbox's People

Contributors

abhimadan avatar emjay276 avatar odedstein avatar otmanon avatar sgsellan avatar tovacinni avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

gpytoolbox's Issues

PLY file not read correctly

This issue was discovered by Jack Zhang.

Our PLY reader fails to read in the face list for a triangle mesh. libigl reads the ply just fine. If I open the triangle mesh in blender and reexport as PLY, it works though.
Simple example (the mesh files are in meshes.zip):

import gpytoolbox as gpy
import igl

V_ply,F_ply = gpy.read_mesh("mesh.ply")
print(f"V_ply: {V_ply.shape}, F_ply: {F_ply.shape}")

V_ply_igl,F_ply_igl = igl.read_triangle_mesh("mesh.ply")
print(f"V_ply_igl: {V_ply_igl.shape}, F_ply_igl: {F_ply_igl.shape}")

V_ply_blender,F_ply_blender = gpy.read_mesh("mesh_exported_by_blender.ply")
print(f"V_ply_blender: {V_ply_blender.shape}, F_ply_blender: {F_ply_blender.shape}")

V_obj,F_obj = gpy.read_mesh("mesh.obj")
print(f"V_obj: {V_obj.shape}, F_obj: {F_obj.shape}")

This produces:

V_ply: (2802, 3), F_ply: (0, 0)
V_ply_igl: (2802, 3), F_ply_igl: (934, 3)
V_ply_blender: (2802, 3), F_ply_blender: (934, 3)
V_obj: (2802, 3), F_obj: (934, 3)

I.e., gpytoolbox returns an empty triangle list on the provided mesh.ply, but not on the reexported mesh_exported_by_blender.ply.

What could cause this?
Looking at the two PLY binary files in detail, one difference that I can see is that for mesh.ply, the vertex indices are given as int, and for mesh_exported_by_blender.py the vertex indices are given as uint:

header of mesh.ply:
element face 934.property list uchar int vertex_index

header of mesh_exported_by_blender.py:
element face 934.property list uchar uint vertex_indices

Indeed, our PLY binding just seems to assume vertex indices in the face list will always be uint. Libigl's does not, they have a switch statement supporting various types.

libigl removed function mat_max

libigl has removed mat_max in recent versions. We use it in src/cpp/upper_envelope.cpp.

We should update our code so it will work with newer versions of libigl when we eventually upgrade.

GMPlib certificate expiration

The SSL certificate in gmplib.org, from which libigl (and therefore us) downloads gmp, has expired, which causes curl (called to download gmp during our build) to fail. I merged #41 , a hotfix that changes our version of libigl to my PR branch sgsellan/libigl, but I am opening this issue so we have a reminder to revert this in the future when the libigl folks have converged on a solution.

png2poly rotates shape

Here's a png:

octopus

Running

from gpytoolbox import png2poly
poly = png2poly("octopus.png")[0]
import matplotlib.pyplot as plt
plt.plot(poly[:,0],poly[:,1])
plt.show()

for some reason produces a rotated polyline, as if the x and y coordinates were flipped:

Screen Shot 2022-09-04 at 2 34 33 PM

Default values for `Ft` and `Fn` if `UV` and `N` are provided

The write_mesh function can optionally take in texture coordinates UV and normals N, which require corresponding index matrices Ft and Fn, respectively. However, the function doesn't seem to check for cases where, for example, UV is provided but Ft is not provided. This results in situations where a written .obj file can contain vt rows but the f rows only contain vertex indices and no texture indices, so the file does not actually have a valid UV map.

I think a reasonable default in these cases would be to fall back on F, if there are as many texture coordinates/normals as vertices and Ft/Fn are not provided. If this isn't satisfied, I think the function should return an error. If it's preferable to avoid defaults and make the API explicit, I still think the function should return an error when UV/N is provided but Ft/Fn is not, so the semantics are clear.

pip install gpytoolbox==0.1.0 gpytoolbox_bindings_copyleft

hello @sgsellan
I execute pip install gpytoolbox==0.1.0
I checked the previous version and the latest version seems to be missing something

The following problems occurred:
from gpytoolbox_bindings_copyleft import _swept_volume_impl
ImportError: DLL load failed while importing gpytoolbox_bindings_copyleft: 找不到指定的模块。

thank you!

remesh_botsch does not work for non-closed meshes

I tried to remesh a non-closed/ watertight mesh with the remesh_botsch algorithm.
Compared to a closed mesh (with almost the same size) it takes a lot longer (>100 times) and returns an error by exiting my python console.

  • Is your implementation not useable for non-closed meshes? The original paper has options for the boundary.

Resolution parameters switched in documentation for torus function

The documentation for the torus function states that the first parameter (nR) is the number of vertices along the large perimeter and the second parameter (nr) is the number of vertices along the small perimeter, but in the code the meaning of these parameters are switched.

V,F = gpy.torus(10, 3, R=1., r=0.1) produces:
torcus_actual

But according to the documentation should produce:
torus_expected

All vertices are detected as boundary vertices

I tried to remesh some models from the Engineering Shape Benchmark (ESB)

For example backdoor.stl from the Flat-Thin Wallcomponents.tar.gz

The result using remesh_botsch is exactly the same as the input.

import gpytoolbox as gpy
v, f = gpy.read_mesh(r"C:\Users\Michael\Desktop\Flat-Thin-Wallcomponents\Flat-Thin Wallcomponents\Back Doors\backdoor.stl")
u, g = gpy.remesh_botsch(v, f, h=None)

I discovered all vertices of the model are detected as boundary vertices by boundary_vertices(f)

But the model has clearly some "inner" vertices (at least on the rounded part in the middle.
grafik

Reach For the Sphere segmentation fault

Hey!

I'm trying to run reach for the sphere, but the code crashes on some models:

V,F = gpy.read_mesh("53159.obj")
j = 32
sdf = lambda x: gpy.signed_distance(x, V, F)[0]
gx, gy, gz = np.meshgrid(np.linspace(-1.0, 1.0, j+1), np.linspace(-1.0, 1.0, j+1), np.linspace(-1.0, 1.0, j+1))
U = np.vstack((gx.flatten(), gy.flatten(), gz.flatten())).T
V0, F0 = gpy.icosphere(2)
Vr,Fr = gpy.reach_for_the_spheres(U, sdf, V0, F0, min_h=.01)

Output:

 Segmentation fault (core dumped)

Is there some requirements on the input? The one I used (53159 of the Thingi10k dataset) is watertight and normalized to -0.8/0.8, but its genus is not zero.

NaNs in the double areas

Our doublearea_instrinsic currently contains

dblA = 0.5 * np.sqrt((a+(b+c)) * (c-(a-b)) * (c+(a-b)) * (a+(b-c)))

If the areas are very small, this can NaN. Ideally, we would do

arg = (a+(b+c)) * (c-(a-b)) * (c+(a-b)) * (a+(b-c))
dblA = 0.5 * np.sqrt(np.maximum(arg, 0.))

However, if I make this change, the unit test for reach_for_the_spheres fails.
I speculate that it is because the optimization in reach_for_the_spheres does not terminate as early anymore, so it reaches a later stage where it can crash.

What should be done about it?

error in poisson surface reconstruction edge case

I ran the function
poisson_surface_reconstruction(nerf_pts, nerf_normals, gs=np.array([50,50,50])
and it results in the error
File "<__array_function__ internals>", line 200, in ravel_multi_index ValueError: invalid entry in coordinates array

A possibly fix for it is using "mode: clip" in the np.ravel_multi_index function, or exposing that option to the user.

`signed_distance_polygon` returns nans if first polyline point is repeated

Sometimes, you'll see that a polyline is given with the last point being equal to the first to denote that it's closed. Currently, signed_distance_polygon does not support this and instead returns nan since it finds an edge with zero length. It'd be nice if the function just ignored zero-length edges instead of giving nans.

2D Swept Volume/Area Computation

My understanding is that the swept volume computation does not support computing the swept area of a 2D mesh.
I would greatly appreciate if it if your implementation also supported 2D meshes. Thanks!

Marching Square gives zigzag lines

Hello, I'm using marching square function on a planar slice of sdf values, but am getting weird zigzag lines in the output. Here is the link to the sdf value and a minimal script that reproduces the image below.
image

Thank you in advance for looking into it!

FEM for 3D Tet mesh

Are you interested in me implementing the FEM for 3D Tets?

I already have a working version for every element type using gmsh.
You probably want to stay with numpy / scipy only, correct?
If you don't need it next week, I can adapt it (for linear elastic tet elements) to only use numpy/scipy 😀.

  • Can you give me some hints where to find existing code/functionality for 3D Tets in gpytoolbox?

  • Do you use voigt notation for stresses/straits?
    grafik

  • Or diagonal notation for stresses/straits?
    grafik
    (only relevant for anisotropic materials)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.