ParaView-5.0.1: Added the source-tree to ThirdParty-dev and patched as described in the README file

Resolves bug-report http://bugs.openfoam.org/view.php?id=2098
This commit is contained in:
Henry Weller
2016-05-30 21:20:56 +01:00
parent 1cce60aa78
commit eba760a6d6
24640 changed files with 6366069 additions and 0 deletions

View File

@ -0,0 +1,98 @@
#include <vtkSmartPointer.h>
#include <vtkXMLPolyDataReader.h>
#include <vtkBandedPolyDataContourFilter.h>
#include <vtkFloatArray.h>
#include <vtkCellData.h>
#include <vtkPointData.h>
#include <vtkScalarsToColors.h>
#include <vtkLookupTable.h>
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
#include <vtkActor.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vector>
int main (int argc, char *argv[])
{
if (argc < 3)
{
std::cerr << "Usage: " << argv[0] << " InputPolyDataFile(.vtp) NumberOfContours" << std::endl;
return EXIT_FAILURE;
}
// Read the file
vtkSmartPointer<vtkXMLPolyDataReader> reader =
vtkSmartPointer<vtkXMLPolyDataReader>::New();
reader->SetFileName( argv[1] );
reader->Update(); // Update so that we can get the scalar range
double scalarRange[2];
reader->GetOutput()->GetPointData()->GetScalars()->GetRange(scalarRange);
int numberOfContours = atoi(argv[2]);
vtkSmartPointer<vtkBandedPolyDataContourFilter> bandedContours =
vtkSmartPointer<vtkBandedPolyDataContourFilter>::New();
bandedContours->SetInputConnection(reader->GetOutputPort());
bandedContours->SetScalarModeToValue();
bandedContours->GenerateContourEdgesOn();
bandedContours->GenerateValues(
numberOfContours, scalarRange[0], scalarRange[1]);
vtkSmartPointer<vtkLookupTable> lut =
vtkSmartPointer<vtkLookupTable>::New();
lut->SetNumberOfTableValues(numberOfContours + 1);
lut->Build();
vtkSmartPointer<vtkPolyDataMapper> contourMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
contourMapper->SetInputConnection(bandedContours->GetOutputPort());
contourMapper->SetScalarRange(scalarRange[0], scalarRange[1]);
contourMapper->SetScalarModeToUseCellData();
contourMapper->SetLookupTable(lut);
vtkSmartPointer<vtkActor> contourActor =
vtkSmartPointer<vtkActor>::New();
contourActor->SetMapper(contourMapper);
contourActor->GetProperty()->SetInterpolationToFlat();
vtkSmartPointer<vtkPolyDataMapper> contourLineMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
contourLineMapper->SetInputData(bandedContours->GetContourEdgesOutput());
contourLineMapper->SetScalarRange(scalarRange[0], scalarRange[1]);
contourLineMapper->ScalarVisibilityOff();
vtkSmartPointer<vtkActor> contourLineActor =
vtkSmartPointer<vtkActor>::New();
contourLineActor->SetMapper(contourLineMapper);
contourLineActor->GetProperty()->SetLineWidth(2);
// The usual renderer, render window and interactor
vtkSmartPointer<vtkRenderer> ren1 =
vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindow> renWin =
vtkSmartPointer<vtkRenderWindow>::New();
vtkSmartPointer<vtkRenderWindowInteractor>
iren = vtkSmartPointer<vtkRenderWindowInteractor>::New();
ren1->SetBackground(.1, .2, .3);
renWin->AddRenderer(ren1);
iren->SetRenderWindow(renWin);
// Add the actors
ren1->AddActor(contourActor);
ren1->AddActor(contourLineActor);
// Begin interaction
renWin->Render();
iren->Start();
return EXIT_SUCCESS;
}

View File

@ -0,0 +1 @@
2683dd99bf47e55b4d7be58ef480ef1c

View File

@ -0,0 +1 @@
0b4a546028931a3bc83f54e83760457f

View File

@ -0,0 +1 @@
844a55bed1ac2ede3ea3a5846594e417

View File

@ -0,0 +1 @@
e629c5fb6b01c8342c10e052a6da2b98

View File

@ -0,0 +1,46 @@
cmake_minimum_required(VERSION 2.8.5 FATAL_ERROR)
if(POLICY CMP0025)
cmake_policy(SET CMP0025 NEW) # CMake 3.0
endif()
if(POLICY CMP0053)
cmake_policy(SET CMP0053 NEW) # CMake 3.1
endif()
project (VisualizationAlgorithms)
find_package(VTK COMPONENTS
vtkCommonCore
vtkCommonDataModel
vtkFiltersCore
vtkFiltersModeling
vtkIOXML
vtkInteractionStyle
vtkRendering${VTK_RENDERING_BACKEND}
vtkTestingRendering
)
include(${VTK_USE_FILE})
add_executable(TubesWithVaryingRadiusAndColors MACOSX_BUNDLE TubesWithVaryingRadiusAndColors.cxx)
add_executable(FilledContours MACOSX_BUNDLE FilledContours.cxx)
add_executable(BandedContours MACOSX_BUNDLE BandedContours.cxx)
target_link_libraries(TubesWithVaryingRadiusAndColors ${VTK_LIBRARIES})
target_link_libraries(FilledContours ${VTK_LIBRARIES})
target_link_libraries(BandedContours ${VTK_LIBRARIES})
if(BUILD_TESTING)
if(vtkTestingRendering_LOADED)
######## Regression Testing ########
set(vtk-example VisualizationAlgorithmsExamples)
set(TestFilledContours_ARGS "DATA{${VTK_TEST_INPUT_DIR}/filledContours.vtp}" 10)
set(TestBandedContours_ARGS "DATA{${VTK_TEST_INPUT_DIR}/filledContours.vtp}" 10)
vtk_add_test_cxx(${vtk-example}CxxTests tests
TestTubesWithVaryingRadiusAndColors.cxx
TestFilledContours.cxx
TestBandedContours.cxx
)
vtk_test_cxx_executable(${vtk-example}CxxTests tests
RENDERING_FACTORY
)
endif()
endif()

View File

@ -0,0 +1,149 @@
#include <vtkSmartPointer.h>
#include <vtkXMLPolyDataReader.h>
#include <vtkAppendPolyData.h>
#include <vtkClipPolyData.h>
#include <vtkCleanPolyData.h>
#include <vtkContourFilter.h>
#include <vtkFloatArray.h>
#include <vtkCellData.h>
#include <vtkPointData.h>
#include <vtkScalarsToColors.h>
#include <vtkLookupTable.h>
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
#include <vtkActor.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vector>
int main (int argc, char *argv[])
{
if (argc < 3)
{
std::cerr << "Usage: " << argv[0] << " InputPolyDataFile(.vtp) NumberOfContours" << std::endl;
return EXIT_FAILURE;
}
// Read the file
vtkSmartPointer<vtkXMLPolyDataReader> reader =
vtkSmartPointer<vtkXMLPolyDataReader>::New();
reader->SetFileName( argv[1] );
reader->Update(); // Update so that we can get the scalar range
double scalarRange[2];
reader->GetOutput()->GetPointData()->GetScalars()->GetRange(scalarRange);
vtkSmartPointer<vtkAppendPolyData> appendFilledContours =
vtkSmartPointer<vtkAppendPolyData>::New();
int numberOfContours = atoi(argv[2]);
double delta =
(scalarRange[1] - scalarRange[0]) /
static_cast<double> (numberOfContours - 1);
// Keep the clippers alive
std::vector<vtkSmartPointer<vtkClipPolyData> > clippersLo;
std::vector<vtkSmartPointer<vtkClipPolyData> > clippersHi;
for (int i = 0; i < numberOfContours; i++)
{
double valueLo = scalarRange[0] + static_cast<double> (i) * delta;
double valueHi = scalarRange[0] + static_cast<double> (i + 1) * delta;
clippersLo.push_back(vtkSmartPointer<vtkClipPolyData>::New());
clippersLo[i]->SetValue(valueLo);
if (i == 0)
{
clippersLo[i]->SetInputConnection(reader->GetOutputPort());
}
else
{
clippersLo[i]->SetInputConnection(clippersHi[i - 1]->GetOutputPort(1));
}
clippersLo[i]->InsideOutOff();
clippersLo[i]->Update();
clippersHi.push_back(vtkSmartPointer<vtkClipPolyData>::New());
clippersHi[i]->SetValue(valueHi);
clippersHi[i]->SetInputConnection(clippersLo[i]->GetOutputPort());
clippersHi[i]->GenerateClippedOutputOn();
clippersHi[i]->InsideOutOn();
clippersHi[i]->Update();
if (clippersHi[i]->GetOutput()->GetNumberOfCells() == 0)
{
continue;
}
vtkSmartPointer<vtkFloatArray> cd =
vtkSmartPointer<vtkFloatArray>::New();
cd->SetNumberOfComponents(1);
cd->SetNumberOfTuples(clippersHi[i]->GetOutput()->GetNumberOfCells());
cd->FillComponent(0, valueLo);
clippersHi[i]->GetOutput()->GetCellData()->SetScalars(cd);
appendFilledContours->AddInputConnection(clippersHi[i]->GetOutputPort());
}
vtkSmartPointer<vtkCleanPolyData> filledContours =
vtkSmartPointer<vtkCleanPolyData>::New();
filledContours->SetInputConnection(appendFilledContours->GetOutputPort());
vtkSmartPointer<vtkLookupTable> lut =
vtkSmartPointer<vtkLookupTable>::New();
lut->SetNumberOfTableValues(numberOfContours + 1);
lut->Build();
vtkSmartPointer<vtkPolyDataMapper> contourMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
contourMapper->SetInputConnection(filledContours->GetOutputPort());
contourMapper->SetScalarRange(scalarRange[0], scalarRange[1]);
contourMapper->SetScalarModeToUseCellData();
contourMapper->SetLookupTable(lut);
vtkSmartPointer<vtkActor> contourActor =
vtkSmartPointer<vtkActor>::New();
contourActor->SetMapper(contourMapper);
contourActor->GetProperty()->SetInterpolationToFlat();
vtkSmartPointer<vtkContourFilter> contours =
vtkSmartPointer<vtkContourFilter>::New();
contours->SetInputConnection(filledContours->GetOutputPort());
contours->GenerateValues(numberOfContours, scalarRange[0], scalarRange[1]);
vtkSmartPointer<vtkPolyDataMapper> contourLineMapperer =
vtkSmartPointer<vtkPolyDataMapper>::New();
contourLineMapperer->SetInputConnection(contours->GetOutputPort());
contourLineMapperer->SetScalarRange(scalarRange[0], scalarRange[1]);
contourLineMapperer->ScalarVisibilityOff();
vtkSmartPointer<vtkActor> contourLineActor =
vtkSmartPointer<vtkActor>::New();
contourLineActor->SetMapper(contourLineMapperer);
contourLineActor->GetProperty()->SetLineWidth(2);
// The usual renderer, render window and interactor
vtkSmartPointer<vtkRenderer> ren1 =
vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindow> renWin =
vtkSmartPointer<vtkRenderWindow>::New();
vtkSmartPointer<vtkRenderWindowInteractor>
iren = vtkSmartPointer<vtkRenderWindowInteractor>::New();
ren1->SetBackground(.1, .2, .3);
renWin->AddRenderer(ren1);
iren->SetRenderWindow(renWin);
// Add the actors
ren1->AddActor(contourActor);
ren1->AddActor(contourLineActor);
// Begin interaction
renWin->Render();
iren->Start();
return EXIT_SUCCESS;
}

View File

@ -0,0 +1,2 @@
#define main TestBandedContours
#include "BandedContours.cxx"

View File

@ -0,0 +1,2 @@
#define main TestFilledContours
#include "FilledContours.cxx"

View File

@ -0,0 +1,2 @@
#define main TestTubesWithVaryingRadiusAndColors
#include "TubesWithVaryingRadiusAndColors.cxx"

View File

@ -0,0 +1,141 @@
// VTK: Spiral with vtkTubeFilter
// Varying tube radius and independent RGB colors with an unsignedCharArray
// Contributed by Marcus Thamson
#include <vtkPolyData.h>
#include <vtkPoints.h>
#include <vtkCellArray.h>
#include <vtkDoubleArray.h>
#include <vtkPolyData.h>
#include <vtkPointData.h>
#include <vtkCell.h>
#include <vtkCellData.h>
#include <vtkDataSet.h>
#include <vtkDataSetAttributes.h>
#include <vtkProperty.h>
#include <vtkSmartPointer.h>
#include <vtkTubeFilter.h>
#include <vtkDataSetMapper.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkCamera.h>
#include <vtkInteractorStyleTrackballCamera.h>
#include <vtkMath.h>
int main (int, char *[])
{
// Spiral tube
double vX, vY, vZ;
unsigned int nV = 256; // No. of vertices
unsigned int nCyc = 5; // No. of spiral cycles
double rT1 = 0.1, rT2 = 0.5;// Start/end tube radii
double rS = 2; // Spiral radius
double h = 10; // Height
unsigned int nTv = 8; // No. of surface elements for each tube vertex
unsigned int i;
// Create points and cells for the spiral
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
for(i = 0; i < nV; i++)
{
// Spiral coordinates
vX = rS * cos(2 * vtkMath::Pi() * nCyc * i / (nV - 1));
vY = rS * sin(2 * vtkMath::Pi() * nCyc * i / (nV - 1));
vZ = h * i / nV;
points->InsertPoint(i, vX, vY, vZ);
}
vtkSmartPointer<vtkCellArray> lines =
vtkSmartPointer<vtkCellArray>::New();
lines->InsertNextCell(nV);
for (i = 0; i < nV; i++)
{
lines->InsertCellPoint(i);
}
vtkSmartPointer<vtkPolyData> polyData =
vtkSmartPointer<vtkPolyData>::New();
polyData->SetPoints(points);
polyData->SetLines(lines);
// Varying tube radius using sine-function
vtkSmartPointer<vtkDoubleArray> tubeRadius =
vtkSmartPointer<vtkDoubleArray>::New();
tubeRadius->SetName("TubeRadius");
tubeRadius->SetNumberOfTuples(nV);
for (i=0 ;i<nV ; i++)
{
tubeRadius->SetTuple1(i,
rT1 + (rT2 - rT1) * sin(vtkMath::Pi() * i / (nV - 1)));
}
polyData->GetPointData()->AddArray(tubeRadius);
polyData->GetPointData()->SetActiveScalars("TubeRadius");
// RBG array (could add Alpha channel too I guess...)
// Varying from blue to red
vtkSmartPointer<vtkUnsignedCharArray> colors =
vtkSmartPointer<vtkUnsignedCharArray>::New();
colors->SetName("Colors");
colors->SetNumberOfComponents(3);
colors->SetNumberOfTuples(nV);
for (i = 0; i < nV ;i++)
{
colors->InsertTuple3(i,
int(255 * i/ (nV - 1)),
0,
int(255 * (nV - 1 - i)/(nV - 1)) );
}
polyData->GetPointData()->AddArray(colors);
vtkSmartPointer<vtkTubeFilter> tube
= vtkSmartPointer<vtkTubeFilter>::New();
tube->SetInputData(polyData);
tube->SetNumberOfSides(nTv);
tube->SetVaryRadiusToVaryRadiusByAbsoluteScalar();
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(tube->GetOutputPort());
mapper->ScalarVisibilityOn();
mapper->SetScalarModeToUsePointFieldData();
mapper->SelectColorArray("Colors");
vtkSmartPointer<vtkActor> actor =
vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
renderer->AddActor(actor);
renderer->SetBackground(.2, .3, .4);
// Make an oblique view
renderer->GetActiveCamera()->Azimuth(30);
renderer->GetActiveCamera()->Elevation(30);
renderer->ResetCamera();
vtkSmartPointer<vtkRenderWindow> renWin =
vtkSmartPointer<vtkRenderWindow>::New();
vtkSmartPointer<vtkRenderWindowInteractor>
iren = vtkSmartPointer<vtkRenderWindowInteractor>::New();
iren->SetRenderWindow(renWin);
renWin->AddRenderer(renderer);
renWin->SetSize(500, 500);
renWin->Render();
vtkSmartPointer<vtkInteractorStyleTrackballCamera> style =
vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
iren->SetInteractorStyle(style);
iren->Start();
return EXIT_SUCCESS;
}