GPUE  v1.0
GPU Gross-Pitaevskii Equation numerical solver for Bose-Einstein condensates
visualize_3d Namespace Reference

Functions

def remove_obj (scene)
 
def create_new_material (passedName, passedcolor)
 
def def_scene (box_length, res_stand, xres, yres, zres)
 
def create_cube (box_length, res_stand, xres, yres, zres, step_size, dens_scale, voxelfile)
 
def create_volume (passedName, xres, yres, zres, step_size, dens_scale, voxelfile)
 
def createCage (passedName)
 
def render_img (filename)
 
def add_fiber ()
 

Variables

string voxelfile = "test_Edges.bvox"
 
string outfile = "image.png"
 
 infile = open(voxelfile, "r")
 
int xDim = 256
 
def scene = def_scene(5, xDim, xDim, yDim, zDim)
 

Function Documentation

◆ add_fiber()

def visualize_3d.add_fiber ( )

Definition at line 171 of file visualize_3d.py.

References create_new_material().

171 def add_fiber():
172  temp_fiber = bpy.ops.mesh.primitive_cylinder_add(radius = 0.1,
173  rotation=(0, 0, 0))
174 
175  ob = bpy.context.active_object
176  ob.scale[2] = 5
177  ob.name = "fiber"
178  me = ob.data
179  color = (1, 1, 1)
180  mat = create_new_material(ob.name, color)
181  me.materials.append(mat)
182 
183 
184 
185 
186 #------------------------------------------------------------------------------#
187 # MAIN
188 #------------------------------------------------------------------------------#
189 
def create_new_material(passedName, passedcolor)
Definition: visualize_3d.py:40
Here is the call graph for this function:

◆ create_cube()

def visualize_3d.create_cube (   box_length,
  res_stand,
  xres,
  yres,
  zres,
  step_size,
  dens_scale,
  voxelfile 
)

Definition at line 103 of file visualize_3d.py.

References create_volume().

Referenced by def_scene().

103  dens_scale, voxelfile):
104  cube = bpy.ops.mesh.primitive_cube_add(
105  location=(0,0,0),
106  radius = box_length * 0.5)
107 
108  bpy.ops.object.mode_set(mode="EDIT")
109  bpy.ops.object.mode_set(mode="OBJECT")
110  ob = bpy.context.object
111  ob.scale = ((xres/res_stand, yres/res_stand, zres/res_stand))
112 
113  # setting voxel material
114  me = ob.data
115  mat = create_volume("MaterialVolume", xres, yres, zres, step_size,
116  dens_scale, voxelfile)
117  me.materials.append(mat)
118 
119  return cube
120 
121 # function to create voxel material for cube
def create_volume(passedName, xres, yres, zres, step_size, dens_scale, voxelfile)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_new_material()

def visualize_3d.create_new_material (   passedName,
  passedcolor 
)

Definition at line 40 of file visualize_3d.py.

Referenced by add_fiber().

40 def create_new_material (passedName,passedcolor):
41  tempMat = bpy.data.materials.new(passedName)
42  if tempMat != None:
43  tempMat.diffuse_color = passedcolor
44  tempMat.diffuse_shader = 'LAMBERT'
45  tempMat.diffuse_intensity = 1.0
46  tempMat.specular_color = (0.9,0.9,0.9)
47  tempMat.specular_shader = 'COOKTORR'
48  tempMat.specular_intensity = 0.5
49  tempMat.use_transparency=False
50  tempMat.alpha = 0.5
51  tempMat.ambient = 0.2
52  tempMat.emit = 0.9
53  tempMat.keyframe_insert(data_path="diffuse_color", frame=1, index=-1)
54  return tempMat
55 
56 # Function to define the scene
def create_new_material(passedName, passedcolor)
Definition: visualize_3d.py:40
Here is the caller graph for this function:

◆ create_volume()

def visualize_3d.create_volume (   passedName,
  xres,
  yres,
  zres,
  step_size,
  dens_scale,
  voxelfile 
)

Definition at line 123 of file visualize_3d.py.

Referenced by create_cube().

123  voxelfile):
124  volMat = bpy.data.materials.new(passedName)
125  volMat.type = "VOLUME"
126  volMat.volume.density = 0.0
127  volMat.volume.step_method = "CONSTANT"
128  volMat.volume.step_size = step_size
129  volMat.volume.depth_threshold = 0.01
130  volMat.volume.density_scale = dens_scale
131  matTex = volMat.texture_slots.add()
132  voxTex = bpy.data.textures.new("VoxelData", type = "VOXEL_DATA")
133  voxTex.voxel_data.file_format = "BLENDER_VOXEL"
134  voxTex.use_color_ramp = True
135  voxTex.color_ramp.color_mode = "RGB"
136  ramp = voxTex.color_ramp
137 
138  values = [(0.0,(0,0,1,0)), (0.5,(0,0,1,0.3)), (0.75,(1,0,1,0.5)), (1.0, (1,0,0,1))]
139 
140  for n,value in enumerate(values):
141  #ramp.elements.new((n+1)*0.2)
142  (pos, color) = value
143  ramp.elements.new(pos)
144  elt = ramp.elements[n]
145  elt.position = pos
146  elt.color = color
147  voxTex.voxel_data.filepath = voxelfile
148  voxTex.voxel_data.resolution = (xres, yres, zres)
149  matTex.texture = voxTex
150  matTex.use_map_to_bounds = True
151  matTex.texture_coords = 'ORCO'
152  matTex.use_map_color_diffuse = True
153  matTex.use_map_emission = True
154  matTex.emission_factor = 1
155  matTex.emission_color_factor = 1
156  matTex.use_map_density = True
157  matTex.density_factor = 1
158  return volMat
159 
Here is the caller graph for this function:

◆ createCage()

def visualize_3d.createCage (   passedName)

Definition at line 160 of file visualize_3d.py.

160 def createCage(passedName):
161  cageMat = bpy.data.materials.new(passedName)
162  cageMat.use_shadeless = True
163  return cageMat
164 
165 # Render Scene into image
def createCage(passedName)

◆ def_scene()

def visualize_3d.def_scene (   box_length,
  res_stand,
  xres,
  yres,
  zres 
)

Definition at line 57 of file visualize_3d.py.

References create_cube(), and remove_obj().

57 def def_scene(box_length, res_stand, xres, yres, zres):
58  # first, we need to relocate the camera
59  x_cam = 0.0
60  y_cam = 1.2
61  z_cam = 0.8
62 
63  scene = bpy.context.scene
64 
65  # removing unnecessary obects (basically leaving only the camera)
66  remove_obj(scene)
67 
68  # defining dummy location (empty) to point camera at.
69  bpy.ops.object.add(type="EMPTY",
70  location=(0,0,0))
71 
72  context = bpy.context
73 
74  bpy.ops.object.select_pattern(pattern="Camera")
75  bpy.context.scene.objects.active = bpy.context.scene.objects["Camera"]
76  ob = bpy.data.objects["Camera"]
77  bpy.ops.object.constraint_add(type = "TRACK_TO")
78  target = bpy.data.objects.get("Empty", False)
79  ob.constraints["Track To"].target=target
80 
81  ob.constraints["Track To"].track_axis = "TRACK_NEGATIVE_Z"
82  ob.constraints["Track To"].up_axis = "UP_Y"
83 
84  scene.camera.location.x = box_length * x_cam * xres / res_stand
85  scene.camera.location.y = box_length * y_cam * yres / res_stand
86  scene.camera.location.z = box_length * z_cam * zres / res_stand
87 
88  # set's FOV
89  scene.camera.data.angle = 50*(np.pi/180.0)
90  bpy.data.cameras["Camera"].ortho_scale = 21.0
91 
92  # Set number of cores used
93  scene.render.threads_mode = "FIXED"
94  scene.render.threads = 8
95 
96  # Sets the BG to be black
97  bpy.data.worlds["World"].horizon_color = (1,1,1)
98 
99  return scene
100 
101 # function to create cube for data
def remove_obj(scene)
Definition: visualize_3d.py:34
def def_scene(box_length, res_stand, xres, yres, zres)
Definition: visualize_3d.py:57
Here is the call graph for this function:

◆ remove_obj()

def visualize_3d.remove_obj (   scene)

Definition at line 34 of file visualize_3d.py.

Referenced by def_scene().

34 def remove_obj(scene):
35  for ob in scene.objects:
36  if ob.name != "Camera":
37  scene.objects.unlink(ob)
38 
39 # Creates sphere material
def remove_obj(scene)
Definition: visualize_3d.py:34
Here is the caller graph for this function:

◆ render_img()

def visualize_3d.render_img (   filename)

Definition at line 166 of file visualize_3d.py.

166 def render_img(filename):
167  bpy.data.scenes['Scene'].render.filepath = filename
168  bpy.ops.render.render( write_still=True )
169 
170 # Function to add fiber
def render_img(filename)

Variable Documentation

◆ infile

visualize_3d.infile = open(voxelfile, "r")

Definition at line 27 of file visualize_3d.py.

◆ outfile

string visualize_3d.outfile = "image.png"

Definition at line 26 of file visualize_3d.py.

◆ scene

def visualize_3d.scene = def_scene(5, xDim, xDim, yDim, zDim)

Definition at line 191 of file visualize_3d.py.

◆ voxelfile

string visualize_3d.voxelfile = "test_Edges.bvox"

Definition at line 25 of file visualize_3d.py.

◆ xDim

int visualize_3d.xDim = 256

Definition at line 190 of file visualize_3d.py.