Skip to content
Snippets Groups Projects
Commit 8bf1634b authored by Karsten Rink's avatar Karsten Rink Committed by Tom Fischer
Browse files

renaming enum classes

parent 63d7fd87
No related branches found
No related tags found
No related merge requests found
...@@ -33,10 +33,9 @@ const std::string mat_id_name = "MaterialIDs"; ...@@ -33,10 +33,9 @@ const std::string mat_id_name = "MaterialIDs";
const std::string eof_error = "Error: Unexpected end of file."; const std::string eof_error = "Error: Unexpected end of file.";
GocadAsciiReader::GocadAsciiReader() GocadAsciiReader::GocadAsciiReader()
: _export_type(GOCAD_DATA_TYPE::ALL) : _export_type(GocadDataType::ALL) {}
{}
GocadAsciiReader::GocadAsciiReader(GOCAD_DATA_TYPE const t) GocadAsciiReader::GocadAsciiReader(GocadDataType const t)
: _export_type(t) : _export_type(t)
{} {}
...@@ -75,20 +74,20 @@ bool GocadAsciiReader::readFile( ...@@ -75,20 +74,20 @@ bool GocadAsciiReader::readFile(
return false; return false;
} }
GOCAD_DATA_TYPE type; GocadDataType type;
while ((type = datasetFound(in)) != GOCAD_DATA_TYPE::UNDEFINED) while ((type = datasetFound(in)) != GocadDataType::UNDEFINED)
{ {
if (_export_type != GOCAD_DATA_TYPE::ALL && type != _export_type) if (_export_type != GocadDataType::ALL && type != _export_type)
{ {
skipToEND(in); skipToEND(in);
continue; continue;
} }
if (type == GOCAD_DATA_TYPE::VSET || type == GOCAD_DATA_TYPE::MODEL3D) if (type == GocadDataType::VSET || type == GocadDataType::MODEL3D)
{ {
if (!skipToEND(in)) if (!skipToEND(in))
{ {
std::string const t = (type == GOCAD_DATA_TYPE::VSET) ? "VSet" : "Model3D"; std::string const t = (type == GocadDataType::VSET) ? "VSet" : "Model3D";
ERR("Parsing of type %s is not implemented. Skipping section.", t); ERR("Parsing of type %s is not implemented. Skipping section.", t);
return false; return false;
} }
...@@ -110,7 +109,7 @@ bool GocadAsciiReader::readFile( ...@@ -110,7 +109,7 @@ bool GocadAsciiReader::readFile(
} }
MeshLib::Mesh* GocadAsciiReader::readData(std::ifstream& in, MeshLib::Mesh* GocadAsciiReader::readData(std::ifstream& in,
GOCAD_DATA_TYPE const& type, GocadDataType const& type,
std::string& mesh_name) std::string& mesh_name)
{ {
if (!parseHeader(in, mesh_name)) if (!parseHeader(in, mesh_name))
...@@ -160,7 +159,7 @@ MeshLib::Mesh* GocadAsciiReader::readData(std::ifstream& in, ...@@ -160,7 +159,7 @@ MeshLib::Mesh* GocadAsciiReader::readData(std::ifstream& in,
return nullptr; return nullptr;
} }
} }
else if (type == GOCAD_DATA_TYPE::PLINE && str[0] == "ILINE") else if (type == GocadDataType::PLINE && str[0] == "ILINE")
{ {
std::vector<MeshLib::Node*> nodes; std::vector<MeshLib::Node*> nodes;
std::vector<MeshLib::Element*> elems; std::vector<MeshLib::Element*> elems;
...@@ -174,7 +173,7 @@ MeshLib::Mesh* GocadAsciiReader::readData(std::ifstream& in, ...@@ -174,7 +173,7 @@ MeshLib::Mesh* GocadAsciiReader::readData(std::ifstream& in,
} }
return new MeshLib::Mesh(mesh_name, nodes, elems, mesh_prop); return new MeshLib::Mesh(mesh_name, nodes, elems, mesh_prop);
} }
else if (type == GOCAD_DATA_TYPE::TSURF && str[0] == "TFACE") else if (type == GocadDataType::TSURF && str[0] == "TFACE")
{ {
std::vector<MeshLib::Node*> nodes; std::vector<MeshLib::Node*> nodes;
std::vector<MeshLib::Element*> elems; std::vector<MeshLib::Element*> elems;
...@@ -198,7 +197,7 @@ MeshLib::Mesh* GocadAsciiReader::readData(std::ifstream& in, ...@@ -198,7 +197,7 @@ MeshLib::Mesh* GocadAsciiReader::readData(std::ifstream& in,
return nullptr; return nullptr;
} }
GOCAD_DATA_TYPE GocadAsciiReader::datasetFound(std::ifstream& in) const GocadDataType GocadAsciiReader::datasetFound(std::ifstream& in) const
{ {
std::string line; std::string line;
while (std::getline(in, line)) while (std::getline(in, line))
...@@ -210,27 +209,27 @@ GOCAD_DATA_TYPE GocadAsciiReader::datasetFound(std::ifstream& in) const ...@@ -210,27 +209,27 @@ GOCAD_DATA_TYPE GocadAsciiReader::datasetFound(std::ifstream& in) const
if (line.substr(0, 10) == "GOCAD VSet") if (line.substr(0, 10) == "GOCAD VSet")
{ {
return GOCAD_DATA_TYPE::VSET; return GocadDataType::VSET;
} }
else if (line.substr(0, 11) == "GOCAD PLine") else if (line.substr(0, 11) == "GOCAD PLine")
{ {
return GOCAD_DATA_TYPE::PLINE; return GocadDataType::PLINE;
} }
else if (line.substr(0, 11) == "GOCAD TSurf") else if (line.substr(0, 11) == "GOCAD TSurf")
{ {
return GOCAD_DATA_TYPE::TSURF; return GocadDataType::TSURF;
} }
else if (line.substr(0, 13) == "GOCAD Model3d") else if (line.substr(0, 13) == "GOCAD Model3d")
{ {
return GOCAD_DATA_TYPE::MODEL3D; return GocadDataType::MODEL3D;
} }
else else
{ {
ERR("No known identifier found..."); ERR("No known identifier found...");
return GOCAD_DATA_TYPE::UNDEFINED; return GocadDataType::UNDEFINED;
} }
} }
return GOCAD_DATA_TYPE::UNDEFINED; return GocadDataType::UNDEFINED;
} }
bool GocadAsciiReader::isCommentLine(std::string const& str) const bool GocadAsciiReader::isCommentLine(std::string const& str) const
...@@ -439,7 +438,7 @@ bool GocadAsciiReader::parseNodes( ...@@ -439,7 +438,7 @@ bool GocadAsciiReader::parseNodes(
std::map<std::size_t, std::size_t>& node_id_map, std::map<std::size_t, std::size_t>& node_id_map,
MeshLib::Properties& mesh_prop) MeshLib::Properties& mesh_prop)
{ {
NODE_TYPE t = NODE_TYPE::UNSPECIFIED; NodeType t = NodeType::UNSPECIFIED;
double value; double value;
std::vector<std::string> const array_names = std::vector<std::string> const array_names =
mesh_prop.getPropertyVectorNames(); mesh_prop.getPropertyVectorNames();
...@@ -472,11 +471,11 @@ bool GocadAsciiReader::parseNodes( ...@@ -472,11 +471,11 @@ bool GocadAsciiReader::parseNodes(
} }
std::stringstream sstr(line); std::stringstream sstr(line);
if (line.substr(0, 4) == "VRTX" && t != NODE_TYPE::PVRTX) if (line.substr(0, 4) == "VRTX" && t != NodeType::PVRTX)
{ {
nodes.push_back(createNode(sstr)); nodes.push_back(createNode(sstr));
} }
else if (line.substr(0, 5) == "PVRTX" && t != NODE_TYPE::VRTX) else if (line.substr(0, 5) == "PVRTX" && t != NodeType::VRTX)
{ {
nodes.push_back(createNode(sstr)); nodes.push_back(createNode(sstr));
for (std::string const& name : array_names) for (std::string const& name : array_names)
......
...@@ -27,7 +27,7 @@ namespace FileIO ...@@ -27,7 +27,7 @@ namespace FileIO
namespace Gocad namespace Gocad
{ {
enum class GOCAD_DATA_TYPE enum class GocadDataType
{ {
UNDEFINED, UNDEFINED,
VSET, VSET,
...@@ -43,7 +43,7 @@ public: ...@@ -43,7 +43,7 @@ public:
explicit GocadAsciiReader(); explicit GocadAsciiReader();
/// Constructor taking a specific data type (will only export that type) /// Constructor taking a specific data type (will only export that type)
explicit GocadAsciiReader(GOCAD_DATA_TYPE const t); explicit GocadAsciiReader(GocadDataType const t);
GocadAsciiReader(GocadAsciiReader&& src) = delete; GocadAsciiReader(GocadAsciiReader&& src) = delete;
GocadAsciiReader(GocadAsciiReader const& src) = delete; GocadAsciiReader(GocadAsciiReader const& src) = delete;
...@@ -55,13 +55,14 @@ public: ...@@ -55,13 +55,14 @@ public:
private: private:
/// Reads one mesh contained in the file (there may be more than one!) /// Reads one mesh contained in the file (there may be more than one!)
MeshLib::Mesh* readData(std::ifstream& in, GOCAD_DATA_TYPE const& type, std::string& mesh_name); MeshLib::Mesh* readData(std::ifstream& in, GocadDataType const& type,
std::string& mesh_name);
/// Checks if the current line is a comment /// Checks if the current line is a comment
bool isCommentLine(std::string const& str) const; bool isCommentLine(std::string const& str) const;
/// Checks if a GoCAD identifier is found at the current stream position. /// Checks if a GoCAD identifier is found at the current stream position.
GOCAD_DATA_TYPE datasetFound(std::ifstream& in) const; GocadDataType datasetFound(std::ifstream& in) const;
/// Parses the HEADER section (everything except the name is ignored right now) /// Parses the HEADER section (everything except the name is ignored right now)
bool parseHeader(std::ifstream& in, std::string& mesh_name); bool parseHeader(std::ifstream& in, std::string& mesh_name);
...@@ -112,14 +113,14 @@ private: ...@@ -112,14 +113,14 @@ private:
void clearData(std::vector<MeshLib::Node*>& nodes, void clearData(std::vector<MeshLib::Node*>& nodes,
std::vector<MeshLib::Element*>& elems); std::vector<MeshLib::Element*>& elems);
enum class NODE_TYPE enum class NodeType
{ {
UNSPECIFIED, UNSPECIFIED,
VRTX, VRTX,
PVRTX PVRTX
}; };
GOCAD_DATA_TYPE _export_type; GocadDataType _export_type;
}; // end class GocadAsciiReader }; // end class GocadAsciiReader
} // end namespace Gocad } // end namespace Gocad
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment