-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
fct.py
87 lines (68 loc) · 2.46 KB
/
fct.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 25 23:14:00 2019
@author: aubin
"""
from PIL import Image
from stl import mesh
import math
import numpy
def RGBAtoRGB(col):
colRGB = []
for i in col :
colRGB.append((i[0],i[1],i[2]))
return colRGB
def cube(x,z):
"""
Creates a cube of size x*x*z at origin
"""
# Create 3 faces of a cube
data = numpy.zeros(12, dtype=mesh.Mesh.dtype)
# Top of the cube
data['vectors'][0] = numpy.array([[0, x, z],
[x, 0, z],
[0, 0, z]])
data['vectors'][1] = numpy.array([[x, 0, z],
[0, x, z],
[x, x, z]])
#bottom
data['vectors'][6] = numpy.array([[0, x, 0],
[x, 0, 0],
[0, 0, 0]])
data['vectors'][7] = numpy.array([[x, 0, 0],
[0, x, 0],
[x, x, 0]])
# Right face
data['vectors'][2] = numpy.array([[x, 0, 0],
[x, 0, z],
[x, x, 0]])
data['vectors'][3] = numpy.array([[x, x, z],
[x, 0, z],
[x, x, 0]])
data['vectors'][8] = numpy.array([[0, 0, 0],
[0, 0, z],
[0, x, 0]])
data['vectors'][9] = numpy.array([[0, x, z],
[0, 0, z],
[0, x, 0]])
# Left face
data['vectors'][4] = numpy.array([[0, 0, 0],
[x, 0, 0],
[x, 0, z]])
data['vectors'][5] = numpy.array([[0, 0, 0],
[0, 0, z],
[x, 0, z]])
data['vectors'][10] = numpy.array([[0, x, 0],
[x, x, 0],
[x, x, z]])
data['vectors'][11] = numpy.array([[0, x, 0],
[0, x, z],
[x, x, z]])
cube = mesh.Mesh(data.copy())
"""cube = mesh.Mesh(numpy.concatenate([
cube_back.data.copy(),
cube_front.data.copy(),
]))
"""
#cube.save("cube.stl")
return cube