mirror of
https://github.com/OpenFOAM/ThirdParty-6.git
synced 2025-12-08 06:57:43 +00:00
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:
60
ParaView-5.0.1/VTK/Examples/Array/Cxx/AdjacencyMatrix.cxx
Normal file
60
ParaView-5.0.1/VTK/Examples/Array/Cxx/AdjacencyMatrix.cxx
Normal file
@ -0,0 +1,60 @@
|
||||
#include <vtkAdjacencyMatrixToEdgeTable.h>
|
||||
#include <vtkArrayPrint.h>
|
||||
#include <vtkDenseArray.h>
|
||||
#include <vtkDiagonalMatrixSource.h>
|
||||
#include <vtkRenderWindow.h>
|
||||
#include <vtkGraphLayoutView.h>
|
||||
#include <vtkSmartPointer.h>
|
||||
#include <vtkTable.h>
|
||||
#include <vtkTableToGraph.h>
|
||||
#include <vtkRenderer.h>
|
||||
#include <vtkRenderWindowInteractor.h>
|
||||
#include <vtkViewTheme.h>
|
||||
|
||||
int main(int vtkNotUsed(argc), char *vtkNotUsed(argv)[])
|
||||
{
|
||||
vtkSmartPointer<vtkDiagonalMatrixSource> source = vtkSmartPointer<vtkDiagonalMatrixSource>::New();
|
||||
source->SetExtents(10);
|
||||
source->SetDiagonal(0);
|
||||
source->SetSuperDiagonal(1);
|
||||
source->SetSubDiagonal(2);
|
||||
source->Update();
|
||||
|
||||
cout << "adjacency matrix:\n";
|
||||
vtkPrintMatrixFormat(cout, vtkDenseArray<double>::SafeDownCast(source->GetOutput()->GetArray(0)));
|
||||
cout << "\n";
|
||||
|
||||
vtkSmartPointer<vtkAdjacencyMatrixToEdgeTable> edges = vtkSmartPointer<vtkAdjacencyMatrixToEdgeTable>::New();
|
||||
edges->SetInputConnection(source->GetOutputPort());
|
||||
|
||||
vtkSmartPointer<vtkTableToGraph> graph = vtkSmartPointer<vtkTableToGraph>::New();
|
||||
graph->SetInputConnection(edges->GetOutputPort());
|
||||
graph->AddLinkVertex("rows", "stuff", false);
|
||||
graph->AddLinkVertex("columns", "stuff", false);
|
||||
graph->AddLinkEdge("rows", "columns");
|
||||
|
||||
vtkSmartPointer<vtkViewTheme> theme;
|
||||
theme.TakeReference(vtkViewTheme::CreateMellowTheme());
|
||||
theme->SetLineWidth(5);
|
||||
theme->SetCellOpacity(0.9);
|
||||
theme->SetCellAlphaRange(0.5,0.5);
|
||||
theme->SetPointSize(10);
|
||||
theme->SetSelectedCellColor(1,0,1);
|
||||
theme->SetSelectedPointColor(1,0,1);
|
||||
|
||||
vtkSmartPointer<vtkGraphLayoutView> view = vtkSmartPointer<vtkGraphLayoutView>::New();
|
||||
view->AddRepresentationFromInputConnection(graph->GetOutputPort());
|
||||
view->EdgeLabelVisibilityOn();
|
||||
view->SetEdgeLabelArrayName("value");
|
||||
view->ApplyViewTheme(theme);
|
||||
view->SetVertexLabelFontSize(20);
|
||||
view->SetEdgeLabelFontSize(18);
|
||||
view->VertexLabelVisibilityOn();
|
||||
|
||||
view->GetRenderWindow()->SetSize(600, 600);
|
||||
view->ResetCamera();
|
||||
view->GetInteractor()->Start();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
90
ParaView-5.0.1/VTK/Examples/Array/Cxx/ArrayBasics.cxx
Normal file
90
ParaView-5.0.1/VTK/Examples/Array/Cxx/ArrayBasics.cxx
Normal file
@ -0,0 +1,90 @@
|
||||
#include <vtkArrayPrint.h>
|
||||
#include <vtkDenseArray.h>
|
||||
#include <vtkSparseArray.h>
|
||||
|
||||
int main(int vtkNotUsed(argc), char *vtkNotUsed(argv)[])
|
||||
{
|
||||
////////////////////////////////////////////////////////
|
||||
// Creating N-Way Arrays
|
||||
|
||||
// Creating a dense array of 10 integers:
|
||||
vtkDenseArray<vtkIdType>* array = vtkDenseArray<vtkIdType>::New();
|
||||
array->Resize(10);
|
||||
|
||||
// Creating a dense 20 x 30 matrix:
|
||||
vtkDenseArray<double>* matrix = vtkDenseArray<double>::New();
|
||||
matrix->Resize(20, 30);
|
||||
|
||||
// Creating a sparse 10 x 20 x 30 x 40 tensor:
|
||||
vtkArrayExtents extents;
|
||||
extents.SetDimensions(4);
|
||||
extents[0] = vtkArrayRange(0, 10);
|
||||
extents[1] = vtkArrayRange(0, 20);
|
||||
extents[2] = vtkArrayRange(0, 30);
|
||||
extents[3] = vtkArrayRange(0, 40);
|
||||
vtkSparseArray<vtkIdType>* tensor = vtkSparseArray<vtkIdType>::New();
|
||||
tensor->Resize(extents);
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
// Initializing N-Way Arrays
|
||||
|
||||
// Filling a dense array with ones:
|
||||
array->Fill(1);
|
||||
|
||||
// Filling a dense matrix with zeros:
|
||||
matrix->Fill(0.0);
|
||||
|
||||
// There's nothing to do for a sparse array - it's already empty.
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
// Assigning N-Way Array Values
|
||||
|
||||
// Assign array value [5]:
|
||||
array->SetValue(5, 42);
|
||||
|
||||
// Assign matrix value [4, 3]:
|
||||
matrix->SetValue(4, 3, 1970);
|
||||
|
||||
// Assign tensor value [3, 7, 1, 2]:
|
||||
vtkArrayCoordinates coordinates;
|
||||
coordinates.SetDimensions(4);
|
||||
coordinates[0] = 3;
|
||||
coordinates[1] = 7;
|
||||
coordinates[2] = 1;
|
||||
coordinates[3] = 2;
|
||||
tensor->SetValue(coordinates, 38);
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
// Accessing N-Way Array Values
|
||||
|
||||
// Access array value [5]:
|
||||
cout << "array[5]: " << array->GetValue(5) << "\n\n";
|
||||
|
||||
// Access matrix value [4, 3]:
|
||||
cout << "matrix[4, 3]: " << matrix->GetValue(4, 3) << "\n\n";
|
||||
|
||||
// Access tensor value [3, 7, 1, 2]:
|
||||
cout << "tensor[3, 7, 1, 2]: " << tensor->GetValue(coordinates) << "\n\n";
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
// Printing N-Way Arrays
|
||||
|
||||
cout << "array:\n";
|
||||
vtkPrintVectorFormat(cout, array);
|
||||
cout << "\n";
|
||||
|
||||
cout << "matrix:\n";
|
||||
vtkPrintMatrixFormat(cout, matrix);
|
||||
cout << "\n";
|
||||
|
||||
cout << "tensor:\n";
|
||||
vtkPrintCoordinateFormat(cout, tensor);
|
||||
cout << "\n";
|
||||
|
||||
// Cleanup array instances ...
|
||||
tensor->Delete();
|
||||
matrix->Delete();
|
||||
array->Delete();
|
||||
|
||||
return 0;
|
||||
}
|
||||
43
ParaView-5.0.1/VTK/Examples/Array/Cxx/ArrayIteration.cxx
Normal file
43
ParaView-5.0.1/VTK/Examples/Array/Cxx/ArrayIteration.cxx
Normal file
@ -0,0 +1,43 @@
|
||||
#include <vtkArrayPrint.h>
|
||||
#include <vtkDenseArray.h>
|
||||
#include <vtkSparseArray.h>
|
||||
|
||||
int main(int vtkNotUsed(argc), char *vtkNotUsed(argv)[])
|
||||
{
|
||||
// Create a dense matrix:
|
||||
vtkDenseArray<double>* matrix = vtkDenseArray<double>::New();
|
||||
matrix->Resize(10, 10);
|
||||
matrix->Fill(0.0);
|
||||
|
||||
// Increment every value in a sparse-or-dense array
|
||||
// with any number of dimensions:
|
||||
for(vtkArray::SizeT n = 0; n != matrix->GetNonNullSize(); ++n)
|
||||
{
|
||||
matrix->SetValueN(n, matrix->GetValueN(n) + 1);
|
||||
}
|
||||
|
||||
// Compute the sum of every column in a sparse-or-dense matrix:
|
||||
vtkDenseArray<double>* sum = vtkDenseArray<double>::New();
|
||||
sum->Resize(matrix->GetExtents()[1]);
|
||||
sum->Fill(0.0);
|
||||
|
||||
vtkArrayCoordinates coordinates;
|
||||
for(vtkArray::SizeT n = 0; n != matrix->GetNonNullSize(); ++n)
|
||||
{
|
||||
matrix->GetCoordinatesN(n, coordinates);
|
||||
sum->SetValue(coordinates[1], sum->GetValue(coordinates[1]) + matrix->GetValueN(n));
|
||||
}
|
||||
|
||||
cout << "matrix:\n";
|
||||
vtkPrintMatrixFormat(cout, matrix);
|
||||
cout << "\n";
|
||||
|
||||
cout << "sum:\n";
|
||||
vtkPrintVectorFormat(cout, sum);
|
||||
cout << "\n";
|
||||
|
||||
sum->Delete();
|
||||
matrix->Delete();
|
||||
|
||||
return 0;
|
||||
}
|
||||
24
ParaView-5.0.1/VTK/Examples/Array/Cxx/CMakeLists.txt
Normal file
24
ParaView-5.0.1/VTK/Examples/Array/Cxx/CMakeLists.txt
Normal file
@ -0,0 +1,24 @@
|
||||
PROJECT(Array)
|
||||
|
||||
IF(NOT VTK_BINARY_DIR)
|
||||
FIND_PACKAGE(VTK REQUIRED)
|
||||
INCLUDE(${VTK_USE_FILE})
|
||||
ENDIF()
|
||||
|
||||
IF(NOT VTK_USE_N_WAY_ARRAYS)
|
||||
MESSAGE(FATAL_ERROR "Example ${PROJECT_NAME} requires VTK_USE_N_WAY_ARRAYS.")
|
||||
ENDIF()
|
||||
|
||||
ADD_EXECUTABLE(ArrayBasics ArrayBasics.cxx)
|
||||
TARGET_LINK_LIBRARIES(ArrayBasics vtkCommon)
|
||||
|
||||
ADD_EXECUTABLE(IdentityMatrix IdentityMatrix.cxx)
|
||||
TARGET_LINK_LIBRARIES(IdentityMatrix vtkCommon)
|
||||
|
||||
ADD_EXECUTABLE(ArrayIteration ArrayIteration.cxx)
|
||||
TARGET_LINK_LIBRARIES(ArrayIteration vtkCommon)
|
||||
|
||||
IF(VTK_USE_VIEWS AND VTK_USE_INFOVIS)
|
||||
ADD_EXECUTABLE(AdjacencyMatrix AdjacencyMatrix.cxx)
|
||||
TARGET_LINK_LIBRARIES(AdjacencyMatrix vtkInfovis vtkViews)
|
||||
ENDIF()
|
||||
41
ParaView-5.0.1/VTK/Examples/Array/Cxx/IdentityMatrix.cxx
Normal file
41
ParaView-5.0.1/VTK/Examples/Array/Cxx/IdentityMatrix.cxx
Normal file
@ -0,0 +1,41 @@
|
||||
#include <vtkArrayPrint.h>
|
||||
#include <vtkSparseArray.h>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
if(argc != 2)
|
||||
{
|
||||
cerr << "usage: " << argv[0] << " matrix-size\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
int size = 0;
|
||||
std::istringstream buffer(argv[1]);
|
||||
buffer >> size;
|
||||
|
||||
if(size < 1)
|
||||
{
|
||||
cerr << "matrix size must be an integer greater-than zero\n";
|
||||
return 2;
|
||||
}
|
||||
|
||||
// Create a sparse identity matrix:
|
||||
vtkSparseArray<double>* matrix = vtkSparseArray<double>::New();
|
||||
matrix->Resize(0, 0); // To set the number of dimensions
|
||||
for(int n = 0; n != size; ++n)
|
||||
{
|
||||
matrix->AddValue(vtkArrayCoordinates(n, n), 1);
|
||||
}
|
||||
matrix->SetExtentsFromContents(); // To synchronize the array extents with newly-added values.
|
||||
|
||||
cout << "matrix:\n";
|
||||
vtkPrintMatrixFormat(cout, matrix);
|
||||
cout << "\n";
|
||||
|
||||
matrix->Delete();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user