Revert "Fix issue: OBJ import takes forever (#759)"

This commit is contained in:
Kim Kulling
2016-01-25 23:53:59 +01:00
parent d58f5613dd
commit 4633266c31
4 changed files with 245 additions and 176 deletions

View File

@@ -65,13 +65,14 @@ class ProgressHandler;
/// \brief Parser for a obj waveform file
class ObjFileParser {
public:
static const size_t Buffersize = 4096;
typedef std::vector<char> DataArray;
typedef std::vector<char>::iterator DataArrayIt;
typedef std::vector<char>::const_iterator ConstDataArrayIt;
public:
/// \brief Constructor with data array.
ObjFileParser(const std::vector<char> &Data,const std::string &strModelName, IOSystem* io, ProgressHandler* progress);
ObjFileParser(std::vector<char> &Data,const std::string &strModelName, IOSystem* io, ProgressHandler* progress);
/// \brief Destructor
~ObjFileParser();
/// \brief Model getter.
@@ -81,25 +82,27 @@ private:
/// Parse the loaded file
void parseFile();
/// Method to copy the new delimited word in the current line.
bool getNextFloat(ConstDataArrayIt &dataIt, const ConstDataArrayIt dataItEnd, float &result);
void copyNextWord(char *pBuffer, size_t length);
/// Method to copy the new line.
void copyNextLine(std::vector<char> &buffer, ConstDataArrayIt &dataIt, const ConstDataArrayIt dataItEnd);
void copyNextLine(char *pBuffer, size_t length);
/// Stores the vector
void getVector( std::vector<aiVector3D> &point3d_array, ConstDataArrayIt &dataIt, const ConstDataArrayIt dataItEnd);
void getVector( std::vector<aiVector3D> &point3d_array );
/// Stores the following 3d vector.
void getVector3(std::vector<aiVector3D> &point3d_array, ConstDataArrayIt &dataIt, const ConstDataArrayIt dataItEnd);
void getVector3( std::vector<aiVector3D> &point3d_array );
/// Stores the following 3d vector.
void getVector2(std::vector<aiVector2D> &point2d_array, ConstDataArrayIt &dataIt, const ConstDataArrayIt dataItEnd);
void getVector2(std::vector<aiVector2D> &point2d_array);
/// Stores the following face.
void getFace(aiPrimitiveType type, ConstDataArrayIt &dataIt, const ConstDataArrayIt dataItEnd);
void getFace(aiPrimitiveType type);
/// Reads the material description.
void getMaterialDesc(ConstDataArrayIt &dataIt, const ConstDataArrayIt dataItEnd);
void getMaterialDesc();
/// Gets a comment.
void getComment();
/// Gets a a material library.
void getMaterialLib(ConstDataArrayIt &dataIt, const ConstDataArrayIt dataItEnd);
void getMaterialLib();
/// Creates a new material.
void getNewMaterial(ConstDataArrayIt &dataIt, const ConstDataArrayIt dataItEnd);
void getNewMaterial();
/// Gets the group name from file.
void getGroupName(ConstDataArrayIt &dataIt, const ConstDataArrayIt dataItEnd);
void getGroupName();
/// Gets the group number from file.
void getGroupNumber();
/// Gets the group number and resolution from file.
@@ -107,7 +110,7 @@ private:
/// Returns the index of the material. Is -1 if not material was found.
int getMaterialIndex( const std::string &strMaterialName );
/// Parse object name
void getObjectName(ConstDataArrayIt &dataIt, const ConstDataArrayIt dataItEnd);
void getObjectName();
/// Creates a new object.
void createObject( const std::string &strObjectName );
/// Creates a new mesh.
@@ -125,12 +128,16 @@ private:
/// Default material name
static const std::string DEFAULT_MATERIAL;
//! Data buffer
const std::vector<char> &m_DataBuffer;
//! Iterator to current position in buffer
DataArrayIt m_DataIt;
//! Iterator to end position of buffer
DataArrayIt m_DataItEnd;
//! Pointer to model instance
ObjFile::Model *m_pModel;
//! Current line (for debugging)
unsigned int m_uiLine;
//! Helper buffer
char m_buffer[Buffersize];
/// Pointer to IO system instance.
IOSystem *m_pIO;
//! Pointer to progress handler