- Timestamp:
- May 8, 2005, 11:50:32 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution/realtime_visualisation.py
r773 r1295 11 11 #n = vector(0,0,0) 12 12 13 return n 13 return n 14 14 15 15 … … 20 20 21 21 #Outward normal 22 22 23 23 self.normal=normal(v1-v0, v2-v0) 24 24 25 25 self.panel = faces(frame = frame) 26 self.backpanel = faces(frame = frame) 26 self.backpanel = faces(frame = frame) 27 27 for v in (v0,v1,v2): 28 28 self.panel.append(pos=v, normal = self.normal, color=color) 29 29 30 30 for v in (v2,v1,v0): 31 self.backpanel.append(pos=v, normal = -self.normal, color=color) 32 33 31 self.backpanel.append(pos=v, normal = -self.normal, color=color) 32 33 34 34 def move(self,v): 35 35 """Move panel in direction given by vector v … … 37 37 38 38 for vertex in self.panel.pos: 39 vertex += v 39 vertex += v 40 40 41 41 def update_height(self,d,fix_baseline=False): … … 47 47 v0 = self.panel.pos[0] 48 48 v1 = self.panel.pos[1] 49 v2 = self.panel.pos[2] 50 49 v2 = self.panel.pos[2] 50 51 51 n = normal(v1-v0, self.normal) 52 52 … … 54 54 self.panel.pos[2] -= d*n 55 55 else: 56 self.panel.pos[:2] += d*n 56 self.panel.pos[:2] += d*n 57 57 58 58 def update_color(self, c): … … 61 61 62 62 self.panel.color = c 63 63 64 64 65 65 def set_vertexheights(self, heights, floor_heights = None): … … 70 70 floor_heights = zeros(heights.shape, Float) 71 71 72 all_vertices_below_threshold = True 72 all_vertices_below_threshold = True 73 73 for k in range(3): 74 74 w = heights[k] … … 77 77 if w-z >= hmin: 78 78 all_vertices_below_threshold = False 79 79 80 80 vertex = self.panel.pos[k] 81 81 vertex[2] = w … … 85 85 86 86 87 #Update color to visualise dry areas 88 if all_vertices_below_threshold: 87 #Update color to visualise dry areas 88 if all_vertices_below_threshold: 89 89 self.panel.color = self.bottom_color 90 self.backpanel.color = self.bottom_color 90 self.backpanel.color = self.bottom_color 91 91 else: 92 92 self.panel.color = self.top_color … … 94 94 95 95 96 #update normal 96 #update normal 97 97 v0 = self.panel.pos[0] 98 98 v1 = self.panel.pos[1] … … 104 104 self.backpanel.normal=-n 105 105 106 106 107 107 108 108 … … 120 120 except: 121 121 bed = False 122 122 123 123 N = Q.vertex_values.shape[0] 124 124 … … 128 128 z0 = Q.vertex_values[i, 0] 129 129 z1 = Q.vertex_values[i, 1] 130 z2 = Q.vertex_values[i, 2] 130 z2 = Q.vertex_values[i, 2] 131 131 132 132 x0, y0 = domain.get_vertex_coordinate(i,0) 133 133 x1, y1 = domain.get_vertex_coordinate(i,1) 134 x2, y2 = domain.get_vertex_coordinate(i,2) 135 134 x2, y2 = domain.get_vertex_coordinate(i,2) 135 136 136 V0 = vector(x0, y0, z0) 137 137 V1 = vector(x1, y1, z1) … … 149 149 150 150 col = (c0,c1,c2) 151 151 152 152 visual_top = Triangle(V0,V1,V2,color=col,frame=fr) 153 153 visual_top.top_color = col 154 154 155 155 156 156 #Bottom surface 157 157 #v0, v1, v2 = volume.vertices … … 168 168 V0 = vector(x0, y0, z0) 169 169 V1 = vector(x1, y1, z1) 170 V2 = vector(x2, y2, z2) 170 V2 = vector(x2, y2, z2) 171 171 172 172 c0 = 0.3 … … 176 176 c2 = 0.4*c2 #To show triangles in slightly different shades 177 177 178 col = (c0,c1,c2) 178 col = (c0,c1,c2) 179 179 visual_bottom = Triangle(V0, V1, V2, color=col,frame=fr) 180 180 visual_top.bottom_color=col 181 181 182 182 domain.visuals.append( (visual_top, visual_bottom) ) 183 183 184 184 update(domain) 185 #print 'Scale', scene.scale 186 187 188 def update(domain): 185 #print 'Scale', scene.scale 186 187 188 def update(domain): 189 189 """Update vertex heights. 190 The argument index refers to which conserved quantity to visualise. 190 The argument index refers to which conserved quantity to visualise. 191 191 If domain.smooth is set True, vertex values will be averaged 192 192 yielding a smoother surface. … … 198 198 Q = domain.quantities['stage'] 199 199 N = Q.vertex_values.shape[0] 200 200 201 201 #print scene.forward 202 202 #FIXME: Use smoother from pyvolution instead … … 218 218 219 219 220 for k in range(N): 220 for k in range(N): 221 221 if domain.smooth: 222 222 #The averages 223 223 x = zeros(3, Float) 224 for i in range(3): 224 for i in range(3): 225 225 vertex = domain.triangles[k, i] 226 226 A = array(vertex_heights[vertex]) 227 227 x[i] = sum(A)/len(A) 228 else: 228 else: 229 229 #The true values 230 230 x = [Q.vertex_values[k, 0], … … 232 232 Q.vertex_values[k, 2]] 233 233 234 234 235 235 #Do it 236 236 floor_heights = array([pos[2] for pos in domain.visuals[k][1].panel.pos]) 237 237 238 238 domain.visuals[k][0].set_vertexheights(x, floor_heights) 239 239 … … 246 246 #Original 247 247 scene.center = (0.5,0.5,0) 248 scene.forward = vector( -0.1, 0.5, -0.5)248 scene.forward = vector(0.0, 0.5, -0.5) 249 249 250 250 #Temporary (for bedslope) 251 #scene.forward = vector(0.0006, 0.7, -0.03) 251 #scene.forward = vector(0.0006, 0.7, -0.03) 252 252 253 253 … … 258 258 #Temporary for hackett - end 259 259 260 260 261 261 scene.ambient = 0.4 262 262 scene.lights = [(0.6, 0.3, 0.2), (0.1, -0.5, 0.4), (-0.1, 0.1, -0.4), … … 266 266 267 267 268
Note: See TracChangeset
for help on using the changeset viewer.