Write join_boundary_simple
This commit is contained in:
parent
fd3d3b91a5
commit
af8e673215
@ -12,6 +12,24 @@
|
|||||||
"import trimesh"
|
"import trimesh"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 5,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"b1 = numpy.array([\n",
|
||||||
|
" [0, 0, 0],\n",
|
||||||
|
" [1, 0, 0],\n",
|
||||||
|
" [1, 1, 0],\n",
|
||||||
|
" [0, 1, 0],\n",
|
||||||
|
"], dtype=numpy.float64)\n",
|
||||||
|
"b2 = numpy.array(b1 + [0,0,1])\n",
|
||||||
|
"\n",
|
||||||
|
"testmesh = meshutil.join_boundary_simple(b1, b2)\n",
|
||||||
|
"testmesh.to_stl_mesh().save(\"simple.stl\")"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 65,
|
"execution_count": 65,
|
||||||
|
|||||||
19
meshutil.py
19
meshutil.py
@ -135,3 +135,22 @@ def cube_distort(angle, open_xz=False):
|
|||||||
faces[11,:] = [0, 5, 4]
|
faces[11,:] = [0, 5, 4]
|
||||||
# winding order?
|
# winding order?
|
||||||
return FaceVertexMesh(verts, faces)
|
return FaceVertexMesh(verts, faces)
|
||||||
|
|
||||||
|
def join_boundary_simple(bound1, bound2):
|
||||||
|
# bound1 & bound2 are both arrays of shape (N,3), representing
|
||||||
|
# the points of a boundary. This joins the two boundaries by
|
||||||
|
# simply connecting quads (made of 2 triangles) straight across.
|
||||||
|
#
|
||||||
|
# Winding will proceed in the direction of the first boundary.
|
||||||
|
#`
|
||||||
|
# Returns FaceVertexMesh.
|
||||||
|
n = bound1.shape[0]
|
||||||
|
vs = numpy.concatenate([bound1, bound2])
|
||||||
|
# Indices 0...N-1 are from bound1, N...2*N-1 are from bound2
|
||||||
|
fs = numpy.zeros((2*n, 3), dtype=int)
|
||||||
|
for i in range(n):
|
||||||
|
v0 = i
|
||||||
|
v1 = (i + 1) % n
|
||||||
|
fs[2*i] = [n + v1, n + v0, v0]
|
||||||
|
fs[2*i + 1] = [v1, n + v1, v0]
|
||||||
|
return FaceVertexMesh(vs, fs)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user