Compare commits

10 Commits

Author SHA1 Message Date
98bc42be7d Add slike to random 2026-02-03 15:25:15 +01:00
208f849b47 add header 2026-01-29 13:43:51 +01:00
771cabed8f old_data 2026-01-05 22:20:51 +01:00
96f4f51e69 ch 2025-12-04 13:31:30 +01:00
525936c6e7 f 2025-10-24 16:54:16 +02:00
060b9f9182 s 2025-10-22 19:07:59 +02:00
59fd47e684 Add print image 2025-10-22 18:47:05 +02:00
593b813988 Add similaritys 2025-10-22 17:56:26 +02:00
5f6305a2f2 s 2025-10-09 15:53:58 +02:00
dddf8ca632 t 2025-10-08 19:41:46 +02:00
5 changed files with 81 additions and 95 deletions

View File

@@ -47,6 +47,7 @@ target_link_libraries(app PRIVATE shared)
add_executable(server add_executable(server
server/src/server.cpp server/src/server.cpp
server/src/checker.cpp server/src/checker.cpp
) )
target_include_directories(server PRIVATE server/inc) target_include_directories(server PRIVATE server/inc)
target_link_libraries(server PRIVATE shared) target_link_libraries(server PRIVATE shared)
@@ -58,6 +59,7 @@ add_executable(view
target_include_directories(view PRIVATE view/inc) target_include_directories(view PRIVATE view/inc)
target_link_libraries(view PRIVATE shared) target_link_libraries(view PRIVATE shared)
add_executable(slike add_executable(slike
random/slike.cpp random/slike.cpp
) )

View File

@@ -3,116 +3,109 @@
#include <cmath> #include <cmath>
#include <vector> #include <vector>
Vector2 newPoint(Vector2 start, float len, float angleD){ float len = 300;
float angleR = (angleD * PI) / 180; // radian float angleD = 100;
return {start.x + len * cos(angleR), start.y - len * sin(angleR)}; float angleR = (angleD * PI) / 180; // radian
} Vector2 start = {250, 400};
Vector2 end = {250, start.y - len};
void drawBranch(Vector2 startV, Vector2 endV, Color startC, Color endC, int startR, int endR){ Vector2 end_kot = {};
float fstep = 0.05; float radius = 20;
for (float i = 0; i < 1.05; i += fstep) float radiusS = 80;
{ float radiusE = 60;
Vector2 point = Vector2Lerp(startV, endV, i); Color colorS = RED;
Color color = ColorLerp(startC, endC, i); Color colorE = GREEN;
int size = Lerp(startR, endR, i);
DrawCircleV(point, size, color);
}
}
constexpr float screenWidth = 800;
constexpr float screenHeight = 800;
constexpr float len = 300;
constexpr float angleD = 100;
constexpr Vector2 start = {screenWidth / 2, screenHeight - 100};
constexpr float radius = 20;
constexpr float radiusS = 80;
constexpr float radiusE = 60;
constexpr Color colorS = RED;
constexpr Color colorE = GREEN;
typedef void (*slika)(); typedef void (*slika)();
Vector2 tstart = {10, 10};
int tsize = 30;
int idx = 0; int idx = 0;
std::vector<slika> v_slik = { std::vector<slika> v_slik = {
[]() []()
{ {
DrawText("Zacetna tocka", tstart.x, tstart.y, tsize, BLACK);
DrawCircleV(start, radius, BLACK); DrawCircleV(start, radius, BLACK);
}, },
[]() []()
{ {
Vector2 end = {start.x, start.y - len}; DrawText("Dolzina", tstart.x, tstart.y, tsize, BLACK);
DrawCircleV(start, radius, BLACK); DrawCircleV(start, radius, BLACK);
DrawLineEx(start, end, 10, BLACK); DrawLineEx(start, end, 10, BLACK);
}, },
[]() []()
{ {
Vector2 end = newPoint(start, len, angleD); DrawText("Kot in Koncna tocka", tstart.x, tstart.y, tsize, BLACK);
DrawCircleV(start, radius, BLACK); DrawCircleV(start, radius, BLACK);
DrawLineEx(start, end, 10, BLACK); DrawLineEx(start, end_kot, 10, BLACK);
DrawCircleV(end, radius, BLACK); DrawCircleV(end_kot, radius, BLACK);
DrawCircleSectorLines(start, len / 3, 360 - angleD, 360, 30, BLACK); DrawCircleSectorLines(start, len / 3, 360 - angleD, 360, 30, BLACK);
}, },
[]() []()
{ {
Vector2 end = newPoint(start, len, angleD); DrawText("Zacetna debelina", tstart.x, tstart.y, tsize, BLACK);
DrawCircleV(start, radius, BLACK); DrawCircleV(start, radius, BLACK);
DrawLineEx(start, end, 10, BLACK); DrawLineEx(start, end_kot, 10, BLACK);
DrawCircleV(end, radius, BLACK); DrawCircleV(end_kot, radius, BLACK);
DrawCircleLinesV(start, radiusS, BLACK); DrawCircleLinesV(start, radiusS, BLACK);
DrawCircleLinesV(end, radiusE, BLACK);
}, },
[]() []()
{ {
Vector2 end = newPoint(start, len, angleD); DrawText("Koncna debelina", tstart.x, tstart.y, tsize, BLACK);
DrawLineEx(start, end, 10, BLACK); DrawCircleV(start, radius, BLACK);
DrawLineEx(start, end_kot, 10, BLACK);
DrawCircleV(end_kot, radius, BLACK);
DrawCircleLinesV(start, radiusS, BLACK);
DrawCircleLinesV(end_kot, radiusE, BLACK);
},
[]()
{
DrawText("Zacetna barva", tstart.x, tstart.y, tsize, BLACK);
DrawLineEx(start, end_kot, 10, BLACK);
DrawCircleV(end_kot, radius, BLACK);
DrawCircleV(start, radiusS, colorS); DrawCircleV(start, radiusS, colorS);
DrawCircleV(end, radiusE, colorE); DrawCircleLinesV(end_kot, radiusE, BLACK);
}, },
[]() []()
{ {
Vector2 end = newPoint(start, len, angleD); DrawText("Koncna barva", tstart.x, tstart.y, tsize, BLACK);
drawBranch(start, end, colorS, colorE, radiusS, radiusE); DrawLineEx(start, end_kot, 10, BLACK);
DrawCircleV(start, radiusS, colorS);
DrawCircleV(end_kot, radiusE, colorE);
}, },
[]() []()
{ {
Vector2 p = newPoint(start, len, angleD); DrawText("Veja", tstart.x, tstart.y, tsize, BLACK);
drawBranch(start, p, colorS, colorE, radiusS, radiusE); float fstep = 0.05;
Vector2 p1 = newPoint(p, len, 135); for (float i = 0; i < 1.05; i += fstep)
Vector2 p2 = newPoint(p, len, 90); {
Vector2 p3 = newPoint(p, len, 45); Vector2 point = Vector2Lerp(start, end_kot, i);
DrawLineEx(p, p1, 10, BLACK); Color color = ColorLerp(colorS, colorE, i);
DrawLineEx(p, p2, 10, BLACK); int size = Lerp(radiusS, radiusE, i);
DrawLineEx(p, p3, 10, BLACK); DrawCircleV(point, size, color);
DrawCircleV(p, radius, BLACK); }
DrawCircleV(p1, radius, BLACK); }
DrawCircleV(p2, radius, BLACK);
DrawCircleV(p3, radius, BLACK);
},
[]()
{
Vector2 p = newPoint(start, len, angleD);
drawBranch(start, p, colorS, colorE, radiusS, radiusE);
Vector2 p1 = newPoint(p, len, 135);
Vector2 p2 = newPoint(p, len, 90);
Vector2 p3 = newPoint(p, len, 45);
drawBranch(p, p1, colorE, BLUE, radiusE, 50);
drawBranch(p, p2, colorE, ORANGE, radiusE, 50);
drawBranch(p, p3, colorE, PURPLE, radiusE, 50);
},
}; };
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int screenWidth = 500;
int screenHeight = 500;
float ny = len * sin(angleR);
float nx = len * cos(angleR);
end_kot.x = start.x + nx;
end_kot.y = start.y - ny;
InitWindow(screenWidth, screenHeight, "Slike"); InitWindow(screenWidth, screenHeight, "Slike");
SetTargetFPS(60); SetTargetFPS(60);

View File

@@ -136,11 +136,7 @@ namespace Similarity
} }
else if (f == &Similarity::hamming_distance) else if (f == &Similarity::hamming_distance)
{ {
return "hamming_distance"; return "hamming";
}
else if (f == &Similarity::hamming_distance_without_seeds)
{
return "hamming_distance_without_seeds";
} }
else if (f == &Similarity::levenshtein_distance) else if (f == &Similarity::levenshtein_distance)
{ {
@@ -148,7 +144,7 @@ namespace Similarity
} }
else else
{ {
return "unknown nameofFunc"; return "unknown";
} }
} }
@@ -171,6 +167,7 @@ namespace Similarity
const auto int_ms = std::chrono::duration_cast<std::chrono::microseconds>(stop - start); const auto int_ms = std::chrono::duration_cast<std::chrono::microseconds>(stop - start);
TraceLog(LOG_INFO, "%s, %d", nameofFunc(f), int_ms);
return average_similarity * 100.0f; return average_similarity * 100.0f;
} }

View File

@@ -28,7 +28,6 @@ public:
private: private:
bool showSelection; bool showSelection;
bool showStats; bool showStats;
bool saveToFile;
sqlite3 *db; sqlite3 *db;
sqlite3_stmt *get_gen_num; sqlite3_stmt *get_gen_num;
std::vector<int64_t> ids; std::vector<int64_t> ids;

View File

@@ -110,7 +110,7 @@ void Vapp::update()
stageOfDrawing = DrawingStage::save; stageOfDrawing = DrawingStage::save;
break; break;
case DrawingStage::save: case DrawingStage::save:
if(saveToFile) drawToFile(); drawToFile();
stageOfDrawing = DrawingStage::done; stageOfDrawing = DrawingStage::done;
break; break;
case DrawingStage::done: case DrawingStage::done:
@@ -140,10 +140,6 @@ void Vapp::draw()
{ {
setUpTable(); setUpTable();
} }
if(ImGui::MenuItem("Save to File", nullptr, saveToFile, true))
{
saveToFile = !saveToFile;
}
ImGui::EndMainMenuBar(); ImGui::EndMainMenuBar();
} }
@@ -339,28 +335,27 @@ void Vapp::setUpTable()
} }
sql::reset(get_gen_stmt); sql::reset(get_gen_stmt);
if(saveToFile)
int64_t id = ids[selected_id_index];
char buff[50];
sprintf(buff, "%ld.txt", id);
std::ofstream file(buff);
file << "| index | euclidean_distance | cosine_similarity | cosine_similarity_int | hamming_distance | levenshtein_distance | dot_minmax |\n";
file << "| --- | --- | --- | --- | --- | --- | --- |\n";
for (size_t i = 0; i < similTable.size(); i++)
{ {
int64_t id = ids[selected_id_index]; file << "|" << i << "|";
const char* buff = TextFormat("%ld.txt", id); for (size_t j = 0; j < similTable[i].size(); j++)
std::ofstream file(buff);
file << "| index | euclidean_distance | cosine_similarity | cosine_similarity_int | hamming_distance | levenshtein_distance | dot_minmax |\n";
file << "| --- | --- | --- | --- | --- | --- | --- |\n";
for (size_t i = 0; i < similTable.size(); i++)
{ {
file << "|" << i << "|"; file << similTable[i][j] << "|";
for (size_t j = 0; j < similTable[i].size(); j++)
{
file << similTable[i][j] << "|";
}
file << "\n";
} }
file << "\n";
} }
} }
sql::finalize(get_gen_stmt); sql::finalize(get_gen_stmt);
} }