Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Clean legacy code #115

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 0 additions & 2 deletions src/AIAC/EventSys/SLAMEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ namespace AIAC

// start mapping
AIAC_APP.GetLayer<AIAC::LayerSlam>()->StartMapping();
AIAC_APP.GetRenderer()->StartMapping();
}

void SLAMStopMappingEvent::OnSLAMStopMapping()
Expand All @@ -82,7 +81,6 @@ namespace AIAC

AIAC_INFO("Stop mapping");
AIAC_APP.GetLayer<AIAC::LayerSlam>()->StopMapping();
AIAC_APP.GetRenderer()->StopMapping();

// Optimize Map
if(m_ToOptimize && m_ToSave) {
Expand Down
4 changes: 4 additions & 0 deletions src/AIAC/GOSys/GOPrimitive.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#include "aiacpch.h"

#include "assimp/Importer.hpp" // C++ importer interface
#include "assimp/scene.h" // Output data structure
#include "assimp/postprocess.h" // Post processing flags

#include "glm/gtx/string_cast.hpp"

#include "AIAC/Log.h"
#include "AIAC/GOSys/GOPrimitive.h"
#include "AIAC/Application.h"
Expand Down
6 changes: 2 additions & 4 deletions src/AIAC/LayerUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ namespace AIAC
ImGui::BeginChild("camera_function_child", ImVec2(0, 50), true, ImGuiWindowFlags_HorizontalScrollbar);
ImGui::PushStyleColor(ImGuiCol_Button, AIAC_UI_LIGHT_GREY);
if(ImGui::Button("Start Calibration")){
AIAC_APP.GetRenderer()->StartCamCalib();
AIAC_APP.GetLayer<LayerCameraCalib>()->StartCalibration();
}
ImGui::SameLine();
Expand Down Expand Up @@ -462,7 +461,7 @@ namespace AIAC
ImGui::Text("ACIM File Manager:");
ImGui::BeginChild("ACIM File Manager", ImVec2(0, 60), true, ImGuiWindowFlags_HorizontalScrollbar);
std::string currentACIMFileEntry = "Current ACIM: " + AIAC_APP.GetLayer<LayerModel>()->GetACInfoModelName();
ImGui::Text(currentACIMFileEntry.c_str());
ImGui::Text("%s", currentACIMFileEntry.c_str());
if(ImGui::Button("Load ACIM")){
OpenFileSelectDialog("Open ACIM file", ".acim", m_TmpPathBuf, [&]{
AIAC_APP.GetLayer<AIAC::LayerModel>()->LoadACInfoModel(m_TmpPathBuf);
Expand Down Expand Up @@ -492,7 +491,7 @@ namespace AIAC
if (sliderVal != 0.f) AIAC_APP.GetLayer<AIAC::LayerModel>()->AddAlignOffset(sliderVal);
sliderVal = 0.f;
ImGui::SameLine();
ImGui::Text(std::to_string(AIAC_APP.GetLayer<AIAC::LayerModel>()->GetAlignOffset()).c_str());
ImGui::Text("%s", std::to_string(AIAC_APP.GetLayer<AIAC::LayerModel>()->GetAlignOffset()).c_str());

ImGui::PushStyleColor(ImGuiCol_Button, AIAC_UI_ROYAL_PURPLE);
if(ImGui::Button("Align Center")){
Expand Down Expand Up @@ -1200,7 +1199,6 @@ namespace AIAC
ImGui::SameLine();
if(ImGui::Button("Exit")){
AIAC_APP.GetLayer<AIAC::LayerCameraCalib>()->StopCalibration();
AIAC_APP.GetRenderer()->StopCamCalib();
}
} ImGui::EndChild();
} ImGui::EndChild();
Expand Down
117 changes: 0 additions & 117 deletions src/AIAC/Mesh.cpp

This file was deleted.

52 changes: 0 additions & 52 deletions src/AIAC/Mesh.h

This file was deleted.

7 changes: 4 additions & 3 deletions src/AIAC/Render/RenderAPI.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#include <ft2build.h>
#include FT_FREETYPE_H

#include "GlUtils.h"
#include "RenderAPI.h"
#include "TextRenderer.h"
#include "AIAC/Log.h"

#include <ft2build.h>
#include FT_FREETYPE_H
#include "AIAC/Application.h"

namespace AIAC
Expand Down
6 changes: 5 additions & 1 deletion src/AIAC/Render/RenderAPI.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#pragma once

#include <memory>
#include <vector>

#include "map.h" // TSLAM map

#include "TextRenderer.h"
#include "GlUtils.h"
#include "AIAC/GOSys/GOPrimitive.h"

namespace AIAC
Expand Down
71 changes: 0 additions & 71 deletions src/AIAC/Render/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,45 +45,6 @@ namespace AIAC
InitCamCalibView();

m_MappingView.SetSize(600, 442);

// auto pt = GOPoint::Add(0, 0, 0, 5.0f);
// pt->SetColor(glm::vec4(1.0f, 0.0f, 0.0f, 1.0f));

// GOLine::Add(glm::vec3(0,0,0), glm::vec3(0,0,10), 10.0f);

// cout << "--------------------" << endl;
// auto myCylinder = GOCylinder::Add(glm::vec3(50,10,0), glm::vec3(50,0,10), 32.0f);
// myCylinder->SetColor(glm::vec4(0.5f, 0.5f, 0.0f, 0.2f));
// cout << "--------------------" << endl;

// vector<glm::vec3> pts;
// pts.push_back(glm::vec3(4,0,0));
// pts.push_back(glm::vec3(99,5,10));
// pts.push_back(glm::vec3(9,10,10));
// auto myPolyline = GOPolyline::Add(pts);
// myPolyline->SetColor(glm::vec4(0.5f, 0.2f, 0.0f, 1.0f));

// auto circle = GOCircle::Add(glm::vec3(0, 5, 0), 10.0f);
// circle->SetColor(glm::vec4(1.0f, 0.0f, 0.0f, 1.0f));

// std::vector<glm::vec3> vertices = {
// glm::vec3(0.0f, 0.0f, 10.0f),
// glm::vec3(0.0f, 0.0f, 0.0f),
// glm::vec3(0.0f, 10.0f, 0.0f),
// glm::vec3(10.0f, 0.0f, 0.0f),
// };
// std::vector<glm::vec4> colors = {
// glm::vec4(1.0f, 0.0f, 0.0f, 1.0f),
// glm::vec4(0.0f, 1.0f, 1.0f, 1.0f),
// glm::vec4(0.0f, 1.0f, 0.0f, 1.0f),
// glm::vec4(0.0f, 0.0f, 1.0f, 1.0f),
// };

// m_TestGLObject = std::make_shared<GLPointObject>(vertices, colors, 3.0f);
// glBindVertexArray(m_VAO);
// m_TestGLObject = glCreatePoints(vertices, colors, 3);
// cout << "m_TestGLObject: " << m_TestGLObject.vertexBuf << endl;

}

void Renderer::InitProjMatrix(){
Expand Down Expand Up @@ -254,23 +215,6 @@ namespace AIAC
glm::mat4 finalPoseMatrix = m_GlobalProjMatrix * m_GlobalCamMatrix;
glUniformMatrix4fv(m_MatrixId, 1, GL_FALSE, &finalPoseMatrix[0][0]);

// if(ShowPointCloudMap){
// PointCloudMap.DrawVertices(m_PointCloudMapColor, 1);
// }
// if(ShowDigitalModel){
// DigitalModel.DrawBoundingBoxEdges(m_DigitalModelBoundingBoxColor);
// DigitalModel.DrawFaces(m_DigitalModelFaceColor);
// }

// DrawSlamMap(AIAC_APP.GetLayer<LayerSlam>()->Slam.getMap(), glm::vec4(1, 0, 0, 1));

// visualize camera
// auto camPoseInv = AIAC_APP.GetLayer<LayerSlam>()->GetInvCamPoseGlm(); // camera pose in world space
// glm::mat4 cameraSpaceMVP = m_GlobalProjMatrix * m_GlobalCamMatrix * camPoseInv;
// glUniformMatrix4fv(m_MatrixId, 1, GL_FALSE, &cameraSpaceMVP[0][0]);
// // glDrawLines3d(m_CamVisualizationEdges, glm::vec4(0, 0, 1, 1));
// glUniformMatrix4fv(m_MatrixId, 1, GL_FALSE, &finalPoseMatrix[0][0]);

// Draw All objects
DrawAllGOs(finalPoseMatrix, 0.05f);

Expand Down Expand Up @@ -326,21 +270,6 @@ namespace AIAC
// Draw the essential objects: map, point cloud map and digital model !
// glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glm::vec4 edgeColor;
// if(AIAC_APP.GetLayer<LayerSlam>()->IsTracked()) {
// // if(ShowPointCloudMap){
// // PointCloudMap.DrawVertices(m_PointCloudMapColor, 1);
// // }
// // if(ShowDigitalModel){
// // DigitalModel.DrawBoundingBoxEdges(m_DigitalModelBoundingBoxColor);
// // DigitalModel.DrawFaces(m_DigitalModelFaceColor);
// // }
// // for (auto& mesh : Meshes) {
// // mesh.DrawEdges(m_DefaultEdgeColor);
// // }
// // Draw All objects
// // DrawSlamMap(AIAC_APP.GetLayer<LayerSlam>()->Slam.getMap(), glm::vec4(1, 0, 0, 1));
// DrawAllGOs(finalPoseMatrix);
// }
if (AIAC_APP.GetLayer<LayerSlam>()->GetNumLostFrame() <= 3){
DrawAllGOs(finalPoseMatrix);
}
Expand Down
13 changes: 0 additions & 13 deletions src/AIAC/Render/Renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include "glm/glm.hpp"

#include "AIAC/Mesh.h"
#include "AIAC/GlHeader.h"
#include "AIAC/Layer.h"

Expand Down Expand Up @@ -44,14 +43,10 @@ namespace AIAC
void UpdateGlobalViewCameraScale(double diff);

// Mapping View
void StartMapping() { ShowDigitalModel = false; ShowPointCloudMap = false; }
void StopMapping() { ShowDigitalModel = true; ShowPointCloudMap = true; }
GLuint GetMappingView() const { return m_MappingView.GetTexture(); };
void SetMappingViewSize(float w, float h);

// CamCalib view
void StartCamCalib() { Meshes.clear(); ShowDigitalModel = false; ShowPointCloudMap = false; }
void StopCamCalib() { ShowDigitalModel = true; ShowPointCloudMap = true; }
GLuint GetCamCalibView() const { return m_CamCalibView.GetTexture(); };
void SetCamCalibViewSize(float w, float h);

Expand All @@ -63,14 +58,6 @@ namespace AIAC
SLAM_PROCESSED
};

public:
AIAC::Mesh PointCloudMap;
AIAC::Mesh DigitalModel;
std::vector<AIAC::Mesh> Meshes;

bool ShowPointCloudMap = true;
bool ShowDigitalModel = true;

private:
void RenderMainView();

Expand Down
Loading