本文整理汇总了C++中ParamArray类的典型用法代码示例。如果您正苦于以下问题:C++ ParamArray类的具体用法?C++ ParamArray怎么用?C++ ParamArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ParamArray类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: absolute
void MaterialItem::slot_export()
{
const char* project_path = m_editor_context.m_project.get_path();
const filesystem::path project_root_path = filesystem::path(project_path).parent_path();
const filesystem::path file_path = absolute("material.dmt", project_root_path);
const filesystem::path file_root_path = file_path.parent_path();
QString filepath =
get_save_filename(
0,
"Export...",
"Disney Materials (*.dmt)",
m_editor_context.m_settings,
SETTINGS_FILE_DIALOG_PROJECTS);
if (!filepath.isEmpty())
{
if (QFileInfo(filepath).suffix().isEmpty())
filepath += ".dmt";
filepath = QDir::toNativeSeparators(filepath);
ParamArray parameters = m_entity->get_parameters();
parameters.insert("__name", m_entity->get_name());
parameters.insert("__model", m_entity->get_model());
SettingsFileWriter writer;
if (!writer.write(filepath.toStdString().c_str(), parameters))
{
show_error_message_box(
"Exporting Error",
"Failed to export the Disney Material file " + filepath.toStdString() + ".");
}
}
}
示例2: get_project_params
void MainWindow::update_override_shading_menu_item()
{
const ParamArray project_params = get_project_params("interactive");
const ParamArray shading_engine_params = project_params.child("shading_engine");
if (shading_engine_params.dictionaries().exist("override_shading"))
{
const string shading_mode =
shading_engine_params.child("override_shading").get_optional<string>("mode", "coverage");
for (const_each<QList<QAction*> > i = m_ui->menu_diagnostics_override_shading->actions(); i; ++i)
{
QAction* action = *i;
if (action->data().toString().toStdString() == shading_mode)
{
action->activate(QAction::Trigger);
break;
}
}
}
else
{
m_ui->action_diagnostics_override_shading_no_override->activate(QAction::Trigger);
}
}
示例3: create_diagnostic_surface_shader
void ShadingEngine::create_diagnostic_surface_shader(const ParamArray& params)
{
if (params.dictionaries().exist("override_shading"))
{
m_diagnostic_surface_shader =
DiagnosticSurfaceShaderFactory().create(
"__diagnostic_surface_shader",
params.child("override_shading"));
}
}
示例4: get_inherited_parameters
ParamArray Configuration::get_inherited_parameters() const
{
if (m_base)
{
ParamArray params = m_base->m_params;
params.merge(m_params);
return params;
}
else
{
return m_params;
}
}
示例5: create_primitive_mesh
auto_release_ptr<MeshObject> create_primitive_mesh(const char* name, const ParamArray& params)
{
const char* primitive_type = params.get("primitive");
// Parametric surfaces.
if (strcmp(primitive_type, "grid") == 0)
return create_parametric_surface<ParametricGrid>(name, params);
if (strcmp(primitive_type, "disk") == 0)
return create_parametric_surface<ParametricDisk>(name, params);
if (strcmp(primitive_type, "sphere") == 0)
return create_parametric_surface<ParametricSphere>(name, params);
if (strcmp(primitive_type, "torus") == 0)
return create_parametric_surface<ParametricTorus>(name, params);
// Other, non-parametric primitives.
if (strcmp(primitive_type, "cube") == 0)
return create_cube(name, params);
RENDERER_LOG_ERROR("unknown primitive type: %s", primitive_type);
return auto_release_ptr<MeshObject>();
}
示例6: string
void ObjectCollectionItem::insert_objects(const string& path) const
{
const string base_object_name =
bf::path(path).replace_extension().filename().string();
ParamArray params;
params.insert("filename", path);
SearchPaths search_paths;
MeshObjectArray mesh_objects;
if (!MeshObjectReader().read(
search_paths,
base_object_name.c_str(),
params,
mesh_objects))
return;
for (size_t i = 0; i < mesh_objects.size(); ++i)
{
MeshObject* object = mesh_objects[i];
m_parent_item->add_item(object);
m_parent.objects().insert(auto_release_ptr<Object>(object));
const string object_instance_name = string(object->get_name()) + "_inst";
auto_release_ptr<ObjectInstance> object_instance(
ObjectInstanceFactory::create(
object_instance_name.c_str(),
ParamArray(),
object->get_name(),
Transformd::identity(),
StringDictionary()));
m_parent_item->add_item(object_instance.get());
m_parent.object_instances().insert(object_instance);
}
if (!mesh_objects.empty())
{
m_parent.bump_version_id();
m_editor_context.m_project_builder.slot_notify_project_modification();
}
}
示例7: get_rendering_thread_count
size_t get_rendering_thread_count(const ParamArray& params)
{
const size_t core_count = System::get_logical_cpu_core_count();
static const char* ThreadCountParameterName = "rendering_threads";
if (!params.strings().exist(ThreadCountParameterName))
return core_count;
const string thread_count_str = params.strings().get<string>(ThreadCountParameterName);
if (thread_count_str == "auto")
return core_count;
bool conversion_failed = false;
size_t thread_count;
try
{
const int num_threads = from_string<int>(thread_count_str);
if (num_threads < 0)
{
// If num_threads is negative, use all cores except -num_threads.
thread_count = max(static_cast<int>(core_count) + num_threads, 1);
}
else
thread_count = num_threads;
}
catch (const ExceptionStringConversionError&)
{
conversion_failed = true;
}
if (conversion_failed || thread_count == 0)
{
RENDERER_LOG_ERROR(
"invalid value \"%s\" for parameter \"%s\", using default value \"%s\".",
thread_count_str.c_str(),
ThreadCountParameterName,
"auto");
return core_count;
}
return thread_count;
}
示例8: get_rendering_thread_count
size_t FrameRendererBase::get_rendering_thread_count(const ParamArray& params)
{
const size_t core_count = System::get_logical_cpu_core_count();
static const char* ThreadCountParameterName = "rendering_threads";
if (!params.strings().exist(ThreadCountParameterName))
return core_count;
const string thread_count_str = params.strings().get<string>(ThreadCountParameterName);
if (thread_count_str == "auto")
return core_count;
bool conversion_failed = false;
size_t thread_count;
try
{
thread_count = from_string<size_t>(thread_count_str);
}
catch (const ExceptionStringConversionError&)
{
conversion_failed = true;
}
if (conversion_failed || thread_count == 0)
{
RENDERER_LOG_ERROR(
"invalid value \"%s\" for parameter \"%s\", using default value \"%s\".",
thread_count_str.c_str(),
ThreadCountParameterName,
"auto");
return core_count;
}
return thread_count;
}
示例9: Impl
Impl(
const char* type,
const char* shader,
const char* layer,
const ParamArray& params)
: m_type(type)
, m_shader(shader)
{
for (const_each<StringDictionary> i = params.strings(); i; ++i)
{
try
{
ShaderParamParser parser(i.it().value());
switch (parser.param_type())
{
case OSLParamTypeColor:
{
float r, g, b;
parser.parse_three_values<float>(r, g, b, true);
m_params.insert(ShaderParam::create_color_param(i.it().key(), r, g, b));
}
break;
case OSLParamTypeColorArray:
{
vector<float> values;
parser.parse_float3_array(values);
m_params.insert(ShaderParam::create_color_array_param(i.it().key(), values));
}
break;
case OSLParamTypeFloat:
{
const float val = parser.parse_one_value<float>();
m_params.insert(ShaderParam::create_float_param(i.it().key(), val));
}
break;
case OSLParamTypeFloatArray:
{
vector<float> values;
parser.parse_float_array(values);
m_params.insert(ShaderParam::create_float_array_param(i.it().key(), values));
}
break;
case OSLParamTypeInt:
{
const int val = parser.parse_one_value<int>();
m_params.insert(ShaderParam::create_int_param(i.it().key(), val));
}
break;
case OSLParamTypeMatrix:
{
float val[16];
parser.parse_n_values(16, val);
m_params.insert(ShaderParam::create_matrix_param(i.it().key(), val));
}
break;
case OSLParamTypeNormal:
{
float x, y, z;
parser.parse_three_values<float>(x, y, z);
m_params.insert(ShaderParam::create_normal_param(i.it().key(), x, y, z));
}
break;
case OSLParamTypeNormalArray:
{
vector<float> values;
parser.parse_float3_array(values);
m_params.insert(ShaderParam::create_normal_array_param(i.it().key(), values));
}
break;
case OSLParamTypePoint:
{
float x, y, z;
parser.parse_three_values<float>(x, y, z);
m_params.insert(ShaderParam::create_point_param(i.it().key(), x, y, z));
}
break;
case OSLParamTypePointArray:
{
vector<float> values;
parser.parse_float3_array(values);
m_params.insert(ShaderParam::create_point_array_param(i.it().key(), values));
}
break;
case OSLParamTypeString:
{
m_params.insert(
ShaderParam::create_string_param(
i.it().key(),
parser.parse_string_value().c_str()));
//.........这里部分代码省略.........
示例10: get_open_filename
void MaterialCollectionItem::slot_import_disney()
{
#ifdef APPLESEED_WITH_DISNEY_MATERIAL
QString filepath =
get_open_filename(
0,
"Import...",
"Disney Material (*.dmt);;All Files (*.*)",
m_editor_context.m_settings,
SETTINGS_FILE_DIALOG_PROJECTS);
if (!filepath.isEmpty())
{
filepath = QDir::toNativeSeparators(filepath);
const bf::path root_path(Application::get_root_path());
const bf::path schema_file_path = root_path / "schemas" / "settings.xsd";
SettingsFileReader reader(global_logger());
ParamArray parameters;
const bool success =
reader.read(
filepath.toStdString().c_str(),
schema_file_path.string().c_str(),
parameters);
if (!success)
{
show_error_message_box(
"Importing Error",
"Failed to import the Disney Material file " + filepath.toStdString());
return;
}
string name = parameters.get("__name");
const string model = parameters.get("__model");
parameters.strings().remove("__name");
parameters.strings().remove("__model");
if (model != "disney_material")
{
show_error_message_box(
"Importing Error",
"Material model " + model + " is not supported.");
return;
}
// If there is already a material with the same name, rename the imported material.
for (const_each<MaterialContainer> i = m_parent.materials(); i; ++i)
{
if (strcmp(i->get_name(), name.c_str()) == 0)
{
name = make_unique_name(name, m_parent.materials());
break;
}
}
auto_release_ptr<Material> material =
DisneyMaterialFactory().create(name.c_str(), parameters);
Material* material_ptr = material.get();
add_item(material_ptr);
EntityTraits<Material>::insert_entity(material, m_parent);
m_editor_context.m_project_builder.notify_project_modification();
m_editor_context.m_project_explorer.select_entity(material_ptr->get_uid());
}
#endif
}
示例11: project
// Create a new instance of the default project.
auto_release_ptr<Project> DefaultProjectFactory::create()
{
// Create a project.
auto_release_ptr<Project> project(ProjectFactory::create("default"));
// Add default configurations to the project.
project->add_default_configurations();
// Create a scene.
auto_release_ptr<Scene> scene(SceneFactory::create());
// Create an assembly.
auto_release_ptr<Assembly> assembly(
AssemblyFactory::create("assembly", ParamArray()));
// Create an instance of the assembly and insert it into the scene.
scene->assembly_instances().insert(
AssemblyInstanceFactory::create(
"assembly_inst",
ParamArray(),
*assembly,
Transformd(Matrix4d::identity())));
// Insert the assembly into the scene.
scene->assemblies().insert(assembly);
//
// Camera.
//
{
// Create a pinhole camera.
// Film dimensions are 0.980 in × 0.735 in (24.892 mm x 18.669 mm).
// Reference: http://en.wikipedia.org/wiki/Aspect_ratio_(image).
ParamArray params;
params.insert("film_dimensions", "0.024892 0.018669");
params.insert("focal_length", "0.035");
auto_release_ptr<Camera> camera(
PinholeCameraFactory().create("camera", params));
// Attach the camera to the scene.
scene->set_camera(camera);
}
//
// Frame.
//
{
// Create a frame.
ParamArray params;
params.insert("camera", scene->get_camera()->get_name());
params.insert("resolution", "640 480");
params.insert("color_space", "srgb");
auto_release_ptr<Frame> frame(FrameFactory::create("beauty", params));
// Attach the frame to the project.
project->set_frame(frame);
}
// Attach the scene to the project.
project->set_scene(scene);
// Return the newly created project.
return project;
}
示例12: initialize_and_render_frame
// Initialize rendering components and render a frame.
IRendererController::Status initialize_and_render_frame()
{
// Construct an abort switch that will allow to abort initialization or rendering.
RendererControllerAbortSwitch abort_switch(*m_renderer_controller);
// Create the texture store.
TextureStore texture_store(
*m_project.get_scene(),
m_params.child("texture_store"));
// Initialize OSL's shading system.
if (!initialize_osl_shading_system(texture_store, abort_switch) ||
abort_switch.is_aborted())
{
// If it wasn't an abort, it was a failure.
return
abort_switch.is_aborted()
? m_renderer_controller->get_status()
: IRendererController::AbortRendering;
}
// Let scene entities perform their pre-render actions. Don't proceed if that failed.
// This is done before creating renderer components because renderer components need
// to access the scene's render data such as the scene's bounding box.
OnRenderBeginRecorder recorder;
if (!m_project.get_scene()->on_render_begin(m_project, nullptr, recorder, &abort_switch) ||
abort_switch.is_aborted())
{
recorder.on_render_end(m_project);
return m_renderer_controller->get_status();
}
// Create renderer components.
RendererComponents components(
m_project,
m_params,
m_tile_callback_factory,
texture_store,
*m_texture_system,
*m_shading_system);
if (!components.create())
{
recorder.on_render_end(m_project);
return IRendererController::AbortRendering;
}
// Print renderer components settings.
components.print_settings();
// Report whether Embree is used or not.
#ifdef APPLESEED_WITH_EMBREE
const bool use_embree = m_params.get_optional<bool>("use_embree", false);
m_project.set_use_embree(use_embree);
#else
const bool use_embree = false;
#endif
if (use_embree)
RENDERER_LOG_INFO("using Intel Embree ray tracing kernel.");
else RENDERER_LOG_INFO("using built-in ray tracing kernel.");
// Updating the trace context causes ray tracing acceleration structures to be updated or rebuilt.
m_project.update_trace_context();
// Load the checkpoint if any.
Frame& frame = *m_project.get_frame();
const size_t pass_count = m_params.get_optional<size_t>("passes", 1);
if (!frame.load_checkpoint(&components.get_shading_result_framebuffer_factory(), pass_count))
{
recorder.on_render_end(m_project);
return IRendererController::AbortRendering;
}
// Let renderer components perform their pre-render actions. Don't proceed if that failed.
if (!components.on_render_begin(recorder, &abort_switch) ||
abort_switch.is_aborted())
{
recorder.on_render_end(m_project);
return m_renderer_controller->get_status();
}
// Execute the main rendering loop.
const auto status = render_frame(components, abort_switch);
// Perform post-render actions.
recorder.on_render_end(m_project);
// End light path recording.
const CanvasProperties& props = m_project.get_frame()->image().properties();
m_project.get_light_path_recorder().finalize(
props.m_canvas_width,
props.m_canvas_height);
// Print texture store performance statistics.
RENDERER_LOG_DEBUG("%s", texture_store.get_statistics().to_string().c_str());
return status;
}
示例13: initialize_osl_shading_system
// Initialize OSL's shading system.
bool initialize_osl_shading_system(
TextureStore& texture_store,
IAbortSwitch& abort_switch)
{
// Construct a search paths string from the project's search paths.
const string project_search_paths =
to_string(m_project.search_paths().to_string_reversed(SearchPaths::osl_path_separator()));
// Initialize OIIO.
const size_t texture_cache_size_bytes =
m_params.child("texture_store").get_optional<size_t>(
"max_size",
TextureStore::get_default_size());
RENDERER_LOG_INFO(
"setting oiio texture cache size to %s.",
pretty_size(texture_cache_size_bytes).c_str());
const float texture_cache_size_mb =
static_cast<float>(texture_cache_size_bytes) / (1024 * 1024);
m_texture_system->attribute("max_memory_MB", texture_cache_size_mb);
// Set OIIO search paths.
string prev_oiio_search_path;
m_texture_system->getattribute("searchpath", prev_oiio_search_path);
if (prev_oiio_search_path != project_search_paths)
{
RENDERER_LOG_INFO("setting oiio search paths to %s", project_search_paths.c_str());
m_texture_system->invalidate_all(true);
m_texture_system->attribute("searchpath", project_search_paths);
}
// Also use the project search paths to look for OpenImageIO plugins.
m_texture_system->attribute("plugin_searchpath", project_search_paths);
// Initialize OSL.
m_renderer_services->initialize(texture_store);
// Set OSL search paths.
string prev_osl_search_paths;
m_shading_system->getattribute("searchpath:shader", prev_osl_search_paths);
if (prev_osl_search_paths != project_search_paths)
{
RENDERER_LOG_INFO("setting osl shader search paths to %s", project_search_paths.c_str());
m_project.get_scene()->release_optimized_osl_shader_groups();
m_shading_system->attribute("searchpath:shader", project_search_paths);
}
// Initialize the shader compiler, if the OSL headers are found.
if (m_resource_search_paths.exist("stdosl.h"))
{
const APIString stdosl_path = m_resource_search_paths.qualify("stdosl.h");
RENDERER_LOG_INFO("found OSL headers in %s", stdosl_path.c_str());
m_osl_compiler = ShaderCompilerFactory::create(stdosl_path.c_str());
}
else
RENDERER_LOG_INFO("OSL headers not found.");
// Re-optimize shader groups that need updating.
return
m_project.get_scene()->create_optimized_osl_shader_groups(
*m_shading_system,
m_osl_compiler.get(),
&abort_switch);
}
示例14: main
int main(int argc, char *argv[])
{
Meas.TaskList.TaskList_len = 1;
Meas.TaskList.TaskList_val = &Task;
Meas.GaugeStem = "";
Meas.RNGStem = "";
Task.OutputFilestem = "";
Task.ArgFilename = "arg_stem";
ws_out.cg = "";
ws_out.cg2 = "filename";
ws_out.pbp = "filename";
ws_out.mid_point = "filename";
ws_out.nucleon = "filename";
ws_out.nucleon_prime = "filename";
ws_out.delta_x = "filename";
ws_out.delta_y = "filename";
ws_out.delta_z = "filename";
ws_out.delta_t = "filename";
evo_arg.ensemble_id = "id";
evo_arg.ensemble_label = "label";
evo_arg.creator = "creator";
evo_arg.gauge_file_stem = "ckpoint_lat";
evo_arg.rng_file_stem = "ckpoint_rng";
evo_arg.plaquette_stem = "plaq";
evo_arg.evo_stem = "hmd";
evo_arg.work_directory = "";
ws_arg.CgArgFile = "CgFile";
rat_arg.resize(4);
rat_arg.resize(0, 10, 16);
rat_arg.resize(1, 10, 16);
rat_arg.resize(2, 9, 14);
rat_arg.resize(3, 6, 9);
bsn_arg.resize(1);
frm_arg.resize(1);
split_arg.resize(2);
quo_arg.resize(1);
rat_quo_arg.resize(1);
rat_quo_arg.resize(0, 9, 15, 6, 9);
float_array.resize(4);
param_array.resize(3);
param_array.params.params_val[0].name="mass";
param_array.params.params_val[1].name="epsilon";
param_array.params.params_val[2].name="u0";
stag_quark_src.type = S_QUARK_POINT;
for(int i = 0; i < 4; i++)
{
stag_quark_src.origin[i] = 0;
stag_quark_src.end[i] = 0;
}
stag_quark_src.dir = HDM_T;
stag_quark_arg.qid = 0;
stag_quark_arg.cg.mass = 0.1;
stag_quark_arg.cg.max_num_iter = 5000;
stag_quark_arg.cg.stop_rsd = 1e-10;
stag_quark_arg.cg.true_rsd = 1e-10;
stag_quark_arg.cg.RitzMatOper = MATPCDAG_MATPC;
stag_quark_arg.cg.Inverter = CG;
stag_quark_arg.cg.bicgstab_n = 1;
stag_quark_arg.src = stag_quark_src;
stag_quark_arg.sln = LOCAL;
stag_meson_arg.qid0 = 0;
stag_meson_arg.qid1 = 1;
stag_meson_arg.dir = HDM_T;
stag_meson_arg.meson_buf = 0;
stag_mom_meson_arg.qid0 = 0;
stag_mom_meson_arg.qid1 = 1;
stag_mom_meson_arg.dir = HDM_T;
stag_mom_meson_arg.no_of_momenta = 4;
stag_mom_meson_arg.meson_buf = 0;
stag_nucleon_arg.qid0 = 0;
stag_nucleon_arg.qid1 = 1;
stag_nucleon_arg.qid2 = 2;
stag_nucleon_arg.dir = HDM_T;
stag_nucleon_arg.nucleon_buf = 0;
stag_non_local_arg.qid0 = 0;
stag_non_local_arg.qid1 = 1;
stag_non_local_arg.qid2 = 2;
stag_non_local_arg.dir = HDM_T;
stag_non_local_arg.nlocal_buf = 0;
for(int i = 0; i < 8; i++)
nlstag_meson_arg.qid0[i] = i;
nlstag_meson_arg.dir = HDM_T;
nlstag_meson_arg.nlocal_buf = 0;
nuc3pt_arg.cname="AlgNuc3pt";
nuc3pt_arg.ensemble_label="AlgNuc3pt";
mdwf_arg.M5 = 1.8;
// mdwf_arg.cg_arg_p = &cg_arg;
cg_arg.Encode("cg_arg.vml","cg_arg");
mdwf_arg.Encode("mdwf_arg.vml","mdwf_arg");
hmd_arg.Encode("hmd_arg.vml","hmd_arg");
evo_arg.Encode("evo_arg.vml","evo_arg");
do_arg.Encode("do_arg.vml","do_arg");
ws_arg.Encode("w_spect_arg.vml","w_spect_arg");
//.........这里部分代码省略.........