Skip to content

Commit

Permalink
chore: run formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
JulioJPinto committed Feb 27, 2024
1 parent 84e2ac1 commit b5b0b14
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 54 deletions.
23 changes: 12 additions & 11 deletions generator/include/utils.hpp
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
#ifndef SOLAR_SYSTEM_UTILS_HPP
#define SOLAR_SYSTEM_UTILS_HPP

#include "utils.hpp"
#include <string>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>

#include "utils.hpp"

// Define Point struct
typedef struct Point {
float x;
float y;
float z;
float x;
float y;
float z;

// Constructor
Point(float x_val = 0.0f, float y_val = 0.0f, float z_val = 0.0f)
: x(x_val), y(y_val), z(z_val) {}
// Constructor
Point(float x_val = 0.0f, float y_val = 0.0f, float z_val = 0.0f)
: x(x_val), y(y_val), z(z_val) {}
} Point;

// Function to convert Point to string
std::string pointToString(const Point& point);

void saveToFile(const std::vector<Point>& points, const char* filepath);

#endif //SOLAR_SYSTEM_UTILS_HPP
#endif // SOLAR_SYSTEM_UTILS_HPP
62 changes: 32 additions & 30 deletions generator/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,43 +1,45 @@
#include <iostream>
#include <string>
#include "../include/shapes/plane.hpp"

#include "../include/shapes/cube.hpp"
#include "../include/shapes/plane.hpp"

void generateFigure(int argc, char* argv[]) {
if (argc < 5) {
std::cerr << "Insufficient arguments\n";
return;
}
if (argc < 5) {
std::cerr << "Insufficient arguments\n";
return;
}

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

if (figureName == "sphere" && argc == 6) {
// Generate Sphere
std::cout << "Generating Sphere\n";
} else if (figureName == "box" && argc == 5) {
// Generate Box
std::cout << "Generating Box\n";
float length = std::stof(argv[2]);
int divisions = std::stoi(argv[3]);
if (figureName == "sphere" && argc == 6) {
// Generate Sphere
std::cout << "Generating Sphere\n";
} else if (figureName == "box" && argc == 5) {
// Generate Box
std::cout << "Generating Box\n";
float length = std::stof(argv[2]);
int divisions = std::stoi(argv[3]);

generateCube(length, divisions, argv[4]);
} else if (figureName == "plane"&& argc == 5) {
// Generate Plane
std::cout << "Generating Plane\n"; // Added newline here
float length = std::stof(argv[2]);
int divisions = std::stoi(argv[3]);
generateCube(length, divisions, argv[4]);
} else if (figureName == "plane" && argc == 5) {
// Generate Plane
std::cout << "Generating Plane\n"; // Added newline here
float length = std::stof(argv[2]);
int divisions = std::stoi(argv[3]);

generatePlane(length, divisions, argv[4]); // Assuming saveToFile is available
} else if (figureName == "cone" && argc == 7) {
// Generate Cone
std::cout << "Generating Cone\n";
} else {
std::cerr << "Invalid arguments\n";
}
generatePlane(length, divisions,
argv[4]); // Assuming saveToFile is available
} else if (figureName == "cone" && argc == 7) {
// Generate Cone
std::cout << "Generating Cone\n";
} else {
std::cerr << "Invalid arguments\n";
}
}

int main(int argc, char* argv[]) {
generateFigure(argc, argv);
return 0;
generateFigure(argc, argv);
return 0;
}
29 changes: 16 additions & 13 deletions generator/src/utils.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
#include "utils.hpp"
#include <string>
#include <sstream>
#include <iostream>

#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>

void saveToFile(const std::vector<Point>& points, const char* filepath) { // Changed parameter type to const char*
std::ofstream file(filepath);
void saveToFile(
const std::vector<Point>& points,
const char* filepath) { // Changed parameter type to const char*
std::ofstream file(filepath);

if (file.is_open()) {
for (const auto& point : points) {
file << point.x << " " << point.y << " " << point.z << "\n";
}
file.close();
std::cout << "File saved successfully.\n";
} else {
std::cerr << "Unable to open file: " << filepath << std::endl;
if (file.is_open()) {
for (const auto& point : points) {
file << point.x << " " << point.y << " " << point.z << "\n";
}
file.close();
std::cout << "File saved successfully.\n";
} else {
std::cerr << "Unable to open file: " << filepath << std::endl;
}
}

0 comments on commit b5b0b14

Please sign in to comment.