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
4bff9a5f
Commit
4bff9a5f
authored
5 years ago
by
Antoine Regimbeau
Browse files
Options
Downloads
Patches
Plain Diff
TEST: add log
parent
e1501ddb
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
Modules/Applications/AppMathParserX/test/otbBandMathXAppTests.cxx
+36
-31
36 additions, 31 deletions
...Applications/AppMathParserX/test/otbBandMathXAppTests.cxx
with
36 additions
and
31 deletions
Modules/Applications/AppMathParserX/test/otbBandMathXAppTests.cxx
+
36
−
31
View file @
4bff9a5f
...
@@ -50,48 +50,60 @@ VectorImageType::Pointer create_vector_image( int pxl_s , int nb_comp , unsigned
...
@@ -50,48 +50,60 @@ VectorImageType::Pointer create_vector_image( int pxl_s , int nb_comp , unsigned
return
image
;
return
image
;
}
}
#define dyn_cast( im_base , vect_im ) \
{ \
vect_im = dynamic_cast<otb::VectorImage<float> *>(im_base); \
if( ! vect_im ) \
{ \
std::cout<<"Not the right conversion, cannot retrieve the output"<<std::endl; \
return EXIT_FAILURE ; \
} \
}
int
main
(
int
,
char
*
argv
[]
)
int
main
(
int
,
char
*
argv
[]
)
{
{
std
::
cout
<<
"Begin bandMathX Test"
<<
std
::
endl
;
int
return_val
=
0
;
int
return_val
=
0
;
auto
img1
=
create_vector_image
(
5
,
2
,
1
);
auto
img1
=
create_vector_image
(
5
,
2
,
1
);
auto
img2
=
create_vector_image
(
5
,
1
,
2
);
auto
img2
=
create_vector_image
(
5
,
1
,
2
);
VectorImageType
::
IndexType
index
;
VectorImageType
::
IndexType
index
;
index
.
Fill
(
3
);
// Center of the images
index
.
Fill
(
3
);
// Center of the images
std
::
cout
<<
"Create application"
<<
std
::
endl
;
auto
app
=
otb
::
Wrapper
::
ApplicationRegistry
::
CreateApplication
(
"BandMathX"
);
auto
app
=
otb
::
Wrapper
::
ApplicationRegistry
::
CreateApplication
(
"BandMathX"
);
app
->
AddImageToParameterInputImageList
(
"il"
,
img1
);
app
->
AddImageToParameterInputImageList
(
"il"
,
img1
);
app
->
UpdateParameters
();
app
->
UpdateParameters
();
app
->
AddImageToParameterInputImageList
(
"il"
,
img2
);
app
->
AddImageToParameterInputImageList
(
"il"
,
img2
);
app
->
UpdateParameters
();
app
->
UpdateParameters
();
std
::
cout
<<
"Inputs are set"
<<
std
::
endl
;
// Case one: only expression
// Case one: only expression
app
->
SetParameterString
(
"exp"
,
"im1b1+im2b1"
);
app
->
SetParameterString
(
"exp"
,
"im1b1+im2b1"
);
app
->
UpdateParameters
();
app
->
UpdateParameters
();
app
->
SetParameterOutputImagePixelType
(
"out"
,
otb
::
Wrapper
::
ImagePixelType
::
ImagePixelType_uint8
);
app
->
SetParameterOutputImagePixelType
(
"out"
,
otb
::
Wrapper
::
ImagePixelType
::
ImagePixelType_uint8
);
std
::
cout
<<
"Case one: parameter exp is set"
<<
std
::
endl
;
app
->
Execute
();
app
->
Execute
();
auto
output
=
app
->
GetParameterImageBase
(
"out"
);
auto
output
=
app
->
GetParameterImageBase
(
"out"
);
output
->
Update
();
output
->
Update
();
float
im_val
=
0
;
float
im_val
=
0
;
// We need to be carefull as we are taking the direct output of the underlying
// We need to be carefull as we are taking the direct output of the underlying
// filter in the application
// filter in the application
auto
output_int
=
dynamic_cast
<
otb
::
VectorImage
<
float
>
*>
(
output
);
otb
::
VectorImage
<
float
>
*
output_int
=
nullptr
;
if
(
output_int
)
// this need to crash if not the case
dyn_cast
(
output
,
output_int
)
im_val
=
output_int
->
GetPixel
(
index
).
GetElement
(
0
);
if
(
im_val
!=
3
)
{
{
im_val
=
output_int
->
GetPixel
(
index
).
GetElement
(
0
);
std
::
cout
<<
"Wrong value in test, was expecting 3, got "
<<
im_val
<<
std
::
endl
;
if
(
im_val
!=
3
)
return_val
++
;
{
std
::
cout
<<
"Wrong value in test, was expecting 3, got "
<<
im_val
<<
std
::
endl
;
return_val
++
;
}
}
}
else
else
{
{
std
::
cout
<<
"Not the right conversion, cannot retrieve the output"
<<
std
::
endl
;
std
::
cout
<<
"Case one passed"
<<
std
::
endl
;
return
EXIT_FAILURE
;
}
}
// Case two: expression and context
// Case two: expression and context
app
->
SetParameterString
(
"exp"
,
"im1b1+val-im2b1"
);
app
->
SetParameterString
(
"exp"
,
"im1b1+val-im2b1"
);
app
->
UpdateParameters
();
app
->
UpdateParameters
();
std
::
cout
<<
"Case two: use context to define a constant"
<<
std
::
endl
;
auto
desc
=
app
->
GetParameterDescription
(
"exp"
);
auto
desc
=
app
->
GetParameterDescription
(
"exp"
);
if
(
desc
.
find
(
"Following variables not allowed : val"
)
==
std
::
string
::
npos
)
if
(
desc
.
find
(
"Following variables not allowed : val"
)
==
std
::
string
::
npos
)
{
{
...
@@ -119,25 +131,22 @@ int main(int , char * argv[] )
...
@@ -119,25 +131,22 @@ int main(int , char * argv[] )
output
->
Update
();
output
->
Update
();
// We need to be carefull as we are taking the direct output of the underlying
// We need to be carefull as we are taking the direct output of the underlying
// filter in the application
// filter in the application
output_int
=
dynamic_cast
<
otb
::
VectorImage
<
float
>
*>
(
output
);
dyn_cast
(
output
,
output_int
)
if
(
output_int
)
// this need to crash if not the case
im_val
=
output_int
->
GetPixel
(
index
).
GetElement
(
0
);
if
(
im_val
!=
0
)
{
{
im_val
=
output_int
->
GetPixel
(
index
).
GetElement
(
0
);
std
::
cout
<<
"Wrong value in test, was expecting 0, got "
<<
im_val
<<
std
::
endl
;
if
(
im_val
!=
0
)
return_val
++
;
{
std
::
cout
<<
"Wrong value in test, was expecting 0, got "
<<
im_val
<<
std
::
endl
;
return_val
++
;
}
}
}
else
else
{
{
std
::
cout
<<
"Not the right conversion, cannot retrieve the output"
<<
std
::
endl
;
std
::
cout
<<
"Case two passed"
<<
std
::
endl
;
return
EXIT_FAILURE
;
}
}
// Case three: no expression and context
// Case three: no expression and context
app
->
SetParameterString
(
"exp"
,
""
);
app
->
SetParameterString
(
"exp"
,
""
);
app
->
UpdateParameters
();
app
->
UpdateParameters
();
std
::
cout
<<
"Case three: no parameter exp"
<<
std
::
endl
;
auto
exp
=
app
->
GetParameterString
(
"exp"
);
auto
exp
=
app
->
GetParameterString
(
"exp"
);
if
(
exp
.
find
(
"im1b1 + 2*val + im2b1"
)
==
std
::
string
::
npos
)
if
(
exp
.
find
(
"im1b1 + 2*val + im2b1"
)
==
std
::
string
::
npos
)
{
{
...
@@ -151,20 +160,16 @@ int main(int , char * argv[] )
...
@@ -151,20 +160,16 @@ int main(int , char * argv[] )
output
->
Update
();
output
->
Update
();
// We need to be carefull as we are taking the direct output of the underlying
// We need to be carefull as we are taking the direct output of the underlying
// filter in the application
// filter in the application
output_int
=
dynamic_cast
<
otb
::
VectorImage
<
float
>
*>
(
output
);
dyn_cast
(
output
,
output_int
)
if
(
output_int
)
// this need to crash if not the case
im_val
=
output_int
->
GetPixel
(
index
).
GetElement
(
0
);
if
(
im_val
!=
5
)
{
{
im_val
=
output_int
->
GetPixel
(
index
).
GetElement
(
0
);
std
::
cout
<<
"Wrong value in test, was expecting 5, got "
<<
im_val
<<
std
::
endl
;
if
(
im_val
!=
5
)
return_val
++
;
{
std
::
cout
<<
"Wrong value in test, was expecting 5, got "
<<
im_val
<<
std
::
endl
;
return_val
++
;
}
}
}
else
else
{
{
std
::
cout
<<
"Not the right conversion, cannot retrieve the output"
<<
std
::
endl
;
std
::
cout
<<
"Case three passed"
<<
std
::
endl
;
return
EXIT_FAILURE
;
}
}
return
return_val
;
return
return_val
;
}
}
\ No newline at end of file
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