-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce numpy UV triangulation (#1185)
- Loading branch information
Showing
2 changed files
with
171 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from helper import * | ||
from meshlib import mrmeshnumpy | ||
import numpy as np | ||
import unittest as ut | ||
import pytest | ||
|
||
# mrmesh uses float32 for vertex coordinates | ||
# however, you could also use float64 | ||
def test_numpy_UVSphere(): | ||
u, v = np.mgrid[0:2 * np.pi:50j, 0:np.pi:100j] | ||
x = np.cos(u) * np.sin(v) | ||
y = np.sin(u) * np.sin(v) | ||
z = np.cos(v) | ||
|
||
mesh = mrmeshnumpy.meshFromUVPoints(x,y,z) | ||
assert (mesh.topology.findHoleRepresentiveEdges().size() == 0) | ||
assert (mrmesh.getAllComponents(mesh).size() == 1) | ||
assert (mesh.volume() > 0) | ||
|
||
def test_numpy_UVTorus(): | ||
r1 = 2.0 | ||
r2 = 1.5 | ||
|
||
u, v = np.mgrid[0:2 * np.pi:4j, 0:2*np.pi:10j] | ||
x = ( r1 - r2 * np.cos( u ) ) * np.cos( v ); | ||
y = ( r1 - r2 * np.cos( u ) ) * np.sin( v ) | ||
z = r2 * np.sin( u ); | ||
|
||
mesh = mrmeshnumpy.meshFromUVPoints(x,y,z) | ||
assert (mesh.topology.findHoleRepresentiveEdges().size() == 0) | ||
assert (mrmesh.getAllComponents(mesh).size() == 1) | ||
assert (mesh.volume() > 0) |