-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
84e2ac1
commit b5b0b14
Showing
3 changed files
with
60 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |