Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
633be4d
Update Readme.md
Swistusmen Apr 20, 2021
acfff56
Update Readme.md
Swistusmen Apr 20, 2021
d419fae
Merge pull request #1 from Swistusmen/qt
Swistusmen Apr 20, 2021
ce52298
Update Readme.md
Swistusmen Apr 20, 2021
ec72fdc
Merge pull request #2 from Swistusmen/qt
Swistusmen Apr 22, 2021
03d735c
Merge pull request #3 from Swistusmen/qt
Swistusmen Apr 24, 2021
075510e
Update Readme.md
Swistusmen Apr 24, 2021
b1c8a12
Merge pull request #4 from Swistusmen/qt
Swistusmen Apr 25, 2021
a07f881
Merge pull request #5 from Swistusmen/qt
Swistusmen Apr 26, 2021
80fc5ea
Merge pull request #6 from Swistusmen/qt
Swistusmen Apr 27, 2021
d97b54b
Merge pull request #9 from Swistusmen/qt
Swistusmen Apr 28, 2021
e452338
Update Readme.md
Swistusmen Apr 28, 2021
e3c449a
Drawing simple red square
Swistusmen Apr 28, 2021
457c318
Merge branch 'master' of github.com:Swistusmen/Geometric-Algorithms
Swistusmen Apr 28, 2021
08fb8e8
Drawing class
Swistusmen May 2, 2021
acbda2a
Reading colors
Swistusmen May 2, 2021
400053a
finished ui for algo interface
Swistusmen May 3, 2021
5d29e63
backup
Swistusmen May 3, 2021
753bf64
adding new slot
Swistusmen May 4, 2021
affbf32
gitignore
Swistusmen May 4, 2021
90ab110
Delete src/release directory
Swistusmen May 4, 2021
28884be
Delete src/debug directory
Swistusmen May 4, 2021
2151084
Delete src.vcxproj
Swistusmen May 4, 2021
3bdee7a
Delete src.vcxproj.filters
Swistusmen May 4, 2021
29e21db
Delete src.vcxproj.user
Swistusmen May 4, 2021
b48ff33
Delete .qmake.stash
Swistusmen May 4, 2021
4a2fd0c
Update Readme.md
Swistusmen May 4, 2021
cab6a48
ui updates, plan to finish messy things
Swistusmen May 5, 2021
412a0ed
Merge branch 'master' of github.com:Swistusmen/Geometric-Algorithms
Swistusmen May 5, 2021
6dd7b0b
Integration with next step
Swistusmen May 6, 2021
a0bf3ae
improved integration
Swistusmen May 7, 2021
0bebd6b
drawing
Swistusmen May 10, 2021
b6f95df
painitng
Swistusmen May 10, 2021
02c822b
simple updates
Swistusmen May 12, 2021
0c4fb4d
loading data
Swistusmen May 13, 2021
302c1ef
colors
Swistusmen May 13, 2021
5bd2bf8
fix of switching layouts
Swistusmen May 13, 2021
f219468
update
Swistusmen May 13, 2021
0e925ae
alert algo not selected
Swistusmen May 15, 2021
e8188cb
finished ui
Swistusmen May 16, 2021
2e18886
definitely finished ui
Swistusmen May 16, 2021
3d1c4af
improved cd- nice build, need to add build for tests
Swistusmen May 16, 2021
a194b05
improved cmake
Swistusmen May 17, 2021
474e199
Update Readme.md
Swistusmen May 17, 2021
ce38987
readme
Swistusmen May 17, 2021
d5f6d2a
Update Readme.md
Swistusmen May 17, 2021
6f23bd2
fixing algorithms
Swistusmen May 18, 2021
eac9601
stupid random finding way using with marking paths
Swistusmen May 18, 2021
ff22987
Merge branch 'master' of github.com:Swistusmen/Geometric-Algorithms
Swistusmen May 18, 2021
48f8b29
Update Readme.md
Swistusmen May 21, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set (CMAKE_PREFIX_PATH "C:\\Qt\\5.15.2\\msvc2019_64\\lib\\cmake")

include_directories(src)
include_directories(tst)
include_directories(lib/include(GoogleTest))

add_subdirectory(src)
add_subdirectory(tst)
add_subdirectory(lib/googletest)
add_subdirectory(lib/googletest)
67 changes: 29 additions & 38 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,40 @@
<h1>Geometric Algorithms</h1>

<h2>Purpose of this project</h2>
<h2>Tech stack</h2>

-Learn geometric algorithms
-C++ 17

-Improve C++ and project patterns skills
-Googletest

<h2>Demands</h2>

-visual studio 2019 (project include windows libraries)
-Qt 5.15.2

-google test (every algorithm has test cases)
<h2>Demands</h2>

-compiler which supports C++2017 features (I'm compiling using msvc_2019)
Project was designed to be built using msvcc19 compiler. It hasn't been testing for any unix-like system. To built, there is need to provide googletest manually to destination: lib/googletest/. Also project doesn't include any tool for installation of Qt packages, interested person should perfomr it manually. If both googletest and qt will be provided, build should be done successfuly. I'm planning to implement building console app in case if no Qt packages were detected. Unit tests covers only algorithms

<h2>Build</h2>

For now there is need to add google test manually to the lib as directory is empty (will be made as subdirectory)</br>
Project demand qt 5.15.2, in the future cmake will be modified to allow creting version without GUI
```
mkdir build
cd build
cmake -S .. -B $(pwd)
```
Project is build, by there is need to made such a configuration:

-load project, change <keyword> to QtVS_v302, reload project

-Convert custom steps to MS/Qt build

-in Properties, select modules: Core, XML, Widget, GUI, select QtInstallation to 5.15.2 (if you haven't create it, create one)
<h2> Implemented algorithms </h2>

-Properties/ Qt Settings/ Paths/ Additional header search path and Additional Qt library search path- you need to paste your paths into them
- Bounding box (rectangle)

-save
-Finding way (stupid algorithm- choosing always the longest path)

-load project, change Keyword back to Win32Proj
-Finding verticies

-you should be able to use qt libraries from now
-Voronoi Diagram

-<b>If it is not possible try to use backupCmakeLists.txt (2) - they have versio without qt, probably there will be need to change source code
-Delano Traingulation

<h2>Implemented algorithms </h2>

-finding path in labirynth
-finding path in labirynth- select longest possible road or road to glory, don't check if repeat

-minimum square bounding box

Expand All @@ -53,30 +44,30 @@ Project is build, by there is need to made such a configuration:

-Delano triangulation

<h2>To implement </h2>
-finding path in labirynth- check if repeat, randomly select way

<h2>Gui app information </h2>

<b> Meaningufull (constant) colors: </b>

⬜- empty/ not initialized

⬛- wall / shape boundary /line

-GUI
🟥- goal / founded

-better input
🟩- position / movement

-algorithm parallelism
<b> Interfaces: </b>

-working on png files as inputs
Data interface:

-algorithms: other ways of finding paths, checking if figure is contiunues, blending figures, ncellular automata
![alt text](https://github.com/Swistusmen/Geometric-Algorithms/blob/master/screenshots/input.png)

Algorithm iterface:
![alt text](https://github.com/Swistusmen/Geometric-Algorithms/blob/master/screenshots/algorithm.png)

<h4>Currently adding gui</h4>
https://stackoverflow.com/questions/4028604/add-qt-to-existing-visual-studio-c-project
https://forum.qt.io/topic/114299/convert-visual-studio-2017-solution-to-use-qt/2

Steps done to switch to Qt:

-changing on CMakeList.txt: Adding set (CMAKE_PREFIX_PATH "C:\\Qt\\5.9.9\\msvc2017_64\\") to main, find_package(Qt5 COMPONENTS Widgets REQUIRED), find_package(Qt5 COMPONENTS Widgets REQUIRED)

-Switching to Qt project by changin .vcxproj <Keyword> to different options

-using Qt5.9.9

-always couldn't find Qt files

Binary file removed assets/russel.jpg
Binary file not shown.
11 changes: 0 additions & 11 deletions backupCMakeLists.txt

This file was deleted.

2 changes: 1 addition & 1 deletion lib/googletest
Submodule googletest updated 115 files
2 changes: 2 additions & 0 deletions saves/b.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
2
{86}0{1}1{8}0{1}2{8}0{1}1{6}0{1}1{17}0{1}1{6}0{1}1{18}0{1}1{5}0{1}1{19}0{1}1{4}0{1}1{2}0{5}1{18}0{3}1{3}0{2}1{13}0{1}1{4}0{2}1{4}0{1}1{19}0{2}1{5}0{2}1{11}0{1}1{5}0{2}1{7}0{1}1{10}0{1}1{4}0{2}1{23}0{2}1{8}0{1}1{10}0{1}1{4}0{1}1{10}0{1}1{3}0{2}1{4}0{1}1{15}0{1}1{2}0{1}1{1}0{3}1{1}0{1}1{16}0{1}1{1}0{1}1{3}0{4}1{15}0{1}1{1}0{1}1{5}0{2}1{15}0{1}1{2}0{1}1{20}0{2}1{3}0{1}1{18}0{2}1{6}0{1}1{1}0{1}1{13}0{1}1{5}0{1}3{6}0{1}1{8}0{3}1{15}0{1}1{1}0{1}1{1}0{2}1{28}0
2 changes: 2 additions & 0 deletions saves/boundary_test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
2
{30}0{4}1{4}0{1}2{3}0{1}3{1}1{9}0{1}1{7}0{3}1{36}0
2 changes: 2 additions & 0 deletions saves/finding_way_2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
2
{31}0{5}1{5}0{7}1{3}0{1}1{8}0{4}1{8}0{1}1{3}0{1}1{11}0{1}1{1}0{1}2{3}0{4}1{3}0{2}1{1}0{7}1{2}0{1}1{2}0{1}1{10}0{1}1{7}0{1}1{2}0{1}1{2}0{1}1{10}0{1}1{7}0{1}1{2}0{1}1{2}0{6}1{5}0{1}1{3}0{5}1{5}0{1}1{4}0{2}1{4}0{2}1{2}0{1}1{9}0{1}1{5}0{1}1{8}0{1}1{9}0{1}1{5}0{1}1{8}0{1}1{5}0{9}1{1}0{1}1{2}0{2}1{4}0{1}1{15}0{1}1{8}0{2}1{14}0{1}1{9}0{1}1{4}0{1}1{9}0{1}1{19}0{3}1{2}0{1}1{4}0{5}1{10}0{1}1{2}0{3}1{8}0{8}1{23}0{2}1{23}0{1}1{4}0{6}1{14}0{1}1{9}0{1}1{4}0{6}1{4}0{1}1{9}0{1}1{7}0{1}1{6}0{1}1{5}0{1}1{2}0{2}1{7}0{1}1{8}0{2}1{2}0{1}1{2}0{1}1{5}0{1}3{12}0{4}1{2}0{1}1{28}0
Binary file added screenshots/algorithm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/input.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions scripts/rebuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

cd src
rm -r ALL_BUILD* CMakeFiles/ CMakeFiles/ INSTALL* GeometricAlgorithms* release/ src/ tst/ debug/ lib/ ZERO* src.v*
cd ../build
cmake -S .. -B $(pwd)
2 changes: 2 additions & 0 deletions src/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ release/
debug/
src.vcxproj.user
src.vcxproj.filters
src.vcxproj


File renamed without changes.
5 changes: 3 additions & 2 deletions src/Board.cpp → src/Algorithms/Board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ BoardImplementation::BoardImplementation(std::shared_ptr<AlgorithmsKeeper> str,
auto size = input.size();
double number = std::sqrt(static_cast<double>(size));
int buffer = number;
std::cout << number-buffer << std::endl;
if (static_cast<double>(number - buffer) != 0.0||size<9)
{
std::cerr << "[E1] Wrong Board initialization- wrong size\n";
Expand Down Expand Up @@ -41,7 +40,9 @@ FieldRepresentation BoardImplementation::Representation()

AlgoType BoardImplementation::GetAlgorithm()
{
return algo->Type();
if(algo!=nullptr)
return algo->Type();
return AlgoType::None;
}

AlgoState BoardImplementation::PerformAlgorithm()
Expand Down
File renamed without changes.
42 changes: 11 additions & 31 deletions src/BoundingBox.cpp → src/Algorithms/BoundingBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ std::vector<unsigned int> BoundingBox::Perform(std::vector<unsigned int> data)
}
if (geometries.empty())
{
std::cerr << "No geoemtires inside\n";
this->state == AlgoState::FINISHED_FAILURE;
return data;
}
auto indexes = FindEdgeIndexes(geometries,dimension,size);
indexes = CalculateEdgeRows(indexes, dimension);
if (indexes[3] == -1 || indexes[1] == -1 || indexes[0] < 0 || indexes[2] < 0)
{
std::cerr << "Size of board is to small\n";
this->state == AlgoState::FINISHED_FAILURE;
return data;
}
int tl = indexes[0] * dimension + indexes[3];
int tr = indexes[0] * dimension + indexes[1];
int br = (indexes[2] -1) * dimension + indexes[1];
int bl = (indexes[1] -1)* dimension + indexes[3];
int br = (indexes[2]) * dimension + indexes[1];
int bl = (indexes[2])* dimension + indexes[3];

for (int i = tl; i < tr; i ++)
data[i] = 2;
Expand All @@ -48,33 +48,13 @@ std::array<int, 4> BoundingBox::FindEdgeIndexes(std::vector<int> data, int dim,
{
int topIndex = data.front();
int botIndex = data.back();
int rightIndex = -1, leftIndex = -1;
for (int i = 0; i < dim; i++)
int rightIndex = -1, leftIndex = 10000000000;
const int noCells = data.size();
for (int i = 0; i < noCells; i++)
{
for (int j = i; j < size; j += dim)
{
if (data[j] == 1)
{
leftIndex = j;
break;
}
}
if (leftIndex != -1)
break;
}

for (int i = dim - 1; i >= 0; i--)
{
for (int j = i; j < size; j += dim)
{
if (data[j] == 1)
{
rightIndex = j;
break;
}
}
if (rightIndex != -1)
break;
int value = data[i] % dim;
leftIndex=value < leftIndex ? value : leftIndex;
rightIndex = value > rightIndex ? value : rightIndex;
}
std::array<int, 4> a{ topIndex,rightIndex,botIndex,leftIndex };
return a;
Expand All @@ -84,7 +64,7 @@ std::array<int, 4> BoundingBox::CalculateEdgeRows(std::array<int, 4> data, int d
{
data[0] = floor(static_cast<double>(data[0] - dim) / dim);
data[1] = (data[1] + 1) % dim == 0 ? -1 : (data[1] + 1) % dim + 1;
data[2] = ceil(static_cast<double>(data[2] + dim) / dim);
data[2] = ceil(static_cast<double>((data[2] + dim) / dim));
data[3] = data[3] % dim == 0 ? -1 : (data[3]) % dim - 1;
return data;
}
Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions src/Algorithms/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
set(BINARY ${CMAKE_PROJECT_NAME})

file(GLOB_RECURSE SOURCES LIST_DIRECTORIES true *.h *.cpp)

set(SOURCES ${SOURCES})

add_executable(${BINARY}_algo ${SOURCES})
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 2 additions & 3 deletions src/FindingWay.cpp → src/Algorithms/FindingWay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,19 @@ std::pair<FindingWay::RobotAction, int> FindingWay::ScanForAWay(std::vector<unsi
break;
if (board[tempRobot]== 0|| board[tempRobot] == 2)
{
distances[i]++;
if (board[tempRobot] == 2)
{
distances[i]++;
founded = i;
std::cout << "Founded\n";
break;
}
if((tempRobot%dimension==0&&(previousRobot+1)%dimension==0) || (previousRobot % dimension == 0 && (tempRobot + 1) % dimension == 0))
break;
distances[i]++;
}
}
}


int rightEdge = dimension - (robot % dimension)-1;
int leftEdge = dimension - rightEdge -1;
distances[1] = distances[1] > rightEdge ? rightEdge : distances[1];
Expand Down
File renamed without changes.
Loading