Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
otb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Julien Cabieces
otb
Commits
c0ec5f40
Commit
c0ec5f40
authored
13 years ago
by
Guillaume Pasero
Browse files
Options
Downloads
Patches
Plain Diff
BUG: third fix for the GetImage_called_twice problem
parent
2a54a856
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Code/ApplicationEngine/otbWrapperInputImageParameter.cxx
+46
-18
46 additions, 18 deletions
Code/ApplicationEngine/otbWrapperInputImageParameter.cxx
Code/ApplicationEngine/otbWrapperInputImageParameter.h
+3
-0
3 additions, 0 deletions
Code/ApplicationEngine/otbWrapperInputImageParameter.h
with
49 additions
and
18 deletions
Code/ApplicationEngine/otbWrapperInputImageParameter.cxx
+
46
−
18
View file @
c0ec5f40
...
...
@@ -33,6 +33,7 @@ InputImageParameter::InputImageParameter()
this
->
SetKey
(
"in"
);
m_FileName
=
""
;
m_PreviousFileName
=
""
;
m_UseFilename
=
true
;
this
->
ClearValue
();
}
...
...
@@ -64,6 +65,7 @@ InputImageParameter::SetFromFileName(const std::string& filename)
// the specified filename is valid => store the value
m_FileName
=
filename
;
m_UseFilename
=
true
;
SetActive
(
true
);
return
true
;
}
...
...
@@ -114,31 +116,54 @@ InputImageParameter::GetImage()
// Used m_PreviousFileName because if not, when the user call twice GetImage,
// it without changing the filename, it returns 2 different
// image pointers
// TODO : how do we deal with 2 GetImage with 2 defferent template???
// Should be handled by the CastImage< > macro
// Only one image type can be used
// 2 cases : the user set a filename vs. the user set an image
if
(
m_PreviousFileName
!=
m_
File
N
ame
&&
!
m_FileName
.
empty
()
)
if
(
m_Use
File
n
ame
)
{
//////////////////////// Filename case:
m_PreviousFileName
=
m_FileName
;
typedef
otb
::
ImageFileReader
<
TOutputImage
>
ReaderType
;
typename
ReaderType
::
Pointer
reader
=
ReaderType
::
New
();
reader
->
SetFileName
(
m_FileName
);
try
if
(
m_PreviousFileName
!=
m_FileName
&&
!
m_FileName
.
empty
()
)
{
reader
->
UpdateOutputInformation
();
//////////////////////// Filename case:
// A new valid filename has been given : a reader is created
m_PreviousFileName
=
m_FileName
;
typedef
otb
::
ImageFileReader
<
TOutputImage
>
ReaderType
;
typename
ReaderType
::
Pointer
reader
=
ReaderType
::
New
();
reader
->
SetFileName
(
m_FileName
);
try
{
reader
->
UpdateOutputInformation
();
}
catch
(
itk
::
ExceptionObject
&
)
{
this
->
ClearValue
();
}
m_Image
=
reader
->
GetOutput
();
m_Reader
=
reader
;
// Pay attention, don't return m_Image because it is a ImageBase...
return
reader
->
GetOutput
();
}
catch
(
itk
::
ExceptionObject
&
)
else
{
this
->
ClearValue
();
// In this case, the reader and the image should already be there
if
(
m_Image
.
IsNull
())
{
itkExceptionMacro
(
"No input image or filename detected..."
);
}
else
{
// Check if the image type asked here is the same as the one used for the reader
if
(
dynamic_cast
<
TOutputImage
*>
(
m_Image
.
GetPointer
()))
{
return
dynamic_cast
<
TOutputImage
*>
(
m_Image
.
GetPointer
());
}
else
{
itkExceptionMacro
(
"Cannot ask a different image type"
);
}
}
}
m_Image
=
reader
->
GetOutput
();
m_Reader
=
reader
;
// Pay attention, don't return m_Image because it is a ImageBase...
return
reader
->
GetOutput
();
}
else
{
...
...
@@ -331,6 +356,7 @@ otbGenericCastImageMacro(DoubleImageType, CastVectorImageFromImage, Vector)
void
InputImageParameter
::
SetImage
(
FloatVectorImageType
*
image
)
{
m_UseFilename
=
false
;
this
->
SetImage
<
FloatVectorImageType
>
(
image
);
}
...
...
@@ -339,6 +365,7 @@ template <class TInputImage>
void
InputImageParameter
::
SetImage
(
TInputImage
*
image
)
{
m_UseFilename
=
false
;
m_Image
=
image
;
}
...
...
@@ -360,6 +387,7 @@ InputImageParameter::ClearValue()
m_Caster
=
NULL
;
m_FileName
=
""
;
m_PreviousFileName
=
""
;
m_UseFilename
=
true
;
}
...
...
This diff is collapsed.
Click to expand it.
Code/ApplicationEngine/otbWrapperInputImageParameter.h
+
3
−
0
View file @
c0ec5f40
...
...
@@ -158,6 +158,9 @@ private:
/** Store the loaded image filename */
std
::
string
m_PreviousFileName
;
/** flag : are we using a filename or an image pointer as an input */
bool
m_UseFilename
;
};
// End class InputImage Parameter
}
// End namespace Wrapper
...
...
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