Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
VTK
VTK
Commits
8df357b8
Commit
8df357b8
authored
Sep 30, 2008
by
Timothy M. Shead
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ENH: Finish adding sample N-Way array filters and tests.
parent
4ca31006
Changes
41
Hide whitespace changes
Inline
Side-by-side
Showing
41 changed files
with
3635 additions
and
0 deletions
+3635
-0
Filtering/vtkArrayData.h
Filtering/vtkArrayData.h
+4
-0
Filtering/vtkArrayDataAlgorithm.h
Filtering/vtkArrayDataAlgorithm.h
+3
-0
Filtering/vtkFactoredArrayData.h
Filtering/vtkFactoredArrayData.h
+3
-0
Filtering/vtkFactoredArrayDataAlgorithm.h
Filtering/vtkFactoredArrayDataAlgorithm.h
+3
-0
Infovis/CMakeLists.txt
Infovis/CMakeLists.txt
+29
-0
Infovis/Testing/Cxx/ArrayAPIDenseCoordinates.cxx
Infovis/Testing/Cxx/ArrayAPIDenseCoordinates.cxx
+96
-0
Infovis/Testing/Cxx/ArrayCosineSimilarity.cxx
Infovis/Testing/Cxx/ArrayCosineSimilarity.cxx
+94
-0
Infovis/Testing/Cxx/ArrayDiagonalMatrixSource.cxx
Infovis/Testing/Cxx/ArrayDiagonalMatrixSource.cxx
+93
-0
Infovis/Testing/Cxx/ArrayExtractFactoredArray.cxx
Infovis/Testing/Cxx/ArrayExtractFactoredArray.cxx
+68
-0
Infovis/Testing/Cxx/ArrayMatricizeArray.cxx
Infovis/Testing/Cxx/ArrayMatricizeArray.cxx
+94
-0
Infovis/Testing/Cxx/ArrayMatrixColumnNorm.cxx
Infovis/Testing/Cxx/ArrayMatrixColumnNorm.cxx
+97
-0
Infovis/Testing/Cxx/ArrayNormalizeMatrixVectors.cxx
Infovis/Testing/Cxx/ArrayNormalizeMatrixVectors.cxx
+115
-0
Infovis/Testing/Cxx/ArrayTableToSparseArray.cxx
Infovis/Testing/Cxx/ArrayTableToSparseArray.cxx
+108
-0
Infovis/Testing/Cxx/ArrayTransposeMatrix.cxx
Infovis/Testing/Cxx/ArrayTransposeMatrix.cxx
+82
-0
Infovis/Testing/Cxx/BoostArrayLogWeighting.cxx
Infovis/Testing/Cxx/BoostArrayLogWeighting.cxx
+115
-0
Infovis/Testing/Cxx/BoostArrayRandomSparseArraySource.cxx
Infovis/Testing/Cxx/BoostArrayRandomSparseArraySource.cxx
+80
-0
Infovis/Testing/Cxx/CMakeLists.txt
Infovis/Testing/Cxx/CMakeLists.txt
+48
-0
Infovis/vtkAdjacencyMatrixToEdgeTable.cxx
Infovis/vtkAdjacencyMatrixToEdgeTable.cxx
+163
-0
Infovis/vtkAdjacencyMatrixToEdgeTable.h
Infovis/vtkAdjacencyMatrixToEdgeTable.h
+87
-0
Infovis/vtkArrayToTable.cxx
Infovis/vtkArrayToTable.cxx
+135
-0
Infovis/vtkArrayToTable.h
Infovis/vtkArrayToTable.h
+57
-0
Infovis/vtkBoostLogWeighting.cxx
Infovis/vtkBoostLogWeighting.cxx
+88
-0
Infovis/vtkBoostLogWeighting.h
Infovis/vtkBoostLogWeighting.h
+56
-0
Infovis/vtkBoostRandomSparseArraySource.cxx
Infovis/vtkBoostRandomSparseArraySource.cxx
+123
-0
Infovis/vtkBoostRandomSparseArraySource.h
Infovis/vtkBoostRandomSparseArraySource.h
+99
-0
Infovis/vtkCosineSimilarity.cxx
Infovis/vtkCosineSimilarity.cxx
+223
-0
Infovis/vtkCosineSimilarity.h
Infovis/vtkCosineSimilarity.h
+90
-0
Infovis/vtkDiagonalMatrixSource.cxx
Infovis/vtkDiagonalMatrixSource.cxx
+153
-0
Infovis/vtkDiagonalMatrixSource.h
Infovis/vtkDiagonalMatrixSource.h
+97
-0
Infovis/vtkExtractFactoredArray.cxx
Infovis/vtkExtractFactoredArray.cxx
+84
-0
Infovis/vtkExtractFactoredArray.h
Infovis/vtkExtractFactoredArray.h
+65
-0
Infovis/vtkMatricizeArray.cxx
Infovis/vtkMatricizeArray.cxx
+126
-0
Infovis/vtkMatricizeArray.h
Infovis/vtkMatricizeArray.h
+77
-0
Infovis/vtkMatrixColumnNorm.cxx
Infovis/vtkMatrixColumnNorm.cxx
+110
-0
Infovis/vtkMatrixColumnNorm.h
Infovis/vtkMatrixColumnNorm.h
+64
-0
Infovis/vtkNormalizeMatrixVectors.cxx
Infovis/vtkNormalizeMatrixVectors.cxx
+108
-0
Infovis/vtkNormalizeMatrixVectors.h
Infovis/vtkNormalizeMatrixVectors.h
+63
-0
Infovis/vtkTableToSparseArray.cxx
Infovis/vtkTableToSparseArray.cxx
+178
-0
Infovis/vtkTableToSparseArray.h
Infovis/vtkTableToSparseArray.h
+82
-0
Infovis/vtkTransposeMatrix.cxx
Infovis/vtkTransposeMatrix.cxx
+118
-0
Infovis/vtkTransposeMatrix.h
Infovis/vtkTransposeMatrix.h
+57
-0
No files found.
Filtering/vtkArrayData.h
View file @
8df357b8
...
...
@@ -31,6 +31,10 @@ class vtkInformationVector;
// .NAME vtkArrayData - Pipeline data object that acts as a container
// for a single vtkArray
// .SECTION Thanks
// Developed by Timothy M. Shead (tshead@sandia.gov) at Sandia National Laboratories.
class
VTK_FILTERING_EXPORT
vtkArrayData
:
public
vtkDataObject
{
public:
...
...
Filtering/vtkArrayDataAlgorithm.h
View file @
8df357b8
...
...
@@ -39,6 +39,9 @@
// signature. For even older filters that don't implement ExecuteData the
// default implementation calls the even older Execute() signature.
// .SECTION Thanks
// Developed by Timothy M. Shead (tshead@sandia.gov) at Sandia National Laboratories.
#ifndef __vtkArrayDataAlgorithm_h
#define __vtkArrayDataAlgorithm_h
...
...
Filtering/vtkFactoredArrayData.h
View file @
8df357b8
...
...
@@ -31,6 +31,9 @@ class vtkArray;
// collection of vtkArray instances. Used to store the "factored"
// representation of a larger array.
// .SECTION Thanks
// Developed by Timothy M. Shead (tshead@sandia.gov) at Sandia National Laboratories.
class
VTK_FILTERING_EXPORT
vtkFactoredArrayData
:
public
vtkDataObject
{
public:
...
...
Filtering/vtkFactoredArrayDataAlgorithm.h
View file @
8df357b8
...
...
@@ -39,6 +39,9 @@
// signature. For even older filters that don't implement ExecuteData the
// default implementation calls the even older Execute() signature.
// .SECTION Thanks
// Developed by Timothy M. Shead (tshead@sandia.gov) at Sandia National Laboratories.
#ifndef __vtkFactoredArrayDataAlgorithm_h
#define __vtkFactoredArrayDataAlgorithm_h
...
...
Infovis/CMakeLists.txt
View file @
8df357b8
...
...
@@ -75,6 +75,7 @@ vtkXMLTreeReader.cxx
# Add these classes only if using Boost
IF
(
VTK_USE_BOOST
)
SET
(
Kit_SRCS
${
Kit_SRCS
}
vtkBoostBiconnectedComponents.cxx
...
...
@@ -86,8 +87,36 @@ IF(VTK_USE_BOOST)
vtkBoostPrimMinimumSpanningTree.cxx
vtkBoostSplitTableField.cxx
)
ENDIF
(
VTK_USE_BOOST
)
IF
(
VTK_USE_N_WAY_ARRAYS
)
SET
(
Kit_SRCS
${
Kit_SRCS
}
vtkAdjacencyMatrixToEdgeTable.cxx
vtkArrayToTable.cxx
vtkCosineSimilarity.cxx
vtkDiagonalMatrixSource.cxx
vtkExtractFactoredArray.cxx
vtkMatricizeArray.cxx
vtkMatrixColumnNorm.cxx
vtkNormalizeMatrixVectors.cxx
vtkTableToSparseArray.cxx
vtkTransposeMatrix.cxx
)
IF
(
VTK_USE_BOOST
)
SET
(
Kit_SRCS
${
Kit_SRCS
}
vtkBoostLogWeighting.cxx
vtkBoostRandomSparseArraySource.cxx
)
ENDIF
(
VTK_USE_BOOST
)
ENDIF
(
VTK_USE_N_WAY_ARRAYS
)
# Add these classes only if vtkTypeUInt64Array exists
SET
(
VTK_HAS_UINT64_ARRAY 0
)
IF
(
VTK_SIZEOF_LONG_LONG MATCHES
"^8$"
)
...
...
Infovis/Testing/Cxx/ArrayAPIDenseCoordinates.cxx
0 → 100644
View file @
8df357b8
/*=========================================================================
Program: Visualization Toolkit
Module: ArrayAPIDenseCoordinates.cxx
-------------------------------------------------------------------------
Copyright 2008 Sandia Corporation.
Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
the U.S. Government retains certain rights in this software.
-------------------------------------------------------------------------
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 <vtkArrayData.h>
#include <vtkArrayPrint.h>
#include <vtkDenseArray.h>
#include <vtkDiagonalMatrixSource.h>
#include <vtkSmartPointer.h>
#include <vtkSparseArray.h>
#include <vtksys/ios/iostream>
#include <vtksys/stl/stdexcept>
#define test_expression(expression) \
{ \
if(!(expression)) \
throw vtkstd::runtime_error("Expression failed: " #expression); \
}
int
ArrayAPIDenseCoordinates
(
int
argc
,
char
*
argv
[])
{
try
{
vtkSmartPointer
<
vtkDiagonalMatrixSource
>
source
=
vtkSmartPointer
<
vtkDiagonalMatrixSource
>::
New
();
source
->
SetExtents
(
3
);
source
->
SetArrayType
(
vtkDiagonalMatrixSource
::
DENSE
);
source
->
SetDiagonal
(
1.0
);
source
->
SetSuperDiagonal
(
0.5
);
source
->
SetSubDiagonal
(
-
0.5
);
source
->
Update
();
vtkDenseArray
<
double
>*
const
array
=
vtkDenseArray
<
double
>::
SafeDownCast
(
source
->
GetOutput
()
->
GetArray
());
cout
<<
"dense diagonal matrix:
\n
"
;
vtkPrintMatrixFormat
(
cout
,
array
);
cout
<<
"dense diagonal coordinates:
\n
"
;
vtkPrintCoordinateFormat
(
cout
,
array
);
test_expression
(
array
);
test_expression
(
array
->
GetValue
(
vtkArrayCoordinates
(
0
,
0
))
==
1.0
);
test_expression
(
array
->
GetValue
(
vtkArrayCoordinates
(
1
,
0
))
==
-
0.5
);
test_expression
(
array
->
GetValue
(
vtkArrayCoordinates
(
2
,
0
))
==
0.0
);
test_expression
(
array
->
GetValue
(
vtkArrayCoordinates
(
0
,
1
))
==
0.5
);
test_expression
(
array
->
GetValue
(
vtkArrayCoordinates
(
1
,
1
))
==
1.0
);
test_expression
(
array
->
GetValue
(
vtkArrayCoordinates
(
2
,
1
))
==
-
0.5
);
test_expression
(
array
->
GetValue
(
vtkArrayCoordinates
(
0
,
2
))
==
0.0
);
test_expression
(
array
->
GetValue
(
vtkArrayCoordinates
(
1
,
2
))
==
0.5
);
test_expression
(
array
->
GetValue
(
vtkArrayCoordinates
(
2
,
2
))
==
1.0
);
for
(
vtkIdType
n
=
0
;
n
!=
array
->
GetNonNullSize
();
++
n
)
{
vtkArrayCoordinates
coordinates
;
array
->
GetCoordinatesN
(
n
,
coordinates
);
if
(
coordinates
[
0
]
==
0
&&
coordinates
[
1
]
==
0
)
{
test_expression
(
array
->
GetValueN
(
n
)
==
1.0
);
}
else
if
(
coordinates
[
0
]
==
0
&&
coordinates
[
1
]
==
1
)
{
test_expression
(
array
->
GetValueN
(
n
)
==
0.5
);
}
else
if
(
coordinates
[
0
]
==
1
&&
coordinates
[
1
]
==
0
)
{
test_expression
(
array
->
GetValueN
(
n
)
==
-
0.5
);
}
}
return
0
;
}
catch
(
vtkstd
::
exception
&
e
)
{
cerr
<<
e
.
what
()
<<
endl
;
return
1
;
}
}
Infovis/Testing/Cxx/ArrayCosineSimilarity.cxx
0 → 100644
View file @
8df357b8
/*=========================================================================
Program: Visualization Toolkit
Module: ArrayCosineSimilarity.cxx
-------------------------------------------------------------------------
Copyright 2008 Sandia Corporation.
Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
the U.S. Government retains certain rights in this software.
-------------------------------------------------------------------------
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 <vtkArrayData.h>
#include <vtkArrayPrint.h>
#include <vtkCosineSimilarity.h>
#include <vtkDenseArray.h>
#include <vtkSmartPointer.h>
#include <vtkTable.h>
#include <vtkVariant.h>
#include <vtksys/ios/iostream>
#include <vtksys/stl/stdexcept>
#define test_expression(expression) \
{ \
if(!(expression)) \
throw vtkstd::runtime_error("Expression failed: " #expression); \
}
static
const
bool
close_enough
(
const
double
lhs
,
const
double
rhs
)
{
return
fabs
(
lhs
-
rhs
)
<
1.0e-12
;
}
int
ArrayCosineSimilarity
(
int
argc
,
char
*
argv
[])
{
cout
<<
setprecision
(
17
);
try
{
vtkSmartPointer
<
vtkDenseArray
<
double
>
>
source
=
vtkSmartPointer
<
vtkDenseArray
<
double
>
>::
New
();
source
->
Resize
(
vtkArrayExtents
(
2
,
4
));
source
->
SetValue
(
vtkArrayCoordinates
(
0
,
0
),
1
);
source
->
SetValue
(
vtkArrayCoordinates
(
1
,
0
),
0
);
source
->
SetValue
(
vtkArrayCoordinates
(
0
,
1
),
1
);
source
->
SetValue
(
vtkArrayCoordinates
(
1
,
1
),
1
);
source
->
SetValue
(
vtkArrayCoordinates
(
0
,
2
),
0
);
source
->
SetValue
(
vtkArrayCoordinates
(
1
,
2
),
1
);
source
->
SetValue
(
vtkArrayCoordinates
(
0
,
3
),
-
1
);
source
->
SetValue
(
vtkArrayCoordinates
(
1
,
3
),
1
);
cout
<<
"source matrix:
\n
"
;
vtkPrintMatrixFormat
(
cout
,
source
.
GetPointer
());
vtkSmartPointer
<
vtkArrayData
>
source_data
=
vtkSmartPointer
<
vtkArrayData
>::
New
();
source_data
->
SetArray
(
source
);
vtkSmartPointer
<
vtkCosineSimilarity
>
similarity
=
vtkSmartPointer
<
vtkCosineSimilarity
>::
New
();
similarity
->
AddInputConnection
(
source_data
->
GetProducerPort
());
similarity
->
SetVectorDimension
(
1
);
similarity
->
Update
();
vtkTable
*
const
table
=
similarity
->
GetOutput
();
test_expression
(
table
->
GetNumberOfColumns
()
==
3
);
cout
<<
"similarity table:
\n
"
;
for
(
vtkIdType
row
=
0
;
row
<
table
->
GetNumberOfRows
();
++
row
)
{
cout
<<
table
->
GetValue
(
row
,
0
).
ToInt
()
<<
" -> "
<<
table
->
GetValue
(
row
,
1
).
ToInt
()
<<
": "
<<
table
->
GetValue
(
row
,
2
).
ToDouble
()
<<
"
\n
"
;
}
return
0
;
}
catch
(
vtkstd
::
exception
&
e
)
{
cerr
<<
e
.
what
()
<<
endl
;
return
1
;
}
}
Infovis/Testing/Cxx/ArrayDiagonalMatrixSource.cxx
0 → 100644
View file @
8df357b8
/*=========================================================================
Program: Visualization Toolkit
Module: ArrayDiagonalMatrixSource.cxx
-------------------------------------------------------------------------
Copyright 2008 Sandia Corporation.
Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
the U.S. Government retains certain rights in this software.
-------------------------------------------------------------------------
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 <vtkArrayData.h>
#include <vtkArrayPrint.h>
#include <vtkDenseArray.h>
#include <vtkDiagonalMatrixSource.h>
#include <vtkSmartPointer.h>
#include <vtkSparseArray.h>
#include <vtksys/ios/iostream>
#include <vtksys/stl/stdexcept>
#define test_expression(expression) \
{ \
if(!(expression)) \
throw vtkstd::runtime_error("Expression failed: " #expression); \
}
int
ArrayDiagonalMatrixSource
(
int
argc
,
char
*
argv
[])
{
try
{
vtkSmartPointer
<
vtkDiagonalMatrixSource
>
source
=
vtkSmartPointer
<
vtkDiagonalMatrixSource
>::
New
();
source
->
SetExtents
(
3
);
source
->
SetArrayType
(
vtkDiagonalMatrixSource
::
SPARSE
);
source
->
SetDiagonal
(
1.0
);
source
->
SetSuperDiagonal
(
0.5
);
source
->
SetSubDiagonal
(
-
0.5
);
source
->
Update
();
vtkSparseArray
<
double
>*
const
sparse_array
=
vtkSparseArray
<
double
>::
SafeDownCast
(
source
->
GetOutput
()
->
GetArray
());
cout
<<
"sparse diagonal matrix:
\n
"
;
vtkPrintMatrixFormat
(
cout
,
sparse_array
);
test_expression
(
sparse_array
);
test_expression
(
sparse_array
->
GetValue
(
vtkArrayCoordinates
(
0
,
0
))
==
1.0
);
test_expression
(
sparse_array
->
GetValue
(
vtkArrayCoordinates
(
1
,
0
))
==
-
0.5
);
test_expression
(
sparse_array
->
GetValue
(
vtkArrayCoordinates
(
2
,
0
))
==
0.0
);
test_expression
(
sparse_array
->
GetValue
(
vtkArrayCoordinates
(
0
,
1
))
==
0.5
);
test_expression
(
sparse_array
->
GetValue
(
vtkArrayCoordinates
(
1
,
1
))
==
1.0
);
test_expression
(
sparse_array
->
GetValue
(
vtkArrayCoordinates
(
2
,
1
))
==
-
0.5
);
test_expression
(
sparse_array
->
GetValue
(
vtkArrayCoordinates
(
0
,
2
))
==
0.0
);
test_expression
(
sparse_array
->
GetValue
(
vtkArrayCoordinates
(
1
,
2
))
==
0.5
);
test_expression
(
sparse_array
->
GetValue
(
vtkArrayCoordinates
(
2
,
2
))
==
1.0
);
source
->
SetArrayType
(
vtkDiagonalMatrixSource
::
DENSE
);
source
->
Update
();
vtkDenseArray
<
double
>*
const
dense_array
=
vtkDenseArray
<
double
>::
SafeDownCast
(
source
->
GetOutput
()
->
GetArray
());
cout
<<
"dense diagonal matrix:
\n
"
;
vtkPrintMatrixFormat
(
cout
,
dense_array
);
test_expression
(
dense_array
);
test_expression
(
dense_array
->
GetValue
(
vtkArrayCoordinates
(
0
,
0
))
==
1.0
);
test_expression
(
dense_array
->
GetValue
(
vtkArrayCoordinates
(
1
,
0
))
==
-
0.5
);
test_expression
(
dense_array
->
GetValue
(
vtkArrayCoordinates
(
2
,
0
))
==
0.0
);
test_expression
(
dense_array
->
GetValue
(
vtkArrayCoordinates
(
0
,
1
))
==
0.5
);
test_expression
(
dense_array
->
GetValue
(
vtkArrayCoordinates
(
1
,
1
))
==
1.0
);
test_expression
(
dense_array
->
GetValue
(
vtkArrayCoordinates
(
2
,
1
))
==
-
0.5
);
test_expression
(
dense_array
->
GetValue
(
vtkArrayCoordinates
(
0
,
2
))
==
0.0
);
test_expression
(
dense_array
->
GetValue
(
vtkArrayCoordinates
(
1
,
2
))
==
0.5
);
test_expression
(
dense_array
->
GetValue
(
vtkArrayCoordinates
(
2
,
2
))
==
1.0
);
return
0
;
}
catch
(
vtkstd
::
exception
&
e
)
{
cerr
<<
e
.
what
()
<<
endl
;
return
1
;
}
}
Infovis/Testing/Cxx/ArrayExtractFactoredArray.cxx
0 → 100644
View file @
8df357b8
/*=========================================================================
Program: Visualization Toolkit
Module: ArrayExtractFactoredArray.cxx
-------------------------------------------------------------------------
Copyright 2008 Sandia Corporation.
Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
the U.S. Government retains certain rights in this software.
-------------------------------------------------------------------------
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 <vtkArrayData.h>
#include <vtkArrayPrint.h>
#include <vtkExtractFactoredArray.h>
#include <vtkFactoredArrayData.h>
#include <vtkSmartPointer.h>
#include <vtkSparseArray.h>
#include <vtksys/ios/iostream>
#include <vtksys/stl/stdexcept>
#define test_expression(expression) \
{ \
if(!(expression)) \
throw vtkstd::runtime_error("Expression failed: " #expression); \
}
int
ArrayExtractFactoredArray
(
int
argc
,
char
*
argv
[])
{
try
{
vtkSmartPointer
<
vtkSparseArray
<
double
>
>
a
=
vtkSmartPointer
<
vtkSparseArray
<
double
>
>::
New
();
vtkSmartPointer
<
vtkSparseArray
<
double
>
>
b
=
vtkSmartPointer
<
vtkSparseArray
<
double
>
>::
New
();
vtkSmartPointer
<
vtkFactoredArrayData
>
factored
=
vtkSmartPointer
<
vtkFactoredArrayData
>::
New
();
factored
->
AddArray
(
a
);
factored
->
AddArray
(
b
);
vtkSmartPointer
<
vtkExtractFactoredArray
>
extract
=
vtkSmartPointer
<
vtkExtractFactoredArray
>::
New
();
extract
->
AddInputConnection
(
factored
->
GetProducerPort
());
extract
->
SetIndex
(
0
);
extract
->
Update
();
test_expression
(
extract
->
GetOutput
()
->
GetArray
()
==
a
.
GetPointer
());
extract
->
SetIndex
(
1
);
extract
->
Update
();
test_expression
(
extract
->
GetOutput
()
->
GetArray
()
==
b
.
GetPointer
());
return
0
;
}
catch
(
vtkstd
::
exception
&
e
)
{
cout
<<
e
.
what
()
<<
endl
;
return
1
;
}
}
Infovis/Testing/Cxx/ArrayMatricizeArray.cxx
0 → 100644
View file @
8df357b8
/*=========================================================================
Program: Visualization Toolkit
Module: ArrayMatricizeArray.cxx
-------------------------------------------------------------------------
Copyright 2008 Sandia Corporation.
Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
the U.S. Government retains certain rights in this software.
-------------------------------------------------------------------------
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 <vtkArrayData.h>
#include <vtkArrayPrint.h>
#include <vtkMatricizeArray.h>
#include <vtkSmartPointer.h>
#include <vtkSparseArray.h>
#include <vtksys/ios/iostream>
#include <vtksys/stl/stdexcept>
#define test_expression(expression) \
{ \
if(!(expression)) \
throw vtkstd::runtime_error("Expression failed: " #expression); \
}
int
ArrayMatricizeArray
(
int
argc
,
char
*
argv
[])
{
try
{
// Create an array ...
vtkSmartPointer
<
vtkSparseArray
<
double
>
>
array
=
vtkSmartPointer
<
vtkSparseArray
<
double
>
>::
New
();
array
->
Resize
(
vtkArrayExtents
(
2
,
2
,
2
));
double
value
=
0
;
const
vtkArrayExtents
extents
=
array
->
GetExtents
();
for
(
int
i
=
0
;
i
!=
extents
[
0
];
++
i
)
{
for
(
int
j
=
0
;
j
!=
extents
[
1
];
++
j
)
{
for
(
int
k
=
0
;
k
!=
extents
[
2
];
++
k
)
{
array
->
AddValue
(
vtkArrayCoordinates
(
i
,
j
,
k
),
value
++
);
}
}
}
cout
<<
"array source:
\n
"
;
vtkPrintCoordinateFormat
(
cout
,
array
.
GetPointer
());
// Create an array data object to hold it ...
vtkSmartPointer
<
vtkArrayData
>
array_data
=
vtkSmartPointer
<
vtkArrayData
>::
New
();
array_data
->
SetArray
(
array
);
// Matricize it ...
vtkSmartPointer
<
vtkMatricizeArray
>
matricize
=
vtkSmartPointer
<
vtkMatricizeArray
>::
New
();
matricize
->
SetInput
(
array_data
);
matricize
->
SetSliceDimension
(
0
);
matricize
->
Update
();
vtkSparseArray
<
double
>*
const
matricized_array
=
vtkSparseArray
<
double
>::
SafeDownCast
(
matricize
->
GetOutput
()
->
GetArray
());
test_expression
(
matricized_array
);
cout
<<
"matricize output:
\n
"
;
vtkPrintCoordinateFormat
(
cout
,
matricized_array
);
test_expression
(
matricized_array
->
GetValue
(
vtkArrayCoordinates
(
0
,
0
))
==
0
);
test_expression
(
matricized_array
->
GetValue
(
vtkArrayCoordinates
(
0
,
1
))
==
1
);
test_expression
(
matricized_array
->
GetValue
(
vtkArrayCoordinates
(
0
,
2
))
==
2
);
test_expression
(
matricized_array
->
GetValue
(
vtkArrayCoordinates
(
0
,
3
))
==
3
);
test_expression
(
matricized_array
->
GetValue
(
vtkArrayCoordinates
(
1
,
0
))
==
4
);
test_expression
(
matricized_array
->
GetValue
(
vtkArrayCoordinates
(
1
,
1
))
==
5
);
test_expression
(
matricized_array
->
GetValue
(
vtkArrayCoordinates
(
1
,
2
))
==
6
);
test_expression
(
matricized_array
->
GetValue
(
vtkArrayCoordinates
(
1
,
3
))
==
7
);
return
0
;
}
catch
(
vtkstd
::
exception
&
e
)
{
cout
<<
e
.
what
()
<<
endl
;
return
1
;
}
}
Infovis/Testing/Cxx/ArrayMatrixColumnNorm.cxx
0 → 100644
View file @
8df357b8
/*=========================================================================
Program: Visualization Toolkit
Module: ArrayMatrixColumnNorm.cxx
-------------------------------------------------------------------------
Copyright 2008 Sandia Corporation.
Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
the U.S. Government retains certain rights in this software.
-------------------------------------------------------------------------
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 <vtkArrayData.h>
#include <vtkArrayPrint.h>
#include <vtkMatrixColumnNorm.h>
#include <vtkDenseArray.h>
#include <vtkDiagonalMatrixSource.h>
#include <vtkSmartPointer.h>
#include <vtkSparseArray.h>
#include <vtksys/ios/iostream>
#include <vtksys/stl/stdexcept>
#define test_expression(expression) \
{ \
if(!(expression)) \
throw vtkstd::runtime_error("Expression failed: " #expression); \
}
static
const
bool
close_enough
(
const
double
lhs
,
const
double
rhs
)
{
return
fabs
(
lhs
-
rhs
)
<
1.0e-12
;
}
int
ArrayMatrixColumnNorm
(
int
argc
,
char
*
argv
[])
{
cout
<<
setprecision
(
17
);
try
{
vtkSmartPointer
<
vtkDiagonalMatrixSource
>
source
=
vtkSmartPointer
<
vtkDiagonalMatrixSource
>::
New
();
source
->
SetExtents
(
3
);
source
->
SetArrayType
(
vtkDiagonalMatrixSource
::
SPARSE
);