MCPcopy Create free account
hub / github.com/GollyGang/ready / MakeDefaultImageSystemFromMesh

Method MakeDefaultImageSystemFromMesh

src/gui/frame.cpp:2641–2696  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2639// ---------------------------------------------------------------------
2640
2641void MyFrame::MakeDefaultImageSystemFromMesh(vtkUnstructuredGrid* ug)
2642{
2643 size_t num_chemicals = 2;
2644 size_t target_chemical = 1;
2645 size_t largest_dimension = 64;
2646 float value_inside = 0.0f;
2647 float value_outside = 1.0f;
2648
2649 unique_ptr<ImageRD> image_sys;
2650 if (this->is_opencl_available)
2651 {
2652 IntegerDialog nc_dlg(this, _("Number of chemicals in new volume image"), _("Number of chemicals:"),
2653 3, 1, 20, wxDefaultPosition, wxDefaultSize);
2654 if (nc_dlg.ShowModal() != wxID_OK) return;
2655 num_chemicals = nc_dlg.GetValue();
2656
2657 wxArrayString choices;
2658 for (size_t i = 0; i<num_chemicals; i++)
2659 choices.Add(GetChemicalName(i));
2660 wxSingleChoiceDialog tc_dlg(this, _("Select the chemical to write the volume into:"), _("Select target chemical"),
2661 choices);
2662 tc_dlg.SetSelection(2);
2663 if (tc_dlg.ShowModal() != wxID_OK) return;
2664 target_chemical = tc_dlg.GetSelection();
2665
2666 IntegerDialog ld_dlg(this, _("Largest dimension of the new volume image"), _("Largest dimension:"),
2667 32, 1, 1024, wxDefaultPosition, wxDefaultSize);
2668 if (ld_dlg.ShowModal() != wxID_OK) return;
2669 largest_dimension = ld_dlg.GetValue();
2670
2671 FloatDialog inval_dlg(this, _("Value to set inside the mesh"), _("Value inside:"),
2672 0.1f, wxDefaultPosition, wxDefaultSize);
2673 if (inval_dlg.ShowModal() != wxID_OK) return;
2674 value_inside = inval_dlg.GetValue();
2675
2676 FloatDialog outval_dlg(this, _("Value to set outside the mesh"), _("Value outside:"),
2677 0.5f, wxDefaultPosition, wxDefaultSize);
2678 if (outval_dlg.ShowModal() != wxID_OK) return;
2679 value_outside = outval_dlg.GetValue();
2680
2681 // at some point we would want the user to decide what data type to use in the image
2682 const int data_type = VTK_FLOAT;
2683
2684 image_sys = make_unique<FormulaOpenCLImageRD>(opencl_platform, opencl_device, data_type);
2685 image_sys->SetFormula("delta_a = D_a * laplacian_a - a*b*b + F*(1.0f-a);\ndelta_b = D_b * laplacian_b + a*b*b - (F+K+c*0.035f)*b;");
2686 }
2687 else {
2688 image_sys = make_unique<GrayScottImageRD>();
2689 }
2690
2691 image_sys->CopyFromMesh(ug, num_chemicals, target_chemical, largest_dimension, value_inside, value_outside);
2692 image_sys->CreateDefaultInitialPatternGenerator(2);
2693 image_sys->GenerateInitialPattern();
2694 this->render_settings.GetProperty("timesteps_per_render").SetInt(16);
2695 this->SetCurrentRDSystem(move(image_sys));
2696}
2697
2698// ---------------------------------------------------------------------

Callers

nothing calls this directly

Calls 9

SetCurrentRDSystemMethod · 0.95
GetChemicalNameFunction · 0.85
AddMethod · 0.80
SetIntMethod · 0.80
GetValueMethod · 0.45
SetFormulaMethod · 0.45
CopyFromMeshMethod · 0.45

Tested by

no test coverage detected