#include "CartographicTransformation.h" #include #include #include vtkSmartPointer createNormalisedCamera() { vtkSmartPointer camera = vtkSmartPointer::New(); camera->ParallelProjectionOn(); // Enable parallel projection camera->SetPosition(0, 0, 1000); // Place the camera above the center camera->SetFocalPoint(0, 0, 0); // Look at the center camera->SetViewUp(0, 1, 0); // Set the up vector to be along the Y-axis camera->SetParallelScale(1); // x,y in [-1, 1] return camera; } vtkSmartPointer getCartographicTransformMatrix(const std::shared_ptr uvGrid) { const double XMin = uvGrid->lons.front(); const double XMax = uvGrid->lons.back(); const double YMin = uvGrid->lats.front(); const double YMax = uvGrid->lats.back(); double eyeTransform[] = { 2/(XMax-XMin), 0, 0, -(XMax+XMin)/(XMax-XMin), 0, 2/(YMax-YMin), 0, -(YMax+YMin)/(YMax-YMin), 0, 0, 1, 0, 0, 0, 0, 1 }; auto matrix = vtkSmartPointer::New(); matrix->DeepCopy(eyeTransform); return matrix; } // Assumes Normalised camera is used vtkSmartPointer createCartographicTransformFilter(const std::shared_ptr uvGrid) { vtkNew transform; transform->SetMatrix(getCartographicTransformMatrix(uvGrid)); vtkSmartPointer transformFilter = vtkSmartPointer::New(); transformFilter->SetTransform(transform); return transformFilter; }