[yt-svn] commit/yt: MatthewTurk: Adding a check for models that are likely too big for sketchfab.
Bitbucket
commits-noreply at bitbucket.org
Thu Dec 6 10:26:41 PST 2012
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/changeset/eda712335ad2/
changeset: eda712335ad2
branch: yt
user: MatthewTurk
date: 2012-12-06 17:41:08
summary: Adding a check for models that are likely too big for sketchfab.
affected #: 2 files
diff -r f8f64e456c322873b011f1a22b313a066e59cb4a -r eda712335ad2d2524ceb50300c4a6895342927c0 yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -4537,6 +4537,16 @@
self.export_ply(ply_file, bounds, color_field, color_map, color_log,
sample_type = "vertex")
ply_file.seek(0)
+ # Greater than ten million vertices and we throw an error but dump
+ # to a file.
+ if self.vertices.shape[1] > 1e7:
+ tfi = 0
+ fn = "temp_model_%03i.ply" % tfi
+ while os.path.exists(fn):
+ fn = "temp_model_%03i.ply" % tfi
+ tfi += 1
+ open(fn, "wb").write(ply_file.read())
+ raise YTTooManyVertices(self.vertices.shape[1], fn)
zfs = TemporaryFile()
with zipfile.ZipFile(zfs, "w", zipfile.ZIP_DEFLATED) as zf:
diff -r f8f64e456c322873b011f1a22b313a066e59cb4a -r eda712335ad2d2524ceb50300c4a6895342927c0 yt/utilities/exceptions.py
--- a/yt/utilities/exceptions.py
+++ b/yt/utilities/exceptions.py
@@ -198,3 +198,13 @@
def __str__(self):
return "You need to set an API key for %s in ~/.yt/config as %s" % (
self.service, self.config_name)
+
+class YTTooManyVertices(YTException):
+ def __init__(self, nv, fn):
+ self.nv = nv
+ self.fn = fn
+
+ def __str__(self):
+ s = "There are too many vertices (%s) to upload to Sketchfab. " % (self.nv)
+ s += "Your model has been saved as %s . You should upload manually." % (self.fn)
+ return s
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list