kind of working but where did the euler layer go?
This commit is contained in:
parent
5a2e9a8a7a
commit
945eebf76f
|
|
@ -8,6 +8,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
find_package(VTK COMPONENTS
|
find_package(VTK COMPONENTS
|
||||||
|
GeovisCore
|
||||||
CommonColor
|
CommonColor
|
||||||
CommonColor
|
CommonColor
|
||||||
CommonCore
|
CommonCore
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,9 @@
|
||||||
#include <vtkMatrix4x4.h>
|
#include <vtkMatrix4x4.h>
|
||||||
#include <vtkTransform.h>
|
#include <vtkTransform.h>
|
||||||
#include <vtkTransformFilter.h>
|
#include <vtkTransformFilter.h>
|
||||||
|
#include <vtkGeoProjection.h>
|
||||||
|
#include <vtkGeoTransform.h>
|
||||||
|
#include <vtkGeneralTransform.h>
|
||||||
|
|
||||||
vtkSmartPointer<vtkCamera> createNormalisedCamera() {
|
vtkSmartPointer<vtkCamera> createNormalisedCamera() {
|
||||||
vtkSmartPointer<vtkCamera> camera = vtkSmartPointer<vtkCamera>::New();
|
vtkSmartPointer<vtkCamera> camera = vtkSmartPointer<vtkCamera>::New();
|
||||||
|
|
@ -15,32 +18,93 @@ vtkSmartPointer<vtkCamera> createNormalisedCamera() {
|
||||||
return camera;
|
return camera;
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkSmartPointer<vtkMatrix4x4> getCartographicTransformMatrix(const std::shared_ptr<UVGrid> uvGrid) {
|
//vtkSmartPointer<vtkMatrix4x4> getCartographicTransformMatrix(const std::shared_ptr<UVGrid> uvGrid) {
|
||||||
const double XMin = uvGrid->lons.front();
|
// const double XMin = uvGrid->lons.front();
|
||||||
const double XMax = uvGrid->lons.back();
|
// const double XMax = uvGrid->lons.back();
|
||||||
const double YMin = uvGrid->lats.front();
|
// const double YMin = uvGrid->lats.front();
|
||||||
const double YMax = uvGrid->lats.back();
|
// const double YMax = uvGrid->lats.back();
|
||||||
|
//
|
||||||
double eyeTransform[] = {
|
// double eyeTransform[] = {
|
||||||
2/(XMax-XMin), 0, 0, -(XMax+XMin)/(XMax-XMin),
|
// 2/(XMax-XMin), 0, 0, -(XMax+XMin)/(XMax-XMin),
|
||||||
0, 2/(YMax-YMin), 0, -(YMax+YMin)/(YMax-YMin),
|
// 0, 2/(YMax-YMin), 0, -(YMax+YMin)/(YMax-YMin),
|
||||||
0, 0, 1, 0,
|
// 0, 0, 1, 0,
|
||||||
0, 0, 0, 1
|
// 0, 0, 0, 1
|
||||||
};
|
// };
|
||||||
|
//
|
||||||
auto matrix = vtkSmartPointer<vtkMatrix4x4>::New();
|
// auto matrix = vtkSmartPointer<vtkMatrix4x4>::New();
|
||||||
matrix->DeepCopy(eyeTransform);
|
// matrix->DeepCopy(eyeTransform);
|
||||||
return matrix;
|
// 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) {
|
||||||
vtkNew<vtkTransform> transform;
|
auto proj = vtkSmartPointer<vtkGeoProjection>::New();
|
||||||
|
proj->SetName("merc");
|
||||||
|
|
||||||
transform->SetMatrix(getCartographicTransformMatrix(uvGrid));
|
auto geoTransform = vtkSmartPointer<vtkGeoTransform>::New();
|
||||||
|
geoTransform->SetDestinationProjection(proj);
|
||||||
|
|
||||||
|
const double XMin = -15.875;
|
||||||
|
const double XMax = 12.875;
|
||||||
|
const double YMin = 46.125;
|
||||||
|
const double YMax = 62.625;
|
||||||
|
|
||||||
|
double bottomLeft[3] = {XMin, YMin, 0};
|
||||||
|
double topRight[3] = {XMax, YMax, 0};
|
||||||
|
geoTransform->TransformPoint(bottomLeft, bottomLeft);
|
||||||
|
geoTransform->TransformPoint(topRight, topRight);
|
||||||
|
|
||||||
|
double width = topRight[0] - bottomLeft[0];
|
||||||
|
double height = topRight[1] - bottomLeft[1];
|
||||||
|
|
||||||
|
auto scaleIntoNormalisedSpace = vtkSmartPointer<vtkTransform>::New();
|
||||||
|
scaleIntoNormalisedSpace->Scale(2/(width), 2/(height), 1);
|
||||||
|
scaleIntoNormalisedSpace->Translate(-(bottomLeft[0]+topRight[0])/2, -(bottomLeft[1] + topRight[1])/2, 0);
|
||||||
|
|
||||||
|
auto totalProjection = vtkSmartPointer<vtkGeneralTransform>::New();
|
||||||
|
totalProjection->Identity();
|
||||||
|
totalProjection->Concatenate(scaleIntoNormalisedSpace);
|
||||||
|
totalProjection->Concatenate(geoTransform);
|
||||||
|
|
||||||
vtkSmartPointer<vtkTransformFilter> transformFilter = vtkSmartPointer<vtkTransformFilter>::New();
|
vtkSmartPointer<vtkTransformFilter> transformFilter = vtkSmartPointer<vtkTransformFilter>::New();
|
||||||
transformFilter->SetTransform(transform);
|
transformFilter->SetTransform(totalProjection);
|
||||||
|
|
||||||
|
return transformFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
vtkSmartPointer<vtkTransformFilter> createInverseCartographicTransformFilter(const std::shared_ptr<UVGrid> uvGrid) {
|
||||||
|
auto proj = vtkSmartPointer<vtkGeoProjection>::New();
|
||||||
|
proj->SetName("merc");
|
||||||
|
|
||||||
|
auto geoTransform = vtkSmartPointer<vtkGeoTransform>::New();
|
||||||
|
geoTransform->SetDestinationProjection(proj);
|
||||||
|
|
||||||
|
const double XMin = -15.875;
|
||||||
|
const double XMax = 12.875;
|
||||||
|
const double YMin = 46.125;
|
||||||
|
const double YMax = 62.625;
|
||||||
|
|
||||||
|
double bottomLeft[3] = {XMin, YMin, 0};
|
||||||
|
double topRight[3] = {XMax, YMax, 0};
|
||||||
|
geoTransform->TransformPoint(bottomLeft, bottomLeft);
|
||||||
|
geoTransform->TransformPoint(topRight, topRight);
|
||||||
|
geoTransform->Inverse();
|
||||||
|
|
||||||
|
double width = topRight[0] - bottomLeft[0];
|
||||||
|
double height = topRight[1] - bottomLeft[1];
|
||||||
|
|
||||||
|
auto scaleIntoNormalisedSpace = vtkSmartPointer<vtkTransform>::New();
|
||||||
|
scaleIntoNormalisedSpace->Scale(2/(width), 2/(height), 1);
|
||||||
|
scaleIntoNormalisedSpace->Translate(-(bottomLeft[0]+topRight[0])/2, -(bottomLeft[1] + topRight[1])/2, 0);
|
||||||
|
scaleIntoNormalisedSpace->Inverse();
|
||||||
|
|
||||||
|
auto totalProjection = vtkSmartPointer<vtkGeneralTransform>::New();
|
||||||
|
totalProjection->Identity();
|
||||||
|
totalProjection->Concatenate(geoTransform);
|
||||||
|
totalProjection->Concatenate(scaleIntoNormalisedSpace);
|
||||||
|
|
||||||
|
vtkSmartPointer<vtkTransformFilter> transformFilter = vtkSmartPointer<vtkTransformFilter>::New();
|
||||||
|
transformFilter->SetTransform(totalProjection);
|
||||||
|
|
||||||
return transformFilter;
|
return transformFilter;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,4 +28,6 @@ vtkSmartPointer<vtkMatrix4x4> getCartographicTransformMatrix(const std::shared_p
|
||||||
* @return pointer to transform filter
|
* @return pointer to transform filter
|
||||||
*/
|
*/
|
||||||
vtkSmartPointer<vtkTransformFilter> createCartographicTransformFilter(const std::shared_ptr<UVGrid> uvGrid);
|
vtkSmartPointer<vtkTransformFilter> createCartographicTransformFilter(const std::shared_ptr<UVGrid> uvGrid);
|
||||||
|
|
||||||
|
vtkSmartPointer<vtkTransformFilter> createInverseCartographicTransformFilter(const std::shared_ptr<UVGrid> uvGrid);
|
||||||
#endif //NORMALISEDCARTOGRAPHICCAMERA_H
|
#endif //NORMALISEDCARTOGRAPHICCAMERA_H
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,8 @@ void SpawnPointCallback::Execute(vtkObject *caller, unsigned long evId, void *ca
|
||||||
ren->SetDisplayPoint(displayPos);
|
ren->SetDisplayPoint(displayPos);
|
||||||
ren->DisplayToWorld();
|
ren->DisplayToWorld();
|
||||||
ren->GetWorldPoint(worldPos);
|
ren->GetWorldPoint(worldPos);
|
||||||
inverseCartographicProjection->MultiplyPoint(worldPos, worldPos);
|
cout << "clicked on " << worldPos[1] << ", " << worldPos[0] << endl;
|
||||||
// cout << "clicked on lon = " << worldPos[0] << " and lat = " << worldPos[1] << endl;
|
inverseCartographicProjection->TransformPoint(worldPos, worldPos);
|
||||||
|
|
||||||
vtkIdType id = points->InsertNextPoint(worldPos[0], worldPos[1], 0);
|
vtkIdType id = points->InsertNextPoint(worldPos[0], worldPos[1], 0);
|
||||||
data->SetPoints(points);
|
data->SetPoints(points);
|
||||||
|
|
@ -77,6 +77,5 @@ void SpawnPointCallback::setRen(const vtkSmartPointer<vtkRenderer> &ren) {
|
||||||
|
|
||||||
void SpawnPointCallback::setUVGrid(const std::shared_ptr<UVGrid> &uvGrid) {
|
void SpawnPointCallback::setUVGrid(const std::shared_ptr<UVGrid> &uvGrid) {
|
||||||
this->uvGrid = uvGrid;
|
this->uvGrid = uvGrid;
|
||||||
inverseCartographicProjection = getCartographicTransformMatrix(uvGrid);
|
inverseCartographicProjection = createInverseCartographicTransformFilter(uvGrid)->GetTransform();
|
||||||
inverseCartographicProjection->Invert();
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
#ifndef SPAWNPOINTCALLBACK_H
|
#ifndef SPAWNPOINTCALLBACK_H
|
||||||
#define SPAWNPOINTCALLBACK_H
|
#define SPAWNPOINTCALLBACK_H
|
||||||
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vtkCallbackCommand.h>
|
#include <vtkCallbackCommand.h>
|
||||||
#include <vtkRenderWindowInteractor.h>
|
#include <vtkRenderWindowInteractor.h>
|
||||||
#include <vtkPoints.h>
|
#include <vtkPoints.h>
|
||||||
#include <vtkPolyData.h>
|
#include <vtkPolyData.h>
|
||||||
#include <vtkMatrix4x4.h>
|
#include <vtkAbstractTransform.h>
|
||||||
|
|
||||||
#include "../advection/UVGrid.h"
|
#include "../advection/UVGrid.h"
|
||||||
|
|
||||||
class SpawnPointCallback : public vtkCallbackCommand {
|
class SpawnPointCallback : public vtkCallbackCommand {
|
||||||
|
|
@ -30,7 +30,7 @@ private:
|
||||||
vtkSmartPointer<vtkPoints> points;
|
vtkSmartPointer<vtkPoints> points;
|
||||||
vtkSmartPointer<vtkRenderer> ren;
|
vtkSmartPointer<vtkRenderer> ren;
|
||||||
std::shared_ptr<UVGrid> uvGrid;
|
std::shared_ptr<UVGrid> uvGrid;
|
||||||
vtkSmartPointer<vtkMatrix4x4> inverseCartographicProjection;
|
vtkSmartPointer<vtkAbstractTransform> inverseCartographicProjection;
|
||||||
|
|
||||||
void Execute(vtkObject *caller, unsigned long evId, void *callData) override;
|
void Execute(vtkObject *caller, unsigned long evId, void *callData) override;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,17 +68,11 @@ LGlyphLayer::LGlyphLayer(std::shared_ptr<UVGrid> uvGrid, std::unique_ptr<Advecti
|
||||||
|
|
||||||
// creates a few points so we can test the updateData function
|
// creates a few points so we can test the updateData function
|
||||||
void LGlyphLayer::spoofPoints() {
|
void LGlyphLayer::spoofPoints() {
|
||||||
this->points->InsertNextPoint(-4.125, 61.375 , 0);
|
this->points->InsertNextPoint(6.532949683882039, 53.24308582564463, 0); // Coordinates of Zernike
|
||||||
// this->points->InsertNextPoint(6.532949683882039, 53.24308582564463, 0); // Coordinates of Zernike
|
this->points->InsertNextPoint(5.315307819255385, 60.40001057122271, 0); // Coordinates of Bergen
|
||||||
// this->points->InsertNextPoint(5.315307819255385, 60.40001057122271, 0); // Coordinates of Bergen
|
this->points->InsertNextPoint(6.646210231365825, 46.52346296009023, 0); // Coordinates of Lausanne
|
||||||
// this->points->InsertNextPoint( 6.646210231365825, 46.52346296009023, 0); // Coordinates of Lausanne
|
this->points->InsertNextPoint(-6.553894313570932, 62.39522131195857,
|
||||||
// this->points->InsertNextPoint(-6.553894313570932, 62.39522131195857, 0); // Coordinates of the top of the Faroe islands
|
0); // Coordinates of the top of the Faroe islands
|
||||||
|
|
||||||
for (int i=0; i < 330; i+=5) {
|
|
||||||
for (int j=0; j < 330; j+=5) {
|
|
||||||
this->points->InsertNextPoint(-15.875+(12.875+15.875)/330*j, 46.125+(62.625-46.125)/330*i, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this->points->Modified();
|
this->points->Modified();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,12 @@
|
||||||
#include "advection/kernel/RK4AdvectionKernel.h"
|
#include "advection/kernel/RK4AdvectionKernel.h"
|
||||||
#include "advection/kernel/SnapBoundaryConditionKernel.h"
|
#include "advection/kernel/SnapBoundaryConditionKernel.h"
|
||||||
|
|
||||||
|
#include <vtkTransform.h>
|
||||||
|
#include <vtkTransformFilter.h>
|
||||||
|
#include <vtkGeoProjection.h>
|
||||||
|
#include <vtkGeoTransform.h>
|
||||||
|
#include <vtkGeneralTransform.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#define DT 60 * 60 // 60 sec/min * 60 mins
|
#define DT 60 * 60 // 60 sec/min * 60 mins
|
||||||
|
|
@ -29,6 +35,7 @@ int main() {
|
||||||
cout << "Starting vtk..." << endl;
|
cout << "Starting vtk..." << endl;
|
||||||
|
|
||||||
auto l = new LGlyphLayer(uvGrid, std::move(kernelRK4BoundaryChecked));
|
auto l = new LGlyphLayer(uvGrid, std::move(kernelRK4BoundaryChecked));
|
||||||
|
l->spoofPoints();
|
||||||
|
|
||||||
unique_ptr<Program> program = make_unique<Program>(DT);
|
unique_ptr<Program> program = make_unique<Program>(DT);
|
||||||
program->addLayer(new BackgroundImage("../../../../data/map_661-661.png"));
|
program->addLayer(new BackgroundImage("../../../../data/map_661-661.png"));
|
||||||
|
|
@ -37,6 +44,47 @@ int main() {
|
||||||
|
|
||||||
program->render();
|
program->render();
|
||||||
|
|
||||||
|
// auto proj = vtkSmartPointer<vtkGeoProjection>::New(); proj->SetName("merc"); auto geoTransform = vtkSmartPointer<vtkGeoTransform>::New(); geoTransform->SetDestinationProjection(proj);
|
||||||
|
// const double XMin = -15.875;
|
||||||
|
// const double XMax = 12.875;
|
||||||
|
// const double YMin = 46.125;
|
||||||
|
// const double YMax = 62.625;
|
||||||
|
//
|
||||||
|
// double bottomLeft[3] = {XMin, YMin, 0};
|
||||||
|
// double topRight[3] = {XMax, YMax, 0};
|
||||||
|
// geoTransform->TransformPoint(bottomLeft, bottomLeft);
|
||||||
|
// geoTransform->TransformPoint(topRight, topRight);
|
||||||
|
//
|
||||||
|
// double width = topRight[0] - bottomLeft[0];
|
||||||
|
// double height = topRight[1] - bottomLeft[1];
|
||||||
|
//
|
||||||
|
// auto scaleIntoNormalisedSpace = vtkSmartPointer<vtkTransform>::New();
|
||||||
|
// scaleIntoNormalisedSpace->Scale(2/(width), 2/(height), 1);
|
||||||
|
// scaleIntoNormalisedSpace->Translate(-(bottomLeft[0]+topRight[0])/2, -(bottomLeft[1] + topRight[1])/2, 0);
|
||||||
|
//
|
||||||
|
// auto totalProjection = vtkSmartPointer<vtkGeneralTransform>::New();
|
||||||
|
// totalProjection->PostMultiply();
|
||||||
|
// totalProjection->Identity();
|
||||||
|
// totalProjection->Concatenate(geoTransform);
|
||||||
|
// totalProjection->Concatenate(scaleIntoNormalisedSpace);
|
||||||
|
//
|
||||||
|
// double in[3] = {4.846871030623073, 52.364810061968335, 0};
|
||||||
|
// geoTransform->TransformPoint(in, in);
|
||||||
|
// cout << "in[3] = {" << in[0] << "," << in[1] << "," << in[2] << "}" << endl;
|
||||||
|
// scaleIntoNormalisedSpace->TransformPoint(in, in);
|
||||||
|
// cout << "in[3] = {" << in[0] << "," << in[1] << "," << in[2] << "}" << endl;
|
||||||
|
// scaleIntoNormalisedSpace->Inverse();
|
||||||
|
// scaleIntoNormalisedSpace->TransformPoint(in, in);
|
||||||
|
// cout << "in[3] = {" << in[0] << "," << in[1] << "," << in[2] << "}" << endl;
|
||||||
|
// geoTransform->Inverse();
|
||||||
|
// geoTransform->TransformPoint(in, in);
|
||||||
|
// cout << "in[3] = {" << in[0] << "," << in[1] << "," << in[2] << "}" << endl;
|
||||||
|
//// totalProjection->TransformPoint(in, in);
|
||||||
|
//// cout << "in[3] = {" << in[0] << "," << in[1] << "," << in[2] << "}" << endl;
|
||||||
|
//// totalProjection->Inverse();
|
||||||
|
//// totalProjection->TransformPoint(in, in);
|
||||||
|
//// cout << "in[3] = {" << in[0] << "," << in[1] << "," << in[2] << "}" << endl;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue