Commit 79e0d716 authored by Andreas Kempe's avatar Andreas Kempe

Corrected an error where the root process was rendering too much.

parent 2cbf0688
......@@ -11,7 +11,7 @@ using namespace Magick;
mandel_render_srv::mandel_render_srv(std::string host, unsigned int port,
int id, int procs, QObject* parent) :
QObject(parent), settings(settings), id(id), procs(procs)
QObject(parent), id(id), procs(procs)
{
// We only let the root process connect to the client.
if (id == 0)
......@@ -57,17 +57,17 @@ void mandel_render_srv::start_drawing()
void mandel_render_srv::root_process_handling(unsigned long *receive_buffer)
{
Image my_image(Geometry(settings.img_width, settings.img_height), "white");
Image my_image(Geometry(settings.img_width, settings.img_height * procs), "white");
my_image.modifyImage();
Pixels pixel_cache(my_image);
PixelPacket *pixels = pixel_cache.get(0, 0, settings.img_width, settings.img_height);
PixelPacket *pixels = pixel_cache.get(0, 0, settings.img_width, settings.img_height * procs);
cout << "Assembling image!" << endl;
for (unsigned long y = 0; y < settings.img_height; ++y)
for (unsigned long y = 0; y < settings.img_height * procs; ++y)
{
cout << "Progress: " << setprecision(3) <<
static_cast<float>(y * 100) / (settings.img_height) << " % \r" << flush;
static_cast<float>(y * 100) / (settings.img_height * procs) << " % \r" << flush;
for (unsigned long x = 0; x < settings.img_width; ++x)
{
......@@ -155,6 +155,8 @@ void mandel_render_srv::handle_recv_data()
settings = recv_settings;
settings.img_height /= procs;
double mpi_data[8];
mpi_data[0] = static_cast<double>(mpi_opcodes::RENDER);
......@@ -163,7 +165,7 @@ void mandel_render_srv::handle_recv_data()
mpi_data[3] = settings.im_max;
mpi_data[4] = settings.im_min;
mpi_data[5] = settings.img_width;
mpi_data[6] = settings.img_height / procs;
mpi_data[6] = settings.img_height;
mpi_data[7] = settings.iterations;
// Send current render settings to other processes.
......@@ -173,6 +175,12 @@ void mandel_render_srv::handle_recv_data()
MPI_Send(mpi_data, 8, MPI_DOUBLE, i, 0, MPI_COMM_WORLD);
}
// Update the settings for the root process.
double im_max = settings.im_max;
double im_min = settings.im_min;
settings.im_max = get_max_im(im_max, im_min, 0, procs);
settings.im_min = get_min_im(im_max, im_min, 0, procs);
start_drawing();
break;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment