Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
LEFEBVREJP email
radix
Commits
0d076c9f
Commit
0d076c9f
authored
Jan 27, 2018
by
Jordan P. Lefebvre
Browse files
WIP. starting on marchingsquares algorithm.
parent
6cf7b9e9
Pipeline
#11521
passed with stages
in 4 minutes and 31 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
radixalgorithm/CMakeLists.txt
View file @
0d076c9f
...
...
@@ -5,6 +5,8 @@ ordering.cc
)
SET
(
HEADERS
ordering.hh
marchingsquares.hh
marchingsquares.i.hh
)
TRIBITS_ADD_LIBRARY
(
radixalgorithmlib
...
...
radixalgorithm/marchingsquares.hh
0 → 100644
View file @
0d076c9f
#ifndef RADIX_RADIXALGORITHM_MARCHINGSQUARES_HH_
#define RADIX_RADIXALGORITHM_MARCHINGSQUARES_HH_
#include
<vector>
namespace
radix
{
template
<
typename
data_type
,
typename
sign_type
=
int
>
void
marching_squares
(
const
std
::
vector
<
data_type
>&
points
,
std
::
vector
<
data_type
>&
out
,
size_t
rows
,
size_t
cols
,
data_type
isovalue
,
sign_type
negative
=
0
,
sign_type
positive
=
1
);
}
// namespace
/** Include implementation file */
#include
"radixalgorithm/marchingsquares.i.hh"
#endif
/** RADIX_RADIXALGORITHM_MARCHINGSQUARES_HH_ */
radixalgorithm/marchingsquares.i.hh
0 → 100644
View file @
0d076c9f
#include
<vector>
#include
"radixbug/bug.hh"
namespace
radix
{
template
<
typename
data_type
,
typename
sign_type
=
int
>
void
marching_squares
(
const
std
::
vector
<
data_type
>&
points
,
std
::
vector
<
data_type
>&
out
,
size_t
rows
,
size_t
cols
,
data_type
isovalue
,
sign_type
negative
,
sign_type
positive
)
{
radix_check
(
points
.
size
()
==
(
rows
*
cols
));
out
.
clear
();
out
.
resize
(
points
.
size
());
//
// Create a 2d view of the points
auto
view
=
[
&
points
,
cols
](
size_t
row
,
size_t
column
)
{
return
points
[
cols
*
row
+
column
];
};
for
(
size_t
p_i
=
0
;
p_i
<
points
.
size
();
++
p_i
)
{
// select data as 0 below value or 1 greater than
if
(
points
[
p_i
]
<
isovalue
)
{
out
[
p_i
]
=
negative
;
}
else
{
out
[
p_i
]
=
positive
;
}
}
}
}
// namespace
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment