| 13 | void ExportVisFunctions(py::module &m); |
| 14 | |
| 15 | void NGS_DLL_HEADER ExportNgsolve(py::module &m ) { |
| 16 | m.def ("__Cleanup", []() |
| 17 | { |
| 18 | GetPreconditionerClasses().Cleanup(); |
| 19 | } |
| 20 | ); |
| 21 | |
| 22 | m.def ("Tcl_Eval", &Ng_TclCmd); |
| 23 | |
| 24 | m.def ("Draw", [](shared_ptr<CoefficientFunction> cf, variant<shared_ptr<MeshAccess>, Region*> ma_or_region, string name, |
| 25 | int sd, bool autoscale, double min, double max, |
| 26 | bool draw_vol, bool draw_surf, bool reset, string title, string number_format, string unit, py::kwargs kwargs) |
| 27 | { |
| 28 | if (cf == nullptr) |
| 29 | throw Exception("In Draw: invalid object to draw"); |
| 30 | |
| 31 | if (reset) |
| 32 | { |
| 33 | Ng_TclCmd ("set ::visoptions.deformation 0;\n"); |
| 34 | Ng_TclCmd ("Ng_Vis_Set parameters;\n"); |
| 35 | Ng_ClearSolutionData(); |
| 36 | } |
| 37 | shared_ptr<MeshAccess> ma; |
| 38 | if(ma_or_region.index() == 0) |
| 39 | ma = get<shared_ptr<MeshAccess>>(ma_or_region); |
| 40 | else |
| 41 | ma = get<Region*>(ma_or_region)->Mesh(); |
| 42 | ma->SelectMesh(); |
| 43 | netgen::SolutionData * vis; |
| 44 | if(dynamic_cast<ProlongateCoefficientFunction *>(cf.get())) |
| 45 | { |
| 46 | shared_ptr<CoefficientFunction> wrapper(new ProlongateCoefficientFunctionVisualization(*static_cast<ProlongateCoefficientFunction *>(cf.get()))); |
| 47 | vis = new VisualizeCoefficientFunction (ma, wrapper); |
| 48 | } |
| 49 | else |
| 50 | vis = new VisualizeCoefficientFunction (ma, cf); |
| 51 | Ng_SolutionData soldata; |
| 52 | Ng_InitSolutionData (&soldata); |
| 53 | |
| 54 | soldata.name = name; |
| 55 | soldata.title = title; |
| 56 | soldata.number_format = number_format; |
| 57 | soldata.unit = unit; |
| 58 | soldata.data = 0; |
| 59 | soldata.components = cf -> Dimension(); |
| 60 | if (cf->IsComplex()) soldata.components *= 2; |
| 61 | soldata.iscomplex = cf -> IsComplex(); |
| 62 | soldata.draw_surface = draw_surf; |
| 63 | soldata.draw_volume = draw_vol; |
| 64 | if(kwargs.contains("surfaces")) |
| 65 | soldata.draw_surfaces = py::cast<shared_ptr<BitArray>>(kwargs["surfaces"]); |
| 66 | if(kwargs.contains("volumes")) |
| 67 | soldata.draw_volumes = py::cast<shared_ptr<BitArray>>(kwargs["volumes"]); |
| 68 | if(ma_or_region.index() == 1) |
| 69 | { |
| 70 | auto reg = get<Region*>(ma_or_region); |
| 71 | if(reg->VB() == VOL) |
| 72 | soldata.draw_volumes = make_shared<BitArray>(reg->Mask()); |
nothing calls this directly
no test coverage detected