Mirror von
https://github.com/Chaoscaot/schemsearch
synchronisiert 2024-11-19 10:20:08 +01:00
Commits vergleichen
3 Commits
511ce04f0b
...
9c8551dc5a
Autor | SHA1 | Datum | |
---|---|---|---|
9c8551dc5a | |||
abb2084029 | |||
3eba89b119 |
@ -1,4 +1,5 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
int32_t isMatching(
|
int32_t isMatching(
|
||||||
const int32_t *schem_data,
|
const int32_t *schem_data,
|
||||||
@ -37,28 +38,28 @@ int32_t isMatching(
|
|||||||
void is_matching_all(
|
void is_matching_all(
|
||||||
const int32_t *schem_data,
|
const int32_t *schem_data,
|
||||||
const int32_t *pattern_data,
|
const int32_t *pattern_data,
|
||||||
size_t schem_width,
|
int32_t schem_width,
|
||||||
size_t schem_height,
|
int32_t schem_height,
|
||||||
size_t schem_length,
|
int32_t schem_length,
|
||||||
size_t pattern_width,
|
int32_t pattern_width,
|
||||||
size_t pattern_height,
|
int32_t pattern_height,
|
||||||
size_t pattern_length,
|
int32_t pattern_length,
|
||||||
int32_t *result
|
int32_t *result
|
||||||
) {
|
) {
|
||||||
for (size_t pz = 0; pz < pattern_length; ++pz) {
|
for (int32_t pz = 0; pz < pattern_length; ++pz) {
|
||||||
size_t maxZ = schem_length - pattern_length + pz + 1;
|
int32_t maxZ = schem_length - pattern_length + pz + 1;
|
||||||
for (size_t py = 0; py < pattern_height; ++py) {
|
for (int32_t py = 0; py < pattern_height; ++py) {
|
||||||
size_t maxY = schem_height - pattern_height + py + 1;
|
int32_t maxY = schem_height - pattern_height + py + 1;
|
||||||
for (size_t px = 0; px < pattern_width; ++px) {
|
for (int32_t px = 0; px < pattern_width; ++px) {
|
||||||
int32_t pv = pattern_data[px + py * pattern_width + pz * pattern_width * pattern_height];
|
int32_t pv = pattern_data[px + py * pattern_width + pz * pattern_width * pattern_height];
|
||||||
size_t maxX = schem_width - pattern_width + px + 1;
|
int32_t maxX = schem_width - pattern_width + px + 1;
|
||||||
for (size_t z = pz; z < maxZ; ++z) {
|
for (int32_t z = pz; z < maxZ; ++z) {
|
||||||
size_t sourceOffsetZ = z * schem_width * schem_height;
|
int32_t sourceOffsetZ = z * schem_width * schem_height;
|
||||||
size_t resultOffsetZ = (z - pz) * schem_width * schem_height - py * schem_width;
|
int32_t resultOffsetZ = (z - pz) * schem_width * schem_height - py * schem_width;
|
||||||
for (size_t y = py; y < maxY; ++y) {
|
for (int32_t y = py; y < maxY; ++y) {
|
||||||
size_t sourceOffsetY = sourceOffsetZ + y * schem_width;
|
int32_t sourceOffsetY = sourceOffsetZ + y * schem_width;
|
||||||
size_t resultOffsetY = resultOffsetZ + y * schem_width - px;
|
int32_t resultOffsetY = resultOffsetZ + y * schem_width - px;
|
||||||
for (size_t x = px; x < maxX; ++x) {
|
for (int32_t x = px; x < maxX; ++x) {
|
||||||
result[resultOffsetY + x] += schem_data[sourceOffsetY + x] == pv;
|
result[resultOffsetY + x] += schem_data[sourceOffsetY + x] == pv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,12 +53,12 @@ extern "C" {
|
|||||||
pub fn is_matching_all(
|
pub fn is_matching_all(
|
||||||
schem_data: *const i32,
|
schem_data: *const i32,
|
||||||
pattern_data: *const i32,
|
pattern_data: *const i32,
|
||||||
schem_width: usize,
|
schem_width: i32,
|
||||||
schem_height: usize,
|
schem_height: i32,
|
||||||
schem_length: usize,
|
schem_length: i32,
|
||||||
pattern_width: usize,
|
pattern_width: i32,
|
||||||
pattern_height: usize,
|
pattern_height: i32,
|
||||||
pattern_length: usize,
|
pattern_length: i32,
|
||||||
result: *mut i32
|
result: *mut i32
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -149,18 +149,16 @@ pub fn search(
|
|||||||
is_matching_all(
|
is_matching_all(
|
||||||
schem_data,
|
schem_data,
|
||||||
pattern_data,
|
pattern_data,
|
||||||
schem_width,
|
schem_width as i32,
|
||||||
schem_height,
|
schem_height as i32,
|
||||||
schem_length,
|
schem_length as i32,
|
||||||
pattern_width,
|
pattern_width as i32,
|
||||||
pattern_height,
|
pattern_height as i32,
|
||||||
pattern_length,
|
pattern_length as i32,
|
||||||
result.as_mut_ptr()
|
result.as_mut_ptr()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
dbg!(result.clone());
|
|
||||||
|
|
||||||
result.into_iter().enumerate().filter(|(_, matching_count)| *matching_count >= i_pattern_blocks - skip_amount).for_each(|(i, matching_count)| {
|
result.into_iter().enumerate().filter(|(_, matching_count)| *matching_count >= i_pattern_blocks - skip_amount).for_each(|(i, matching_count)| {
|
||||||
let percent = matching_count as f32 / pattern_blocks;
|
let percent = matching_count as f32 / pattern_blocks;
|
||||||
let x = i % schem_width;
|
let x = i % schem_width;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren