fixed incorrect coord functionality

This commit is contained in:
2022-03-16 14:38:33 -05:00
parent 30490cb735
commit 5368ae466e
2 changed files with 38 additions and 34 deletions

View File

@@ -4,7 +4,7 @@
* @brief A C++ file containing the functionality need to read in a .stl file. * @brief A C++ file containing the functionality need to read in a .stl file.
* The ReadSTL class allows the min/max coordinates and total count of the STL * The ReadSTL class allows the min/max coordinates and total count of the STL
* facets be stored. The appropriate getters are also included. * facets be stored. The appropriate getters are also included.
* @version 1.0 * @version 1.1
* @date 2022-03-15 * @date 2022-03-15
* *
* @copyright Copyright (c) 2022 * @copyright Copyright (c) 2022
@@ -55,35 +55,13 @@ class ReadSTL {
// Facet header // Facet header
// Iterate past "normal" // Iterate past "normal"
lineStream >> token; lineStream >> token;
// Coord double value // No additional functionality required for facet normal vectors
double coord; // Normal X
// X Coord
lineStream >> token; lineStream >> token;
coord = stod(token); // Normal Y
if((coord < Xmin) || numFacet == 0) {
Xmin = coord;
}
if((coord > Xmax) || numFacet == 0) {
Xmax = coord;
}
// Y Coord
lineStream >> token; lineStream >> token;
coord = stod(token); // Z Normal
if((coord < Ymin) || numFacet == 0) {
Ymin = coord;
}
if((coord > Ymax) || numFacet == 0) {
Ymax = coord;
}
// Z Coord
lineStream >> token; lineStream >> token;
coord = stod(token);
if((coord < Zmin) || numFacet == 0) {
Zmin = coord;
}
if((coord > Zmax) || numFacet == 0) {
Zmax = coord;
}
// End facet header // End facet header
do { do {
// Get next line // Get next line
@@ -104,13 +82,35 @@ class ReadSTL {
lineStream >> token; lineStream >> token;
if(!token.compare("vertex")) { if(!token.compare("vertex")) {
// Process vertex // Process vertex
// No additional functionality required // Coord double value
// X coord double coord;
// X Coord
lineStream >> token; lineStream >> token;
// Y coord coord = stod(token);
if((coord < Xmin) || numFacet == 0) {
Xmin = coord;
}
if((coord > Xmax) || numFacet == 0) {
Xmax = coord;
}
// Y Coord
lineStream >> token; lineStream >> token;
// Z coord coord = stod(token);
if((coord < Ymin) || numFacet == 0) {
Ymin = coord;
}
if((coord > Ymax) || numFacet == 0) {
Ymax = coord;
}
// Z Coord
lineStream >> token; lineStream >> token;
coord = stod(token);
if((coord < Zmin) || numFacet == 0) {
Zmin = coord;
}
if((coord > Zmax) || numFacet == 0) {
Zmax = coord;
}
} // End vertex line } // End vertex line
} while(token.compare("endloop")); // Endloop } while(token.compare("endloop")); // Endloop
} }

View File

@@ -5,7 +5,7 @@
* ReadSTL class. The user enters the file location of the STL file as a * ReadSTL class. The user enters the file location of the STL file as a
* command line arg and the console returns the min/max coords of the solid's * command line arg and the console returns the min/max coords of the solid's
* facets as well as the total number of facets. * facets as well as the total number of facets.
* @version 1.0 * @version 1.1
* @date 2022-03-15 * @date 2022-03-15
* *
* @copyright Copyright (c) 2022 * @copyright Copyright (c) 2022
@@ -16,8 +16,12 @@
#include "ReadSTL.cpp" #include "ReadSTL.cpp"
using namespace std; using namespace std;
int main(int argc, char** argv) { //int main(int argc, char** argv) {
ReadSTL stl1(argv[1]); int main(){
// Debug mode
ReadSTL stl1("STLFiles/shape.stl");
// End debug mode
//ReadSTL stl1(argv[1]);
cout << endl << "File read successfully!" << endl; cout << endl << "File read successfully!" << endl;
// Formatted file info output // Formatted file info output
cout << "Facets in file: " << stl1.getNumFacets() << endl << endl; cout << "Facets in file: " << stl1.getNumFacets() << endl << endl;