Skip to content

Commit

Permalink
chore: docs and generator
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioRodrigues10 committed Feb 16, 2024
1 parent 4ca1e82 commit eccf749
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 18 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/obj)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/obj)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(INCLUDE_PATH "include")

add_library(visualizer STATIC src/visualizer.cpp)
target_include_directories(visualizer PUBLIC include)
add_executable(${PROJECT_NAME} src/engine.cpp)
add_executable(generator src/generator.cpp)

Expand All @@ -18,6 +21,9 @@ include_directories(${OpenGL_INCLUDE_DIRS})
link_directories(${OpenGL_LIBRARY_DIRS})
add_definitions(${OpenGL_DEFINITIONS})

target_include_directories(visualizer PUBLIC include)
target_include_directories(generator PUBLIC include)

if(NOT OPENGL_FOUND)
message(FATAL_ERROR "OPENGL not found!")
endif(NOT OPENGL_FOUND)
Expand Down
38 changes: 38 additions & 0 deletions include/figure_generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,46 @@

#include "figure.hpp"

/**
* @brief Generates a plane
*
* @param length the length of the plane
* @param divisions the number of divisions
*
* @return the generated plane
*/
std::unique_ptr<Figure> generatePlane(float length, int divisions);

/**
* @brief Generates a box
*
* @param dimension the dimension of the box
* @param divisions the number of divisions
*
* @return the generated box
*/
std::unique_ptr<Figure> generateBox(float dimension, int divisions);

/**
* @brief Generates a sphere
*
* @param radius the radius of the sphere
* @param slices the number of slices
* @param stacks the number of stacks
*
* @return the generated sphere
*/
std::unique_ptr<Figure> generateSphere(float radius, int slices, int stacks);

/**
* @brief Generates a cone
*
* @param radius the radius of the cone
* @param height the height of the cone
* @param slices the number of slices
* @param stacks the number of stacks
*
* @return the generated cone
*/
std::unique_ptr<Figure> generateCone(float radius, float height, int slices,
int stacks);
36 changes: 18 additions & 18 deletions src/generator.cpp
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
#include <string.h>

#include <iostream>

#include "../include/figure.hpp"
#include "../include/figure_generator.hpp"
#include "figure.hpp"
#include "figure_generator.hpp" // Include the figure_generator header

inline std::unique_ptr<Figure> generateFigure(int argc, char* argv[]) {
if (argc < 5) {
std::cerr << "Insufficient arguments\n";
return 0;
return nullptr;
}

std::string figureType = argv[argc - 1];
std::string figureName = argv[1];

if (figureType == "sphere.3d" && argc == 6) {
if (figureName == "sphere" && figureType == "sphere.3d" && argc == 6) {
// Generate Sphere
std::cout << "Generating Sphere\n";
return 0;
} else if (figureType == "box.3d" && argc == 5) {
return nullptr;
} else if (figureName == "box" && figureType == "box.3d" && argc == 5) {
// Generate Box
std::cout << "Generating Box\n";
return 0;
} else if (figureType == "plane.3d" && argc == 5) {
return nullptr;
} else if (figureName == "plane" && figureType == "plane.3d" && argc == 5) {
// Generate Plane
std::cout << "Generating Plane\n";
return 0;
} else if (figureType == "cone.3d" && argc == 7) {
std::cout << "Generating Plane\n"; // Added newline here
float length = std::stof(argv[2]);
int divisions = std::stoi(argv[3]);
// generatePlane(length, divisions);
return nullptr;
} else if (figureName == "cone" && figureType == "cone.3d" && argc == 7) {
// Generate Cone
std::cout << "Generating Cone\n";
return 0;
return nullptr;
} else {
std::cerr << "Invalid arguments\n";
return 0;
return nullptr;
}
return 0;
}

int main(int argc, char* argv[]) {
std::unique_ptr<Figure> figure = generateFigure(argc, argv);

return 0;
}
}

0 comments on commit eccf749

Please sign in to comment.