no real changes

This commit is contained in:
robin 2024-05-08 13:59:20 +02:00
parent 2b641a4a78
commit 16d3423eb9
2 changed files with 54 additions and 37 deletions

View File

@ -7,35 +7,17 @@
#include <vtkGeneralTransform.h> #include <vtkGeneralTransform.h>
vtkSmartPointer<vtkCamera> createNormalisedCamera() { vtkSmartPointer<vtkCamera> createNormalisedCamera() {
vtkSmartPointer<vtkCamera> camera = vtkSmartPointer<vtkCamera>::New(); vtkSmartPointer<vtkCamera> camera = vtkSmartPointer<vtkCamera>::New();
camera->ParallelProjectionOn(); // Enable parallel projection camera->ParallelProjectionOn(); // Enable parallel projection
camera->SetPosition(0, 0, 1000); // Place the camera above the center camera->SetPosition(0, 0, 1000); // Place the camera above the center
camera->SetFocalPoint(0, 0, 0); // Look at 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->SetViewUp(0, 1, 0); // Set the up vector to be along the Y-axis
camera->SetParallelScale(1); // x,y in [-1, 1] camera->SetParallelScale(1); // x,y in [-1, 1]
return camera; return camera;
} }
//vtkSmartPointer<vtkMatrix4x4> getCartographicTransformMatrix(const std::shared_ptr<UVGrid> 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<vtkMatrix4x4>::New();
// matrix->DeepCopy(eyeTransform);
// return matrix;
//}
// Assumes Normalised camera is used // Assumes Normalised camera is used
vtkSmartPointer<vtkTransformFilter> createCartographicTransformFilter(const std::shared_ptr<UVGrid> uvGrid) { vtkSmartPointer<vtkTransformFilter> createCartographicTransformFilter(const std::shared_ptr<UVGrid> uvGrid) {
auto proj = vtkSmartPointer<vtkGeoProjection>::New(); auto proj = vtkSmartPointer<vtkGeoProjection>::New();
@ -44,10 +26,10 @@ vtkSmartPointer<vtkTransformFilter> createCartographicTransformFilter(const std:
auto geoTransform = vtkSmartPointer<vtkGeoTransform>::New(); auto geoTransform = vtkSmartPointer<vtkGeoTransform>::New();
geoTransform->SetDestinationProjection(proj); geoTransform->SetDestinationProjection(proj);
const double XMin = -15.875; const double XMin = uvGrid->lons.front();
const double XMax = 12.875; const double XMax = uvGrid->lons.back();
const double YMin = 46.125; const double YMin = uvGrid->lats.front();
const double YMax = 62.625; const double YMax = uvGrid->lats.back();
double bottomLeft[3] = {XMin, YMin, 0}; double bottomLeft[3] = {XMin, YMin, 0};
double topRight[3] = {XMax, YMax, 0}; double topRight[3] = {XMax, YMax, 0};
@ -58,8 +40,8 @@ vtkSmartPointer<vtkTransformFilter> createCartographicTransformFilter(const std:
double height = topRight[1] - bottomLeft[1]; double height = topRight[1] - bottomLeft[1];
auto scaleIntoNormalisedSpace = vtkSmartPointer<vtkTransform>::New(); auto scaleIntoNormalisedSpace = vtkSmartPointer<vtkTransform>::New();
scaleIntoNormalisedSpace->Scale(2/(width), 2/(height), 1); scaleIntoNormalisedSpace->Scale(2 / (width), 2 / (height), 1);
scaleIntoNormalisedSpace->Translate(-(bottomLeft[0]+topRight[0])/2, -(bottomLeft[1] + topRight[1])/2, 0); scaleIntoNormalisedSpace->Translate(-(bottomLeft[0] + topRight[0]) / 2, -(bottomLeft[1] + topRight[1]) / 2, 0);
auto totalProjection = vtkSmartPointer<vtkGeneralTransform>::New(); auto totalProjection = vtkSmartPointer<vtkGeneralTransform>::New();
totalProjection->Identity(); totalProjection->Identity();
@ -79,10 +61,10 @@ vtkSmartPointer<vtkTransformFilter> createInverseCartographicTransformFilter(con
auto geoTransform = vtkSmartPointer<vtkGeoTransform>::New(); auto geoTransform = vtkSmartPointer<vtkGeoTransform>::New();
geoTransform->SetDestinationProjection(proj); geoTransform->SetDestinationProjection(proj);
const double XMin = -15.875; const double XMin = uvGrid->lons.front();
const double XMax = 12.875; const double XMax = uvGrid->lons.back();
const double YMin = 46.125; const double YMin = uvGrid->lats.front();
const double YMax = 62.625; const double YMax = uvGrid->lats.back();
double bottomLeft[3] = {XMin, YMin, 0}; double bottomLeft[3] = {XMin, YMin, 0};
double topRight[3] = {XMax, YMax, 0}; double topRight[3] = {XMax, YMax, 0};
@ -94,8 +76,8 @@ vtkSmartPointer<vtkTransformFilter> createInverseCartographicTransformFilter(con
double height = topRight[1] - bottomLeft[1]; double height = topRight[1] - bottomLeft[1];
auto scaleIntoNormalisedSpace = vtkSmartPointer<vtkTransform>::New(); auto scaleIntoNormalisedSpace = vtkSmartPointer<vtkTransform>::New();
scaleIntoNormalisedSpace->Scale(2/(width), 2/(height), 1); scaleIntoNormalisedSpace->Scale(2 / (width), 2 / (height), 1);
scaleIntoNormalisedSpace->Translate(-(bottomLeft[0]+topRight[0])/2, -(bottomLeft[1] + topRight[1])/2, 0); scaleIntoNormalisedSpace->Translate(-(bottomLeft[0] + topRight[0]) / 2, -(bottomLeft[1] + topRight[1]) / 2, 0);
scaleIntoNormalisedSpace->Inverse(); scaleIntoNormalisedSpace->Inverse();
auto totalProjection = vtkSmartPointer<vtkGeneralTransform>::New(); auto totalProjection = vtkSmartPointer<vtkGeneralTransform>::New();
@ -108,3 +90,33 @@ vtkSmartPointer<vtkTransformFilter> createInverseCartographicTransformFilter(con
return transformFilter; return transformFilter;
} }
//vtkSmartPointer<vtkMatrix4x4> getCartographicTransformMatrix(const std::shared_ptr<UVGrid> 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<vtkMatrix4x4>::New();
// matrix->DeepCopy(eyeTransform);
// return matrix;
//}
//
//// Assumes Normalised camera is used
//vtkSmartPointer<vtkTransformFilter> createCartographicTransformFilter(const std::shared_ptr<UVGrid> uvGrid) {
// vtkNew<vtkTransform> transform;
//
// transform->SetMatrix(getCartographicTransformMatrix(uvGrid));
//
// vtkSmartPointer<vtkTransformFilter> transformFilter = vtkSmartPointer<vtkTransformFilter>::New();
// transformFilter->SetTransform(transform);
//
// return transformFilter;
//}

View File

@ -12,10 +12,13 @@
#include <vtkProperty2D.h> #include <vtkProperty2D.h>
#include <vtkVertexGlyphFilter.h> #include <vtkVertexGlyphFilter.h>
#include <vtkArrowSource.h> #include <vtkArrowSource.h>
#include "../CartographicTransformation.h" #include "../CartographicTransformation.h"
#include "../advection/readdata.h" #include "../advection/readdata.h"
#include "../advection/interpolate.h" #include "../advection/interpolate.h"
#include "vtkTransform.h"
using namespace std; using namespace std;
EGlyphLayer::EGlyphLayer(std::shared_ptr<UVGrid> uvGrid) { EGlyphLayer::EGlyphLayer(std::shared_ptr<UVGrid> uvGrid) {
@ -41,6 +44,7 @@ void EGlyphLayer::readCoordinates() {
this->direction->SetNumberOfTuples(numLats * numLons); this->direction->SetNumberOfTuples(numLats * numLons);
points->Allocate(numLats * numLons); points->Allocate(numLats * numLons);
int i = 0; int i = 0;
int latIndex = 0; int latIndex = 0;
for (double lat: uvGrid->lats) { for (double lat: uvGrid->lats) {
@ -49,6 +53,7 @@ void EGlyphLayer::readCoordinates() {
auto [u, v] = (*uvGrid)[0, latIndex, lonIndex]; auto [u, v] = (*uvGrid)[0, latIndex, lonIndex];
direction->SetTuple3(i, 5*u, 5*v, 0); direction->SetTuple3(i, 5*u, 5*v, 0);
points->InsertPoint(i++, lon, lat, 0); points->InsertPoint(i++, lon, lat, 0);
lonIndex++; lonIndex++;
} }
latIndex++; latIndex++;