From 2604e3889a67f89a4ce8b4b4648fa8e4b6dbc303 Mon Sep 17 00:00:00 2001 From: jmsgrogan Date: Wed, 25 Oct 2017 10:19:55 +0100 Subject: [PATCH] Turn off GPU --- src/product_gen/generate_lamp.py | 2 +- src/rendering/setup_renderer.py | 2 +- test/lamp_shape_generation.py | 30 +++++++++++++++++++++++++----- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/product_gen/generate_lamp.py b/src/product_gen/generate_lamp.py index 63444f1..9b505ec 100644 --- a/src/product_gen/generate_lamp.py +++ b/src/product_gen/generate_lamp.py @@ -8,7 +8,7 @@ def generate_models(shape_parameters): # Shade if shape_parameters["shape"] == "mesh": shade = gs.generate_mesh_shade(shape_parameters) - elif shape_parameters["shape"] == "led": + elif shape_parameters["shape"] == "led" or "bio": shade = gs.generate_led_shade(shape_parameters) else: # default pendant shade = gs.generate_pendant_shade(shape_parameters) diff --git a/src/rendering/setup_renderer.py b/src/rendering/setup_renderer.py index 6563f96..d365d35 100644 --- a/src/rendering/setup_renderer.py +++ b/src/rendering/setup_renderer.py @@ -6,7 +6,7 @@ def setup_renderer(shape_parameters, engine="CYCLES"): this_scene = bpy.context.scene if engine=="CYCLES": this_scene.render.engine = 'CYCLES' - this_scene.cycles.device = 'GPU' + this_scene.cycles.device = 'CPU' this_scene.cycles.samples = 12.0 this_scene.cycles.caustics_reflective = False this_scene.cycles.caustics_refractive = False diff --git a/test/lamp_shape_generation.py b/test/lamp_shape_generation.py index da6d0a9..cd290ab 100644 --- a/test/lamp_shape_generation.py +++ b/test/lamp_shape_generation.py @@ -1,17 +1,37 @@ import numpy as np import matplotlib.pyplot as plt -height = 10 +height = 3 radius = 2 base_radius = 0.5 -base_length = 1.0 +base_length = 0.3 + +def morph_shape(x, L, H, morph_type="linear"): + + y = np.ones(x.shape[0]) + if morph_type == "linear": + y = (x/L)*H + elif morph_type == "logistic": + k = 10.0 + v = 1.0 + y = H/(1.0 + np.power(np.exp(-k*(x-L/4.0)), v)) + elif morph_type == "sinusoid": + y = np.sin((x/L)*np.pi/2.0) + elif morph_type == "hyperbolic_tan": + y = np.tanh((x/L)*np.pi/2.0) + elif morph_type == "circle": + y = np.tanh((x/L)*np.pi/2.0) + + return y x_base = np.linspace(0, base_length, 10) y_base = base_radius*np.ones(x_base.shape[0]) x_lamp = np.linspace(base_length, height, 100) -y_lamp = base_radius + ((x_lamp)/height)*(radius-base_radius) - +y_lamp = base_radius + morph_shape(x_lamp-base_length, + height-base_length, + radius-base_radius, + "hyperbolic_tan") x = np.append(x_base, x_lamp) y = np.append(y_base, y_lamp) plt.plot(x, y) @@ -19,5 +39,5 @@ plt.plot(x, y) axes = plt.gca() axes.set_xlim([0, 1.1*base_length+height]) axes.set_ylim([0,1.1*radius]) - +plt.axis('equal') plt.show()