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
Brénainn Woodsend
VTK
Commits
64c07e78
Commit
64c07e78
authored
3 years ago
by
Sankhesh Jhaveri
Browse files
Options
Downloads
Patches
Plain Diff
Initialize output to copy of first input scalars
parent
0b869a23
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
Imaging/Math/vtkImageMathematics.cxx
+58
-9
58 additions, 9 deletions
Imaging/Math/vtkImageMathematics.cxx
with
58 additions
and
9 deletions
Imaging/Math/vtkImageMathematics.cxx
+
58
−
9
View file @
64c07e78
...
...
@@ -15,10 +15,12 @@
#include
"vtkImageMathematics.h"
#include
"vtkAlgorithmOutput.h"
#include
"vtkDataArray.h"
#include
"vtkImageData.h"
#include
"vtkInformation.h"
#include
"vtkInformationVector.h"
#include
"vtkObjectFactory.h"
#include
"vtkPointData.h"
#include
"vtkStreamingDemandDrivenPipeline.h"
#include
<cmath>
...
...
@@ -83,8 +85,6 @@ int vtkImageMathematics::RequestInformation(vtkInformation* vtkNotUsed(request),
{
// get the info objects
vtkInformation
*
outInfo
=
outputVector
->
GetInformationObject
(
0
);
// vtkInformation* inInfo = inputVector[0]->GetInformationObject(0);
// vtkInformation* inInfo2 = inputVector[1]->GetInformationObject(0);
vtkInformation
*
inInfo
;
int
c
,
idx
;
...
...
@@ -99,12 +99,6 @@ int vtkImageMathematics::RequestInformation(vtkInformation* vtkNotUsed(request),
this
->
Operation
==
VTK_MULTIPLY
||
this
->
Operation
==
VTK_DIVIDE
||
this
->
Operation
==
VTK_MIN
||
this
->
Operation
==
VTK_MAX
||
this
->
Operation
==
VTK_ATAN2
)
{
if
(
this
->
GetNumberOfInputConnections
(
0
)
<
2
)
{
vtkErrorMacro
(
<<
"Second input must be specified for this operation."
);
return
1
;
}
for
(
c
=
0
;
c
<
this
->
GetNumberOfInputConnections
(
0
);
++
c
)
{
inInfo
=
inputVector
[
0
]
->
GetInformationObject
(
c
);
...
...
@@ -390,6 +384,54 @@ void vtkImageMathematicsExecute2(vtkImageMathematics* self, vtkImageData* inData
}
}
//------------------------------------------------------------------------------
template
<
class
T
>
void
vtkImageMathematicsInitOutput
(
vtkImageData
*
inData
,
T
*
inPtr
,
vtkImageData
*
vtkNotUsed
(
outData
),
T
*
outPtr
,
int
ext
[
6
])
{
int
idxY
,
idxZ
;
int
maxY
,
maxZ
;
vtkIdType
outIncY
,
outIncZ
;
int
rowLength
;
int
typeSize
;
T
*
outPtrZ
,
*
outPtrY
;
T
*
inPtrZ
,
*
inPtrY
;
// This method needs to copy scalars from input to output for the update-extent.
vtkDataArray
*
inArray
=
inData
->
GetPointData
()
->
GetScalars
();
typeSize
=
vtkDataArray
::
GetDataTypeSize
(
inArray
->
GetDataType
());
outPtrZ
=
outPtr
;
inPtrZ
=
inPtr
;
// Get increments to march through data
vtkIdType
increments
[
3
];
increments
[
0
]
=
inArray
->
GetNumberOfComponents
();
increments
[
1
]
=
increments
[
0
]
*
(
ext
[
1
]
-
ext
[
0
]
+
1
);
increments
[
2
]
=
increments
[
1
]
*
(
ext
[
3
]
-
ext
[
2
]
+
1
);
outIncY
=
increments
[
1
];
outIncZ
=
increments
[
2
];
// Find the region to loop over
rowLength
=
(
ext
[
1
]
-
ext
[
0
]
+
1
)
*
inArray
->
GetNumberOfComponents
();
rowLength
*=
typeSize
;
maxY
=
ext
[
3
]
-
ext
[
2
];
maxZ
=
ext
[
5
]
-
ext
[
4
];
// Loop through input pixels
for
(
idxZ
=
0
;
idxZ
<=
maxZ
;
idxZ
++
)
{
outPtrY
=
outPtrZ
;
inPtrY
=
inPtrZ
;
for
(
idxY
=
0
;
idxY
<=
maxY
;
idxY
++
)
{
memcpy
(
outPtrY
,
inPtrY
,
rowLength
);
outPtrY
+=
outIncY
;
inPtrY
+=
outIncY
;
}
outPtrZ
+=
outIncZ
;
inPtrZ
+=
outIncZ
;
}
}
//------------------------------------------------------------------------------
// This method is passed a input and output datas, and executes the filter
// algorithm to fill the output from the inputs.
...
...
@@ -432,7 +474,14 @@ void vtkImageMathematics::ThreadedRequestData(vtkInformation* vtkNotUsed(request
}
if
(
idx1
==
0
)
{
outData
[
0
]
->
DeepCopy
(
inData
[
0
][
idx1
]);
switch
(
inData
[
0
][
idx1
]
->
GetScalarType
())
{
vtkTemplateMacro
(
vtkImageMathematicsInitOutput
(
inData
[
0
][
idx1
],
static_cast
<
VTK_TT
*>
(
inPtr1
),
outData
[
0
],
static_cast
<
VTK_TT
*>
(
outPtr
),
outExt
));
default:
vtkErrorMacro
(
<<
"InitOutput: Unknown ScalarType"
);
return
;
}
}
else
{
...
...
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