Commit 8c4ad118 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit Committed by Kitware Robot

Merge topic 'vtk-master' into pv-master

0ae9a6d7 Merge topic 'fix-java-windows-install-rules' into master
40e24641 Provide valid dll directory path for Java install rules
d44754cc Merge topic '0014453-fix-for-streamtracer' into master
0664ec35 Merge topic 'dataset-surface-fix' into master
3978a87e Fixed issue in filter leading to sanitizer errors.
0dec660c Merge topic 'module-RUNTIME_LIBRARY_DIRS' into master
c7e38430 Merge remote-tracking branch 'pvvtk/pv-master' into HEAD
a9b6127d Merge topic 'areroul_is_not_valid' into master
e24213c3 Merge topic '0014200-incorrect-vtkAxisActor2D-scaling' into master
dd4b51b9 Report runtime linker search path to VTK clients
7b045ad7 Fix typo in vtktiff CMakeLists to areroul.
0f33c6a7 Merge topic 'unstructured-ghost-zones' into master
09a16733 Merge topic '0014446-raycastrendertexture-must-enable-blending' into master
2f40000d Merge topic 'tcl_interactive' into master
dff62296 Merge topic 'Coverage_HyperOctreeIO' into master
a99e8317 Merge topic 'Coverage_ChacoGraphReader' into master
...
parents 994589d2 0ae9a6d7
......@@ -16,6 +16,7 @@ macro(_vtk_module_config_recurse ns mod)
list(APPEND ${ns}_LIBRARIES ${${mod}_LIBRARIES})
list(APPEND ${ns}_INCLUDE_DIRS ${${mod}_INCLUDE_DIRS})
list(APPEND ${ns}_LIBRARY_DIRS ${${mod}_LIBRARY_DIRS})
list(APPEND ${ns}_RUNTIME_LIBRARY_DIRS ${${mod}_RUNTIME_LIBRARY_DIRS})
foreach(iface IN LISTS ${mod}_IMPLEMENTS)
list(APPEND _${ns}_AUTOINIT_${iface} ${mod})
list(APPEND _${ns}_AUTOINIT ${iface})
......@@ -38,6 +39,7 @@ endmacro()
# <module>_LIBRARIES = Libraries to link
# <module>_INCLUDE_DIRS = Header search path
# <module>_LIBRARY_DIRS = Library search path (for outside dependencies)
# <module>_RUNTIME_LIBRARY_DIRS = Runtime linker search path
macro(vtk_module_load mod)
if(NOT ${mod}_LOADED)
include("${VTK_MODULES_DIR}/${mod}.cmake" OPTIONAL RESULT_VARIABLE _found)
......@@ -97,6 +99,7 @@ endmacro()
# <namespace>_LIBRARIES = Libraries to link
# <namespace>_INCLUDE_DIRS = Header search path
# <namespace>_LIBRARY_DIRS = Library search path (for outside dependencies)
# <namespace>_RUNTIME_LIBRARY_DIRS = Runtime linker search path
#
# Calling this macro also recursively calls vtk_module_load for all modules
# explicitly named, and their dependencies, making them available in the local
......@@ -121,6 +124,7 @@ macro(vtk_module_config ns)
set(${ns}_LIBRARIES "")
set(${ns}_INCLUDE_DIRS "")
set(${ns}_LIBRARY_DIRS "")
set(${ns}_RUNTIME_LIBRARY_DIRS "")
set(_${ns}_AUTOINIT "")
set(_${ns}_USED_MODULES "")
......@@ -133,7 +137,7 @@ macro(vtk_module_config ns)
unset(_${ns}_USED_MODULES)
foreach(v ${ns}_LIBRARIES ${ns}_INCLUDE_DIRS ${ns}_LIBRARY_DIRS
_${ns}_AUTOINIT)
${ns}_RUNTIME_LIBRARY_DIRS _${ns}_AUTOINIT)
if(${v})
list(REMOVE_DUPLICATES ${v})
endif()
......
......@@ -3,5 +3,6 @@ set(@vtk-module@_DEPENDS "@vtk-module-DEPENDS@")
set(@vtk-module@_LIBRARIES "@vtk-module-LIBRARIES@")
set(@vtk-module@_INCLUDE_DIRS "@vtk-module-INCLUDE_DIRS@")
set(@vtk-module@_LIBRARY_DIRS "@vtk-module-LIBRARY_DIRS@")
set(@vtk-module@_RUNTIME_LIBRARY_DIRS "@vtk-module-RUNTIME_LIBRARY_DIRS@")
set(@vtk-module@_WRAP_HIERARCHY_FILE "@vtk-module-WRAP_HIERARCHY_FILE@")
@vtk-module-EXPORT_CODE@
......@@ -208,13 +208,22 @@ macro(vtk_module_export_info)
list(APPEND vtk-module-INCLUDE_DIRS-build "${${vtk-module}_SYSTEM_INCLUDE_DIRS}")
list(APPEND vtk-module-INCLUDE_DIRS-install "${${vtk-module}_SYSTEM_INCLUDE_DIRS}")
endif()
if(WIN32)
set(vtk-module-RUNTIME_LIBRARY_DIRS-build "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
set(vtk-module-RUNTIME_LIBRARY_DIRS-install "\${VTK_INSTALL_PREFIX}/${VTK_INSTALL_RUNTIME_DIR}")
else()
set(vtk-module-RUNTIME_LIBRARY_DIRS-build "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
set(vtk-module-RUNTIME_LIBRARY_DIRS-install "\${VTK_INSTALL_PREFIX}/${VTK_INSTALL_LIBRARY_DIR}")
endif()
set(vtk-module-LIBRARY_DIRS "${${vtk-module}_SYSTEM_LIBRARY_DIRS}")
set(vtk-module-RUNTIME_LIBRARY_DIRS "${vtk-module-RUNTIME_LIBRARY_DIRS-build}")
set(vtk-module-INCLUDE_DIRS "${vtk-module-INCLUDE_DIRS-build}")
set(vtk-module-EXPORT_CODE "${vtk-module-EXPORT_CODE-build}")
set(vtk-module-WRAP_HIERARCHY_FILE "${${vtk-module}_WRAP_HIERARCHY_FILE}")
configure_file(${_VTKModuleMacros_DIR}/vtkModuleInfo.cmake.in
${VTK_MODULES_DIR}/${vtk-module}.cmake @ONLY)
set(vtk-module-INCLUDE_DIRS "${vtk-module-INCLUDE_DIRS-install}")
set(vtk-module-RUNTIME_LIBRARY_DIRS "${vtk-module-RUNTIME_LIBRARY_DIRS-install}")
set(vtk-module-EXPORT_CODE "${vtk-module-EXPORT_CODE-install}")
set(vtk-module-WRAP_HIERARCHY_FILE
"\${CMAKE_CURRENT_LIST_DIR}/${vtk-module}Hierarchy.txt")
......
......@@ -334,6 +334,7 @@ if (NOT VTK_INSTALL_NO_DEVELOPMENT)
CMake/vtk-forward.c.in
CMake/vtkForwardingExecutable.cmake
CMake/vtkJavaWrapping.cmake
CMake/vtkMakeInstantiator.cmake
CMake/vtkModuleAPI.cmake
CMake/vtkModuleHeaders.cmake.in
CMake/vtkModuleInfo.cmake.in
......
......@@ -23,7 +23,9 @@ set(Module_SRCS
vtkPiecewisePointHandleItem.cxx
vtkPlot.cxx
vtkPlot3D.cxx
vtkPlotBag.cxx
vtkPlotBar.cxx
vtkPlotFunctionalBag.cxx
vtkPlotGrid.cxx
vtkPlotHistogram2D.cxx
vtkPlotLine.cxx
......
......@@ -11,6 +11,7 @@ set(TestContextUnicode_ARGS DATA{../Data/Fonts/DejaVuSans.ttf})
# add tests that require data
vtk_add_test_cxx(
TestAxes.cxx
TestBagPlot.cxx
TestBarGraph.cxx
TestBarGraphHorizontal.cxx
TestCategoryLegend.cxx
......@@ -25,6 +26,7 @@ vtk_add_test_cxx(
TestContextUnicode.cxx
TestControlPointsHandleItem.cxx,-E30
TestDiagram.cxx
TestFunctionalBagPlot.cxx
TestHistogram2D.cxx
TestInteractiveChartXYZ.cxx
TestLegendHiddenPlots.cxx
......
/*=========================================================================
Program: Visualization Toolkit
Module: TestBagPlot.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkChartXY.h"
#include "vtkContextScene.h"
#include "vtkContextView.h"
#include "vtkDoubleArray.h"
#include "vtkIntArray.h"
#include "vtkNew.h"
#include "vtkPlotBag.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkTable.h"
//----------------------------------------------------------------------------
int TestBagPlot(int, char * [])
{
// Set up a 2D scene, add an XY chart to it
vtkNew<vtkContextView> view;
view->GetRenderWindow()->SetSize(400, 400);
view->GetRenderWindow()->SetMultiSamples(0);
vtkNew<vtkChartXY> chart;
view->GetScene()->AddItem(chart.GetPointer());
chart->SetShowLegend(true);
// Creates a vtkPlotBag input table
// We construct a 2D grid 20*20.
int numDataI = 20;
int numDataJ = 20;
vtkNew<vtkIntArray> arrX;
arrX->SetName("X");
vtkNew<vtkDoubleArray> arrY;
arrY->SetName("Y");
vtkNew<vtkDoubleArray> arrDensity;
arrDensity->SetName("Density");
vtkNew<vtkTable> table;
table->AddColumn(arrX.GetPointer());
table->AddColumn(arrY.GetPointer());
table->AddColumn(arrDensity.GetPointer());
table->SetNumberOfRows(numDataI * numDataJ);
// Fill the table
for (int j = 0; j < numDataJ; ++j)
{
for (int i = 0; i < numDataI; ++i)
{
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);
table->SetValue(i + j * numDataI, 2, d); // Density
}
}
vtkNew<vtkPlotBag> bagPlot;
chart->AddPlot(bagPlot.GetPointer());
bagPlot->SetInputData(table.GetPointer(), arrX->GetName(),
arrY->GetName(), arrDensity->GetName());
bagPlot->SetColor(255, 0, 0, 255);
bagPlot->SetMarkerSize(4);
// Render the scene
view->GetInteractor()->Initialize();
view->GetInteractor()->Start();
return EXIT_SUCCESS;
}
/*=========================================================================
Program: Visualization Toolkit
Module: TestFunctionalBagPlot.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkChartXY.h"
#include "vtkChartLegend.h"
#include "vtkContextScene.h"
#include "vtkContextView.h"
#include "vtkDoubleArray.h"
#include "vtkLookupTable.h"
#include "vtkPlotFunctionalBag.h"
#include "vtkMath.h"
#include "vtkNew.h"
#include "vtkPen.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkStringArray.h"
#include "vtkTable.h"
#include <sstream>
//----------------------------------------------------------------------------
int TestFunctionalBagPlot(int, char * [])
{
// Creates an input table
const int numCols = 7;
const int numVals = 100;
vtkNew<vtkTable> inputTable;
vtkNew<vtkDoubleArray> arr[numCols];
for (int i = 0; i < numCols; i++)
{
std::stringstream ss;
ss << "Y" << i;
arr[i]->SetName(ss.str().c_str());
arr[i]->SetNumberOfValues(numVals);
for (int j = 0; j < numVals; j++)
{
arr[i]->SetValue(j, (i+1) *
fabs(sin((j * 2.f *vtkMath::Pi()) /
static_cast<float>(numVals))) * j + i * 20);
}
inputTable->AddColumn(arr[i].GetPointer());
}
// Create a X-axis column
vtkNew<vtkDoubleArray> xArr;
xArr->SetName("X");
xArr->SetNumberOfValues(numVals);
for (int j = 0; j < numVals; j++)
{
xArr->SetValue(j, j * 2.0);
}
inputTable->AddColumn(xArr.GetPointer());
// Create the bag columns
vtkNew<vtkDoubleArray> q3Arr;
q3Arr->SetName("Q3");
q3Arr->SetNumberOfComponents(2);
q3Arr->SetNumberOfTuples(numVals);
vtkNew<vtkDoubleArray> q2Arr;
q2Arr->SetName("Q2");
q2Arr->SetNumberOfComponents(2);
q2Arr->SetNumberOfTuples(numVals);
for (int i = 0; i < numVals; i++)
{
double v0, v1;
v0 = arr[1]->GetVariantValue(i).ToFloat();
v1 = arr[5]->GetVariantValue(i).ToFloat();
q3Arr->SetTuple2(i, v0, v1);
v0 = arr[2]->GetVariantValue(i).ToFloat();
v1 = arr[4]->GetVariantValue(i).ToFloat();
q2Arr->SetTuple2(i, v0, v1);
}
inputTable->AddColumn(q3Arr.GetPointer());
inputTable->AddColumn(q2Arr.GetPointer());
// Set up a 2D scene and add an XY chart to it
vtkNew<vtkContextView> view;
view->GetRenderWindow()->SetSize(400, 400);
view->GetRenderWindow()->SetMultiSamples(0);
vtkNew<vtkChartXY> chart;
view->GetScene()->AddItem(chart.GetPointer());
chart->SetShowLegend(true);
chart->GetLegend()->SetHorizontalAlignment(vtkChartLegend::LEFT);
chart->GetLegend()->SetVerticalAlignment(vtkChartLegend::TOP);
// Create the functional bag plots
vtkNew<vtkPlotFunctionalBag> q3Plot;
q3Plot->SetColor(0.5, 0, 0);
q3Plot->SetInputData(inputTable.GetPointer(), "X", "Q3");
chart->AddPlot(q3Plot.GetPointer());
vtkNew<vtkPlotFunctionalBag> q2Plot;
q2Plot->SetColor(1., 0, 0);
q2Plot->SetInputData(inputTable.GetPointer(), "X", "Q2");
chart->AddPlot(q2Plot.GetPointer());
vtkNew<vtkLookupTable> lookup;
lookup->SetNumberOfColors(numCols);
lookup->SetRange(0, numCols-1);
lookup->Build();
for (int j = 0; j < numCols; j++)
{
vtkNew<vtkPlotFunctionalBag> plot;
double rgb[3];
lookup->GetColor(j, rgb);
plot->SetColor(rgb[0], rgb[1], rgb[2]);
plot->SetInputData(inputTable.GetPointer(), "X",
inputTable->GetColumn(j)->GetName());
chart->AddPlot(plot.GetPointer());
}
// Render the scene
view->GetInteractor()->Initialize();
view->GetInteractor()->Start();
return EXIT_SUCCESS;
}
......@@ -51,7 +51,9 @@ public:
LINE,
POINTS,
BAR,
STACKED};
STACKED,
BAG,
FUNCTIONALBAG};
// Description:
// Enum of valid chart action types.
......
......@@ -33,6 +33,8 @@
#include "vtkVectorOperators.h"
#include "vtkPlotBar.h"
#include "vtkPlotBag.h"
#include "vtkPlotFunctionalBag.h"
#include "vtkPlotStacked.h"
#include "vtkPlotLine.h"
#include "vtkPlotPoints.h"
......@@ -1038,6 +1040,13 @@ vtkPlot * vtkChartXY::AddPlot(int type)
plot = bar;
break;
}
case FUNCTIONALBAG:
{
vtkPlotFunctionalBag *bag = vtkPlotFunctionalBag::New();
bag->GetBrush()->SetColor(color.GetData());
plot = bag;
break;
}
case STACKED:
{
vtkPlotStacked *stacked = vtkPlotStacked::New();
......@@ -1046,6 +1055,15 @@ vtkPlot * vtkChartXY::AddPlot(int type)
plot = stacked;
break;
}
case BAG:
{
vtkPlotBag *bag = vtkPlotBag::New();
bag->SetParent(this);
bag->GetBrush()->SetColor(color.GetData());
plot = bag;
break;
}
default:
plot = NULL;
}
......
/*=========================================================================
Program: Visualization Toolkit
Module: vtkPlotBag.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkBrush.h"
#include "vtkContext2D.h"
#include "vtkContextMapper2D.h"
#include "vtkDataArray.h"
#include "vtkDoubleArray.h"
#include "vtkObjectFactory.h"
#include "vtkPen.h"
#include "vtkPlotBag.h"
#include "vtkPoints.h"
#include "vtkPoints2D.h"
#include "vtkPointsProjectedHull.h"
#include "vtkStringArray.h"
#include "vtkTable.h"
#include "vtkTimeStamp.h"
#include <algorithm>
//-----------------------------------------------------------------------------
vtkStandardNewMacro(vtkPlotBag);
//-----------------------------------------------------------------------------
vtkPlotBag::vtkPlotBag()
{
this->MedianPoints = vtkPoints2D::New();
this->Q3Points = vtkPoints2D::New();
this->TooltipDefaultLabelFormat = "%l (%x, %y): %z";
}
//-----------------------------------------------------------------------------
vtkPlotBag::~vtkPlotBag()
{
if (this->MedianPoints)
{
this->MedianPoints->Delete();
this->MedianPoints = 0;
}
if (this->Q3Points)
{
this->Q3Points->Delete();
this->Q3Points = 0;
}
}
//-----------------------------------------------------------------------------
void vtkPlotBag::Update()
{
if (!this->Visible)
{
return;
}
// Check if we have an input
vtkTable *table = this->Data->GetInput();
vtkDataArray *density = vtkDataArray::SafeDownCast(
this->Data->GetInputAbstractArrayToProcess(2, this->GetInput()));
if (!table || !density)
{
vtkDebugMacro(<< "Update event called with no input table or density column set.");
return;
}
bool update = (this->Data->GetMTime() > this->BuildTime ||
table->GetMTime() > this->BuildTime ||
this->MTime > this->BuildTime);
this->Superclass::Update();
if (update)
{
vtkDebugMacro(<< "Updating cached values.");
this->UpdateTableCache(density);
}
}
//-----------------------------------------------------------------------------
class ArraySorter
{
public:
ArraySorter(vtkDataArray* arr) : Array(arr) {}
bool operator()(const vtkIdType& a, const vtkIdType& b)
{
return this->Array->GetTuple1(a) > this->Array->GetTuple1(b);
}
vtkDataArray* Array;
};
//-----------------------------------------------------------------------------
void vtkPlotBag::UpdateTableCache(vtkDataArray* density)
{
this->MedianPoints->Reset();
this->Q3Points->Reset();
if (!this->Points)
{
return;
}
vtkIdType nbPoints = density->GetNumberOfTuples();
// Sort the density array
std::vector<vtkIdType> ids;
ids.resize(nbPoints);
double sum = 0.0;
for (vtkIdType i = 0; i < nbPoints; i++)
{
sum += density->GetTuple1(i);
ids[i] = i;
}
vtkNew<vtkDoubleArray> nDensity;
// Normalize the density array if needed
if (fabs(sum - 1.0) > 1.0e-12)
{
sum = 1.0 / sum;
nDensity->SetNumberOfComponents(1);
nDensity->SetNumberOfTuples(nbPoints);
for (vtkIdType i = 0; i < nbPoints; i++)
{
nDensity->SetTuple1(i, density->GetTuple1(ids[i]) * sum);
}
density = nDensity.GetPointer();
}
// Sort array by density
ArraySorter arraySorter(density);
std::sort(ids.begin(), ids.end(), arraySorter);
vtkNew<vtkPointsProjectedHull> q3Points;
q3Points->Allocate(nbPoints);
vtkNew<vtkPointsProjectedHull> medianPoints;
medianPoints->Allocate(nbPoints);
for (vtkIdType i = 0; i < nbPoints; i++)
{
double x[3];
this->Points->GetPoint(ids[i], x);
if (i < static_cast<vtkIdType>(nbPoints * 0.5))
{
medianPoints->InsertNextPoint(x);
}
if (i < static_cast<vtkIdType>(nbPoints * 0.75))
{
q3Points->InsertNextPoint(x);
}
else
{
break;
}
}
// Compute the convex hull for the median points
vtkIdType nbMedPoints = medianPoints->GetNumberOfPoints();
if (nbMedPoints > 2)
{
int size = medianPoints->GetSizeCCWHullZ();
this->MedianPoints->SetDataTypeToFloat();
this->MedianPoints->SetNumberOfPoints(size+1);
medianPoints->GetCCWHullZ(
static_cast<float*>(this->MedianPoints->GetData()->GetVoidPointer(0)), size);
double x[3];
this->MedianPoints->GetPoint(0, x);
this->MedianPoints->SetPoint(size, x);
}
else if (nbMedPoints > 0)
{
this->MedianPoints->SetNumberOfPoints(nbMedPoints);
for (int j = 0; j < nbMedPoints; j++)
{
double x[3];
medianPoints->GetPoint(j, x);
this->MedianPoints->SetPoint(j, x);
}
}
// Compute the convex hull for the first quartile points
vtkIdType nbQ3Points = q3Points->GetNumberOfPoints();
if (nbQ3Points > 2)
{
int size = q3Points->GetSizeCCWHullZ();