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.
* The ReadSTL class allows the min/max coordinates and total count of the STL
* facets be stored. The appropriate getters are also included.
* @version 1.0
* @version 1.1
* @date 2022-03-15
*
* @copyright Copyright (c) 2022
@@ -55,6 +55,33 @@ class ReadSTL {
// Facet header
// Iterate past "normal"
lineStream >> token;
// No additional functionality required for facet normal vectors
// Normal X
lineStream >> token;
// Normal Y
lineStream >> token;
// Z Normal
lineStream >> token;
// End facet header
do {
// Get next line
getline(inputfile, line);
// Set string stream to new line
lineStream.str(line);
// Clear sstream error state
lineStream.clear();
lineStream >> token;
if (!token.compare("outer")) {
do {
// Get next line
getline(inputfile, line);
// Set string stream to new line
lineStream.str(line);
// Clear sstream error state
lineStream.clear();
lineStream >> token;
if(!token.compare("vertex")) {
// Process vertex
// Coord double value
double coord;
// X Coord
@@ -84,33 +111,6 @@ class ReadSTL {
if((coord > Zmax) || numFacet == 0) {
Zmax = coord;
}
// End facet header
do {
// Get next line
getline(inputfile, line);
// Set string stream to new line
lineStream.str(line);
// Clear sstream error state
lineStream.clear();
lineStream >> token;
if (!token.compare("outer")) {
do {
// Get next line
getline(inputfile, line);
// Set string stream to new line
lineStream.str(line);
// Clear sstream error state
lineStream.clear();
lineStream >> token;
if(!token.compare("vertex")) {
// Process vertex
// No additional functionality required
// X coord
lineStream >> token;
// Y coord
lineStream >> token;
// Z coord
lineStream >> token;
} // End vertex line
} 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
* command line arg and the console returns the min/max coords of the solid's
* facets as well as the total number of facets.
* @version 1.0
* @version 1.1
* @date 2022-03-15
*
* @copyright Copyright (c) 2022
@@ -16,8 +16,12 @@
#include "ReadSTL.cpp"
using namespace std;
int main(int argc, char** argv) {
ReadSTL stl1(argv[1]);
//int main(int argc, char** argv) {
int main(){
// Debug mode
ReadSTL stl1("STLFiles/shape.stl");
// End debug mode
//ReadSTL stl1(argv[1]);
cout << endl << "File read successfully!" << endl;
// Formatted file info output
cout << "Facets in file: " << stl1.getNumFacets() << endl << endl;