try to fix linux build.2

pull/3012/head
kkulling 2020-03-20 13:18:49 +01:00
parent dd58568d60
commit b40769c395
5 changed files with 87 additions and 84 deletions

View File

@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2020, assimp team Copyright (c) 2006-2020, assimp team
All rights reserved. All rights reserved.
Redistribution and use of this software in source and binary forms, Redistribution and use of this software in source and binary forms,

View File

@ -69,6 +69,7 @@ ObjFileParser::ObjFileParser(IOStreamBuffer<char> &streamBuffer, const std::stri
m_DataIt(), m_DataIt(),
m_DataItEnd(), m_DataItEnd(),
m_pModel(nullptr), m_pModel(nullptr),
m_buffer(),
m_uiLine(0), m_uiLine(0),
m_pIO(io), m_pIO(io),
m_progress(progress), m_progress(progress),
@ -89,8 +90,7 @@ ObjFileParser::ObjFileParser(IOStreamBuffer<char> &streamBuffer, const std::stri
parseFile(streamBuffer); parseFile(streamBuffer);
} }
ObjFileParser::~ObjFileParser() ObjFileParser::~ObjFileParser() {
{
} }
void ObjFileParser::setBuffer(std::vector<char> &buffer) { void ObjFileParser::setBuffer(std::vector<char> &buffer) {
@ -127,96 +127,96 @@ void ObjFileParser::parseFile(IOStreamBuffer<char> &streamBuffer) {
// parse line // parse line
switch (*m_DataIt) { switch (*m_DataIt) {
case 'v': // Parse a vertex texture coordinate case 'v': // Parse a vertex texture coordinate
{ {
++m_DataIt;
if (*m_DataIt == ' ' || *m_DataIt == '\t') {
size_t numComponents = getNumComponentsInDataDefinition();
if (numComponents == 3) {
// read in vertex definition
getVector3(m_pModel->m_Vertices);
} else if (numComponents == 4) {
// read in vertex definition (homogeneous coords)
getHomogeneousVector3(m_pModel->m_Vertices);
} else if (numComponents == 6) {
// read vertex and vertex-color
getTwoVectors3(m_pModel->m_Vertices, m_pModel->m_VertexColors);
}
} else if (*m_DataIt == 't') {
// read in texture coordinate ( 2D or 3D )
++m_DataIt; ++m_DataIt;
if (*m_DataIt == ' ' || *m_DataIt == '\t') { size_t dim = getTexCoordVector(m_pModel->m_TextureCoord);
size_t numComponents = getNumComponentsInDataDefinition(); m_pModel->m_TextureCoordDim = std::max(m_pModel->m_TextureCoordDim, (unsigned int)dim);
if (numComponents == 3) { } else if (*m_DataIt == 'n') {
// read in vertex definition // Read in normal vector definition
getVector3(m_pModel->m_Vertices); ++m_DataIt;
} else if (numComponents == 4) { getVector3(m_pModel->m_Normals);
// read in vertex definition (homogeneous coords) }
getHomogeneousVector3(m_pModel->m_Vertices); } break;
} else if (numComponents == 6) {
// read vertex and vertex-color
getTwoVectors3(m_pModel->m_Vertices, m_pModel->m_VertexColors);
}
} else if (*m_DataIt == 't') {
// read in texture coordinate ( 2D or 3D )
++m_DataIt;
size_t dim = getTexCoordVector(m_pModel->m_TextureCoord);
m_pModel->m_TextureCoordDim = std::max(m_pModel->m_TextureCoordDim, (unsigned int)dim);
} else if (*m_DataIt == 'n') {
// Read in normal vector definition
++m_DataIt;
getVector3(m_pModel->m_Normals);
}
} break;
case 'p': // Parse a face, line or point statement case 'p': // Parse a face, line or point statement
case 'l': case 'l':
case 'f': { case 'f': {
getFace(*m_DataIt == 'f' ? aiPrimitiveType_POLYGON : (*m_DataIt == 'l' ? aiPrimitiveType_LINE : aiPrimitiveType_POINT)); getFace(*m_DataIt == 'f' ? aiPrimitiveType_POLYGON : (*m_DataIt == 'l' ? aiPrimitiveType_LINE : aiPrimitiveType_POINT));
} break; } break;
case '#': // Parse a comment case '#': // Parse a comment
{ {
getComment(); getComment();
} break; } break;
case 'u': // Parse a material desc. setter case 'u': // Parse a material desc. setter
{ {
std::string name; std::string name;
getNameNoSpace(m_DataIt, m_DataItEnd, name); getNameNoSpace(m_DataIt, m_DataItEnd, name);
size_t nextSpace = name.find(' '); size_t nextSpace = name.find(' ');
if (nextSpace != std::string::npos) if (nextSpace != std::string::npos)
name = name.substr(0, nextSpace); name = name.substr(0, nextSpace);
if (name == "usemtl") { if (name == "usemtl") {
getMaterialDesc(); getMaterialDesc();
} }
} break; } break;
case 'm': // Parse a material library or merging group ('mg') case 'm': // Parse a material library or merging group ('mg')
{ {
std::string name; std::string name;
getNameNoSpace(m_DataIt, m_DataItEnd, name); getNameNoSpace(m_DataIt, m_DataItEnd, name);
size_t nextSpace = name.find(' '); size_t nextSpace = name.find(' ');
if (nextSpace != std::string::npos) if (nextSpace != std::string::npos)
name = name.substr(0, nextSpace); name = name.substr(0, nextSpace);
if (name == "mg") if (name == "mg")
getGroupNumberAndResolution(); getGroupNumberAndResolution();
else if (name == "mtllib") else if (name == "mtllib")
getMaterialLib(); getMaterialLib();
else else
goto pf_skip_line; goto pf_skip_line;
} break; } break;
case 'g': // Parse group name case 'g': // Parse group name
{ {
getGroupName(); getGroupName();
} break; } break;
case 's': // Parse group number case 's': // Parse group number
{ {
getGroupNumber(); getGroupNumber();
} break; } break;
case 'o': // Parse object name case 'o': // Parse object name
{ {
getObjectName(); getObjectName();
} break; } break;
default: { default: {
pf_skip_line: pf_skip_line:
m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine); m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
} break; } break;
} }
} }
} }

View File

@ -85,6 +85,9 @@ public:
/// @brief Model getter. /// @brief Model getter.
ObjFile::Model *GetModel() const; ObjFile::Model *GetModel() const;
ObjFileParser(const ObjFileParser&) = delete;
ObjFileParser &operator=(const ObjFileParser& ) = delete;
protected: protected:
/// Parse the loaded file /// Parse the loaded file
void parseFile(IOStreamBuffer<char> &streamBuffer); void parseFile(IOStreamBuffer<char> &streamBuffer);
@ -136,8 +139,6 @@ protected:
private: private:
// Copy and assignment constructor should be private // Copy and assignment constructor should be private
// because the class contains pointer to allocated memory // because the class contains pointer to allocated memory
ObjFileParser(const ObjFileParser &rhs);
ObjFileParser &operator=(const ObjFileParser &rhs);
/// Default material name /// Default material name
static const std::string DEFAULT_MATERIAL; static const std::string DEFAULT_MATERIAL;

View File

@ -105,11 +105,15 @@ bool PLYImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool c
if (extension == "ply") { if (extension == "ply") {
return true; return true;
} else if (!extension.length() || checkSig) { }
if (!extension.length() || checkSig) {
if (!pIOHandler) { if (!pIOHandler) {
return true; return true;
} }
static const char *tokens[] = { "ply" }; static const char *tokens[] = {
"ply"
};
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1); return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
} }

View File

@ -57,7 +57,7 @@ class X3DExporter {
Value() { Value() {
// empty // empty
} }
SAttribute(std::string name, std::string value) : SAttribute(const std::string &name, const std::string &value) :
Name(name), Name(name),
Value(value) { Value(value) {
// empty // empty