Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Backofen, Rainer
amdis
Commits
7c6dd8a4
Commit
7c6dd8a4
authored
Dec 09, 2011
by
Praetorius, Simon
Browse files
PngReader implemented
parent
74f06100
Changes
2
Hide whitespace changes
Inline
Side-by-side
AMDiS/src/io/PngReader.cc
View file @
7c6dd8a4
...
@@ -29,23 +29,27 @@ namespace AMDiS {
...
@@ -29,23 +29,27 @@ namespace AMDiS {
png_infop
info_ptr
;
png_infop
info_ptr
;
FILE
*
fp
;
FILE
*
fp
;
unsigned
int
sig_read
=
0
;
unsigned
int
sig_read
=
0
;
int
row
,
col
,
nVertices
,
nElements
;
int
row
,
col
;
int
bytesPerPixel
=
0
;
int
bytesPerPixel
=
0
;
// Open files and create the png data structures.
// Open files and create the png data structures.
if
((
fp
=
fopen
(
filename
.
c_str
(),
"rb"
))
==
NULL
)
if
((
fp
=
fopen
(
filename
.
c_str
(),
"rb"
))
==
NULL
)
{
TEST_EXIT
(
0
)(
"ERROR: file can not be opened
\n
"
);
TEST_EXIT
(
0
)(
"ERROR: file can not >be opened
\n
"
);
}
png_ptr
=
png_create_read_struct
(
PNG_LIBPNG_VER_STRING
,
NULL
,
NULL
,
NULL
);
png_ptr
=
png_create_read_struct
(
PNG_LIBPNG_VER_STRING
,
NULL
,
NULL
,
NULL
);
if
(
png_ptr
==
NULL
)
if
(
png_ptr
==
NULL
)
{
TEST_EXIT
(
0
)(
"ERROR in png_create_read_struct
\n
"
);
TEST_EXIT
(
0
)(
"ERROR in png_create_read_struct
\n
"
);
}
info_ptr
=
png_create_info_struct
(
png_ptr
);
info_ptr
=
png_create_info_struct
(
png_ptr
);
if
(
info_ptr
==
NULL
)
if
(
info_ptr
==
NULL
)
{
TEST_EXIT
(
0
)(
"ERROR in png_create_info_struct
\n
"
);
TEST_EXIT
(
0
)(
"ERROR in png_create_info_struct
\n
"
);
}
if
(
setjmp
(
png_jmpbuf
(
png_ptr
)))
if
(
setjmp
(
png_jmpbuf
(
png_ptr
)))
{
TEST_EXIT
(
0
)(
"ERROR in png_jmpbuf
\n
"
);
TEST_EXIT
(
0
)(
"ERROR in png_jmpbuf
\n
"
);
}
png_init_io
(
png_ptr
,
fp
);
png_init_io
(
png_ptr
,
fp
);
png_set_sig_bytes
(
png_ptr
,
sig_read
);
png_set_sig_bytes
(
png_ptr
,
sig_read
);
...
@@ -60,10 +64,6 @@ namespace AMDiS {
...
@@ -60,10 +64,6 @@ namespace AMDiS {
cout
<<
"Bytes per pixel: "
<<
bytesPerPixel
<<
endl
;
cout
<<
"Bytes per pixel: "
<<
bytesPerPixel
<<
endl
;
double
value
=
0
;
double
value
=
0
;
const
DOFAdmin
*
admin
=
vec
->
getFeSpace
()
->
getAdmin
();
int
n0
=
admin
->
getNumberOfPreDofs
(
VERTEX
);
//offset zum globale DOF-managment
int
dim
=
vec
->
getFeSpace
()
->
getMesh
()
->
getDim
();
int
dow
=
Global
::
getGeo
(
WORLD
);
const
BasisFunction
*
basFcts
=
vec
->
getFeSpace
()
->
getBasisFcts
();
const
BasisFunction
*
basFcts
=
vec
->
getFeSpace
()
->
getBasisFcts
();
int
numBasFcts
=
basFcts
->
getNumber
();
int
numBasFcts
=
basFcts
->
getNumber
();
DegreeOfFreedom
*
localIndices
=
new
DegreeOfFreedom
[
numBasFcts
];
DegreeOfFreedom
*
localIndices
=
new
DegreeOfFreedom
[
numBasFcts
];
...
@@ -76,7 +76,6 @@ namespace AMDiS {
...
@@ -76,7 +76,6 @@ namespace AMDiS {
Mesh
::
CALL_LEAF_EL
|
Mesh
::
CALL_LEAF_EL
|
Mesh
::
FILL_COORDS
);
Mesh
::
FILL_COORDS
);
while
(
elInfo
)
{
while
(
elInfo
)
{
const
DegreeOfFreedom
**
dof
=
elInfo
->
getElement
()
->
getDof
();
Element
*
el
=
elInfo
->
getElement
();
Element
*
el
=
elInfo
->
getElement
();
basFcts
->
getLocalIndices
(
el
,
vec
->
getFeSpace
()
->
getAdmin
(),
localIndices
);
basFcts
->
getLocalIndices
(
el
,
vec
->
getFeSpace
()
->
getAdmin
(),
localIndices
);
...
@@ -96,7 +95,7 @@ namespace AMDiS {
...
@@ -96,7 +95,7 @@ namespace AMDiS {
static_cast
<
double
>
(
info_ptr
->
row_pointers
[
row
][
col
*
3
+
2
]));
static_cast
<
double
>
(
info_ptr
->
row_pointers
[
row
][
col
*
3
+
2
]));
break
;
break
;
default:
default:
TEST_EXIT
(
false
)(
"ERROR: bytesPerPixel=%d is unknown case!
\n
"
,
bytesPerPixel
)
TEST_EXIT
(
false
)(
"ERROR: bytesPerPixel=%d is unknown case!
\n
"
,
bytesPerPixel
)
;
}
}
(
*
vec
)[
localIndices
[
i
]]
=
value
;
(
*
vec
)[
localIndices
[
i
]]
=
value
;
}
}
...
@@ -107,7 +106,6 @@ namespace AMDiS {
...
@@ -107,7 +106,6 @@ namespace AMDiS {
png_destroy_read_struct
(
&
png_ptr
,
&
info_ptr
,
NULL
);
png_destroy_read_struct
(
&
png_ptr
,
&
info_ptr
,
NULL
);
fclose
(
fp
);
fclose
(
fp
);
};
return
(
0
);
}
};
}
AMDiS/src/io/PngReader.h
View file @
7c6dd8a4
...
@@ -20,8 +20,8 @@
...
@@ -20,8 +20,8 @@
/** \file ValueReader.h */
/** \file ValueReader.h */
#ifndef AMDIS_
VALUE
READER_H
#ifndef AMDIS_
PNG
READER_H
#define AMDIS_
VALUE
READER_H
#define AMDIS_
PNG
READER_H
#include
"AMDiS.h"
#include
"AMDiS.h"
...
@@ -63,6 +63,7 @@ namespace AMDiS {
...
@@ -63,6 +63,7 @@ namespace AMDiS {
yMin
=
minDim
[
1
];
yMax
=
maxDim
[
1
];
yMin
=
minDim
[
1
];
yMax
=
maxDim
[
1
];
};
};
};
}
}
#endif
#endif
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment