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
Container Registry
Model registry
Operate
Environments
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
Antoine Belvire
otb
Commits
a192546b
Commit
a192546b
authored
18 years ago
by
Patrick Imbo
Browse files
Options
Downloads
Patches
Plain Diff
No commit message
No commit message
parent
1be957db
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Code/IO/otbONERAImageIO.cxx
+21
-27
21 additions, 27 deletions
Code/IO/otbONERAImageIO.cxx
Code/IO/otbONERAImageIO.h
+6
-15
6 additions, 15 deletions
Code/IO/otbONERAImageIO.h
with
27 additions
and
42 deletions
Code/IO/otbONERAImageIO.cxx
+
21
−
27
View file @
a192546b
...
...
@@ -9,20 +9,17 @@
$Id$
=========================================================================*/
#include
"itkExceptionObject.h"
#include
"itkMacro.h"
#include
"otbONERAImageIO.h"
#include
"itkByteSwapper.h"
#include
<itksys/SystemTools.hxx>
#include
<string.h>
// for strncpy
#include
<iostream.h>
#include
<string.h>
#
#include
"otbONERAImageIO.h"
#include
"itkExceptionObject.h"
#include
"otbMacro.h"
#include
<sys/types.h>
#include
<dirent.h>
#include
"itkMacro.h"
#define ONERA_MAGIC_NUMBER 33554433
#define ONERA_HEADER_LENGTH 0
#define ONERA_FILE_ID_OFFSET 0
namespace
otb
...
...
@@ -46,20 +43,19 @@ ONERAImageIO::ONERAImageIO()
m_Origin
[
1
]
=
0.0
;
m_currentfile
=
NULL
;
m_poBands
=
NULL
;
}
ONERAImageIO
::~
ONERAImageIO
()
{
if
(
m_poBands
!=
NULL
)
delete
[]
m_poBands
;
}
bool
ONERAImageIO
::
CanReadFile
(
const
char
*
filename
)
{
// First check the filename extension
std
::
string
fname
=
filename
;
std
::
ifstream
file
;
std
::
string
fname
(
filename
);
if
(
fname
==
""
)
{
otbDebugMacro
(
<<
"No filename specified."
);
...
...
@@ -134,20 +130,20 @@ void ONERAImageIO::Read(void* buffer)
//read header information file:
this
->
OpenOneraDataFileForReading
(
file
,
m_FileName
.
c_str
());
int
HeaderLength
=
ONERA_HEADER_LENGTH
+
4
+
4
*
2
*
m_
W
idth
;
int
HeaderLength
=
ONERA_HEADER_LENGTH
+
4
+
4
*
2
*
m_
w
idth
;
file
.
seekg
(
HeaderLength
,
std
::
ios
::
beg
);
if
(
!
this
->
ReadBufferAsBinary
(
file
,
buffer
,
this
->
GetImageSizeInBytes
())
)
{
otb
ExceptionMacro
(
<<
"Read failed: Wanted "
<<
this
->
GetImageSizeInBytes
()
itk
ExceptionMacro
(
<<
"Read failed: Wanted "
<<
this
->
GetImageSizeInBytes
()
<<
" bytes, but read "
<<
file
.
gcount
()
<<
" bytes."
);
}
//byte swapping depending on pixel type:
if
(
this
->
GetComponentType
()
==
FLOAT
)
{
ByteSwapper
<
float
>::
SwapRangeFromSystemToBigEndian
(
itk
::
ByteSwapper
<
float
>::
SwapRangeFromSystemToBigEndian
(
reinterpret_cast
<
float
*>
(
buffer
),
this
->
GetImageSizeInComponents
()
);
}
...
...
@@ -167,7 +163,7 @@ bool ONERAImageIO::OpenOneraDataFileForReading(std::ifstream& os,
// Make sure that we have a file to
if
(
filename
==
""
)
{
otb
ExceptionMacro
(
<<
"A FileName must be specified."
);
itk
ExceptionMacro
(
<<
"A FileName must be specified."
);
return
false
;
}
...
...
@@ -194,7 +190,9 @@ bool ONERAImageIO::OpenOneraDataFileForReading(std::ifstream& os,
void
ONERAImageIO
::
ReadImageInformation
()
{
this
->
InternalReadImageInformation
();
std
::
ifstream
file
;
this
->
InternalReadImageInformation
(
file
);
file
.
close
();
}
...
...
@@ -205,18 +203,13 @@ void ONERAImageIO::InternalReadImageInformation(std::ifstream& file)
//read .ent file (header)
if
(
!
this
->
OpenOneraDataFileForReading
(
file
,
m_FileName
.
c_str
())
)
{
otb
ExceptionMacro
(
<<
"Cannot read requested file"
);
itk
ExceptionMacro
(
<<
"Cannot read requested file"
);
}
// Find info...
float
NbCol
;
float
NbRow
p
=
&
h
;
if
(
sizeof
(
h
)
!=
BIORAD_HEADER_LENGTH
)
{
itkExceptionMacro
(
<<
"Problem of alignement on your plateform"
);
}
float
NbRow
;
file
.
seekg
(
ONERA_FILE_ID_OFFSET
+
4
,
std
::
ios
::
beg
);
file
.
read
((
char
*
)(
&
NbCol
),
4
);
...
...
@@ -225,15 +218,16 @@ void ONERAImageIO::InternalReadImageInformation(std::ifstream& file)
itk
::
ByteSwapper
<
float
>::
SwapFromSystemToBigEndian
(
&
NbRow
);
file
.
seekg
(
0
,
std
::
ios
::
end
);
long
gcount
=
static_cast
<
long
>
(
file
.
tellg
())
-
ONERA_HEADER_LENGTH
-
2
*
4
*
NbCol
;
long
gcountHead
=
static_cast
<
long
>
(
ONERA_HEADER_LENGTH
+
2
*
4
*
NbCol
);
long
gcount
=
static_cast
<
long
>
(
file
.
tellg
());
// Set dim X,Y
m_width
=
static_cast
<
int
>
(
NbCol
);
m_height
=
static_cast
<
int
>
(
gcount
/
(
4
*
2
)
);
m_height
=
static_cast
<
int
>
(
gcount
-
gcountHead
/
(
4
*
2
)
);
if
(
m_width
==
0
&
m_height
==
0
)
{
otb
ExceptionMacro
(
<<
"Unknown image dimension"
);
itk
ExceptionMacro
(
<<
"Unknown image dimension"
);
}
else
{
...
...
This diff is collapsed.
Click to expand it.
Code/IO/otbONERAImageIO.h
+
6
−
15
View file @
a192546b
...
...
@@ -12,18 +12,8 @@
#ifndef __otbONERAImageIO_h
#define __otbONERAImageIO_h
#ifdef _MSC_VER
#pragma warning ( disable : 4786 )
#endif
/* C++ Libraries */
#include
<string>
#include
"stdlib.h"
/* ITK Libraries */
#include
"itkImageIOBase.h"
#include
"otbMetaDataKey.h"
#include
<fstream>
namespace
otb
...
...
@@ -38,8 +28,7 @@ namespace otb
* \ingroup IOFilters
*
*/
class
ITK_EXPORT
GDALImageIO
:
public
itk
::
ImageIOBase
,
public
MetaDataKey
class
ITK_EXPORT
ONERAImageIO
:
public
itk
::
ImageIOBase
{
public:
...
...
@@ -99,10 +88,12 @@ protected:
ONERAImageIO
();
/** Destructor.*/
~
ONERAImageIO
();
bool
OpenOneraDataFileForReading
(
std
::
ifstream
&
os
,
const
char
*
filename
);
void
InternalReadImageInformation
(
std
::
ifstream
&
file
);
void
PrintSelf
(
std
::
ostream
&
os
,
itk
::
Indent
indent
)
const
;
/** Read all information on the image*/
void
InternalReadImageInformation
();
/** Dimension along Ox of the image*/
int
m_width
;
/** Dimension along Oy of the image*/
...
...
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