Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
openfpm_io
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
Sbalzarini Lab
Software
Parallel Computing
OpenFPM
openfpm_io
Commits
906d6487
Commit
906d6487
authored
3 years ago
by
Pietro Incardona
Browse files
Options
Downloads
Plain Diff
Merge branch 'develop' of
ssh://git.mpi-cbg.de/openfpm/openfpm_io
into develop
parents
8fed0db5
91686e37
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#3056
failed
3 years ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/RawReader/InitGridWithPixel.hpp
+41
-13
41 additions, 13 deletions
src/RawReader/InitGridWithPixel.hpp
with
41 additions
and
13 deletions
src/RawReader/InitGridWithPixel.hpp
+
41
−
13
View file @
906d6487
...
...
@@ -18,6 +18,7 @@
#include
<iostream>
#include
<typeinfo>
#include
<cmath>
#include
<sys/stat.h>
#include
"Vector/vector_dist.hpp"
#include
"Grid/grid_dist_id.hpp"
...
...
@@ -26,6 +27,14 @@
#include
"level_set/redistancing_Sussman/HelpFunctionsForGrid.hpp"
typedef
signed
char
BYTE
;
inline
bool
exists_test
(
const
std
::
string
&
name
)
{
struct
stat
buffer
;
return
(
stat
(
name
.
c_str
(),
&
buffer
)
==
0
);
}
/**@brief Read the number of pixels per dimension from a csv-file in order to create a grid with the same size.
*
* @param path_to_file Std::string containing the path to the csv file that holds the image/volume size in
...
...
@@ -35,13 +44,15 @@ typedef signed char BYTE;
std
::
vector
<
size_t
>
get_size
(
const
std
::
string
&
path_to_file
)
{
std
::
vector
<
size_t
>
stack_dimst_1d
;
// stream input csv file
and error check
std
::
ifstream
file
(
path_to_file
)
;
if
(
!
file
)
{
std
::
cout
<<
"
Error opening file
"
<<
std
::
endl
;
exit
(
EXIT_FAILURE
);
//
check if file exists and
stream input csv file
if
(
!
exists_test
(
path_to_file
)
){
std
::
cout
<<
"------------------------------------------------------------------------"
<<
std
::
endl
;
std
::
cout
<<
"Error: file "
<<
path_to_file
<<
" does not exist. Aborting..."
<<
std
::
endl
;
std
::
cout
<<
"
------------------------------------------------------------------------
"
<<
std
::
endl
;
abort
(
);
}
std
::
ifstream
file
(
path_to_file
);
// get its size
std
::
streampos
fileSize
;
...
...
@@ -83,7 +94,14 @@ void load_pixel_onto_grid(grid_type & grid, std::string file_name, std::vector <
constexpr
size_t
x
=
0
;
constexpr
size_t
y
=
1
;
constexpr
size_t
z
=
2
;
// check if file exists and stream input file
if
(
!
exists_test
(
file_name
)){
std
::
cout
<<
"------------------------------------------------------------------------"
<<
std
::
endl
;
std
::
cout
<<
"Error: file "
<<
file_name
<<
" does not exist. Aborting..."
<<
std
::
endl
;
std
::
cout
<<
"------------------------------------------------------------------------"
<<
std
::
endl
;
abort
();
}
std
::
ifstream
file_stream
(
file_name
,
std
::
ifstream
::
binary
);
auto
&
v_cl
=
create_vcluster
();
...
...
@@ -121,17 +139,24 @@ void load_pixel_onto_grid(grid_type & grid, std::string file_name, std::vector <
auto
key
=
dom
.
get
();
auto
gkey
=
grid
.
getGKey
(
key
);
// In case a patch starts within a group of nodes to which same pixel-value should be assigned, get the
// respective rest-offset
size_t
rest_offset
=
(
size_t
)
(
fmod
(
gkey
.
get
(
0
),
refinement
[
x
]));
// get the remainder
// get l as the length of one x-line of the original image stack for the specific patch on the processor
auto
&
gbox
=
grid
.
getLocalGridsInfo
();
auto
&
DomBox
=
gbox
.
get
(
key
.
getSub
()).
Dbox
;
int
l
=
(
size_t
)
std
::
round
((
DomBox
.
getHigh
(
0
)
-
DomBox
.
getLow
(
0
)
+
1
)
/
refinement
[
x
]);
auto
&
gbox
=
grid
.
getLocalGridsInfo
();
auto
&
DomBox
=
gbox
.
get
(
key
.
getSub
()).
Dbox
;
size_t
patch_size
=
DomBox
.
getHigh
(
0
)
-
DomBox
.
getLow
(
0
)
+
1
;
size_t
l
=
(
size_t
)
ceil
(
(
patch_size
+
rest_offset
)
/
refinement
[
x
]);
// in case that the grid has a different resolution than the underlying image stack:
// create a key which is used to get the offset for the file reading
// the indices in this key are corrected by the refinement factor
for
(
size_t
d
=
0
;
d
<
grid_type
::
dims
;
d
++
)
{
gkey
.
set_d
(
d
,
std
::
round
(
gkey
.
get
(
d
)
/
refinement
[
d
]));
gkey
.
set_d
(
d
,
floor
(
gkey
.
get
(
d
)
/
refinement
[
d
]));
}
// the offset matches the pixel from the image stack to the corresponding current position of the iterator
...
...
@@ -147,10 +172,13 @@ void load_pixel_onto_grid(grid_type & grid, std::string file_name, std::vector <
// run over a whole grid-line in x and assign pixel values from pixel_line to grid nodes
// if the grid is finer in x as the image stack, the same pixel value from pixel_line is
// assigned refinement[x] times
for
(
size_t
i
=
0
;
i
<
l
*
refinement
[
x
]
;
i
++
)
for
(
size_t
k
=
0
;
k
<
patch_size
;
++
k
)
{
auto
key
=
dom
.
get
();
grid
.
template
get
<
Phi_0
>(
key
)
=
(
double
)
pixel_line
[(
size_t
)
floor
(
i
/
refinement
[
x
])];
// get the correct index of the pixel to be read from pixel_line by considering a potential rest-offset,
// when the patch divides group of nodes that belong to the same pixel
size_t
i
=
(
size_t
)
floor
((
k
+
rest_offset
)
/
refinement
[
x
]);
grid
.
template
get
<
Phi_0
>(
key
)
=
(
double
)
pixel_line
[
i
];
++
dom
;
}
// now one grid line in x is finished and the iterator dom has advanced accordingly s.t. next loop continues
...
...
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