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

Function MakeNewTriangularMesh

src/gui/MakeNewSystem.cpp:172–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

170// ---------------------------------------------------------------------
171
172unique_ptr<AbstractRD> MakeNewTriangularMesh(const bool is_opencl_available, const int opencl_platform, const int opencl_device, Properties& render_settings)
173{
174 // perhaps at some point we will want this to be determined by the user
175 const int data_type = VTK_FLOAT;
176
177 int n;
178 {
179 const int N_CHOICES = 5;
180 int choices[N_CHOICES] = { 30,50,100,200,500 };
181 int cells[N_CHOICES] = { 1682,4802,19602,79202,498002 };
182 wxString div_descriptions[N_CHOICES];
183 for (int i = 0; i<N_CHOICES; i++)
184 div_descriptions[i] = wxString::Format("%d cells", cells[i]);
185 wxSingleChoiceDialog dlg(NULL, _("Select the grid size:"), _("Triangular mesh options"), N_CHOICES, div_descriptions);
186 dlg.SetSelection(1); // default selection
187 dlg.SetSize(wxDefaultCoord, 130 + N_CHOICES * 20); // increase dlg height so we see all choices without having to scroll
188 if (dlg.ShowModal() != wxID_OK) {
189 return NULL;
190 }
191 n = choices[dlg.GetSelection()];
192 }
193 wxBusyCursor busy;
194 vtkSmartPointer<vtkUnstructuredGrid> mesh = vtkSmartPointer<vtkUnstructuredGrid>::New();
195 MeshGenerators::GetTriangularMesh(n, n, mesh, 2, data_type);
196 unique_ptr<MeshRD> mesh_sys;
197 if (is_opencl_available)
198 mesh_sys = make_unique<FormulaOpenCLMeshRD>(opencl_platform, opencl_device, data_type);
199 else
200 mesh_sys = make_unique<GrayScottMeshRD>();
201 mesh_sys->CopyFromMesh(mesh);
202 render_settings.GetProperty("active_chemical").SetChemical("b");
203 render_settings.GetProperty("slice_3D").SetBool(false);
204 render_settings.GetProperty("show_cell_edges").SetBool(n<100);
205 render_settings.GetProperty("use_image_interpolation").SetBool(false);
206 return mesh_sys;
207}
208
209// ---------------------------------------------------------------------
210

Callers 1

OnNewPatternMethod · 0.85

Calls 3

SetChemicalMethod · 0.80
SetBoolMethod · 0.80
CopyFromMeshMethod · 0.45

Tested by

no test coverage detected