This example demonstrates the use of the queue manager.
#include <iostream>
#include <sstream>
#include <string>
#include "example_shared.h"
#include "example_render_target_simple.h"
class Iray_bridge_snapshot_callback
{
public:
{
if( error_code == 0)
fprintf( stderr, "Successfully created cb snapshot.\n");
else
fprintf( stderr, "Failed to create cb snapshot.\n");
m_condition.signal();
}
void progress(
mi::Float64 value,
const char* area,
const char* message)
{
fprintf( stderr, "Progress: %.4f %s %s\n", value, area, message);
}
void wait_for_ready_callback()
{
m_condition.wait();
}
private:
};
{
check_success( rc->add_mdl_path( mdl_path) == 0);
check_success( rc->add_mdl_path( ".") == 0);
}
{
check_success( database.is_valid_interface());
check_success( transaction.is_valid_interface());
check_success( import_api.is_valid_interface());
import_api->import_elements( transaction.get(), uri->get_c_str()));
check_success( import_result->get_error_number() == 0);
check_success( scene.is_valid_interface());
scene->set_rootgroup( import_result->get_rootgroup());
scene->set_options( import_result->get_options());
scene->set_camera_instance( import_result->get_camera_inst());
transaction->store( scene.get(), "the_scene");
scene = 0;
transaction->commit();
}
void make_snapshot(
const char* queue_manager_address,
const char* user_name,
const char* password)
{
queue_manager_api->connect( queue_manager_address, user_name, password, &errors));
check_success( errors == 0);
check_success( connection.is_valid_interface());
const std::string bridge_server_url(connection->get_compatible_snapshot_bridge_url());
const std::string authentication_token(connection->get_authentication_token());
check_success( iray_bridge_client.is_valid_interface());
check_success( iray_bridge_client->set_application_url( bridge_server_url.c_str()) == 0);
check_success( iray_bridge_client->set_security_token( authentication_token.c_str()) == 0);
iray_bridge_client->create_snapshot_context( transaction.get(), "the_scene"));
= snapshot_context->create_snapshot( transaction.get(), "snapshot.cb", callback.get());
if( result >= 0)
callback->wait_for_ready_callback();
transaction->commit();
}
void rendering(
const char* queue_manager_address,
const char* user_name,
const char* password)
{
queue_manager_api->connect( queue_manager_address, user_name, password, &errors));
check_success( errors == 0);
check_success( connection.is_valid_interface());
snapshot_name->set_c_str( "snapshot.cb");
result_name->set_c_str( "example_queue_manager_client_snapshot_%B");
name0->set_c_str( "result");
render_target0->get_value<
mi::IString>(
"pixel_type"));
pixel_type0->set_c_str( "Color");
render_target0->get_value<
mi::IString>(
"output_name"));
output_name0->set_c_str( "result");
name1->set_c_str( "normal");
render_target1->get_value<
mi::IString>(
"pixel_type"));
pixel_type1->set_c_str( "Float32<3>");
render_target1->get_value<
mi::IString>(
"output_name"));
output_name1->set_c_str( "normal");
errors = connection->submit_job(
"example", snapshots.get(), render_targets.get(), 512, 384, 100, 3600, 1.0f, "png", 0);
check_success( errors == 0);
}
int main( int argc, char* argv[])
{
if( argc != 6) {
std::cerr << "Usage: example_queue_manager_client <scene_file> <mdl_path> \\\n"
<< " <queue_manager_address> <user_name> <password>" << std::endl;
keep_console_open();
return EXIT_FAILURE;
}
const char* scene_file = argv[1];
const char* mdl_path = argv[2];
const char* queue_manager_address = argv[3];
const char* user_name = argv[4];
const char* password = argv[5];
check_success( neuray.is_valid_interface());
configuration( neuray.get(), mdl_path);
check_start_success( result);
import_and_store_scene( neuray.get(), scene_file);
make_snapshot( neuray.get(), queue_manager_address, user_name, password);
rendering( neuray.get(), queue_manager_address, user_name, password);
check_success( neuray->
shutdown() == 0);
neuray = 0;
check_success( unload());
keep_console_open();
return EXIT_SUCCESS;
}
This interface represents static arrays, i.e., arrays with a fixed number of elements.
Definition: iarray.h:37
A simple string class.
Definition: istring.h:22
This interface represents structures, i.e., a key-value based data structure.
Definition: istructure.h:44
Conditions allow threads to signal an event and to wait for such a signal, respectively.
Definition: condition.h:33
Handle class template for interfaces, automatizing the lifetime control via reference counting.
Definition: handle.h:113
Mixin class template for deriving interface implementations.
Definition: interface_implement.h:41
API component that serves as entry point for the client-side Iray Bridge API.
Definition: iiray_bridge_client.h:248
This interface is used to interact with the distributed database.
Definition: idatabase.h:293
This API component allows the creation, assignment, and cloning of instances of types.
Definition: ifactory.h:35
This interface is used to import files.
Definition: iimport_api.h:100
This is an object representing the Iray library.
Definition: ineuray.h:44
virtual Sint32 shutdown(bool blocking=true)=0
Shuts down the library.
virtual base::IInterface * get_api_component(const base::Uuid &uuid) const =0
Returns an API component from the Iray SDK API.
virtual Sint32 start(bool blocking=true)=0
Starts the operation of the Iray library.
This interface is used to load plugins and to query information about loaded plugins.
Definition: iplugin_configuration.h:24
An API component which can be used to create a connection to a queue manager.
Definition: iqueue_manager_api.h:163
This interface is used to query and change the rendering configuration.
Definition: irendering_configuration.h:109
The scene is the top-level element describing a subset of DB elements to be rendered.
Definition: iscene.h:44
#define MI_BASE_DLL_FILE_EXT
The operating system specific default filename extension for shared libraries (DLLs)
Definition: config.h:340
Uint64 Size
Unsigned integral type that is large enough to hold the size of all types.
Definition: types.h:112
double Float64
64-bit float.
Definition: types.h:52
signed int Sint32
32-bit signed integer.
Definition: types.h:46