This commit is contained in:
Djairo Hougee 2024-05-05 23:28:01 +02:00
parent f2b6286ecb
commit b5dd0d5e49
1 changed files with 26 additions and 26 deletions

View File

@ -62,32 +62,32 @@ void BackgroundImage::updateImage() {
this->ren->AddActor(imageActor); this->ren->AddActor(imageActor);
// camera stuff // // camera stuff
// essentially sets the camera to the middle of the background, and points it at the background // // essentially sets the camera to the middle of the background, and points it at the background
// TODO: extract this to its own function, separate from the background class. // // TODO: extract this to its own function, separate from the background class.
double origin[3], spacing[3]; // double origin[3], spacing[3];
int extent[6]; // int extent[6];
imageData->GetOrigin(origin); // imageData->GetOrigin(origin);
imageData->GetSpacing(spacing); // imageData->GetSpacing(spacing);
imageData->GetExtent(extent); // imageData->GetExtent(extent);
//
printf("%lf, %lf, %lf\n", origin[0], origin[1], origin[2]); // printf("%lf, %lf, %lf\n", origin[0], origin[1], origin[2]);
printf("%lf, %lf, %lf\n", spacing[0], spacing[1], spacing[2]); // printf("%lf, %lf, %lf\n", spacing[0], spacing[1], spacing[2]);
printf("%d, %d, %d, ", extent[0], extent[1], extent[2]); // printf("%d, %d, %d, ", extent[0], extent[1], extent[2]);
printf("%d, %d, %d\n", extent[3], extent[4], extent[5]); // printf("%d, %d, %d\n", extent[3], extent[4], extent[5]);
//
vtkCamera *camera = this->ren->GetActiveCamera(); // vtkCamera *camera = this->ren->GetActiveCamera();
camera->ParallelProjectionOn(); // camera->ParallelProjectionOn();
//
double xc = origin[0] + 0.5 * (extent[0] + extent[1]) * spacing[0]; // double xc = origin[0] + 0.5 * (extent[0] + extent[1]) * spacing[0];
double yc = origin[1] + 0.5 * (extent[2] + extent[3]) * spacing[1]; // double yc = origin[1] + 0.5 * (extent[2] + extent[3]) * spacing[1];
double yd = (extent[3] - extent[2] + 1) * spacing[1]; // double yd = (extent[3] - extent[2] + 1) * spacing[1];
//
printf("%lf, %lf, %lf\n", xc, yc, yd); // printf("%lf, %lf, %lf\n", xc, yc, yd);
//
camera->SetParallelScale(0.5 * yd); // sets to 330; should be 1 -> transform // camera->SetParallelScale(0.5 * yd); // sets to 330; should be 1 -> transform
camera->SetFocalPoint(xc, yc, 0.0); // sets to 0,0,0; isnice // camera->SetFocalPoint(xc, yc, 0.0); // sets to 0,0,0; isnice
camera->SetPosition(xc, yc, 1000); // sets to 0,0,1000; isnice // camera->SetPosition(xc, yc, 1000); // sets to 0,0,1000; isnice
} }