Compare commits
10 Commits
FPS_Tests
...
98bc42be7d
| Author | SHA1 | Date | |
|---|---|---|---|
| 98bc42be7d | |||
| 208f849b47 | |||
| 771cabed8f | |||
| 96f4f51e69 | |||
| 525936c6e7 | |||
| 060b9f9182 | |||
| 59fd47e684 | |||
| 593b813988 | |||
| 5f6305a2f2 | |||
| dddf8ca632 |
@@ -33,7 +33,6 @@ add_library(shared STATIC
|
|||||||
shared/src/values/Similarity.cpp
|
shared/src/values/Similarity.cpp
|
||||||
shared/src/TcpSocket.cpp
|
shared/src/TcpSocket.cpp
|
||||||
shared/src/sql.cpp
|
shared/src/sql.cpp
|
||||||
shared/src/timing.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(app
|
add_executable(app
|
||||||
@@ -45,23 +44,23 @@ add_executable(app
|
|||||||
target_include_directories(app PRIVATE app/inc)
|
target_include_directories(app PRIVATE app/inc)
|
||||||
target_link_libraries(app PRIVATE shared)
|
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_link_libraries(server PRIVATE shared)
|
|
||||||
|
|
||||||
# add_executable(view
|
)
|
||||||
# view/src/main.cpp
|
target_include_directories(server PRIVATE server/inc)
|
||||||
# view/src/Vapp.cpp
|
target_link_libraries(server PRIVATE shared)
|
||||||
# )
|
|
||||||
# target_include_directories(view PRIVATE view/inc)
|
|
||||||
# target_link_libraries(view PRIVATE shared)
|
|
||||||
|
|
||||||
# add_executable(slike
|
add_executable(view
|
||||||
# random/slike.cpp
|
view/src/main.cpp
|
||||||
# )
|
view/src/Vapp.cpp
|
||||||
# target_link_libraries(slike PRIVATE shared)
|
)
|
||||||
|
target_include_directories(view PRIVATE view/inc)
|
||||||
|
target_link_libraries(view PRIVATE shared)
|
||||||
|
|
||||||
file(COPY CascadiaCode.ttf DESTINATION "res")
|
|
||||||
|
add_executable(slike
|
||||||
|
random/slike.cpp
|
||||||
|
)
|
||||||
|
target_link_libraries(slike PRIVATE shared)
|
||||||
BIN
CascadiaCode.ttf
BIN
CascadiaCode.ttf
Binary file not shown.
@@ -18,14 +18,30 @@ private:
|
|||||||
int screenWidth, screenHeight;
|
int screenWidth, screenHeight;
|
||||||
Canvas canvas;
|
Canvas canvas;
|
||||||
|
|
||||||
RenderTexture2D canvasTexure = {0};
|
int pos = 0;
|
||||||
|
std::array<RenderTexture2D, 2> canvasTexure = {0};
|
||||||
|
|
||||||
|
float rotation = 0.0f;
|
||||||
|
Vector2 mouseStart;
|
||||||
|
bool validHit = false;
|
||||||
|
float len;
|
||||||
|
float ofset;
|
||||||
|
|
||||||
|
Liked topLiked = Liked::tbd;
|
||||||
|
|
||||||
Rectangle destA;
|
Rectangle destA;
|
||||||
|
Rectangle destB;
|
||||||
|
Rectangle likeBox;
|
||||||
|
Rectangle disLikeBox;
|
||||||
|
|
||||||
UiUnit unit = {0};
|
std::array<UiUnit, 2> unit = {0};
|
||||||
|
|
||||||
DnaManagerData manager;
|
DnaManagerData manager;
|
||||||
|
|
||||||
|
Rectangle likedTextBox;
|
||||||
|
Rectangle genTextBox;
|
||||||
|
Rectangle simTextBox;
|
||||||
|
float simil = 100.0f;
|
||||||
|
|
||||||
|
Color appColor = BLUE;
|
||||||
};
|
};
|
||||||
|
|||||||
227
app/src/App.cpp
227
app/src/App.cpp
@@ -2,118 +2,241 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include "App.hpp"
|
#include "App.hpp"
|
||||||
#include "timing.hpp"
|
|
||||||
|
|
||||||
#include <raylib.h>
|
#include <raylib.h>
|
||||||
#include <raymath.h>
|
#include <raymath.h>
|
||||||
|
|
||||||
Font fontTtf;
|
#define TOP (1 - pos)
|
||||||
|
#define BOTTOM pos
|
||||||
|
|
||||||
void DrawTextB(const char *text, float posX, float posY, int fontSize, Color color)
|
Rectangle TextInSpace(Rectangle box, float textH, float textW, float margin, bool topOrBottom, bool leftOrRigth)
|
||||||
{
|
{
|
||||||
DrawTextEx(fontTtf, text, (Vector2){ posX, posY }, fontSize, 1, color);
|
float br = box.width / box.height;
|
||||||
|
float tr = textW / textH;
|
||||||
|
|
||||||
|
Rectangle ret = {0, 0, 0, 0};
|
||||||
|
|
||||||
|
float hm = box.height * margin;
|
||||||
|
float wm = box.width * margin;
|
||||||
|
|
||||||
|
ret.height = box.height - hm;
|
||||||
|
ret.width = box.width - wm;
|
||||||
|
|
||||||
|
if (br < tr)
|
||||||
|
{
|
||||||
|
// bolj kvadrat izracunaj visino iz sirine
|
||||||
|
ret.height = ret.width / tr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// bolj podolgovat izracunaj sirino iz visine
|
||||||
|
ret.width = ret.height * tr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (topOrBottom)
|
||||||
|
{
|
||||||
|
ret.y = box.y + hm;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret.y = box.y + box.height - hm - ret.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (leftOrRigth)
|
||||||
|
{
|
||||||
|
ret.x = box.x + wm;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret.x = box.x + box.width - wm - ret.width;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Dimentions for font size 20
|
||||||
|
// DISLIKE 83
|
||||||
|
// LIKE 46
|
||||||
|
// GEN 9999: 999/999 -> 200
|
||||||
|
constexpr float textMargin = 0.02f;
|
||||||
|
|
||||||
void App::init(int screenWidth, int screenHeight)
|
void App::init(int screenWidth, int screenHeight)
|
||||||
{
|
{
|
||||||
fontTtf = LoadFontEx("res/CascadiaCode.ttf", 32, 0, 0);
|
|
||||||
SetTextLineSpacing(16);
|
|
||||||
this->screenWidth = screenWidth;
|
this->screenWidth = screenWidth;
|
||||||
this->screenHeight = screenHeight;
|
this->screenHeight = screenHeight;
|
||||||
this->canvas.init(screenWidth);
|
this->canvas.init(screenWidth);
|
||||||
|
|
||||||
|
// int s = MeasureText("GEN 9999: 999/999", 20);
|
||||||
|
// TraceLog(LOG_INFO, "%d", s);
|
||||||
|
|
||||||
canvasTexure = LoadRenderTexture(screenWidth, screenWidth);
|
for (size_t i = 0; i < canvasTexure.size(); i++)
|
||||||
|
{
|
||||||
|
canvasTexure[i] = LoadRenderTexture(screenWidth, screenWidth);
|
||||||
|
}
|
||||||
|
|
||||||
DnaStore::load(&manager);
|
DnaStore::load(&manager);
|
||||||
|
simil = Similarity::calc_similarity(manager.vector);
|
||||||
upTex(Liked::tbd);
|
upTex(Liked::tbd);
|
||||||
while (!canvas.tick(canvasTexure))
|
while (!canvas.tick(canvasTexure[TOP]))
|
||||||
{
|
{
|
||||||
// wait to finish drawing
|
// wait to finish drawing
|
||||||
}
|
}
|
||||||
|
pos = 1 - pos;
|
||||||
|
upTex(Liked::tbd);
|
||||||
|
while (!canvas.tick(canvasTexure[TOP]))
|
||||||
|
{
|
||||||
|
// wait to finish drawing
|
||||||
|
}
|
||||||
|
pos = 1 - pos;
|
||||||
|
|
||||||
float posY = (screenHeight - screenWidth) / 2.0f;
|
float posY = (screenHeight - screenWidth) / 2.0f;
|
||||||
|
|
||||||
destA = {0, posY, (float)screenWidth, (float)screenWidth};
|
likedTextBox = TextInSpace({0,
|
||||||
|
0,
|
||||||
|
(float)screenWidth / 2.0f,
|
||||||
|
posY},
|
||||||
|
20.0f, 83.0f, textMargin, false, true);
|
||||||
|
|
||||||
|
genTextBox = TextInSpace({0,
|
||||||
|
posY + screenWidth,
|
||||||
|
(float)screenWidth,
|
||||||
|
posY},
|
||||||
|
20.0f, 200.0f, textMargin, true, true);
|
||||||
|
|
||||||
|
simTextBox = TextInSpace({(float)screenWidth / 2.0f,
|
||||||
|
likedTextBox.y,
|
||||||
|
(float)screenWidth / 2.0f,
|
||||||
|
likedTextBox.height},
|
||||||
|
20.0f, 60.0f, textMargin, false, false);
|
||||||
|
|
||||||
|
destB = {0, posY, (float)screenWidth, (float)screenWidth};
|
||||||
|
destA = destB;
|
||||||
|
|
||||||
|
float recPosX = screenWidth * 0.3f;
|
||||||
|
disLikeBox = {0, posY, (float)recPosX, (float)screenWidth};
|
||||||
|
likeBox = {screenWidth - recPosX, posY, (float)recPosX, (float)screenWidth};
|
||||||
|
|
||||||
|
if(!DnaStore::ping()){
|
||||||
|
appColor = RED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::upTex(Liked liked)
|
void App::upTex(Liked liked)
|
||||||
{
|
{
|
||||||
if (liked != Liked::tbd)
|
if (liked != Liked::tbd)
|
||||||
{
|
{
|
||||||
unit.liked = liked;
|
unit[TOP].liked = liked;
|
||||||
bool ng = DnaManager::like(unit, &manager);
|
bool ng = DnaManager::like(unit[TOP], &manager);
|
||||||
|
|
||||||
if (ng)
|
if (ng)
|
||||||
{
|
{
|
||||||
DnaStore::saveGen(&manager);
|
DnaStore::saveGen(&manager);
|
||||||
DnaManager::newGen(&manager);
|
DnaManager::newGen(&manager);
|
||||||
DnaStore::saveVec(&manager);
|
DnaStore::saveVec(&manager);
|
||||||
|
simil = Similarity::calc_similarity(manager.vector);
|
||||||
}
|
}
|
||||||
DnaStore::saveData(&manager);
|
DnaStore::saveData(&manager);
|
||||||
}
|
}
|
||||||
unit = DnaManager::next(&manager);
|
unit[TOP] = DnaManager::next(&manager);
|
||||||
if (unit.dna != nullptr)
|
if (unit[TOP].dna != nullptr)
|
||||||
{
|
{
|
||||||
canvas.newGen(canvasTexure, unit.dna);
|
canvas.newGen(canvasTexure[TOP], unit[TOP].dna);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BeginTextureMode(canvasTexure);
|
BeginTextureMode(canvasTexure[TOP]);
|
||||||
ClearBackground(BLACK);
|
ClearBackground(BLACK);
|
||||||
DrawText("NEXT GEN", 10, 10, screenWidth/10, WHITE);
|
DrawText("NEXT GEN", 10, 10, screenWidth/10, WHITE);
|
||||||
EndTextureMode();
|
EndTextureMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::update(){}
|
void App::update()
|
||||||
|
{
|
||||||
|
bool isDone = canvas.tick(canvasTexure[BOTTOM]);
|
||||||
|
Vector2 mousePosition = GetMousePosition();
|
||||||
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
|
||||||
|
{
|
||||||
|
mouseStart = mousePosition;
|
||||||
|
validHit = CheckCollisionPointRec(mouseStart, destA);
|
||||||
|
len = Vector2Distance(mouseStart, {destB.x, destB.y});
|
||||||
|
ofset = std::atan2(destB.x - mouseStart.x, destB.y - mouseStart.y);
|
||||||
|
}
|
||||||
|
|
||||||
enum class Rend_type{
|
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT) && validHit)
|
||||||
every_frame,
|
{
|
||||||
in_one_frame,
|
float dist = mousePosition.x - mouseStart.x;
|
||||||
over_frames,
|
float l = dist / screenWidth;
|
||||||
};
|
rotation = Lerp(45.0f, -45.0f, (l + 1) / 2);
|
||||||
|
|
||||||
constexpr Rend_type rend_type = Rend_type::over_frames;
|
float angle = ((rotation)*PI) / 180.0f;
|
||||||
|
angle += ofset;
|
||||||
|
Vector2 newCenter = {.x = len * std::sin(angle), .y = len * std::cos(angle)};
|
||||||
|
|
||||||
|
destA.x = newCenter.x + mousePosition.x;
|
||||||
|
destA.y = newCenter.y + mousePosition.y;
|
||||||
|
|
||||||
|
if (CheckCollisionPointRec(mousePosition, disLikeBox))
|
||||||
|
{
|
||||||
|
topLiked = Liked::no;
|
||||||
|
}
|
||||||
|
else if (CheckCollisionPointRec(mousePosition, likeBox))
|
||||||
|
{
|
||||||
|
topLiked = Liked::yes;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
topLiked = Liked::tbd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsMouseButtonReleased(MOUSE_BUTTON_LEFT) && validHit)
|
||||||
|
{
|
||||||
|
if (isDone)
|
||||||
|
{
|
||||||
|
if (topLiked != Liked::tbd)
|
||||||
|
{
|
||||||
|
upTex(topLiked);
|
||||||
|
pos = 1 - pos; // switch bottom and top
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rotation = 0.0f;
|
||||||
|
destA = destB;
|
||||||
|
topLiked = Liked::tbd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void App::draw()
|
void App::draw()
|
||||||
{
|
{
|
||||||
if (IsMouseButtonReleased(MOUSE_BUTTON_LEFT))
|
ClearBackground(appColor);
|
||||||
{
|
|
||||||
TraceLog(LOG_INFO, "CLICK");
|
|
||||||
upTex(Liked::yes);
|
|
||||||
if constexpr (rend_type == Rend_type::in_one_frame){
|
|
||||||
while (!canvas.tick(canvasTexure))
|
|
||||||
{
|
|
||||||
// wait to finish drawing
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if constexpr (rend_type == Rend_type::over_frames){
|
|
||||||
canvas.tick(canvasTexure);
|
|
||||||
}
|
|
||||||
ClearBackground(BLUE);
|
|
||||||
|
|
||||||
int fps = GetFPS();
|
|
||||||
const char* fpstext = TextFormat("%04d FPS", fps);
|
|
||||||
DrawTextB(fpstext, 10, 10, 36, BLACK);
|
|
||||||
const char* ctext = TextFormat("%04ld Circles", canvas.tree.circles);
|
|
||||||
DrawTextB(ctext, 10, 50, 36, BLACK);
|
|
||||||
|
|
||||||
Rectangle source = {0, 0, (float)screenWidth, (float)-screenWidth};
|
Rectangle source = {0, 0, (float)screenWidth, (float)-screenWidth};
|
||||||
Vector2 origin = {0.0f, 0.0f};
|
Vector2 origin = {0.0f, 0.0f};
|
||||||
if constexpr (rend_type == Rend_type::every_frame){
|
|
||||||
canvas.newGen(canvasTexure, unit.dna);
|
DrawTexturePro(canvasTexure[BOTTOM].texture, source, destB, origin, 0.0f, WHITE);
|
||||||
while (!canvas.tick(canvasTexure))
|
|
||||||
{
|
DrawTexturePro(canvasTexure[TOP].texture, source, destA, origin, 360 - rotation, WHITE);
|
||||||
// wait to finish drawing
|
|
||||||
}
|
const char *textGen = TextFormat("GEN %d: %d / %d", manager.generation, unit[TOP].index + 1, NUM_PER_GEN);
|
||||||
|
DrawText(textGen, genTextBox.x, genTextBox.y, genTextBox.height, BLACK);
|
||||||
|
const char *textProc = TextFormat("%.1f%%", simil);
|
||||||
|
DrawText(textProc, simTextBox.x, simTextBox.y, simTextBox.height, BLACK);
|
||||||
|
switch (topLiked)
|
||||||
|
{
|
||||||
|
case Liked::yes:
|
||||||
|
DrawText("LIKED", likedTextBox.x, likedTextBox.y, likedTextBox.height, BLACK);
|
||||||
|
break;
|
||||||
|
case Liked::no:
|
||||||
|
DrawText("DISLIKE", likedTextBox.x, likedTextBox.y, likedTextBox.height, BLACK);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
DrawTexturePro(canvasTexure.texture, source, destA, origin, 360, WHITE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::deinit()
|
void App::deinit()
|
||||||
{
|
{
|
||||||
UnloadRenderTexture(canvasTexure);
|
for (size_t i = 0; i < canvasTexure.size(); i++)
|
||||||
UnloadFont(fontTtf);
|
{
|
||||||
|
UnloadRenderTexture(canvasTexure[i]);
|
||||||
|
}
|
||||||
canvas.deinit();
|
canvas.deinit();
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
#include <raylib.h>
|
#include <raylib.h>
|
||||||
#include "App.hpp"
|
#include "App.hpp"
|
||||||
#include "timing.hpp"
|
|
||||||
|
|
||||||
#if defined(PLATFORM_WEB)
|
#if defined(PLATFORM_WEB)
|
||||||
#include <emscripten/emscripten.h>
|
#include <emscripten/emscripten.h>
|
||||||
@@ -8,14 +7,12 @@
|
|||||||
|
|
||||||
static App app;
|
static App app;
|
||||||
|
|
||||||
Timer t;
|
|
||||||
void UpdateDrawFrame()
|
void UpdateDrawFrame()
|
||||||
{
|
{
|
||||||
t.reset_and_start();
|
app.update();
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
app.draw();
|
app.draw();
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
t.stop_and_print("to draw frame");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
@@ -37,7 +34,7 @@ int main(void)
|
|||||||
#if defined(PLATFORM_WEB)
|
#if defined(PLATFORM_WEB)
|
||||||
emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
|
emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
|
||||||
#else
|
#else
|
||||||
// SetTargetFPS(60);
|
SetTargetFPS(60);
|
||||||
while (!WindowShouldClose())
|
while (!WindowShouldClose())
|
||||||
{
|
{
|
||||||
UpdateDrawFrame();
|
UpdateDrawFrame();
|
||||||
|
|||||||
123
random/slike.cpp
123
random/slike.cpp
@@ -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);
|
},
|
||||||
|
|
||||||
|
[]()
|
||||||
|
{
|
||||||
|
DrawText("Koncna debelina", tstart.x, tstart.y, tsize, 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);
|
||||||
},
|
},
|
||||||
|
|
||||||
[]()
|
[]()
|
||||||
{
|
{
|
||||||
Vector2 end = newPoint(start, len, angleD);
|
DrawText("Zacetna barva", tstart.x, tstart.y, tsize, BLACK);
|
||||||
DrawLineEx(start, end, 10, 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);
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ public:
|
|||||||
void newGen(RenderTexture2D &target, Dna *dna);
|
void newGen(RenderTexture2D &target, Dna *dna);
|
||||||
bool tick(RenderTexture2D &target);
|
bool tick(RenderTexture2D &target);
|
||||||
|
|
||||||
|
private:
|
||||||
BackGround backGround;
|
BackGround backGround;
|
||||||
Tree tree;
|
Tree tree;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ public:
|
|||||||
void init(int size);
|
void init(int size);
|
||||||
void draw(Dna *dna);
|
void draw(Dna *dna);
|
||||||
bool tick();
|
bool tick();
|
||||||
uint64_t circles;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Dna *m_dna;
|
Dna *m_dna;
|
||||||
@@ -35,8 +34,7 @@ private:
|
|||||||
|
|
||||||
void calculateBranch();
|
void calculateBranch();
|
||||||
|
|
||||||
void drawBranch_rlTriangle(Vector2 startPoint, Vector2 endPoint, Color startColor, Color endColor, float startThickness, float endThickness, float length);
|
void drawBranch(Vector2 startPoint, Vector2 endPoint, Color startColor, Color endColor, float startThickness, float endThickness);
|
||||||
void drawBranch_circles(Vector2 startPoint, Vector2 endPoint, Color startColor, Color endColor, float startThickness, float endThickness, float length);
|
|
||||||
inline size_t getNumOfBranches(int dep);
|
inline size_t getNumOfBranches(int dep);
|
||||||
inline Color getStartColor(DrawArgs &arg);
|
inline Color getStartColor(DrawArgs &arg);
|
||||||
inline Color getEndColor(int dep, Color &start);
|
inline Color getEndColor(int dep, Color &start);
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
|
|
||||||
#include <chrono>
|
|
||||||
|
|
||||||
|
|
||||||
struct Timer
|
|
||||||
{
|
|
||||||
std::chrono::steady_clock::time_point start_t;
|
|
||||||
std::chrono::steady_clock::time_point end_t;
|
|
||||||
std::chrono::nanoseconds dur;
|
|
||||||
void start();
|
|
||||||
void stop();
|
|
||||||
void reset();
|
|
||||||
void print(const char * str);
|
|
||||||
void stop_and_print(const char * str);
|
|
||||||
void reset_and_start();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "canvas/Canvas.hpp"
|
#include "canvas/Canvas.hpp"
|
||||||
#include "timing.hpp"
|
|
||||||
|
|
||||||
void Canvas::init(int size)
|
void Canvas::init(int size)
|
||||||
{
|
{
|
||||||
@@ -7,13 +6,8 @@ void Canvas::init(int size)
|
|||||||
tree.init(size);
|
tree.init(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool finished = false;
|
|
||||||
Timer timer;
|
|
||||||
void Canvas::newGen(RenderTexture2D &target, Dna *dna)
|
void Canvas::newGen(RenderTexture2D &target, Dna *dna)
|
||||||
{
|
{
|
||||||
|
|
||||||
finished = false;
|
|
||||||
timer.reset_and_start();
|
|
||||||
BeginTextureMode(target);
|
BeginTextureMode(target);
|
||||||
ClearBackground(WHITE);
|
ClearBackground(WHITE);
|
||||||
|
|
||||||
@@ -21,20 +15,13 @@ void Canvas::newGen(RenderTexture2D &target, Dna *dna)
|
|||||||
tree.draw(dna);
|
tree.draw(dna);
|
||||||
|
|
||||||
EndTextureMode();
|
EndTextureMode();
|
||||||
timer.stop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Canvas::tick(RenderTexture2D &target)
|
bool Canvas::tick(RenderTexture2D &target)
|
||||||
{
|
{
|
||||||
timer.start();
|
|
||||||
BeginTextureMode(target);
|
BeginTextureMode(target);
|
||||||
bool ret = tree.tick();
|
bool ret = tree.tick();
|
||||||
EndTextureMode();
|
EndTextureMode();
|
||||||
timer.stop();
|
|
||||||
if(ret && !finished){
|
|
||||||
finished = true;
|
|
||||||
timer.print("to draw canvas");
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include "canvas/Tree.hpp"
|
#include "canvas/Tree.hpp"
|
||||||
#include "timing.hpp"
|
|
||||||
|
|
||||||
#include <raylib.h>
|
#include <raylib.h>
|
||||||
#include <raymath.h>
|
#include <raymath.h>
|
||||||
#include <rlgl.h>
|
#include <rlgl.h>
|
||||||
|
|
||||||
#define ITER_PER_FRAME 10000
|
#define ITER_PER_FRAME 5000
|
||||||
|
|
||||||
constexpr int maxColorChange = 15;
|
constexpr int maxColorChange = 15;
|
||||||
constexpr int minColorChange = -15;
|
constexpr int minColorChange = -15;
|
||||||
@@ -47,23 +46,22 @@ void Tree::init(int size)
|
|||||||
|
|
||||||
void Tree::draw(Dna *dna)
|
void Tree::draw(Dna *dna)
|
||||||
{
|
{
|
||||||
circles = 0;
|
|
||||||
m_dna = dna;
|
m_dna = dna;
|
||||||
branchSeed = dna->branchSeed;
|
branchSeed = dna->branchSeed;
|
||||||
drawCalls.push_back({start, 180.0f, 0});
|
drawCalls.push_back({start, 180.0f, 0});
|
||||||
|
tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Tree::tick()
|
bool Tree::tick()
|
||||||
{
|
{
|
||||||
using namespace std::chrono;
|
size_t i = 0;
|
||||||
auto start = steady_clock::now();
|
while (!drawCalls.empty())
|
||||||
nanoseconds dur = 0us;
|
|
||||||
while (!drawCalls.empty() && dur < 14ms)
|
|
||||||
{
|
{
|
||||||
calculateBranch();
|
calculateBranch();
|
||||||
drawCalls.pop_front();
|
drawCalls.pop_front();
|
||||||
auto end = steady_clock::now();
|
i++;
|
||||||
dur = end - start;
|
if (i >= ITER_PER_FRAME)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return drawCalls.empty();
|
return drawCalls.empty();
|
||||||
@@ -85,13 +83,20 @@ void Tree::calculateBranch()
|
|||||||
|
|
||||||
int sizeStart = getStartSize(arg);
|
int sizeStart = getStartSize(arg);
|
||||||
int sizeEnd = getEndSize(arg, sizeStart);
|
int sizeEnd = getEndSize(arg, sizeStart);
|
||||||
|
float fstep = 1.0 / ((length / sizeStart) * 2.0f);
|
||||||
|
|
||||||
Color colorStart = getStartColor(arg);
|
Color colorStart = getStartColor(arg);
|
||||||
Color colorEnd = getEndColor(arg.dep, colorStart);
|
Color colorEnd = getEndColor(arg.dep, colorStart);
|
||||||
// drawBranch_rlTriangle(arg.start, end, colorStart, colorEnd, sizeStart, sizeEnd, length);
|
// drawBranch(arg.start, end, colorStart, colorEnd, sizeStart, sizeEnd);
|
||||||
drawBranch_circles(arg.start, end, colorStart, colorEnd, sizeStart, sizeEnd, length);
|
for (float i = 0; i < 1; i += fstep)
|
||||||
// DrawLineEx(arg.start, end, sizeStart, colorStart);
|
{
|
||||||
|
Vector2 point = Vector2Lerp(arg.start, end, i);
|
||||||
|
Color color = ColorLerp(colorStart, colorEnd, i);
|
||||||
|
int size = Lerp(sizeStart, sizeEnd, i);
|
||||||
|
DrawCircleV(point, size, color);
|
||||||
|
// DrawTextureEx(texBunny, point,0, ((float)size) / texBunny.height, color);
|
||||||
|
}
|
||||||
|
|
||||||
// add more branches to draw
|
// add more branches to draw
|
||||||
|
|
||||||
if (arg.dep + 1 >= MAX_DEPTH)
|
if (arg.dep + 1 >= MAX_DEPTH)
|
||||||
@@ -109,7 +114,6 @@ void Tree::calculateBranch()
|
|||||||
|
|
||||||
inline size_t Tree::getNumOfBranches(int dep)
|
inline size_t Tree::getNumOfBranches(int dep)
|
||||||
{
|
{
|
||||||
return 3;
|
|
||||||
if (m_dna->branches[dep].branchCount < 128)
|
if (m_dna->branches[dep].branchCount < 128)
|
||||||
return 2;
|
return 2;
|
||||||
else
|
else
|
||||||
@@ -159,7 +163,7 @@ inline int Tree::getStartSize(DrawArgs &arg)
|
|||||||
float mixLevel = m_dna->branches[arg.dep].sizeLevel / 255.0f;
|
float mixLevel = m_dna->branches[arg.dep].sizeLevel / 255.0f;
|
||||||
size = std::lerp(size, sizes[MAX_DEPTH - arg.dep - 1], mixLevel);
|
size = std::lerp(size, sizes[MAX_DEPTH - arg.dep - 1], mixLevel);
|
||||||
|
|
||||||
//if (size < 1)
|
if (size < 1)
|
||||||
size = 1;
|
size = 1;
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
@@ -169,7 +173,7 @@ inline int Tree::getEndSize(DrawArgs &arg, int start)
|
|||||||
int size = Remap(m_dna->branches[arg.dep].sizeChange, 0, 255, MinSizeChange, maxSizeChange);
|
int size = Remap(m_dna->branches[arg.dep].sizeChange, 0, 255, MinSizeChange, maxSizeChange);
|
||||||
size += start;
|
size += start;
|
||||||
|
|
||||||
//if (size < 1)
|
if (size < 1)
|
||||||
size = 1;
|
size = 1;
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
@@ -177,9 +181,9 @@ inline int Tree::getEndSize(DrawArgs &arg, int start)
|
|||||||
inline float Tree::getLength(DrawArgs &arg)
|
inline float Tree::getLength(DrawArgs &arg)
|
||||||
{
|
{
|
||||||
float lenght = lengths[arg.dep];
|
float lenght = lengths[arg.dep];
|
||||||
float lenghtRatio = Remap(255, 0, 255, 0.5f, 1.3f);
|
float lenghtRatio = Remap(m_dna->branches[arg.dep].length, 0, 255, 0.5f, 1.3f);
|
||||||
lenght *= lenghtRatio;
|
lenght *= lenghtRatio;
|
||||||
float lenghtVar = Remap(255, 0, 255, -0.15f, 0.15f);
|
float lenghtVar = Remap(m_dna->branches[arg.dep].lengthVar, 0, 255, -0.15f, 0.15f);
|
||||||
lenght += lenght * lenghtVar * mrand::getFloat(&branchSeed);
|
lenght += lenght * lenghtVar * mrand::getFloat(&branchSeed);
|
||||||
if (lenght < 1)
|
if (lenght < 1)
|
||||||
lenght = 1;
|
lenght = 1;
|
||||||
@@ -195,28 +199,15 @@ inline float Tree::getAngleVar(DrawArgs &arg)
|
|||||||
return angleVar;
|
return angleVar;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tree::drawBranch_circles(Vector2 startPoint, Vector2 endPoint, Color startColor, Color endColor, float startThickness, float endThickness, float length)
|
void Tree::drawBranch(Vector2 startPoint, Vector2 endPoint, Color startColor, Color endColor, float startThickness, float endThickness)
|
||||||
{
|
|
||||||
|
|
||||||
float fstep = 1.0 / ((length / startThickness) * 2.0f);
|
|
||||||
for (float i = 0; i < 1; i += fstep)
|
|
||||||
{
|
|
||||||
Vector2 point = Vector2Lerp(startPoint, endPoint, i);
|
|
||||||
Color color = ColorLerp(startColor, endColor, i);
|
|
||||||
int size = Lerp(startThickness, endThickness, i);
|
|
||||||
DrawCircleV(point, size, color);
|
|
||||||
circles++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Tree::drawBranch_rlTriangle(Vector2 startPoint, Vector2 endPoint, Color startColor, Color endColor, float startThickness, float endThickness, float length)
|
|
||||||
{
|
{
|
||||||
DrawCircleV(startPoint, startThickness, startColor);
|
|
||||||
DrawCircleV(endPoint, endThickness, endColor);
|
|
||||||
// Calculate the direction vector from startPoint to endPoint
|
// Calculate the direction vector from startPoint to endPoint
|
||||||
Vector2 direction = {endPoint.x - startPoint.x, endPoint.y - startPoint.y};
|
Vector2 direction = {endPoint.x - startPoint.x, endPoint.y - startPoint.y};
|
||||||
|
|
||||||
// Normalize the direction vector
|
// Normalize the direction vector
|
||||||
|
float length = sqrtf(direction.x * direction.x + direction.y * direction.y);
|
||||||
|
if (length == 0)
|
||||||
|
length = 1; // Avoid division by zero
|
||||||
Vector2 normalizedDir = {direction.x / length, direction.y / length};
|
Vector2 normalizedDir = {direction.x / length, direction.y / length};
|
||||||
|
|
||||||
// Calculate the perpendicular vector (rotate 90 degrees)
|
// Calculate the perpendicular vector (rotate 90 degrees)
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
#include <raylib.h>
|
|
||||||
#include <chrono>
|
|
||||||
#include "timing.hpp"
|
|
||||||
|
|
||||||
using namespace std::chrono;
|
|
||||||
|
|
||||||
void Timer::start()
|
|
||||||
{
|
|
||||||
start_t = std::chrono::steady_clock::now();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Timer::stop()
|
|
||||||
{
|
|
||||||
end_t = std::chrono::steady_clock::now();
|
|
||||||
dur += end_t - start_t;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Timer::reset()
|
|
||||||
{
|
|
||||||
dur = 0ns;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Timer::print(const char * str)
|
|
||||||
{
|
|
||||||
auto s = std::chrono::duration_cast<std::chrono::milliseconds>(dur);
|
|
||||||
if (s > 1000us)
|
|
||||||
{
|
|
||||||
TraceLog(LOG_INFO, "%ld ms %s", s.count(), str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Timer::stop_and_print(const char *str)
|
|
||||||
{
|
|
||||||
stop();
|
|
||||||
print(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Timer::reset_and_start()
|
|
||||||
{
|
|
||||||
reset();
|
|
||||||
start();
|
|
||||||
}
|
|
||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user