Mesh: [skip ci] fix several minor issues

This commit is contained in:
wmayer
2022-09-03 18:30:49 +02:00
parent 1d0e2a5526
commit 299397fd2f
5 changed files with 16 additions and 15 deletions

View File

@@ -176,6 +176,7 @@ bool Reader3MF::LoadBuild(XERCES_CPP_NAMESPACE_QUALIFIER DOMNodeList* nodes)
bool Reader3MF::LoadItems(XERCES_CPP_NAMESPACE_QUALIFIER DOMNodeList* nodes)
{
const std::size_t numEntries = 12;
if (!nodes)
return false;
@@ -193,8 +194,8 @@ bool Reader3MF::LoadItems(XERCES_CPP_NAMESPACE_QUALIFIER DOMNodeList* nodes)
boost::char_separator<char> sep(" ,");
boost::tokenizer<boost::char_separator<char> > tokens(transform, sep);
std::vector<std::string> token_results;
token_results.assign(tokens.begin(),tokens.end());
if (token_results.size() == 12) {
token_results.assign(tokens.begin(), tokens.end());
if (token_results.size() == numEntries) {
mat[0][0] = std::stod(token_results[0]);
mat[1][0] = std::stod(token_results[1]);
mat[2][0] = std::stod(token_results[2]);

View File

@@ -49,7 +49,7 @@ public:
*
* Passes an input stream to the constructor.
*/
Reader3MF(std::istream &str);
explicit Reader3MF(std::istream &str);
/*!
* \brief Reader3MF
@@ -57,7 +57,7 @@ public:
*
* Passes a file name to the constructor
*/
Reader3MF(const std::string &filename);
explicit Reader3MF(const std::string &filename);
/*!
* \brief Load the mesh from the input stream or file
* \return true on success and false otherwise

View File

@@ -54,14 +54,14 @@ public:
* Passes an output stream to the constructor.
* \param str
*/
Writer3MF(std::ostream &str);
explicit Writer3MF(std::ostream &str);
/*!
* \brief Writer3MF
* Passes a file name to the constructor
* \param filename
*/
Writer3MF(const std::string &filename);
explicit Writer3MF(const std::string &filename);
/*!
* \brief Add a mesh object resource to the 3MF file.

View File

@@ -151,7 +151,7 @@ MeshIO::Format MeshInput::getFormat(const char* FileName)
return MeshIO::Format::SMF;
}
else {
throw Base::FileException("File extension not supported",FileName);
throw Base::FileException("File extension not supported", FileName);
}
}
@@ -160,9 +160,9 @@ bool MeshInput::LoadAny(const char* FileName)
// ask for read permission
Base::FileInfo fi(FileName);
if (!fi.exists() || !fi.isFile())
throw Base::FileException("File does not exist",FileName);
throw Base::FileException("File does not exist", FileName);
if (!fi.isReadable())
throw Base::FileException("No permission on the file",FileName);
throw Base::FileException("No permission on the file", FileName);
Base::ifstream str(fi, std::ios::in | std::ios::binary);
@@ -200,7 +200,7 @@ bool MeshInput::LoadAny(const char* FileName)
ok = LoadPLY( str );
}
else {
throw Base::FileException("File extension not supported",FileName);
throw Base::FileException("File extension not supported", FileName);
}
return ok;
@@ -336,7 +336,7 @@ bool MeshInput::LoadOBJ (std::istream &rstrIn)
std::string line;
float fX, fY, fZ;
int i1=1,i2=1,i3=1,i4=1;
int i1=1, i2=1, i3=1, i4=1;
MeshFacet item;
if (!rstrIn || rstrIn.bad())
@@ -363,9 +363,9 @@ bool MeshInput::LoadOBJ (std::istream &rstrIn)
fX = (float)std::atof(what[1].first);
fY = (float)std::atof(what[4].first);
fZ = (float)std::atof(what[7].first);
float r = std::min<int>(std::atof(what[10].first),255) / 255.0f;
float g = std::min<int>(std::atof(what[11].first),255) / 255.0f;
float b = std::min<int>(std::atof(what[12].first),255) / 255.0f;
float r = std::min<int>(std::atof(what[10].first), 255) / 255.0f;
float g = std::min<int>(std::atof(what[11].first), 255) / 255.0f;
float b = std::min<int>(std::atof(what[12].first), 255) / 255.0f;
meshPoints.push_back(MeshPoint(Base::Vector3f(fX, fY, fZ)));
App::Color c(r,g,b);

View File

@@ -105,7 +105,7 @@ public:
bool LoadAny(const char* FileName);
/// Loads from a stream and the given format
bool LoadFormat(std::istream &str, MeshIO::Format fmt);
/** Loads an STL file either in binary or ASCII format.
/** Loads an STL file either in binary or ASCII format.
* Therefore the file header gets checked to decide if the file is binary or not.
*/
bool LoadSTL (std::istream &rstrIn);