Skip to content

Commit 45b4682

Browse files
committedDec 22, 2017
修改适配层以解决字符数组传送问题。
1 parent a99fc17 commit 45b4682

File tree

6 files changed

+10
-16
lines changed

6 files changed

+10
-16
lines changed
 

‎csharp/BfsTest/.vs/BfsTest/v15/.suo

31 KB
Binary file not shown.

‎csharp/BfsTest/.vs/BfsTest/v15/Server/sqlite3/db.lock

Whitespace-only changes.
Binary file not shown.

‎csharp/BfsTest/BfsTest/MainWindow.xaml.cs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public partial class MainWindow : Window
2525
internal const string DllName = @"C:\Users\The18\Documents\Visual Studio 2017\Projects\3rd Party\Leo-AlgorithmModule\lib\algorithm_module.dll";
2626
internal const string TestDllName = @"C:\Users\The18\Documents\Visual Studio 2017\Projects\BfsTest\x64\Debug\DllTest.dll";
2727
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
28-
internal static extern int EscapeMaze(int floors, int height, int width, char[,,] mazeData);
28+
internal static extern int EscapeMaze(int floors, int height, int width, string mazeData);
2929
[DllImport(TestDllName, CallingConvention = CallingConvention.Cdecl)]
3030
private static extern int add(int[,] data);
3131
private void buttonEscapeClick(object s, RoutedEventArgs e)
@@ -37,19 +37,8 @@ private void buttonEscapeClick(object s, RoutedEventArgs e)
3737
var floors = int.Parse(firstData[0]);
3838
var height = int.Parse(firstData[1]);
3939
var width = int.Parse(firstData[2]);
40-
var mazeData = new char[floors, height, width];
4140
data = data.Replace(Environment.NewLine, "").Replace(" ", "");
42-
for (var x = 0; x < floors; x++)
43-
{
44-
for (var y = 0; y < height; y++)
45-
{
46-
for (var z = 0; z < width; z++)
47-
{
48-
mazeData[x, y, z] = data[x * (width * height) + y * width + z];
49-
}
50-
}
51-
}
52-
var result = EscapeMaze(floors, height, width, mazeData);
41+
var result = EscapeMaze(floors, height, width, data);
5342
MessageBox.Show(result.ToString());
5443
}
5544
private void buttonEscapeRightClick(object s, MouseButtonEventArgs e)
0 Bytes
Binary file not shown.

‎src/algorithm_module/c_adapt.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "algorithm_module.h"
2+
#include "Windows.h"
23
#define C_PUBLIC extern "C" __declspec(dllexport) //C export
34
namespace Algorithm
45
{
@@ -56,19 +57,21 @@ namespace Algorithm
5657
walk
5758
};
5859

59-
C_PUBLIC int EscapeMaze(int floors, int height, int width, char mazeData[maxn][maxn][maxn])
60+
C_PUBLIC int EscapeMaze(int floors, int height, int width, char mazeData[maxn*maxn*maxn])
6061
{
6162
t = floors;
6263
a = height;
6364
b = width;
6465
int start, dest;
66+
//std::string message = "";
6567
for (int i = 0; i < t; i++)
6668
{
6769
for (int j = 0; j < a; j++)
6870
{
6971
for (int k = 0; k < b; k++)
7072
{
71-
s[i][j][k] = mazeData[i][j][k];
73+
s[i][j][k] = mazeData[i*(a*b)+j*b+k];
74+
//message.push_back(s[i][j][k]);
7275
if (s[i][j][k] == 'S')
7376
{
7477
start = encoder(i, j, k);
@@ -78,9 +81,11 @@ namespace Algorithm
7881
dest = encoder(i, j, k);
7982
}
8083
}
84+
//message.push_back('\n');
8185
}
86+
//message.push_back('\n');
8287
}
83-
88+
//MessageBox(NULL, message.c_str(), "From C", MB_OK);
8489
return bfsStep(start, dest, graph);
8590
}
8691
}

0 commit comments

Comments
 (0)