diff --git a/setup.py b/setup.py index 0f22f1f..0963004 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ from setuptools import setup, find_packages setup( - name= 'smbsurf', + name='smbsurf', description='', version='0.0', packages=find_packages(), diff --git a/surf/geometry.py b/surf/geometry.py index 9dcd4ad..8691f3b 100755 --- a/surf/geometry.py +++ b/surf/geometry.py @@ -1,6 +1,4 @@ -from __future__ import division import pprint -import json ''' http://en.wikipedia.org/wiki/Polygon_mesh @@ -95,9 +93,16 @@ class Vertex(object): self.y = y self.z = z self.edges = [] + + def __eq__(self, other): + if(self.x == other.x and self.y == other.y and self.z == other.z): + return True + else: + return False + def __repr__(self): - return "<%.2f, %.2f, %.2f>" % (self.x, self.y, self.z) + return "[%.2f, %.2f, %.2f]" % (self.x, self.y, self.z) def __add__(self, other): # for now just assume type(other) = Vertex... bad, I know @@ -115,6 +120,7 @@ class Vertex(object): def __div__(self, other): # same assumption as __mult__ + other = float(other) return Vertex(self.x / other, self.y / other, self.z / other) class Edge(object): diff --git a/surf/subd/cc.py b/surf/subd/cc.py index ce544be..dbd73df 100644 --- a/surf/subd/cc.py +++ b/surf/subd/cc.py @@ -1,4 +1,4 @@ -from surf.geometry import * +from surf.geometry import Vertex, Polygon def refine(poly): ''' diff --git a/surf/util.py b/surf/util.py index 3b52fff..4ea6f70 100644 --- a/surf/util.py +++ b/surf/util.py @@ -1,12 +1,13 @@ from surf.geometry import Vertex, Edge, Face, Polygon + def cube(): v = [] v.append(Vertex(0.0, 1.0, 0.0)) v.append(Vertex(1.0, 1.0, 0.0)) v.append(Vertex(1.0, 0.0, 0.0)) v.append(Vertex(0.0, 0.0, 0.0)) - + v.append(Vertex(0.0, 1.0, 1.0)) v.append(Vertex(1.0, 1.0, 1.0)) v.append(Vertex(1.0, 0.0, 1.0)) diff --git a/test/test00.py b/test/test00.py index 62a6852..88597df 100644 --- a/test/test00.py +++ b/test/test00.py @@ -1,4 +1,4 @@ -from surf.util import cube +from surf.util import cube from surf.subd import cc polygon = cube() refined_poly = cc.refine(polygon) @@ -6,11 +6,11 @@ refined_poly = cc.refine(polygon) print polygon print refined_poly -# -# +# +# # import pylab # import mpl_toolkits.mplot3d.axes3d as p3 -# +# # fig = pylab.figure() # ax = p3.Axes3D(fig) # for edge in newPolygon.edges: diff --git a/test/test01.py b/test/test01.py index bdfd2e2..ba861ae 100644 --- a/test/test01.py +++ b/test/test01.py @@ -1,7 +1,6 @@ -from __future__ import division from surf.geometry import Vertex -v1 = Vertex(0.5, 0.25, 1/3.0) +v1 = Vertex(0.5, 0.25, 1 / 3.0) v2 = Vertex(1, 1, 1) print v1, v2, (v1 + v2) / 2