(encode, mesh, cf)
| 221 | timer3multngs = ngs.Timer("timer3 mul ngs") |
| 222 | |
| 223 | def GetNodalP1Data(encode, mesh, cf): |
| 224 | timerp1.Start() |
| 225 | fes = ngs.NodalFESpace(mesh, order=1)**cf.dim |
| 226 | gfu = ngs.GridFunction(fes) |
| 227 | gfu.Interpolate(cf, ngs.BND) |
| 228 | function_values = gfu.vec.FV().NumPy() |
| 229 | nvert = mesh.nv |
| 230 | function_values = function_values.reshape(-1, nvert).transpose().flatten() |
| 231 | fmin, fmax = ngs.Vector(function_values, copy=False).MinMax(True) |
| 232 | vertices = np.array(mesh.ngmesh._getVertices(), dtype=np.float32) |
| 233 | |
| 234 | pmat = vertices.reshape(-1, 3) |
| 235 | pmin = pmat.min(axis=0) |
| 236 | pmax = pmat.max(axis=0) |
| 237 | mesh_center = list(np.array(0.5*(pmin+pmax), dtype=np.float64)) |
| 238 | mesh_radius = float(np.linalg.norm(pmax-pmin)/2) |
| 239 | |
| 240 | segments = mesh.ngmesh._getSegments() |
| 241 | |
| 242 | d = {} |
| 243 | d['vertices'] = encode(vertices, dtype=np.float32) |
| 244 | d['nodal_function_values'] = encode(function_values, dtype=np.float32) |
| 245 | d['trigs'] = encode(np.array(mesh.ngmesh._get2dElementsAsTriangles(), dtype=np.int32)) |
| 246 | d['tets'] = encode(np.array(mesh.ngmesh._get3dElementsAsTets(), dtype=np.int32)) |
| 247 | d['segs'] = encode(np.array(segments, dtype=np.int32)) |
| 248 | d['mesh_center'] = mesh_center |
| 249 | d['mesh_radius'] = mesh_radius |
| 250 | d['funcmin'] = fmin |
| 251 | d['funcmax'] = fmax |
| 252 | |
| 253 | timerp1.Stop() |
| 254 | return d |
| 255 | |
| 256 | |
| 257 | def BuildRenderData(mesh, func, order=2, draw_surf=True, draw_vol=True, intpoints=None, deformation=None, regions=None, objects=[], nodal_p1=False, encoding='b64', settings={}): |
no test coverage detected