Skip to content
Snippets Groups Projects
Commit df6c71a9 authored by Joachim Pouderoux's avatar Joachim Pouderoux
Browse files

Fix and enhance bag plots.

Fix the way how the bags are computed. They are now performed at
50 and 99% of the distribution.
Functional bag plots also create a median serie which is the
median line of all input series. Outliers series are also
tagged with an "_outlier" extension in their name.

Change-Id: I990428c9b79278be9be725491232b3e9d69190b0
parent ce692f85
No related branches found
No related tags found
No related merge requests found
......@@ -25,26 +25,26 @@
#include "vtkTable.h"
const double densities[] = {
-0.42, -0.349997, -0.289995, -0.229993, -0.16999, -0.119988, -0.079985, -0.0499825, -0.01998, -0.0099775, 2.5e-005, -0.0099725, -0.01997, -0.0499675, -0.079965, -0.119963, -0.16996, -0.229958, -0.289955, -0.349953,
-0.34995, -0.279948, -0.209945, -0.149943, -0.08994, -0.0299375, 0.010065, 0.0500675, 0.07007, 0.0900725, 0.090075, 0.0900775, 0.07008, 0.0500825, 0.010085, -0.0299125, -0.08991, -0.149908, -0.209905, -0.279903,
-0.2899, -0.209897, -0.139895, -0.0698925, 0.00011, 0.0501125, 0.100115, 0.140118, 0.17012, 0.190123, 0.190125, 0.190128, 0.17013, 0.140133, 0.100135, 0.0501375, 0.00014, -0.0698575, -0.139855, -0.209853,
-0.22985, -0.149847, -0.069845, 0.0101575, 0.07016, 0.130163, 0.190165, 0.230168, 0.27017, 0.290173, 0.300175, 0.290177, 0.27018, 0.230183, 0.190185, 0.130188, 0.07019, 0.0101925, -0.069805, -0.149803,
-0.1698, -0.0897975, 0.000205, 0.0702075, 0.15021, 0.210213, 0.270215, 0.320217, 0.36022, 0.390223, 0.400225, 0.390228, 0.36023, 0.320233, 0.270235, 0.210237, 0.15024, 0.0702425, 0.000245, -0.0897525,
-0.11975, -0.0297475, 0.050255, 0.130258, 0.21026, 0.290262, 0.350265, 0.410267, 0.46027, 0.490273, 0.500275, 0.490277, 0.46028, 0.410282, 0.350285, 0.290287, 0.21029, 0.130293, 0.050295, -0.0297025,
-0.0797, 0.0103025, 0.100305, 0.190307, 0.27031, 0.350312, 0.430315, 0.500317, 0.55032, 0.580322, 0.600325, 0.580328, 0.55033, 0.500332, 0.430335, 0.350337, 0.27034, 0.190343, 0.100345, 0.0103475,
-0.04965, 0.0503525, 0.140355, 0.230358, 0.32036, 0.410362, 0.500365, 0.570367, 0.63037, 0.680373, 0.700375, 0.680378, 0.63038, 0.570382, 0.500385, 0.410387, 0.32039, 0.230393, 0.140395, 0.0503975,
-0.0196, 0.0704025, 0.170405, 0.270408, 0.36041, 0.460413, 0.550415, 0.630417, 0.71042, 0.770423, 0.800425, 0.770428, 0.71043, 0.630432, 0.550435, 0.460438, 0.36044, 0.270443, 0.170445, 0.0704475,
-0.00955, 0.0904525, 0.190455, 0.290457, 0.39046, 0.490462, 0.580465, 0.680468, 0.77047, 0.850472, 0.900475, 0.850478, 0.77048, 0.680483, 0.580485, 0.490487, 0.39049, 0.290492, 0.190495, 0.0904975,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2.5e-005, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0.010065, 0.0500675, 0.07007, 0.0900725, 0.090075, 0.0900775, 0.07008, 0.0500825, 0.010085, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0.00011, 0.0501125, 0.100115, 0.140118, 0.17012, 0.190123, 0.190125, 0.190128, 0.17013, 0.140133, 0.100135, 0.0501375, 0.00014, 0, 0, 0,
0, 0, 0, 0.0101575, 0.07016, 0.130163, 0.190165, 0.230168, 0.27017, 0.290173, 0.300175, 0.290177, 0.27018, 0.230183, 0.190185, 0.130188, 0.07019, 0.0101925, 0, 0,
0, 0, 0.000205, 0.0702075, 0.15021, 0.210213, 0.270215, 0.320217, 0.36022, 0.390223, 0.400225, 0.390228, 0.36023, 0.320233, 0.270235, 0.210237, 0.15024, 0.0702425, 0.000245, 0,
0, 0, 0.050255, 0.130258, 0.21026, 0.290262, 0.350265, 0.410267, 0.46027, 0.490273, 0.500275, 0.490277, 0.46028, 0.410282, 0.350285, 0.290287, 0.21029, 0.130293, 0.050295, 0,
0, 0.0103025, 0.100305, 0.190307, 0.27031, 0.350312, 0.430315, 0.500317, 0.55032, 0.580322, 0.600325, 0.580328, 0.55033, 0.500332, 0.430335, 0.350337, 0.27034, 0.190343, 0.100345, 0.0103475,
0, 0.0503525, 0.140355, 0.230358, 0.32036, 0.410362, 0.500365, 0.570367, 0.63037, 0.680373, 0.700375, 0.680378, 0.63038, 0.570382, 0.500385, 0.410387, 0.32039, 0.230393, 0.140395, 0.0503975,
0, 0.0704025, 0.170405, 0.270408, 0.36041, 0.460413, 0.550415, 0.630417, 0.71042, 0.770423, 0.800425, 0.770428, 0.71043, 0.630432, 0.550435, 0.460438, 0.36044, 0.270443, 0.170445, 0.0704475,
0, 0.0904525, 0.190455, 0.290457, 0.39046, 0.490462, 0.580465, 0.680468, 0.77047, 0.850472, 0.900475, 0.850478, 0.77048, 0.680483, 0.580485, 0.490487, 0.39049, 0.290492, 0.190495, 0.0904975,
0.0005, 0.0905025, 0.190505, 0.300507, 0.40051, 0.500513, 0.600515, 0.700517, 0.80052, 0.900523, 1.00053, 0.900528, 0.80053, 0.700533, 0.600535, 0.500537, 0.40054, 0.300542, 0.190545, 0.0905475,
-0.00945, 0.0905525, 0.190555, 0.290557, 0.39056, 0.490563, 0.580565, 0.680568, 0.77057, 0.850572, 0.900575, 0.850577, 0.77058, 0.680583, 0.580585, 0.490588, 0.39059, 0.290592, 0.190595, 0.0905975,
-0.0194, 0.0706025, 0.170605, 0.270608, 0.36061, 0.460613, 0.550615, 0.630618, 0.71062, 0.770622, 0.800625, 0.770628, 0.71063, 0.630633, 0.550635, 0.460638, 0.36064, 0.270643, 0.170645, 0.0706475,
-0.04935, 0.0506525, 0.140655, 0.230658, 0.32066, 0.410662, 0.500665, 0.570667, 0.63067, 0.680673, 0.700675, 0.680678, 0.63068, 0.570682, 0.500685, 0.410687, 0.32069, 0.230693, 0.140695, 0.0506975,
-0.0793, 0.0107025, 0.100705, 0.190708, 0.27071, 0.350712, 0.430715, 0.500718, 0.55072, 0.580722, 0.600725, 0.580727, 0.55073, 0.500733, 0.430735, 0.350737, 0.27074, 0.190743, 0.100745, 0.0107475,
-0.11925, -0.0292475, 0.050755, 0.130758, 0.21076, 0.290762, 0.350765, 0.410767, 0.46077, 0.490773, 0.500775, 0.490777, 0.46078, 0.410782, 0.350785, 0.290787, 0.21079, 0.130793, 0.050795, -0.0292025,
-0.1692, -0.0891975, 0.000805, 0.0708075, 0.15081, 0.210812, 0.270815, 0.320818, 0.36082, 0.390823, 0.400825, 0.390827, 0.36083, 0.320833, 0.270835, 0.210837, 0.15084, 0.0708425, 0.000845, -0.0891525,
-0.22915, -0.149147, -0.069145, 0.0108575, 0.07086, 0.130862, 0.190865, 0.230868, 0.27087, 0.290872, 0.300875, 0.290877, 0.27088, 0.230883, 0.190885, 0.130888, 0.07089, 0.0108925, -0.069105, -0.149103,
-0.2891, -0.209097, -0.139095, -0.0690925, 0.00091, 0.0509125, 0.100915, 0.140918, 0.17092, 0.190922, 0.190925, 0.190928, 0.17093, 0.140933, 0.100935, 0.0509375, 0.00094, -0.0690575, -0.139055, -0.209053,
-0.34905, -0.279048, -0.209045, -0.149042, -0.08904, -0.0290375, 0.010965, 0.0509675, 0.07097, 0.0909725, 0.090975, 0.0909775, 0.07098, 0.0509825, 0.010985, -0.0290125, -0.08901, -0.149007, -0.209005, -0.279003,
0, 0.0905525, 0.190555, 0.290557, 0.39056, 0.490563, 0.580565, 0.680568, 0.77057, 0.850572, 0.900575, 0.850577, 0.77058, 0.680583, 0.580585, 0.490588, 0.39059, 0.290592, 0.190595, 0.0905975,
0, 0.0706025, 0.170605, 0.270608, 0.36061, 0.460613, 0.550615, 0.630618, 0.71062, 0.770622, 0.800625, 0.770628, 0.71063, 0.630633, 0.550635, 0.460638, 0.36064, 0.270643, 0.170645, 0.0706475,
0, 0.0506525, 0.140655, 0.230658, 0.32066, 0.410662, 0.500665, 0.570667, 0.63067, 0.680673, 0.700675, 0.680678, 0.63068, 0.570682, 0.500685, 0.410687, 0.32069, 0.230693, 0.140695, 0.0506975,
0, 0.0107025, 0.100705, 0.190708, 0.27071, 0.350712, 0.430715, 0.500718, 0.55072, 0.580722, 0.600725, 0.580727, 0.55073, 0.500733, 0.430735, 0.350737, 0.27074, 0.190743, 0.100745, 0.0107475,
0, 0, 0.050755, 0.130758, 0.21076, 0.290762, 0.350765, 0.410767, 0.46077, 0.490773, 0.500775, 0.490777, 0.46078, 0.410782, 0.350785, 0.290787, 0.21079, 0.130793, 0.050795, 0,
0, 0, 0.000805, 0.0708075, 0.15081, 0.210812, 0.270815, 0.320818, 0.36082, 0.390823, 0.400825, 0.390827, 0.36083, 0.320833, 0.270835, 0.210837, 0.15084, 0.0708425, 0.000845, 0,
0, 0, 0, 0.0108575, 0.07086, 0.130862, 0.190865, 0.230868, 0.27087, 0.290872, 0.300875, 0.290877, 0.27088, 0.230883, 0.190885, 0.130888, 0.07089, 0.0108925, 0, 0,
0, 0, 0, 0, 0.00091, 0.0509125, 0.100915, 0.140918, 0.17092, 0.190922, 0.190925, 0.190928, 0.17093, 0.140933, 0.100935, 0.0509375, 0.00094, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0.010965, 0.0509675, 0.07097, 0.0909725, 0.090975, 0.0909775, 0.07098, 0.0509825, 0.010985, 0, 0, 0, 0, 0,
};
//----------------------------------------------------------------------------
int TestBagPlot(int, char * [])
......@@ -85,11 +85,6 @@ int TestBagPlot(int, char * [])
{
table->SetValue(i + j * numDataI, 0, i); //X
table->SetValue(i + j * numDataI, 1, j); //Y
//double dx = (numDataI / 2. - i) / (numDataI / 2.);
//double dy = (numDataJ / 2. - j) / (numDataJ / 2.);
//double d = 1. - sqrt(dx * dx + dy * dy);
//d = floor(d * 100.) / 100.; // to avoid conflicts
//d += (i + j * numDataI) / (double)(1000. * numDataI * numDataJ);
double d = densities[i + j * numDataI];
table->SetValue(i + j * numDataI, 2, d); // Density
}
......
c1d6e4f60c9b8ccc9e8ae6b9cf7fb040
4e320f7efda9ccf279c8d668de7ebd95
......@@ -27,8 +27,10 @@
#include "vtkStringArray.h"
#include "vtkTable.h"
#include "vtkTimeStamp.h"
#include "vtkMath.h"
#include <algorithm>
#include <sstream>
//-----------------------------------------------------------------------------
vtkStandardNewMacro(vtkPlotBag);
......@@ -40,7 +42,7 @@ vtkPlotBag::vtkPlotBag()
{
this->MedianPoints = vtkPoints2D::New();
this->Q3Points = vtkPoints2D::New();
this->TooltipDefaultLabelFormat = "%l (%x, %y): %z";
this->TooltipDefaultLabelFormat = "%C, %l (%x, %y): %z";
this->Brush->SetColor(255, 0, 0);
this->Brush->SetOpacity(255);
this->Pen->SetColor(0, 0, 0);
......@@ -101,15 +103,16 @@ void vtkPlotBag::Update()
}
//-----------------------------------------------------------------------------
class ArraySorter
class DensityVal
{
public:
ArraySorter(vtkDataArray* arr) : Array(arr) {}
bool operator()(const vtkIdType& a, const vtkIdType& b)
DensityVal(double d, vtkIdType cid) : Density(d), Id(cid) {}
bool operator<(const DensityVal& b) const
{
return this->Array->GetTuple1(a) > this->Array->GetTuple1(b);
return this->Density > b.Density;
}
vtkDataArray* Array;
double Density;
vtkIdType Id;
};
//-----------------------------------------------------------------------------
......@@ -122,34 +125,43 @@ void vtkPlotBag::UpdateTableCache(vtkDataArray* density)
{
return;
}
vtkIdType nbPoints = density->GetNumberOfTuples();
vtkDataArray* d = density;
vtkPoints2D* points = this->Points;
// Sort the density array
std::vector<vtkIdType> ids;
ids.resize(nbPoints);
for (vtkIdType i = 0; i < nbPoints; i++)
vtkIdType nbPoints = d->GetNumberOfTuples();
// Fetch and sort arrays according their density
std::vector<DensityVal> ids;
ids.reserve(nbPoints);
for (int i = 0; i < nbPoints; i++)
{
ids[i] = i;
ids.push_back(DensityVal(d->GetTuple1(i), i));
}
// Sort array by density
ArraySorter arraySorter(density);
std::sort(ids.begin(), ids.end(), arraySorter);
std::sort(ids.begin(), ids.end());
vtkNew<vtkPointsProjectedHull> q3Points;
q3Points->Allocate(nbPoints);
vtkNew<vtkPointsProjectedHull> medianPoints;
medianPoints->Allocate(nbPoints);
// Compute total density sum
double densitySum = 0.0;
for (vtkIdType i = 0; i < nbPoints; i++)
{
densitySum += d->GetTuple1(i);
}
double sum = 0.0;
for (vtkIdType i = 0; i < nbPoints; i++)
{
double x[3];
this->Points->GetPoint(ids[i], x);
if (i < static_cast<vtkIdType>(nbPoints * 0.5))
points->GetPoint(ids[i].Id, x);
sum += ids[i].Density;
if (sum < 0.5 * densitySum)
{
medianPoints->InsertNextPoint(x);
}
if (i < static_cast<vtkIdType>(nbPoints * 0.75))
if (sum < 0.99 * densitySum)
{
q3Points->InsertNextPoint(x);
}
......@@ -347,6 +359,23 @@ vtkStdString vtkPlotBag::GetTooltipLabel(const vtkVector2d &plotPos,
// GetLabel() is GetLabel(0) in this implementation
tooltipLabel += this->GetLabel();
break;
case 'c':
{
std::stringstream ss;
ss << seriesIndex;
tooltipLabel += ss.str();
}
break;
case 'C':
{
vtkAbstractArray *colName = vtkAbstractArray::SafeDownCast(
this->GetInput()->GetColumnByName("ColName"));
std::stringstream ss;
ss << (!colName ? "?" :
colName->GetVariantValue(seriesIndex).ToString());
tooltipLabel += ss.str();
}
break;
default: // If no match, insert the entire format tag
tooltipLabel += "%";
tooltipLabel += format[i];
......@@ -380,7 +409,6 @@ void vtkPlotBag::SetInputData(vtkTable *table)
void vtkPlotBag::SetInputData(vtkTable *table, const vtkStdString &yColumn,
const vtkStdString &densityColumn)
{
vtkDebugMacro(<< "Setting input, Y column = \"" << yColumn.c_str() << "\", "
<< "Density column = \"" << densityColumn.c_str() << "\"");
......
......@@ -21,6 +21,7 @@
#include "vtkContext2D.h"
#include "vtkContextMapper2D.h"
#include "vtkDoubleArray.h"
#include "vtkIdTypeArray.h"
#include "vtkLookupTable.h"
#include "vtkObjectFactory.h"
#include "vtkPen.h"
......
......@@ -37,15 +37,15 @@ const double densities[] = {
0.289692,
0.36827,
0.398942,
0.36827,
0.289692,
0.194186,
0.110921,
0.053991,
0.0223945,
0.00791545,
0.00238409,
0.000611902
0.368271,
0.2896921,
0.1941861,
0.1109211,
0.0539911,
0.02239451,
0.007915451,
0.002384091,
0.0006119021
};
//----------------------------------------------------------------------------
......@@ -77,9 +77,6 @@ int TestExtractFunctionalBagPlot(int , char * [])
}
}
cout << "\n## Input data table:\n";
table->Dump();
// Create a density table
vtkNew<vtkDoubleArray> density;
......@@ -91,11 +88,8 @@ int TestExtractFunctionalBagPlot(int , char * [])
varName->SetNumberOfValues(numCols);
for (int j = 0; j < numCols; j++)
{
//double x = j * 8. / static_cast<double>(numCols) - 4.;
//double d = (1. / sqrt(vtkMath::Pi() * 2.)) * exp(-(x*x) / 2.);
double d = densities[j];
density->SetValue(j, d);
varName->SetValue(j, table->GetColumn(j)->GetName());
}
......@@ -103,15 +97,10 @@ int TestExtractFunctionalBagPlot(int , char * [])
inTableDensity->AddColumn(density.GetPointer());
inTableDensity->AddColumn(varName.GetPointer());
cout << "\n## Input density table:\n";
inTableDensity->Dump();
vtkNew<vtkExtractFunctionalBagPlot> ebp;
// First verify that absence of input does not cause trouble
cout << "## Verifying that absence of input does not cause trouble... ";
ebp->Update();
cout << "done.\n";
ebp->SetInputData(0, table.GetPointer());
ebp->SetInputData(1, inTableDensity.GetPointer());
......@@ -121,9 +110,7 @@ int TestExtractFunctionalBagPlot(int , char * [])
vtkDataObject::FIELD_ASSOCIATION_ROWS, "ColName");
ebp->Update();
cout << "\n## Results:" << endl;
vtkTable* outBPTable = ebp->GetOutput();
outBPTable->Dump();
vtkDoubleArray* q3Points =
vtkDoubleArray::SafeDownCast(outBPTable->GetColumnByName("Q3Points"));
......@@ -132,6 +119,7 @@ int TestExtractFunctionalBagPlot(int , char * [])
if (!q3Points || !q2Points)
{
outBPTable->Dump();
cout << "## Failure: Missing Q3Points or QMedPoints columns!" << endl;
return EXIT_FAILURE;
}
......@@ -139,6 +127,7 @@ int TestExtractFunctionalBagPlot(int , char * [])
if (q3Points->GetNumberOfTuples() != numPoints ||
q2Points->GetNumberOfTuples() != numPoints)
{
outBPTable->Dump();
cout << "## Failure: Bad number of tuples in Q3Points or QMedPoints columns!" << endl;
return EXIT_FAILURE;
}
......@@ -146,6 +135,7 @@ int TestExtractFunctionalBagPlot(int , char * [])
if (q3Points->GetNumberOfComponents() != 2 ||
q2Points->GetNumberOfComponents() != 2)
{
outBPTable->Dump();
cout << "## Failure: Q3Points or QMedPoints does not have 2 components!" << endl;
return EXIT_FAILURE;
}
......@@ -156,11 +146,11 @@ int TestExtractFunctionalBagPlot(int , char * [])
double q2v[2];
q2Points->GetTuple(19, q2v);
if (q3v[0] != 38 || q3v[1] != 323 || q2v[0] != 95 || q2v[1] != 285)
if (q3v[0] != 95 || q3v[1] != 304 || q2v[0] != 171 || q2v[1] != 209)
{
outBPTable->Dump();
cout << "## Failure: bad values found in Q3Points or QMedPoints" << endl;
return EXIT_FAILURE;
}
cout << "## Success!" << endl;
return EXIT_SUCCESS;
}
......@@ -25,6 +25,7 @@
#include "vtkTable.h"
#include <algorithm>
#include <set>
#include <vector>
vtkStandardNewMacro(vtkExtractFunctionalBagPlot);
......@@ -100,48 +101,68 @@ int vtkExtractFunctionalBagPlot::RequestData(vtkInformation* /*request*/,
}
vtkIdType nbPoints = varName->GetNumberOfValues();
// Sort the density array
std::vector<vtkIdType> ids;
ids.resize(nbPoints);
for (vtkIdType i = 0; i < nbPoints; i++)
{
ids[i] = i;
}
// Fetch and sort arrays according their density
std::vector<DensityVal> varNames;
for (int i = 0; i < varName->GetNumberOfValues(); i++)
varNames.reserve(nbPoints);
for (int i = 0; i < nbPoints; i++)
{
varNames.push_back(
DensityVal(density->GetValue(i),
inTable->GetColumnByName(varName->GetValue(i))));
varNames.push_back(DensityVal(density->GetValue(i),
inTable->GetColumnByName(varName->GetValue(i))));
}
std::sort(varNames.begin(), varNames.end());
std::vector<vtkAbstractArray*> medianLines;
std::vector<vtkAbstractArray*> q3Lines;
std::set<vtkAbstractArray*> outliersSeries;
// Compute total density sum
double densitySum = 0.0;
for (vtkIdType i = 0; i < nbPoints; i++)
{
densitySum += density->GetTuple1(i);
}
size_t nbVarNames = varNames.size();
for (size_t i = 0; i < nbVarNames; i++)
double sum = 0.0;
for (vtkIdType i = 0; i < nbPoints; i++)
{
if (i <= static_cast<size_t>(nbPoints * 0.5))
sum += varNames[i].Density;
if (sum < 0.5 * densitySum)
{
medianLines.push_back(varNames[i].Array);
}
if (i <= static_cast<size_t>(nbPoints * 0.75))
if (sum < 0.99 * densitySum)
{
q3Lines.push_back(varNames[i].Array);
}
else
{
break;
outliersSeries.insert(varNames[i].Array);
}
}
// Generate the quad strip arrays
vtkIdType nbRows = inTable->GetNumberOfRows();
vtkIdType nbCols = inTable->GetNumberOfColumns();
// Generate the median line
vtkNew<vtkDoubleArray> qMedPoints;
qMedPoints->SetName("QMedianLine");
qMedPoints->SetNumberOfComponents(1);
qMedPoints->SetNumberOfTuples(nbRows);
std::vector<double> vals;
vals.resize(nbCols);
for (vtkIdType i = 0; i < nbRows; i++)
{
for (vtkIdType j = 0; j < nbCols; j++)
{
vals[j] = inTable->GetValue(i, j).ToDouble();
}
std::sort(vals.begin(), vals.end());
qMedPoints->SetTuple1(i, vals[nbCols / 2]);
}
// Generate the quad strip arrays
vtkNew<vtkDoubleArray> q3Points;
q3Points->SetName("Q3Points");
q3Points->SetNumberOfComponents(2);
......@@ -180,11 +201,25 @@ int vtkExtractFunctionalBagPlot::RequestData(vtkInformation* /*request*/,
// Add the 2 "bag" columns into the output table
outTable->AddColumn(q3Points.GetPointer());
outTable->AddColumn(q2Points.GetPointer());
outTable->AddColumn(qMedPoints.GetPointer());
// Then append the input columns
for (vtkIdType i = 0; i < inNbColumns; i++)
{
outTable->AddColumn(inTable->GetColumn(i));
vtkAbstractArray* arr = inTable->GetColumn(i);
if (outliersSeries.find(arr) != outliersSeries.end())
{
vtkAbstractArray* arrCopy = arr->NewInstance();
arrCopy->DeepCopy(arr);
std::string name = std::string(arr->GetName()) + "_outlier";
arrCopy->SetName(name.c_str());
outTable->AddColumn(arrCopy);
arrCopy->Delete();
}
else
{
outTable->AddColumn(arr);
}
}
return 1;
......
......@@ -167,32 +167,12 @@ void vtkHighestDensityRegionsStatistics::Learn(vtkTable* inData,
outObservations->SetNumberOfComponents(1);
outObservations->SetNumberOfTuples(inObservations->GetNumberOfTuples());
double sum = this->ComputeHDR(inObservations.GetPointer(), outObservations);
this->ComputeHDR(inObservations.GetPointer(), outObservations);
std::stringstream ss;
ss <<"HDR (" << inputColX->GetName() << "," << inputColY->GetName() << ")";
outObservations->SetName(ss.str().c_str());
outputColumns->AddColumn(outObservations);
if (sum != 0.0)
{
sum = 1.0 / sum;
// Creation of the hdr array.
vtkNew<vtkDoubleArray> normalizedHDR;
std::stringstream sst;
sst << "Normalized " << outObservations->GetName();
normalizedHDR->SetName(sst.str().c_str());
normalizedHDR->SetNumberOfComponents(1);
vtkIdType nbObservations = outObservations->GetNumberOfTuples();
normalizedHDR->SetNumberOfTuples(nbObservations);
for (vtkIdType j = 0; j < nbObservations; j++)
{
normalizedHDR->SetTuple1(j, sum * outObservations->GetTuple1(j));
}
outputColumns->AddColumn(normalizedHDR.GetPointer());
}
arrX->Delete();
arrY->Delete();
outObservations->Delete();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment