From 2355deec9f7794975a29dcdabe0dff4033e19fb5 Mon Sep 17 00:00:00 2001 From: "Stephen M. McQuay" Date: Tue, 29 May 2012 17:33:15 -0600 Subject: [PATCH] Stubbed out subd.butterfly and added testing script --- bin/iterate.py | 24 ++++++++++++++++++++++++ surf/__init__.py | 2 ++ surf/geometry.py | 5 +++++ surf/subd/__init__.py | 7 +++++++ surf/subd/butterfly.py | 2 ++ surf/subd/cc.py | 11 ----------- 6 files changed, 40 insertions(+), 11 deletions(-) create mode 100644 bin/iterate.py create mode 100644 surf/subd/butterfly.py diff --git a/bin/iterate.py b/bin/iterate.py new file mode 100644 index 0000000..af1d6a9 --- /dev/null +++ b/bin/iterate.py @@ -0,0 +1,24 @@ +import argparse +import json + +from surf.geometry import PolygonMesh +from surf.subd import cc +from surf.subd import butterfly + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Prune orphan PCDs from couchdb') + parser.add_argument('type', choices=('cc', 'butterfly')) + parser.add_argument('mesh') + opt = parser.parse_args() + + cube = json.load(open(opt.mesh, 'r')) + p = PolygonMesh(**cube) + + if opt.type == 'cc': + refine = cc.refine + else: + refine = butterfly.refine + + q = refine(p) + print(q) diff --git a/surf/__init__.py b/surf/__init__.py index 67ffd7c..d90a625 100644 --- a/surf/__init__.py +++ b/surf/__init__.py @@ -1,6 +1,8 @@ from .geometry import Vertex, PolygonMesh +from . import subd __all__ = [ Vertex.__name__, PolygonMesh.__name__, + 'subd', ] diff --git a/surf/geometry.py b/surf/geometry.py index a43a40e..554918c 100644 --- a/surf/geometry.py +++ b/surf/geometry.py @@ -18,6 +18,11 @@ We have chosen to use a winged-edge style mesh for our purpopses. ''' +__all__ = [ + 'Vertex', + 'PolygonMesh', +] + def cross(a, b): i = a.y * b.z - a.z * b.y diff --git a/surf/subd/__init__.py b/surf/subd/__init__.py index e69de29..40f4138 100644 --- a/surf/subd/__init__.py +++ b/surf/subd/__init__.py @@ -0,0 +1,7 @@ +from . import cc, butterfly + + +__all__ = [ + cc.__name__, + butterfly.__name__, +] diff --git a/surf/subd/butterfly.py b/surf/subd/butterfly.py new file mode 100644 index 0000000..2a5196c --- /dev/null +++ b/surf/subd/butterfly.py @@ -0,0 +1,2 @@ +def refine(mesh): + pass diff --git a/surf/subd/cc.py b/surf/subd/cc.py index 3b4dfbf..77e7fc5 100644 --- a/surf/subd/cc.py +++ b/surf/subd/cc.py @@ -109,14 +109,3 @@ def refine(mesh): new_faces.append([fvid, common_ids[0], connected_vid, common_ids[1]]) return PolygonMesh(vertices=new_vertices, edges=new_edges, faces=new_faces) - - -if __name__ == '__main__': - import sys - import json - from surf.subd.cc import refine - input_file_name = sys.argv[1] - cube = json.load(open(input_file_name, 'r')) - p = PolygonMesh(**cube) - q = refine(p) - print q