added cellparticledensity to lcol

This commit is contained in:
Djairo Hougee 2024-05-27 11:04:34 +02:00
parent 0fa9486363
commit 30892988fd
2 changed files with 16 additions and 20 deletions

View File

@ -1,6 +1,7 @@
#include "LColLayer.h" #include "LColLayer.h"
#include "../commands/SpawnPointCallback.h" #include "../commands/SpawnPointCallback.h"
#include <vtkActor2D.h> #include <vtkActor2D.h>
#include <vtkCellData.h>
#include <vtkGlyph2D.h> #include <vtkGlyph2D.h>
#include <vtkLookupTable.h> #include <vtkLookupTable.h>
#include <vtkGlyphSource2D.h> #include <vtkGlyphSource2D.h>
@ -66,15 +67,25 @@ LColLayer::LColLayer(std::shared_ptr<UVGrid> uvGrid, std::unique_ptr<AdvectionKe
this->particlesBeached = vtkSmartPointer<vtkIntArray>::New(); this->particlesBeached = vtkSmartPointer<vtkIntArray>::New();
this->particlesBeached->SetName("particlesBeached"); this->particlesBeached->SetName("particlesBeached");
this->particlesBeached->SetNumberOfComponents(0); this->particlesBeached->SetNumberOfComponents(1);
this->particlesAge = vtkSmartPointer<vtkIntArray>::New(); this->particlesAge = vtkSmartPointer<vtkIntArray>::New();
this->particlesAge->SetName("particlesAge"); this->particlesAge->SetName("particlesAge");
this->particlesAge->SetNumberOfComponents(0); this->particlesAge->SetNumberOfComponents(1);
this->uvGrid = uvGrid;
this->numLats = uvGrid->lats.size();
this->numLons = uvGrid->lons.size();
this->cellParticleDensity = vtkSmartPointer<vtkIntArray>::New();
this->cellParticleDensity->SetName("cellParticleDensity");
this->cellParticleDensity->SetNumberOfComponents(1);
this->cellParticleDensity->SetNumberOfTuples((numLats-1)*(numLons-1));
data->GetPointData()->AddArray(this->particlesBeached); data->GetPointData()->AddArray(this->particlesBeached);
data->GetPointData()->AddArray(this->particlesAge); data->GetPointData()->AddArray(this->particlesAge);
data->GetCellData()->AddArray(this->cellParticleDensity);
data->GetPointData()->SetActiveScalars("particlesAge"); data->GetPointData()->SetActiveScalars("particlesAge");
data->GetCellData()->SetActiveScalars("cellParticleDensity");
advector = std::move(advectionKernel); advector = std::move(advectionKernel);
this->uvGrid = uvGrid; this->uvGrid = uvGrid;
@ -82,24 +93,6 @@ LColLayer::LColLayer(std::shared_ptr<UVGrid> uvGrid, std::unique_ptr<AdvectionKe
vtkSmartPointer<vtkTransformFilter> transformFilter = createCartographicTransformFilter(uvGrid); vtkSmartPointer<vtkTransformFilter> transformFilter = createCartographicTransformFilter(uvGrid);
transformFilter->SetInputData(data); transformFilter->SetInputData(data);
vtkNew<vtkGlyphSource2D> circleSource;
circleSource->SetGlyphTypeToCircle();
circleSource->SetScale(0.02);
circleSource->Update();
vtkNew<vtkGlyph2D> glyph2D;
glyph2D->SetSourceConnection(circleSource->GetOutputPort());
glyph2D->SetInputConnection(transformFilter->GetOutputPort());
glyph2D->SetScaleModeToDataScalingOff();
glyph2D->Update();
vtkNew<vtkPolyDataMapper> mapper;
mapper->SetInputConnection(glyph2D->GetOutputPort());
mapper->SetColorModeToMapScalars();
mapper->SetLookupTable(buildLut(512));
mapper->UseLookupTableScalarRangeOn();
mapper->Update();
vtkNew<vtkActor> actor; vtkNew<vtkActor> actor;
actor->SetMapper(mapper); actor->SetMapper(mapper);

View File

@ -16,11 +16,14 @@ private:
vtkSmartPointer<vtkPolyData> data; vtkSmartPointer<vtkPolyData> data;
vtkSmartPointer<vtkIntArray> particlesBeached; vtkSmartPointer<vtkIntArray> particlesBeached;
vtkSmartPointer<vtkIntArray> particlesAge; vtkSmartPointer<vtkIntArray> particlesAge;
vtkSmartPointer<vtkIntArray> cellParticleDensity;
vtkSmartPointer<SpawnPointCallback> callback; vtkSmartPointer<SpawnPointCallback> callback;
std::unique_ptr<AdvectionKernel> advector; std::unique_ptr<AdvectionKernel> advector;
std::shared_ptr<UVGrid> uvGrid; std::shared_ptr<UVGrid> uvGrid;
int dt = 3600; int dt = 3600;
int beachedAtNumberOfTimes = 20; int beachedAtNumberOfTimes = 20;
int numLats;
int numLons;
public: public:
/** Constructor. /** Constructor.