(mesh, func, order=2, draw_surf=True, draw_vol=True, intpoints=None, deformation=None, regions=None, objects=[], nodal_p1=False, encoding='b64', settings={})
| 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={}): |
| 258 | timer.Start() |
| 259 | |
| 260 | import inspect |
| 261 | # stay backwards-compatible with older verisons of webgui_jupyter_widgets |
| 262 | if 'encoding' in inspect.signature(encodeData).parameters: |
| 263 | def encode(*args, **kwargs): |
| 264 | return encodeData(*args, **kwargs, encoding=encoding) |
| 265 | else: |
| 266 | def encode(*args, **kwargs): |
| 267 | return encodeData(*args, **kwargs) |
| 268 | |
| 269 | if isinstance(deformation, ngs.CoefficientFunction) and deformation.dim==2: |
| 270 | deformation = ngs.CoefficientFunction((deformation, 0.0)) |
| 271 | |
| 272 | #TODO: handle quads and non-smooth functions |
| 273 | #TODO: subdivision |
| 274 | |
| 275 | d = {} |
| 276 | d['gui_settings'] = settings |
| 277 | d['ngsolve_version'] = ngs.__version__ |
| 278 | d['mesh_dim'] = mesh.dim |
| 279 | # order = order or mesh.GetCurveOrder() |
| 280 | if (not func) and (mesh.GetCurveOrder()==1) and (mesh.nv==len(mesh.ngmesh.Points())): |
| 281 | order=1 |
| 282 | order2d = min(order, 3) |
| 283 | order3d = min(order, 2) |
| 284 | d['order2d'] = order2d |
| 285 | d['order3d'] = order3d |
| 286 | |
| 287 | d['draw_vol'] = func and mesh.dim==3 and draw_vol and mesh.ne>0 |
| 288 | d['draw_surf'] = func and draw_surf |
| 289 | |
| 290 | d['objects'] = [] |
| 291 | for obj in objects: |
| 292 | if isinstance(obj, dict): |
| 293 | d['objects'].append(obj) |
| 294 | else: |
| 295 | d['objects'].append(obj._GetWebguiData()) |
| 296 | |
| 297 | if isinstance(deformation, bool): |
| 298 | d['deformation'] = deformation |
| 299 | deformation = None |
| 300 | |
| 301 | cf = None |
| 302 | |
| 303 | if func and func.is_complex: |
| 304 | d['is_complex'] = True |
| 305 | cf = func.realimag |
| 306 | elif func: |
| 307 | cf = func |
| 308 | else: |
| 309 | # no function at all -> we are just drawing a mesh, eval mesh element index instead |
| 310 | mats = mesh.GetMaterials() |
| 311 | bnds = mesh.GetBoundaries() |
| 312 | bbnds = mesh.GetBBoundaries() |
| 313 | nmats = len(mesh.GetMaterials()) |
| 314 | nbnds = len(mesh.GetBoundaries()) |
no test coverage detected