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
All rights reserved.
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_DataItEnd(),
m_pModel(nullptr),
m_buffer(),
m_uiLine(0),
m_pIO(io),
m_progress(progress),
@ -89,8 +90,7 @@ ObjFileParser::ObjFileParser(IOStreamBuffer<char> &streamBuffer, const std::stri
parseFile(streamBuffer);
}
ObjFileParser::~ObjFileParser()
{
ObjFileParser::~ObjFileParser() {
}
void ObjFileParser::setBuffer(std::vector<char> &buffer) {
@ -127,96 +127,96 @@ void ObjFileParser::parseFile(IOStreamBuffer<char> &streamBuffer) {
// parse line
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;
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;
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;
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 'l':
case 'f': {
getFace(*m_DataIt == 'f' ? aiPrimitiveType_POLYGON : (*m_DataIt == 'l' ? aiPrimitiveType_LINE : aiPrimitiveType_POINT));
} break;
case 'p': // Parse a face, line or point statement
case 'l':
case 'f': {
getFace(*m_DataIt == 'f' ? aiPrimitiveType_POLYGON : (*m_DataIt == 'l' ? aiPrimitiveType_LINE : aiPrimitiveType_POINT));
} break;
case '#': // Parse a comment
{
getComment();
} break;
case '#': // Parse a comment
{
getComment();
} break;
case 'u': // Parse a material desc. setter
{
std::string name;
case 'u': // Parse a material desc. setter
{
std::string name;
getNameNoSpace(m_DataIt, m_DataItEnd, name);
getNameNoSpace(m_DataIt, m_DataItEnd, name);
size_t nextSpace = name.find(' ');
if (nextSpace != std::string::npos)
name = name.substr(0, nextSpace);
size_t nextSpace = name.find(' ');
if (nextSpace != std::string::npos)
name = name.substr(0, nextSpace);
if (name == "usemtl") {
getMaterialDesc();
}
} break;
if (name == "usemtl") {
getMaterialDesc();
}
} break;
case 'm': // Parse a material library or merging group ('mg')
{
std::string name;
case 'm': // Parse a material library or merging group ('mg')
{
std::string name;
getNameNoSpace(m_DataIt, m_DataItEnd, name);
getNameNoSpace(m_DataIt, m_DataItEnd, name);
size_t nextSpace = name.find(' ');
if (nextSpace != std::string::npos)
name = name.substr(0, nextSpace);
size_t nextSpace = name.find(' ');
if (nextSpace != std::string::npos)
name = name.substr(0, nextSpace);
if (name == "mg")
getGroupNumberAndResolution();
else if (name == "mtllib")
getMaterialLib();
else
goto pf_skip_line;
} break;
if (name == "mg")
getGroupNumberAndResolution();
else if (name == "mtllib")
getMaterialLib();
else
goto pf_skip_line;
} break;
case 'g': // Parse group name
{
getGroupName();
} break;
case 'g': // Parse group name
{
getGroupName();
} break;
case 's': // Parse group number
{
getGroupNumber();
} break;
case 's': // Parse group number
{
getGroupNumber();
} break;
case 'o': // Parse object name
{
getObjectName();
} break;
case 'o': // Parse object name
{
getObjectName();
} break;
default: {
pf_skip_line:
m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
} break;
default: {
pf_skip_line:
m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
} break;
}
}
}

View File

@ -85,6 +85,9 @@ public:
/// @brief Model getter.
ObjFile::Model *GetModel() const;
ObjFileParser(const ObjFileParser&) = delete;
ObjFileParser &operator=(const ObjFileParser& ) = delete;
protected:
/// Parse the loaded file
void parseFile(IOStreamBuffer<char> &streamBuffer);
@ -136,8 +139,6 @@ protected:
private:
// Copy and assignment constructor should be private
// because the class contains pointer to allocated memory
ObjFileParser(const ObjFileParser &rhs);
ObjFileParser &operator=(const ObjFileParser &rhs);
/// Default material name
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") {
return true;
} else if (!extension.length() || checkSig) {
}
if (!extension.length() || checkSig) {
if (!pIOHandler) {
return true;
}
static const char *tokens[] = { "ply" };
static const char *tokens[] = {
"ply"
};
return SearchFileHeaderForToken(pIOHandler, pFile, tokens, 1);
}

View File

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