1
0
Mirror von https://github.com/Chaoscaot/schemsearch synchronisiert 2024-11-14 07:50:08 +01:00
Dieser Commit ist enthalten in:
Chaoscaot 2023-12-27 20:43:50 +01:00
Ursprung 511ce04f0b
Commit 3eba89b119
2 geänderte Dateien mit 30 neuen und 30 gelöschten Zeilen

Datei anzeigen

@ -37,27 +37,27 @@ int32_t isMatching(
void is_matching_all(
const int32_t *schem_data,
const int32_t *pattern_data,
size_t schem_width,
size_t schem_height,
size_t schem_length,
size_t pattern_width,
size_t pattern_height,
size_t pattern_length,
int32_t schem_width,
int32_t schem_height,
int32_t schem_length,
int32_t pattern_width,
int32_t pattern_height,
int32_t pattern_length,
int32_t *result
) {
for (size_t pz = 0; pz < pattern_length; ++pz) {
size_t maxZ = schem_length - pattern_length + pz + 1;
for (size_t py = 0; py < pattern_height; ++py) {
size_t maxY = schem_height - pattern_height + py + 1;
for (size_t px = 0; px < pattern_width; ++px) {
for (int32_t pz = 0; pz < pattern_length; ++pz) {
int32_t maxZ = schem_length - pattern_length + pz + 1;
for (int32_t py = 0; py < pattern_height; ++py) {
int32_t maxY = schem_height - pattern_height + py + 1;
for (int32_t px = 0; px < pattern_width; ++px) {
int32_t pv = pattern_data[px + py * pattern_width + pz * pattern_width * pattern_height];
size_t maxX = schem_width - pattern_width + px + 1;
for (size_t z = pz; z < maxZ; ++z) {
size_t sourceOffsetZ = z * schem_width * schem_height;
size_t resultOffsetZ = (z - pz) * schem_width * schem_height - py * schem_width;
for (size_t y = py; y < maxY; ++y) {
size_t sourceOffsetY = sourceOffsetZ + y * schem_width;
size_t resultOffsetY = resultOffsetZ + y * schem_width - px;
int32_t maxX = schem_width - pattern_width + px + 1;
for (int32_t z = pz; z < maxZ; ++z) {
int32_t sourceOffsetZ = z * schem_width * schem_height;
int32_t resultOffsetZ = (z - pz) * schem_width * schem_height - py * schem_width;
for (int32_t y = py; y < maxY; ++y) {
int32_t sourceOffsetY = sourceOffsetZ + y * schem_width;
int32_t resultOffsetY = resultOffsetZ + y * schem_width - px;
for (size_t x = px; x < maxX; ++x) {
result[resultOffsetY + x] += schem_data[sourceOffsetY + x] == pv;
}

Datei anzeigen

@ -53,12 +53,12 @@ extern "C" {
pub fn is_matching_all(
schem_data: *const i32,
pattern_data: *const i32,
schem_width: usize,
schem_height: usize,
schem_length: usize,
pattern_width: usize,
pattern_height: usize,
pattern_length: usize,
schem_width: i32,
schem_height: i32,
schem_length: i32,
pattern_width: i32,
pattern_height: i32,
pattern_length: i32,
result: *mut i32
);
}
@ -149,12 +149,12 @@ pub fn search(
is_matching_all(
schem_data,
pattern_data,
schem_width,
schem_height,
schem_length,
pattern_width,
pattern_height,
pattern_length,
schem_width as i32,
schem_height as i32,
schem_length as i32,
pattern_width as i32,
pattern_height as i32,
pattern_length as i32,
result.as_mut_ptr()
);
}