Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VTK
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jens Munk Hansen
VTK
Commits
a47b7be0
Commit
a47b7be0
authored
4 weeks ago
by
Mathieu Westphal (Kitware)
Browse files
Options
Downloads
Patches
Plain Diff
Tests: Adding a vtkProbeFilter test for oriented images
parent
00733b9d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Filters/Core/Testing/Cxx/TestProbeFilter.cxx
+66
-8
66 additions, 8 deletions
Filters/Core/Testing/Cxx/TestProbeFilter.cxx
with
66 additions
and
8 deletions
Filters/Core/Testing/Cxx/TestProbeFilter.cxx
+
66
−
8
View file @
a47b7be0
...
...
@@ -4,18 +4,20 @@
#include
"vtkArrayCalculator.h"
#include
"vtkDataArray.h"
#include
"vtkDataSet.h"
#include
"vtkImageData.h"
#include
"vtkLineSource.h"
#include
"vtkNew.h"
#include
"vtkPointData.h"
#include
"vtkProbeFilter.h"
#include
"vtkRTAnalyticSource.h"
// Gets the number of points the probe filter counted as valid.
// The parameter should be the output of the probe filter
int
GetNumberOfValidPoints
(
vtkDataSet
*
pd
)
vtkIdType
GetNumberOfValidPoints
(
vtkDataSet
*
pd
)
{
vtkDataArray
*
data
=
pd
->
GetPointData
()
->
GetScalars
(
"vtkValidPointMask"
);
int
numValid
=
0
;
for
(
int
i
=
0
;
i
<
data
->
GetNumberOfTuples
();
++
i
)
vtkIdType
numValid
=
0
;
for
(
vtkIdType
i
=
0
;
i
<
data
->
GetNumberOfTuples
();
++
i
)
{
if
(
data
->
GetVariantValue
(
i
).
ToDouble
()
==
1
)
{
...
...
@@ -25,8 +27,27 @@ int GetNumberOfValidPoints(vtkDataSet* pd)
return
numValid
;
}
bool
TestProbeFilterWithProvidedData
(
vtkDataSet
*
input
,
vtkDataSet
*
source
,
vtkIdType
expectedNValidPoints
)
{
vtkNew
<
vtkProbeFilter
>
probe
;
probe
->
SetInputData
(
input
);
probe
->
SetSourceData
(
source
);
probe
->
Update
();
vtkIdType
nValidPoints
=
GetNumberOfValidPoints
(
probe
->
GetOutput
());
if
(
nValidPoints
!=
expectedNValidPoints
)
{
std
::
cerr
<<
"Unexpected number of valid points, got "
<<
nValidPoints
<<
" instead of "
<<
expectedNValidPoints
<<
std
::
endl
;
return
false
;
}
return
true
;
}
// Tests the CompteThreshold and Threshold parameters on the vtkProbeFilter
int
TestProbeFilterThreshold
()
bool
TestProbeFilterThreshold
()
{
vtkNew
<
vtkLineSource
>
line1
;
line1
->
SetPoint1
(
-
1
,
0
,
0
);
...
...
@@ -51,7 +72,7 @@ int TestProbeFilterThreshold()
int
validDefault
=
GetNumberOfValidPoints
(
probe
->
GetOutput
());
if
(
validDefault
!=
2
)
{
return
1
;
return
false
;
}
// turn off computing tolerance and set it to 11 times what is was.
// 11 is magic number to get all the points within line1 selected.
...
...
@@ -63,19 +84,56 @@ int TestProbeFilterThreshold()
if
(
validNext
!=
11
)
{
return
1
;
return
false
;
}
// threshold is still set high, but we tell it to ignore it
probe
->
SetComputeTolerance
(
true
);
probe
->
Update
();
int
validIgnore
=
GetNumberOfValidPoints
(
probe
->
GetOutput
());
return
(
validIgnore
==
2
)
?
0
:
1
;
return
(
validIgnore
==
2
)
?
true
:
false
;
}
// Test probing one image into another
bool
TestProbeFilterWithImages
()
{
// Create Pipeline
vtkNew
<
vtkRTAnalyticSource
>
wavelet
;
wavelet
->
SetWholeExtent
(
0
,
16
,
0
,
16
,
0
,
16
);
wavelet
->
SetCenter
(
8
,
8
,
8
);
wavelet
->
Update
();
vtkNew
<
vtkImageData
>
img
;
img
->
SetExtent
(
1
,
15
,
1
,
15
,
1
,
15
);
img
->
SetOrigin
(
1
,
1
,
1
);
return
TestProbeFilterWithProvidedData
(
img
,
wavelet
->
GetOutput
(),
3375
);
}
// Test probing one image into an oriented one
bool
TestProbeFilterWithOrientedImages
()
{
// Create Pipeline
vtkNew
<
vtkRTAnalyticSource
>
wavelet
;
wavelet
->
SetWholeExtent
(
0
,
16
,
0
,
16
,
0
,
16
);
wavelet
->
SetCenter
(
8
,
8
,
8
);
wavelet
->
Update
();
vtkNew
<
vtkImageData
>
img
;
img
->
SetExtent
(
1
,
15
,
1
,
15
,
1
,
15
);
img
->
SetOrigin
(
1
,
1
,
1
);
img
->
SetDirectionMatrix
(
0.7
,
-
0.7
,
0
,
0.7
,
0.7
,
0
,
0
,
0
,
1
);
return
TestProbeFilterWithProvidedData
(
img
,
wavelet
->
GetOutput
(),
1575
);
}
// Currently only tests the ComputeThreshold and Threshold. Other tests
// should be added
int
TestProbeFilter
(
int
,
char
*
[])
{
return
TestProbeFilterThreshold
();
bool
status
=
true
;
status
&=
TestProbeFilterThreshold
();
status
&=
TestProbeFilterWithImages
();
status
&=
TestProbeFilterWithOrientedImages
();
return
status
?
EXIT_SUCCESS
:
EXIT_FAILURE
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment