Added sample json files.

- removed the older util.py module
This commit is contained in:
Stephen M. McQuay 2012-05-07 23:17:29 -06:00
parent 475b9dd25d
commit d117dacf08
3 changed files with 2 additions and 178 deletions

View File

@ -0,0 +1 @@
{"vertices": [[-1.0, -1.0, -1.0], [-1.0, 1.0, -1.0], [1.0, 1.0, -1.0], [1.0, -1.0, -1.0], [-1.0, -1.0, 1.0], [-1.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, -1.0, 1.0]], "edges": [[4, 5], [5, 1], [1, 0], [0, 4], [5, 6], [6, 2], [2, 1], [6, 7], [7, 3], [3, 2], [7, 4], [0, 3]], "faces for edge": [[5, 0], [1, 0], [4, 0], [3, 0], [5, 1], [2, 1], [4, 1], [5, 2], [3, 2], [4, 2], [5, 3], [4, 3]], "faces": [[4, 5, 1, 0], [5, 6, 2, 1], [6, 7, 3, 2], [7, 4, 0, 3], [0, 1, 2, 3], [7, 6, 5, 4]], "edges for face": [[0, 1, 2, 3], [4, 5, 6, 1], [7, 8, 9, 5], [10, 3, 11, 8], [2, 6, 9, 11], [7, 4, 0, 10]], "edges for vert": [[2, 3, 11], [1, 2, 6], [5, 6, 9], [8, 9, 11], [0, 3, 10], [0, 1, 4], [4, 5, 7], [7, 8, 10]], "faces for vert": [[4, 0, 3], [1, 0, 4], [2, 1, 4], [3, 2, 4], [0, 3, 5], [5, 0, 1], [5, 1, 2], [5, 2, 3]]}

File diff suppressed because one or more lines are too long

View File

@ -1,178 +0,0 @@
from geometry import Vertex, Edge, Face, Polygon
def cube():
'''
This function returns a populated Polygon object. The object is a cube with
a vertex at the origin, and another at (1, 1, 1).
v4 v5
*-----e8-----*
| |
| |
e|4 f4 e|5
| |
v4 v|0 v|1 v5
*-----e4-----*-----e0-----*-----e5-----*
| | | |
| | | |
e11| f3 e|3 f0 e|1 f1 e|9
| | | |
| | | |
*-----e7-----*-----e2-----*-----e6-----*
v7 v|3 v|2 v6
| |
e|7 f2 e|6
| |
v|7 v|6
*-----e10----*
| |
| |
e|11 f5 e|9
| |
| |
*-----e8-----*
v4 v5
v0 - <0,1,0>
v1 - <1,1,0>
v2 - <1,0,0>
v3 - <0,0,0>
v4 - <0,1,1>
v5 - <1,1,1>
v6 - <1,0,1>
v7 - <0,0,1>
face list
f0 - e0, e1, e2, e3
f1 - e1, e5, e9, e6
f2 - e2, e6, e10, e7
f3 - e4, e3, e7, e11
f4 - e8, e5, e0, e4
f5 - e10, e9, e8, e11
winged edges ordered by face, then by vertex reference
edge list
e0 - v0, v1; f0, f4; e3, e1, e4, e5
e1 - v1, v2; f0, f1; e0, e2, e5, e6
e2 - v3, v2; f0, f2; e3, e7, e1, e6
e3 - v0, v3; f3, f0; e4, e7, e0, e2
e4 - v4, v0; f3, f4; e11, e3, e0 e8
e5 - v5, v1; f4, f1; e8, e0, e9, e1
e6 - v2, v6; f1, f2; e1, e9, e2, e10
e7 - v7, v3; f3, f2; e11, e3, e10, e2
e8 - v4, v5, f4, f5; e4, e5, e11, e9
e9 - v5, v6; f1, f5; e5, e6, e8, e10
e10 - v7, v6; f2, f5; e7, e6, e11, e9
e11 - v4, v7; f3, f5; e4, e7, e8, 10
vertex list
v0 - e0, e3, e4
v1 - e0, e5, e1
v2 - e1, e6, e2
v3 - e2, e7, e3
v4 - e4, e11, e8
v5 - e5, e9, e8
v6 - e2, e9, e10
v7 - e7, e10, e11
'''
p = Polygon()
# setup vertices
p.vertices = [
Vertex(p, 0, 1.0, 1.0, 0.0),
Vertex(p, 1, 1.0, 0.0, 0.0),
Vertex(p, 2, 0.0, 1.0, 0.0),
Vertex(p, 3, 0.0, 0.0, 0.0),
Vertex(p, 4, 0.0, 1.0, 1.0),
Vertex(p, 5, 1.0, 1.0, 1.0),
Vertex(p, 6, 1.0, 0.0, 1.0),
Vertex(p, 7, 0.0, 0.0, 1.0)]
p.vertices[0].edge_ids = [0, 3, 4]
p.vertices[1].edge_ids = [0, 5, 1]
p.vertices[2].edge_ids = [1, 6, 2]
p.vertices[3].edge_ids = [2, 7, 3]
p.vertices[4].edge_ids = [4, 11, 8]
p.vertices[5].edge_ids = [5, 9, 8]
p.vertices[6].edge_ids = [6, 9, 10]
p.vertices[7].edge_ids = [7, 10, 11]
# setup edges
p.edges = [Edge(p, i) for i in range(12)]
# winged edges ordered by face, then by vertex reference
# setup edge end vertex ids
p.edges[0].vertex_ids = [0, 1]
p.edges[1].vertex_ids = [1, 2]
p.edges[2].vertex_ids = [2, 3]
p.edges[3].vertex_ids = [3, 0]
p.edges[4].vertex_ids = [0, 4]
p.edges[5].vertex_ids = [5, 1]
p.edges[6].vertex_ids = [2, 6]
p.edges[7].vertex_ids = [7, 3]
p.edges[8].vertex_ids = [4, 5]
p.edges[9].vertex_ids = [5, 6]
p.edges[10].vertex_ids = [7, 6]
p.edges[11].vertex_ids = [4, 7]
# setup edges winged edge ids
p.edges[0].edge_ids = [3, 1, 4, 5]
p.edges[1].edge_ids = [0, 2, 5, 6]
p.edges[2].edge_ids = [1, 3, 6, 7]
p.edges[3].edge_ids = [4, 7, 0, 2]
p.edges[4].edge_ids = [11, 3, 0, 8]
p.edges[5].edge_ids = [8, 0, 9, 1]
p.edges[6].edge_ids = [1, 9, 2, 10]
p.edges[7].edge_ids = [11, 3, 10, 2]
p.edges[8].edge_ids = [4, 5, 11, 9]
p.edges[9].edge_ids = [5, 6, 8, 10]
p.edges[10].edge_ids = [7, 6, 11, 9]
p.edges[11].edge_ids = [4, 7, 8, 10]
# setup edge adjacent face ids
p.edges[0].face_ids = [0, 4]
p.edges[1].face_ids = [0, 1]
p.edges[2].face_ids = [0, 2]
p.edges[3].face_ids = [3, 0]
p.edges[4].face_ids = [3, 4]
p.edges[5].face_ids = [4, 1]
p.edges[6].face_ids = [1, 2]
p.edges[7].face_ids = [3, 2]
p.edges[8].face_ids = [4, 5]
p.edges[9].face_ids = [1, 5]
p.edges[10].face_ids = [2, 5]
p.edges[11].face_ids = [3, 5]
# setup faces
p.faces = [Face(p, i) for i in range(6)]
# setup face edge ids
p.faces[0].edge_ids = [0, 1, 2, 3]
p.faces[1].edge_ids = [1, 5, 9, 6]
p.faces[2].edge_ids = [2, 6, 10, 7]
p.faces[3].edge_ids = [4, 3, 7, 11]
p.faces[4].edge_ids = [8, 5, 0, 4]
p.faces[5].edge_ids = [10, 9, 8, 11]
# Polygon stores all the actual data.
# Every other class only stores indices to
# the original data. This could be slightly
# dangerous if any items get appended to the
# list of objects or the indices get changed.
# These are all the same vertex, just testing to make
# sure I did it right.
# print p.vertices[1].x
# edge_v_id = p.edges[1].vertex_ids[0]
# print p.vertices[edge_v_id].x
# face_edge_id = p.faces[0].edge_ids[1]
# edge_v_id = p.edges[face_edge_id].vertex_ids[0]
# print p.vertices[edge_v_id].x
return p
# print cube()